|
|
@ -58,12 +58,20 @@ PopAST::PopAST(const std::string& n): BaseAST(n) {}
|
|
|
|
|
|
|
|
|
|
|
|
llvm::Value *PopAST::codegen(LLVMState& llvmState) const
|
|
|
|
llvm::Value *PopAST::codegen(LLVMState& llvmState) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
auto gep = llvmState.createPop();
|
|
|
|
if (name == "self") {
|
|
|
|
auto var = llvmState.createVariable(name);
|
|
|
|
extern std::list<ThunkAST> scope;
|
|
|
|
auto load = llvmState.builder.CreateLoad(llvmState.inttype, gep);
|
|
|
|
auto func = scope.back().func;
|
|
|
|
llvmState.builder.CreateStore(load, var, false);
|
|
|
|
auto var = llvmState.createVariable(name);
|
|
|
|
|
|
|
|
llvmState.builder.CreateStore(func, var, false);
|
|
|
|
|
|
|
|
return Var::addLocal(name, var).value;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
auto gep = llvmState.createPop();
|
|
|
|
|
|
|
|
auto var = llvmState.createVariable(name);
|
|
|
|
|
|
|
|
auto load = llvmState.builder.CreateLoad(llvmState.inttype, gep);
|
|
|
|
|
|
|
|
llvmState.builder.CreateStore(load, var, false);
|
|
|
|
|
|
|
|
|
|
|
|
return Var::addLocal(name, var).value;
|
|
|
|
return Var::addLocal(name, var).value;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CallAST::CallAST(const std::string& n): BaseAST(n) {}
|
|
|
|
CallAST::CallAST(const std::string& n): BaseAST(n) {}
|
|
|
|