This commit is contained in:
agra
2026-02-21 02:25:21 +02:00
parent ff2b2a69ab
commit b02fe37a87
6 changed files with 96 additions and 12 deletions

View File

@@ -2338,6 +2338,9 @@ pub const CodeGen = struct {
const llvm_ty = self.typeToLLVM(target_ty);
switch (node.data) {
.int_literal => |lit| {
if (target_ty.isFloat()) {
return c.LLVMConstReal(llvm_ty, @floatFromInt(@as(i64, lit.value)));
}
return c.LLVMConstInt(llvm_ty, @bitCast(@as(i64, lit.value)), 0);
},
.float_literal => |lit| {
@@ -4773,6 +4776,15 @@ pub const CodeGen = struct {
return entry.ptr;
}
}
// Non-identifier expressions (e.g. field access, tuple element):
// generate value, store into temp alloca, return alloca pointer
if (node.data != .identifier) {
const val = try self.genExpr(node);
const llvm_ty = c.LLVMTypeOf(val);
const tmp = self.buildEntryBlockAlloca(llvm_ty, "implicit_addr");
_ = c.LLVMBuildStore(self.builder, val, tmp);
return tmp;
}
}
}