porffor 0.14.0-3c0ba31cd → 0.14.0-3fa90b5d2

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.
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.14.0-3c0ba31cd",
4
+ "version": "0.14.0-3fa90b5d2",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {
package/runner/index.js CHANGED
@@ -25,7 +25,7 @@ if (process.argv.includes('--help')) {
25
25
  console.log(`Usage: \x1B[1mporf [command] path/to/script.js [...prefs] [...args]\x1B[0m`);
26
26
 
27
27
  // commands
28
- console.log(`\n\u001b[4mCommands\x1B[0m`);
28
+ console.log(`\n\x1B[1mCommands:\x1B[0m`);
29
29
  for (const [ cmd, [ color, desc ] ] of Object.entries({
30
30
  run: [ 34, 'Run a JS file' ],
31
31
  wasm: [ 34, 'Compile a JS file to a Wasm binary\n' ],
package/runner/repl.js CHANGED
@@ -1,6 +1,11 @@
1
+ import { TYPE_NAMES } from '../compiler/types.js';
1
2
  import compile from '../compiler/wrap.js';
2
3
  import version from './version.js';
3
4
 
5
+ import util from 'node:util';
6
+
7
+ process.argv.push('--no-opt-unused');
8
+
4
9
  let repl;
5
10
  try {
6
11
  // try importing node:repl
@@ -86,10 +91,21 @@ const run = async (source, _context, _filename, callback, run = true) => {
86
91
  lastPages = [...pages.keys()];
87
92
  }
88
93
 
89
- const ret = run ? exports.main() : undefined;
90
- callback(null, ret);
94
+ let ret = run ? exports.main() : undefined;
95
+ let value, type;
96
+ if (ret?.type != null) {
97
+ value = ret.value;
98
+ type = ret.type;
99
+ ret = ret.js;
100
+ }
101
+
102
+ console.log(util.inspect(ret, false, 2, true), (value != null ? `\x1B[34m\x1B[3m(value: ${value}, type: ${TYPE_NAMES[type]})\x1B[0m` : ''));
103
+
104
+ // callback(null, ret);
91
105
 
92
106
  prev = prev + ';\n' + source.trim();
107
+
108
+ callback();
93
109
  };
94
110
 
95
111
  const replServer = repl.start({ prompt: '> ', eval: run });