extend default to s64
This commit is contained in:
30
src/sema.zig
30
src/sema.zig
@@ -125,7 +125,7 @@ pub const Analyzer = struct {
|
||||
var param_types = std.ArrayList(Type).empty;
|
||||
var has_variadic = false;
|
||||
for (fd.params) |param| {
|
||||
const pt = Type.fromTypeExpr(param.type_expr) orelse Type.s(32);
|
||||
const pt = Type.fromTypeExpr(param.type_expr) orelse Type.s(64);
|
||||
if (param.is_variadic) {
|
||||
has_variadic = true;
|
||||
// Variadic param becomes a slice type
|
||||
@@ -158,7 +158,7 @@ pub const Analyzer = struct {
|
||||
const lam = cd.value.data.lambda;
|
||||
var param_types = std.ArrayList(Type).empty;
|
||||
for (lam.params) |param| {
|
||||
const pt = Type.fromTypeExpr(param.type_expr) orelse Type.s(32);
|
||||
const pt = Type.fromTypeExpr(param.type_expr) orelse Type.s(64);
|
||||
try param_types.append(self.allocator, pt);
|
||||
}
|
||||
const ret = if (lam.return_type) |rt| Type.fromTypeExpr(rt) orelse .void_type else .void_type;
|
||||
@@ -185,7 +185,7 @@ pub const Analyzer = struct {
|
||||
// Populate struct_types registry
|
||||
var field_types = std.ArrayList(Type).empty;
|
||||
for (sd.field_types) |ft| {
|
||||
const resolved = Type.fromTypeExpr(ft) orelse Type.s(32);
|
||||
const resolved = Type.fromTypeExpr(ft) orelse Type.s(64);
|
||||
try field_types.append(self.allocator, resolved);
|
||||
}
|
||||
try self.struct_types.put(sd.name, .{
|
||||
@@ -272,7 +272,7 @@ pub const Analyzer = struct {
|
||||
/// symbols for identifier types, and Type.widen for arithmetic promotion.
|
||||
pub fn inferExprType(self: *Analyzer, node: *const Node) Type {
|
||||
return switch (node.data) {
|
||||
.int_literal => Type.s(32),
|
||||
.int_literal => Type.s(64),
|
||||
.float_literal => .f32,
|
||||
.bool_literal => .boolean,
|
||||
.string_literal => .string_type,
|
||||
@@ -296,10 +296,10 @@ pub const Analyzer = struct {
|
||||
i -= 1;
|
||||
const sym = self.symbols.items[i];
|
||||
if (sym.scope_depth <= self.scope_depth and std.mem.eql(u8, sym.name, ident.name)) {
|
||||
return sym.ty orelse Type.s(32);
|
||||
return sym.ty orelse Type.s(64);
|
||||
}
|
||||
}
|
||||
return Type.s(32);
|
||||
return Type.s(64);
|
||||
},
|
||||
.if_expr => |ie| {
|
||||
return self.inferExprType(ie.then_branch);
|
||||
@@ -317,7 +317,7 @@ pub const Analyzer = struct {
|
||||
return .void_type;
|
||||
},
|
||||
.call => |call_node| {
|
||||
const callee_name = self.resolveCalleeName(call_node) orelse return Type.s(32);
|
||||
const callee_name = self.resolveCalleeName(call_node) orelse return Type.s(64);
|
||||
// Check fn_signatures registry
|
||||
if (self.fn_signatures.get(callee_name)) |sig| {
|
||||
return sig.return_type;
|
||||
@@ -328,7 +328,7 @@ pub const Analyzer = struct {
|
||||
if (call_node.args.len > 0) return self.inferExprType(call_node.args[0]);
|
||||
return .f32;
|
||||
}
|
||||
return Type.s(32);
|
||||
return Type.s(64);
|
||||
},
|
||||
.unary_op => |unop| {
|
||||
return self.inferExprType(unop.operand);
|
||||
@@ -336,7 +336,7 @@ pub const Analyzer = struct {
|
||||
.field_access => |fa| {
|
||||
const obj_ty = self.inferExprType(fa.object);
|
||||
if (obj_ty == .string_type) {
|
||||
if (std.mem.eql(u8, fa.field, "len")) return Type.s(32);
|
||||
if (std.mem.eql(u8, fa.field, "len")) return Type.s(64);
|
||||
if (std.mem.eql(u8, fa.field, "ptr")) return .string_type;
|
||||
}
|
||||
if (obj_ty.isStruct()) {
|
||||
@@ -349,17 +349,17 @@ pub const Analyzer = struct {
|
||||
}
|
||||
}
|
||||
if (obj_ty.isArray()) {
|
||||
return Type.fromName(obj_ty.array_type.element_name) orelse Type.s(32);
|
||||
return Type.fromName(obj_ty.array_type.element_name) orelse Type.s(64);
|
||||
}
|
||||
return Type.s(32);
|
||||
return Type.s(64);
|
||||
},
|
||||
.index_expr => |ie| {
|
||||
const obj_ty = self.inferExprType(ie.object);
|
||||
if (obj_ty == .string_type) return Type.s(32);
|
||||
if (obj_ty == .string_type) return Type.u(8);
|
||||
if (obj_ty.isArray()) {
|
||||
return Type.fromName(obj_ty.array_type.element_name) orelse Type.s(32);
|
||||
return Type.fromName(obj_ty.array_type.element_name) orelse Type.s(64);
|
||||
}
|
||||
return Type.s(32);
|
||||
return Type.s(64);
|
||||
},
|
||||
.slice_expr => |se| {
|
||||
const obj_ty = self.inferExprType(se.object);
|
||||
@@ -741,7 +741,7 @@ pub const Analyzer = struct {
|
||||
|
||||
fn inferValueType(value: *Node) ?Type {
|
||||
return switch (value.data) {
|
||||
.int_literal => Type.s(32),
|
||||
.int_literal => Type.s(64),
|
||||
.float_literal => .f64,
|
||||
.bool_literal => .boolean,
|
||||
.string_literal => .string_type,
|
||||
|
||||
Reference in New Issue
Block a user