| ... | @@ -78,6 +78,17 @@ fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: ZigNode) !void { | ... | @@ -78,6 +78,17 @@ fn addTopLevelDecl(c: *Context, name: []const u8, decl_node: ZigNode) !void { |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | | 80 | |
| | 81 | fn fail( |
| | 82 | c: *Context, |
| | 83 | err: anytype, |
| | 84 | source_loc: TokenIndex, |
| | 85 | comptime format: []const u8, |
| | 86 | args: anytype, |
| | 87 | ) (@TypeOf(err) || error{OutOfMemory}) { |
| | 88 | try warn(c, &c.global_scope.base, source_loc, format, args); |
| | 89 | return err; |
| | 90 | } |
| | 91 | |
| 81 | fn failDecl(c: *Context, loc: TokenIndex, name: []const u8, comptime format: []const u8, args: anytype) Error!void { | 92 | fn failDecl(c: *Context, loc: TokenIndex, name: []const u8, comptime format: []const u8, args: anytype) Error!void { |
| 82 | // location | 93 | // location |
| 83 | // pub const name = @compileError(msg); | 94 | // pub const name = @compileError(msg); |
| ... | @@ -687,8 +698,21 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const Type.Enum, field_ | ... | @@ -687,8 +698,21 @@ fn transEnumDecl(c: *Context, scope: *Scope, enum_decl: *const Type.Enum, field_ |
| 687 | } | 698 | } |
| 688 | } | 699 | } |
| 689 | | 700 | |
| | 701 | fn getTypeStr(c: *Context, ty: Type) ![]const u8 { |
| | 702 | var buf: std.ArrayListUnmanaged(u8) = .{}; |
| | 703 | defer buf.deinit(c.gpa); |
| | 704 | const w = buf.writer(c.gpa); |
| | 705 | try ty.print(c.mapper, c.comp.langopts, w); |
| | 706 | return c.arena.dupe(u8, buf.items); |
| | 707 | } |
| | 708 | |
| 690 | fn transType(c: *Context, scope: *Scope, raw_ty: Type, qual_handling: Type.QualHandling, source_loc: TokenIndex) TypeError!ZigNode { | 709 | fn transType(c: *Context, scope: *Scope, raw_ty: Type, qual_handling: Type.QualHandling, source_loc: TokenIndex) TypeError!ZigNode { |
| 691 | const ty = raw_ty.canonicalize(qual_handling); | 710 | const ty = raw_ty.canonicalize(qual_handling); |
| | 711 | if (ty.qual.atomic) { |
| | 712 | const type_name = try getTypeStr(c, ty); |
| | 713 | return fail(c, error.UnsupportedType, source_loc, "unsupported type: '{s}'", .{type_name}); |
| | 714 | } |
| | 715 | |
| 692 | switch (ty.specifier) { | 716 | switch (ty.specifier) { |
| 693 | .void => return ZigTag.type.create(c.arena, "anyopaque"), | 717 | .void => return ZigTag.type.create(c.arena, "anyopaque"), |
| 694 | .bool => return ZigTag.type.create(c.arena, "bool"), | 718 | .bool => return ZigTag.type.create(c.arena, "bool"), |