porffor 0.20.3 → 0.20.5

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.
@@ -146,7 +146,7 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
146
146
 
147
147
  const tableSection = !funcs.table ? [] : createSection(
148
148
  Section.table,
149
- encodeVector([ [ Reftype.funcref, 0x00, funcs.length ] ])
149
+ encodeVector([ [ Reftype.funcref, 0x00, ...unsignedLEB128(funcs.length) ] ])
150
150
  );
151
151
 
152
152
  const elementSection = !funcs.table ? [] : createSection(
@@ -42,13 +42,11 @@ export const __Symbol_prototype_toString = (_this: Symbol) => {
42
42
  Porffor.wasm.i32.store8(out, 108, 0, 9);
43
43
  Porffor.wasm.i32.store8(out, 40, 0, 10);
44
44
 
45
- const description: any = descStore[Porffor.wasm`local.get ${_this}` - 1];
45
+ const description: any = _this.description;
46
46
  let descLen: i32 = 0;
47
47
  if (description !== undefined) {
48
48
  descLen = description.length;
49
49
 
50
- print(descLen);
51
-
52
50
  // todo: support regular string
53
51
  let outPtr: i32 = Porffor.wasm`local.get ${out}` + 7;
54
52
  let descPtr: i32 = Porffor.wasm`local.get ${description}`;
@@ -80,4 +78,16 @@ export const __Symbol_for = (key: any): Symbol => {
80
78
  forStore.set(key, out);
81
79
 
82
80
  return out;
81
+ };
82
+
83
+ export const __Symbol_keyFor = (arg: any): any => {
84
+ if (Porffor.rawType(arg) != Porffor.TYPES.symbol) throw new TypeError('Symbol.keyFor argument should be a Symbol');
85
+
86
+ const sym: Symbol = arg;
87
+ const desc: any = sym.description;
88
+
89
+ const stored: Symbol = forStore.get(desc);
90
+ if (sym == stored) return desc;
91
+
92
+ return undefined;
83
93
  };