porffor 0.48.6 → 0.48.8
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 +3 -4
- package/compiler/builtins/promise.ts +2 -0
- package/compiler/builtins_precompiled.js +7 -0
- package/compiler/codegen.js +104 -84
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/README.md
CHANGED
@@ -83,11 +83,10 @@ Rhemyn is Porffor's own regex engine; it compiles literal regex to Wasm bytecode
|
|
83
83
|
2c is Porffor's own Wasm -> C compiler, using generated Wasm bytecode and internal info to generate specific and efficient/fast C code. Little boilerplate/preluded code or required external files, just for CLI binaries (not like wasm2c very much).
|
84
84
|
|
85
85
|
## Versioning
|
86
|
-
Porffor uses a unique versioning system, here's an example: `0.
|
86
|
+
Porffor uses a unique versioning system, here's an example: `0.48.7`. Let's break it down:
|
87
87
|
1. `0` - major, always `0` as Porffor is not ready yet
|
88
|
-
2. `
|
89
|
-
3. `
|
90
|
-
4. `2aa3f0589` - commit hash
|
88
|
+
2. `48` - minor, total Test262 pass percentage (rounded half down, eg `49.4%` -> `48`, `49.5%` -> `49`)
|
89
|
+
3. `7` - micro, build number for that minor (incremented each git push)
|
91
90
|
|
92
91
|
## Performance
|
93
92
|
*For the features it supports most of the time*, Porffor is *blazingly fast* compared to most interpreters and common engines running without JIT. For those with JIT, it is usually slower by default, but can catch up with compiler arguments and typed input, even more so when compiling to native binaries.
|
@@ -473,6 +473,8 @@ export const __Promise_race = (promises: any): Promise => {
|
|
473
473
|
});
|
474
474
|
};
|
475
475
|
|
476
|
+
// export const __Promise_try = function (cb: any, ...args: any[]) { return new this(res => res(cb(...args))) };
|
477
|
+
export const __Promise_try = async (cb: any, ...args: any[]) => cb(...args);
|
476
478
|
|
477
479
|
export const __Promise_prototype_toString = (_this: any) => '[object Promise]';
|
478
480
|
export const __Promise_prototype_toLocaleString = (_this: any) => __Promise_prototype_toString(_this);
|
@@ -2460,6 +2460,13 @@ locals:[124,127,127],localNames:["r","r#type","#indirect_callee","#typeswitch_tm
|
|
2460
2460
|
globalInits:{jobQueue:(_,{allocPage,glbl})=>[...number(allocPage(_,'promise.ts/jobQueue'),124),...glbl(36,'jobQueue',124),[65,16],[26]]},
|
2461
2461
|
table:1,usesTag:1,
|
2462
2462
|
}
|
2463
|
+
this.__Promise_try = {
|
2464
|
+
wasm:(_,{t,builtin,internalThrow})=>[[16,builtin('__Porffor_promise_create')],[26],[33,4],[6,64],[32,0],[33,14],[32,1],[33,10],[2,124],...t([6],()=>[[32,10],[65,6],[70],[4,64],[68,0],[65,128,1],[68,0],[65,128,1],[32,2],[33,5],[65,208,0],[34,6],[65,208,0],[70],[32,6],[65,19],[70],[114],[32,6],[65,195,0],[70],[114],[32,6],[65,195,1],[70],[114],[32,6],[65,50],[70],[114],[32,6],[65,216,0],[78],[32,6],[65,224,0],[76],[113],[114],[69],[4,64],...internalThrow(_,'TypeError',`Cannot spread a non-iterable`),[11],[32,5],[33,7],[68,0],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,1],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,2],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,3],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,4],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,5],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,6],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,5],[33,7],[68,7],[33,8],[32,6],[33,10],[2,124],...t([67],()=>[[32,10],[65,195,0],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[65,2],[108],[32,7],[252,3],[106],[47,0,4],[59,0,4],[32,11],[184],[65,195,0],[33,9],[12,1],[11]]),...t([80],()=>[[32,10],[65,208,0],[70],[4,64],[32,8],[252,3],[65,9],[108],[32,7],[252,3],[106],[34,12],[43,0,4],[32,12],[45,0,12],[33,9],[12,1],[11]]),...t([88],()=>[[32,10],[65,216,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([89],()=>[[32,10],[65,217,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[44,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([90],()=>[[32,10],[65,218,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[106],[45,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([91],()=>[[32,10],[65,219,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[47,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([92],()=>[[32,10],[65,220,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,2],[108],[106],[46,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([93],()=>[[32,10],[65,221,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[184],[65,1],[33,9],[12,1],[11]]),...t([94],()=>[[32,10],[65,222,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[40,0,4],[183],[65,1],[33,9],[12,1],[11]]),...t([95],()=>[[32,10],[65,223,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,4],[108],[106],[42,0,4],[187],[65,1],[33,9],[12,1],[11]]),...t([96],()=>[[32,10],[65,224,0],[70],[4,64],[32,7],[252,3],[40,0,4],[32,8],[252,3],[65,8],[108],[106],[43,0,4],[65,1],[33,9],[12,1],[11]]),...t([128],()=>[[32,10],[65,128,1],[70],[4,64],...internalThrow(_,'TypeError',`Cannot read property of undefined`),[68,0],[12,1],[11]]),...t([195],()=>[[32,10],[65,195,1],[70],[4,64],[65,8],[16,builtin('__Porffor_allocateBytes')],[34,11],[65,1],[54,0,0],[32,11],[32,8],[252,3],[32,7],[252,3],[106],[45,0,4],[58,0,4],[32,11],[184],[65,195,1],[33,9],[12,1],[11]]),[32,7],[252,2],[32,6],[32,8],[65,1],[16,builtin('__ecma262_ToPropertyKey')],[33,13],[252,2],[32,13],[16,builtin('__Porffor_object_get')],[33,9],[11],[32,9],[32,14],[252,3],[17,10,0],[33,9],[12,1],[11]]),...internalThrow(_,'TypeError',`cb is not a function`),[68,0],[11],[32,9],[32,4],[65,36],[16,builtin('__Porffor_promise_resolve')],[26],[26],[32,4],[65,36],[15],[7,0],[32,4],[65,36],[16,builtin('__Porffor_promise_reject')],[26],[26],[11],[32,4],[65,36],[15]],
|
2465
|
+
params:[124,127,124,127],typedParams:1,returns:[124,127],typedReturns:1,
|
2466
|
+
locals:[124,124,127,124,124,127,127,127,127,127,124],localNames:["cb","cb#type","args","args#type","#async_out_promise","#spread","#spread#type","#member_obj","#member_prop","#last_type","#typeswitch_tmp1","#member_allocd","#loadArray_offset","#swap","#indirect_callee"],
|
2467
|
+
usedTypes:[36,80,67,195],
|
2468
|
+
table:1,hasRestArgument:1,usesTag:1,
|
2469
|
+
}
|
2463
2470
|
this.__Promise_prototype_toString = {
|
2464
2471
|
wasm:(_,{makeString})=>[...makeString(_,"[object Promise]",1),[65,195,1],[15]],
|
2465
2472
|
params:[124,127],typedParams:1,returns:[124,127],typedReturns:1,
|
package/compiler/codegen.js
CHANGED
@@ -164,7 +164,8 @@ const funcRef = func => {
|
|
164
164
|
[ Opcodes.local_get, 0 ], // new.target value
|
165
165
|
Opcodes.i32_to_u,
|
166
166
|
[ Opcodes.if, Blocktype.void ], // if value is non-zero
|
167
|
-
...internalThrow(wrapperFunc, 'TypeError', `${unhackName(func.name)} is not a constructor`), // throw type error
|
167
|
+
// ...internalThrow(wrapperFunc, 'TypeError', `${unhackName(func.name)} is not a constructor`), // throw type error
|
168
|
+
...internalThrow(wrapperFunc, 'TypeError', `Function is not a constructor`), // throw type error
|
168
169
|
[ Opcodes.end ]
|
169
170
|
);
|
170
171
|
}
|
@@ -1730,7 +1731,11 @@ const generateSequence = (scope, decl) => {
|
|
1730
1731
|
};
|
1731
1732
|
|
1732
1733
|
const generateChain = (scope, decl) => {
|
1733
|
-
|
1734
|
+
scope.chainMembers = 0;
|
1735
|
+
const out = generate(scope, decl.expression);
|
1736
|
+
scope.chainMembers = null;
|
1737
|
+
|
1738
|
+
return out;
|
1734
1739
|
};
|
1735
1740
|
|
1736
1741
|
const ArrayUtil = {
|
@@ -1859,6 +1864,21 @@ const aliasPrimObjsBC = bc => {
|
|
1859
1864
|
add(TYPES.string, TYPES.stringobject);
|
1860
1865
|
};
|
1861
1866
|
|
1867
|
+
const typeIsIterable = wasm => [
|
1868
|
+
// array, set, string, bytestring, generator
|
1869
|
+
...typeIsOneOf(wasm, [ TYPES.array, TYPES.set, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
|
1870
|
+
// typed array
|
1871
|
+
...wasm,
|
1872
|
+
...number(TYPES.uint8array, Valtype.i32),
|
1873
|
+
[ Opcodes.i32_ge_s ],
|
1874
|
+
...wasm,
|
1875
|
+
...number(TYPES.float64array, Valtype.i32),
|
1876
|
+
[ Opcodes.i32_le_s ],
|
1877
|
+
[ Opcodes.i32_and ],
|
1878
|
+
[ Opcodes.i32_or ],
|
1879
|
+
[ Opcodes.i32_eqz ],
|
1880
|
+
];
|
1881
|
+
|
1862
1882
|
const createThisArg = (scope, decl) => {
|
1863
1883
|
const name = decl.callee?.name;
|
1864
1884
|
if (decl._new) {
|
@@ -1902,21 +1922,29 @@ const createThisArg = (scope, decl) => {
|
|
1902
1922
|
...number(TYPES.object, Valtype.i32)
|
1903
1923
|
];
|
1904
1924
|
} else {
|
1905
|
-
if (name && name.startsWith('__')
|
1906
|
-
|
1907
|
-
|
1908
|
-
|
1909
|
-
|
1910
|
-
|
1911
|
-
|
1925
|
+
if (name && name.startsWith('__')) {
|
1926
|
+
let node = null;
|
1927
|
+
|
1928
|
+
if (name.includes('_prototype_')) {
|
1929
|
+
node = {
|
1930
|
+
type: 'NewExpression',
|
1931
|
+
callee: {
|
1932
|
+
type: 'Identifier',
|
1933
|
+
name: name.slice(2, name.indexOf('_', 2))
|
1934
|
+
},
|
1935
|
+
arguments: [],
|
1936
|
+
_new: true
|
1937
|
+
};
|
1938
|
+
} else {
|
1939
|
+
node = {
|
1912
1940
|
type: 'Identifier',
|
1913
|
-
name: name.slice(2, name.
|
1914
|
-
}
|
1915
|
-
arguments: [],
|
1916
|
-
_new: true
|
1917
|
-
};
|
1941
|
+
name: name.slice(2, name.lastIndexOf('_'))
|
1942
|
+
};
|
1918
1943
|
|
1919
|
-
|
1944
|
+
if (ifIdentifierErrors(scope, node)) node = null;
|
1945
|
+
}
|
1946
|
+
|
1947
|
+
if (node) return [
|
1920
1948
|
...generate(scope, node),
|
1921
1949
|
...getNodeType(scope, node)
|
1922
1950
|
];
|
@@ -2273,6 +2301,36 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2273
2301
|
}
|
2274
2302
|
}
|
2275
2303
|
|
2304
|
+
let args = decl.arguments.slice();
|
2305
|
+
if (args.at(-1)?.type === 'SpreadElement') {
|
2306
|
+
// hack: support spread element if last by doing essentially:
|
2307
|
+
// const foo = () => ...;
|
2308
|
+
// foo(a, b, ...c) -> _ = c; foo(a, b, _[0], _[1], ...)
|
2309
|
+
const arg = args.at(-1).argument;
|
2310
|
+
out.push(
|
2311
|
+
...generate(scope, arg),
|
2312
|
+
[ Opcodes.local_set, localTmp(scope, '#spread') ],
|
2313
|
+
...getNodeType(scope, arg),
|
2314
|
+
[ Opcodes.local_set, localTmp(scope, '#spread#type', Valtype.i32) ],
|
2315
|
+
|
2316
|
+
...typeIsIterable([ [ Opcodes.local_get, localTmp(scope, '#spread#type', Valtype.i32) ] ]),
|
2317
|
+
[ Opcodes.if, Blocktype.void ],
|
2318
|
+
...internalThrow(scope, 'TypeError', 'Cannot spread a non-iterable'),
|
2319
|
+
[ Opcodes.end ]
|
2320
|
+
);
|
2321
|
+
|
2322
|
+
args.pop();
|
2323
|
+
for (let i = 0; i < 8; i++) {
|
2324
|
+
args.push({
|
2325
|
+
type: 'MemberExpression',
|
2326
|
+
object: { type: 'Identifier', name: '#spread' },
|
2327
|
+
property: { type: 'Literal', value: i },
|
2328
|
+
computed: true,
|
2329
|
+
optional: false
|
2330
|
+
});
|
2331
|
+
}
|
2332
|
+
}
|
2333
|
+
|
2276
2334
|
let idx;
|
2277
2335
|
if (Object.hasOwn(funcIndex, name)) {
|
2278
2336
|
idx = funcIndex[name];
|
@@ -2350,11 +2408,9 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2350
2408
|
funcs.table = true;
|
2351
2409
|
scope.table = true;
|
2352
2410
|
|
2353
|
-
let args = decl.arguments;
|
2354
2411
|
const wrapperArgc = Prefs.indirectWrapperArgc ?? 8;
|
2355
|
-
|
2356
|
-
|
2357
|
-
}
|
2412
|
+
const underflow = wrapperArgc - args.length;
|
2413
|
+
for (let i = 0; i < underflow; i++) args.push(DEFAULT_VALUE());
|
2358
2414
|
|
2359
2415
|
for (let i = 0; i < args.length; i++) {
|
2360
2416
|
const arg = args[i];
|
@@ -2442,7 +2498,6 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2442
2498
|
return internalThrow(scope, 'TypeError', `${unhackName(name)} is not a constructor`, true);
|
2443
2499
|
}
|
2444
2500
|
|
2445
|
-
let args = [...decl.arguments];
|
2446
2501
|
const internalProtoFunc = func && func.internal && func.name.includes('_prototype_');
|
2447
2502
|
if (!globalThis.precompile && internalProtoFunc && !decl._protoInternalCall) {
|
2448
2503
|
// just function called, not as prototype, add this to start
|
@@ -2455,34 +2510,10 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
2455
2510
|
paramOffset += 4;
|
2456
2511
|
}
|
2457
2512
|
|
2458
|
-
if (args.at(-1)?.type === 'SpreadElement') {
|
2459
|
-
// hack: support spread element if last by doing essentially:
|
2460
|
-
// const foo = (a, b, c, d) => ...
|
2461
|
-
// foo(a, b, ...c) -> _ = c; foo(a, b, _[0], _[1])
|
2462
|
-
const arg = args.at(-1).argument;
|
2463
|
-
out.push(
|
2464
|
-
...generate(scope, arg),
|
2465
|
-
[ Opcodes.local_set, localTmp(scope, '#spread') ],
|
2466
|
-
...getNodeType(scope, arg),
|
2467
|
-
[ Opcodes.local_set, localTmp(scope, '#spread#type', Valtype.i32) ]
|
2468
|
-
);
|
2469
|
-
|
2470
|
-
args.pop();
|
2471
|
-
const leftover = paramCount - args.length;
|
2472
|
-
for (let i = 0; i < leftover; i++) {
|
2473
|
-
args.push({
|
2474
|
-
type: 'MemberExpression',
|
2475
|
-
object: { type: 'Identifier', name: '#spread' },
|
2476
|
-
property: { type: 'Literal', value: i },
|
2477
|
-
computed: true,
|
2478
|
-
optional: false
|
2479
|
-
});
|
2480
|
-
}
|
2481
|
-
}
|
2482
|
-
|
2483
2513
|
if (func && args.length < paramCount) {
|
2484
2514
|
// too little args, push undefineds
|
2485
|
-
|
2515
|
+
const underflow = paramCount - (func.hasRestArgument ? 1 : 0) - args.length;
|
2516
|
+
for (let i = 0; i < underflow; i++) args.push(DEFAULT_VALUE());
|
2486
2517
|
}
|
2487
2518
|
|
2488
2519
|
if (func && func.hasRestArgument) {
|
@@ -3126,7 +3157,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3126
3157
|
let out = generateVarDstr(scope, 'const', tmpName, init, defaultValue, false);
|
3127
3158
|
|
3128
3159
|
let i = 0;
|
3129
|
-
const elements =
|
3160
|
+
const elements = pattern.elements.slice();
|
3130
3161
|
for (const e of elements) {
|
3131
3162
|
switch (e?.type) {
|
3132
3163
|
case 'RestElement': { // let [ ...foo ] = []
|
@@ -3187,24 +3218,11 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3187
3218
|
|
3188
3219
|
out = out.concat([
|
3189
3220
|
// check tmp is iterable
|
3190
|
-
|
3191
|
-
...typeIsOneOf(getType(scope, tmpName), [ TYPES.array, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
|
3192
|
-
// typed array
|
3193
|
-
...getType(scope, tmpName),
|
3194
|
-
...number(TYPES.uint8array, Valtype.i32),
|
3195
|
-
[ Opcodes.i32_ge_s ],
|
3196
|
-
...getType(scope, tmpName),
|
3197
|
-
...number(TYPES.float64array, Valtype.i32),
|
3198
|
-
[ Opcodes.i32_le_s ],
|
3199
|
-
[ Opcodes.i32_and ],
|
3200
|
-
[ Opcodes.i32_or ],
|
3201
|
-
[ Opcodes.i32_eqz ],
|
3221
|
+
...typeIsIterable(getType(scope, tmpName)),
|
3202
3222
|
[ Opcodes.if, Blocktype.void ],
|
3203
3223
|
...internalThrow(scope, 'TypeError', 'Cannot array destructure a non-iterable'),
|
3204
3224
|
[ Opcodes.end ],
|
3205
|
-
|
3206
|
-
...decls
|
3207
|
-
]);
|
3225
|
+
], decls);
|
3208
3226
|
|
3209
3227
|
return out;
|
3210
3228
|
}
|
@@ -3214,7 +3232,7 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3214
3232
|
const tmpName = '#destructure' + uniqId();
|
3215
3233
|
let out = generateVarDstr(scope, 'const', tmpName, init, defaultValue, false);
|
3216
3234
|
|
3217
|
-
const properties =
|
3235
|
+
const properties = pattern.properties.slice();
|
3218
3236
|
const usedProps = [];
|
3219
3237
|
for (const prop of properties) {
|
3220
3238
|
if (prop.type == 'Property') { // let { foo } = {}
|
@@ -3277,10 +3295,8 @@ const generateVarDstr = (scope, kind, pattern, init, defaultValue, global) => {
|
|
3277
3295
|
[ Opcodes.i32_or ],
|
3278
3296
|
[ Opcodes.if, Blocktype.void ],
|
3279
3297
|
...internalThrow(scope, 'TypeError', 'Cannot object destructure undefined or null'),
|
3280
|
-
[ Opcodes.end ]
|
3281
|
-
|
3282
|
-
...decls
|
3283
|
-
]);
|
3298
|
+
[ Opcodes.end ]
|
3299
|
+
], decls);
|
3284
3300
|
|
3285
3301
|
return out;
|
3286
3302
|
}
|
@@ -4125,18 +4141,7 @@ const generateForOf = (scope, decl) => {
|
|
4125
4141
|
[ Opcodes.local_set, counter ],
|
4126
4142
|
|
4127
4143
|
// check tmp is iterable
|
4128
|
-
|
4129
|
-
...typeIsOneOf(iterType, [ TYPES.array, TYPES.set, TYPES.string, TYPES.bytestring, TYPES.__porffor_generator ]),
|
4130
|
-
// typed array
|
4131
|
-
...iterType,
|
4132
|
-
...number(TYPES.uint8array, Valtype.i32),
|
4133
|
-
[ Opcodes.i32_ge_s ],
|
4134
|
-
...iterType,
|
4135
|
-
...number(TYPES.float64array, Valtype.i32),
|
4136
|
-
[ Opcodes.i32_le_s ],
|
4137
|
-
[ Opcodes.i32_and ],
|
4138
|
-
[ Opcodes.i32_or ],
|
4139
|
-
[ Opcodes.i32_eqz ],
|
4144
|
+
...typeIsIterable(iterType),
|
4140
4145
|
[ Opcodes.if, Blocktype.void ],
|
4141
4146
|
...internalThrow(scope, 'TypeError', `Tried for..of on non-iterable type`),
|
4142
4147
|
[ Opcodes.end ],
|
@@ -5284,7 +5289,7 @@ const countLength = (func, name = undefined) => {
|
|
5284
5289
|
return count;
|
5285
5290
|
};
|
5286
5291
|
|
5287
|
-
const generateMember = (scope, decl, _global, _name
|
5292
|
+
const generateMember = (scope, decl, _global, _name) => {
|
5288
5293
|
let final = [], finalEnd, extraBC = {};
|
5289
5294
|
let name = decl.object.name;
|
5290
5295
|
|
@@ -5302,6 +5307,8 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5302
5307
|
const object = decl.object;
|
5303
5308
|
const property = getProperty(decl);
|
5304
5309
|
|
5310
|
+
let chainCount = scope.chainMembers != null ? ++scope.chainMembers : 0;
|
5311
|
+
|
5305
5312
|
// generate now so type is gotten correctly later (it gets cached)
|
5306
5313
|
generate(scope, object);
|
5307
5314
|
|
@@ -5640,7 +5647,7 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5640
5647
|
if (decl.optional) {
|
5641
5648
|
out.unshift(
|
5642
5649
|
[ Opcodes.block, valtypeBinary ],
|
5643
|
-
...
|
5650
|
+
...generate(scope, object),
|
5644
5651
|
[ Opcodes.local_tee, localTmp(scope, '#member_obj') ],
|
5645
5652
|
...(scope.locals['#member_obj#type'] ? [
|
5646
5653
|
...getNodeType(scope, object),
|
@@ -5651,7 +5658,7 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5651
5658
|
[ Opcodes.if, Blocktype.void ],
|
5652
5659
|
...setLastType(scope, TYPES.undefined),
|
5653
5660
|
...number(0),
|
5654
|
-
[ Opcodes.br,
|
5661
|
+
[ Opcodes.br, chainCount ],
|
5655
5662
|
[ Opcodes.end ],
|
5656
5663
|
|
5657
5664
|
...generate(scope, property, false, '#member_prop'),
|
@@ -5663,7 +5670,7 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5663
5670
|
);
|
5664
5671
|
} else {
|
5665
5672
|
out.unshift(
|
5666
|
-
...
|
5673
|
+
...generate(scope, object),
|
5667
5674
|
[ Opcodes.local_set, localTmp(scope, '#member_obj') ],
|
5668
5675
|
...(scope.locals['#member_obj#type'] ? [
|
5669
5676
|
...getNodeType(scope, object),
|
@@ -5673,6 +5680,17 @@ const generateMember = (scope, decl, _global, _name, _objectWasm = undefined) =>
|
|
5673
5680
|
...generate(scope, property, false, '#member_prop'),
|
5674
5681
|
[ Opcodes.local_set, localTmp(scope, '#member_prop') ]
|
5675
5682
|
);
|
5683
|
+
|
5684
|
+
// todo: maybe this just needs 1 block?
|
5685
|
+
if (chainCount > 0) {
|
5686
|
+
out.unshift(
|
5687
|
+
[ Opcodes.block, valtypeBinary ]
|
5688
|
+
);
|
5689
|
+
|
5690
|
+
out.push(
|
5691
|
+
[ Opcodes.end ]
|
5692
|
+
);
|
5693
|
+
}
|
5676
5694
|
}
|
5677
5695
|
|
5678
5696
|
if (final.length > 0) {
|
@@ -6153,7 +6171,9 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
6153
6171
|
typeUsed(func, TYPES.promise);
|
6154
6172
|
}
|
6155
6173
|
|
6156
|
-
|
6174
|
+
const preface = wasm;
|
6175
|
+
wasm = generate(func, body);
|
6176
|
+
wasm.unshift(...preface);
|
6157
6177
|
|
6158
6178
|
if (func.generator) {
|
6159
6179
|
// make generator at the start
|
package/package.json
CHANGED