diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-28 11:19:23 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2024-06-28 11:19:23 -0400 |
commit | ea55b08698329defe9155ba89f013efc9350a861 (patch) | |
tree | 516eb74131de3b507fa7d63e6be73f16eeabe760 /ast.cpp | |
parent | 08f4a92102c9739e0736965186814e856ff727a1 (diff) |
shortcut push-pops; don't env-copy functions
Diffstat (limited to 'ast.cpp')
-rw-r--r-- | ast.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -60,8 +60,12 @@ PushAST::PushAST(const std::string& n): BaseAST(n) {} llvm::Value *PushAST::codegen(LLVMState& llvmState) const { if (auto [var, native] = Var::lookup(name, 1); var) { - auto index = llvm::ConstantInt::get(llvmState.inttype, llvmState.envidx++); - Var::addLocal(name, index); + if (!native) { + auto index = llvm::ConstantInt::get(llvmState.inttype, llvmState.envidx++); + Var::addLocal(name, index); + } else { + Var::addLocal(name, Var {var, native}); + } } if (auto [var, native] = Var::lookupLocal(name); var) { @@ -182,9 +186,11 @@ void ThunkAST::endGen(LLVMState& llvmState) if (Var::vars.back().size() > 0) { for (auto& [n, v] : Var::vars.back()) { - if (auto [c, _] = Var::lookup(n, 1); c) { - auto src = loadEnv(llvmState, c); - storeEnv(llvmState, v.value, src); + if (auto [c, nat] = Var::lookup(n, 1); c) { + if (!nat) { + auto src = loadEnv(llvmState, c); + storeEnv(llvmState, v.value, src); + } } } } |