fix(evaluate): use engine262 inspect() for console output

Replace naive manual .stringValue()/.value fallback with engine262's
inspect() function so console.log outputs readable strings instead of
raw engine262 internal objects.

Closes #5
This commit is contained in:
2026-04-27 16:41:07 +05:30
parent cc77ac19ae
commit 9b49d92cb8
+3 -13
View File
@@ -25,6 +25,7 @@ process.stdin.on("end", async () => {
const Value = engine.Value;
const skipDebugger = engine.skipDebugger;
const ask262Debug = engine.ask262Debug;
const inspect = engine.inspect;
// Reset state
ask262Debug.reset();
@@ -87,19 +88,8 @@ process.stdin.on("end", async () => {
for (const method of consoleMethods) {
const fn = CreateBuiltinFunction(
(args) => {
const jsValues = args.map((arg) => {
if (arg && typeof arg === "object") {
const strVal = arg.stringValue;
if (typeof strVal === "function") {
return strVal.call(arg);
}
const value = arg.value;
if (value !== undefined) {
return value;
}
}
return arg;
});
// Use engine262's inspect() to convert Values to readable JS strings
const jsValues = args.map((arg) => inspect(arg));
consoleOutput.push({ method, values: jsValues });
return Value("undefined");
},