// File: /workspace/github_cpp_makefile_star2_O2/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST.cpp
// Function: AST_function::AST_function(int, tokenId*, AST_arg_list*, AST_block*)
AST_function::AST_function(TYPE t, tokenId* id, AST_arg_list* args,
                           AST_block* code
                          )
{
    line = id->line;
    column = id->column;
    
    vector< symbol* >::iterator it;
    vector< TYPE > types;
    for (it = args->args.begin(); it != args->args.end(); ++ it){
        types.push_back( (*it)->getType() );
    }
    
    if ( t ){
        func = new symbol_function(id->ident, t, id->line, id->column,
                                   types);
    } else {
        func = new symbol_function(id->ident, id->line, id->column, types );
    }
    
    delete id;
    
    formal_parameters = args;
    instructions = code;
    
    if ( func->getType() != NONE ){
        if ( code->has_return == NO ){
            // Reportar error de tipo de argumento
            logger->buf << "Función '" << id->ident << "' sin retorno.";
            logger->error(line, column);
        } else if ( code->has_return == MAYBE ){
            logger->buf << "Función '" << id->ident << "' posiblemente sin retorno.";
            logger->warning(line, column);
        }
    }
    has_return = NO;
    
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %r8, 0x8(%rsp)
movq %rcx, %r12
movq %rdx, %r14
movl %esi, (%rsp)
movq %rdi, %rbx
callq 0x1263c
leaq 0x25c19(%rip), %rax     # 0x375d8
movq %rax, (%rbx)
movq (%r14), %rax
movq %rax, 0x8(%rbx)
leaq 0x10(%rsp), %r15
andq $0x0, 0x10(%r15)
xorps %xmm0, %xmm0
movaps %xmm0, (%r15)
movq 0x10(%r12), %rbp
leaq 0x4(%rsp), %r13
cmpq 0x18(%r12), %rbp
je 0x11a09
movq (%rbp), %rdi
callq 0x13f0c
movl %eax, 0x4(%rsp)
movq %r15, %rdi
movq %r13, %rsi
callq 0x13aee
addq $0x8, %rbp
jmp 0x119e4
cmpl $0x0, (%rsp)
je 0x11a4e
movl $0x90, %edi
callq 0x62d0
movq 0x8(%rsp), %rbp
movq %rax, %r13
leaq 0x8(%r14), %rsi
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x63e0
movl (%r14), %ecx
movl 0x4(%r14), %r8d
leaq 0x10(%rsp), %r9
movq %r13, %rdi
movq %r15, %rsi
movl (%rsp), %edx
callq 0x13fda
jmp 0x11a88
movl $0x90, %edi
callq 0x62d0
movq 0x8(%rsp), %rbp
movq %rax, %r13
leaq 0x8(%r14), %rsi
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x63e0
movl (%r14), %edx
movl 0x4(%r14), %ecx
leaq 0x10(%rsp), %r8
movq %r13, %rdi
movq %r15, %rsi
callq 0x13f36
movq %r13, 0x98(%rbx)
movq %r15, %rdi
callq 0x65c8
movq %r14, %rdi
callq 0x125aa
pushq $0x28
popq %rsi
movq %r14, %rdi
callq 0x62e0
movq %r12, 0xa0(%rbx)
movq %rbp, 0xa8(%rbx)
movq 0x98(%rbx), %rdi
callq 0x13f0c
cmpl $0x2, %eax
je 0x11b6c
movl 0x78(%rbp), %eax
cmpl $0x2, %eax
je 0x11b26
cmpl $0x1, %eax
jne 0x11b6c
leaq 0x2691b(%rip), %r15     # 0x38400
movq (%r15), %rdi
addq $0x48, %rdi
leaq 0x11eec(%rip), %rsi     # 0x239df
callq 0x62b0
addq $0x8, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x62a0
leaq 0x1363a(%rip), %rsi     # 0x25148
movq %rax, %rdi
callq 0x62b0
movq (%r15), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x16112
jmp 0x11b6c
leaq 0x268d3(%rip), %r15     # 0x38400
movq (%r15), %rdi
addq $0x48, %rdi
leaq 0x11ea4(%rip), %rsi     # 0x239df
callq 0x62b0
addq $0x8, %r14
movq %rax, %rdi
movq %r14, %rsi
callq 0x62a0
leaq 0x13601(%rip), %rsi     # 0x25157
movq %rax, %rdi
callq 0x62b0
movq (%r15), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x15fb8
movl $0x1, 0x10(%rbx)
leaq 0x10(%rsp), %rdi
callq 0x13aba
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
leaq 0x28(%rsp), %rdi
jmp 0x11ba0
jmp 0x11ba7
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x65c8
jmp 0x11baa
movq %rax, %r14
movl $0x90, %esi
movq %r13, %rdi
callq 0x62e0
jmp 0x11bbe
jmp 0x11bbb
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x13aba
movq %rbx, %rdi
callq 0x1266c
movq %r14, %rdi
callq 0x6530