porffor 0.24.5 → 0.24.6

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.
@@ -1,5 +1,12 @@
1
1
  import type {} from './porffor.d.ts';
2
2
 
3
+ export const Number = function (argument: any): any {
4
+ // todo: actually do prim objects
5
+ new.target; // trick compiler into allowing as constructor
6
+
7
+ return ecma262.ToNumeric(argument);
8
+ };
9
+
3
10
  // radix: number|any for rawType check
4
11
  export const __Number_prototype_toString = (_this: number, radix: number|any) => {
5
12
  let out: bytestring = Porffor.allocate();
@@ -82,6 +82,7 @@ declare global {
82
82
  ToIntegerOrInfinity(argument: unknown): number;
83
83
  ToString(argument: unknown): bytestring;
84
84
  ToNumber(argument: unknown): number;
85
+ ToNumeric(argument: unknown): number;
85
86
  ToPropertyKey(argument: unknown): any;
86
87
  }
87
88
 
@@ -13,7 +13,7 @@ export const __ecma262_StringToNumber = (str: unknown): number => {
13
13
  export const __ecma262_ToNumber = (argument: unknown): number => {
14
14
  const t: i32 = Porffor.rawType(argument);
15
15
 
16
- // If argument is a Number, return argument.
16
+ // 1. If argument is a Number, return argument.
17
17
  if (t == Porffor.TYPES.number) return argument;
18
18
 
19
19
  // 2. If argument is either a Symbol or a BigInt, throw a TypeError exception.
@@ -51,6 +51,20 @@ export const __ecma262_ToNumber = (argument: unknown): number => {
51
51
  return NaN;
52
52
  };
53
53
 
54
+
55
+ // 7.1.3 ToNumeric (value)
56
+ // https://tc39.es/ecma262/#sec-tonumeric
57
+ export const __ecma262_ToNumeric = (value: unknown): number => {
58
+ // 1. Let primValue be ? ToPrimitive(value, number).
59
+ // we do not have ToPrimitive
60
+
61
+ // 2. If primValue is a BigInt, return primValue.
62
+ // todo: do this when we have bigints
63
+
64
+ // 3. Return ? ToNumber(primValue).
65
+ return __ecma262_ToNumber(value);
66
+ };
67
+
54
68
  // 7.1.5 ToIntegerOrInfinity (argument)
55
69
  // https://tc39.es/ecma262/#sec-tointegerorinfinity
56
70
  export const __ecma262_ToIntegerOrInfinity = (argument: unknown): number => {
@@ -215,19 +215,6 @@ export const BuiltinFuncs = function() {
215
215
  };
216
216
  }
217
217
 
218
-
219
- // just echo given for now, for type constructors
220
- this.Number = {
221
- params: [ valtypeBinary ],
222
- locals: [],
223
- returns: [ valtypeBinary ],
224
- returnType: TYPES.number,
225
- wasm: [
226
- [ Opcodes.local_get, 0 ]
227
- ],
228
- constr: true
229
- };
230
-
231
218
  this.isNaN = {
232
219
  floatOnly: true,
233
220
  params: [ valtypeBinary ],
@@ -1647,6 +1647,13 @@ export const BuiltinFuncs = function() {
1647
1647
  returns: [124,127], typedReturns: 1,
1648
1648
  locals: [124,127,127], localNames: ["y","y#type","x","x#type","ratio","ratio#type","#last_type"],
1649
1649
  };
1650
+ this.Number = {
1651
+ wasm: (scope, {builtin}) => [[32,-1],[184],[65,2],[33,2],[26],[32,0],[32,1],[16, ...builtin('__ecma262_ToNumber')],[34,2],[15]],
1652
+ params: [124,127], typedParams: 1,
1653
+ returns: [124,127], typedReturns: 1,
1654
+ locals: [127], localNames: ["argument","argument#type","#last_type"],
1655
+ constr: 1,
1656
+ };
1650
1657
  this.__Number_prototype_toString = {
1651
1658
  wasm: (scope, {allocPage,builtin,internalThrow}) => [[16, ...builtin('__Porffor_allocate')],[183],[34,4],[33,5],[32,0],[16, ...builtin('__Number_isFinite')],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,0],[16, ...builtin('__Number_isNaN')],[252,3],[4,64],...number(allocPage(scope, 'bytestring: __Number_prototype_toString/out', 'i8') * pageSize, 124),[34,4],[65,195,1],[15],[11],[32,0],[68,0,0,0,0,0,0,240,127],[97],[4,64],[32,4],[252,3],[34,6],[65,8],[54,1,0],[32,6],[65,201,0],[58,0,4],[32,6],[65,238,0],[58,0,5],[32,6],[65,230,0],[58,0,6],[32,6],[65,233,0],[58,0,7],[32,6],[65,238,0],[58,0,8],[32,6],[65,233,0],[58,0,9],[32,6],[65,244,0],[58,0,10],[32,6],[65,249,0],[58,0,11],[32,6],[184],[34,4],[65,195,1],[15],[11],[32,4],[252,3],[34,6],[65,9],[54,1,0],[32,6],[65,45],[58,0,4],[32,6],[65,201,0],[58,0,5],[32,6],[65,238,0],[58,0,6],[32,6],[65,230,0],[58,0,7],[32,6],[65,233,0],[58,0,8],[32,6],[65,238,0],[58,0,9],[32,6],[65,233,0],[58,0,10],[32,6],[65,244,0],[58,0,11],[32,6],[65,249,0],[58,0,12],[32,6],[184],[34,4],[65,195,1],[15],[11],[32,2],[32,3],[16, ...builtin('__Porffor_rawType')],[68,0,0,0,0,0,0,240,63],[98],[4,64],[68,0,0,0,0,0,0,36,64],[34,2],[65,1],[33,3],[26],[11],[32,2],[68,0,0,0,0,0,0,0,0],[16, ...builtin('f64_|')],[34,2],[65,1],[33,3],[26],[32,2],[68,0,0,0,0,0,0,0,64],[99],[34,7],[69],[4,127],[32,2],[68,0,0,0,0,0,0,66,64],[100],[65,2],[33,8],[5],[32,7],[65,2],[33,8],[11],[4,64],...internalThrow(scope, 'RangeError', `toString() radix argument must be between 2 and 36`),[11],[32,0],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,4],[252,3],[34,6],[65,1],[54,1,0],[32,6],[65,48],[58,0,4],[32,6],[184],[34,4],[65,195,1],[15],[11],[32,0],[68,0,0,0,0,0,0,0,0],[99],[4,64],[32,0],[154],[33,0],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,45],[58,0,4],[11],[32,0],[16, ...builtin('__Math_trunc')],[33,9],...number(allocPage(scope, 'bytestring: __Number_prototype_toString/digits', 'i8') * pageSize, 124),[33,10],[68,0,0,0,0,0,0,0,0],[33,11],[32,2],[68,0,0,0,0,0,0,36,64],[97],[4,64],[32,9],[68,80,239,226,214,228,26,75,68],[102],[4,64],[68,0,0,0,0,0,0,240,63],[33,12],[68,0,0,0,0,0,0,240,191],[33,13],[3,64],[32,9],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,9],[32,2],[16, ...builtin('f64_%')],[33,14],[32,9],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,9],[32,13],[68,0,0,0,0,0,0,240,63],[160],[33,13],[32,12],[252,3],[4,64],[32,14],[68,0,0,0,0,0,0,0,0],[97],[4,64],[12,3],[11],[68,0,0,0,0,0,0,0,0],[33,12],[11],[32,10],[32,11],[160],[252,2],[32,14],[252,2],[58,0,4],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,17],[3,64],[32,5],[32,16],[99],[4,64],[32,5],[32,17],[97],[4,64],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,46],[58,0,4],[32,16],[68,0,0,0,0,0,0,240,63],[160],[33,16],[11],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[34,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,229,0],[58,0,4],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,43],[58,0,4],[68,0,0,0,0,0,0,0,0],[33,11],[3,64],[32,13],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,10],[32,11],[160],[252,2],[32,13],[32,2],[16, ...builtin('f64_%')],[252,2],[58,0,4],[32,13],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,13],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[3,64],[32,5],[32,16],[99],[4,64],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[34,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[32,4],[252,3],[32,5],[32,4],[161],[34,18],[252,3],[54,1,0],[32,4],[65,195,1],[15],[11],[32,0],[68,141,237,181,160,247,198,176,62],[99],[4,64],[32,0],[33,19],[68,0,0,0,0,0,0,240,63],[33,13],[3,64],[65,1],[4,64],[32,19],[32,2],[162],[34,19],[16, ...builtin('__Math_trunc')],[34,20],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,19],[32,20],[161],[68,187,189,215,217,223,124,219,61],[99],[4,64],[12,2],[11],[5],[32,13],[68,0,0,0,0,0,0,240,63],[160],[33,13],[11],[12,1],[11],[11],[3,64],[32,19],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,19],[32,2],[16, ...builtin('f64_%')],[33,14],[32,19],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,19],[32,10],[32,11],[160],[252,2],[32,14],[252,2],[58,0,4],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,17],[3,64],[32,5],[32,16],[99],[4,64],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[33,14],[32,5],[32,17],[97],[4,64],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,46],[58,0,4],[32,16],[68,0,0,0,0,0,0,240,63],[160],[33,16],[11],[32,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,229,0],[58,0,4],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,45],[58,0,4],[68,0,0,0,0,0,0,0,0],[33,11],[3,64],[32,13],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,10],[32,11],[160],[252,2],[32,13],[32,2],[16, ...builtin('f64_%')],[252,2],[58,0,4],[32,13],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,13],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[3,64],[32,5],[32,16],[99],[4,64],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[34,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[32,4],[252,3],[32,5],[32,4],[161],[34,18],[252,3],[54,1,0],[32,4],[65,195,1],[15],[11],[11],[32,9],[68,0,0,0,0,0,0,0,0],[97],[4,64],[32,10],[252,2],[65,0],[58,0,4],[68,0,0,0,0,0,0,240,63],[33,11],[5],[3,64],[32,9],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,10],[32,11],[160],[252,2],[32,9],[32,2],[16, ...builtin('f64_%')],[252,2],[58,0,4],[32,9],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,9],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[3,64],[32,5],[32,16],[99],[4,64],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[34,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[32,0],[32,0],[16, ...builtin('__Math_trunc')],[161],[34,19],[68,0,0,0,0,0,0,0,0],[100],[4,64],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[65,46],[58,0,4],[32,19],[68,0,0,0,0,0,0,240,63],[160],[33,19],[68,0,0,0,0,0,0,48,64],[32,11],[161],[33,21],[68,0,0,0,0,0,0,0,0],[33,22],[3,64],[32,22],[32,21],[99],[4,64],[32,19],[32,2],[162],[33,19],[32,22],[68,0,0,0,0,0,0,240,63],[160],[33,22],[12,1],[11],[11],[32,19],[16, ...builtin('__Math_round')],[33,19],[68,0,0,0,0,0,0,0,0],[33,11],[68,0,0,0,0,0,0,240,63],[33,12],[3,64],[32,19],[68,0,0,0,0,0,0,240,63],[100],[4,64],[32,19],[32,2],[16, ...builtin('f64_%')],[33,14],[32,19],[32,2],[163],[16, ...builtin('__Math_trunc')],[33,19],[32,12],[252,3],[4,64],[32,14],[68,0,0,0,0,0,0,0,0],[97],[4,64],[12,3],[11],[68,0,0,0,0,0,0,0,0],[33,12],[11],[32,10],[32,11],[160],[252,2],[32,14],[252,2],[58,0,4],[32,11],[68,0,0,0,0,0,0,240,63],[160],[33,11],[12,1],[11],[11],[32,10],[32,11],[160],[33,15],[32,5],[32,11],[160],[33,16],[3,64],[32,5],[32,16],[99],[4,64],[32,15],[68,0,0,0,0,0,0,240,63],[161],[34,15],[252,2],[45,0,4],[183],[34,14],[68,0,0,0,0,0,0,36,64],[99],[4,64],[32,14],[68,0,0,0,0,0,0,72,64],[160],[33,14],[5],[32,14],[68,0,0,0,0,0,192,85,64],[160],[33,14],[11],[32,5],[32,5],[68,0,0,0,0,0,0,240,63],[160],[33,5],[252,2],[32,14],[252,2],[58,0,4],[12,1],[11],[11],[11],[32,4],[252,3],[32,5],[32,4],[161],[34,18],[252,3],[54,1,0],[32,4],[65,195,1],[15]],
1652
1659
  params: [124,127,124,127], typedParams: 1,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.24.5+a0b7c83a7",
4
+ "version": "0.24.6+12b34ae5c",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.24.5+a0b7c83a7';
3
+ globalThis.version = '0.24.6+12b34ae5c';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {