jseption 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -4
- package/dist/atoms.d.ts +1 -0
- package/dist/atoms.js +2 -1
- package/dist/atoms.js.map +1 -1
- package/dist/builtins/base64.d.ts +14 -0
- package/dist/builtins/base64.js +219 -0
- package/dist/builtins/base64.js.map +1 -0
- package/dist/builtins/bigint.js +3 -3
- package/dist/builtins/bigint.js.map +1 -1
- package/dist/builtins/date.d.ts +1 -0
- package/dist/builtins/date.js +26 -12
- package/dist/builtins/date.js.map +1 -1
- package/dist/builtins/error.js +9 -0
- package/dist/builtins/error.js.map +1 -1
- package/dist/builtins/float16.d.ts +3 -0
- package/dist/builtins/float16.js +69 -0
- package/dist/builtins/float16.js.map +1 -0
- package/dist/builtins/function.js +2 -2
- package/dist/builtins/index.js +9 -6
- package/dist/builtins/index.js.map +1 -1
- package/dist/builtins/iterator.d.ts +2 -0
- package/dist/builtins/iterator.js +624 -0
- package/dist/builtins/iterator.js.map +1 -0
- package/dist/builtins/json.d.ts +13 -1
- package/dist/builtins/json.js +283 -211
- package/dist/builtins/json.js.map +1 -1
- package/dist/builtins/mapset.js +365 -6
- package/dist/builtins/mapset.js.map +1 -1
- package/dist/builtins/math.js +203 -3
- package/dist/builtins/math.js.map +1 -1
- package/dist/builtins/native.js +6 -6
- package/dist/builtins/object.js +9 -2
- package/dist/builtins/object.js.map +1 -1
- package/dist/builtins/promise.js +31 -11
- package/dist/builtins/promise.js.map +1 -1
- package/dist/builtins/proxy.js +2 -2
- package/dist/builtins/reflect.js +6 -2
- package/dist/builtins/reflect.js.map +1 -1
- package/dist/builtins/regexp.js +74 -3
- package/dist/builtins/regexp.js.map +1 -1
- package/dist/builtins/string.js +1 -1
- package/dist/builtins/symbol.js +1 -1
- package/dist/builtins/symbol.js.map +1 -1
- package/dist/builtins/typedarray.d.ts +1 -0
- package/dist/builtins/typedarray.js +302 -32
- package/dist/builtins/typedarray.js.map +1 -1
- package/dist/builtins/weakref.js +7 -7
- package/dist/embed.d.ts +5 -0
- package/dist/embed.js +47 -15
- package/dist/embed.js.map +1 -1
- package/dist/interpreter.js +15 -14
- package/dist/interpreter.js.map +1 -1
- package/dist/jit.d.ts +1 -0
- package/dist/jit.js +51 -13
- package/dist/jit.js.map +1 -1
- package/dist/jit_hook.d.ts +1 -0
- package/dist/jit_hook.js.map +1 -1
- package/dist/jit_runtime.d.ts +1 -1
- package/dist/jit_runtime.js +6 -6
- package/dist/jit_runtime.js.map +1 -1
- package/dist/jit_stack.d.ts +1 -0
- package/dist/jit_stack.js +2 -1
- package/dist/jit_stack.js.map +1 -1
- package/dist/jseption.d.ts +4 -0
- package/dist/jseption.js +2 -0
- package/dist/jseption.js.map +1 -1
- package/dist/membrane.d.ts +16 -0
- package/dist/membrane.js +576 -0
- package/dist/membrane.js.map +1 -0
- package/dist/module.js +5 -3
- package/dist/module.js.map +1 -1
- package/dist/parser.js +26 -9
- package/dist/parser.js.map +1 -1
- package/dist/print.d.ts +12 -0
- package/dist/print.js +494 -0
- package/dist/print.js.map +1 -0
- package/dist/qjs.js +13 -10
- package/dist/qjs.js.map +1 -1
- package/dist/quickjs.d.ts +8 -0
- package/dist/quickjs.js +132 -53
- package/dist/quickjs.js.map +1 -1
- package/dist/std.d.ts +4 -2
- package/dist/std.js +42 -8
- package/dist/std.js.map +1 -1
- package/dist/values.d.ts +31 -27
- package/dist/values.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
package/dist/parser.js
CHANGED
|
@@ -890,9 +890,13 @@ function js_parse_number(s, p) {
|
|
|
890
890
|
if (last_was_sep)
|
|
891
891
|
return [js_parse_error_pos(s, p, 'invalid number literal'), p];
|
|
892
892
|
let is_bigint = false;
|
|
893
|
+
/* a fraction or an exponent (decimal literals only) rules out the BigInt suffix; the digits
|
|
894
|
+
themselves are not inspected, since 'e' is a hex digit */
|
|
895
|
+
let is_float = false;
|
|
893
896
|
if (radix === 10 && !is_legacy_octal) {
|
|
894
897
|
/* fraction and exponent */
|
|
895
898
|
if (buf.charCodeAt(p) === 46 /* . */) {
|
|
899
|
+
is_float = true;
|
|
896
900
|
text += '.';
|
|
897
901
|
p++;
|
|
898
902
|
last_was_sep = false;
|
|
@@ -949,6 +953,7 @@ function js_parse_number(s, p) {
|
|
|
949
953
|
if (last_was_sep)
|
|
950
954
|
return [js_parse_error_pos(s, q, 'invalid number literal'), q];
|
|
951
955
|
text += etext;
|
|
956
|
+
is_float = true;
|
|
952
957
|
p = q;
|
|
953
958
|
}
|
|
954
959
|
else {
|
|
@@ -959,7 +964,7 @@ function js_parse_number(s, p) {
|
|
|
959
964
|
else if (ndigits === 0) {
|
|
960
965
|
return [js_parse_error_pos(s, start, 'invalid number literal'), p];
|
|
961
966
|
}
|
|
962
|
-
if (buf.charCodeAt(p) === 110 /* n */ && !is_legacy_octal && !
|
|
967
|
+
if (buf.charCodeAt(p) === 110 /* n */ && !is_legacy_octal && !is_float) {
|
|
963
968
|
is_bigint = true;
|
|
964
969
|
p++;
|
|
965
970
|
}
|
|
@@ -4474,7 +4479,8 @@ function js_parse_property_name(s, out, allow_method, allow_var, allow_private)
|
|
|
4474
4479
|
else if (tv(s) === 91 /* [ */) {
|
|
4475
4480
|
if (next_token(s))
|
|
4476
4481
|
return -1;
|
|
4477
|
-
|
|
4482
|
+
/* ComputedPropertyName: [ AssignmentExpression ] (a comma expression is a syntax error) */
|
|
4483
|
+
if (js_parse_assign_expr(s))
|
|
4478
4484
|
return -1;
|
|
4479
4485
|
if (js_parse_expect(s, 93))
|
|
4480
4486
|
return -1;
|
|
@@ -5552,6 +5558,9 @@ function js_parse_postfix_expr(s, parse_flags) {
|
|
|
5552
5558
|
let has_optional_chain = false;
|
|
5553
5559
|
let action = 'none';
|
|
5554
5560
|
if (tv(s) === -89 /* TOK.QUESTION_MARK_DOT */) {
|
|
5561
|
+
/* the callee of `new` cannot contain an optional chain (`new a?.b()`) */
|
|
5562
|
+
if ((parse_flags & PF_POSTFIX_CALL) === 0)
|
|
5563
|
+
return js_parse_error(s, 'new keyword cannot be used with an optional chain');
|
|
5555
5564
|
op_token_ptr = s.token.ptr;
|
|
5556
5565
|
/* optional chaining */
|
|
5557
5566
|
if (next_token(s))
|
|
@@ -6810,6 +6819,8 @@ function js_parse_var(s, parse_flags, tok, export_flag) {
|
|
|
6810
6819
|
if (export_flag && add_local_export(s, name))
|
|
6811
6820
|
return -1;
|
|
6812
6821
|
if (tv(s) === 61 /* = */) {
|
|
6822
|
+
/* an error storing the value is reported at the '=' (upstream 14a1536) */
|
|
6823
|
+
const source_ptr = s.token.ptr;
|
|
6813
6824
|
if (next_token(s))
|
|
6814
6825
|
return -1;
|
|
6815
6826
|
if (need_var_reference(s, tok)) {
|
|
@@ -6823,12 +6834,14 @@ function js_parse_var(s, parse_flags, tok, export_flag) {
|
|
|
6823
6834
|
if (js_parse_assign_expr2(s, parse_flags))
|
|
6824
6835
|
return -1;
|
|
6825
6836
|
set_object_name(s, name);
|
|
6837
|
+
emit_source_pos(s, source_ptr);
|
|
6826
6838
|
put_lvalue(s, lv, 0 /* PutLValueEnum.PUT_LVALUE_NOKEEP */, false);
|
|
6827
6839
|
}
|
|
6828
6840
|
else {
|
|
6829
6841
|
if (js_parse_assign_expr2(s, parse_flags))
|
|
6830
6842
|
return -1;
|
|
6831
6843
|
set_object_name(s, name);
|
|
6844
|
+
emit_source_pos(s, source_ptr);
|
|
6832
6845
|
emit_op(s, (tok === -55 /* TOK.CONST */ || tok === -47 /* TOK.LET */) ? 191 /* OP.scope_put_var_init */ : 187 /* OP.scope_put_var */);
|
|
6833
6846
|
emit_atom(s, name);
|
|
6834
6847
|
emit_u16(s, fd.scope_level);
|
|
@@ -7006,8 +7019,7 @@ function js_parse_for_in_of(s, label_name, is_async) {
|
|
|
7006
7019
|
}
|
|
7007
7020
|
}
|
|
7008
7021
|
if (token_is_pseudo_keyword(s, JS_ATOM_of)) {
|
|
7009
|
-
|
|
7010
|
-
break_entry.drop_count += 2;
|
|
7022
|
+
is_for_of = true;
|
|
7011
7023
|
if (has_initializer)
|
|
7012
7024
|
return js_parse_error(s, "a declaration in the head of a for-of loop can't have an initializer");
|
|
7013
7025
|
}
|
|
@@ -7034,6 +7046,10 @@ function js_parse_for_in_of(s, label_name, is_async) {
|
|
|
7034
7046
|
/* close the scope after having evaluated the expression so that the TDZ values are in the closures */
|
|
7035
7047
|
close_scopes(s, fd.scope_level, block_scope_level);
|
|
7036
7048
|
if (is_for_of) {
|
|
7049
|
+
/* set has_iterator after the iterable expression is parsed so that a yield in the expression
|
|
7050
|
+
does not try to close a not-yet-created iterator */
|
|
7051
|
+
break_entry.has_iterator = true;
|
|
7052
|
+
break_entry.drop_count += 2;
|
|
7037
7053
|
if (is_async)
|
|
7038
7054
|
emit_op(s, 128 /* OP.for_await_of_start */);
|
|
7039
7055
|
else
|
|
@@ -9087,7 +9103,7 @@ function js_parse_module_export_name(s, out) {
|
|
|
9087
9103
|
let atom;
|
|
9088
9104
|
if (tv(s) === -127 /* TOK.STRING */) {
|
|
9089
9105
|
if (!is_well_formed_string(s.token.str)) {
|
|
9090
|
-
js_parse_error(s, '
|
|
9106
|
+
js_parse_error(s, 'contains unpaired surrogate');
|
|
9091
9107
|
return JS_ATOM_NULL;
|
|
9092
9108
|
}
|
|
9093
9109
|
atom = JS_NewAtom(s.ctx, s.token.str);
|
|
@@ -9131,21 +9147,22 @@ function js_parse_with_clause(s, out) {
|
|
|
9131
9147
|
return -1;
|
|
9132
9148
|
const attrs = Object.create(null);
|
|
9133
9149
|
while (tv(s) !== 125) {
|
|
9150
|
+
const key_token_ptr = s.token.ptr;
|
|
9134
9151
|
let key;
|
|
9135
9152
|
if (tv(s) === -127 /* TOK.STRING */)
|
|
9136
9153
|
key = s.token.str;
|
|
9137
9154
|
else if (token_is_ident_or_keyword(tv(s)) || token_is_ident(tv(s)))
|
|
9138
9155
|
key = JS_AtomGetStr(s.ctx, s.token.atom);
|
|
9139
9156
|
else
|
|
9140
|
-
return js_parse_error(s, 'identifier
|
|
9141
|
-
if (Object.prototype.hasOwnProperty.call(attrs, key))
|
|
9142
|
-
return js_parse_error(s, `duplicate import attribute '${key}'`);
|
|
9157
|
+
return js_parse_error(s, 'identifier expected');
|
|
9143
9158
|
if (next_token(s))
|
|
9144
9159
|
return -1;
|
|
9145
9160
|
if (js_parse_expect(s, 58))
|
|
9146
9161
|
return -1;
|
|
9147
9162
|
if (tv(s) !== -127 /* TOK.STRING */)
|
|
9148
|
-
return
|
|
9163
|
+
return js_parse_error_pos(s, key_token_ptr, 'string expected');
|
|
9164
|
+
if (Object.prototype.hasOwnProperty.call(attrs, key))
|
|
9165
|
+
return js_parse_error(s, 'duplicate with key');
|
|
9149
9166
|
attrs[key] = s.token.str;
|
|
9150
9167
|
if (next_token(s))
|
|
9151
9168
|
return -1;
|