feat: materialize tagged-union and fallible constants
This commit is contained in:
+12
-2
@@ -31,8 +31,14 @@ NodeId :: distinct u32
|
||||
@hide:file
|
||||
no_node :: maxval!(NodeId)
|
||||
|
||||
#! void literals are generated constants only; there is no source void literal.
|
||||
LiteralKind :: enum {
|
||||
int, float, string, bool, null
|
||||
int
|
||||
float
|
||||
string
|
||||
bool
|
||||
null
|
||||
void
|
||||
}
|
||||
|
||||
ExprKind :: enum {
|
||||
@@ -71,6 +77,7 @@ ExprKind :: enum {
|
||||
catch_expr
|
||||
typed_constant
|
||||
comptime_expr
|
||||
literal_void
|
||||
}
|
||||
|
||||
DeclKind :: enum {
|
||||
@@ -176,6 +183,7 @@ NodeKind :: enum {
|
||||
expr_typed_constant
|
||||
expr_comptime
|
||||
literal_float_value
|
||||
literal_void
|
||||
}
|
||||
|
||||
@hide:file
|
||||
@@ -490,6 +498,7 @@ add_literal proc(builder @mut Builder, kind LiteralKind, span Span) NodeId ! mem
|
||||
.string: .literal_string
|
||||
.bool: .literal_bool
|
||||
.null: .literal_null
|
||||
.void: .literal_void
|
||||
}
|
||||
return try add_node(builder, Node{ kind = node_kind }, span)
|
||||
}
|
||||
@@ -1408,6 +1417,7 @@ expression_kind proc(kind NodeKind) ExprKind {
|
||||
.expr_typed_constant: .typed_constant
|
||||
.expr_comptime: .comptime_expr
|
||||
.literal_float_value: .literal_float
|
||||
.literal_void: .literal_void
|
||||
else: unreachable
|
||||
}
|
||||
}
|
||||
@@ -1803,7 +1813,7 @@ node_layout proc(node Node) NodeLayout {
|
||||
layout := NodeLayout{}
|
||||
match node.kind {
|
||||
.literal_int, .literal_float, .literal_float_value, .literal_string, .literal_bool, .literal_null,
|
||||
.expr_identifier, .invalid_expr: {}
|
||||
.literal_void, .expr_identifier, .invalid_expr: {}
|
||||
.expr_unary: layout.direct_children = 2
|
||||
.expr_binary, .expr_range, .expr_index, .expr_selection, .expr_typed_constant,
|
||||
.expr_fallible_type, .expr_sum_type, .expr_array_type, .expr_slice_type:
|
||||
|
||||
Reference in New Issue
Block a user