porffor 0.18.14 → 0.18.15

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.
@@ -28,7 +28,7 @@ export const __crypto_randomUUID = (): bytestring => {
28
28
  12 // 4 + 8
29
29
  );
30
30
 
31
- let output: bytestring = '------------------------------------';
31
+ let output: bytestring = Porffor.allocate();
32
32
 
33
33
  let i: i32 = Porffor.wasm`local.get ${output}`;
34
34
  let j: i32 = bytesPtr;
@@ -1,19 +1,6 @@
1
1
  // @porf --valtype=i32
2
2
  import type {} from './porffor.d.ts';
3
3
 
4
- export const __String_fromCharCode = (code: i32) => {
5
- // todo: support >1 arg
6
- if (code < 256) {
7
- let out: bytestring = '.';
8
- Porffor.wasm.i32.store8(out, code, 0, 4);
9
- return out;
10
- }
11
-
12
- let out: string = Porffor.s`.`;
13
- Porffor.wasm.i32.store16(out, code, 0, 4);
14
- return out;
15
- };
16
-
17
4
  export const __String_prototype_toUpperCase = (_this: string) => {
18
5
  // todo: unicode not just ascii
19
6
  const len: i32 = _this.length;
@@ -5,4 +5,33 @@ import type {} from './porffor.d.ts';
5
5
  export const String = function (value: any): bytestring {
6
6
  if (!new.target && Porffor.rawType(value) == Porffor.TYPES.symbol) return __Symbol_prototype_toString(value);
7
7
  return __ecma262_ToString(value);
8
+ };
9
+
10
+ export const __String_fromCharCode = (...codes: any[]): bytestring|string => {
11
+ let out: string = Porffor.allocate();
12
+
13
+ const len: i32 = codes.length;
14
+ out.length = len;
15
+
16
+ let bytestringable: boolean = true;
17
+ for (let i: i32 = 0; i < len; i++) {
18
+ const v: i32 = __ecma262_ToIntegerOrInfinity(codes[i]);
19
+ if (v > 0xFF) bytestringable = false;
20
+
21
+ Porffor.wasm.i32.store16(Porffor.wasm`local.get ${out}` + i * 2, v, 0, 4);
22
+ }
23
+
24
+ if (bytestringable) {
25
+ let out2: bytestring = Porffor.wasm`local.get ${out}`;
26
+ for (let i: i32 = 0; i < len; i++) {
27
+ Porffor.wasm.i32.store8(
28
+ Porffor.wasm`local.get ${out}` + i,
29
+ Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${out}` + i * 2, 0, 4),
30
+ 0, 4);
31
+ }
32
+
33
+ return out2;
34
+ }
35
+
36
+ return out;
8
37
  };
@@ -516,14 +516,14 @@ export const BuiltinFuncs = function() {
516
516
  data: [{"bytes":[9,0,0,0,27,91,49,59,49,72,27,91,74],"offset":0}],
517
517
  };
518
518
  this.__crypto_randomUUID = {
519
- wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __crypto_randomUUID/bytes', 'i8') * pageSize, 127),[34,0],[34,1],[34,2],[65,16],[106],[33,3],[3,64],[32,2],[32,3],[72],[4,64],[32,2],[32,2],[65,1],[106],[33,2],[16, builtin('__Porffor_randomByte')],[58,0,4],[12,1],[11],[11],[32,1],[32,1],[45,0,10],[65,15],[113],[65,192,0],[114],[58,0,10],[32,1],[32,1],[45,0,12],[65,63],[113],[65,128,1],[114],[58,0,12],...number(allocPage(scope, 'bytestring: __crypto_randomUUID/output', 'i8') * pageSize, 127),[34,4],[33,5],[32,1],[33,6],[32,5],[65,8],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,4],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[34,5],[65,12],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,6],[32,6],[65,1],[106],[33,6],[45,0,4],[34,8],[65,15],[113],[65,48],[106],[34,9],[65,57],[74],[4,64],[32,9],[65,39],[106],[33,9],[11],[32,8],[65,4],[117],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,5],[32,5],[65,1],[106],[33,5],[32,10],[58,0,4],[32,5],[32,5],[65,1],[106],[33,5],[32,9],[58,0,4],[12,1],[11],[11],[32,5],[65,1],[106],[33,5],[32,4],[65,194,1],[15]],
519
+ wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __crypto_randomUUID/bytes', 'i8') * pageSize, 127),[34,0],[34,1],[34,2],[65,16],[106],[33,3],[3,64],[32,2],[32,3],[72],[4,64],[32,2],[32,2],[65,1],[106],[33,2],[16, builtin('__Porffor_randomByte')],[58,0,4],[12,1],[11],[11],[32,1],[32,1],[45,0,10],[65,15],[113],[65,192,0],[114],[58,0,10],[32,1],[32,1],[45,0,12],[65,63],[113],[65,128,1],[114],[58,0,12],[16, builtin('__Porffor_allocate')],[33,5],[252,2],[34,4],[33,6],[32,1],[33,7],[32,6],[65,8],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[34,9],[65,15],[113],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,9],[65,4],[117],[65,48],[106],[34,11],[65,57],[74],[4,64],[32,11],[65,39],[106],[33,11],[11],[32,6],[32,6],[65,1],[106],[33,6],[32,11],[58,0,4],[32,6],[32,6],[65,1],[106],[33,6],[32,10],[58,0,4],[12,1],[11],[11],[32,6],[65,1],[106],[34,6],[65,4],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[34,9],[65,15],[113],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,9],[65,4],[117],[65,48],[106],[34,11],[65,57],[74],[4,64],[32,11],[65,39],[106],[33,11],[11],[32,6],[32,6],[65,1],[106],[33,6],[32,11],[58,0,4],[32,6],[32,6],[65,1],[106],[33,6],[32,10],[58,0,4],[12,1],[11],[11],[32,6],[65,1],[106],[34,6],[65,4],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[34,9],[65,15],[113],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,9],[65,4],[117],[65,48],[106],[34,11],[65,57],[74],[4,64],[32,11],[65,39],[106],[33,11],[11],[32,6],[32,6],[65,1],[106],[33,6],[32,11],[58,0,4],[32,6],[32,6],[65,1],[106],[33,6],[32,10],[58,0,4],[12,1],[11],[11],[32,6],[65,1],[106],[34,6],[65,4],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[34,9],[65,15],[113],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,9],[65,4],[117],[65,48],[106],[34,11],[65,57],[74],[4,64],[32,11],[65,39],[106],[33,11],[11],[32,6],[32,6],[65,1],[106],[33,6],[32,11],[58,0,4],[32,6],[32,6],[65,1],[106],[33,6],[32,10],[58,0,4],[12,1],[11],[11],[32,6],[65,1],[106],[34,6],[65,12],[106],[33,8],[3,64],[32,6],[32,8],[72],[4,64],[32,7],[32,7],[65,1],[106],[33,7],[45,0,4],[34,9],[65,15],[113],[65,48],[106],[34,10],[65,57],[74],[4,64],[32,10],[65,39],[106],[33,10],[11],[32,9],[65,4],[117],[65,48],[106],[34,11],[65,57],[74],[4,64],[32,11],[65,39],[106],[33,11],[11],[32,6],[32,6],[65,1],[106],[33,6],[32,11],[58,0,4],[32,6],[32,6],[65,1],[106],[33,6],[32,10],[58,0,4],[12,1],[11],[11],[32,6],[65,1],[106],[33,6],[32,4],[65,194,1],[15]],
520
520
  params: [],
521
521
  typedParams: true,
522
522
  returns: [127,127],
523
523
  typedReturns: true,
524
- locals: [127,127,127,127,127,127,127,127,127,127,127],
525
- localNames: ["bytes","bytesPtr","a","aEndPtr","output","i","j","endPtr","byte","lower","upper"],
526
- data: [{"bytes":[16,0,0,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46],"offset":0},{"bytes":[36,0,0,0,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45,45],"offset":65536}],
524
+ locals: [127,127,127,127,127,127,127,127,127,127,127,127],
525
+ localNames: ["bytes","bytesPtr","a","aEndPtr","output","#last_type","i","j","endPtr","byte","lower","upper"],
526
+ data: [{"bytes":[16,0,0,0,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46,46],"offset":0}],
527
527
  };
528
528
  this.__ecma262_Day = {
529
529
  wasm: (scope, {builtin,}) => [[32,0],[68,0,0,0,0,112,153,148,65],[163],[16, builtin('__Math_floor')],[65,0],[15]],
@@ -1773,16 +1773,6 @@ export const BuiltinFuncs = function() {
1773
1773
  localNames: ["_this","_this#type","out"],
1774
1774
  data: [{"bytes":[12,0,0,0,91,111,98,106,101,99,116,32,83,101,116,93],"offset":0}],
1775
1775
  };
1776
- this.__String_fromCharCode = {
1777
- wasm: (scope, {allocPage,}) => [[32,0],[65,128,2],[72],[4,64],...number(allocPage(scope, 'bytestring: __String_fromCharCode/out', 'i8') * pageSize, 127),[34,2],[32,0],[58,0,4],[32,2],[65,194,1],[15],[11],[32,2],[34,3],[65,1],[54,1,0],[32,3],[65,46],[59,0,4],[32,3],[34,2],[32,0],[59,0,4],[32,2],[65,194,0],[15]],
1778
- params: [127,127],
1779
- typedParams: true,
1780
- returns: [127,127],
1781
- typedReturns: true,
1782
- locals: [127,127],
1783
- localNames: ["code","code#type","out","#makearray_pointer_tmp"],
1784
- data: [{"bytes":[1,0,0,0,46],"offset":0}],
1785
- };
1786
1776
  this.__String_prototype_toUpperCase = {
1787
1777
  wasm: (scope, {builtin,}) => [[32,0],[40,1,0],[33,2],[16, builtin('__Porffor_allocate')],[33,4],[252,2],[34,3],[32,2],[54,0,0],[32,0],[33,5],[32,3],[33,6],[32,5],[32,2],[65,2],[108],[106],[33,7],[3,64],[32,5],[32,7],[72],[4,64],[32,5],[47,0,4],[33,8],[32,5],[65,2],[106],[33,5],[32,8],[65,225,0],[78],[4,64],[32,8],[65,250,0],[76],[4,64],[32,8],[65,32],[107],[33,8],[11],[11],[32,6],[32,8],[59,0,4],[32,6],[65,2],[106],[33,6],[12,1],[11],[11],[32,3],[65,194,0],[15]],
1788
1778
  params: [127,127],
@@ -2099,6 +2089,16 @@ export const BuiltinFuncs = function() {
2099
2089
  localNames: ["value","value#type","#last_type","#logicinner_tmp","#typeswitch_tmp","logictmp"],
2100
2090
  constr: true,
2101
2091
  };
2092
+ this.__String_fromCharCode = {
2093
+ wasm: (scope, {builtin,}) => [[16, builtin('__Porffor_allocate')],[33,3],[33,2],[32,0],[252,3],[40,1,0],[184],[33,4],[32,2],[252,3],[32,4],[34,5],[252,3],[54,1,0],[68,0,0,0,0,0,0,240,63],[33,6],[68,0,0,0,0,0,0,0,0],[33,7],[3,64],[32,7],[32,4],[99],[4,64],[32,7],[252,3],[65,9],[108],[32,0],[252,3],[106],[34,9],[43,0,4],[32,9],[45,0,12],[34,3],[16, builtin('__ecma262_ToIntegerOrInfinity')],[33,3],[34,8],[68,0,0,0,0,0,224,111,64],[100],[4,64],[68,0,0,0,0,0,0,0,0],[33,6],[11],[32,2],[32,7],[68,0,0,0,0,0,0,0,64],[162],[160],[252,2],[32,8],[252,2],[59,0,4],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[12,1],[11],[11],[32,6],[252,3],[4,64],[32,2],[33,10],[68,0,0,0,0,0,0,0,0],[33,7],[3,64],[32,7],[32,4],[99],[4,64],[32,2],[32,7],[160],[252,2],[32,2],[32,7],[68,0,0,0,0,0,0,0,64],[162],[160],[252,2],[45,0,4],[58,0,4],[32,7],[68,0,0,0,0,0,0,240,63],[160],[33,7],[12,1],[11],[11],[32,10],[65,194,1],[15],[11],[32,2],[65,194,0],[15]],
2094
+ params: [124,127],
2095
+ typedParams: true,
2096
+ returns: [124,127],
2097
+ typedReturns: true,
2098
+ locals: [124,127,124,124,124,124,124,127,124],
2099
+ localNames: ["codes","codes#type","out","#last_type","len","__length_setter_tmp","bytestringable","i","v","#loadArray_offset","out2"],
2100
+ hasRestArgument: true,
2101
+ };
2102
2102
  this.__Porffor_symbol_descStore = {
2103
2103
  wasm: (scope, {allocPage,builtin,}) => [...number(allocPage(scope, 'bytestring: __Porffor_symbol_descStore/ptr', 'i8') * pageSize, 124),[33,4],[32,0],[252,3],[4,64],[32,4],[252,2],[40,0,0],[183],[33,5],[32,4],[252,2],[32,5],[68,0,0,0,0,0,0,240,63],[160],[252,2],[54,0,0],[32,4],[65,194,1],[32,5],[65,0],[32,2],[32,3],[16, builtin('__Porffor_set_write')],[33,6],[26],[32,5],[65,0],[15],[5],[32,4],[65,194,1],[32,2],[32,3],[16, builtin('__Porffor_set_read')],[34,6],[15],[11],[68,0,0,0,0,0,0,0,0],[65,3],[15]],
2104
2104
  params: [124,127,124,127],
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.18.14+d7ef62736",
4
+ "version": "0.18.15+60ee60319",
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.18.14+d7ef62736';
3
+ globalThis.version = '0.18.15+60ee60319';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {