fixed JS_GetScriptOrModuleName() in direct or indirect eval code
This commit is contained in:
parent
9a4379daf6
commit
efdb722f02
2 changed files with 24 additions and 13 deletions
35
quickjs.c
35
quickjs.c
|
@ -597,6 +597,7 @@ typedef struct JSFunctionBytecode {
|
||||||
uint8_t has_debug : 1;
|
uint8_t has_debug : 1;
|
||||||
uint8_t backtrace_barrier : 1; /* stop backtrace on this function */
|
uint8_t backtrace_barrier : 1; /* stop backtrace on this function */
|
||||||
uint8_t read_only_bytecode : 1;
|
uint8_t read_only_bytecode : 1;
|
||||||
|
uint8_t is_direct_or_indirect_eval : 1; /* used by JS_GetScriptOrModuleName() */
|
||||||
/* XXX: 4 bits available */
|
/* XXX: 4 bits available */
|
||||||
uint8_t *byte_code_buf; /* (self pointer) */
|
uint8_t *byte_code_buf; /* (self pointer) */
|
||||||
int byte_code_len;
|
int byte_code_len;
|
||||||
|
@ -28285,8 +28286,8 @@ JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
|
||||||
JSFunctionBytecode *b;
|
JSFunctionBytecode *b;
|
||||||
JSObject *p;
|
JSObject *p;
|
||||||
/* XXX: currently we just use the filename of the englobing
|
/* XXX: currently we just use the filename of the englobing
|
||||||
function. It does not work for eval(). Need to add a
|
function from the debug info. May need to add a ScriptOrModule
|
||||||
ScriptOrModule info in JSFunctionBytecode */
|
info in JSFunctionBytecode. */
|
||||||
sf = ctx->rt->current_stack_frame;
|
sf = ctx->rt->current_stack_frame;
|
||||||
if (!sf)
|
if (!sf)
|
||||||
return JS_ATOM_NULL;
|
return JS_ATOM_NULL;
|
||||||
|
@ -28295,15 +28296,23 @@ JSAtom JS_GetScriptOrModuleName(JSContext *ctx, int n_stack_levels)
|
||||||
if (!sf)
|
if (!sf)
|
||||||
return JS_ATOM_NULL;
|
return JS_ATOM_NULL;
|
||||||
}
|
}
|
||||||
if (JS_VALUE_GET_TAG(sf->cur_func) != JS_TAG_OBJECT)
|
for(;;) {
|
||||||
return JS_ATOM_NULL;
|
if (JS_VALUE_GET_TAG(sf->cur_func) != JS_TAG_OBJECT)
|
||||||
p = JS_VALUE_GET_OBJ(sf->cur_func);
|
return JS_ATOM_NULL;
|
||||||
if (!js_class_has_bytecode(p->class_id))
|
p = JS_VALUE_GET_OBJ(sf->cur_func);
|
||||||
return JS_ATOM_NULL;
|
if (!js_class_has_bytecode(p->class_id))
|
||||||
b = p->u.func.function_bytecode;
|
return JS_ATOM_NULL;
|
||||||
if (!b->has_debug)
|
b = p->u.func.function_bytecode;
|
||||||
return JS_ATOM_NULL;
|
if (!b->is_direct_or_indirect_eval) {
|
||||||
return JS_DupAtom(ctx, b->debug.filename);
|
if (!b->has_debug)
|
||||||
|
return JS_ATOM_NULL;
|
||||||
|
return JS_DupAtom(ctx, b->debug.filename);
|
||||||
|
} else {
|
||||||
|
sf = sf->prev_frame;
|
||||||
|
if (!sf)
|
||||||
|
return JS_ATOM_NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
|
JSAtom JS_GetModuleName(JSContext *ctx, JSModuleDef *m)
|
||||||
|
@ -33319,6 +33328,8 @@ static JSValue js_create_function(JSContext *ctx, JSFunctionDef *fd)
|
||||||
b->super_allowed = fd->super_allowed;
|
b->super_allowed = fd->super_allowed;
|
||||||
b->arguments_allowed = fd->arguments_allowed;
|
b->arguments_allowed = fd->arguments_allowed;
|
||||||
b->backtrace_barrier = fd->backtrace_barrier;
|
b->backtrace_barrier = fd->backtrace_barrier;
|
||||||
|
b->is_direct_or_indirect_eval = (fd->eval_type == JS_EVAL_TYPE_DIRECT ||
|
||||||
|
fd->eval_type == JS_EVAL_TYPE_INDIRECT);
|
||||||
b->realm = JS_DupContext(ctx);
|
b->realm = JS_DupContext(ctx);
|
||||||
|
|
||||||
add_gc_object(ctx->rt, &b->header, JS_GC_OBJ_TYPE_FUNCTION_BYTECODE);
|
add_gc_object(ctx->rt, &b->header, JS_GC_OBJ_TYPE_FUNCTION_BYTECODE);
|
||||||
|
@ -34968,6 +34979,7 @@ static int JS_WriteFunctionTag(BCWriterState *s, JSValueConst obj)
|
||||||
bc_set_flags(&flags, &idx, b->arguments_allowed, 1);
|
bc_set_flags(&flags, &idx, b->arguments_allowed, 1);
|
||||||
bc_set_flags(&flags, &idx, b->has_debug, 1);
|
bc_set_flags(&flags, &idx, b->has_debug, 1);
|
||||||
bc_set_flags(&flags, &idx, b->backtrace_barrier, 1);
|
bc_set_flags(&flags, &idx, b->backtrace_barrier, 1);
|
||||||
|
bc_set_flags(&flags, &idx, b->is_direct_or_indirect_eval, 1);
|
||||||
assert(idx <= 16);
|
assert(idx <= 16);
|
||||||
bc_put_u16(s, flags);
|
bc_put_u16(s, flags);
|
||||||
bc_put_u8(s, b->js_mode);
|
bc_put_u8(s, b->js_mode);
|
||||||
|
@ -35908,6 +35920,7 @@ static JSValue JS_ReadFunctionTag(BCReaderState *s)
|
||||||
bc.arguments_allowed = bc_get_flags(v16, &idx, 1);
|
bc.arguments_allowed = bc_get_flags(v16, &idx, 1);
|
||||||
bc.has_debug = bc_get_flags(v16, &idx, 1);
|
bc.has_debug = bc_get_flags(v16, &idx, 1);
|
||||||
bc.backtrace_barrier = bc_get_flags(v16, &idx, 1);
|
bc.backtrace_barrier = bc_get_flags(v16, &idx, 1);
|
||||||
|
bc.is_direct_or_indirect_eval = bc_get_flags(v16, &idx, 1);
|
||||||
bc.read_only_bytecode = s->is_rom_data;
|
bc.read_only_bytecode = s->is_rom_data;
|
||||||
if (bc_get_u8(s, &v8))
|
if (bc_get_u8(s, &v8))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
@ -3,8 +3,6 @@ test262/test/language/expressions/assignment/target-member-computed-reference-nu
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-null.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: Test262Error: Expected a DummyError but got a TypeError
|
||||||
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
test262/test/language/expressions/assignment/target-member-computed-reference-undefined.js:32: strict mode: Test262Error: Expected a DummyError but got a TypeError
|
||||||
test262/test/language/expressions/dynamic-import/usage-from-eval.js:26: TypeError: $DONE() not called
|
|
||||||
test262/test/language/expressions/dynamic-import/usage-from-eval.js:26: strict mode: TypeError: $DONE() not called
|
|
||||||
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: unexpected error type: Test262: This statement should not be evaluated.
|
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: unexpected error type: Test262: This statement should not be evaluated.
|
||||||
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: strict mode: unexpected error type: Test262: This statement should not be evaluated.
|
test262/test/language/expressions/in/private-field-invalid-assignment-target.js:23: strict mode: unexpected error type: Test262: This statement should not be evaluated.
|
||||||
test262/test/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js:13: Test262Error: variable Expected a SyntaxError to be thrown but no exception was thrown at all
|
test262/test/language/global-code/script-decl-lex-var-declared-via-eval-sloppy.js:13: Test262Error: variable Expected a SyntaxError to be thrown but no exception was thrown at all
|
||||||
|
|
Loading…
Reference in a new issue