codegen: use Parameter.llvm_alloca

This commit is contained in:
Luna 2019-09-28 12:46:23 -03:00
parent 61c8493484
commit 93811c986d
2 changed files with 5 additions and 8 deletions

View file

@ -24,6 +24,7 @@ pub const NodeType = enum {
pub const ParamDecl = struct {
name: Token,
typ: Token,
};
pub const MethodData = struct {

View file

@ -236,14 +236,10 @@ pub const Codegen = struct {
return switch (metadata.using) {
.Function => blk: {
var param = metadata.from_function.?.parameters.get(vari.lexeme).?.value;
var llvm_func = self.llvm_table.get(self.current_function_name.?).?.value;
// var llvm_func = self.llvm_table.get(self.current_function_name.?).?.value;
// break :blk llvm.LLVMGetParam(llvm_func, @intCast(c_uint, param.idx));
// TODO we should create stack-stored variables
// instead of the arg registers
// may i thank all the demons in hell for giving me
// good energies to make this work
break :blk llvm.LLVMGetParam(llvm_func, @intCast(c_uint, param.idx));
break :blk param.llvm_alloca;
},
.Scope => @panic("TODO local variables"),
@ -359,7 +355,6 @@ pub const Codegen = struct {
var fn_symbol = self.getFnSymbol(self.current_function_name.?);
// TODO add llvm value ref to var metadata as well
var variable = llvm.LLVMBuildAlloca(
builder,
try self.typeToLLVM(var_metadata.typ),
@ -442,6 +437,7 @@ pub const Codegen = struct {
param.llvm_alloca = alloca;
// TODO store register into stack param
// llvm.LLVMBuildStore(builder, null, assign_expr);
}
self.ctx.setScope(fn_sym.scope);