|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|