jseption 0.0.0-stage → 0.0.2

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.
Files changed (114) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +191 -2
  3. package/dist/atoms.d.ts +255 -0
  4. package/dist/atoms.js +445 -0
  5. package/dist/atoms.js.map +1 -0
  6. package/dist/builtins/array.d.ts +3 -0
  7. package/dist/builtins/array.js +116 -0
  8. package/dist/builtins/array.js.map +1 -0
  9. package/dist/builtins/bigint.d.ts +3 -0
  10. package/dist/builtins/bigint.js +122 -0
  11. package/dist/builtins/bigint.js.map +1 -0
  12. package/dist/builtins/boolean.d.ts +2 -0
  13. package/dist/builtins/boolean.js +26 -0
  14. package/dist/builtins/boolean.js.map +1 -0
  15. package/dist/builtins/date.d.ts +3 -0
  16. package/dist/builtins/date.js +1046 -0
  17. package/dist/builtins/date.js.map +1 -0
  18. package/dist/builtins/error.d.ts +2 -0
  19. package/dist/builtins/error.js +154 -0
  20. package/dist/builtins/error.js.map +1 -0
  21. package/dist/builtins/function.d.ts +5 -0
  22. package/dist/builtins/function.js +164 -0
  23. package/dist/builtins/function.js.map +1 -0
  24. package/dist/builtins/global.d.ts +2 -0
  25. package/dist/builtins/global.js +29 -0
  26. package/dist/builtins/global.js.map +1 -0
  27. package/dist/builtins/index.d.ts +3 -0
  28. package/dist/builtins/index.js +139 -0
  29. package/dist/builtins/index.js.map +1 -0
  30. package/dist/builtins/json.d.ts +6 -0
  31. package/dist/builtins/json.js +984 -0
  32. package/dist/builtins/json.js.map +1 -0
  33. package/dist/builtins/mapset.d.ts +4 -0
  34. package/dist/builtins/mapset.js +234 -0
  35. package/dist/builtins/mapset.js.map +1 -0
  36. package/dist/builtins/math.d.ts +2 -0
  37. package/dist/builtins/math.js +62 -0
  38. package/dist/builtins/math.js.map +1 -0
  39. package/dist/builtins/native.d.ts +22 -0
  40. package/dist/builtins/native.js +250 -0
  41. package/dist/builtins/native.js.map +1 -0
  42. package/dist/builtins/number.d.ts +4 -0
  43. package/dist/builtins/number.js +76 -0
  44. package/dist/builtins/number.js.map +1 -0
  45. package/dist/builtins/object.d.ts +12 -0
  46. package/dist/builtins/object.js +575 -0
  47. package/dist/builtins/object.js.map +1 -0
  48. package/dist/builtins/promise.d.ts +13 -0
  49. package/dist/builtins/promise.js +582 -0
  50. package/dist/builtins/promise.js.map +1 -0
  51. package/dist/builtins/proxy.d.ts +3 -0
  52. package/dist/builtins/proxy.js +226 -0
  53. package/dist/builtins/proxy.js.map +1 -0
  54. package/dist/builtins/reflect.d.ts +2 -0
  55. package/dist/builtins/reflect.js +109 -0
  56. package/dist/builtins/reflect.js.map +1 -0
  57. package/dist/builtins/regexp.d.ts +2 -0
  58. package/dist/builtins/regexp.js +203 -0
  59. package/dist/builtins/regexp.js.map +1 -0
  60. package/dist/builtins/string.d.ts +4 -0
  61. package/dist/builtins/string.js +135 -0
  62. package/dist/builtins/string.js.map +1 -0
  63. package/dist/builtins/symbol.d.ts +3 -0
  64. package/dist/builtins/symbol.js +98 -0
  65. package/dist/builtins/symbol.js.map +1 -0
  66. package/dist/builtins/typedarray.d.ts +15 -0
  67. package/dist/builtins/typedarray.js +1838 -0
  68. package/dist/builtins/typedarray.js.map +1 -0
  69. package/dist/builtins/weakref.d.ts +18 -0
  70. package/dist/builtins/weakref.js +130 -0
  71. package/dist/builtins/weakref.js.map +1 -0
  72. package/dist/dump.d.ts +2 -0
  73. package/dist/dump.js +124 -0
  74. package/dist/dump.js.map +1 -0
  75. package/dist/embed.d.ts +18 -0
  76. package/dist/embed.js +286 -0
  77. package/dist/embed.js.map +1 -0
  78. package/dist/interpreter.d.ts +81 -0
  79. package/dist/interpreter.js +3768 -0
  80. package/dist/interpreter.js.map +1 -0
  81. package/dist/jit.d.ts +59 -0
  82. package/dist/jit.js +3440 -0
  83. package/dist/jit.js.map +1 -0
  84. package/dist/jit_hook.d.ts +21 -0
  85. package/dist/jit_hook.js +4 -0
  86. package/dist/jit_hook.js.map +1 -0
  87. package/dist/jit_runtime.d.ts +104 -0
  88. package/dist/jit_runtime.js +721 -0
  89. package/dist/jit_runtime.js.map +1 -0
  90. package/dist/jit_stack.d.ts +24 -0
  91. package/dist/jit_stack.js +227 -0
  92. package/dist/jit_stack.js.map +1 -0
  93. package/dist/jseption.d.ts +15 -0
  94. package/dist/jseption.js +61 -0
  95. package/dist/jseption.js.map +1 -0
  96. package/dist/opcodes.d.ts +347 -0
  97. package/dist/opcodes.js +322 -0
  98. package/dist/opcodes.js.map +1 -0
  99. package/dist/parser.d.ts +283 -0
  100. package/dist/parser.js +9752 -0
  101. package/dist/parser.js.map +1 -0
  102. package/dist/qjs.d.ts +2 -0
  103. package/dist/qjs.js +122 -0
  104. package/dist/qjs.js.map +1 -0
  105. package/dist/quickjs.d.ts +460 -0
  106. package/dist/quickjs.js +3408 -0
  107. package/dist/quickjs.js.map +1 -0
  108. package/dist/std.d.ts +4 -0
  109. package/dist/std.js +273 -0
  110. package/dist/std.js.map +1 -0
  111. package/dist/values.d.ts +447 -0
  112. package/dist/values.js +461 -0
  113. package/dist/values.js.map +1 -0
  114. package/package.json +59 -4
@@ -0,0 +1,139 @@
1
+ import { JS_NewObjectProto, JS_NewObjectProtoClass, JS_NewCFunction3, JS_NewCFunction, JS_NewCFunctionMagic, JS_DefinePropertyValue, JS_DefinePropertyValueStr, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_ThrowTypeError, JS_SetPropertyFunctionList, JS_NATIVE_DEF, JS_PROP_STRING_DEF, JS_SetConstructor2, JS_PreventExtensions, JS_ATOM_Symbol_iterator, JS_ATOM_Symbol_asyncIterator, JS_ATOM_Symbol_toStringTag, JS_ATOM_values, JS_EvalThis, JS_GetProperty, JS_GetPropertyStr, JS_EVAL_TYPE_INDIRECT, hooks, } from "../quickjs.js";
2
+ import { js_generator_proto_funcs, js_generator_function_proto_funcs, js_async_function_proto_funcs, js_async_generator_proto_funcs, js_async_generator_function_proto_funcs, js_async_from_sync_iterator_proto_funcs, } from "../interpreter.js";
3
+ import { HOST_ARRAY_ITERATOR_PROTO, fix_iter_result_entries } from "./native.js";
4
+ import { JS_AddIntrinsicError } from "./error.js";
5
+ import { JS_AddIntrinsicSymbol } from "./symbol.js";
6
+ import { JS_AddIntrinsicFunction, js_function_proto, js_function_constructor } from "./function.js";
7
+ import { JS_AddIntrinsicPromise } from "./promise.js";
8
+ import { JS_AddIntrinsicObject } from "./object.js";
9
+ import { JS_AddIntrinsicArray } from "./array.js";
10
+ import { JS_AddIntrinsicNumber } from "./number.js";
11
+ import { JS_AddIntrinsicBoolean } from "./boolean.js";
12
+ import { JS_AddIntrinsicString } from "./string.js";
13
+ import { JS_AddIntrinsicMath } from "./math.js";
14
+ import { JS_AddIntrinsicJSON } from "./json.js";
15
+ import { JS_AddIntrinsicReflect } from "./reflect.js";
16
+ import { JS_AddIntrinsicMapSet } from "./mapset.js";
17
+ import { JS_AddIntrinsicRegExp } from "./regexp.js";
18
+ import { JS_AddIntrinsicDate } from "./date.js";
19
+ import { JS_AddIntrinsicBigInt } from "./bigint.js";
20
+ import { JS_AddIntrinsicProxy } from "./proxy.js";
21
+ import { JS_AddIntrinsicTypedArrays } from "./typedarray.js";
22
+ import { JS_AddIntrinsicGlobal } from "./global.js";
23
+ import { JS_AddIntrinsicWeakRef } from "./weakref.js";
24
+ /* %IteratorPrototype%[Symbol.iterator]() and %AsyncIteratorPrototype%[Symbol.asyncIterator]() */
25
+ function js_iterator_proto_iterator(ctx, this_val, argv) {
26
+ return this_val;
27
+ }
28
+ /* Array iterator: the host array iterators (created by the borrowed
29
+ Array.prototype.values/keys/entries and the typed array equivalents) are
30
+ re-prototyped to this prototype, whose `next` is the host one */
31
+ const js_array_iterator_proto_funcs = [
32
+ JS_NATIVE_DEF('next', 0, HOST_ARRAY_ITERATOR_PROTO.next, fix_iter_result_entries),
33
+ JS_PROP_STRING_DEF(JS_ATOM_Symbol_toStringTag, 'Array Iterator', JS_PROP_CONFIGURABLE),
34
+ ];
35
+ function js_throw_type_error(ctx, this_val, argv) {
36
+ return JS_ThrowTypeError(ctx, 'invalid property access');
37
+ }
38
+ /* indirect eval */
39
+ function js_global_eval(ctx, this_val, argv) {
40
+ const val = argv[0];
41
+ if (typeof val !== 'string')
42
+ return val;
43
+ return JS_EvalThis(ctx, ctx.global_obj, val, '<input>', JS_EVAL_TYPE_INDIRECT);
44
+ }
45
+ export function JS_AddIntrinsicBasicObjects(ctx) {
46
+ const proto = ctx.class_proto[1 /* JSClassID.OBJECT */];
47
+ /* Function.prototype is itself a (C) function */
48
+ ctx.function_proto = JS_NewCFunction3(ctx, js_function_proto, '', 0, 0 /* JSCFunctionEnum.generic */, 0, proto);
49
+ /* 'caller' and 'arguments' accessors throw in strict mode */
50
+ ctx.throw_type_error = JS_NewCFunction(ctx, js_throw_type_error, '', 0);
51
+ JS_PreventExtensions(ctx, ctx.throw_type_error);
52
+ /* ArrayPrototype (needed early for JS_NewArray): an array exotic object */
53
+ ctx.class_proto[2 /* JSClassID.ARRAY */] = JS_NewObjectProtoClass(ctx, proto, 2 /* JSClassID.ARRAY */);
54
+ /* XXX: could use a specific class for the arguments prototype */
55
+ ctx.class_proto[8 /* JSClassID.ARGUMENTS */] = ctx.class_proto[1 /* JSClassID.OBJECT */];
56
+ ctx.class_proto[9 /* JSClassID.MAPPED_ARGUMENTS */] = ctx.class_proto[1 /* JSClassID.OBJECT */];
57
+ /* iterator prototypes */
58
+ ctx.iterator_proto = JS_NewObjectProto(ctx, proto);
59
+ const iter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.iterator]', 0, 0 /* JSCFunctionEnum.generic */, 0, ctx.function_proto);
60
+ JS_DefinePropertyValue(ctx, ctx.iterator_proto, JS_ATOM_Symbol_iterator, iter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
61
+ ctx.async_iterator_proto = JS_NewObjectProto(ctx, proto);
62
+ const aiter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.asyncIterator]', 0, 0 /* JSCFunctionEnum.generic */, 0, ctx.function_proto);
63
+ JS_DefinePropertyValue(ctx, ctx.async_iterator_proto, JS_ATOM_Symbol_asyncIterator, aiter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
64
+ /* Array iterator */
65
+ ctx.array_iterator_proto = JS_NewObjectProto(ctx, ctx.iterator_proto);
66
+ ctx.class_proto[40 /* JSClassID.ARRAY_ITERATOR */] = ctx.array_iterator_proto;
67
+ JS_SetPropertyFunctionList(ctx, ctx.array_iterator_proto, js_array_iterator_proto_funcs);
68
+ }
69
+ export function JS_AddIntrinsicBaseObjects(ctx) {
70
+ JS_AddIntrinsicBasicObjects(ctx);
71
+ /* global object: globalThis */
72
+ JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'globalThis', ctx.global_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
73
+ JS_AddIntrinsicObject(ctx);
74
+ JS_AddIntrinsicFunction(ctx);
75
+ JS_AddIntrinsicError(ctx);
76
+ JS_AddIntrinsicSymbol(ctx);
77
+ JS_AddIntrinsicArray(ctx);
78
+ /* Array.prototype.values (=== Array.prototype[Symbol.iterator]) */
79
+ ctx.array_proto_values = JS_GetProperty(ctx, ctx.class_proto[2 /* JSClassID.ARRAY */], JS_ATOM_values);
80
+ JS_AddIntrinsicNumber(ctx);
81
+ JS_AddIntrinsicBoolean(ctx);
82
+ JS_AddIntrinsicString(ctx);
83
+ JS_AddIntrinsicMath(ctx);
84
+ JS_AddIntrinsicJSON(ctx);
85
+ JS_AddIntrinsicReflect(ctx);
86
+ JS_AddIntrinsicMapSet(ctx);
87
+ JS_AddIntrinsicRegExp(ctx);
88
+ JS_AddIntrinsicDate(ctx);
89
+ JS_AddIntrinsicBigInt(ctx);
90
+ JS_AddIntrinsicProxy(ctx);
91
+ JS_AddIntrinsicTypedArrays(ctx);
92
+ JS_AddIntrinsicWeakRef(ctx);
93
+ /* eval */
94
+ const eval_obj = JS_NewCFunction(ctx, js_global_eval, 'eval', 1);
95
+ JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'eval', eval_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
96
+ ctx.eval_obj = eval_obj;
97
+ JS_AddIntrinsicGlobal(ctx);
98
+ /* Number.parseInt / Number.parseFloat are the global functions */
99
+ const number_ctor = JS_GetPropertyStr(ctx, ctx.global_obj, 'Number');
100
+ for (const name of ['parseInt', 'parseFloat']) {
101
+ JS_DefinePropertyValueStr(ctx, number_ctor, name, JS_GetPropertyStr(ctx, ctx.global_obj, name), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);
102
+ }
103
+ /* Generator */
104
+ const gen_proto = JS_NewObjectProto(ctx, ctx.iterator_proto);
105
+ ctx.class_proto[43 /* JSClassID.GENERATOR */] = gen_proto;
106
+ ctx.generator_proto = gen_proto;
107
+ JS_SetPropertyFunctionList(ctx, gen_proto, js_generator_proto_funcs);
108
+ const gen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
109
+ ctx.class_proto[16 /* JSClassID.GENERATOR_FUNCTION */] = gen_func_proto;
110
+ const gen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'GeneratorFunction', 1, 5 /* JSCFunctionEnum.constructor_or_func_magic */, 1 /* JSFunctionKind.GENERATOR */);
111
+ JS_SetPropertyFunctionList(ctx, gen_func_proto, js_generator_function_proto_funcs);
112
+ JS_SetConstructor2(ctx, gen_func_proto, gen_proto, 0, JS_PROP_CONFIGURABLE);
113
+ JS_SetConstructor2(ctx, gen_ctor, gen_func_proto, 0, JS_PROP_CONFIGURABLE);
114
+ /* Promise */
115
+ JS_AddIntrinsicPromise(ctx);
116
+ /* AsyncFunction */
117
+ const async_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
118
+ ctx.class_proto[48 /* JSClassID.ASYNC_FUNCTION */] = async_func_proto;
119
+ const async_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncFunction', 1, 5 /* JSCFunctionEnum.constructor_or_func_magic */, 2 /* JSFunctionKind.ASYNC */);
120
+ JS_SetPropertyFunctionList(ctx, async_func_proto, js_async_function_proto_funcs);
121
+ JS_SetConstructor2(ctx, async_ctor, async_func_proto, 0, JS_PROP_CONFIGURABLE);
122
+ /* AsyncIteratorPrototype / AsyncFromSyncIterator */
123
+ const afs_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto);
124
+ ctx.class_proto[51 /* JSClassID.ASYNC_FROM_SYNC_ITERATOR */] = afs_proto;
125
+ JS_SetPropertyFunctionList(ctx, afs_proto, js_async_from_sync_iterator_proto_funcs);
126
+ /* AsyncGenerator */
127
+ const agen_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto);
128
+ ctx.class_proto[53 /* JSClassID.ASYNC_GENERATOR */] = agen_proto;
129
+ ctx.async_generator_proto = agen_proto;
130
+ JS_SetPropertyFunctionList(ctx, agen_proto, js_async_generator_proto_funcs);
131
+ const agen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto);
132
+ ctx.class_proto[52 /* JSClassID.ASYNC_GENERATOR_FUNCTION */] = agen_func_proto;
133
+ const agen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncGeneratorFunction', 1, 5 /* JSCFunctionEnum.constructor_or_func_magic */, 3 /* JSFunctionKind.ASYNC_GENERATOR */);
134
+ JS_SetPropertyFunctionList(ctx, agen_func_proto, js_async_generator_function_proto_funcs);
135
+ JS_SetConstructor2(ctx, agen_func_proto, agen_proto, 0, JS_PROP_CONFIGURABLE);
136
+ JS_SetConstructor2(ctx, agen_ctor, agen_func_proto, 0, JS_PROP_CONFIGURABLE);
137
+ }
138
+ hooks.JS_AddIntrinsicBaseObjects = JS_AddIntrinsicBaseObjects;
139
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/builtins/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,iBAAiB,EAAE,sBAA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C;IAC/E,GAAG,CAAC,WAAW,6CAAoC,GAAG,eAAe,CAAC;IACtE,MAAM,SAAS,GAAG,oBAAoB,CAAC,GAAG,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC,4FAA4E,CAAC;IAC7K,0BAA0B,CAAC,GAAG,EAAE,eAAe,EAAE,uCAAuC,CAAC,CAAC;IAC1F,kBAAkB,CAAC,GAAG,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,EAAE,oBAAoB,CAAC,CAAC;IAC9E,kBAAkB,CAAC,GAAG,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,EAAE,oBAAoB,CAAC,CAAC;AAC/E,CAAC;AAED,KAAK,CAAC,0BAA0B,GAAG,0BAA0B,CAAC","sourcesContent":["/*\n * Intrinsic objects: port of JS_AddIntrinsicBasicObjects / JS_AddIntrinsicBaseObjects\n */\nimport * as Q from '../quickjs.ts';\nimport {\n JSContext, JSValue, JSObject, JSClassID, JSFunctionKind, JS_EXCEPTION, JS_IsException, JS_IsUndefined, JS_IsObject,\n JS_NewObjectProto, JS_NewObjectProtoClass, JS_NewCFunction3, JS_NewCFunction, JS_NewCFunctionMagic, JSCFunctionEnum,\n JS_DefinePropertyValue, JS_DefinePropertyValueStr, JS_PROP_WRITABLE, JS_PROP_CONFIGURABLE, JS_PROP_C_W_E,\n JS_ThrowTypeError, JS_SetPropertyFunctionList, JS_CFUNC_DEF, JS_CFUNC_MAGIC_DEF, JS_NATIVE_DEF,\n JS_PROP_STRING_DEF, JS_SetConstructor2, JS_PreventExtensions, JS_ATOM_Symbol_iterator,\n JS_ATOM_Symbol_asyncIterator, JS_ATOM_Symbol_toStringTag, JS_ATOM_length, JS_ATOM_name, JS_ATOM_values,\n JS_ATOM_Generator, JS_ATOM_prototype, JS_ATOM_constructor, JS_EvalThis, JS_GetProperty, JS_GetPropertyStr,\n JS_EVAL_TYPE_INDIRECT, hooks, JS_NewAtom, JS_ATOM_Symbol_hasInstance, JS_PROP_ENUMERABLE,\n} from '../quickjs.ts';\nimport {\n js_generator_proto_funcs, js_generator_function_proto_funcs, js_async_function_proto_funcs,\n js_async_generator_proto_funcs, js_async_generator_function_proto_funcs, js_async_from_sync_iterator_proto_funcs,\n} from '../interpreter.ts';\nimport { HOST_ARRAY_ITERATOR_PROTO, fix_iter_result_entries } from './native.ts';\nimport { JS_AddIntrinsicError } from './error.ts';\nimport { JS_AddIntrinsicSymbol } from './symbol.ts';\nimport { JS_AddIntrinsicFunction, js_function_proto, js_function_constructor, js_function_proto_caller } from './function.ts';\nimport { JS_AddIntrinsicPromise } from './promise.ts';\nimport { JS_AddIntrinsicObject } from './object.ts';\nimport { JS_AddIntrinsicArray } from './array.ts';\nimport { JS_AddIntrinsicNumber } from './number.ts';\nimport { JS_AddIntrinsicBoolean } from './boolean.ts';\nimport { JS_AddIntrinsicString } from './string.ts';\nimport { JS_AddIntrinsicMath } from './math.ts';\nimport { JS_AddIntrinsicJSON } from './json.ts';\nimport { JS_AddIntrinsicReflect } from './reflect.ts';\nimport { JS_AddIntrinsicMapSet } from './mapset.ts';\nimport { JS_AddIntrinsicRegExp } from './regexp.ts';\nimport { JS_AddIntrinsicDate } from './date.ts';\nimport { JS_AddIntrinsicBigInt } from './bigint.ts';\nimport { JS_AddIntrinsicProxy } from './proxy.ts';\nimport { JS_AddIntrinsicTypedArrays } from './typedarray.ts';\nimport { JS_AddIntrinsicGlobal } from './global.ts';\nimport { JS_AddIntrinsicWeakRef } from './weakref.ts';\n\n/* %IteratorPrototype%[Symbol.iterator]() and %AsyncIteratorPrototype%[Symbol.asyncIterator]() */\nfunction js_iterator_proto_iterator(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return this_val;\n}\n\n/* Array iterator: the host array iterators (created by the borrowed\n Array.prototype.values/keys/entries and the typed array equivalents) are\n re-prototyped to this prototype, whose `next` is the host one */\nconst js_array_iterator_proto_funcs = [\n JS_NATIVE_DEF('next', 0, (HOST_ARRAY_ITERATOR_PROTO as any).next, fix_iter_result_entries),\n JS_PROP_STRING_DEF(JS_ATOM_Symbol_toStringTag, 'Array Iterator', JS_PROP_CONFIGURABLE),\n];\n\nfunction js_throw_type_error(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n return JS_ThrowTypeError(ctx, 'invalid property access');\n}\n\n/* indirect eval */\nfunction js_global_eval(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue {\n const val = argv[0];\n if (typeof val !== 'string') return val;\n return JS_EvalThis(ctx, ctx.global_obj, val, '<input>', JS_EVAL_TYPE_INDIRECT);\n}\n\nexport function JS_AddIntrinsicBasicObjects(ctx: JSContext): void {\n const proto = ctx.class_proto[JSClassID.OBJECT]!;\n /* Function.prototype is itself a (C) function */\n ctx.function_proto = JS_NewCFunction3(ctx, js_function_proto, '', 0, JSCFunctionEnum.generic, 0, proto) as JSObject;\n /* 'caller' and 'arguments' accessors throw in strict mode */\n ctx.throw_type_error = JS_NewCFunction(ctx, js_throw_type_error, '', 0) as JSObject;\n JS_PreventExtensions(ctx, ctx.throw_type_error);\n /* ArrayPrototype (needed early for JS_NewArray): an array exotic object */\n ctx.class_proto[JSClassID.ARRAY] = JS_NewObjectProtoClass(ctx, proto, JSClassID.ARRAY) as JSObject;\n /* XXX: could use a specific class for the arguments prototype */\n ctx.class_proto[JSClassID.ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n ctx.class_proto[JSClassID.MAPPED_ARGUMENTS] = ctx.class_proto[JSClassID.OBJECT];\n /* iterator prototypes */\n ctx.iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const iter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.iterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.iterator_proto, JS_ATOM_Symbol_iterator, iter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.async_iterator_proto = JS_NewObjectProto(ctx, proto) as JSObject;\n const aiter_fn = JS_NewCFunction3(ctx, js_iterator_proto_iterator, '[Symbol.asyncIterator]', 0, JSCFunctionEnum.generic, 0, ctx.function_proto);\n JS_DefinePropertyValue(ctx, ctx.async_iterator_proto, JS_ATOM_Symbol_asyncIterator, aiter_fn, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n /* Array iterator */\n ctx.array_iterator_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ARRAY_ITERATOR] = ctx.array_iterator_proto;\n JS_SetPropertyFunctionList(ctx, ctx.array_iterator_proto, js_array_iterator_proto_funcs);\n}\n\nexport function JS_AddIntrinsicBaseObjects(ctx: JSContext): void {\n JS_AddIntrinsicBasicObjects(ctx);\n\n /* global object: globalThis */\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'globalThis', ctx.global_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n\n JS_AddIntrinsicObject(ctx);\n JS_AddIntrinsicFunction(ctx);\n JS_AddIntrinsicError(ctx);\n JS_AddIntrinsicSymbol(ctx);\n JS_AddIntrinsicArray(ctx);\n\n /* Array.prototype.values (=== Array.prototype[Symbol.iterator]) */\n ctx.array_proto_values = JS_GetProperty(ctx, ctx.class_proto[JSClassID.ARRAY]!, JS_ATOM_values);\n\n JS_AddIntrinsicNumber(ctx);\n JS_AddIntrinsicBoolean(ctx);\n JS_AddIntrinsicString(ctx);\n JS_AddIntrinsicMath(ctx);\n JS_AddIntrinsicJSON(ctx);\n JS_AddIntrinsicReflect(ctx);\n JS_AddIntrinsicMapSet(ctx);\n JS_AddIntrinsicRegExp(ctx);\n JS_AddIntrinsicDate(ctx);\n JS_AddIntrinsicBigInt(ctx);\n JS_AddIntrinsicProxy(ctx);\n JS_AddIntrinsicTypedArrays(ctx);\n JS_AddIntrinsicWeakRef(ctx);\n\n /* eval */\n const eval_obj = JS_NewCFunction(ctx, js_global_eval, 'eval', 1);\n JS_DefinePropertyValueStr(ctx, ctx.global_obj, 'eval', eval_obj, JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n ctx.eval_obj = eval_obj;\n\n JS_AddIntrinsicGlobal(ctx);\n /* Number.parseInt / Number.parseFloat are the global functions */\n const number_ctor = JS_GetPropertyStr(ctx, ctx.global_obj, 'Number');\n for (const name of ['parseInt', 'parseFloat']) {\n JS_DefinePropertyValueStr(ctx, number_ctor, name, JS_GetPropertyStr(ctx, ctx.global_obj, name), JS_PROP_WRITABLE | JS_PROP_CONFIGURABLE);\n }\n\n /* Generator */\n const gen_proto = JS_NewObjectProto(ctx, ctx.iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR] = gen_proto;\n ctx.generator_proto = gen_proto;\n JS_SetPropertyFunctionList(ctx, gen_proto, js_generator_proto_funcs);\n const gen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.GENERATOR_FUNCTION] = gen_func_proto;\n const gen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'GeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.GENERATOR);\n JS_SetPropertyFunctionList(ctx, gen_func_proto, js_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, gen_func_proto, gen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, gen_ctor, gen_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* Promise */\n JS_AddIntrinsicPromise(ctx);\n\n /* AsyncFunction */\n const async_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FUNCTION] = async_func_proto;\n const async_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC);\n JS_SetPropertyFunctionList(ctx, async_func_proto, js_async_function_proto_funcs);\n JS_SetConstructor2(ctx, async_ctor, async_func_proto, 0, JS_PROP_CONFIGURABLE);\n\n /* AsyncIteratorPrototype / AsyncFromSyncIterator */\n const afs_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_FROM_SYNC_ITERATOR] = afs_proto;\n JS_SetPropertyFunctionList(ctx, afs_proto, js_async_from_sync_iterator_proto_funcs);\n\n /* AsyncGenerator */\n const agen_proto = JS_NewObjectProto(ctx, ctx.async_iterator_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR] = agen_proto;\n ctx.async_generator_proto = agen_proto;\n JS_SetPropertyFunctionList(ctx, agen_proto, js_async_generator_proto_funcs);\n const agen_func_proto = JS_NewObjectProto(ctx, ctx.function_proto) as JSObject;\n ctx.class_proto[JSClassID.ASYNC_GENERATOR_FUNCTION] = agen_func_proto;\n const agen_ctor = JS_NewCFunctionMagic(ctx, js_function_constructor, 'AsyncGeneratorFunction', 1, JSCFunctionEnum.constructor_or_func_magic, JSFunctionKind.ASYNC_GENERATOR);\n JS_SetPropertyFunctionList(ctx, agen_func_proto, js_async_generator_function_proto_funcs);\n JS_SetConstructor2(ctx, agen_func_proto, agen_proto, 0, JS_PROP_CONFIGURABLE);\n JS_SetConstructor2(ctx, agen_ctor, agen_func_proto, 0, JS_PROP_CONFIGURABLE);\n}\n\nhooks.JS_AddIntrinsicBaseObjects = JS_AddIntrinsicBaseObjects;\n"]}
@@ -0,0 +1,6 @@
1
+ import { JSContext, JSValue } from '../quickjs.ts';
2
+ export declare const JS_PARSE_JSON_EXT: number;
3
+ export declare function JS_ParseJSON2(ctx: JSContext, buf: string, filename: string, flags: number): JSValue;
4
+ export declare function JS_ParseJSON(ctx: JSContext, buf: string, filename: string): JSValue;
5
+ export declare function JS_JSONStringify(ctx: JSContext, obj: JSValue, replacer: JSValue, space0: JSValue): JSValue;
6
+ export declare function JS_AddIntrinsicJSON(ctx: JSContext): void;