|
|
@ -60,8 +60,12 @@ PushAST::PushAST(const std::string& n): BaseAST(n) {}
|
|
|
|
llvm::Value *PushAST::codegen(LLVMState& llvmState) const
|
|
|
|
llvm::Value *PushAST::codegen(LLVMState& llvmState) const
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (auto [var, native] = Var::lookup(name, 1); var) {
|
|
|
|
if (auto [var, native] = Var::lookup(name, 1); var) {
|
|
|
|
auto index = llvm::ConstantInt::get(llvmState.inttype, llvmState.envidx++);
|
|
|
|
if (!native) {
|
|
|
|
Var::addLocal(name, index);
|
|
|
|
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) {
|
|
|
|
if (auto [var, native] = Var::lookupLocal(name); var) {
|
|
|
@ -182,9 +186,11 @@ void ThunkAST::endGen(LLVMState& llvmState)
|
|
|
|
|
|
|
|
|
|
|
|
if (Var::vars.back().size() > 0) {
|
|
|
|
if (Var::vars.back().size() > 0) {
|
|
|
|
for (auto& [n, v] : Var::vars.back()) {
|
|
|
|
for (auto& [n, v] : Var::vars.back()) {
|
|
|
|
if (auto [c, _] = Var::lookup(n, 1); c) {
|
|
|
|
if (auto [c, nat] = Var::lookup(n, 1); c) {
|
|
|
|
auto src = loadEnv(llvmState, c);
|
|
|
|
if (!nat) {
|
|
|
|
storeEnv(llvmState, v.value, src);
|
|
|
|
auto src = loadEnv(llvmState, c);
|
|
|
|
|
|
|
|
storeEnv(llvmState, v.value, src);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|