porffor 0.55.32 → 0.55.34

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.
@@ -11,7 +11,7 @@ export const Array = function (...args: any[]): any[] {
11
11
  if (argsLen == 1) {
12
12
  // 1 arg, length (number) or first element (non-number)
13
13
  const arg: any = args[0];
14
- if (Porffor.rawType(arg) == Porffor.TYPES.number) {
14
+ if (Porffor.type(arg) == Porffor.TYPES.number) {
15
15
  // number so use as length
16
16
  const n: number = args[0];
17
17
  if (Porffor.fastOr(
@@ -33,7 +33,7 @@ export const Array = function (...args: any[]): any[] {
33
33
  };
34
34
 
35
35
  export const __Array_isArray = (x: unknown): boolean =>
36
- Porffor.rawType(x) == Porffor.TYPES.array;
36
+ Porffor.type(x) == Porffor.TYPES.array;
37
37
 
38
38
  export const __Array_from = (arg: any, mapFn: any): any[] => {
39
39
  if (arg == null) throw new TypeError('Argument cannot be nullish');
@@ -41,7 +41,7 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
41
41
  let out: any[] = Porffor.allocate();
42
42
  let len: i32 = 0;
43
43
 
44
- const type = Porffor.rawType(arg);
44
+ const type = Porffor.type(arg);
45
45
  if (Porffor.fastOr(
46
46
  type == Porffor.TYPES.array,
47
47
  type == Porffor.TYPES.string, type == Porffor.TYPES.bytestring,
@@ -49,8 +49,8 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
49
49
  Porffor.fastAnd(type >= Porffor.TYPES.uint8array, type <= Porffor.TYPES.float64array)
50
50
  )) {
51
51
  let i: i32 = 0;
52
- if (Porffor.rawType(mapFn) != Porffor.TYPES.undefined) {
53
- if (Porffor.rawType(mapFn) != Porffor.TYPES.function) throw new TypeError('Called Array.from with a non-function mapFn');
52
+ if (Porffor.type(mapFn) != Porffor.TYPES.undefined) {
53
+ if (Porffor.type(mapFn) != Porffor.TYPES.function) throw new TypeError('Called Array.from with a non-function mapFn');
54
54
 
55
55
  for (const x of arg) {
56
56
  out[i] = mapFn(x, i);
@@ -66,8 +66,7 @@ export const __Array_from = (arg: any, mapFn: any): any[] => {
66
66
  }
67
67
 
68
68
  if (type == Porffor.TYPES.object) {
69
- const lengthKey: bytestring = 'length';
70
- len = ecma262.ToIntegerOrInfinity((arg as object)[lengthKey]);
69
+ len = ecma262.ToIntegerOrInfinity((arg as object)['length']);
71
70
  if (len > 4294967295) throw new RangeError('Invalid array length');
72
71
  if (len < 0) len = 0;
73
72
 
@@ -133,7 +132,7 @@ memory.copy 0 0`;
133
132
 
134
133
  export const __Array_prototype_slice = (_this: any[], _start: any, _end: any) => {
135
134
  const len: i32 = _this.length;
136
- if (Porffor.rawType(_end) == Porffor.TYPES.undefined) _end = len;
135
+ if (Porffor.type(_end) == Porffor.TYPES.undefined) _end = len;
137
136
 
138
137
  let start: i32 = ecma262.ToIntegerOrInfinity(_start);
139
138
  let end: i32 = ecma262.ToIntegerOrInfinity(_end);
@@ -182,7 +181,7 @@ export const __Array_prototype_splice = (_this: any[], _start: any, _deleteCount
182
181
  }
183
182
  if (start > len) start = len;
184
183
 
185
- if (Porffor.rawType(_deleteCount) == Porffor.TYPES.undefined) _deleteCount = len - start;
184
+ if (Porffor.type(_deleteCount) == Porffor.TYPES.undefined) _deleteCount = len - start;
186
185
  let deleteCount: i32 = ecma262.ToIntegerOrInfinity(_deleteCount);
187
186
 
188
187
  if (deleteCount < 0) deleteCount = 0;
@@ -273,8 +272,8 @@ memory.copy 0 0`;
273
272
  export const __Array_prototype_fill = (_this: any[], value: any, _start: any, _end: any) => {
274
273
  const len: i32 = _this.length;
275
274
 
276
- if (Porffor.rawType(_start) == Porffor.TYPES.undefined) _start = 0;
277
- if (Porffor.rawType(_end) == Porffor.TYPES.undefined) _end = len;
275
+ if (Porffor.type(_start) == Porffor.TYPES.undefined) _start = 0;
276
+ if (Porffor.type(_end) == Porffor.TYPES.undefined) _end = len;
278
277
 
279
278
  let start: i32 = ecma262.ToIntegerOrInfinity(_start);
280
279
  let end: i32 = ecma262.ToIntegerOrInfinity(_end);
@@ -393,7 +392,7 @@ export const __Array_prototype_copyWithin = (_this: any[], _target: any, _start:
393
392
  if (start > len) start = len;
394
393
 
395
394
  let end: i32;
396
- if (Porffor.rawType(_end) == Porffor.TYPES.undefined) {
395
+ if (Porffor.type(_end) == Porffor.TYPES.undefined) {
397
396
  end = len;
398
397
  } else {
399
398
  end = ecma262.ToIntegerOrInfinity(_end);
@@ -420,7 +419,7 @@ export const __Array_prototype_concat = (_this: any[], ...vals: any[]) => {
420
419
  let len: i32 = _this.length;
421
420
 
422
421
  for (const x of vals) {
423
- if (Porffor.rawType(x) & 0b01000000) { // value is iterable
422
+ if (Porffor.type(x) & 0b01000000) { // value is iterable
424
423
  // todo: for..of is broken here because ??
425
424
  const l: i32 = x.length;
426
425
  for (let i: i32 = 0; i < l; i++) {
@@ -498,7 +497,7 @@ export const __Array_prototype_flatMap = (_this: any[], callbackFn: any, thisArg
498
497
  let i: i32 = 0, j: i32 = 0;
499
498
  while (i < len) {
500
499
  let x: any = callbackFn.call(thisArg, _this[i], i++, _this);
501
- if (Porffor.rawType(x) == Porffor.TYPES.array) {
500
+ if (Porffor.type(x) == Porffor.TYPES.array) {
502
501
  for (const y of x) out[j++] = y;
503
502
  } else out[j++] = x;
504
503
  }
@@ -647,8 +646,8 @@ export const __Array_prototype_sort = (_this: any[], callbackFn: any) => {
647
646
 
648
647
  // 23.1.3.30.2 CompareArrayElements (x, y, comparefn)
649
648
  // https://tc39.es/ecma262/#sec-comparearrayelements
650
- const xt: i32 = Porffor.rawType(x);
651
- const yt: i32 = Porffor.rawType(y);
649
+ const xt: i32 = Porffor.type(x);
650
+ const yt: i32 = Porffor.type(y);
652
651
  let v: number;
653
652
 
654
653
  // 1. If x and y are both undefined, return +0𝔽.
@@ -691,7 +690,7 @@ export const __Array_prototype_toString = (_this: any[]) => {
691
690
  if (i > 0) Porffor.bytestring.appendChar(out, 44);
692
691
 
693
692
  const element: any = _this[i++];
694
- const type: i32 = Porffor.rawType(element);
693
+ const type: i32 = Porffor.type(element);
695
694
  if (element != 0 || Porffor.fastAnd(
696
695
  type != Porffor.TYPES.undefined, // undefined
697
696
  type != Porffor.TYPES.object // null
@@ -713,7 +712,7 @@ export const __Array_prototype_join = (_this: any[], _separator: any) => {
713
712
  // todo/perf: optimize default separator (?)
714
713
 
715
714
  let separator: bytestring = ',';
716
- if (Porffor.rawType(_separator) != Porffor.TYPES.undefined)
715
+ if (Porffor.type(_separator) != Porffor.TYPES.undefined)
717
716
  separator = ecma262.ToString(_separator);
718
717
 
719
718
  let out: bytestring = Porffor.allocate();
@@ -723,7 +722,7 @@ export const __Array_prototype_join = (_this: any[], _separator: any) => {
723
722
  if (i > 0) Porffor.bytestring.appendStr(out, separator);
724
723
 
725
724
  const element: any = _this[i++];
726
- const type: i32 = Porffor.rawType(element);
725
+ const type: i32 = Porffor.type(element);
727
726
  if (element != 0 || Porffor.fastAnd(
728
727
  type != Porffor.TYPES.undefined, // undefined
729
728
  type != Porffor.TYPES.object // null
@@ -781,7 +780,7 @@ export const __Array_prototype_toSpliced = (_this: any[], _start: any, _deleteCo
781
780
  }
782
781
  if (start > len) start = len;
783
782
 
784
- if (Porffor.rawType(_deleteCount) == Porffor.TYPES.undefined) _deleteCount = len - start;
783
+ if (Porffor.type(_deleteCount) == Porffor.TYPES.undefined) _deleteCount = len - start;
785
784
  let deleteCount: i32 = ecma262.ToIntegerOrInfinity(_deleteCount);
786
785
 
787
786
  if (deleteCount < 0) deleteCount = 0;
@@ -854,7 +853,7 @@ memory.copy 0 0`;
854
853
 
855
854
 
856
855
  export const __Array_prototype_flat = (_this: any[], _depth: any) => {
857
- if (Porffor.rawType(_depth) == Porffor.TYPES.undefined) _depth = 1;
856
+ if (Porffor.type(_depth) == Porffor.TYPES.undefined) _depth = 1;
858
857
  let depth: i32 = ecma262.ToIntegerOrInfinity(_depth);
859
858
 
860
859
  let out: any[] = Porffor.allocate();
@@ -867,7 +866,7 @@ export const __Array_prototype_flat = (_this: any[], _depth: any) => {
867
866
  let i: i32 = 0, j: i32 = 0;
868
867
  while (i < len) {
869
868
  let x: any = _this[i++];
870
- if (Porffor.rawType(x) == Porffor.TYPES.array) {
869
+ if (Porffor.type(x) == Porffor.TYPES.array) {
871
870
  if (depth > 1) x = __Array_prototype_flat(x, depth - 1);
872
871
  for (const y of x) out[j++] = y;
873
872
  } else out[j++] = x;
@@ -1,7 +1,7 @@
1
1
  import type {} from './porffor.d.ts';
2
2
 
3
3
  export const __ArrayBuffer_isView = (value: any): boolean => {
4
- const t: i32 = Porffor.rawType(value);
4
+ const t: i32 = Porffor.type(value);
5
5
  if (Porffor.fastOr(
6
6
  t == Porffor.TYPES.dataview,
7
7
  Porffor.fastAnd(t >= Porffor.TYPES.uint8array, t <= Porffor.TYPES.float64array)
@@ -84,7 +84,7 @@ export const __ArrayBuffer_prototype_slice = (_this: ArrayBuffer, start: any, en
84
84
  if (_this.detached) throw new TypeError('Called ArrayBuffer.prototype.slice on a detached ArrayBuffer');
85
85
 
86
86
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
87
- if (Porffor.rawType(end) == Porffor.TYPES.undefined) end = len;
87
+ if (Porffor.type(end) == Porffor.TYPES.undefined) end = len;
88
88
 
89
89
  start = ecma262.ToIntegerOrInfinity(start);
90
90
  end = ecma262.ToIntegerOrInfinity(end);
@@ -136,7 +136,7 @@ export const __ArrayBuffer_prototype_transfer = (_this: ArrayBuffer, newLength:
136
136
  if (_this.detached) throw new TypeError('Called ArrayBuffer.prototype.transfer on a detached ArrayBuffer');
137
137
 
138
138
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
139
- if (Porffor.rawType(newLength) == Porffor.TYPES.undefined) newLength = len;
139
+ if (Porffor.type(newLength) == Porffor.TYPES.undefined) newLength = len;
140
140
 
141
141
  // make new arraybuffer
142
142
  const out: ArrayBuffer = new ArrayBuffer(newLength);
@@ -208,7 +208,7 @@ export const __SharedArrayBuffer_prototype_growable$get = (_this: SharedArrayBuf
208
208
 
209
209
  export const __SharedArrayBuffer_prototype_slice = (_this: SharedArrayBuffer, start: any, end: any) => {
210
210
  const len: i32 = Porffor.wasm.i32.load(_this, 0, 0);
211
- if (Porffor.rawType(end) == Porffor.TYPES.undefined) end = len;
211
+ if (Porffor.type(end) == Porffor.TYPES.undefined) end = len;
212
212
 
213
213
  start = ecma262.ToIntegerOrInfinity(start);
214
214
  end = ecma262.ToIntegerOrInfinity(end);
@@ -280,16 +280,16 @@ export const __ecma262_ToBigInt = (argument: any): bigint => {
280
280
  // Table 12: BigInt Conversions
281
281
  // Argument Type Result
282
282
  // BigInt Return prim.
283
- if (Porffor.rawType(prim) == Porffor.TYPES.bigint) return prim;
283
+ if (Porffor.type(prim) == Porffor.TYPES.bigint) return prim;
284
284
 
285
285
  // String
286
286
  // 1. Let n be StringToBigInt(prim).
287
287
  // 2. If n is undefined, throw a SyntaxError exception.
288
288
  // 3. Return n.
289
- if ((Porffor.rawType(prim) | 0b10000000) == Porffor.TYPES.bytestring) return __Porffor_bigint_fromString(prim);
289
+ if ((Porffor.type(prim) | 0b10000000) == Porffor.TYPES.bytestring) return __Porffor_bigint_fromString(prim);
290
290
 
291
291
  // Boolean Return 1n if prim is true and 0n if prim is false.
292
- if (Porffor.rawType(prim) == Porffor.TYPES.boolean) return prim ? 1n : 0n;
292
+ if (Porffor.type(prim) == Porffor.TYPES.boolean) return prim ? 1n : 0n;
293
293
 
294
294
  // Number Throw a TypeError exception.
295
295
  // Symbol Throw a TypeError exception.
@@ -306,7 +306,7 @@ export const BigInt = (value: any): bigint => {
306
306
  const prim: any = ecma262.ToPrimitive.Number(value);
307
307
 
308
308
  // 3. If prim is a Number, return ? NumberToBigInt(prim).
309
- if (Porffor.rawType(prim) == Porffor.TYPES.number) return __Porffor_bigint_fromNumber(prim);
309
+ if (Porffor.type(prim) == Porffor.TYPES.number) return __Porffor_bigint_fromNumber(prim);
310
310
 
311
311
  // 4. Otherwise, return ? ToBigInt(prim).
312
312
  return __ecma262_ToBigInt(prim);
@@ -2,7 +2,7 @@ import type {} from './porffor.d.ts';
2
2
 
3
3
  export const __Porffor_printString = (arg: bytestring|string) => {
4
4
  let ptr: i32 = Porffor.wasm`local.get ${arg}`;
5
- if (Porffor.rawType(arg) == Porffor.TYPES.bytestring) {
5
+ if (Porffor.type(arg) == Porffor.TYPES.bytestring) {
6
6
  const end: i32 = ptr + arg.length;
7
7
  while (ptr < end) {
8
8
  printChar(Porffor.wasm.i32.load8_u(ptr++, 0, 4));
@@ -35,7 +35,7 @@ export const __Porffor_numberLog = (arg: number) => {
35
35
  };
36
36
 
37
37
  export const __Porffor_miniLog = (arg: any) => {
38
- switch (Porffor.rawType(arg)) {
38
+ switch (Porffor.type(arg)) {
39
39
  case Porffor.TYPES.number:
40
40
  print(arg);
41
41
  break;
@@ -111,7 +111,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
111
111
  }
112
112
  };
113
113
 
114
- switch (Porffor.rawType(arg)) {
114
+ switch (Porffor.type(arg)) {
115
115
  case Porffor.TYPES.number:
116
116
  if (colors) Porffor.printStatic('\x1b[33m'); // yellow
117
117
  print(arg);
@@ -248,7 +248,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
248
248
 
249
249
  case Porffor.TYPES.sharedarraybuffer:
250
250
  case Porffor.TYPES.arraybuffer:
251
- if (Porffor.rawType(arg) == Porffor.TYPES.sharedarraybuffer) Porffor.printStatic('SharedArrayBuffer');
251
+ if (Porffor.type(arg) == Porffor.TYPES.sharedarraybuffer) Porffor.printStatic('SharedArrayBuffer');
252
252
  else Porffor.printStatic('ArrayBuffer');
253
253
  Porffor.printStatic(' {\n');
254
254
 
@@ -286,7 +286,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
286
286
 
287
287
  case Porffor.TYPES.weakmap:
288
288
  case Porffor.TYPES.map:
289
- if (Porffor.rawType(arg) == Porffor.TYPES.weakmap) Porffor.printStatic('WeakMap');
289
+ if (Porffor.type(arg) == Porffor.TYPES.weakmap) Porffor.printStatic('WeakMap');
290
290
  else Porffor.printStatic('Map');
291
291
  Porffor.printStatic('(');
292
292
 
@@ -308,7 +308,7 @@ export const __Porffor_print = (arg: any, colors: boolean = true, depth: number
308
308
 
309
309
  case Porffor.TYPES.weakset:
310
310
  case Porffor.TYPES.set:
311
- if (Porffor.rawType(arg) == Porffor.TYPES.weakset) Porffor.printStatic('WeakSet');
311
+ if (Porffor.type(arg) == Porffor.TYPES.weakset) Porffor.printStatic('WeakSet');
312
312
  else Porffor.printStatic('Set');
313
313
  Porffor.printStatic('(');
314
314
 
@@ -351,7 +351,7 @@ export const __console_clear = () => {
351
351
  };
352
352
 
353
353
  export const __Porffor_consolePrint = (arg: any) => {
354
- if (Porffor.fastOr(Porffor.rawType(arg) == Porffor.TYPES.bytestring, Porffor.rawType(arg) == Porffor.TYPES.string)) {
354
+ if (Porffor.fastOr(Porffor.type(arg) == Porffor.TYPES.bytestring, Porffor.type(arg) == Porffor.TYPES.string)) {
355
355
  __Porffor_printString(arg);
356
356
  return;
357
357
  }
@@ -359,7 +359,7 @@ export const __Porffor_consolePrint = (arg: any) => {
359
359
  };
360
360
 
361
361
  export const __console_group = (label: bytestring) => {
362
- if (Porffor.rawType(label) != Porffor.TYPES.undefined) {
362
+ if (Porffor.type(label) != Porffor.TYPES.undefined) {
363
363
  __Porffor_consoleIndent();
364
364
  __Porffor_consolePrint(label);
365
365
  }
@@ -453,7 +453,7 @@ export const __console_assert = (assertion: any, ...args: any[]) => {
453
453
  };
454
454
 
455
455
  export const __Porffor_dirObject = (obj: any, colors: boolean, depth: i32, showHidden: boolean) => {
456
- if (Porffor.rawType(obj) != Porffor.TYPES.object || depth == 0) {
456
+ if (Porffor.type(obj) != Porffor.TYPES.object || depth == 0) {
457
457
  __Porffor_print(obj, colors);
458
458
  return;
459
459
  }
@@ -9,7 +9,7 @@ export const DataView = function (arg: any, byteOffset: any, length: any): DataV
9
9
  let len: i32 = 0;
10
10
  let bufferPtr: i32;
11
11
 
12
- const type: i32 = Porffor.rawType(arg);
12
+ const type: i32 = Porffor.type(arg);
13
13
  if (Porffor.fastOr(
14
14
  type == Porffor.TYPES.arraybuffer,
15
15
  type == Porffor.TYPES.sharedarraybuffer
@@ -19,13 +19,13 @@ export const DataView = function (arg: any, byteOffset: any, length: any): DataV
19
19
  if (arg.detached) throw new TypeError('Constructed DataView with a detached ArrayBuffer');
20
20
 
21
21
  let offset: i32 = 0;
22
- if (Porffor.rawType(byteOffset) != Porffor.TYPES.undefined) offset = Math.trunc(byteOffset);
22
+ if (Porffor.type(byteOffset) != Porffor.TYPES.undefined) offset = Math.trunc(byteOffset);
23
23
  if (offset < 0) throw new RangeError('Invalid DataView byte offset (negative)');
24
24
 
25
25
  Porffor.wasm.i32.store(outPtr, offset, 0, 8);
26
26
  Porffor.wasm.i32.store(outPtr, bufferPtr + offset, 0, 4);
27
27
 
28
- if (Porffor.rawType(length) == Porffor.TYPES.undefined) {
28
+ if (Porffor.type(length) == Porffor.TYPES.undefined) {
29
29
  const bufferLen: i32 = Porffor.wasm.i32.load(bufferPtr, 0, 0);
30
30
  len = bufferLen - byteOffset;
31
31
  } else len = Math.trunc(length);
@@ -372,27 +372,27 @@ export const __Date_UTC = (year: unknown, month: unknown, date: unknown, hours:
372
372
 
373
373
  // 2. If month is present, let m be ? ToNumber(month); else let m be +0𝔽.
374
374
  let m: number = 0;
375
- if (Porffor.rawType(month) != Porffor.TYPES.undefined) m = ecma262.ToNumber(month);
375
+ if (Porffor.type(month) != Porffor.TYPES.undefined) m = ecma262.ToNumber(month);
376
376
 
377
377
  // 3. If date is present, let dt be ? ToNumber(date); else let dt be 1𝔽.
378
378
  let dt: number = 1;
379
- if (Porffor.rawType(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
379
+ if (Porffor.type(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
380
380
 
381
381
  // 4. If hours is present, let h be ? ToNumber(hours); else let h be +0𝔽.
382
382
  let h: number = 0;
383
- if (Porffor.rawType(hours) != Porffor.TYPES.undefined) h = ecma262.ToNumber(hours);
383
+ if (Porffor.type(hours) != Porffor.TYPES.undefined) h = ecma262.ToNumber(hours);
384
384
 
385
385
  // 5. If minutes is present, let min be ? ToNumber(minutes); else let min be +0𝔽.
386
386
  let min: number = 0;
387
- if (Porffor.rawType(minutes) != Porffor.TYPES.undefined) min = ecma262.ToNumber(minutes);
387
+ if (Porffor.type(minutes) != Porffor.TYPES.undefined) min = ecma262.ToNumber(minutes);
388
388
 
389
389
  // 6. If seconds is present, let s be ? ToNumber(seconds); else let s be +0𝔽.
390
390
  let s: number = 0;
391
- if (Porffor.rawType(seconds) != Porffor.TYPES.undefined) s = ecma262.ToNumber(seconds);
391
+ if (Porffor.type(seconds) != Porffor.TYPES.undefined) s = ecma262.ToNumber(seconds);
392
392
 
393
393
  // 7. If ms is present, let milli be ? ToNumber(ms); else let milli be +0𝔽.
394
394
  let milli: number = 0;
395
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) h = ecma262.ToNumber(ms);
395
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) h = ecma262.ToNumber(ms);
396
396
 
397
397
  // 8. Let yr be MakeFullYear(y).
398
398
  const yr: number = __ecma262_MakeFullYear(y);
@@ -413,10 +413,8 @@ export const __ecma262_WeekDayName = (tv: number): bytestring => {
413
413
  // 4𝔽 "Thu"
414
414
  // 5𝔽 "Fri"
415
415
  // 6𝔽 "Sat"
416
-
417
- const weekday: number = __ecma262_WeekDay(tv);
418
-
419
416
  const lut: bytestring = 'SunMonTueWedThuFriSat';
417
+ const weekday: number = __ecma262_WeekDay(tv);
420
418
 
421
419
  let out: bytestring = Porffor.allocateBytes(7);
422
420
  out.length = 3;
@@ -447,10 +445,8 @@ export const __ecma262_MonthName = (tv: number): bytestring => {
447
445
  // 9𝔽 "Oct"
448
446
  // 10𝔽 "Nov"
449
447
  // 11𝔽 "Dec"
450
-
451
- const month: number = __ecma262_MonthFromTime(tv);
452
-
453
448
  const lut: bytestring = 'JanFebMarAprMayJunJulAugSepOctNovDec';
449
+ const month: number = __ecma262_MonthFromTime(tv);
454
450
 
455
451
  let out: bytestring = Porffor.allocateBytes(7);
456
452
  out.length = 3;
@@ -1015,12 +1011,12 @@ export const __Date_prototype_setFullYear = (_this: Date, year: any, month: any,
1015
1011
 
1016
1012
  // 6. If month is not present, let m be MonthFromTime(t); otherwise, let m be ? ToNumber(month).
1017
1013
  let m: number;
1018
- if (Porffor.rawType(month) == Porffor.TYPES.undefined) m = __ecma262_MonthFromTime(t);
1014
+ if (Porffor.type(month) == Porffor.TYPES.undefined) m = __ecma262_MonthFromTime(t);
1019
1015
  else m = ecma262.ToNumber(month);
1020
1016
 
1021
1017
  // 7. If date is not present, let dt be DateFromTime(t); otherwise, let dt be ? ToNumber(date).
1022
1018
  let dt: number;
1023
- if (Porffor.rawType(date) == Porffor.TYPES.undefined) dt = __ecma262_DateFromTime(t);
1019
+ if (Porffor.type(date) == Porffor.TYPES.undefined) dt = __ecma262_DateFromTime(t);
1024
1020
  else dt = ecma262.ToNumber(date);
1025
1021
 
1026
1022
  // 8. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
@@ -1057,19 +1053,19 @@ export const __Date_prototype_setHours = (_this: Date, hour: any, min: any, sec:
1057
1053
 
1058
1054
  // 5. If min is present, let m be ? ToNumber(min).
1059
1055
  let m: number;
1060
- if (Porffor.rawType(min) != Porffor.TYPES.undefined) m = ecma262.ToNumber(min);
1056
+ if (Porffor.type(min) != Porffor.TYPES.undefined) m = ecma262.ToNumber(min);
1061
1057
  // 10. If min is not present, let m be MinFromTime(t).
1062
1058
  else m = __ecma262_MinFromTime(t);
1063
1059
 
1064
1060
  // 6. If sec is present, let s be ? ToNumber(sec).
1065
1061
  let s: number;
1066
- if (Porffor.rawType(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1062
+ if (Porffor.type(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1067
1063
  // 11. If sec is not present, let s be SecFromTime(t).
1068
1064
  else s = __ecma262_SecFromTime(t);
1069
1065
 
1070
1066
  // 7. If ms is present, let milli be ? ToNumber(ms).
1071
1067
  let milli: number;
1072
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1068
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1073
1069
  // 12. If ms is not present, let milli be msFromTime(t).
1074
1070
  else milli = __ecma262_msFromTime(t);
1075
1071
 
@@ -1138,13 +1134,13 @@ export const __Date_prototype_setMinutes = (_this: Date, min: any, sec: any, ms:
1138
1134
 
1139
1135
  // 5. If sec is present, let s be ? ToNumber(sec).
1140
1136
  let s: number;
1141
- if (Porffor.rawType(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1137
+ if (Porffor.type(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1142
1138
  // 9. If sec is not present, let s be SecFromTime(t).
1143
1139
  else s = __ecma262_SecFromTime(t);
1144
1140
 
1145
1141
  // 6. If ms is present, let milli be ? ToNumber(ms).
1146
1142
  let milli: number;
1147
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1143
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1148
1144
  // 10. If ms is not present, let milli be msFromTime(t).
1149
1145
  else milli = __ecma262_msFromTime(t);
1150
1146
 
@@ -1182,7 +1178,7 @@ export const __Date_prototype_setMonth = (_this: Date, month: any, date: any) =>
1182
1178
 
1183
1179
  // 5. If date is present, let dt be ? ToNumber(date).
1184
1180
  let dt: number;
1185
- if (Porffor.rawType(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
1181
+ if (Porffor.type(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
1186
1182
  // 8. If date is not present, let dt be DateFromTime(t).
1187
1183
  else dt = __ecma262_DateFromTime(t);
1188
1184
 
@@ -1220,7 +1216,7 @@ export const __Date_prototype_setSeconds = (_this: Date, sec: any, ms: any) => {
1220
1216
 
1221
1217
  // 5. If ms is present, let milli be ? ToNumber(ms).
1222
1218
  let milli: number;
1223
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1219
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1224
1220
  // 8. If ms is not present, let milli be msFromTime(t).
1225
1221
  else milli = __ecma262_msFromTime(t);
1226
1222
 
@@ -1299,12 +1295,12 @@ export const __Date_prototype_setUTCFullYear = (_this: Date, year: any, month: a
1299
1295
 
1300
1296
  // 6. If month is not present, let m be MonthFromTime(t); otherwise, let m be ? ToNumber(month).
1301
1297
  let m: number;
1302
- if (Porffor.rawType(month) == Porffor.TYPES.undefined) m = __ecma262_MonthFromTime(t);
1298
+ if (Porffor.type(month) == Porffor.TYPES.undefined) m = __ecma262_MonthFromTime(t);
1303
1299
  else m = ecma262.ToNumber(month);
1304
1300
 
1305
1301
  // 7. If date is not present, let dt be DateFromTime(t); otherwise, let dt be ? ToNumber(date).
1306
1302
  let dt: number;
1307
- if (Porffor.rawType(date) == Porffor.TYPES.undefined) dt = __ecma262_DateFromTime(t);
1303
+ if (Porffor.type(date) == Porffor.TYPES.undefined) dt = __ecma262_DateFromTime(t);
1308
1304
  else dt = ecma262.ToNumber(date);
1309
1305
 
1310
1306
  // 8. Let newDate be MakeDate(MakeDay(y, m, dt), TimeWithinDay(t)).
@@ -1338,19 +1334,19 @@ export const __Date_prototype_setUTCHours = (_this: Date, hour: any, min: any, s
1338
1334
 
1339
1335
  // 5. If min is present, let m be ? ToNumber(min).
1340
1336
  let m: number;
1341
- if (Porffor.rawType(min) != Porffor.TYPES.undefined) m = ecma262.ToNumber(min);
1337
+ if (Porffor.type(min) != Porffor.TYPES.undefined) m = ecma262.ToNumber(min);
1342
1338
  // 9. If min is not present, let m be MinFromTime(t).
1343
1339
  else m = __ecma262_MinFromTime(t);
1344
1340
 
1345
1341
  // 6. If sec is present, let s be ? ToNumber(sec).
1346
1342
  let s: number;
1347
- if (Porffor.rawType(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1343
+ if (Porffor.type(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1348
1344
  // 10. If sec is not present, let s be SecFromTime(t).
1349
1345
  else s = __ecma262_SecFromTime(t);
1350
1346
 
1351
1347
  // 7. If ms is present, let milli be ? ToNumber(ms).
1352
1348
  let milli: number;
1353
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1349
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1354
1350
  // 11. If ms is not present, let milli be msFromTime(t).
1355
1351
  else milli = __ecma262_msFromTime(t);
1356
1352
 
@@ -1413,13 +1409,13 @@ export const __Date_prototype_setUTCMinutes = (_this: Date, min: any, sec: any,
1413
1409
 
1414
1410
  // 5. If sec is present, let s be ? ToNumber(sec).
1415
1411
  let s: number;
1416
- if (Porffor.rawType(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1412
+ if (Porffor.type(sec) != Porffor.TYPES.undefined) s = ecma262.ToNumber(sec);
1417
1413
  // 8. If sec is not present, let s be SecFromTime(t).
1418
1414
  else s = __ecma262_SecFromTime(t);
1419
1415
 
1420
1416
  // 6. If ms is present, let milli be ? ToNumber(ms).
1421
1417
  let milli: number;
1422
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1418
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1423
1419
  // 9. If ms is not present, let milli be msFromTime(t).
1424
1420
  else milli = __ecma262_msFromTime(t);
1425
1421
 
@@ -1454,7 +1450,7 @@ export const __Date_prototype_setUTCMonth = (_this: Date, month: any, date: any)
1454
1450
 
1455
1451
  // 5. If date is present, let dt be ? ToNumber(date).
1456
1452
  let dt: number;
1457
- if (Porffor.rawType(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
1453
+ if (Porffor.type(date) != Porffor.TYPES.undefined) dt = ecma262.ToNumber(date);
1458
1454
  // 7. If date is not present, let dt be DateFromTime(t).
1459
1455
  else dt = __ecma262_DateFromTime(t);
1460
1456
 
@@ -1489,7 +1485,7 @@ export const __Date_prototype_setUTCSeconds = (_this: Date, sec: any, ms: any) =
1489
1485
 
1490
1486
  // 5. If ms is present, let milli be ? ToNumber(ms).
1491
1487
  let milli: number;
1492
- if (Porffor.rawType(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1488
+ if (Porffor.type(ms) != Porffor.TYPES.undefined) milli = ecma262.ToNumber(ms);
1493
1489
  // 7. If ms is not present, let milli be msFromTime(t).
1494
1490
  else milli = __ecma262_msFromTime(t);
1495
1491
 
@@ -1746,13 +1742,13 @@ export const __ecma262_TimeZoneString = (tv: number) => {
1746
1742
  // https://tc39.es/ecma262/multipage/numbers-and-dates.html#sec-todatestring
1747
1743
  export const __ecma262_ToDateString = (tv: number) => {
1748
1744
  // 1. If tv is NaN, return "Invalid Date".
1749
- let out: bytestring = Porffor.allocateBytes(44);
1750
- if (Number.isNaN(tv)) return out = 'Invalid Date';
1745
+ if (Number.isNaN(tv)) return 'Invalid Date';
1751
1746
 
1752
1747
  // 2. Let t be LocalTime(tv).
1753
1748
  const t: number = __ecma262_LocalTime(tv);
1754
1749
 
1755
1750
  // 3. Return the string-concatenation of DateString(t), the code unit 0x0020 (SPACE), TimeString(t), and TimeZoneString(tv).
1751
+ const out: bytestring = Porffor.allocateBytes(44);
1756
1752
  __Porffor_bytestring_appendStr(out, __ecma262_DateString(t));
1757
1753
  __Porffor_bytestring_appendChar(out, 32);
1758
1754
 
@@ -1784,13 +1780,13 @@ export const __Date_prototype_toTimeString = (_this: Date) => {
1784
1780
  const tv: number = __Porffor_date_read(_this);
1785
1781
 
1786
1782
  // 4. If tv is NaN, return "Invalid Date".
1787
- let out: bytestring = Porffor.allocateBytes(27);
1788
- if (Number.isNaN(tv)) return out = 'Invalid Date';
1783
+ if (Number.isNaN(tv)) return 'Invalid Date';
1789
1784
 
1790
1785
  // 5. Let t be LocalTime(tv).
1791
1786
  const t: number = __ecma262_LocalTime(tv);
1792
1787
 
1793
1788
  // 6. Return the string-concatenation of TimeString(t) and TimeZoneString(tv).
1789
+ const out: bytestring = Porffor.allocateBytes(27);
1794
1790
  __Porffor_bytestring_appendStr(out, __ecma262_TimeString(t));
1795
1791
  __Porffor_bytestring_appendStr(out, __ecma262_TimeZoneString(tv));
1796
1792
 
@@ -1807,15 +1803,13 @@ export const __Date_prototype_toDateString = (_this: Date) => {
1807
1803
  const tv: number = __Porffor_date_read(_this);
1808
1804
 
1809
1805
  // 4. If tv is NaN, return "Invalid Date".
1810
- let out: bytestring = Porffor.allocateBytes(20);
1811
- if (Number.isNaN(tv)) return out = 'Invalid Date';
1806
+ if (Number.isNaN(tv)) return 'Invalid Date';
1812
1807
 
1813
1808
  // 5. Let t be LocalTime(tv).
1814
1809
  const t: number = __ecma262_LocalTime(tv);
1815
1810
 
1816
1811
  // 6. Return DateString(t).
1817
- out = __ecma262_DateString(t);
1818
- return out;
1812
+ return __ecma262_DateString(t);
1819
1813
  };
1820
1814
 
1821
1815
  // 21.4.4.43 Date.prototype.toUTCString ()
@@ -1827,11 +1821,7 @@ export const __Date_prototype_toUTCString = (_this: Date) => {
1827
1821
  const tv: number = __Porffor_date_read(_this);
1828
1822
 
1829
1823
  // 4. If tv is NaN, return "Invalid Date".
1830
- let out: bytestring = Porffor.allocateBytes(34);
1831
- if (Number.isNaN(tv)) {
1832
- out = 'Invalid Date';
1833
- return out;
1834
- }
1824
+ if (Number.isNaN(tv)) return 'Invalid Date';
1835
1825
 
1836
1826
  // 5. Let weekday be the Name of the entry in Table 62 with the Number WeekDay(tv).
1837
1827
  const weekday: bytestring = __ecma262_WeekDayName(tv);
@@ -1847,7 +1837,11 @@ export const __Date_prototype_toUTCString = (_this: Date) => {
1847
1837
 
1848
1838
  // 9. If yv is +0𝔽 or yv > +0𝔽, let yearSign be the empty String; otherwise, let yearSign be "-".
1849
1839
  // 10. Let paddedYear be ToZeroPaddedDecimalString(abs(ℝ(yv)), 4).
1850
- // 11. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE), day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE), yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).
1840
+ // 11. Return the string-concatenation of weekday, ",", the code unit 0x0020 (SPACE),
1841
+ // day, the code unit 0x0020 (SPACE), month, the code unit 0x0020 (SPACE),
1842
+ // yearSign, paddedYear, the code unit 0x0020 (SPACE), and TimeString(tv).
1843
+ const out: bytestring = Porffor.allocateBytes(34);
1844
+
1851
1845
  // weekday
1852
1846
  __Porffor_bytestring_appendStr(out, weekday);
1853
1847
  __Porffor_bytestring_appendChar(out, 44); // ','
@@ -1913,13 +1907,13 @@ export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown
1913
1907
  // 2. Let numberOfArgs be the number of elements in values.
1914
1908
  // sorry.
1915
1909
  const numberOfArgs: i32 =
1916
- (Porffor.rawType(v0) != Porffor.TYPES.undefined) +
1917
- (Porffor.rawType(v1) != Porffor.TYPES.undefined) +
1918
- (Porffor.rawType(v2) != Porffor.TYPES.undefined) +
1919
- (Porffor.rawType(v3) != Porffor.TYPES.undefined) +
1920
- (Porffor.rawType(v4) != Porffor.TYPES.undefined) +
1921
- (Porffor.rawType(v5) != Porffor.TYPES.undefined) +
1922
- (Porffor.rawType(v6) != Porffor.TYPES.undefined);
1910
+ (Porffor.type(v0) != Porffor.TYPES.undefined) +
1911
+ (Porffor.type(v1) != Porffor.TYPES.undefined) +
1912
+ (Porffor.type(v2) != Porffor.TYPES.undefined) +
1913
+ (Porffor.type(v3) != Porffor.TYPES.undefined) +
1914
+ (Porffor.type(v4) != Porffor.TYPES.undefined) +
1915
+ (Porffor.type(v5) != Porffor.TYPES.undefined) +
1916
+ (Porffor.type(v6) != Porffor.TYPES.undefined);
1923
1917
 
1924
1918
  let dv: number = 0;
1925
1919
 
@@ -1932,7 +1926,7 @@ export const Date = function (v0: unknown, v1: unknown, v2: unknown, v3: unknown
1932
1926
  // a. Let value be values[0].
1933
1927
  const value: any = v0;
1934
1928
 
1935
- const valueType: i32 = Porffor.rawType(v0);
1929
+ const valueType: i32 = Porffor.type(v0);
1936
1930
 
1937
1931
  let tv: number = 0;
1938
1932
 
@@ -43,7 +43,7 @@ export const __Test262Error_thrower = message => {
43
43
  throw new Test262Error(message);
44
44
  };
45
45
 
46
- export const __Error_isError = (x: unknown): boolean => Porffor.fastOr(${errors.map(x => `Porffor.rawType(x) == Porffor.TYPES.${x.toLowerCase()}`).join(', ')});`;
46
+ export const __Error_isError = (x: unknown): boolean => Porffor.fastOr(${errors.map(x => `Porffor.type(x) == Porffor.TYPES.${x.toLowerCase()}`).join(', ')});`;
47
47
 
48
48
  return out;
49
49
  };