| ... | ... | @@ -17,6 +17,7 @@ pub const Inst = struct { |
| 17 | 17 | @"asm", |
| 18 | 18 | @"unreachable", |
| 19 | 19 | @"fn", |
| 20 | @"export", |
| 20 | 21 | }; |
| 21 | 22 | |
| 22 | 23 | pub fn TagToType(tag: Tag) type { |
| ... | ... | @@ -26,8 +27,9 @@ pub const Inst = struct { |
| 26 | 27 | .fieldptr => FieldPtr, |
| 27 | 28 | .deref => Deref, |
| 28 | 29 | .@"asm" => Assembly, |
| 29 | | .@"unreachable" => Unreach, |
| 30 | .@"unreachable" => Unreachable, |
| 30 | 31 | .@"fn" => Fn, |
| 32 | .@"export" => Export, |
| 31 | 33 | }; |
| 32 | 34 | } |
| 33 | 35 | |
| ... | ... | @@ -87,8 +89,8 @@ pub const Inst = struct { |
| 87 | 89 | }, |
| 88 | 90 | }; |
| 89 | 91 | |
| 90 | | pub const Unreach = struct { |
| 91 | | base: Inst = Inst{ .tag = .unreach }, |
| 92 | pub const Unreachable = struct { |
| 93 | base: Inst = Inst{ .tag = .@"unreachable" }, |
| 92 | 94 | |
| 93 | 95 | positionals: struct {}, |
| 94 | 96 | kw_args: struct {}, |
| ... | ... | @@ -108,6 +110,16 @@ pub const Inst = struct { |
| 108 | 110 | instructions: []*Inst, |
| 109 | 111 | }; |
| 110 | 112 | }; |
| 113 | |
| 114 | pub const Export = struct { |
| 115 | base: Inst = Inst{ .tag = .@"export" }, |
| 116 | |
| 117 | positionals: struct { |
| 118 | symbol_name: *Inst, |
| 119 | value: *Inst, |
| 120 | }, |
| 121 | kw_args: struct {}, |
| 122 | }; |
| 111 | 123 | }; |
| 112 | 124 | |
| 113 | 125 | pub const ErrorMsg = struct { |
| ... | ... | @@ -319,7 +331,6 @@ fn parseParameterGeneric(ctx: *ParseContext, comptime T: type, body_ctx: ?*BodyC |
| 319 | 331 | while (ctx.i < ctx.source.len) : (ctx.i += 1) switch (ctx.source[ctx.i]) { |
| 320 | 332 | ' ', '\n', ',', ')' => { |
| 321 | 333 | const enum_name = ctx.source[start..ctx.i]; |
| 322 | | ctx.i += 1; |
| 323 | 334 | return std.meta.stringToEnum(T, enum_name) orelse { |
| 324 | 335 | return parseError(ctx, "tag '{}' not a member of enum '{}'", .{ enum_name, @typeName(T) }); |
| 325 | 336 | }; |
| ... | ... | @@ -427,6 +438,10 @@ fn parseBody(ctx: *ParseContext) !Inst.Fn.Body { |
| 427 | 438 | continue; |
| 428 | 439 | }, |
| 429 | 440 | ' ', '\n' => continue, |
| 441 | '}' => { |
| 442 | ctx.i += 1; |
| 443 | break; |
| 444 | }, |
| 430 | 445 | else => |byte| return parseError(ctx, "unexpected byte: '{c}'", .{byte}), |
| 431 | 446 | }; |
| 432 | 447 | |