...
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user