// File: marxn[P]pupp/src/parser/statement.cpp
// Function: VarDefinitionStatement::Provision()
bool VarDefinitionStatement::Provision()
{
        Node * parent = this->GetParentNode();

        if(parent)
        {
                string varname = *(this->Ident);
                if(parent->FindVariable(varname, NULL))
                {
                        cerr<<"pupp provision error: Duplicated variable: "<<varname<<endl;
                        return false;
                }

                this->VarDef = new VariableDef(varname);
                this->VarDef->SetVarType(this->VarType->GetVarType());

                //Variable type has to be determined before Lambda expression defined.
                if(this->InitExpr!=NULL && this->InitExpr->IsLambdaExp())
                {
                        this->VarDef->SetVarType(Func);
                }

                parent->AddVariable(this->VarDef);
        }

        if(this->InitExpr)
        {
                this->InitExpr->SetParentNode(this);
                return this->InitExpr->Provision();
        }

        return true;
}

// Assembly:
subq $0xd8, %rsp
movq %rdi, 0xc8(%rsp)
movq 0xc8(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x14170
movq %rax, 0xc0(%rsp)
cmpq $0x0, 0xc0(%rsp)
je 0x2e9f5
movq 0x40(%rsp), %rax
movq 0x70(%rax), %rsi
leaq 0xa0(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x6160
movq 0x30(%rsp), %rsi
movq 0xc0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x6160
jmp 0x2e7e4
movq 0x38(%rsp), %rdi
xorl %eax, %eax
movl %eax, %edx
leaq 0x80(%rsp), %rsi
callq 0x143e0
movq %rax, 0x28(%rsp)
jmp 0x2e801
leaq 0x80(%rsp), %rdi
callq 0x61e0
movq 0x28(%rsp), %rax
cmpq $0x0, %rax
je 0x2e8ab
movq 0x477cc(%rip), %rdi     # 0x75ff0
leaq 0x32813(%rip), %rsi     # 0x6103e
callq 0x62d0
movq %rax, 0x20(%rsp)
jmp 0x2e837
movq 0x20(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x62a0
movq %rax, 0x18(%rsp)
jmp 0x2e850
movq 0x18(%rsp), %rdi
movq 0x4775c(%rip), %rsi     # 0x75fb8
callq 0x6320
jmp 0x2e863
movb $0x0, 0xd7(%rsp)
movl $0x1, 0x70(%rsp)
jmp 0x2e9cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x2e9e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x61e0
jmp 0x2e9e6
movl $0x40, %edi
callq 0x62f0
movq %rax, 0x10(%rsp)
jmp 0x2e8bc
movb $0x1, 0x4f(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x6160
jmp 0x2e8d5
movq 0x10(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x30e90
jmp 0x2e8e6
movq 0x40(%rsp), %rax
movq 0x10(%rsp), %rcx
movb $0x0, 0x4f(%rsp)
movq %rcx, 0x60(%rax)
leaq 0x50(%rsp), %rdi
callq 0x61e0
movq 0x40(%rsp), %rax
movq 0x60(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x78(%rax), %rdi
callq 0x2e0e0
movq 0x8(%rsp), %rdi
movl %eax, %esi
callq 0x31000
jmp 0x2e928
movq 0x40(%rsp), %rax
cmpq $0x0, 0x68(%rax)
je 0x2e9ab
movq 0x40(%rsp), %rax
movq 0x68(%rax), %rdi
callq 0xda60
movb %al, 0x7(%rsp)
jmp 0x2e948
movb 0x7(%rsp), %al
testb $0x1, %al
jne 0x2e952
jmp 0x2e9ab
movq 0x40(%rsp), %rax
movq 0x60(%rax), %rdi
movl $0x8, %esi
callq 0x31000
jmp 0x2e967
jmp 0x2e9ab
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
jmp 0x2e991
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x78(%rsp)
movl %eax, 0x74(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x61e0
testb $0x1, 0x4f(%rsp)
jne 0x2e99a
jmp 0x2e9a9
movq 0x10(%rsp), %rdi
movl $0x40, %esi
callq 0x6300
jmp 0x2e9e6
movq 0x40(%rsp), %rax
movq 0xc0(%rsp), %rdi
movq 0x60(%rax), %rsi
callq 0x141b0
jmp 0x2e9c3
movl $0x0, 0x70(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x61e0
movl 0x70(%rsp), %eax
testl %eax, %eax
je 0x2e9e4
jmp 0x2e9e2
jmp 0x2ea31
jmp 0x2e9f5
leaq 0xa0(%rsp), %rdi
callq 0x61e0
jmp 0x2ea42
movq 0x40(%rsp), %rax
cmpq $0x0, 0x68(%rax)
je 0x2ea29
movq 0x40(%rsp), %rsi
movq 0x68(%rsi), %rdi
callq 0xda00
movq 0x40(%rsp), %rax
movq 0x68(%rax), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
andb $0x1, %al
movb %al, 0xd7(%rsp)
jmp 0x2ea31
movb $0x1, 0xd7(%rsp)
movb 0xd7(%rsp), %al
andb $0x1, %al
addq $0xd8, %rsp
retq
movq 0x78(%rsp), %rdi
callq 0x6550
nopl (%rax)