// File: /workspace/github_cpp_makefile_star2_O2/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 0x61110
leaq 0x26035(%rip), %rcx     # 0x870b8
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x61098
movq (%rsi), %rax
movq 0x78(%rax), %rax
retq
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x610a9
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 0x610d6
movq (%rsi), %rax
movq 0x58(%rax), %rax
retq
movl 0x18(%rdi), %eax
cmpq $0x3, %rax
ja 0x61110
movslq 0x8(%rdi), %rcx
movq 0x10(%rsi), %rdx
movq 0x40(%rdx), %rdx
movq (%rdx,%rcx,8), %rcx
leaq 0x25fed(%rip), %rdx     # 0x870e8
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
cmpq $0x0, 0x18(%rcx)
je 0x61177
movq 0x30(%rcx), %rax
retq
xorl %eax, %eax
retq
movq 0x8(%rsi), %rax
testq %rax, %rax
jne 0x6111f
movq (%rsi), %rax
movq 0x68(%rax), %rax
retq
movq 0x8(%rdi), %rax
retq
movl 0x10(%rcx), %eax
retq
movq (%rsi), %rax
movq 0x8(%rcx), %rsi
movq 0x18(%rcx), %rdx
cmpq 0x8(%rax), %rsi
je 0x61158
movzwl 0x10(%rdi), %eax
testq %rdx, %rdx
je 0x61181
addq 0x38(%rcx), %rax
retq
cmpq $0x0, 0x18(%rcx)
je 0x6117c
movq 0x38(%rcx), %rax
retq
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
retq
movq 0x8(%rcx), %rax
retq
movq 0x20(%rcx), %rax
retq
addq 0x20(%rcx), %rax
retq