feat: evaluate compile-time aggregates and explicit expressions
This commit is contained in:
@@ -1795,6 +1795,9 @@ lower_expression proc(state @mut State, id ast.NodeId) ir.ValueId ! (mem.AllocEr
|
||||
}
|
||||
if (typecheck.is_union_variant(state.checked, id)) return try lower_union(state, id)
|
||||
match ast.expr_kind(tree, id) {
|
||||
.comptime_expr: {
|
||||
if (!trap_type(state, id)) unreachable
|
||||
}
|
||||
.typed_constant: {
|
||||
if (trap_type(state, id)) return ir.no_value
|
||||
return try lower_as(state, ast.typed_constant(tree, id).value, typecheck.type_of(state.checked, id))
|
||||
@@ -2130,6 +2133,12 @@ exact_float_integer proc(text []u8, value f64) bool {
|
||||
@hide:file
|
||||
lower_number proc(state @mut State, id ast.NodeId) ir.ValueId ! (mem.AllocError | diagnostics.CapacityError) {
|
||||
span :: ast.node_span(state.tree, id)
|
||||
if (ast.float_value(state.tree, id)) |value| {
|
||||
return try constant(state, ir.Value{
|
||||
type = .float,
|
||||
data = ir.ValueData{ real = value },
|
||||
}, span)
|
||||
}
|
||||
text :: ast.literal_text(state.tree, id)
|
||||
type :: lower_type(state, typecheck.type_of(state.checked, id))
|
||||
if (ir.integer_bits(type) != 0 and !ir.unsigned_integer(type)) {
|
||||
|
||||
Reference in New Issue
Block a user