mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Add Set.prototype.isDisjointFrom (#528)
This commit is contained in:
parent
fb70e0994b
commit
12940d7877
2 changed files with 71 additions and 38 deletions
71
quickjs.c
71
quickjs.c
|
@ -46292,6 +46292,76 @@ static int js_setlike_get_keys(JSContext *ctx, JSValue setlike, JSValue *pout)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static JSValue js_set_isDisjointFrom(JSContext *ctx, JSValue this_val,
|
||||
int argc, JSValue *argv)
|
||||
{
|
||||
JSValue item, iter, keys, has, next, rv, rval;
|
||||
BOOL done, found;
|
||||
JSMapState *s;
|
||||
int64_t size;
|
||||
int ok;
|
||||
|
||||
has = JS_UNDEFINED;
|
||||
iter = JS_UNDEFINED;
|
||||
keys = JS_UNDEFINED;
|
||||
next = JS_UNDEFINED;
|
||||
rval = JS_EXCEPTION;
|
||||
s = JS_GetOpaque2(ctx, this_val, JS_CLASS_SET);
|
||||
if (!s)
|
||||
goto exception;
|
||||
// order matters!
|
||||
if (js_setlike_get_size(ctx, argv[0], &size) < 0)
|
||||
goto exception;
|
||||
if (js_setlike_get_has(ctx, argv[0], &has) < 0)
|
||||
goto exception;
|
||||
if (js_setlike_get_keys(ctx, argv[0], &keys) < 0)
|
||||
goto exception;
|
||||
if (s->record_count > size) {
|
||||
iter = JS_Call(ctx, keys, argv[0], 0, NULL);
|
||||
if (JS_IsException(iter))
|
||||
goto exception;
|
||||
next = JS_GetProperty(ctx, iter, JS_ATOM_next);
|
||||
if (JS_IsException(next))
|
||||
goto exception;
|
||||
found = FALSE;
|
||||
do {
|
||||
item = JS_IteratorNext(ctx, iter, next, 0, NULL, &done);
|
||||
if (JS_IsException(item))
|
||||
goto exception;
|
||||
if (done) // item is JS_UNDEFINED
|
||||
break;
|
||||
item = map_normalize_key(ctx, item);
|
||||
found = (NULL != map_find_record(ctx, s, item));
|
||||
JS_FreeValue(ctx, item);
|
||||
} while (!found);
|
||||
} else {
|
||||
iter = js_create_map_iterator(ctx, this_val, 0, NULL, MAGIC_SET);
|
||||
if (JS_IsException(iter))
|
||||
goto exception;
|
||||
found = FALSE;
|
||||
do {
|
||||
item = js_map_iterator_next(ctx, iter, 0, NULL, &done, MAGIC_SET);
|
||||
if (JS_IsException(item))
|
||||
goto exception;
|
||||
if (done) // item is JS_UNDEFINED
|
||||
break;
|
||||
rv = JS_Call(ctx, has, argv[0], 1, &item);
|
||||
JS_FreeValue(ctx, item);
|
||||
ok = JS_ToBoolFree(ctx, rv); // returns -1 if rv is JS_EXCEPTION
|
||||
if (ok < 0)
|
||||
goto exception;
|
||||
found = (ok > 0);
|
||||
} while (!found);
|
||||
}
|
||||
rval = !found ? JS_TRUE : JS_FALSE;
|
||||
exception:
|
||||
JS_FreeValue(ctx, has);
|
||||
JS_FreeValue(ctx, keys);
|
||||
JS_FreeValue(ctx, iter);
|
||||
JS_FreeValue(ctx, next);
|
||||
return rval;
|
||||
}
|
||||
|
||||
static JSValue js_set_intersection(JSContext *ctx, JSValue this_val,
|
||||
int argc, JSValue *argv)
|
||||
{
|
||||
|
@ -46668,6 +46738,7 @@ static const JSCFunctionListEntry js_set_proto_funcs[] = {
|
|||
JS_CFUNC_MAGIC_DEF("clear", 0, js_map_clear, MAGIC_SET ),
|
||||
JS_CGETSET_MAGIC_DEF("size", js_map_get_size, NULL, MAGIC_SET ),
|
||||
JS_CFUNC_MAGIC_DEF("forEach", 1, js_map_forEach, MAGIC_SET ),
|
||||
JS_CFUNC_DEF("isDisjointFrom", 1, js_set_isDisjointFrom ),
|
||||
JS_CFUNC_DEF("intersection", 1, js_set_intersection ),
|
||||
JS_CFUNC_DEF("difference", 1, js_set_difference ),
|
||||
JS_CFUNC_DEF("symmetricDifference", 1, js_set_symmetricDifference ),
|
||||
|
|
|
@ -72,44 +72,6 @@ test262/test/built-ins/RegExp/property-escapes/generated/XID_Start.js:16: Test26
|
|||
test262/test/built-ins/RegExp/property-escapes/generated/XID_Start.js:16: strict mode: Test262Error: `\p{XID_Start}` should match U+02EBF0 (``)
|
||||
test262/test/built-ins/RegExp/unicode_full_case_folding.js:20: Test262Error: \u0390 does not match \u1fd3
|
||||
test262/test/built-ins/RegExp/unicode_full_case_folding.js:20: strict mode: Test262Error: \u0390 does not match \u1fd3
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/allows-set-like-class.js:30: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/allows-set-like-class.js:30: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/allows-set-like-object.js:28: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/allows-set-like-object.js:28: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/builtins.js:9: Test262Error: Built-in objects must be extensible. Expected SameValue(«false», «true») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/builtins.js:9: strict mode: Test262Error: Built-in objects must be extensible. Expected SameValue(«false», «true») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-Map.js:15: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-Map.js:15: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-empty-sets.js:12: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-empty-sets.js:12: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-itself.js:11: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-itself.js:11: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-same-sets.js:12: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-same-sets.js:12: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-sets.js:12: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/compares-sets.js:12: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/converts-negative-zero.js:22: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/converts-negative-zero.js:22: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/isDisjointFrom.js:10: Test262Error: `typeof Set.prototype.isDisjointFrom` is `'function'` Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/isDisjointFrom.js:10: strict mode: Test262Error: `typeof Set.prototype.isDisjointFrom` is `'function'` Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/length.js:11: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/length.js:11: strict mode: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/name.js:11: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/name.js:11: strict mode: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js:17: Test262Error: isConstructor invoked with a non-function value
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/not-a-constructor.js:17: strict mode: Test262Error: isConstructor invoked with a non-function value
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/require-internal-slot.js:17: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/require-internal-slot.js:17: strict mode: Test262Error: Expected SameValue(«undefined», «function») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-array.js:20: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-array.js:20: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-class-mutation.js:34: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-class-mutation.js:34: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-class-order.js:67: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/set-like-class-order.js:67: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/size-is-a-number.js:24: Test262Error: GetSetRecord coerces size Expected SameValue(«0», «1») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/size-is-a-number.js:24: strict mode: Test262Error: GetSetRecord coerces size Expected SameValue(«0», «1») to be true
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js:32: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isDisjointFrom/subclass-receiver-methods.js:32: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isSubsetOf/allows-set-like-class.js:31: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isSubsetOf/allows-set-like-class.js:31: strict mode: TypeError: not a function
|
||||
test262/test/built-ins/Set/prototype/isSubsetOf/allows-set-like-object.js:29: TypeError: not a function
|
||||
|
|
Loading…
Reference in a new issue