// File: /workspace/github_c_makefile_star2_O1/goodpaul6[P]generic/script.c
// Function: resolve_symbols
static void resolve_symbols(script_t* script, expr_t* exp)
{
	switch(exp->type)
	{
		case EXP_ATOMIC:
		{
			resolve_symbols(script, exp->atomx);
		} break;
		
		case EXP_DOT: case EXP_COLON:
		{
			resolve_symbols(script, exp->dotx.value);
		} break;
		
		case EXP_STRUCT_NEW:
		{
			for(int i = 0; i < exp->newx.init.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->newx.init, i, expr_t*));
		} break;
		
		case EXP_STRUCT_DECL:
		{
			for(int i = 0; i < exp->struct_tag->ds.members.length; ++i)
			{
				type_tag_member_t* mem = vec_get(&exp->struct_tag->ds.members, i);
				if(mem->default_value)
					resolve_symbols(script, mem->default_value);
			}
		} break;
		
		case EXP_NULL:
		case EXP_EXTERN:
		case EXP_EXTERN_LIST:
		case EXP_NUMBER:
		case EXP_STRING:
		case EXP_CHAR:
		case EXP_BOOL: break;
	
		case EXP_VAR:
		{
			if(exp->varx.decl) return;
			exp->varx.decl = reference_variable(script, exp->varx.name);
			if(!exp->varx.decl) 
			{
				if(reference_function(script, exp->varx.name)) return;
				if(get_type_tag_from_name(script, exp->varx.name)) return;
				error_defer_e(exp, "Attempted to reference undeclared entity '%s'\n", exp->varx.name);
			}
		} break;
		
		case EXP_UNARY:
		{
			resolve_symbols(script, exp->unaryx.rhs);
		} break;
		
		case EXP_BINARY:
		{
			resolve_symbols(script, exp->binx.lhs);
			resolve_symbols(script, exp->binx.rhs);
		} break;
		
		case EXP_PAREN:
		{
			resolve_symbols(script, exp->paren);
		} break;
		
		case EXP_BLOCK:
		{
			for(int i = 0; i < exp->block.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->block, i, expr_t*));
		} break;
		
		case EXP_ARRAY_INDEX:
		{
			resolve_symbols(script, exp->array_index.array);
			resolve_symbols(script, exp->array_index.index);
		} break;
		
		case EXP_ARRAY_LITERAL:
		{
			for(int i = 0; i < exp->array_literal.values.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->array_literal.values, i, expr_t*));
		} break;
		
		case EXP_IF:
		{
			resolve_symbols(script, exp->ifx.cond);
			resolve_symbols(script, exp->ifx.body);
			if(exp->ifx.alt) resolve_symbols(script, exp->ifx.alt);
		} break;
		
		case EXP_WHILE:
		{
			resolve_symbols(script, exp->whilex.cond);
			resolve_symbols(script, exp->whilex.body);
		} break;
		
		case EXP_FOR:
		{
			resolve_symbols(script, exp->forx.init);
			resolve_symbols(script, exp->forx.cond);
			resolve_symbols(script, exp->forx.step);
			resolve_symbols(script, exp->forx.body);
		} break;

		case EXP_RETURN:
		{
			if(exp->retx.value)
				resolve_symbols(script, exp->retx.value);
		} break;
		
		case EXP_CALL:
		{
			for(int i = 0; i < exp->callx.args.length; ++i)
				resolve_symbols(script, vec_get_value(&exp->callx.args, i, expr_t*));
			resolve_symbols(script, exp->callx.func);
		} break;
		
		case EXP_FUNC:
		{
			resolve_symbols(script, exp->funcx.body);
		} break;
		
		case EXP_WRITE:
		{
			resolve_symbols(script, exp->write);
		} break;
		
		case EXP_LEN:
		{
			resolve_symbols(script, exp->len);
		} break;

		default:
			assert(0);
			break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x6711(%rip), %r13      # 0xf298
movl 0x28(%rbx), %eax
cmpq $0x1a, %rax
ja 0x8d8d
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x38(%rbx), %rbx
jmp 0x8b87
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x40(%rbx), %rbx
jmp 0x8b87
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x48(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x50(%rbx), %rbx
jmp 0x8b87
movq 0x40(%rbx), %rbx
jmp 0x8c31
cmpq $0x0, 0x50(%rbx)
je 0x8b9e
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8b6c
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8bf4
jmp 0x8b9e
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x40(%rbx), %rsi
movq %r14, %rdi
callq 0x8b6c
movq 0x48(%rbx), %rbx
testq %rbx, %rbx
jne 0x8b87
jmp 0x8d7e
cmpq $0x0, 0x50(%rbx)
je 0x8d7e
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8b6c
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8c51
jmp 0x8d7e
cmpq $0x0, 0x50(%rbx)
je 0x8d7e
leaq 0x40(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8b6c
incq %r12
cmpq %r12, 0x50(%rbx)
ja 0x8c87
jmp 0x8d7e
movq 0x38(%rbx), %rdi
cmpq $0x0, 0x70(%rdi)
je 0x8d7e
xorl %r15d, %r15d
addq $0x60, %rdi
movq %r15, %rsi
callq 0xdf24
movq 0x18(%rax), %rsi
testq %rsi, %rsi
je 0x8cda
movq %r14, %rdi
callq 0x8b6c
incq %r15
movq 0x38(%rbx), %rdi
cmpq %r15, 0x70(%rdi)
ja 0x8cbd
jmp 0x8d7e
cmpq $0x0, 0x40(%rbx)
jne 0x8d7e
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x86d2
movq %rax, 0x40(%rbx)
testq %rax, %rax
jne 0x8d7e
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x84c0
testq %rax, %rax
jne 0x8d7e
movq 0x38(%rbx), %rsi
movq %r14, %rdi
callq 0x8dac
testq %rax, %rax
jne 0x8d7e
movq 0x38(%rbx), %rdx
leaq 0x79a3(%rip), %rsi      # 0x106dc
movq %rbx, %rdi
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x22a3
cmpq $0x0, 0x48(%rbx)
je 0x8d7e
leaq 0x38(%rbx), %r15
xorl %r12d, %r12d
movq %r15, %rdi
movq %r12, %rsi
callq 0xdf24
movq (%rax), %rsi
movq %r14, %rdi
callq 0x8b6c
incq %r12
cmpq %r12, 0x48(%rbx)
ja 0x8d5f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x6df8(%rip), %rdi      # 0xfb8c
leaq 0x6df3(%rip), %rsi      # 0xfb8e
leaq 0x7969(%rip), %rcx      # 0x1070b
movl $0xc54, %edx            # imm = 0xC54
callq 0x2100