Skip to content

Commit

Permalink
pack pointer type struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Techatrix committed Nov 22, 2023
1 parent 46cc5be commit d81c8a8
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 143 deletions.
14 changes: 8 additions & 6 deletions src/ComptimeInterpreter.zig
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ pub fn interpret(
const ty = interpreter.ip.typeOf(val);

const inner_ty = switch (interpreter.ip.indexToKey(ty)) {
.pointer_type => |pointer_info| if (pointer_info.size == .One) pointer_info.elem_type else ty,
.pointer_type => |pointer_info| if (pointer_info.flags.size == .One) pointer_info.elem_type else ty,

Check warning on line 456 in src/ComptimeInterpreter.zig

View check run for this annotation

Codecov / codecov/patch

src/ComptimeInterpreter.zig#L456

Added line #L456 was not covered by tests
else => ty,
};

Expand Down Expand Up @@ -505,7 +505,7 @@ pub fn interpret(
else => {},
},
.pointer_type => |pointer_info| {
switch (pointer_info.size) {
switch (pointer_info.flags.size) {

Check warning on line 508 in src/ComptimeInterpreter.zig

View check run for this annotation

Codecov / codecov/patch

src/ComptimeInterpreter.zig#L508

Added line #L508 was not covered by tests
.Many, .C => {},
.One => {
switch (interpreter.ip.indexToKey(pointer_info.elem_type)) {

Check warning on line 511 in src/ComptimeInterpreter.zig

View check run for this annotation

Codecov / codecov/patch

src/ComptimeInterpreter.zig#L511

Added line #L511 was not covered by tests
Expand All @@ -529,7 +529,7 @@ pub fn interpret(
.Slice => {
if (std.mem.eql(u8, field_name, "ptr")) {
var many_ptr_info = InternPool.Key{ .pointer_type = pointer_info };
many_ptr_info.pointer_type.size = .Many;
many_ptr_info.pointer_type.flags.size = .Many;
return InterpretResult{

Check warning on line 533 in src/ComptimeInterpreter.zig

View check run for this annotation

Codecov / codecov/patch

src/ComptimeInterpreter.zig#L530-L533

Added lines #L530 - L533 were not covered by tests
.value = Value{
.interpreter = interpreter,
Expand Down Expand Up @@ -1019,8 +1019,10 @@ pub fn interpret(
.len = @intCast(str.len),

Check warning on line 1019 in src/ComptimeInterpreter.zig

View check run for this annotation

Codecov / codecov/patch

src/ComptimeInterpreter.zig#L1019

Added line #L1019 was not covered by tests
.sentinel = .zero_u8,
} }),
.size = .One,
.is_const = true,
.flags = .{
.size = .One,
.is_const = true,
},
} });

return InterpretResult{ .value = Value{
Expand Down Expand Up @@ -1174,7 +1176,7 @@ pub fn interpret(

const pointer_type = try interpreter.ip.get(interpreter.allocator, Key{ .pointer_type = .{
.elem_type = ty,
.size = .One,
.flags = .{ .size = .One },
} });

return InterpretResult{ .value = .{
Expand Down
Loading

0 comments on commit d81c8a8

Please sign in to comment.