// File: /workspace/github_cpp_makefile_star2_O2/kelwinfc[P]ci4721-Fernandez-Gyomrey/src/AST/check.cpp
// Function: AST_variable_declaration::fill_and_check(symbol_table*)
void AST_variable_declaration::fill_and_check(symbol_table* st){

    if (types.has_type(sym->getName())) {
        logger->buf << "Identificador '" << sym->getName()
                    << "' ya existe como tipo '" << types.get_type(sym->getName())->name << "'.";
        logger->error(sym->getLine(), sym->getColumn());
    }

    sym->offset    = st->accumulated_offset;
    sym->width     = types.types[sym->getType()]->width;
    sym->alignment = types.types[sym->getType()]->alignment;
    
    int level;
    symbol* previous = st->lookup(sym->getName(), &level);
    
    if ( value ){
        value->fill_and_check(st);
    }
    
    if ( previous ){
        if ( previous->is_function ){
            logger->buf << "Identificador '" << sym->getName()
                        << "' ya fue definido previamente como función en "
                        << sym->getLine() << ':' << sym->getColumn();
            logger->error(sym->getLine(), sym->getColumn());
        } else if ( level == 0 ){
            logger->buf << "Identificador '" << sym->getName()
                        << "' ya fue definido previamente en "
                        << sym->getLine() << ':' << sym->getColumn();
            logger->error(sym->getLine(), sym->getColumn());
        } else {
            st->insert(sym);
        }
    } else {
        st->insert(sym);
    }
    
    if ( value
         && value->type != sym->getType()
         && value->type != INVALID
         && sym->getType() != INVALID
       )
    {
        logger->buf << "Inicialización de '" << sym->getName()
                    << "' con tipo inválido '" << types.types[value->type]->name
                    << "', esperado '" << types.types[sym->getType()]->name << "'.";
        logger->error(line, column);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r15
movq %rdi, %rbx
movq 0x98(%rdi), %rsi
leaq 0x68(%rsp), %r12
movq %r12, %rdi
callq 0x13efa
leaq 0x2e19c(%rip), %r14     # 0x38408
movq %r14, %rdi
movq %r12, %rsi
callq 0x15840
movl %eax, %ebp
leaq 0x68(%rsp), %rdi
callq 0x65c8
testb %bpl, %bpl
je 0xa359
leaq 0x2e16d(%rip), %rbp     # 0x38400
movq (%rbp), %rdi
addq $0x48, %rdi
leaq 0x195ea(%rip), %rsi     # 0x2388c
callq 0x62b0
movq %rax, %r12
movq 0x98(%rbx), %rsi
leaq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x13efa
movq %r12, %rdi
movq %r13, %rsi
callq 0x62a0
leaq 0x197a6(%rip), %rsi     # 0x23a76
movq %rax, %rdi
callq 0x62b0
movq %rax, %r12
movq 0x98(%rbx), %rsi
leaq 0x28(%rsp), %rdi
callq 0x13efa
leaq 0x2e115(%rip), %rdi     # 0x38408
leaq 0x28(%rsp), %rsi
callq 0x158f0
addq $0x8, %rax
movq %r12, %rdi
movq %rax, %rsi
callq 0x62a0
leaq 0x1e284(%rip), %rsi     # 0x28597
movq %rax, %rdi
callq 0x62b0
leaq 0x28(%rsp), %rdi
callq 0x65c8
leaq 0x8(%rsp), %rdi
callq 0x65c8
movq (%rbp), %r12
movq 0x98(%rbx), %rdi
callq 0x13f10
movl %eax, %ebp
movq 0x98(%rbx), %rdi
callq 0x13f14
movq %r12, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x16112
movl 0xc(%r15), %eax
movq 0x98(%rbx), %rdi
movl %eax, 0x34(%rdi)
callq 0x13f0c
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movl 0x28(%rax), %eax
movq 0x98(%rbx), %rdi
movl %eax, 0x38(%rdi)
callq 0x13f0c
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rax
movl 0x2c(%rax), %eax
movq 0x98(%rbx), %rsi
movl %eax, 0x3c(%rsi)
leaq 0x48(%rsp), %r12
movq %r12, %rdi
callq 0x13efa
leaq 0x4(%rsp), %rdx
movq %r15, %rdi
movq %r12, %rsi
callq 0x1422e
movq %rax, %r12
leaq 0x48(%rsp), %rdi
callq 0x65c8
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0xa3dc
movq (%rdi), %rax
movq %r15, %rsi
callq *0x8(%rax)
testq %r12, %r12
je 0xa486
cmpb $0x1, 0x31(%r12)
jne 0xa47f
leaq 0x2e008(%rip), %r13     # 0x38400
movq (%r13), %rdi
addq $0x48, %rdi
leaq 0x19485(%rip), %rsi     # 0x2388c
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x13efa
movq %r15, %rdi
movq %r12, %rsi
callq 0x62a0
leaq 0x19659(%rip), %rsi     # 0x23a8e
movq %rax, %rdi
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x13f10
movq %r15, %rdi
movl %eax, %esi
callq 0x6510
pushq $0x3a
popq %rsi
movq %rax, %rdi
callq 0x6350
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x13f14
movq %r15, %rdi
movl %eax, %esi
callq 0x6510
jmp 0xa523
cmpl $0x0, 0x4(%rsp)
je 0xa49a
movq 0x98(%rbx), %rsi
movq %r15, %rdi
callq 0x142e6
jmp 0xa557
leaq 0x2df5f(%rip), %r13     # 0x38400
movq (%r13), %rdi
addq $0x48, %rdi
leaq 0x193dc(%rip), %rsi     # 0x2388c
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x13efa
movq %r15, %rdi
movq %r12, %rsi
callq 0x62a0
leaq 0x195e0(%rip), %rsi     # 0x23abe
movq %rax, %rdi
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x13f10
movq %r15, %rdi
movl %eax, %esi
callq 0x6510
pushq $0x3a
popq %rsi
movq %rax, %rdi
callq 0x6350
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x13f14
movq %r15, %rdi
movl %eax, %esi
callq 0x6510
leaq 0x8(%rsp), %rdi
callq 0x65c8
movq (%r13), %r15
movq 0x98(%rbx), %rdi
callq 0x13f10
movl %eax, %ebp
movq 0x98(%rbx), %rdi
callq 0x13f14
movq %r15, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x16112
movq 0xa0(%rbx), %rax
testq %rax, %rax
je 0xa669
movl 0x10(%rax), %ebp
movq 0x98(%rbx), %rdi
callq 0x13f0c
cmpl %eax, %ebp
je 0xa669
movq 0xa0(%rbx), %rax
cmpl $0x1, 0x10(%rax)
je 0xa669
movq 0x98(%rbx), %rdi
callq 0x13f0c
cmpl $0x1, %eax
je 0xa669
leaq 0x2de55(%rip), %r13     # 0x38400
movq (%r13), %rdi
addq $0x48, %rdi
leaq 0x19526(%rip), %rsi     # 0x23ae0
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rsi
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x13efa
movq %r15, %rdi
movq %r12, %rsi
callq 0x62a0
leaq 0x1950d(%rip), %rsi     # 0x23af5
movq %rax, %rdi
callq 0x62b0
movq 0xa0(%rbx), %rcx
movslq 0x10(%rcx), %rcx
movq (%r14), %rdx
movq (%rdx,%rcx,8), %rsi
addq $0x8, %rsi
movq %rax, %rdi
callq 0x62a0
leaq 0x19255(%rip), %rsi     # 0x2386a
movq %rax, %rdi
callq 0x62b0
movq %rax, %r15
movq 0x98(%rbx), %rdi
callq 0x13f0c
cltq
movq (%r14), %rcx
movq (%rcx,%rax,8), %rsi
addq $0x8, %rsi
movq %r15, %rdi
callq 0x62a0
leaq 0x1df4f(%rip), %rsi     # 0x28597
movq %rax, %rdi
callq 0x62b0
leaq 0x8(%rsp), %rdi
callq 0x65c8
movq (%r13), %rdi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x16112
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xa6a4
jmp 0xa6a4
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
jmp 0xa6ac
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
jmp 0xa6ac
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x65c8
jmp 0xa6a7
jmp 0xa6a4
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x65c8
movq %rbx, %rdi
callq 0x6530
nop