diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-15 21:06:27 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-15 21:06:27 -0400 |
commit | 6be79eda61b3c64b38528c023845991a0cb4a274 (patch) | |
tree | eb95a1980831b1e62641335ce1e7b7cbbfa9b044 /ast.cpp | |
parent | ed78a6054c628e80240eff8ea9a06412774df094 (diff) |
recursion; list via support.c
Diffstat (limited to 'ast.cpp')
-rw-r--r-- | ast.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -58,12 +58,20 @@ PopAST::PopAST(const std::string& n): BaseAST(n) {} llvm::Value *PopAST::codegen(LLVMState& llvmState) const { - auto gep = llvmState.createPop(); - auto var = llvmState.createVariable(name); - auto load = llvmState.builder.CreateLoad(llvmState.inttype, gep); - llvmState.builder.CreateStore(load, var, false); + if (name == "self") { + extern std::list<ThunkAST> scope; + auto func = scope.back().func; + 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) {} |