porffor 0.49.8 → 0.49.10

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.
@@ -1507,7 +1507,7 @@ const getNodeType = (scope, node) => {
1507
1507
  }
1508
1508
 
1509
1509
  if (Object.hasOwn(builtinFuncs, name) && !builtinFuncs[name].typedReturns) return builtinFuncs[name].returnType ?? TYPES.number;
1510
- if (Object.hasOwn(internalConstrs, name)) return internalConstrs[name].type;
1510
+ if (Object.hasOwn(internalConstrs, name) && internalConstrs[name].type != null) return internalConstrs[name].type;
1511
1511
 
1512
1512
  // check if this is a prototype function
1513
1513
  // if so and there is only one impl (eg charCodeAt)
@@ -1929,7 +1929,7 @@ const createThisArg = (scope, decl) => {
1929
1929
  const name = decl.callee?.name;
1930
1930
  if (decl._new) {
1931
1931
  // if precompiling or builtin func, just make it null as unused
1932
- if (globalThis.precompile || Object.hasOwn(builtinFuncs, name)) return [
1932
+ if (!decl._forceCreateThis && (globalThis.precompile || Object.hasOwn(builtinFuncs, name))) return [
1933
1933
  ...number(NULL),
1934
1934
  ...number(TYPES.object, Valtype.i32)
1935
1935
  ];
@@ -6094,7 +6094,7 @@ const objectHack = node => {
6094
6094
  if (node.computed || node.optional) return;
6095
6095
 
6096
6096
  // hack: block these properties as they can be accessed on functions
6097
- if (node.property.name === 'length' || node.property.name === 'name' || node.property.name === 'call') return abortOut;
6097
+ if (node.object.name !== 'Porffor' && (node.property.name === 'length' || node.property.name === 'name' || node.property.name === 'call')) return abortOut;
6098
6098
 
6099
6099
  if (node.property.name === '__proto__') return abortOut;
6100
6100
 
@@ -6605,6 +6605,30 @@ const internalConstrs = {
6605
6605
  type: TYPES.bytestring,
6606
6606
  notConstr: true,
6607
6607
  length: 1
6608
+ },
6609
+
6610
+ __Porffor_call: {
6611
+ // Porffor.call(func, argArray, this, newTarget)
6612
+ generate: (scope, decl) => generate(scope, {
6613
+ type: 'CallExpression',
6614
+ callee: decl.arguments[0],
6615
+ arguments: [ {
6616
+ type: 'SpreadElement',
6617
+ argument: decl.arguments[1],
6618
+ } ],
6619
+ _thisWasm: decl.arguments[2].value === null ? null : [
6620
+ ...generate(scope, decl.arguments[2]),
6621
+ ...getNodeType(scope, decl.arguments[2])
6622
+ ],
6623
+ _newTargetWasm: decl.arguments[3].value === null ? null : [
6624
+ ...generate(scope, decl.arguments[3]),
6625
+ ...getNodeType(scope, decl.arguments[3])
6626
+ ],
6627
+ _new: decl.arguments[3].value !== null,
6628
+ _forceCreateThis: true
6629
+ }),
6630
+ notConstr: true,
6631
+ length: 1
6608
6632
  }
6609
6633
  };
6610
6634
 
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.49.8",
4
+ "version": "0.49.10",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
@@ -54,7 +54,7 @@ const render = () => {
54
54
  text += `${' '.repeat(12 - text.length)}┃ samples: ${samples}`;
55
55
  text += `${' '.repeat(32 - text.length)}┃ render: ${lastRenderTime.toFixed(2)}ms`;
56
56
 
57
- if (end != null && Prefs.live) {
57
+ if (end != null || Prefs.live) {
58
58
  const btHeight = 20;
59
59
  const fgBottom = termHeight - btHeight - 10;
60
60
 
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.49.8';
3
+ globalThis.version = '0.49.10';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {