porffor 0.21.5 → 0.21.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.
@@ -28,6 +28,41 @@ export const __Porffor_object_isInextensible = (ptr: object): boolean => {
|
|
28
28
|
};
|
29
29
|
|
30
30
|
|
31
|
+
export const __Porffor_object_overrideAllFlags = (_this: object, overrideOr: i32, overrideAnd: i32) => {
|
32
|
+
let ptr: i32 = Porffor.wasm`local.get ${_this}` + 5;
|
33
|
+
|
34
|
+
const size: i32 = Porffor.wasm.i32.load(_this, 0, 0);
|
35
|
+
const endPtr: i32 = ptr + size * 14;
|
36
|
+
|
37
|
+
for (; ptr < endPtr; ptr += 14) {
|
38
|
+
let flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 12);
|
39
|
+
flags = (flags | overrideOr) & overrideAnd;
|
40
|
+
Porffor.wasm.i32.store8(ptr, flags, 0, 12);
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
export const __Porffor_object_checkAllFlags = (_this: object, dataAnd: i32, accessorAnd: i32, dataExpected: i32, accessorExpected: i32): boolean => {
|
45
|
+
let ptr: i32 = Porffor.wasm`local.get ${_this}` + 5;
|
46
|
+
|
47
|
+
const size: i32 = Porffor.wasm.i32.load(_this, 0, 0);
|
48
|
+
const endPtr: i32 = ptr + size * 14;
|
49
|
+
|
50
|
+
for (; ptr < endPtr; ptr += 14) {
|
51
|
+
const flags: i32 = Porffor.wasm.i32.load8_u(ptr, 0, 12);
|
52
|
+
if (flags & 0b0001) {
|
53
|
+
// accessor
|
54
|
+
if ((flags & accessorAnd) != accessorExpected) return false;
|
55
|
+
} else {
|
56
|
+
// data
|
57
|
+
if ((flags & dataAnd) != dataExpected) return false;
|
58
|
+
}
|
59
|
+
|
60
|
+
}
|
61
|
+
|
62
|
+
return true;
|
63
|
+
};
|
64
|
+
|
65
|
+
|
31
66
|
export const __Porffor_object_lookup = (_this: object, target: any): i32 => {
|
32
67
|
const targetType: i32 = Porffor.wasm`local.get ${target+1}`;
|
33
68
|
|
@@ -301,7 +301,7 @@ export const __Object_preventExtensions = (obj: any): any => {
|
|
301
301
|
return obj;
|
302
302
|
}
|
303
303
|
|
304
|
-
|
304
|
+
Porffor.object.preventExtensions(obj);
|
305
305
|
|
306
306
|
return obj;
|
307
307
|
};
|
@@ -316,9 +316,45 @@ export const __Object_isExtensible = (obj: any): any => {
|
|
316
316
|
return true;
|
317
317
|
}
|
318
318
|
|
319
|
-
return !
|
319
|
+
return !Porffor.object.isInextensible(obj);
|
320
320
|
};
|
321
321
|
|
322
|
+
|
323
|
+
export const __Object_freeze = (obj: any): any => {
|
324
|
+
// todo: support non-pure-objects
|
325
|
+
if (Porffor.rawType(obj) != Porffor.TYPES.object) {
|
326
|
+
return obj;
|
327
|
+
}
|
328
|
+
|
329
|
+
// make inextensible
|
330
|
+
Porffor.object.preventExtensions(obj);
|
331
|
+
|
332
|
+
// make all properties non-configurable and non-writable (if data descriptor)
|
333
|
+
Porffor.object.overrideAllFlags(obj, 0b0000, 0b0101);
|
334
|
+
|
335
|
+
return obj;
|
336
|
+
};
|
337
|
+
|
338
|
+
export const __Object_isFrozen = (obj: any): any => {
|
339
|
+
if (!Porffor.object.isObject(obj)) {
|
340
|
+
return true;
|
341
|
+
}
|
342
|
+
|
343
|
+
// todo: support non-pure-objects
|
344
|
+
if (Porffor.rawType(obj) != Porffor.TYPES.object) {
|
345
|
+
return false;
|
346
|
+
}
|
347
|
+
|
348
|
+
// check obj is inextensible
|
349
|
+
if (!Porffor.object.isInextensible(obj)) {
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
|
353
|
+
// check all properties are non-configurable and non-writable (if data descriptor)
|
354
|
+
return Porffor.object.checkAllFlags(obj, 0b1010, 0b0010, 0, 0);
|
355
|
+
};
|
356
|
+
|
357
|
+
|
322
358
|
export const __Object_prototype_toString = (_this: object) => {
|
323
359
|
let out: bytestring = '[object Object]';
|
324
360
|
return out;
|
package/compiler/codegen.js
CHANGED
@@ -310,7 +310,7 @@ const generateIdent = (scope, decl) => {
|
|
310
310
|
if (builtinVars[name].floatOnly && valtype[0] === 'i') throw new Error(`Cannot use ${unhackName(name)} with integer valtype`);
|
311
311
|
|
312
312
|
let wasm = builtinVars[name];
|
313
|
-
if (typeof wasm === 'function') wasm = asmFuncToAsm(
|
313
|
+
if (typeof wasm === 'function') wasm = asmFuncToAsm(scope, wasm);
|
314
314
|
return wasm.slice();
|
315
315
|
}
|
316
316
|
|
@@ -4326,7 +4326,7 @@ const makeArray = (scope, decl, global = false, name = '$undeclared', initEmpty
|
|
4326
4326
|
const firstAssign = !scope.arrays.has(uniqueName);
|
4327
4327
|
if (firstAssign) scope.arrays.set(uniqueName, rawPtr);
|
4328
4328
|
|
4329
|
-
const local = global ? globals[name] : scope.locals[name];
|
4329
|
+
const local = global ? globals[name] : scope.locals?.[name];
|
4330
4330
|
if (
|
4331
4331
|
Prefs.data && firstAssign && useRawElements &&
|
4332
4332
|
name !== '#member_prop' &&
|
@@ -14,6 +14,18 @@ export const BuiltinFuncs = function() {
|
|
14
14
|
returns: [127,127], typedReturns: 1,
|
15
15
|
locals: [127], localNames: ["ptr","ptr#type","out"],
|
16
16
|
};
|
17
|
+
this.__Porffor_object_overrideAllFlags = {
|
18
|
+
wasm: (scope, {}) => [[32,0],[65,5],[106],[33,6],[32,0],[40,0,0],[33,7],[32,6],[32,7],[65,14],[108],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,6],[45,0,12],[34,9],[32,2],[114],[32,4],[113],[33,9],[32,6],[32,9],[58,0,12],[32,6],[65,14],[106],[34,6],[12,1],[11],[11],[65,0],[65,128,1],[15]],
|
19
|
+
params: [127,127,127,127,127,127], typedParams: 1,
|
20
|
+
returns: [127,127], typedReturns: 1,
|
21
|
+
locals: [127,127,127,127], localNames: ["_this","_this#type","overrideOr","overrideOr#type","overrideAnd","overrideAnd#type","ptr","size","endPtr","flags"],
|
22
|
+
};
|
23
|
+
this.__Porffor_object_checkAllFlags = {
|
24
|
+
wasm: (scope, {}) => [[32,0],[65,5],[106],[33,10],[32,0],[40,0,0],[33,11],[32,10],[32,11],[65,14],[108],[106],[33,12],[3,64],[32,10],[32,12],[72],[4,64],[32,10],[45,0,12],[34,13],[65,1],[113],[4,64],[32,13],[32,4],[113],[32,8],[71],[4,64],[65,0],[65,2],[15],[11],[5],[32,13],[32,2],[113],[32,6],[71],[4,64],[65,0],[65,2],[15],[11],[11],[32,10],[65,14],[106],[34,10],[12,1],[11],[11],[65,1],[65,2],[15]],
|
25
|
+
params: [127,127,127,127,127,127,127,127,127,127], typedParams: 1,
|
26
|
+
returns: [127,127], typedReturns: 1,
|
27
|
+
locals: [127,127,127,127], localNames: ["_this","_this#type","dataAnd","dataAnd#type","accessorAnd","accessorAnd#type","dataExpected","dataExpected#type","accessorExpected","accessorExpected#type","ptr","size","endPtr","flags"],
|
28
|
+
};
|
17
29
|
this.__Porffor_object_lookup = {
|
18
30
|
wasm: (scope, {}) => [[32,3],[33,4],[32,0],[65,5],[106],[33,5],[32,0],[40,0,0],[33,6],[32,5],[32,6],[65,14],[108],[106],[33,7],[32,4],[65,195,1],[70],[4,64],[32,2],[33,8],[3,64],[32,5],[32,7],[72],[4,64],[2,64],[32,5],[40,0,0],[34,9],[69],[4,64],[12,2],[11],[32,9],[65,31],[118],[4,64],[12,1],[11],[32,9],[34,10],[32,8],[33,13],[34,11],[32,13],[71],[4,127],[32,11],[40,0,0],[34,12],[32,13],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,14],[32,12],[33,15],[3,64],[32,14],[32,11],[106],[45,0,4],[32,14],[32,13],[106],[45,0,4],[71],[4,64],[65,0],[12,2],[11],[32,14],[65,1],[106],[34,14],[32,15],[72],[13,0],[11],[65,1],[5],[65,1],[11],[4,64],[32,5],[65,1],[15],[11],[11],[32,5],[65,14],[106],[34,5],[12,1],[11],[11],[5],[32,2],[33,8],[3,64],[32,5],[32,7],[72],[4,64],[2,64],[32,5],[40,0,0],[34,9],[69],[4,64],[12,2],[11],[32,9],[65,31],[118],[4,64],[32,9],[65,255,255,255,255,7],[113],[34,10],[32,8],[33,13],[34,11],[32,13],[71],[4,127],[32,11],[40,0,0],[34,12],[32,13],[40,0,0],[71],[4,64],[65,0],[12,1],[11],[65,0],[33,14],[32,12],[65,2],[108],[33,15],[3,64],[32,14],[32,11],[106],[47,0,4],[32,14],[32,13],[106],[47,0,4],[71],[4,64],[65,0],[12,2],[11],[32,14],[65,2],[106],[34,14],[32,15],[72],[13,0],[11],[65,1],[5],[65,1],[11],[4,64],[32,5],[65,1],[15],[11],[11],[11],[32,5],[65,14],[106],[34,5],[12,1],[11],[11],[11],[65,127],[65,1],[15]],
|
19
31
|
params: [127,127,127,127], typedParams: 1,
|
@@ -1743,6 +1755,18 @@ export const BuiltinFuncs = function() {
|
|
1743
1755
|
returns: [124,127], typedReturns: 1,
|
1744
1756
|
locals: [127,124,127], localNames: ["obj","obj#type","#last_type","#logicinner_tmp","#typeswitch_tmp"],
|
1745
1757
|
};
|
1758
|
+
this.__Object_freeze = {
|
1759
|
+
wasm: (scope, {builtin}) => [[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,28,64],[98],[4,64],[32,0],[32,1],[15],[11],[32,0],[252,2],[32,1],[16, ...builtin('__Porffor_object_preventExtensions')],[26],[183],[26],[32,0],[252,2],[32,1],[65,0],[65,1],[65,5],[65,1],[16, ...builtin('__Porffor_object_overrideAllFlags')],[26],[183],[26],[32,0],[32,1],[15]],
|
1760
|
+
params: [124,127], typedParams: 1,
|
1761
|
+
returns: [124,127], typedReturns: 1,
|
1762
|
+
locals: [127], localNames: ["obj","obj#type","#last_type"],
|
1763
|
+
};
|
1764
|
+
this.__Object_isFrozen = {
|
1765
|
+
wasm: (scope, {builtin}) => [[32,0],[252,2],[32,1],[16, ...builtin('__Porffor_object_isObject')],[33,2],[183],[33,3],[32,2],[33,4],[2,124],[32,4],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,3],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,4],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,3],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,3],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],[68,0,0,0,0,0,0,240,63],[65,2],[15],[11],[32,0],[32,1],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,28,64],[98],[4,64],[68,0,0,0,0,0,0,0,0],[65,2],[15],[11],[32,0],[252,2],[32,1],[16, ...builtin('__Porffor_object_isInextensible')],[33,2],[183],[33,3],[32,2],[33,4],[2,124],[32,4],[65,195,0],[70],[4,64,"TYPESWITCH|String"],[32,3],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,4],[65,195,1],[70],[4,64,"TYPESWITCH|ByteString"],[32,3],[252,3],[40,1,0],[69],[184],[12,1],[11],[32,3],[68,0,0,0,0,0,0,0,0],[97],[184],[11,"TYPESWITCH_end"],[252,3],[4,64],[68,0,0,0,0,0,0,0,0],[65,2],[15],[11],[32,0],[252,2],[32,1],[65,10],[65,1],[65,2],[65,1],[65,0],[65,1],[65,0],[65,1],[16, ...builtin('__Porffor_object_checkAllFlags')],[33,2],[183],[32,2],[15]],
|
1766
|
+
params: [124,127], typedParams: 1,
|
1767
|
+
returns: [124,127], typedReturns: 1,
|
1768
|
+
locals: [127,124,127], localNames: ["obj","obj#type","#last_type","#logicinner_tmp","#typeswitch_tmp"],
|
1769
|
+
};
|
1746
1770
|
this.__Object_prototype_toString = {
|
1747
1771
|
wasm: (scope, {allocPage}) => [...number(allocPage(scope, 'bytestring: __Object_prototype_toString/out', 'i8') * pageSize, 124),[34,2],[65,195,1],[15]],
|
1748
1772
|
params: [124,127], typedParams: 1,
|
package/package.json
CHANGED
package/runner/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
2
|
import fs from 'node:fs';
|
3
|
-
globalThis.version = '0.21.
|
3
|
+
globalThis.version = '0.21.6+e77e4f0cb';
|
4
4
|
|
5
5
|
// deno compat
|
6
6
|
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
|
@@ -62,6 +62,12 @@ if (process.argv.includes('--help')) {
|
|
62
62
|
process.exit(0);
|
63
63
|
}
|
64
64
|
|
65
|
+
const done = async () => {
|
66
|
+
// do nothing for the rest of this file
|
67
|
+
await new Promise(res => process.on('beforeExit', res));
|
68
|
+
process.exit();
|
69
|
+
};
|
70
|
+
|
65
71
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
66
72
|
if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
67
73
|
// remove this arg
|
@@ -69,17 +75,17 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm
|
|
69
75
|
|
70
76
|
if (file === 'precompile') {
|
71
77
|
await import('../compiler/precompile.js');
|
72
|
-
await
|
78
|
+
await done();
|
73
79
|
}
|
74
80
|
|
75
81
|
if (file === 'profile') {
|
76
82
|
await import('./profile.js');
|
77
|
-
await
|
83
|
+
await done();
|
78
84
|
}
|
79
85
|
|
80
86
|
if (file === 'debug') {
|
81
87
|
await import('./debug.js');
|
82
|
-
await
|
88
|
+
await done();
|
83
89
|
}
|
84
90
|
|
85
91
|
if (['wasm', 'native', 'c'].includes(file)) {
|
@@ -109,7 +115,7 @@ if (!file) {
|
|
109
115
|
|
110
116
|
// run repl if no file given
|
111
117
|
await import('./repl.js');
|
112
|
-
await
|
118
|
+
await done();
|
113
119
|
}
|
114
120
|
|
115
121
|
const source = fs.readFileSync(file, 'utf8');
|