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.
- package/LICENSE +26 -0
- package/README.md +191 -2
- package/dist/atoms.d.ts +255 -0
- package/dist/atoms.js +445 -0
- package/dist/atoms.js.map +1 -0
- package/dist/builtins/array.d.ts +3 -0
- package/dist/builtins/array.js +116 -0
- package/dist/builtins/array.js.map +1 -0
- package/dist/builtins/bigint.d.ts +3 -0
- package/dist/builtins/bigint.js +122 -0
- package/dist/builtins/bigint.js.map +1 -0
- package/dist/builtins/boolean.d.ts +2 -0
- package/dist/builtins/boolean.js +26 -0
- package/dist/builtins/boolean.js.map +1 -0
- package/dist/builtins/date.d.ts +3 -0
- package/dist/builtins/date.js +1046 -0
- package/dist/builtins/date.js.map +1 -0
- package/dist/builtins/error.d.ts +2 -0
- package/dist/builtins/error.js +154 -0
- package/dist/builtins/error.js.map +1 -0
- package/dist/builtins/function.d.ts +5 -0
- package/dist/builtins/function.js +164 -0
- package/dist/builtins/function.js.map +1 -0
- package/dist/builtins/global.d.ts +2 -0
- package/dist/builtins/global.js +29 -0
- package/dist/builtins/global.js.map +1 -0
- package/dist/builtins/index.d.ts +3 -0
- package/dist/builtins/index.js +139 -0
- package/dist/builtins/index.js.map +1 -0
- package/dist/builtins/json.d.ts +6 -0
- package/dist/builtins/json.js +984 -0
- package/dist/builtins/json.js.map +1 -0
- package/dist/builtins/mapset.d.ts +4 -0
- package/dist/builtins/mapset.js +234 -0
- package/dist/builtins/mapset.js.map +1 -0
- package/dist/builtins/math.d.ts +2 -0
- package/dist/builtins/math.js +62 -0
- package/dist/builtins/math.js.map +1 -0
- package/dist/builtins/native.d.ts +22 -0
- package/dist/builtins/native.js +250 -0
- package/dist/builtins/native.js.map +1 -0
- package/dist/builtins/number.d.ts +4 -0
- package/dist/builtins/number.js +76 -0
- package/dist/builtins/number.js.map +1 -0
- package/dist/builtins/object.d.ts +12 -0
- package/dist/builtins/object.js +575 -0
- package/dist/builtins/object.js.map +1 -0
- package/dist/builtins/promise.d.ts +13 -0
- package/dist/builtins/promise.js +582 -0
- package/dist/builtins/promise.js.map +1 -0
- package/dist/builtins/proxy.d.ts +3 -0
- package/dist/builtins/proxy.js +226 -0
- package/dist/builtins/proxy.js.map +1 -0
- package/dist/builtins/reflect.d.ts +2 -0
- package/dist/builtins/reflect.js +109 -0
- package/dist/builtins/reflect.js.map +1 -0
- package/dist/builtins/regexp.d.ts +2 -0
- package/dist/builtins/regexp.js +203 -0
- package/dist/builtins/regexp.js.map +1 -0
- package/dist/builtins/string.d.ts +4 -0
- package/dist/builtins/string.js +135 -0
- package/dist/builtins/string.js.map +1 -0
- package/dist/builtins/symbol.d.ts +3 -0
- package/dist/builtins/symbol.js +98 -0
- package/dist/builtins/symbol.js.map +1 -0
- package/dist/builtins/typedarray.d.ts +15 -0
- package/dist/builtins/typedarray.js +1838 -0
- package/dist/builtins/typedarray.js.map +1 -0
- package/dist/builtins/weakref.d.ts +18 -0
- package/dist/builtins/weakref.js +130 -0
- package/dist/builtins/weakref.js.map +1 -0
- package/dist/dump.d.ts +2 -0
- package/dist/dump.js +124 -0
- package/dist/dump.js.map +1 -0
- package/dist/embed.d.ts +18 -0
- package/dist/embed.js +286 -0
- package/dist/embed.js.map +1 -0
- package/dist/interpreter.d.ts +81 -0
- package/dist/interpreter.js +3768 -0
- package/dist/interpreter.js.map +1 -0
- package/dist/jit.d.ts +59 -0
- package/dist/jit.js +3440 -0
- package/dist/jit.js.map +1 -0
- package/dist/jit_hook.d.ts +21 -0
- package/dist/jit_hook.js +4 -0
- package/dist/jit_hook.js.map +1 -0
- package/dist/jit_runtime.d.ts +104 -0
- package/dist/jit_runtime.js +721 -0
- package/dist/jit_runtime.js.map +1 -0
- package/dist/jit_stack.d.ts +24 -0
- package/dist/jit_stack.js +227 -0
- package/dist/jit_stack.js.map +1 -0
- package/dist/jseption.d.ts +15 -0
- package/dist/jseption.js +61 -0
- package/dist/jseption.js.map +1 -0
- package/dist/opcodes.d.ts +347 -0
- package/dist/opcodes.js +322 -0
- package/dist/opcodes.js.map +1 -0
- package/dist/parser.d.ts +283 -0
- package/dist/parser.js +9752 -0
- package/dist/parser.js.map +1 -0
- package/dist/qjs.d.ts +2 -0
- package/dist/qjs.js +122 -0
- package/dist/qjs.js.map +1 -0
- package/dist/quickjs.d.ts +460 -0
- package/dist/quickjs.js +3408 -0
- package/dist/quickjs.js.map +1 -0
- package/dist/std.d.ts +4 -0
- package/dist/std.js +273 -0
- package/dist/std.js.map +1 -0
- package/dist/values.d.ts +447 -0
- package/dist/values.js +461 -0
- package/dist/values.js.map +1 -0
- package/package.json +59 -4
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Borrowed host natives.
|
|
3
|
+
*
|
|
4
|
+
* A guest call into a ported builtin costs a few hundred nanoseconds
|
|
5
|
+
* (wrapper, C function frame, ported body, property API), while the host
|
|
6
|
+
* native costs a few nanoseconds. Where the host native is spec-equivalent,
|
|
7
|
+
* the guest intrinsic is a "forwarder": a strict host function with the
|
|
8
|
+
* guest Function.prototype that calls the host native with the same `this`
|
|
9
|
+
* and arguments. The call goes through `h.call`/`h.apply`, which
|
|
10
|
+
* JavaScriptCore recognises at the call site (about 1 ns), never through
|
|
11
|
+
* Reflect.apply (about 35 ns).
|
|
12
|
+
*
|
|
13
|
+
* Sandbox invariants (docs/HOST_VALUES.md): the host native itself is never
|
|
14
|
+
* visible to the guest, and every object a native creates (arrays, iterator
|
|
15
|
+
* results, primitive wrappers, JSON trees) is re-prototyped to the guest
|
|
16
|
+
* intrinsic by a "fixer" before it is returned. Host errors raised by the
|
|
17
|
+
* natives are converted to guest errors at the call boundaries
|
|
18
|
+
* (js_host_exception_to_guest).
|
|
19
|
+
*/
|
|
20
|
+
import { JSObjectMeta, js_meta, js_direct, hooks, JS_IsObject, } from "../quickjs.js";
|
|
21
|
+
/* Forwarder factories. Module code is strict, so a primitive `this` is
|
|
22
|
+
passed unboxed; no code generation from strings is needed. Arity
|
|
23
|
+
specialised: `h.call(this, a, b)` with a fixed argument count is the
|
|
24
|
+
shape JSC inlines; `arguments` is only materialised for the rare 4+
|
|
25
|
+
argument call. */
|
|
26
|
+
const factory = {
|
|
27
|
+
plain(h) {
|
|
28
|
+
const o = { m(a, b, c) {
|
|
29
|
+
switch (arguments.length) {
|
|
30
|
+
case 0: return h.call(this);
|
|
31
|
+
case 1: return h.call(this, a);
|
|
32
|
+
case 2: return h.call(this, a, b);
|
|
33
|
+
case 3: return h.call(this, a, b, c);
|
|
34
|
+
default: return h.apply(this, arguments);
|
|
35
|
+
}
|
|
36
|
+
} };
|
|
37
|
+
return o.m;
|
|
38
|
+
},
|
|
39
|
+
fixed(h, fix, ctx) {
|
|
40
|
+
const o = { m(a, b, c) {
|
|
41
|
+
switch (arguments.length) {
|
|
42
|
+
case 0: return fix(ctx, h.call(this));
|
|
43
|
+
case 1: return fix(ctx, h.call(this, a));
|
|
44
|
+
case 2: return fix(ctx, h.call(this, a, b));
|
|
45
|
+
case 3: return fix(ctx, h.call(this, a, b, c));
|
|
46
|
+
default: return fix(ctx, h.apply(this, arguments));
|
|
47
|
+
}
|
|
48
|
+
} };
|
|
49
|
+
return o.m;
|
|
50
|
+
},
|
|
51
|
+
direct(h) { return (t, nt, ...args) => h.apply(t, args); },
|
|
52
|
+
direct_fixed(h, fix, ctx) {
|
|
53
|
+
return (t, nt, ...args) => fix(ctx, h.apply(t, args));
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
/* Create a guest function forwarding to the host native 'host'. The
|
|
57
|
+
forwarder is not a constructor (method shorthand: `new` throws). */
|
|
58
|
+
export function js_borrow_native(ctx, host, name, length, fix) {
|
|
59
|
+
const f = fix ? factory.fixed(host, fix, ctx) : factory.plain(host);
|
|
60
|
+
Object.setPrototypeOf(f, ctx.function_proto);
|
|
61
|
+
Reflect.defineProperty(f, 'length', { value: length, writable: false, enumerable: false, configurable: true });
|
|
62
|
+
Reflect.defineProperty(f, 'name', { value: name, writable: false, enumerable: false, configurable: true });
|
|
63
|
+
const m = new JSObjectMeta(12 /* JSClassID.C_FUNCTION */);
|
|
64
|
+
m.realm = ctx;
|
|
65
|
+
js_meta.set(f, m);
|
|
66
|
+
js_direct.set(f, fix ? factory.direct_fixed(host, fix, ctx) : factory.direct(host));
|
|
67
|
+
return f;
|
|
68
|
+
}
|
|
69
|
+
hooks.js_borrow_native = js_borrow_native;
|
|
70
|
+
/* ---------------------------------------------------------------------
|
|
71
|
+
Fixers: re-prototype objects created by host natives
|
|
72
|
+
--------------------------------------------------------------------- */
|
|
73
|
+
const HOST_ARRAY_PROTO = Array.prototype;
|
|
74
|
+
const HOST_OBJECT_PROTO = Object.prototype;
|
|
75
|
+
/* a host created array becomes a guest array */
|
|
76
|
+
export function fix_array(ctx, v) {
|
|
77
|
+
if (Array.isArray(v) && Object.getPrototypeOf(v) === HOST_ARRAY_PROTO) {
|
|
78
|
+
Object.setPrototypeOf(v, ctx.class_proto[2 /* JSClassID.ARRAY */]);
|
|
79
|
+
}
|
|
80
|
+
return v;
|
|
81
|
+
}
|
|
82
|
+
/* a host created plain object becomes a guest object */
|
|
83
|
+
export function fix_object(ctx, v) {
|
|
84
|
+
if (typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === HOST_OBJECT_PROTO) {
|
|
85
|
+
Object.setPrototypeOf(v, ctx.class_proto[1 /* JSClassID.OBJECT */]);
|
|
86
|
+
}
|
|
87
|
+
return v;
|
|
88
|
+
}
|
|
89
|
+
/* any object a native may create: array, plain object or primitive wrapper
|
|
90
|
+
(ToObject on a primitive `this` or argument, e.g. Array.prototype.fill
|
|
91
|
+
called on a number) */
|
|
92
|
+
export function fix_any(ctx, v) {
|
|
93
|
+
if (typeof v !== 'object' || v === null)
|
|
94
|
+
return v;
|
|
95
|
+
const p = Object.getPrototypeOf(v);
|
|
96
|
+
if (p === HOST_ARRAY_PROTO) {
|
|
97
|
+
Object.setPrototypeOf(v, ctx.class_proto[2 /* JSClassID.ARRAY */]);
|
|
98
|
+
}
|
|
99
|
+
else if (p === HOST_OBJECT_PROTO) {
|
|
100
|
+
Object.setPrototypeOf(v, ctx.class_proto[1 /* JSClassID.OBJECT */]);
|
|
101
|
+
}
|
|
102
|
+
else if (p !== null && js_meta.get(v) === undefined) {
|
|
103
|
+
fix_wrapper(ctx, v, p);
|
|
104
|
+
}
|
|
105
|
+
return v;
|
|
106
|
+
}
|
|
107
|
+
/* host primitive wrapper -> guest wrapper (prototype + metadata) */
|
|
108
|
+
function fix_wrapper(ctx, v, p) {
|
|
109
|
+
let class_id;
|
|
110
|
+
let value;
|
|
111
|
+
switch (p) {
|
|
112
|
+
case String.prototype:
|
|
113
|
+
class_id = 5 /* JSClassID.STRING */;
|
|
114
|
+
value = String.prototype.valueOf.call(v);
|
|
115
|
+
break;
|
|
116
|
+
case Number.prototype:
|
|
117
|
+
class_id = 4 /* JSClassID.NUMBER */;
|
|
118
|
+
value = Number.prototype.valueOf.call(v);
|
|
119
|
+
break;
|
|
120
|
+
case Boolean.prototype:
|
|
121
|
+
class_id = 6 /* JSClassID.BOOLEAN */;
|
|
122
|
+
value = Boolean.prototype.valueOf.call(v);
|
|
123
|
+
break;
|
|
124
|
+
case Symbol.prototype:
|
|
125
|
+
class_id = 7 /* JSClassID.SYMBOL */;
|
|
126
|
+
value = Symbol.prototype.valueOf.call(v);
|
|
127
|
+
break;
|
|
128
|
+
case BigInt.prototype:
|
|
129
|
+
class_id = 33 /* JSClassID.BIG_INT */;
|
|
130
|
+
value = BigInt.prototype.valueOf.call(v);
|
|
131
|
+
break;
|
|
132
|
+
default: return;
|
|
133
|
+
}
|
|
134
|
+
Object.setPrototypeOf(v, ctx.class_proto[class_id]);
|
|
135
|
+
const m = new JSObjectMeta(class_id);
|
|
136
|
+
m.u = value;
|
|
137
|
+
js_meta.set(v, m);
|
|
138
|
+
}
|
|
139
|
+
/* Object.entries: an array of [key, value] arrays */
|
|
140
|
+
export function fix_entries(ctx, v) {
|
|
141
|
+
fix_array(ctx, v);
|
|
142
|
+
if (Array.isArray(v)) {
|
|
143
|
+
for (let i = 0; i < v.length; i++)
|
|
144
|
+
fix_array(ctx, v[i]);
|
|
145
|
+
}
|
|
146
|
+
return v;
|
|
147
|
+
}
|
|
148
|
+
/* RegExp match result: an array with index/input/groups (groups has a null
|
|
149
|
+
prototype) and, with the 'd' flag, an 'indices' array of arrays */
|
|
150
|
+
export function fix_match(ctx, v) {
|
|
151
|
+
if (v === null || typeof v !== 'object')
|
|
152
|
+
return v;
|
|
153
|
+
fix_array(ctx, v);
|
|
154
|
+
const indices = v.indices;
|
|
155
|
+
if (indices !== undefined) {
|
|
156
|
+
fix_array(ctx, indices);
|
|
157
|
+
if (Array.isArray(indices)) {
|
|
158
|
+
for (let i = 0; i < indices.length; i++)
|
|
159
|
+
fix_array(ctx, indices[i]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return v;
|
|
163
|
+
}
|
|
164
|
+
/* JSON.parse tree */
|
|
165
|
+
export function fix_deep_json(ctx, v) {
|
|
166
|
+
if (typeof v !== 'object' || v === null)
|
|
167
|
+
return v;
|
|
168
|
+
const array_proto = ctx.class_proto[2 /* JSClassID.ARRAY */];
|
|
169
|
+
const object_proto = ctx.class_proto[1 /* JSClassID.OBJECT */];
|
|
170
|
+
const stack = [v];
|
|
171
|
+
while (stack.length > 0) {
|
|
172
|
+
const o = stack.pop();
|
|
173
|
+
if (Array.isArray(o)) {
|
|
174
|
+
Object.setPrototypeOf(o, array_proto);
|
|
175
|
+
for (let i = 0; i < o.length; i++) {
|
|
176
|
+
const e = o[i];
|
|
177
|
+
if (typeof e === 'object' && e !== null)
|
|
178
|
+
stack.push(e);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
Object.setPrototypeOf(o, object_proto);
|
|
183
|
+
for (const k in o) {
|
|
184
|
+
const e = o[k];
|
|
185
|
+
if (typeof e === 'object' && e !== null)
|
|
186
|
+
stack.push(e);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return v;
|
|
191
|
+
}
|
|
192
|
+
/* iterator objects created by host natives are re-prototyped to the guest
|
|
193
|
+
iterator prototype of their class, whose `next` is itself a borrowed
|
|
194
|
+
native (the brand check of the host `next` passes because the object is
|
|
195
|
+
a genuine host iterator) */
|
|
196
|
+
/* the host prototypes of the iterators created by the borrowed natives */
|
|
197
|
+
export const HOST_ARRAY_ITERATOR_PROTO = Object.getPrototypeOf([][Symbol.iterator]());
|
|
198
|
+
export const HOST_STRING_ITERATOR_PROTO = Object.getPrototypeOf(''[Symbol.iterator]());
|
|
199
|
+
export const HOST_MAP_ITERATOR_PROTO = Object.getPrototypeOf(new Map().entries());
|
|
200
|
+
export const HOST_SET_ITERATOR_PROTO = Object.getPrototypeOf(new Set().values());
|
|
201
|
+
export const HOST_REGEXP_STRING_ITERATOR_PROTO = Object.getPrototypeOf(/a/g[Symbol.matchAll]('a'));
|
|
202
|
+
/* Only objects whose prototype is the host iterator prototype are touched:
|
|
203
|
+
a user defined Symbol.iterator/Symbol.matchAll may return any guest
|
|
204
|
+
object, which must be left alone. */
|
|
205
|
+
function make_fix_iterator(host_proto, class_id) {
|
|
206
|
+
return (ctx, v) => {
|
|
207
|
+
if (typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === host_proto) {
|
|
208
|
+
Object.setPrototypeOf(v, ctx.class_proto[class_id]);
|
|
209
|
+
}
|
|
210
|
+
return v;
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
export const fix_array_iterator = make_fix_iterator(HOST_ARRAY_ITERATOR_PROTO, 40 /* JSClassID.ARRAY_ITERATOR */);
|
|
214
|
+
export const fix_string_iterator = make_fix_iterator(HOST_STRING_ITERATOR_PROTO, 41 /* JSClassID.STRING_ITERATOR */);
|
|
215
|
+
export const fix_map_iterator = make_fix_iterator(HOST_MAP_ITERATOR_PROTO, 38 /* JSClassID.MAP_ITERATOR */);
|
|
216
|
+
export const fix_set_iterator = make_fix_iterator(HOST_SET_ITERATOR_PROTO, 39 /* JSClassID.SET_ITERATOR */);
|
|
217
|
+
export const fix_regexp_string_iterator = make_fix_iterator(HOST_REGEXP_STRING_ITERATOR_PROTO, 42 /* JSClassID.REGEXP_STRING_ITERATOR */);
|
|
218
|
+
/* iterator results `{ value, done }` are fresh host objects */
|
|
219
|
+
export function fix_iter_result(ctx, r) {
|
|
220
|
+
if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {
|
|
221
|
+
Object.setPrototypeOf(r, ctx.class_proto[1 /* JSClassID.OBJECT */]);
|
|
222
|
+
}
|
|
223
|
+
return r;
|
|
224
|
+
}
|
|
225
|
+
/* entries iterators yield [key, value] host arrays */
|
|
226
|
+
export function fix_iter_result_entries(ctx, r) {
|
|
227
|
+
if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {
|
|
228
|
+
Object.setPrototypeOf(r, ctx.class_proto[1 /* JSClassID.OBJECT */]);
|
|
229
|
+
fix_array(ctx, r.value);
|
|
230
|
+
}
|
|
231
|
+
return r;
|
|
232
|
+
}
|
|
233
|
+
/* RegExp string iterators yield match arrays */
|
|
234
|
+
export function fix_iter_result_match(ctx, r) {
|
|
235
|
+
if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {
|
|
236
|
+
Object.setPrototypeOf(r, ctx.class_proto[1 /* JSClassID.OBJECT */]);
|
|
237
|
+
fix_match(ctx, r.value);
|
|
238
|
+
}
|
|
239
|
+
return r;
|
|
240
|
+
}
|
|
241
|
+
/* re-prototype a host object 'obj' to the guest prototype 'proto' and tag
|
|
242
|
+
it with 'class_id' (used for host backed Map, Set, RegExp...) */
|
|
243
|
+
export function js_adopt_host_object(ctx, obj, proto, class_id, opaque = null) {
|
|
244
|
+
Object.setPrototypeOf(obj, JS_IsObject(proto) ? proto : null);
|
|
245
|
+
const m = new JSObjectMeta(class_id);
|
|
246
|
+
m.u = opaque;
|
|
247
|
+
js_meta.set(obj, m);
|
|
248
|
+
return obj;
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native.js","sourceRoot":"","sources":["../../src/builtins/native.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAC0B,YAAY,EAAiB,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,WAAW,GACnG,MAAM,eAAe,CAAC;AAEvB;;;;oBAIoB;AACpB,MAAM,OAAO,GAAG;IACd,KAAK,CAAC,CAAW;QACf,MAAM,CAAC,GAAG,EAAE,CAAC,CAAY,CAAO,EAAE,CAAO,EAAE,CAAO;gBAChD,QAAQ,SAAS,CAAC,MAAM,EAAE,CAAC;oBACzB,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBAC5B,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;oBAC/B,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBAClC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;oBACrC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;gBAC3C,CAAC;YACH,CAAC,EAAE,CAAC;QACJ,OAAO,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IACD,KAAK,CAAC,CAAW,EAAE,GAAkB,EAAE,GAAc;QACnD,MAAM,CAAC,GAAG,EAAE,CAAC,CAAY,CAAO,EAAE,CAAO,EAAE,CAAO;gBAChD,QAAQ,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CAAC,CAAC;IACrC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC;IACb,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IACpB,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/*\n * Borrowed host natives.\n *\n * A guest call into a ported builtin costs a few hundred nanoseconds\n * (wrapper, C function frame, ported body, property API), while the host\n * native costs a few nanoseconds. Where the host native is spec-equivalent,\n * the guest intrinsic is a \"forwarder\": a strict host function with the\n * guest Function.prototype that calls the host native with the same `this`\n * and arguments. The call goes through `h.call`/`h.apply`, which\n * JavaScriptCore recognises at the call site (about 1 ns), never through\n * Reflect.apply (about 35 ns).\n *\n * Sandbox invariants (docs/HOST_VALUES.md): the host native itself is never\n * visible to the guest, and every object a native creates (arrays, iterator\n * results, primitive wrappers, JSON trees) is re-prototyped to the guest\n * intrinsic by a \"fixer\" before it is returned. Host errors raised by the\n * natives are converted to guest errors at the call boundaries\n * (js_host_exception_to_guest).\n */\nimport {\n JSContext, JSValue, JSClassID, JSObjectMeta, JSNativeFixer, js_meta, js_direct, hooks, JS_IsObject,\n} from '../quickjs.ts';\n\n/* Forwarder factories. Module code is strict, so a primitive `this` is\n passed unboxed; no code generation from strings is needed. Arity\n specialised: `h.call(this, a, b)` with a fixed argument count is the\n shape JSC inlines; `arguments` is only materialised for the rare 4+\n argument call. */\nconst factory = {\n plain(h: Function): Function {\n const o = { m(this: any, a?: any, b?: any, c?: any) {\n switch (arguments.length) {\n case 0: return h.call(this);\n case 1: return h.call(this, a);\n case 2: return h.call(this, a, b);\n case 3: return h.call(this, a, b, c);\n default: return h.apply(this, arguments);\n }\n } };\n return o.m;\n },\n fixed(h: Function, fix: JSNativeFixer, ctx: JSContext): Function {\n const o = { m(this: any, a?: any, b?: any, c?: any) {\n switch (arguments.length) {\n case 0: return fix(ctx, h.call(this));\n case 1: return fix(ctx, h.call(this, a));\n case 2: return fix(ctx, h.call(this, a, b));\n case 3: return fix(ctx, h.call(this, a, b, c));\n default: return fix(ctx, h.apply(this, arguments));\n }\n } };\n return o.m;\n },\n direct(h: Function): Function { return (t: any, nt: any, ...args: any[]) => h.apply(t, args); },\n direct_fixed(h: Function, fix: JSNativeFixer, ctx: JSContext): Function {\n return (t: any, nt: any, ...args: any[]) => fix(ctx, h.apply(t, args));\n },\n};\n\n/* Create a guest function forwarding to the host native 'host'. The\n forwarder is not a constructor (method shorthand: `new` throws). */\nexport function js_borrow_native(ctx: JSContext, host: Function, name: string, length: number,\n fix: JSNativeFixer | null): JSValue {\n const f = fix ? factory.fixed(host, fix, ctx) : factory.plain(host);\n Object.setPrototypeOf(f, ctx.function_proto);\n Reflect.defineProperty(f, 'length', { value: length, writable: false, enumerable: false, configurable: true });\n Reflect.defineProperty(f, 'name', { value: name, writable: false, enumerable: false, configurable: true });\n const m = new JSObjectMeta(JSClassID.C_FUNCTION);\n m.realm = ctx;\n js_meta.set(f, m);\n js_direct.set(f, fix ? factory.direct_fixed(host, fix, ctx) : factory.direct(host));\n return f;\n}\nhooks.js_borrow_native = js_borrow_native;\n\n/* ---------------------------------------------------------------------\n Fixers: re-prototype objects created by host natives\n --------------------------------------------------------------------- */\n\nconst HOST_ARRAY_PROTO = Array.prototype;\nconst HOST_OBJECT_PROTO = Object.prototype;\n\n/* a host created array becomes a guest array */\nexport function fix_array(ctx: JSContext, v: any): any {\n if (Array.isArray(v) && Object.getPrototypeOf(v) === HOST_ARRAY_PROTO) {\n Object.setPrototypeOf(v, ctx.class_proto[JSClassID.ARRAY]);\n }\n return v;\n}\n\n/* a host created plain object becomes a guest object */\nexport function fix_object(ctx: JSContext, v: any): any {\n if (typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === HOST_OBJECT_PROTO) {\n Object.setPrototypeOf(v, ctx.class_proto[JSClassID.OBJECT]);\n }\n return v;\n}\n\n/* any object a native may create: array, plain object or primitive wrapper\n (ToObject on a primitive `this` or argument, e.g. Array.prototype.fill\n called on a number) */\nexport function fix_any(ctx: JSContext, v: any): any {\n if (typeof v !== 'object' || v === null) return v;\n const p = Object.getPrototypeOf(v);\n if (p === HOST_ARRAY_PROTO) {\n Object.setPrototypeOf(v, ctx.class_proto[JSClassID.ARRAY]);\n } else if (p === HOST_OBJECT_PROTO) {\n Object.setPrototypeOf(v, ctx.class_proto[JSClassID.OBJECT]);\n } else if (p !== null && js_meta.get(v) === undefined) {\n fix_wrapper(ctx, v, p);\n }\n return v;\n}\n\n/* host primitive wrapper -> guest wrapper (prototype + metadata) */\nfunction fix_wrapper(ctx: JSContext, v: object, p: object): void {\n let class_id: JSClassID;\n let value: JSValue;\n switch (p) {\n case String.prototype: class_id = JSClassID.STRING; value = String.prototype.valueOf.call(v); break;\n case Number.prototype: class_id = JSClassID.NUMBER; value = Number.prototype.valueOf.call(v); break;\n case Boolean.prototype: class_id = JSClassID.BOOLEAN; value = Boolean.prototype.valueOf.call(v); break;\n case Symbol.prototype: class_id = JSClassID.SYMBOL; value = Symbol.prototype.valueOf.call(v); break;\n case BigInt.prototype: class_id = JSClassID.BIG_INT; value = BigInt.prototype.valueOf.call(v); break;\n default: return;\n }\n Object.setPrototypeOf(v, ctx.class_proto[class_id]);\n const m = new JSObjectMeta(class_id);\n m.u = value;\n js_meta.set(v, m);\n}\n\n/* Object.entries: an array of [key, value] arrays */\nexport function fix_entries(ctx: JSContext, v: any): any {\n fix_array(ctx, v);\n if (Array.isArray(v)) {\n for (let i = 0; i < v.length; i++) fix_array(ctx, v[i]);\n }\n return v;\n}\n\n/* RegExp match result: an array with index/input/groups (groups has a null\n prototype) and, with the 'd' flag, an 'indices' array of arrays */\nexport function fix_match(ctx: JSContext, v: any): any {\n if (v === null || typeof v !== 'object') return v;\n fix_array(ctx, v);\n const indices = (v as any).indices;\n if (indices !== undefined) {\n fix_array(ctx, indices);\n if (Array.isArray(indices)) {\n for (let i = 0; i < indices.length; i++) fix_array(ctx, indices[i]);\n }\n }\n return v;\n}\n\n/* JSON.parse tree */\nexport function fix_deep_json(ctx: JSContext, v: any): any {\n if (typeof v !== 'object' || v === null) return v;\n const array_proto = ctx.class_proto[JSClassID.ARRAY];\n const object_proto = ctx.class_proto[JSClassID.OBJECT];\n const stack: object[] = [v];\n while (stack.length > 0) {\n const o = stack.pop()!;\n if (Array.isArray(o)) {\n Object.setPrototypeOf(o, array_proto);\n for (let i = 0; i < o.length; i++) {\n const e = o[i];\n if (typeof e === 'object' && e !== null) stack.push(e);\n }\n } else {\n Object.setPrototypeOf(o, object_proto);\n for (const k in o) {\n const e = (o as any)[k];\n if (typeof e === 'object' && e !== null) stack.push(e);\n }\n }\n }\n return v;\n}\n\n/* iterator objects created by host natives are re-prototyped to the guest\n iterator prototype of their class, whose `next` is itself a borrowed\n native (the brand check of the host `next` passes because the object is\n a genuine host iterator) */\n/* the host prototypes of the iterators created by the borrowed natives */\nexport const HOST_ARRAY_ITERATOR_PROTO: object = Object.getPrototypeOf([][Symbol.iterator]());\nexport const HOST_STRING_ITERATOR_PROTO: object = Object.getPrototypeOf(''[Symbol.iterator]());\nexport const HOST_MAP_ITERATOR_PROTO: object = Object.getPrototypeOf(new Map().entries());\nexport const HOST_SET_ITERATOR_PROTO: object = Object.getPrototypeOf(new Set().values());\nexport const HOST_REGEXP_STRING_ITERATOR_PROTO: object = Object.getPrototypeOf(/a/g[Symbol.matchAll]('a'));\n\n/* Only objects whose prototype is the host iterator prototype are touched:\n a user defined Symbol.iterator/Symbol.matchAll may return any guest\n object, which must be left alone. */\nfunction make_fix_iterator(host_proto: object, class_id: JSClassID): JSNativeFixer {\n return (ctx, v) => {\n if (typeof v === 'object' && v !== null && Object.getPrototypeOf(v) === host_proto) {\n Object.setPrototypeOf(v, ctx.class_proto[class_id]);\n }\n return v;\n };\n}\nexport const fix_array_iterator = make_fix_iterator(HOST_ARRAY_ITERATOR_PROTO, JSClassID.ARRAY_ITERATOR);\nexport const fix_string_iterator = make_fix_iterator(HOST_STRING_ITERATOR_PROTO, JSClassID.STRING_ITERATOR);\nexport const fix_map_iterator = make_fix_iterator(HOST_MAP_ITERATOR_PROTO, JSClassID.MAP_ITERATOR);\nexport const fix_set_iterator = make_fix_iterator(HOST_SET_ITERATOR_PROTO, JSClassID.SET_ITERATOR);\nexport const fix_regexp_string_iterator = make_fix_iterator(HOST_REGEXP_STRING_ITERATOR_PROTO, JSClassID.REGEXP_STRING_ITERATOR);\n\n/* iterator results `{ value, done }` are fresh host objects */\nexport function fix_iter_result(ctx: JSContext, r: any): any {\n if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {\n Object.setPrototypeOf(r, ctx.class_proto[JSClassID.OBJECT]);\n }\n return r;\n}\n/* entries iterators yield [key, value] host arrays */\nexport function fix_iter_result_entries(ctx: JSContext, r: any): any {\n if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {\n Object.setPrototypeOf(r, ctx.class_proto[JSClassID.OBJECT]);\n fix_array(ctx, r.value);\n }\n return r;\n}\n/* RegExp string iterators yield match arrays */\nexport function fix_iter_result_match(ctx: JSContext, r: any): any {\n if (typeof r === 'object' && r !== null && Object.getPrototypeOf(r) === HOST_OBJECT_PROTO) {\n Object.setPrototypeOf(r, ctx.class_proto[JSClassID.OBJECT]);\n fix_match(ctx, r.value);\n }\n return r;\n}\n\n/* re-prototype a host object 'obj' to the guest prototype 'proto' and tag\n it with 'class_id' (used for host backed Map, Set, RegExp...) */\nexport function js_adopt_host_object(ctx: JSContext, obj: object, proto: JSValue | null, class_id: JSClassID, opaque: any = null): JSValue {\n Object.setPrototypeOf(obj, JS_IsObject(proto) ? proto : null);\n const m = new JSObjectMeta(class_id);\n m.u = opaque;\n js_meta.set(obj, m);\n return obj;\n}\n"]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { JSContext, JSValue } from '../quickjs.ts';
|
|
2
|
+
export declare function js_argc(ctx: JSContext, argv: JSValue[]): number;
|
|
3
|
+
export declare function js_get_radix(ctx: JSContext, val: JSValue): number;
|
|
4
|
+
export declare function JS_AddIntrinsicNumber(ctx: JSContext): void;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Number objects (port of the Number part of quickjs.c)
|
|
3
|
+
*
|
|
4
|
+
* Number wrapper objects are host Number objects with the guest prototype,
|
|
5
|
+
* so the prototype methods and the static predicates are borrowed host
|
|
6
|
+
* natives (builtins/native.ts). Number.parseInt / Number.parseFloat are the
|
|
7
|
+
* global functions (aliased in builtins/index.ts).
|
|
8
|
+
*/
|
|
9
|
+
import * as Q from "../quickjs.js";
|
|
10
|
+
import { JS_IsException, JS_IsUndefined, JS_NewGlobalCConstructor, JS_ToNumeric, JS_ToInt32Sat, JS_ThrowRangeError, JS_SetPropertyFunctionList, JS_NATIVE_DEF, JS_PROP_DOUBLE_DEF, } from "../quickjs.js";
|
|
11
|
+
/* Number of arguments actually passed by the caller (argv is not padded). */
|
|
12
|
+
export function js_argc(ctx, argv) {
|
|
13
|
+
return argv.length;
|
|
14
|
+
}
|
|
15
|
+
function js_number_constructor(ctx, new_target, argv) {
|
|
16
|
+
let val;
|
|
17
|
+
if (argv.length === 0) {
|
|
18
|
+
val = 0;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
val = JS_ToNumeric(ctx, argv[0]);
|
|
22
|
+
if (JS_IsException(val))
|
|
23
|
+
return val;
|
|
24
|
+
if (typeof val === 'bigint')
|
|
25
|
+
val = Number(val);
|
|
26
|
+
}
|
|
27
|
+
if (!JS_IsUndefined(new_target)) {
|
|
28
|
+
return Q.js_create_wrapper_from_ctor(ctx, new_target, 4 /* JSClassID.NUMBER */, val);
|
|
29
|
+
}
|
|
30
|
+
return val;
|
|
31
|
+
}
|
|
32
|
+
/* radix argument of toString(): -1 on exception */
|
|
33
|
+
export function js_get_radix(ctx, val) {
|
|
34
|
+
const r = JS_ToInt32Sat(ctx, val);
|
|
35
|
+
if (JS_IsException(r))
|
|
36
|
+
return -1;
|
|
37
|
+
const radix = r;
|
|
38
|
+
if (radix < 2 || radix > 36) {
|
|
39
|
+
JS_ThrowRangeError(ctx, 'radix must be between 2 and 36');
|
|
40
|
+
return -1;
|
|
41
|
+
}
|
|
42
|
+
return radix;
|
|
43
|
+
}
|
|
44
|
+
const N = Number;
|
|
45
|
+
const NP = Number.prototype;
|
|
46
|
+
const js_number_funcs = [
|
|
47
|
+
JS_NATIVE_DEF('isNaN', 1, N.isNaN),
|
|
48
|
+
JS_NATIVE_DEF('isFinite', 1, N.isFinite),
|
|
49
|
+
JS_NATIVE_DEF('isInteger', 1, N.isInteger),
|
|
50
|
+
JS_NATIVE_DEF('isSafeInteger', 1, N.isSafeInteger),
|
|
51
|
+
JS_PROP_DOUBLE_DEF('MAX_VALUE', 1.7976931348623157e+308, 0),
|
|
52
|
+
JS_PROP_DOUBLE_DEF('MIN_VALUE', 5e-324, 0),
|
|
53
|
+
JS_PROP_DOUBLE_DEF('NaN', NaN, 0),
|
|
54
|
+
JS_PROP_DOUBLE_DEF('NEGATIVE_INFINITY', -Infinity, 0),
|
|
55
|
+
JS_PROP_DOUBLE_DEF('POSITIVE_INFINITY', Infinity, 0),
|
|
56
|
+
JS_PROP_DOUBLE_DEF('EPSILON', 2.220446049250313e-16, 0), /* ES6 */
|
|
57
|
+
JS_PROP_DOUBLE_DEF('MAX_SAFE_INTEGER', 9007199254740991.0, 0), /* ES6 */
|
|
58
|
+
JS_PROP_DOUBLE_DEF('MIN_SAFE_INTEGER', -9007199254740991.0, 0), /* ES6 */
|
|
59
|
+
];
|
|
60
|
+
const js_number_proto_funcs = [
|
|
61
|
+
JS_NATIVE_DEF('toExponential', 1, NP.toExponential),
|
|
62
|
+
JS_NATIVE_DEF('toFixed', 1, NP.toFixed),
|
|
63
|
+
JS_NATIVE_DEF('toPrecision', 1, NP.toPrecision),
|
|
64
|
+
JS_NATIVE_DEF('toString', 1, NP.toString),
|
|
65
|
+
JS_NATIVE_DEF('toLocaleString', 0, NP.toLocaleString),
|
|
66
|
+
JS_NATIVE_DEF('valueOf', 0, NP.valueOf),
|
|
67
|
+
];
|
|
68
|
+
export function JS_AddIntrinsicNumber(ctx) {
|
|
69
|
+
/* Number.prototype is a Number object with value 0 */
|
|
70
|
+
const proto = Q.js_new_primitive_wrapper(ctx, ctx.class_proto[1 /* JSClassID.OBJECT */], 4 /* JSClassID.NUMBER */, 0);
|
|
71
|
+
ctx.class_proto[4 /* JSClassID.NUMBER */] = proto;
|
|
72
|
+
JS_SetPropertyFunctionList(ctx, proto, js_number_proto_funcs);
|
|
73
|
+
const number_obj = JS_NewGlobalCConstructor(ctx, 'Number', js_number_constructor, 1, proto);
|
|
74
|
+
JS_SetPropertyFunctionList(ctx, number_obj, js_number_funcs);
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=number.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number.js","sourceRoot":"","sources":["../../src/builtins/number.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AACnC,OAAO,EACoC,cAAc,EAAE,cAAc,EAAE,wBAAwB,EACjG,YAAY,EAAE,aAAa,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,aAAa,EAAE,kBAAkB,GAC/G,MAAM,eAAe,CAAC;AAEvB,6EAA6E;AAC7E,MAAM,UAAU,OAAO,CAAC,GAAc,EAAE,IAAe;IACrD,OAAO,IAAI,CAAC,MAAM,CAAC;AACrB,CAAC;AAED,SAAS,qBAAqB,CAAC,GAAc,EAAE,UAAmB,EAAE,IAAe;IACjF,IAAI,GAAY,CAAC;IACjB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtB,GAAG,GAAG,CAAC,CAAC;IACV,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,YAAY,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACjC,IAAI,cAAc,CAAC,GAAG,CAAC;YAAE,OAAO,GAAG,CAAC;QACpC,IAA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CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC;AAC/D,CAAC","sourcesContent":["/*\n * Number objects (port of the Number part of quickjs.c)\n *\n * Number wrapper objects are host Number objects with the guest prototype,\n * so the prototype methods and the static predicates are borrowed host\n * natives (builtins/native.ts). Number.parseInt / Number.parseFloat are the\n * global functions (aliased in builtins/index.ts).\n */\nimport * as Q from '../quickjs.ts';\nimport {\n JSContext, JSValue, JSObject, JSClassID, JS_IsException, JS_IsUndefined, JS_NewGlobalCConstructor,\n JS_ToNumeric, JS_ToInt32Sat, JS_ThrowRangeError, JS_SetPropertyFunctionList, JS_NATIVE_DEF, JS_PROP_DOUBLE_DEF,\n} from '../quickjs.ts';\n\n/* Number of arguments actually passed by the caller (argv is not padded). */\nexport function js_argc(ctx: JSContext, argv: JSValue[]): number {\n return argv.length;\n}\n\nfunction js_number_constructor(ctx: JSContext, new_target: JSValue, argv: JSValue[]): JSValue {\n let val: JSValue;\n if (argv.length === 0) {\n val = 0;\n } else {\n val = JS_ToNumeric(ctx, argv[0]);\n if (JS_IsException(val)) return val;\n if (typeof val === 'bigint') val = Number(val);\n }\n if (!JS_IsUndefined(new_target)) {\n return Q.js_create_wrapper_from_ctor(ctx, new_target, JSClassID.NUMBER, val);\n }\n return val;\n}\n\n/* radix argument of toString(): -1 on exception */\nexport function js_get_radix(ctx: JSContext, val: JSValue): number {\n const r = JS_ToInt32Sat(ctx, val);\n if (JS_IsException(r)) return -1;\n const radix = r as number;\n if (radix < 2 || radix > 36) {\n JS_ThrowRangeError(ctx, 'radix must be between 2 and 36');\n return -1;\n }\n return radix;\n}\n\nconst N = Number;\nconst NP = Number.prototype;\n\nconst js_number_funcs = [\n JS_NATIVE_DEF('isNaN', 1, N.isNaN),\n JS_NATIVE_DEF('isFinite', 1, N.isFinite),\n JS_NATIVE_DEF('isInteger', 1, N.isInteger),\n JS_NATIVE_DEF('isSafeInteger', 1, N.isSafeInteger),\n JS_PROP_DOUBLE_DEF('MAX_VALUE', 1.7976931348623157e+308, 0),\n JS_PROP_DOUBLE_DEF('MIN_VALUE', 5e-324, 0),\n JS_PROP_DOUBLE_DEF('NaN', NaN, 0),\n JS_PROP_DOUBLE_DEF('NEGATIVE_INFINITY', -Infinity, 0),\n JS_PROP_DOUBLE_DEF('POSITIVE_INFINITY', Infinity, 0),\n JS_PROP_DOUBLE_DEF('EPSILON', 2.220446049250313e-16, 0), /* ES6 */\n JS_PROP_DOUBLE_DEF('MAX_SAFE_INTEGER', 9007199254740991.0, 0), /* ES6 */\n JS_PROP_DOUBLE_DEF('MIN_SAFE_INTEGER', -9007199254740991.0, 0), /* ES6 */\n];\n\nconst js_number_proto_funcs = [\n JS_NATIVE_DEF('toExponential', 1, NP.toExponential),\n JS_NATIVE_DEF('toFixed', 1, NP.toFixed),\n JS_NATIVE_DEF('toPrecision', 1, NP.toPrecision),\n JS_NATIVE_DEF('toString', 1, NP.toString),\n JS_NATIVE_DEF('toLocaleString', 0, NP.toLocaleString),\n JS_NATIVE_DEF('valueOf', 0, NP.valueOf),\n];\n\nexport function JS_AddIntrinsicNumber(ctx: JSContext): void {\n /* Number.prototype is a Number object with value 0 */\n const proto = Q.js_new_primitive_wrapper(ctx, ctx.class_proto[JSClassID.OBJECT], JSClassID.NUMBER, 0) as JSObject;\n ctx.class_proto[JSClassID.NUMBER] = proto;\n JS_SetPropertyFunctionList(ctx, proto, js_number_proto_funcs);\n const number_obj = JS_NewGlobalCConstructor(ctx, 'Number', js_number_constructor, 1, proto);\n JS_SetPropertyFunctionList(ctx, number_obj, js_number_funcs);\n}\n"]}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JSContext, JSValue, JSAtom } from '../quickjs.ts';
|
|
2
|
+
export declare function JS_DefinePropertyDesc(ctx: JSContext, obj: JSValue, prop: JSAtom, desc: JSValue, flags: number): number;
|
|
3
|
+
export declare function JS_ObjectDefineProperties(ctx: JSContext, obj: JSValue, properties: JSValue): number;
|
|
4
|
+
export declare function js_object_getPrototypeOf(ctx: JSContext, this_val: JSValue, argv: JSValue[], magic: number): JSValue;
|
|
5
|
+
export declare function js_set_prototype_internal(ctx: JSContext, obj: JSValue, proto_val: JSValue, throw_flag: boolean): number;
|
|
6
|
+
export declare function js_object_defineProperty(ctx: JSContext, this_val: JSValue, argv: JSValue[], magic: number): JSValue;
|
|
7
|
+
export declare function js_object_getOwnPropertyDescriptor(ctx: JSContext, this_val: JSValue, argv: JSValue[], magic: number): JSValue;
|
|
8
|
+
export declare function JS_GetOwnPropertyNames2(ctx: JSContext, obj1: JSValue, flags: number, kind: number): JSValue;
|
|
9
|
+
export declare function js_object_isExtensible(ctx: JSContext, this_val: JSValue, argv: JSValue[], reflect: number): JSValue;
|
|
10
|
+
export declare function js_object_preventExtensions(ctx: JSContext, this_val: JSValue, argv: JSValue[], reflect: number): JSValue;
|
|
11
|
+
export declare function js_object_toString(ctx: JSContext, this_val: JSValue, argv: JSValue[]): JSValue;
|
|
12
|
+
export declare function JS_AddIntrinsicObject(ctx: JSContext): void;
|