porffor 0.14.0-eca486960 → 0.16.0-594397507
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/CONTRIBUTING.md +15 -9
- package/README.md +9 -13
- package/asur/index.js +1 -1
- package/compiler/2c.js +68 -3
- package/compiler/assemble.js +14 -0
- package/compiler/builtins/annexb_string.ts +1 -0
- package/compiler/builtins/array.ts +84 -4
- package/compiler/builtins/base64.ts +1 -0
- package/compiler/builtins/boolean.ts +2 -0
- package/compiler/builtins/console.ts +6 -0
- package/compiler/builtins/crypto.ts +1 -0
- package/compiler/builtins/date.ts +2 -0
- package/compiler/builtins/error.js +22 -0
- package/compiler/builtins/escape.ts +1 -2
- package/compiler/builtins/function.ts +2 -0
- package/compiler/builtins/int.ts +2 -0
- package/compiler/builtins/math.ts +410 -0
- package/compiler/builtins/number.ts +2 -0
- package/compiler/builtins/object.ts +2 -0
- package/compiler/builtins/porffor.d.ts +8 -0
- package/compiler/builtins/set.ts +15 -1
- package/compiler/builtins/string.ts +1 -0
- package/compiler/builtins/symbol.ts +8 -7
- package/compiler/builtins.js +23 -7
- package/compiler/codegen.js +383 -172
- package/compiler/decompile.js +4 -0
- package/compiler/generated_builtins.js +503 -53
- package/compiler/index.js +2 -1
- package/compiler/parse.js +2 -2
- package/compiler/precompile.js +5 -4
- package/compiler/prefs.js +1 -1
- package/compiler/prototype.js +180 -157
- package/compiler/wrap.js +18 -4
- package/package.json +1 -1
- package/runner/index.js +5 -4
- package/runner/repl.js +18 -2
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 });
|