| ... | ... | @@ -126,6 +126,12 @@ pub const Inst = struct { |
| 126 | 126 | condbr, |
| 127 | 127 | /// Special case, has no textual representation. |
| 128 | 128 | @"const", |
| 129 | /// Container field with just the name. |
| 130 | container_field_named, |
| 131 | /// Container field with a type and a name, |
| 132 | container_field_typed, |
| 133 | /// Container field with all the bells and whistles. |
| 134 | container_field, |
| 129 | 135 | /// Declares the beginning of a statement. Used for debug info. |
| 130 | 136 | dbg_stmt, |
| 131 | 137 | /// Represents a pointer to a global decl by name. |
| ... | ... | @@ -245,6 +251,8 @@ pub const Inst = struct { |
| 245 | 251 | store, |
| 246 | 252 | /// String Literal. Makes an anonymous Decl and then takes a pointer to it. |
| 247 | 253 | str, |
| 254 | /// Create a struct type. |
| 255 | struct_type, |
| 248 | 256 | /// Arithmetic subtraction. Asserts no integer overflow. |
| 249 | 257 | sub, |
| 250 | 258 | /// Twos complement wrapping integer subtraction. |
| ... | ... | @@ -262,6 +270,8 @@ pub const Inst = struct { |
| 262 | 270 | xor, |
| 263 | 271 | /// Create an optional type '?T' |
| 264 | 272 | optional_type, |
| 273 | /// Create a union type. |
| 274 | union_type, |
| 265 | 275 | /// Unwraps an optional value 'lhs.?' |
| 266 | 276 | unwrap_optional_safe, |
| 267 | 277 | /// Same as previous, but without safety checks. Used for orelse, if and while |
| ... | ... | @@ -274,8 +284,10 @@ pub const Inst = struct { |
| 274 | 284 | unwrap_err_code, |
| 275 | 285 | /// Takes a *E!T and raises a compiler error if T != void |
| 276 | 286 | ensure_err_payload_void, |
| 277 | | /// Enum literal |
| 287 | /// Create a enum literal, |
| 278 | 288 | enum_literal, |
| 289 | /// Create an enum type. |
| 290 | enum_type, |
| 279 | 291 | /// A switch expression. |
| 280 | 292 | switchbr, |
| 281 | 293 | /// A range in a switch case, `lhs...rhs`. |
| ... | ... | @@ -403,6 +415,12 @@ pub const Inst = struct { |
| 403 | 415 | .error_set => ErrorSet, |
| 404 | 416 | .slice => Slice, |
| 405 | 417 | .switchbr => SwitchBr, |
| 418 | .container_field_named => ContainerFieldNamed, |
| 419 | .container_field_typed => ContainerFieldTyped, |
| 420 | .container_field => ContainerField, |
| 421 | .enum_type => EnumType, |
| 422 | .union_type => UnionType, |
| 423 | .struct_type => StructType, |
| 406 | 424 | }; |
| 407 | 425 | } |
| 408 | 426 | |
| ... | ... | @@ -510,6 +528,9 @@ pub const Inst = struct { |
| 510 | 528 | .slice_start, |
| 511 | 529 | .import, |
| 512 | 530 | .switch_range, |
| 531 | .enum_type, |
| 532 | .union_type, |
| 533 | .struct_type, |
| 513 | 534 | => false, |
| 514 | 535 | |
| 515 | 536 | .@"break", |
| ... | ... | @@ -522,6 +543,9 @@ pub const Inst = struct { |
| 522 | 543 | .@"unreachable", |
| 523 | 544 | .loop, |
| 524 | 545 | .switchbr, |
| 546 | .container_field_named, |
| 547 | .container_field_typed, |
| 548 | .container_field, |
| 525 | 549 | => true, |
| 526 | 550 | }; |
| 527 | 551 | } |
| ... | ... | @@ -1032,6 +1056,83 @@ pub const Inst = struct { |
| 1032 | 1056 | body: Module.Body, |
| 1033 | 1057 | }; |
| 1034 | 1058 | }; |
| 1059 | |
| 1060 | pub const ContainerFieldNamed = struct { |
| 1061 | pub const base_tag = Tag.container_field_named; |
| 1062 | base: Inst, |
| 1063 | |
| 1064 | positionals: struct { |
| 1065 | bytes: []const u8, |
| 1066 | }, |
| 1067 | kw_args: struct {}, |
| 1068 | }; |
| 1069 | |
| 1070 | pub const ContainerFieldTyped = struct { |
| 1071 | pub const base_tag = Tag.container_field_typed; |
| 1072 | base: Inst, |
| 1073 | |
| 1074 | positionals: struct { |
| 1075 | bytes: []const u8, |
| 1076 | ty: *Inst, |
| 1077 | }, |
| 1078 | kw_args: struct {}, |
| 1079 | }; |
| 1080 | |
| 1081 | pub const ContainerField = struct { |
| 1082 | pub const base_tag = Tag.container_field; |
| 1083 | base: Inst, |
| 1084 | |
| 1085 | positionals: struct { |
| 1086 | bytes: []const u8, |
| 1087 | ty: ?*Inst, |
| 1088 | init: ?*Inst, |
| 1089 | alignment: ?*Inst, |
| 1090 | is_comptime: bool, |
| 1091 | }, |
| 1092 | kw_args: struct {}, |
| 1093 | }; |
| 1094 | |
| 1095 | pub const EnumType = struct { |
| 1096 | pub const base_tag = Tag.enum_type; |
| 1097 | base: Inst, |
| 1098 | |
| 1099 | positionals: struct { |
| 1100 | fields: []*Inst, |
| 1101 | }, |
| 1102 | kw_args: struct { |
| 1103 | tag_type: ?*Inst = null, |
| 1104 | layout: std.builtin.TypeInfo.ContainerLayout = .Auto, |
| 1105 | }, |
| 1106 | }; |
| 1107 | |
| 1108 | pub const StructType = struct { |
| 1109 | pub const base_tag = Tag.struct_type; |
| 1110 | base: Inst, |
| 1111 | |
| 1112 | positionals: struct { |
| 1113 | fields: []*Inst, |
| 1114 | }, |
| 1115 | kw_args: struct { |
| 1116 | layout: std.builtin.TypeInfo.ContainerLayout = .Auto, |
| 1117 | }, |
| 1118 | }; |
| 1119 | |
| 1120 | pub const UnionType = struct { |
| 1121 | pub const base_tag = Tag.union_type; |
| 1122 | base: Inst, |
| 1123 | |
| 1124 | positionals: struct { |
| 1125 | fields: []*Inst, |
| 1126 | }, |
| 1127 | kw_args: struct { |
| 1128 | init_expr: union(enum) { |
| 1129 | enum_type: ?*Inst, |
| 1130 | tag_type: *Inst, |
| 1131 | none, |
| 1132 | }, |
| 1133 | layout: std.builtin.TypeInfo.ContainerLayout = .Auto, |
| 1134 | }, |
| 1135 | }; |
| 1035 | 1136 | }; |
| 1036 | 1137 | |
| 1037 | 1138 | pub const ErrorMsg = struct { |