// File: /workspace/github_cpp_makefile_star2_O1/jstaursky[P]hutch/src/Sleigh/semantics.cc
// Function: ConstTpl::fix(ParserWalker const&) const
uintb ConstTpl::fix(const ParserWalker &walker) const

{ // Get the value of the ConstTpl in context
  // NOTE: if the property is dynamic this returns the property
  // of the temporary storage
  switch(type) {
  case j_start:
    return walker.getAddr().getOffset(); // Fill in starting address placeholder with real address
  case j_next:
    return walker.getNaddr().getOffset(); // Fill in next address placeholder with real address
  case j_flowref:
    return walker.getRefAddr().getOffset();
  case j_flowref_size:
    return walker.getRefAddr().getAddrSize();
  case j_flowdest:
    return walker.getDestAddr().getOffset();
  case j_flowdest_size:
    return walker.getDestAddr().getAddrSize();
  case j_curspace_size:
    return walker.getCurSpace()->getAddrSize();
  case j_curspace:
    return (uintb)(uintp)walker.getCurSpace();
  case handle:
    {
      const FixedHandle &hand(walker.getFixedHandle(value.handle_index));
      switch(select) {
      case v_space:
	if (hand.offset_space == (AddrSpace *)0)
	  return (uintb)(uintp)hand.space;
	return (uintb)(uintp)hand.temp_space;
      case v_offset:
	if (hand.offset_space==(AddrSpace *)0)
	  return hand.offset_offset;
	return hand.temp_offset;
      case v_size:
	return hand.size;
      case v_offset_plus:
	if (hand.space != walker.getConstSpace()) { // If we are not a constant
	  if (hand.offset_space==(AddrSpace *)0)
	    return hand.offset_offset + (value_real&0xffff); // Adjust offset by truncation amount
	  return hand.temp_offset + (value_real&0xffff);
	}
	else {			// If we are a constant, we want to return a shifted value
	  uintb val;
	  if (hand.offset_space==(AddrSpace *)0)
	    val = hand.offset_offset;
	  else
	    val = hand.temp_offset;
	  val >>= 8 * (value_real>>16);
	  return val;
	}
      }
      break;
    }
  case j_relative:
  case real:
    return value_real;
  case spaceid:
    return (uintb)(uintp)value.spaceid;
  }
  return 0;			// Should never reach here
}

// Assembly:
movl (%rdi), %eax
cmpq $0xb, %rax
ja 0x54b2c
leaq 0x2b6bd(%rip), %rcx     # 0x800d8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x54a30
movq (%rsi), %rax
movq 0x78(%rax), %rax
retq
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x54a41
movq (%rsi), %rax
movq 0x70(%rax), %rax
movslq 0x58(%rax), %rax
retq
movq 0x10(%rdi), %rax
retq
movq (%rsi), %rax
movq 0x50(%rax), %rax
movl 0x58(%rax), %eax
retq
movq (%rsi), %rax
movq 0x50(%rax), %rax
retq
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x54a6e
movq (%rsi), %rax
movq 0x58(%rax), %rax
retq
movl 0x18(%rdi), %eax
cmpq $0x3, %rax
ja 0x54af1
movslq 0x8(%rdi), %rcx
movq 0x10(%rsi), %rdx
movq 0x40(%rdx), %rdx
movq (%rdx,%rcx,8), %rcx
leaq 0x2b675(%rip), %rdx     # 0x80108
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
cmpq $0x0, 0x18(%rcx)
je 0x54b15
movq 0x30(%rcx), %rax
jmp 0x54b25
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x54ab5
movq (%rsi), %rax
movq 0x68(%rax), %rax
retq
movq 0x8(%rdi), %rax
retq
movl 0x10(%rcx), %eax
jmp 0x54b25
movq (%rsi), %rax
movq 0x8(%rcx), %rsi
movq 0x18(%rcx), %rdx
cmpq 0x8(%rax), %rsi
je 0x54af5
movzwl 0x10(%rdi), %eax
testq %rdx, %rdx
je 0x54b21
addq 0x38(%rcx), %rax
jmp 0x54b25
cmpq $0x0, 0x18(%rcx)
je 0x54b1b
movq 0x38(%rcx), %rax
jmp 0x54b25
xorl %ecx, %ecx
jmp 0x54b27
leaq 0x38(%rcx), %rax
addq $0x20, %rcx
testq %rdx, %rdx
cmovneq %rax, %rcx
movq (%rcx), %rax
movl 0x10(%rdi), %ecx
shrl $0xd, %ecx
andb $-0x8, %cl
shrq %cl, %rax
jmp 0x54b25
movq 0x8(%rcx), %rax
jmp 0x54b25
movq 0x20(%rcx), %rax
jmp 0x54b25
addq 0x20(%rcx), %rax
movb $0x1, %cl
testb %cl, %cl
je 0x54b2c
retq
xorl %eax, %eax
retq
nop