P5.7 Step C: delete interp.zig — the comptime VM is the sole evaluator
The legacy tagged-Value Interpreter is gone. Relocate the Value result-DTO
+ decodeVariantElements into a new comptime_value.zig (the VM<->host
materialization boundary); repoint comptime_vm/emit_llvm/ir-barrel Value to
it and BuildConfig to compiler_hooks; delete the dead valueToReg bridge;
slim compiler_lib.zig to just the name registry (BoundFn{sx_name} + bound_fns
+ findFn — weldedCompilerFn only validates names); simplify printInterpBailDiag
to comptime_vm.last_bail_reason; drop the unused interp_mod import in lower.zig.
rm src/ir/interp.zig + interp.test.zig.
Value is relocated (not eliminated): it survives only as the slim result DTO
at the VM->valueToLLVMConst boundary; the execution-time marshaling the VM
pivot targeted is gone. Drop dead Value.asString/reflectTypeId.
706/0 corpus + 476/476 unit.
This commit is contained in:
@@ -12,7 +12,7 @@ const FuncId = inst_mod.FuncId;
|
||||
const Function = inst_mod.Function;
|
||||
const Block = inst_mod.Block;
|
||||
const Module = @import("module.zig").Module;
|
||||
const Value = @import("interp.zig").Value;
|
||||
const Value = @import("comptime_value.zig").Value;
|
||||
const TypeId = types.TypeId;
|
||||
|
||||
const dummy: types.StringId = @enumFromInt(0);
|
||||
@@ -1262,41 +1262,6 @@ test "comptime_vm exec: recursive call (sum 0..n)" {
|
||||
try std.testing.expectEqual(@as(i64, 55), toI64(try v.run(module.getFunction(sum_id), &.{fromI64(10)})));
|
||||
}
|
||||
|
||||
test "comptime_vm bridge: Value <-> Reg round-trips (scalar, string, struct)" {
|
||||
const alloc = std.testing.allocator;
|
||||
var table = types.TypeTable.init(alloc);
|
||||
defer table.deinit();
|
||||
const pfields = [_]types.TypeInfo.StructInfo.Field{
|
||||
.{ .name = table.internString("x"), .ty = .i64 },
|
||||
.{ .name = table.internString("y"), .ty = .i64 },
|
||||
};
|
||||
const point = table.intern(.{ .@"struct" = .{ .name = table.internString("Point"), .fields = &pfields } });
|
||||
|
||||
var v = vm.Vm.init(alloc);
|
||||
v.table = &table;
|
||||
defer v.deinit();
|
||||
|
||||
// scalar i64
|
||||
const r_i = try v.valueToReg(&table, .{ .int = 42 }, .i64);
|
||||
try std.testing.expectEqual(@as(i64, 42), toI64(r_i));
|
||||
const back_i = try v.regToValue(alloc, &table, r_i, .i64);
|
||||
try std.testing.expectEqual(@as(i64, 42), back_i.int);
|
||||
|
||||
// string (materialized into comptime memory, read back + deep-copied out)
|
||||
const r_s = try v.valueToReg(&table, .{ .string = "hi" }, .string);
|
||||
const back_s = try v.regToValue(alloc, &table, r_s, .string);
|
||||
defer alloc.free(back_s.string);
|
||||
try std.testing.expectEqualStrings("hi", back_s.string);
|
||||
|
||||
// struct {x:i64, y:i64}
|
||||
const fvals = [_]Value{ .{ .int = 3 }, .{ .int = 4 } };
|
||||
const r_p = try v.valueToReg(&table, .{ .aggregate = &fvals }, point);
|
||||
const back_p = try v.regToValue(alloc, &table, r_p, point);
|
||||
defer alloc.free(back_p.aggregate);
|
||||
try std.testing.expectEqual(@as(i64, 3), back_p.aggregate[0].int);
|
||||
try std.testing.expectEqual(@as(i64, 4), back_p.aggregate[1].int);
|
||||
}
|
||||
|
||||
test "comptime_vm tryEval: pure function → Value; unsupported → null" {
|
||||
const alloc = std.testing.allocator;
|
||||
var module = Module.init(alloc);
|
||||
|
||||
Reference in New Issue
Block a user