codegen: emit vardecl initializer
This commit is contained in:
parent
d235ce0d13
commit
81fd718403
1 changed files with 4 additions and 4 deletions
|
@ -339,7 +339,6 @@ pub const Codegen = struct {
|
||||||
_ = llvm.LLVMBuildUnreachable(builder);
|
_ = llvm.LLVMBuildUnreachable(builder);
|
||||||
},
|
},
|
||||||
|
|
||||||
// TODO
|
|
||||||
.VarDecl => |vardecl| {
|
.VarDecl => |vardecl| {
|
||||||
// we alaready inferred the type of the variable in the
|
// we alaready inferred the type of the variable in the
|
||||||
// analyze pass and the current scope contains the variable's
|
// analyze pass and the current scope contains the variable's
|
||||||
|
@ -352,14 +351,15 @@ pub const Codegen = struct {
|
||||||
|
|
||||||
var fn_symbol = self.getFnSymbol(self.current_function_name.?);
|
var fn_symbol = self.getFnSymbol(self.current_function_name.?);
|
||||||
|
|
||||||
_ = llvm.LLVMBuildAlloca(
|
// TODO add llvm value ref to var metadata as well
|
||||||
|
var variable = llvm.LLVMBuildAlloca(
|
||||||
builder,
|
builder,
|
||||||
try self.typeToLLVM(var_metadata.typ),
|
try self.typeToLLVM(var_metadata.typ),
|
||||||
name_cstr.ptr,
|
name_cstr.ptr,
|
||||||
);
|
);
|
||||||
|
|
||||||
// TODO generate the store for the initializer
|
var llvm_expr = try self.emitExpr(builder, vardecl.value);
|
||||||
//var llvm_expr = try self.emitExpr(vardecl.value);
|
_ = llvm.LLVMBuildStore(builder, llvm_expr, variable);
|
||||||
},
|
},
|
||||||
|
|
||||||
else => {
|
else => {
|
||||||
|
|
Loading…
Reference in a new issue