MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve object primitive handling

+29 -12
+4 -4
examples/results.txt
··· 638 638 compat-table/es6/Reflect.has.js: OK 639 639 compat-table/es6/Reflect.isExtensible.js: OK 640 640 compat-table/es6/Reflect.ownKeys.string.js: OK 641 - compat-table/es6/Reflect.ownKeys.symbol.js: failed 641 + compat-table/es6/Reflect.ownKeys.symbol.js: OK 642 642 compat-table/es6/Reflect.preventExtensions.js: OK 643 643 compat-table/es6/Reflect.setPrototypeOf.js: OK 644 644 compat-table/es6/Reflect.set.js: OK ··· 944 944 compat-table/es6/misc.Invalid-Date.js: OK 945 945 compat-table/es6/misc.Object.freeze.primitives.js: OK 946 946 compat-table/es6/misc.Object.getOwnPropertyDescriptor.primitives.js: OK 947 - compat-table/es6/misc.Object.getOwnPropertyNames.primitives.js: failed 947 + compat-table/es6/misc.Object.getOwnPropertyNames.primitives.js: OK 948 948 compat-table/es6/misc.Object.getPrototypeOf.primitives.js: OK 949 - compat-table/es6/misc.Object.isExtensible.primitives.js: failed 949 + compat-table/es6/misc.Object.isExtensible.primitives.js: OK 950 950 compat-table/es6/misc.Object.isFrozen.primitives.js: OK 951 951 compat-table/es6/misc.Object.isSealed.primitives.js: OK 952 - compat-table/es6/misc.Object.keys.primitives.js: failed 952 + compat-table/es6/misc.Object.keys.primitives.js: OK 953 953 compat-table/es6/misc.Object.preventExtensions.primitives.js: OK 954 954 compat-table/es6/misc.Object.seal.primitives.js: OK 955 955 compat-table/es6/misc.Proxy.defineProperty.SetIntegrityLevel.js: failed
+21 -3
src/ant.c
··· 6575 6575 6576 6576 static ant_value_t builtin_object_keys(ant_t *js, ant_value_t *args, int nargs) { 6577 6577 if (nargs == 0) return mkarr(js); 6578 + 6578 6579 ant_value_t obj = args[0]; 6580 + if (vtype(obj) == T_STR) return js_for_in_keys(js, obj); 6581 + 6579 6582 if (vtype(obj) == T_CFUNC) { 6580 6583 ant_value_t promoted = js_cfunc_lookup_promoted(js, obj); 6581 6584 if (vtype(promoted) != T_FUNC) return mkarr(js); 6582 6585 obj = promoted; 6583 6586 } 6584 - if (vtype(obj) != T_OBJ && vtype(obj) != T_ARR && vtype(obj) != T_FUNC) return mkarr(js); 6585 6587 6588 + if (vtype(obj) != T_OBJ && vtype(obj) != T_ARR && vtype(obj) != T_FUNC) return mkarr(js); 6586 6589 if (is_proxy(obj)) return proxy_enum(js, obj, OBJ_ENUM_KEYS); 6587 6590 6588 6591 return object_enum(js, obj, OBJ_ENUM_KEYS); ··· 7996 7999 if (nargs == 0) return mkarr(js); 7997 8000 ant_value_t obj = args[0]; 7998 8001 8002 + if (vtype(obj) == T_STR) { 8003 + ant_value_t arr = mkarr(js); 8004 + ant_offset_t idx = 0; 8005 + ant_offset_t slen = vstrlen(js, obj); 8006 + 8007 + for (ant_offset_t i = 0; i < slen; i++) { 8008 + char idxstr[16]; 8009 + size_t idxlen = uint_to_str(idxstr, sizeof(idxstr), (uint64_t)i); 8010 + arr_set(js, arr, idx++, js_mkstr(js, idxstr, idxlen)); 8011 + } 8012 + 8013 + arr_set(js, arr, idx++, js->length_str); 8014 + return mkval(T_ARR, vdata(arr)); 8015 + } 8016 + 7999 8017 if (vtype(obj) == T_CFUNC) { 8000 8018 ant_value_t promoted = js_cfunc_lookup_promoted(js, obj); 8001 8019 if (vtype(promoted) == T_FUNC) obj = promoted; ··· 8138 8156 } 8139 8157 8140 8158 static ant_value_t builtin_object_isExtensible(ant_t *js, ant_value_t *args, int nargs) { 8141 - if (nargs == 0) return js_true; 8159 + if (nargs == 0) return js_false; 8142 8160 8143 8161 ant_value_t obj = args[0]; 8144 8162 uint8_t t = vtype(obj); 8145 8163 8146 - if (t != T_OBJ && t != T_ARR && t != T_FUNC) return js_true; 8164 + if (t != T_OBJ && t != T_ARR && t != T_FUNC) return js_false; 8147 8165 ant_value_t as_obj = js_as_obj(obj); 8148 8166 8149 8167 ant_object_t *ptr = js_obj_ptr(as_obj);
+4 -5
src/modules/reflect.c
··· 107 107 108 108 ant_value_t keys_arr = js_mkarr(js); 109 109 ant_iter_t iter = js_prop_iter_begin(js, target); 110 - const char *key; size_t key_len; ant_value_t value; 111 - 112 - while (js_prop_iter_next(&iter, &key, &key_len, &value)) { 113 - js_arr_push(js, keys_arr, js_mkstr(js, key, key_len)); 114 - } 110 + 111 + ant_value_t key, value; 112 + while (js_prop_iter_next_val(&iter, &key, &value)) 113 + js_arr_push(js, keys_arr, key); 115 114 116 115 js_prop_iter_end(&iter); 117 116 return keys_arr;