porffor 0.14.0-3ba07b862 → 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/compiler/builtins/array.ts +6 -4
- package/compiler/builtins/set.ts +5 -6
- package/compiler/builtins/symbol.ts +1 -1
- package/compiler/builtins.js +9 -4
- package/compiler/codegen.js +266 -126
- package/compiler/generated_builtins.js +32 -32
- package/compiler/precompile.js +1 -1
- package/compiler/prefs.js +1 -1
- package/compiler/prototype.js +180 -157
- package/compiler/wrap.js +66 -37
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/runner/repl.js +18 -2
package/package.json
CHANGED
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\
|
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
|
-
|
90
|
-
|
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 });
|