porffor 0.20.8 → 0.20.9

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.
@@ -24,7 +24,7 @@ const compile = async (file, _funcs) => {
24
24
  first = source.slice(0, source.indexOf('\n'));
25
25
  }
26
26
 
27
- let args = ['--bytestring', '--todo-time=compile', '--truthy=no_nan_negative', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--fast-object', '--parse-types', '--opt-types'];
27
+ let args = ['--bytestring', '--todo-time=compile', '--truthy=no_nan_negative', '--no-treeshake-wasm-imports', '--no-rm-unused-types', '--scoped-page-names', '--funsafe-no-unlikely-proto-checks', '--fast-length', '--parse-types', '--opt-types'];
28
28
  if (first.startsWith('// @porf')) {
29
29
  args = first.slice('// @porf '.length).split(' ').concat(args);
30
30
  }
@@ -48,6 +48,7 @@ const compile = async (file, _funcs) => {
48
48
 
49
49
  const paramOverrides = {
50
50
  __Porffor_object_set: [ Valtype.i32, Valtype.i32, Valtype.i32, Valtype.i32, Valtype.f64, Valtype.i32 ],
51
+ __Porffor_object_define: [ Valtype.i32, Valtype.i32, Valtype.i32, Valtype.i32, Valtype.f64, Valtype.i32, Valtype.i32, Valtype.i32 ],
51
52
  };
52
53
 
53
54
  const main = funcs.find(x => x.name === 'main');
@@ -113,7 +114,7 @@ const compile = async (file, _funcs) => {
113
114
  if (y[0] === Opcodes.const && (n[0] === Opcodes.local_set || n[0] === Opcodes.local_tee)) {
114
115
  const l = locals[n[1]];
115
116
  if (!l) continue;
116
- if (![TYPES.string, TYPES.array, TYPES.bytestring].includes(l.metadata?.type)) continue;
117
+ if (!['#member_prop'].includes(l.name) && ![TYPES.string, TYPES.array, TYPES.bytestring].includes(l.metadata?.type)) continue;
117
118
  if (!x.pages) continue;
118
119
 
119
120
  const pageName = [...x.pages.keys()].find(z => z.endsWith(l.name));
package/compiler/wrap.js CHANGED
@@ -67,7 +67,7 @@ const porfToJSValue = ({ memory, funcs, pages }, value, type) => {
67
67
  if (Prefs.d) {
68
68
  console.log(`\x1b[4m\x1b[1m${k}\x1b[0m \x1B[90m(${TYPE_NAMES[kType]})\x1B[0m
69
69
  value: \x1B[92m${v}\x1B[0m \x1B[90m(${TYPE_NAMES[vType]})\x1B[0m
70
- flags: 0b\x1B[93m${flags.toString(2)}\x1B[0m\x1B[90m
70
+ flags: 0b\x1B[93m${flags.toString(2).padStart(4, '0')}\x1B[0m\x1B[90m
71
71
  accessor: ${!!(flags & 0b0001)}
72
72
  configurable: ${!!(flags & 0b0010)}
73
73
  enumerable: ${!!(flags & 0b0100)}
@@ -75,8 +75,14 @@ const porfToJSValue = ({ memory, funcs, pages }, value, type) => {
75
75
  \x1B[0m`);
76
76
  }
77
77
 
78
- // todo: use object.defineproperty
79
- out[k] = v;
78
+ const configurable = flags & 0b0010;
79
+ const enumerable = flags & 0b0100;
80
+
81
+ Object.defineProperty(out, k, {
82
+ value: v,
83
+ configurable,
84
+ enumerable,
85
+ });
80
86
  }
81
87
 
82
88
  return out;
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.20.8+6cd20b620",
4
+ "version": "0.20.9+891a17fe5",
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.20.8+6cd20b620';
3
+ globalThis.version = '0.20.9+891a17fe5';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {