|
|
@ -117,15 +117,17 @@ llvm::Value *CallAST::codegen(LLVMState& llvmState) const
|
|
|
|
Var::addGlobal(name, Var {fn, true});
|
|
|
|
Var::addGlobal(name, Var {fn, true});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
auto ptrty = llvmState.inttype->getPointerTo();
|
|
|
|
bool couldRecur = Var::lookup("self").value != nullptr;
|
|
|
|
llvm::Type *type;
|
|
|
|
auto localCount = Var::vars.back().size();
|
|
|
|
llvm::Value *mem;
|
|
|
|
if (!couldRecur || localCount == 0) {
|
|
|
|
|
|
|
|
return llvmState.builder.CreateCall(llvmState.ftype, fn, llvm::ArrayRef {scope.back().env});
|
|
|
|
if (auto sz = Var::vars.back().size(); sz > 0) {
|
|
|
|
} else {
|
|
|
|
type = llvm::VectorType::get(llvmState.inttype, sz, false);
|
|
|
|
int i;
|
|
|
|
mem = llvmState.builder.CreateAlloca(type, nullptr);
|
|
|
|
auto ptrty = llvmState.inttype->getPointerTo();
|
|
|
|
|
|
|
|
auto type = llvm::VectorType::get(llvmState.inttype, localCount, false);
|
|
|
|
|
|
|
|
auto mem = llvmState.builder.CreateAlloca(type, nullptr);
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
i = 0;
|
|
|
|
for (auto& [_, v] : Var::vars.back()) {
|
|
|
|
for (auto& [_, v] : Var::vars.back()) {
|
|
|
|
if (!v.native) {
|
|
|
|
if (!v.native) {
|
|
|
|
auto index = llvm::ConstantInt::get(llvmState.inttype, i++);
|
|
|
|
auto index = llvm::ConstantInt::get(llvmState.inttype, i++);
|
|
|
@ -133,12 +135,10 @@ llvm::Value *CallAST::codegen(LLVMState& llvmState) const
|
|
|
|
llvmState.builder.CreateStore(loadEnv(llvmState, v.value), m, false);
|
|
|
|
llvmState.builder.CreateStore(loadEnv(llvmState, v.value), m, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto call = llvmState.builder.CreateCall(llvmState.ftype, fn, llvm::ArrayRef {scope.back().env});
|
|
|
|
auto call = llvmState.builder.CreateCall(llvmState.ftype, fn, llvm::ArrayRef {scope.back().env});
|
|
|
|
|
|
|
|
|
|
|
|
if (auto sz = Var::vars.back().size(); sz > 0) {
|
|
|
|
i = 0;
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
for (auto& [_, v] : Var::vars.back()) {
|
|
|
|
for (auto& [_, v] : Var::vars.back()) {
|
|
|
|
if (!v.native) {
|
|
|
|
if (!v.native) {
|
|
|
|
auto index = llvm::ConstantInt::get(llvmState.inttype, i++);
|
|
|
|
auto index = llvm::ConstantInt::get(llvmState.inttype, i++);
|
|
|
@ -147,9 +147,9 @@ llvm::Value *CallAST::codegen(LLVMState& llvmState) const
|
|
|
|
storeEnv(llvmState, v.value, l);
|
|
|
|
storeEnv(llvmState, v.value, l);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return call;
|
|
|
|
return call;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ThunkAST::ThunkAST(LLVMState& llvmState):
|
|
|
|
ThunkAST::ThunkAST(LLVMState& llvmState):
|
|
|
|