porffor 0.60.16 → 0.60.17

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.
@@ -1581,4 +1581,77 @@ export const __String_prototype_matchAll = (_this: string, regexp: any) => {
1581
1581
 
1582
1582
  export const __ByteString_prototype_matchAll = (_this: bytestring, regexp: any) => {
1583
1583
  return __Porffor_regex_matchAll(regexp, _this);
1584
+ };
1585
+
1586
+
1587
+ export const __Porffor_regex_escapeX = (out: bytestring, char: i32) => {
1588
+ // 0-9 or a-z or A-Z as first char - escape as \xNN
1589
+ Porffor.bytestring.append2Char(out, 92, 120);
1590
+
1591
+ let char1: i32 = 48 + Math.floor(char / 16);
1592
+ if (char1 > 57) char1 += 39; // 58 (:) -> 97 (a)
1593
+ let char2: i32 = 48 + char % 16;
1594
+ if (char2 > 57) char2 += 39; // 58 (:) -> 97 (a)
1595
+ Porffor.bytestring.append2Char(out, char1, char2);
1596
+ };
1597
+
1598
+ export const __RegExp_escape = (str: any) => {
1599
+ const out: bytestring = Porffor.allocate();
1600
+
1601
+ let i: i32 = 0;
1602
+ const first: i32 = str.charCodeAt(0);
1603
+ if ((first > 47 && first < 58) || (first > 96 && first < 123) || (first > 64 && first < 91)) {
1604
+ __Porffor_regex_escapeX(out, first);
1605
+ i++;
1606
+ }
1607
+
1608
+ const len: i32 = str.length;
1609
+ for (; i < len; i++) {
1610
+ const char: i32 = str.charCodeAt(i);
1611
+ // ^, $, \, ., *, +, ?, (, ), [, ], {, }, |, /
1612
+ if (Porffor.fastOr(char == 94, char == 36, char == 92, char == 46, char == 42, char == 43, char == 63, char == 40, char == 41, char == 91, char == 93, char == 123, char == 125, char == 124, char == 47)) {
1613
+ // regex syntax, escape with \
1614
+ Porffor.bytestring.append2Char(out, 92, char);
1615
+ continue;
1616
+ }
1617
+
1618
+ // ,, -, =, <, >, #, &, !, %, :, ;, @, ~, ', `, "
1619
+ if (Porffor.fastOr(char == 44, char == 45, char == 61, char == 60, char == 62, char == 35, char == 38, char == 33, char == 37, char == 58, char == 59, char == 64, char == 126, char == 39, char == 96, char == 34)) {
1620
+ // punctuator, escape with \x
1621
+ __Porffor_regex_escapeX(out, char);
1622
+ continue;
1623
+ }
1624
+
1625
+ // \f, \n, \r, \t, \v, \x20
1626
+ if (char == 12) {
1627
+ Porffor.bytestring.append2Char(out, 92, 102);
1628
+ continue;
1629
+ }
1630
+ if (char == 10) {
1631
+ Porffor.bytestring.append2Char(out, 92, 110);
1632
+ continue;
1633
+ }
1634
+ if (char == 13) {
1635
+ Porffor.bytestring.append2Char(out, 92, 114);
1636
+ continue;
1637
+ }
1638
+ if (char == 9) {
1639
+ Porffor.bytestring.append2Char(out, 92, 116);
1640
+ continue;
1641
+ }
1642
+ if (char == 11) {
1643
+ Porffor.bytestring.append2Char(out, 92, 118);
1644
+ continue;
1645
+ }
1646
+ if (char == 32) {
1647
+ Porffor.bytestring.append2Char(out, 92, 120);
1648
+ Porffor.bytestring.append2Char(out, 50, 48);
1649
+ continue;
1650
+ }
1651
+
1652
+ // todo: surrogates
1653
+ Porffor.bytestring.appendChar(out, char);
1654
+ }
1655
+
1656
+ return out;
1584
1657
  };
@@ -2938,6 +2938,17 @@ wasm:(_,{builtin})=>eval("[[32,2],[32,3],[32,0],[65,195],[16,builtin('__Porffor_
2938
2938
  params:[127,127,127,127],typedParams:1,returns:[127,127],jsLength:1,
2939
2939
  locals:[127],localNames:["_this","_this#type","regexp","regexp#type","#last_type"]
2940
2940
  }
2941
+ x.__Porffor_regex_escapeX={
2942
+ wasm:(_,{builtin})=>eval("[[32,0],[183],[65,195],[65,92],[183],[65,1],[65,120],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[65,48],[32,2],[65,16],[109],[183],[16,builtin('__Math_floor')],[252,2],[106],[34,4],[65,57],[74],[4,64],[32,4],[65,39],[106],[33,4],[11],[65,48],[32,2],[65,16],[111],[106],[34,5],[65,57],[74],[4,64],[32,5],[65,39],[106],[33,5],[11],[32,0],[183],[65,195],[32,4],[183],[65,1],[32,5],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[65,0],[65,0],[15]]"),
2943
+ params:[127,127,127,127],typedParams:1,returns:[127,127],jsLength:2,
2944
+ locals:[127,127],localNames:["out","out#type","char","char#type","char1","char2"]
2945
+ }
2946
+ x.__RegExp_escape={
2947
+ wasm:(_,{t,builtin,internalThrow})=>eval("[[16,builtin('__Porffor_allocate')],[33,2],[65,0],[33,3],[32,0],[33,5],[32,1],[33,6],[32,1],[33,7],[2,127],...t([33],()=>[[32,7],[65,33],[70],[4,64],[32,5],[183],[32,6],[65,0],[183],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11]]),...t([67],()=>[[32,7],[65,67],[70],[4,64],[32,5],[183],[32,6],[65,0],[183],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11]]),...t([195],()=>[[32,7],[65,195],[70],[4,64],[32,5],[183],[32,6],[65,0],[183],[65,1],[16,builtin('__ByteString_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11]]),...internalThrow(_,'TypeError',`'charCodeAt' proto func tried to be called on a type without an impl`),[65,0],[11],[34,4],[65,47],[74],[34,9],[4,127],[32,4],[65,58],[72],[65,2],[33,8],[5],[32,9],[65,2],[33,8],[11],[34,9],[33,10],[32,8],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,67],[70],[32,7],[65,195],[70],[114],[4,64],[32,10],[40,1,0],[69],[12,1],[11]]),[32,10],[69],[11],[4,127],[32,4],[65,96],[74],[34,9],[4,127],[32,4],[65,123],[72],[65,2],[33,8],[5],[32,9],[65,2],[33,8],[11],[32,8],[33,8],[5],[32,9],[32,8],[33,8],[11],[34,9],[33,10],[32,8],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,67],[70],[32,7],[65,195],[70],[114],[4,64],[32,10],[40,1,0],[69],[12,1],[11]]),[32,10],[69],[11],[4,127],[32,4],[65,64],[74],[34,9],[4,127],[32,4],[65,91],[72],[65,2],[33,8],[5],[32,9],[65,2],[33,8],[11],[32,8],[33,8],[5],[32,9],[32,8],[33,8],[11],[33,11],[32,8],[33,7],[2,127],...t([67,195],()=>[[32,7],[65,67],[70],[32,7],[65,195],[70],[114],[4,64],[32,11],[40,1,0],[12,1],[11]]),[32,11],[11],[4,64],[32,2],[65,195],[32,4],[65,1],[16,builtin('__Porffor_regex_escapeX')],[33,8],[26],[32,3],[65,1],[106],[33,3],[11],[32,0],[40,1,0],[33,12],[3,64],[32,3],[32,12],[72],[4,64],[2,64],[32,0],[33,5],[32,1],[33,6],[32,1],[33,7],[2,127],...t([33],()=>[[32,7],[65,33],[70],[4,64],[32,5],[183],[32,6],[32,3],[183],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11]]),...t([67],()=>[[32,7],[65,67],[70],[4,64],[32,5],[183],[32,6],[32,3],[183],[65,1],[16,builtin('__String_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11]]),[32,7],[65,195],[70],[4,64],[32,5],[183],[32,6],[32,3],[183],[65,1],[16,builtin('__ByteString_prototype_charCodeAt')],[33,8],[252,2],[12,1],[11],...internalThrow(_,'TypeError',`'charCodeAt' proto func tried to be called on a type without an impl`),[65,0],[11],[34,13],[65,94],[70],[32,13],[65,36],[70],[114],[32,13],[65,92],[70],[114],[32,13],[65,46],[70],[114],[32,13],[65,42],[70],[114],[32,13],[65,43],[70],[114],[32,13],[65,63],[70],[114],[32,13],[65,40],[70],[114],[32,13],[65,41],[70],[114],[32,13],[65,91],[70],[114],[32,13],[65,93],[70],[114],[32,13],[65,123],[70],[114],[32,13],[65,125],[70],[114],[32,13],[65,124],[70],[114],[32,13],[65,47],[70],[114],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[32,13],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,44],[70],[32,13],[65,45],[70],[114],[32,13],[65,61],[70],[114],[32,13],[65,60],[70],[114],[32,13],[65,62],[70],[114],[32,13],[65,35],[70],[114],[32,13],[65,38],[70],[114],[32,13],[65,33],[70],[114],[32,13],[65,37],[70],[114],[32,13],[65,58],[70],[114],[32,13],[65,59],[70],[114],[32,13],[65,64],[70],[114],[32,13],[65,126],[70],[114],[32,13],[65,39],[70],[114],[32,13],[65,96],[70],[114],[32,13],[65,34],[70],[114],[4,64],[32,2],[65,195],[32,13],[65,1],[16,builtin('__Porffor_regex_escapeX')],[33,8],[26],[12,1],[26],[11],[32,13],[65,12],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,102],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,10],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,110],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,13],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,114],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,9],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,116],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,11],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,118],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,13],[65,32],[70],[4,64],[32,2],[183],[65,195],[65,92],[183],[65,1],[65,120],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[32,2],[183],[65,195],[65,50],[183],[65,1],[65,48],[183],[65,1],[16,builtin('__Porffor_bytestring_append2Char')],[252,2],[26],[12,1],[26],[11],[32,2],[183],[65,195],[32,13],[183],[65,1],[16,builtin('__Porffor_bytestring_appendChar')],[252,2],[26],[11],[32,3],[65,1],[106],[33,3],[12,1],[11],[11],[32,2],[65,195],[15]]"),
2948
+ params:[127,127],typedParams:1,returns:[127,127],jsLength:1,
2949
+ locals:[127,127,127,127,127,127,127,127,127,127,127,127],localNames:["str","str#type","out","i","first","#proto_target","#proto_target#type","#typeswitch_tmp1","#last_type","logictmp","#logicinner_tmp","#logicinner_tmp_int","len","char"],
2950
+ usesTag:1
2951
+ }
2941
2952
  x.__Set_prototype_size$get={
2942
2953
  wasm:(_,{internalThrow})=>eval("[[32,1],[65,11],[71],[4,64],...internalThrow(_,'TypeError',`Set.prototype.size$get expects 'this' to be a Set`),[11],[32,0],[252,2],[40,0,0],[183],[65,1],[15]]"),
2943
2954
  params:[124,127],typedParams:1,returns:[124,127],jsLength:0,
package/jsr.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honk/porffor",
3
- "version": "0.58.7",
3
+ "version": "0.60.17",
4
4
  "exports": "./compiler/wrap.js",
5
5
  "publish": {
6
6
  "exclude": [
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "An ahead-of-time JavaScript compiler",
4
- "version": "0.60.16",
4
+ "version": "0.60.17",
5
5
  "author": "Oliver Medhurst <honk@goose.icu>",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runtime/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.60.16';
3
+ globalThis.version = '0.60.17';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {