// File: /workspace/github_cpp_makefile_star2_O2/menhits[P]phplus/src/AstNode.cpp
// Function: AstToken::resolveAction()
void AstToken::resolveAction()
{
	//error.log("resolveAction called for token "+token->getText(), JSYK, token);
	
	if (token->getType()==TokenData::IDENTIFIER || token->getType()==TokenData::OPERATOR)
	{
		if (token->getOp() && !token->getOp()->isOverloadable())
		{
			throw PhplusError("non overloadable operator in AstToken, it should have been removed and processed by the parser", INTERNAL_ERROR, token);
		}
		
		/*
		if (inLeftType->getType()==TypeBase::TUPLE && inLeftType->getSubType(token->getText()).type!=nullptr)
		{
			if (inRightType->isVoid())
			{
				action=getElemFromTupleAction(inLeftType, token->getText());
				return;
			}
			else
			{
				throw PhplusError("sorry, Phplus does not yet support mutating tuples", SOURCE_ERROR, token);
			}
		}
		*/
		
		action=ns->getActionForTokenWithInput(token, inLeftType, inRightType, dynamic, true, token);
		
		/*
		try
		{
			//error.log("looking for "+token->getText()+" in\n"+ns->getStringWithParents(), JSYK, token);
			action=ns->getActionForTokenWithInput(token, inLeftType, inRightType, dynamic);
		}
		catch (IdNotFoundError err)
		{
			if (token->getType()==TokenData::OPERATOR)
			{
				throw PhplusError("unknown overload for "+inLeftType->getString()+" "+token->getText()+" "+inRightType->getString()+"'", SOURCE_ERROR, token);
			}
			else if (token->getType()==TokenData::IDENTIFIER)
			{
				vector<Action> actions;
				ns->getActions(token->getText(), actions, dynamic);
				
				if (actions.size()>0) // if there are actions with the requested name that didn't match the type
				{
					string posibleInputs="the following is the inputs it can take:";
					
					for (int i=0; i<(int)actions.size(); i++)
					{
						posibleInputs+="\n    ";
						posibleInputs+=actions[i]->getInLeftType()->getString()+" . "+actions[i]->getInRightType()->getString()+" -> "+actions[i]->getReturnType()->getString();
					}
					
					throw PhplusError(
						"'"+token->getText()+"' can not take input of type "+
						inLeftType->getString()+" . "+inRightType->getString()+"\n"+
						posibleInputs,
						SOURCE_ERROR, token);
				}
			}
			
			if (inRightType->getType()==TypeBase::METATYPE)
			{
				throw PhplusError("metatype handeling in "+FUNC+" not yet implemented", INTERNAL_ERROR, token);
			}
			else if (inRightType->isVoid())
			{
				//throw PhplusError("unknown identifier '"+token->getText()+"' (var can not be made bc right in type is "+type->getString()+")", SOURCE_ERROR, token);
				throw PhplusError("unknown identifier '"+token->getText()+"'", SOURCE_ERROR, token);
			}
			else if (!inRightType->isCreatable())
			{
				throw PhplusError("cannot create variable '"+token->getText()+"' of type {"+inRightType->getString()+"}", SOURCE_ERROR, token);
			}
			
			ns->addVar(inRightType, token->getText());
			
			try
			{
				action=ns->getActionForTokenWithInput(token, inLeftType, inRightType, dynamic);
			}
			catch (IdNotFoundError err)
			{
				throw err.toPhplusError(token);
			}
		}
		*/
	}
	else if (token->getType()==TokenData::LITERAL || token->getType()==TokenData::STRING_LITERAL)
	{
		if (!inLeftType->isVoid() || !inRightType->isVoid())
		{
			throw PhplusError("a literal can not be given an input", SOURCE_ERROR, token);
		}
		
		action=resolveLiteral(token);
	}
	else
	{
		throw PhplusError("AstToken givin invalid token '"+token->getText()+"' of type "+TokenData::typeToString(token->getType()), INTERNAL_ERROR, token);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x168, %rsp            # imm = 0x168
movq %rdi, %r14
leaq 0x88(%rdi), %r12
movq 0x88(%rdi), %rsi
movl 0x38(%rsi), %eax
leal -0x3(%rax), %ecx
cmpl $0x2, %ecx
jb 0x10b51
cmpl $0x5, %eax
je 0x10a8f
cmpl $0x2, %eax
jne 0x10ceb
addq $0x40, %rsi
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0xc950
cmpq $0x0, (%r15)
je 0x10bb7
movq (%r12), %rsi
addq $0x40, %rsi
leaq 0x78(%rsp), %r15
movq %r15, %rdi
callq 0xc950
movq (%r15), %rax
leaq 0x80(%rsp), %rdi
movb 0x24(%rax), %bl
callq 0xc984
leaq 0x10(%rsp), %rdi
callq 0xc984
testb %bl, %bl
jne 0x10bc1
pushq $0x38
popq %rdi
callq 0xa1b0
movq %rax, %r14
leaq 0x439cd(%rip), %rsi     # 0x544c3
leaq 0x148(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xa150
leaq 0xb8(%rsp), %r15
movq %r15, %rdi
movq %r12, %rsi
callq 0x12e2e
movb $0x1, %bpl
leaq 0x148(%rsp), %rsi
pushq $0x3
popq %rdx
movq %r14, %rdi
movq %r15, %rcx
callq 0x19f06
xorl %ebp, %ebp
leaq 0x66a5b(%rip), %rsi     # 0x77598
leaq 0xb4e(%rip), %rdx       # 0x11692
movq %r14, %rdi
callq 0xa4e0
jmp 0x10daa
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
testb %al, %al
je 0x10c7f
movq 0x38(%r14), %rdi
movq (%rdi), %rax
callq *0x28(%rax)
testb %al, %al
je 0x10c7f
leaq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12e2e
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x3c081
addq $0x48, %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x13816
leaq 0x10(%rsp), %rdi
callq 0xc984
leaq 0x40(%rsp), %rdi
jmp 0x10c68
leaq 0x10(%rsp), %rdi
callq 0xc984
movq 0x70(%r14), %r15
leaq 0x28(%rsp), %rdi
movq %r12, %rsi
callq 0x12e2e
leaq 0x28(%r14), %rsi
leaq 0x68(%rsp), %r13
movq %r13, %rdi
callq 0x12c0a
leaq 0x38(%r14), %rsi
leaq 0x58(%rsp), %rbp
movq %rbp, %rdi
callq 0x12c0a
movzbl 0x68(%r14), %ebx
movq %r12, %rsi
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x12e2e
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
leaq 0x28(%rsp), %rdx
movq %r13, %rcx
movq %rbp, %r8
movl %ebx, %r9d
pushq %r12
pushq $0x1
callq 0x1d016
popq %rax
popq %rcx
addq $0x48, %r14
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x13816
leaq 0x10(%rsp), %rdi
callq 0xc984
leaq 0x50(%rsp), %rdi
callq 0xc984
leaq 0x60(%rsp), %rdi
callq 0xc984
leaq 0x70(%rsp), %rdi
callq 0xc984
leaq 0x30(%rsp), %rdi
callq 0xc984
addq $0x168, %rsp            # imm = 0x168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x38
popq %rdi
callq 0xa1b0
movq %rax, %r14
leaq 0x43891(%rip), %rsi     # 0x54522
leaq 0x128(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xa150
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x12e2e
movb $0x1, %bpl
leaq 0x128(%rsp), %rsi
movq %r14, %rdi
xorl %edx, %edx
movq %rbx, %rcx
callq 0x19f06
xorl %ebp, %ebp
leaq 0x668c1(%rip), %rsi     # 0x77598
leaq 0x9b4(%rip), %rdx       # 0x11692
movq %r14, %rdi
callq 0xa4e0
jmp 0x10daa
pushq $0x38
popq %rdi
callq 0xa1b0
movq %rax, %r14
movq %r12, %r15
movq (%r12), %rsi
leaq 0xe8(%rsp), %rdi
callq 0xa3b0
leaq 0x43835(%rip), %rsi     # 0x54546
leaq 0x78(%rsp), %rdi
leaq 0xe8(%rsp), %rdx
callq 0x11ff8
leaq 0x4383b(%rip), %rdx     # 0x54565
leaq 0x8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0xc882
movq (%r15), %rax
movl 0x38(%rax), %esi
leaq 0xc8(%rsp), %rdi
callq 0x3d070
leaq 0x108(%rsp), %rdi
leaq 0x8(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x1205e
leaq 0x98(%rsp), %rbx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x12e2e
movb $0x1, %bpl
leaq 0x108(%rsp), %rsi
pushq $0x3
popq %rdx
movq %r14, %rdi
movq %rbx, %rcx
callq 0x19f06
xorl %ebp, %ebp
leaq 0x667fd(%rip), %rsi     # 0x77598
leaq 0x8f0(%rip), %rdx       # 0x11692
movq %r14, %rdi
callq 0xa4e0
movq %rax, %rbx
leaq 0xa0(%rsp), %rdi
callq 0xc984
leaq 0x108(%rsp), %rdi
callq 0xa558
jmp 0x10dcf
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xc8(%rsp), %rdi
callq 0xa558
jmp 0x10de4
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x8(%rsp), %rdi
callq 0xa558
jmp 0x10df6
movq %rax, %rbx
movb $0x1, %bpl
leaq 0x78(%rsp), %rdi
callq 0xa558
jmp 0x10e08
movq %rax, %rbx
movb $0x1, %bpl
leaq 0xe8(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
je 0x10eb7
jmp 0x10eaf
jmp 0x10eac
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xc984
leaq 0x148(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
jne 0x10e4f
jmp 0x10eb7
movq %rax, %rbx
jmp 0x10eaf
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x10e81
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0xc984
leaq 0x60(%rsp), %rdi
callq 0xc984
leaq 0x70(%rsp), %rdi
callq 0xc984
leaq 0x30(%rsp), %rdi
callq 0xc984
jmp 0x10eb7
movq %rax, %rbx
leaq 0xb0(%rsp), %rdi
callq 0xc984
leaq 0x128(%rsp), %rdi
callq 0xa558
testb %bpl, %bpl
je 0x10eb7
jmp 0x10eaf
movq %rax, %rbx
movq %r14, %rdi
callq 0xa230
movq %rbx, %rdi
callq 0xa500
nop