| ... | @@ -3,10 +3,9 @@ | ... | @@ -3,10 +3,9 @@ |
| 3 | const std = @import("std"); | 3 | const std = @import("std"); |
| 4 | const mem = std.mem; | 4 | const mem = std.mem; |
| 5 | const Allocator = std.mem.Allocator; | 5 | const Allocator = std.mem.Allocator; |
| 6 | const Value = @import("../value.zig").Value; | | |
| 7 | const assert = std.debug.assert; | 6 | const assert = std.debug.assert; |
| 8 | const ir = @import("../ir.zig"); | | |
| 9 | const BigInt = std.math.big.Int; | 7 | const BigInt = std.math.big.Int; |
| | 8 | const Type = @import("../type.zig").Type; |
| 10 | | 9 | |
| 11 | /// These are instructions that correspond to the ZIR text format. See `ir.Inst` for | 10 | /// These are instructions that correspond to the ZIR text format. See `ir.Inst` for |
| 12 | /// in-memory, analyzed instructions with types and values. | 11 | /// in-memory, analyzed instructions with types and values. |
| ... | @@ -201,6 +200,34 @@ pub const Inst = struct { | ... | @@ -201,6 +200,34 @@ pub const Inst = struct { |
| 201 | @"anyerror", | 200 | @"anyerror", |
| 202 | @"comptime_int", | 201 | @"comptime_int", |
| 203 | @"comptime_float", | 202 | @"comptime_float", |
| | 203 | |
| | 204 | fn toType(self: BuiltinType) Type { |
| | 205 | return switch (self) { |
| | 206 | .@"isize" => Type.initTag(.@"isize"), |
| | 207 | .@"usize" => Type.initTag(.@"usize"), |
| | 208 | .@"c_short" => Type.initTag(.@"c_short"), |
| | 209 | .@"c_ushort" => Type.initTag(.@"c_ushort"), |
| | 210 | .@"c_int" => Type.initTag(.@"c_int"), |
| | 211 | .@"c_uint" => Type.initTag(.@"c_uint"), |
| | 212 | .@"c_long" => Type.initTag(.@"c_long"), |
| | 213 | .@"c_ulong" => Type.initTag(.@"c_ulong"), |
| | 214 | .@"c_longlong" => Type.initTag(.@"c_longlong"), |
| | 215 | .@"c_ulonglong" => Type.initTag(.@"c_ulonglong"), |
| | 216 | .@"c_longdouble" => Type.initTag(.@"c_longdouble"), |
| | 217 | .@"c_void" => Type.initTag(.@"c_void"), |
| | 218 | .@"f16" => Type.initTag(.@"f16"), |
| | 219 | .@"f32" => Type.initTag(.@"f32"), |
| | 220 | .@"f64" => Type.initTag(.@"f64"), |
| | 221 | .@"f128" => Type.initTag(.@"f128"), |
| | 222 | .@"bool" => Type.initTag(.@"bool"), |
| | 223 | .@"void" => Type.initTag(.@"void"), |
| | 224 | .@"noreturn" => Type.initTag(.@"noreturn"), |
| | 225 | .@"type" => Type.initTag(.@"type"), |
| | 226 | .@"anyerror" => Type.initTag(.@"anyerror"), |
| | 227 | .@"comptime_int" => Type.initTag(.@"comptime_int"), |
| | 228 | .@"comptime_float" => Type.initTag(.@"comptime_float"), |
| | 229 | }; |
| | 230 | } |
| 204 | }; | 231 | }; |
| 205 | }; | 232 | }; |
| 206 | | 233 | |
| ... | @@ -337,7 +364,6 @@ pub const Module = struct { | ... | @@ -337,7 +364,6 @@ pub const Module = struct { |
| 337 | return stream.writeAll(@tagName(param)); | 364 | return stream.writeAll(@tagName(param)); |
| 338 | } | 365 | } |
| 339 | switch (@TypeOf(param)) { | 366 | switch (@TypeOf(param)) { |
| 340 | Value => return stream.print("{}", .{param}), | | |
| 341 | *Inst => return self.writeInstParamToStream(stream, param, inst_table), | 367 | *Inst => return self.writeInstParamToStream(stream, param, inst_table), |
| 342 | []*Inst => { | 368 | []*Inst => { |
| 343 | try stream.writeByte('['); | 369 | try stream.writeByte('['); |
| ... | @@ -693,7 +719,6 @@ const Parser = struct { | ... | @@ -693,7 +719,6 @@ const Parser = struct { |
| 693 | return instructions.toOwnedSlice(); | 719 | return instructions.toOwnedSlice(); |
| 694 | }, | 720 | }, |
| 695 | *Inst => return parseParameterInst(self, body_ctx), | 721 | *Inst => return parseParameterInst(self, body_ctx), |
| 696 | Value => return self.fail("TODO implement parseParameterGeneric for type Value", .{}), | | |
| 697 | []u8 => return self.parseStringLiteral(), | 722 | []u8 => return self.parseStringLiteral(), |
| 698 | BigInt => return self.parseIntegerLiteral(), | 723 | BigInt => return self.parseIntegerLiteral(), |
| 699 | else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)), | 724 | else => @compileError("Unimplemented: ir parseParameterGeneric for type " ++ @typeName(T)), |