porffor 0.57.27 → 0.57.29

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.
@@ -395,22 +395,14 @@ return`;
395
395
  export const __Porffor_object_accessorGet = (entryPtr: i32): Function|undefined => {
396
396
  const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 8);
397
397
 
398
- // no getter, return undefined
399
- if (Porffor.wasm`local.get ${out}` == 0) {
400
- return undefined;
401
- }
402
-
398
+ if (Porffor.wasm`local.get ${out}` == 0) return undefined;
403
399
  return out;
404
400
  };
405
401
 
406
402
  export const __Porffor_object_accessorSet = (entryPtr: i32): Function|undefined => {
407
403
  const out: Function = Porffor.wasm.i32.load(entryPtr, 0, 12);
408
404
 
409
- // no setter, return undefined
410
- if (Porffor.wasm`local.get ${out}` == 0) {
411
- return undefined;
412
- }
413
-
405
+ if (Porffor.wasm`local.get ${out}` == 0) return undefined;
414
406
  return out;
415
407
  };
416
408
 
@@ -507,12 +499,7 @@ local.set ${obj+1}`;
507
499
  lastProto = obj;
508
500
  }
509
501
 
510
- if (entryPtr == -1) {
511
- Porffor.wasm`
512
- f64.const 0
513
- i32.const 128
514
- return`;
515
- }
502
+ if (entryPtr == -1) return undefined;
516
503
  }
517
504
 
518
505
  const tail: i32 = Porffor.wasm.i32.load16_u(entryPtr, 0, 16);
@@ -520,14 +507,7 @@ return`;
520
507
  // accessor descriptor
521
508
  const get: Function = __Porffor_object_accessorGet(entryPtr);
522
509
 
523
- // no getter, return undefined
524
- if (Porffor.wasm`local.get ${get}` == 0) {
525
- Porffor.wasm`
526
- f64.const 0
527
- i32.const 128
528
- return`;
529
- }
530
-
510
+ if (Porffor.wasm`local.get ${get}` == 0) return undefined;
531
511
  return get.call(obj);
532
512
  }
533
513
 
@@ -585,12 +565,7 @@ local.set ${obj+1}`;
585
565
  lastProto = obj;
586
566
  }
587
567
 
588
- if (entryPtr == -1) {
589
- Porffor.wasm`
590
- f64.const 0
591
- i32.const 128
592
- return`;
593
- }
568
+ if (entryPtr == -1) return undefined;
594
569
  }
595
570
 
596
571
  const tail: i32 = Porffor.wasm.i32.load16_u(entryPtr, 0, 16);
@@ -598,14 +573,7 @@ return`;
598
573
  // accessor descriptor
599
574
  const get: Function = __Porffor_object_accessorGet(entryPtr);
600
575
 
601
- // no getter, return undefined
602
- if (Porffor.wasm`local.get ${get}` == 0) {
603
- Porffor.wasm`
604
- f64.const 0
605
- i32.const 128
606
- return`;
607
- }
608
-
576
+ if (Porffor.wasm`local.get ${get}` == 0) return undefined;
609
577
  return get.call(obj);
610
578
  }
611
579
 
@@ -19,14 +19,26 @@ export const __ByteString_prototype_${a0} = (_this: bytestring) =>
19
19
  noArgs('sup', 'sup');
20
20
 
21
21
  const arg = (name, s1, s2) => out += `
22
- export const __String_prototype_${name} = (_this: string, arg: any) =>
23
- Porffor.concatStrings(
22
+ export const __String_prototype_${name} = (_this: string, arg: any) => {
23
+ arg = ecma262.ToString(arg);
24
+ let escaped: bytestring = Porffor.allocate();
25
+ for (let i = 0; i < arg.length; i++) {
26
+ const c = arg.charCodeAt(i);
27
+ if (c != 34) {
28
+ __Porffor_bytestring_appendChar(escaped, c);
29
+ } else {
30
+ __Porffor_bytestring_appendStr(escaped, '&quot;');
31
+ }
32
+ }
33
+
34
+ return Porffor.concatStrings(
24
35
  Porffor.concatStrings(
25
36
  Porffor.concatStrings(
26
- Porffor.concatStrings('<${s1} ${s2}="', arg),
37
+ Porffor.concatStrings('<${s1} ${s2}="', escaped),
27
38
  '">'),
28
39
  _this),
29
40
  '</${s1}>');
41
+ }
30
42
  export const __ByteString_prototype_${name} = (_this: bytestring, arg: any) =>
31
43
  __String_prototype_${name}(_this, arg);`;
32
44
 
@@ -35,7 +47,7 @@ export const __ByteString_prototype_${name} = (_this: bytestring, arg: any) =>
35
47
  arg('anchor', 'a', 'name');
36
48
  arg('link', 'a', 'href');
37
49
 
38
- const prototypeAlias = (regular, annex) => `
50
+ const prototypeAlias = (regular, annex) => out += `
39
51
  export const __String_prototype_${annex} = (_this: any) =>
40
52
  __String_prototype_${regular}(_this);
41
53
  export const __ByteString_prototype_${annex} = (_this: any) =>
@@ -746,8 +746,11 @@ export const __Array_prototype_toReversed = (_this: any[]) => {
746
746
  let out: any[] = Porffor.allocate();
747
747
  out.length = len;
748
748
 
749
- while (start < end) {
749
+ while (true) {
750
750
  out[start] = _this[end];
751
+ if (start >= end) {
752
+ break;
753
+ }
751
754
  out[end--] = _this[start++];
752
755
  }
753
756
 
@@ -87,8 +87,41 @@ export const __RegExp_prototype_source$get = (_this: RegExp) => {
87
87
  return Porffor.wasm.i32.load(_this, 0, 0) as bytestring;
88
88
  };
89
89
 
90
+ // 22.2.6.4 get RegExp.prototype.flags
91
+ // https://tc39.es/ecma262/multipage/text-processing.html#sec-get-regexp.prototype.flags
90
92
  export const __RegExp_prototype_flags$get = (_this: RegExp) => {
91
- return Porffor.wasm.i32.load(_this, 0, 4) as bytestring;
93
+ // 1. Let R be the this value.
94
+ // 2. If R is not an Object, throw a TypeError exception.
95
+ if (!Porffor.object.isObject(_this)) throw new TypeError('This is a non-object');
96
+ let flags: i32 = Porffor.wasm.i32.load(_this, 0, 8);
97
+ // 3. Let codeUnits be a new empty List.
98
+ let result: bytestring = Porffor.allocateBytes(4 + 8);
99
+ // 4. Let hasIndices be ToBoolean(? Get(R, "hasIndices")).
100
+ // 5. If hasIndices is true, append the code unit 0x0064 (LATIN SMALL LETTER D) to codeUnits.
101
+ if (flags & 0b01000000) Porffor.bytestring.appendChar(result, 0x64);
102
+ // 6. Let global be ToBoolean(? Get(R, "global")).
103
+ // 7. If global is true, append the code unit 0x0067 (LATIN SMALL LETTER G) to codeUnits.
104
+ if (flags & 0b00000001) Porffor.bytestring.appendChar(result, 0x67);
105
+ // 8. Let ignoreCase be ToBoolean(? Get(R, "ignoreCase")).
106
+ // 9. If ignoreCase is true, append the code unit 0x0069 (LATIN SMALL LETTER I) to codeUnits.
107
+ if (flags & 0b00000010) Porffor.bytestring.appendChar(result, 0x69);
108
+ // 10. Let multiline be ToBoolean(? Get(R, "multiline")).
109
+ // 11. If multiline is true, append the code unit 0x006D (LATIN SMALL LETTER M) to codeUnits.
110
+ if (flags & 0b00000100) Porffor.bytestring.appendChar(result, 0x6d);
111
+ // 12. Let dotAll be ToBoolean(? Get(R, "dotAll")).
112
+ // 13. If dotAll is true, append the code unit 0x0073 (LATIN SMALL LETTER S) to codeUnits.
113
+ if (flags & 0b00001000) Porffor.bytestring.appendChar(result, 0x73);
114
+ // 14. Let unicode be ToBoolean(? Get(R, "unicode")).
115
+ // 15. If unicode is true, append the code unit 0x0075 (LATIN SMALL LETTER U) to codeUnits.
116
+ if (flags & 0b00010000) Porffor.bytestring.appendChar(result, 0x75);
117
+ // 16. Let unicodeSets be ToBoolean(? Get(R, "unicodeSets")).
118
+ // 17. If unicodeSets is true, append the code unit 0x0076 (LATIN SMALL LETTER V) to codeUnits.
119
+ if (flags & 0b10000000) Porffor.bytestring.appendChar(result, 0x76);
120
+ // 18. Let sticky be ToBoolean(? Get(R, "sticky")).
121
+ // 19. If sticky is true, append the code unit 0x0079 (LATIN SMALL LETTER Y) to codeUnits.
122
+ if (flags & 0b00100000) Porffor.bytestring.appendChar(result, 0x79);
123
+ // 20. Return the String value whose code units are the elements of the List codeUnits. If codeUnits has no elements, the empty String is returned.
124
+ return result;
92
125
  };
93
126
 
94
127
  export const __RegExp_prototype_global$get = (_this: RegExp) => {
@@ -80,6 +80,8 @@ export const __Symbol_prototype_valueOf = (_this: Symbol) => {
80
80
 
81
81
  const forStore: Map = new Map();
82
82
  export const __Symbol_for = (key: any): Symbol => {
83
+ key = ecma262.ToString(key);
84
+
83
85
  if (forStore.has(key)) return forStore.get(key);
84
86
 
85
87
  const out: Symbol = Symbol(key);