mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Fix Iterator.prototype
Make sure all descriptors are attached to the one and only iterator prototype.
This commit is contained in:
parent
554907e88f
commit
559029baad
2 changed files with 10 additions and 19 deletions
25
quickjs.c
25
quickjs.c
|
@ -2417,7 +2417,6 @@ static void JS_MarkContext(JSRuntime *rt, JSContext *ctx,
|
||||||
JS_MarkValue(rt, ctx->class_proto[i], mark_func);
|
JS_MarkValue(rt, ctx->class_proto[i], mark_func);
|
||||||
}
|
}
|
||||||
JS_MarkValue(rt, ctx->iterator_ctor, mark_func);
|
JS_MarkValue(rt, ctx->iterator_ctor, mark_func);
|
||||||
JS_MarkValue(rt, ctx->iterator_proto, mark_func);
|
|
||||||
JS_MarkValue(rt, ctx->async_iterator_proto, mark_func);
|
JS_MarkValue(rt, ctx->async_iterator_proto, mark_func);
|
||||||
JS_MarkValue(rt, ctx->promise_ctor, mark_func);
|
JS_MarkValue(rt, ctx->promise_ctor, mark_func);
|
||||||
JS_MarkValue(rt, ctx->array_ctor, mark_func);
|
JS_MarkValue(rt, ctx->array_ctor, mark_func);
|
||||||
|
@ -2486,7 +2485,6 @@ void JS_FreeContext(JSContext *ctx)
|
||||||
}
|
}
|
||||||
js_free_rt(rt, ctx->class_proto);
|
js_free_rt(rt, ctx->class_proto);
|
||||||
JS_FreeValue(ctx, ctx->iterator_ctor);
|
JS_FreeValue(ctx, ctx->iterator_ctor);
|
||||||
JS_FreeValue(ctx, ctx->iterator_proto);
|
|
||||||
JS_FreeValue(ctx, ctx->async_iterator_proto);
|
JS_FreeValue(ctx, ctx->async_iterator_proto);
|
||||||
JS_FreeValue(ctx, ctx->promise_ctor);
|
JS_FreeValue(ctx, ctx->promise_ctor);
|
||||||
JS_FreeValue(ctx, ctx->array_ctor);
|
JS_FreeValue(ctx, ctx->array_ctor);
|
||||||
|
@ -40110,7 +40108,7 @@ static JSValue js_iterator_from(JSContext *ctx, JSValue this_val,
|
||||||
JS_FreeValue(ctx, temp);
|
JS_FreeValue(ctx, temp);
|
||||||
if (JS_IsException(method))
|
if (JS_IsException(method))
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
iter = JS_NewObjectProtoClass(ctx, ctx->iterator_proto, JS_CLASS_ITERATOR);
|
iter = JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_ITERATOR], JS_CLASS_ITERATOR);
|
||||||
if (JS_IsException(iter)) {
|
if (JS_IsException(iter)) {
|
||||||
JS_FreeValue(ctx, method);
|
JS_FreeValue(ctx, method);
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
@ -40562,17 +40560,13 @@ static JSValue js_iterator_proto_get_toStringTag(JSContext *ctx, JSValue this_va
|
||||||
|
|
||||||
static JSValue js_iterator_proto_set_toStringTag(JSContext *ctx, JSValue this_val, JSValue val)
|
static JSValue js_iterator_proto_set_toStringTag(JSContext *ctx, JSValue this_val, JSValue val)
|
||||||
{
|
{
|
||||||
JSObject *p;
|
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
if (JS_VALUE_GET_TAG(this_val) != JS_TAG_OBJECT)
|
if (JS_VALUE_GET_TAG(this_val) != JS_TAG_OBJECT)
|
||||||
return JS_ThrowTypeError(ctx,
|
return JS_ThrowTypeError(ctx,
|
||||||
"set Iterator.prototype[Symbol.toStringTag] called on non-object");
|
"set Iterator.prototype[Symbol.toStringTag] called on non-object");
|
||||||
p = JS_VALUE_GET_OBJ(this_val);
|
if (js_same_value(ctx, this_val, ctx->class_proto[JS_CLASS_ITERATOR]))
|
||||||
if (p->class_id == JS_CLASS_ITERATOR) {
|
|
||||||
// This is home.
|
|
||||||
return JS_ThrowTypeError(ctx, "Cannot assign to read only property");
|
return JS_ThrowTypeError(ctx, "Cannot assign to read only property");
|
||||||
}
|
|
||||||
res = JS_GetOwnProperty(ctx, NULL, this_val, JS_ATOM_Symbol_toStringTag);
|
res = JS_GetOwnProperty(ctx, NULL, this_val, JS_ATOM_Symbol_toStringTag);
|
||||||
if (res < 0)
|
if (res < 0)
|
||||||
return JS_EXCEPTION;
|
return JS_EXCEPTION;
|
||||||
|
@ -44962,7 +44956,7 @@ void JS_AddIntrinsicRegExp(JSContext *ctx)
|
||||||
JS_SetPropertyFunctionList(ctx, obj, js_regexp_funcs, countof(js_regexp_funcs));
|
JS_SetPropertyFunctionList(ctx, obj, js_regexp_funcs, countof(js_regexp_funcs));
|
||||||
|
|
||||||
ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR] =
|
ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR] =
|
||||||
JS_NewObjectProto(ctx, ctx->iterator_proto);
|
JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_REGEXP_STRING_ITERATOR],
|
||||||
js_regexp_string_iterator_proto_funcs,
|
js_regexp_string_iterator_proto_funcs,
|
||||||
countof(js_regexp_string_iterator_proto_funcs));
|
countof(js_regexp_string_iterator_proto_funcs));
|
||||||
|
@ -48415,7 +48409,7 @@ void JS_AddIntrinsicMapSet(JSContext *ctx)
|
||||||
|
|
||||||
for(i = 0; i < 2; i++) {
|
for(i = 0; i < 2; i++) {
|
||||||
ctx->class_proto[JS_CLASS_MAP_ITERATOR + i] =
|
ctx->class_proto[JS_CLASS_MAP_ITERATOR + i] =
|
||||||
JS_NewObjectProto(ctx, ctx->iterator_proto);
|
JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_MAP_ITERATOR + i],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_MAP_ITERATOR + i],
|
||||||
js_map_proto_funcs_ptr[i + 4],
|
js_map_proto_funcs_ptr[i + 4],
|
||||||
js_map_proto_funcs_count[i + 4]);
|
js_map_proto_funcs_count[i + 4]);
|
||||||
|
@ -51544,11 +51538,8 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
||||||
JS_SetPropertyFunctionList(ctx, obj,
|
JS_SetPropertyFunctionList(ctx, obj,
|
||||||
js_iterator_funcs,
|
js_iterator_funcs,
|
||||||
countof(js_iterator_funcs));
|
countof(js_iterator_funcs));
|
||||||
ctx->iterator_proto =
|
|
||||||
JS_NewObjectProtoClass(ctx, ctx->class_proto[JS_CLASS_ITERATOR],
|
|
||||||
JS_CLASS_ITERATOR);
|
|
||||||
|
|
||||||
ctx->class_proto[JS_CLASS_ITERATOR_HELPER] = JS_NewObjectProto(ctx, ctx->iterator_proto);
|
ctx->class_proto[JS_CLASS_ITERATOR_HELPER] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR_HELPER],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ITERATOR_HELPER],
|
||||||
js_iterator_helper_proto_funcs,
|
js_iterator_helper_proto_funcs,
|
||||||
countof(js_iterator_helper_proto_funcs));
|
countof(js_iterator_helper_proto_funcs));
|
||||||
|
@ -51597,7 +51588,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
||||||
ctx->array_proto_values =
|
ctx->array_proto_values =
|
||||||
JS_GetProperty(ctx, ctx->class_proto[JS_CLASS_ARRAY], JS_ATOM_values);
|
JS_GetProperty(ctx, ctx->class_proto[JS_CLASS_ARRAY], JS_ATOM_values);
|
||||||
|
|
||||||
ctx->class_proto[JS_CLASS_ARRAY_ITERATOR] = JS_NewObjectProto(ctx, ctx->iterator_proto);
|
ctx->class_proto[JS_CLASS_ARRAY_ITERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY_ITERATOR],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_ARRAY_ITERATOR],
|
||||||
js_array_iterator_proto_funcs,
|
js_array_iterator_proto_funcs,
|
||||||
countof(js_array_iterator_proto_funcs));
|
countof(js_array_iterator_proto_funcs));
|
||||||
|
@ -51639,7 +51630,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING], js_string_proto_funcs,
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING], js_string_proto_funcs,
|
||||||
countof(js_string_proto_funcs));
|
countof(js_string_proto_funcs));
|
||||||
|
|
||||||
ctx->class_proto[JS_CLASS_STRING_ITERATOR] = JS_NewObjectProto(ctx, ctx->iterator_proto);
|
ctx->class_proto[JS_CLASS_STRING_ITERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING_ITERATOR],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_STRING_ITERATOR],
|
||||||
js_string_iterator_proto_funcs,
|
js_string_iterator_proto_funcs,
|
||||||
countof(js_string_iterator_proto_funcs));
|
countof(js_string_iterator_proto_funcs));
|
||||||
|
@ -51671,7 +51662,7 @@ void JS_AddIntrinsicBaseObjects(JSContext *ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ES6 Generator */
|
/* ES6 Generator */
|
||||||
ctx->class_proto[JS_CLASS_GENERATOR] = JS_NewObjectProto(ctx, ctx->iterator_proto);
|
ctx->class_proto[JS_CLASS_GENERATOR] = JS_NewObjectProto(ctx, ctx->class_proto[JS_CLASS_ITERATOR]);
|
||||||
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_GENERATOR],
|
JS_SetPropertyFunctionList(ctx, ctx->class_proto[JS_CLASS_GENERATOR],
|
||||||
js_generator_proto_funcs,
|
js_generator_proto_funcs,
|
||||||
countof(js_generator_proto_funcs));
|
countof(js_generator_proto_funcs));
|
||||||
|
|
|
@ -44,14 +44,14 @@ test262/test/built-ins/Date/prototype/setUTCSeconds/date-value-read-before-tonum
|
||||||
test262/test/built-ins/Date/prototype/setUTCSeconds/date-value-read-before-tonumber-when-date-is-invalid.js:26: strict mode: Test262Error: time updated in valueOf Expected SameValue(«NaN», «0») to be true
|
test262/test/built-ins/Date/prototype/setUTCSeconds/date-value-read-before-tonumber-when-date-is-invalid.js:26: strict mode: Test262Error: time updated in valueOf Expected SameValue(«NaN», «0») to be true
|
||||||
test262/test/built-ins/Iterator/from/get-return-method-when-call-return.js:24: TypeError: not a function
|
test262/test/built-ins/Iterator/from/get-return-method-when-call-return.js:24: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/get-return-method-when-call-return.js:24: strict mode: TypeError: not a function
|
test262/test/built-ins/Iterator/from/get-return-method-when-call-return.js:24: strict mode: TypeError: not a function
|
||||||
|
test262/test/built-ins/Iterator/from/result-proto.js:10: unexpected error: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
|
||||||
|
test262/test/built-ins/Iterator/from/result-proto.js:10: strict mode: unexpected error: Test262Error: Expected SameValue(«[object Object]», «[object Iterator]») to be true
|
||||||
test262/test/built-ins/Iterator/from/return-method-calls-base-return-method.js:29: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-calls-base-return-method.js:29: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/return-method-calls-base-return-method.js:29: strict mode: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-calls-base-return-method.js:29: strict mode: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/return-method-returns-iterator-result.js:18: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-returns-iterator-result.js:18: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/return-method-returns-iterator-result.js:18: strict mode: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-returns-iterator-result.js:18: strict mode: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/return-method-throws-for-invalid-this.js:16: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-throws-for-invalid-this.js:16: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/from/return-method-throws-for-invalid-this.js:16: strict mode: TypeError: not a function
|
test262/test/built-ins/Iterator/from/return-method-throws-for-invalid-this.js:16: strict mode: TypeError: not a function
|
||||||
test262/test/built-ins/Iterator/prototype/Symbol.iterator/prop-desc.js:15: Test262Error: obj should have an own property Symbol(Symbol.iterator)
|
|
||||||
test262/test/built-ins/Iterator/prototype/Symbol.iterator/prop-desc.js:15: strict mode: Test262Error: obj should have an own property Symbol(Symbol.iterator)
|
|
||||||
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: Test262Error: Expected SameValue(«"undefined"», «"function"») to be true
|
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: Test262Error: Expected SameValue(«"undefined"», «"function"») to be true
|
||||||
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: strict mode: Test262Error: Expected SameValue(«"undefined"», «"function"») to be true
|
test262/test/built-ins/Iterator/prototype/constructor/prop-desc.js:10: strict mode: Test262Error: Expected SameValue(«"undefined"», «"function"») to be true
|
||||||
test262/test/built-ins/Iterator/prototype/constructor/weird-setter.js:23: TypeError: cannot read property 'call' of undefined
|
test262/test/built-ins/Iterator/prototype/constructor/weird-setter.js:23: TypeError: cannot read property 'call' of undefined
|
||||||
|
|
Loading…
Reference in a new issue