porffor 0.56.7 → 0.56.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/compiler/2c.js CHANGED
@@ -175,7 +175,9 @@ const removeBrackets = str => {
175
175
  return str.startsWith('(') && str.endsWith(')') && !str.startsWith('(*') ? str.slice(1, -1) : str;
176
176
  };
177
177
 
178
- export default ({ funcs, globals, tags, data, exceptions, pages }) => {
178
+ export default ({ funcs, globals, data, pages }) => {
179
+ if (Prefs.secure) log.warning('2c', `native/c targets are not sandboxed or proven to be safe (--secure)`);
180
+
179
181
  const invOperatorOpcode = Object.values(operatorOpcode).reduce((acc, x) => {
180
182
  for (const k in x) {
181
183
  acc[x[k]] = k;
@@ -794,6 +796,7 @@ _time_out = _time.tv_nsec / 1000000. + _time.tv_sec * 1000.;`);
794
796
  }
795
797
 
796
798
  case Opcodes.throw: {
799
+ // only supports stack exception mode
797
800
  // todo: allow catching
798
801
  const type = vals.pop();
799
802
  const val = vals.pop();
@@ -1,7 +1,5 @@
1
1
  import type {} from './porffor.d.ts';
2
2
 
3
- const descStore: any[] = [];
4
-
5
3
  // 20.4.1.1 Symbol ([ description ])
6
4
  // https://tc39.es/ecma262/#sec-symbol-description
7
5
  export const Symbol = (description: any): Symbol => {
@@ -17,11 +15,28 @@ export const Symbol = (description: any): Symbol => {
17
15
  }
18
16
 
19
17
  // 4. Return a new Symbol whose [[Description]] is descString.
20
- return Porffor.array.fastPush(descStore, descString) as Symbol;
18
+ Porffor.wasm`
19
+ local symbol i32
20
+ i32.const 16
21
+ call __Porffor_allocateBytes
22
+ local.tee symbol
23
+ local.get ${descString}
24
+ f64.store 0 0
25
+ local.get symbol
26
+ local.get ${descString+1}
27
+ i32.store8 0 8`;
28
+
29
+ return symbol;
21
30
  };
22
31
 
23
32
  export const __Symbol_prototype_description$get = (_this: Symbol) => {
24
- return descStore[Porffor.wasm`local.get ${_this}` - 1];
33
+ Porffor.wasm`local.get ${_this}
34
+ i32.to_u
35
+ f64.load 0 0
36
+ local.get ${_this}
37
+ i32.to_u
38
+ i32.load8_u 0 8
39
+ return`;
25
40
  };
26
41
 
27
42
  export const __Symbol_prototype_toString = (_this: Symbol) => {