// File: jstaursky[P]hutch/src/Sleigh/context.cc
// Function: ParserContext::applyCommits()
void ParserContext::applyCommits(void)

{
  if (contextcommit.empty()) return;
  ParserWalker walker(this);
  walker.baseState();

  vector<ContextSet>::iterator iter;

  for(iter=contextcommit.begin();iter!=contextcommit.end();++iter) {
    TripleSymbol *sym = (*iter).sym;
    Address commitaddr;
    if (sym->getType() == SleighSymbol::operand_symbol) {
      // The value for an OperandSymbol is probabably already
      // calculated, we just need to find the right
      // tree node of the state
      int4 i = ((OperandSymbol *)sym)->getIndex();
      FixedHandle &h((*iter).point->resolve[i]->hand);
      commitaddr = Address(h.space,h.offset_offset);
    }
    else {
      FixedHandle hand;
      sym->getFixedHandle(hand,walker);
      commitaddr = Address(hand.space,hand.offset_offset);
    }
    if (commitaddr.isConstant()) {
      // If the symbol handed to globalset was a computed value, the getFixedHandle calculation
      // will return a value in the constant space. If this is a case, we explicitly convert the
      // offset into the current address space
      uintb newoff = AddrSpace::addressToByte(commitaddr.getOffset(),addr.getSpace()->getWordSize());
      commitaddr = Address(addr.getSpace(),newoff);
    }

				// Commit context change
    if ((*iter).flow)		// The context flows
      contcache->setContext(commitaddr,(*iter).num,(*iter).mask,(*iter).value);
    else {  // Set the context so that is doesn't flow
      Address nextaddr = commitaddr + 1;
      if (nextaddr.getOffset() < commitaddr.getOffset())
	contcache->setContext(commitaddr,(*iter).num,(*iter).mask,(*iter).value);
      else
	contcache->setContext(commitaddr,nextaddr,(*iter).num,(*iter).mask,(*iter).value);
    }
  }
}

// Assembly:
subq $0x1b8, %rsp            # imm = 0x1B8
movq %rdi, 0x1b0(%rsp)
movq 0x1b0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
addq $0x38, %rdi
callq 0xd7590
testb $0x1, %al
jne 0x106c7b
jmp 0x106c80
jmp 0x107023
movq 0x48(%rsp), %rsi
leaq 0x110(%rsp), %rdi
callq 0xd7160
leaq 0x110(%rsp), %rdi
callq 0xe07e0
leaq 0x108(%rsp), %rdi
callq 0xd3900
movq 0x48(%rsp), %rdi
addq $0x38, %rdi
callq 0xd3740
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0x108(%rsp)
movq 0x48(%rsp), %rdi
addq $0x38, %rdi
callq 0xcf6d0
movq %rax, 0xf8(%rsp)
leaq 0x108(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0xd7ea0
testb $0x1, %al
jne 0x106d06
jmp 0x107023
leaq 0x108(%rsp), %rdi
callq 0xdc160
movq (%rax), %rax
movq %rax, 0xf0(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xe1dc0
movq 0xf0(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpl $0x8, %eax
jne 0x106dc2
movq 0xf0(%rsp), %rdi
callq 0xd91d0
movl %eax, 0xdc(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movq 0x8(%rax), %rdi
addq $0x40, %rdi
movslq 0xdc(%rsp), %rsi
callq 0xd3290
movq (%rax), %rax
addq $0x8, %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rax
movq (%rax), %rsi
movq 0xd0(%rsp), %rax
movq 0x18(%rax), %rdx
leaq 0xc0(%rsp), %rdi
callq 0xd81b0
leaq 0xe0(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0xdafc0
jmp 0x106e0c
movq 0xf0(%rsp), %rdi
movq (%rdi), %rax
leaq 0x88(%rsp), %rsi
leaq 0x110(%rsp), %rdx
callq *0x40(%rax)
movq 0x88(%rsp), %rsi
movq 0xa0(%rsp), %rdx
leaq 0x78(%rsp), %rdi
callq 0xd81b0
leaq 0xe0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xdafc0
leaq 0xe0(%rsp), %rdi
callq 0xd55a0
testb $0x1, %al
jne 0x106e1f
jmp 0x106e8a
leaq 0xe0(%rsp), %rdi
callq 0xe03b0
movq 0x48(%rsp), %rdi
movq %rax, 0x40(%rsp)
addq $0x50, %rdi
callq 0xd9cf0
movq %rax, %rdi
callq 0xde1c0
movq 0x40(%rsp), %rdi
movl %eax, %esi
callq 0xe2550
movq 0x48(%rsp), %rdi
movq %rax, 0x70(%rsp)
addq $0x50, %rdi
callq 0xd9cf0
movq %rax, %rsi
movq 0x70(%rsp), %rdx
leaq 0x60(%rsp), %rdi
callq 0xd81b0
leaq 0xe0(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0xdafc0
leaq 0x108(%rsp), %rdi
callq 0xdc160
testb $0x1, 0x1c(%rax)
je 0x106f03
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x30(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x10(%rax), %eax
movl %eax, 0x38(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x14(%rax), %eax
movl %eax, 0x3c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movq 0x30(%rsp), %rdi
movl 0x38(%rsp), %edx
movl 0x3c(%rsp), %ecx
movl 0x18(%rax), %r8d
leaq 0xe0(%rsp), %rsi
callq 0xd2d10
jmp 0x10700f
leaq 0x50(%rsp), %rdi
leaq 0xe0(%rsp), %rsi
movl $0x1, %edx
callq 0xd8150
leaq 0x50(%rsp), %rdi
callq 0xe03b0
movq %rax, 0x28(%rsp)
leaq 0xe0(%rsp), %rdi
callq 0xe03b0
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x106fa6
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x10(%rax), %eax
movl %eax, 0x20(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x14(%rax), %eax
movl %eax, 0x24(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movq 0x18(%rsp), %rdi
movl 0x20(%rsp), %edx
movl 0x24(%rsp), %ecx
movl 0x18(%rax), %r8d
leaq 0xe0(%rsp), %rsi
callq 0xd2d10
jmp 0x10700d
movq 0x48(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x10(%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movl 0x14(%rax), %eax
movl %eax, 0x14(%rsp)
leaq 0x108(%rsp), %rdi
callq 0xdc160
movq 0x8(%rsp), %rdi
movl 0x10(%rsp), %ecx
movl 0x14(%rsp), %r8d
movl 0x18(%rax), %r9d
leaq 0xe0(%rsp), %rsi
leaq 0x50(%rsp), %rdx
callq 0xce1c0
jmp 0x10700f
jmp 0x107011
leaq 0x108(%rsp), %rdi
callq 0xde610
jmp 0x106cd2
addq $0x1b8, %rsp            # imm = 0x1B8
retq
nopl (%rax,%rax)