porffor 0.49.5 โ 0.49.7
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/README.md +3 -3
- package/compiler/builtins/console.ts +8 -6
- package/compiler/builtins/math.ts +49 -11
- package/compiler/builtins_precompiled.js +752 -752
- package/compiler/codegen.js +58 -52
- package/compiler/parse.js +1 -1
- package/compiler/precompile.js +1 -1
- package/package.json +1 -1
- package/richards.js +91 -129
- package/runner/index.js +29 -34
- /package/runner/{profile.js โ hotlines.js} +0 -0
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.
|
3
|
+
globalThis.version = '0.49.7';
|
4
4
|
|
5
5
|
// deno compat
|
6
6
|
if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
|
@@ -11,43 +11,38 @@ const start = performance.now();
|
|
11
11
|
|
12
12
|
if (process.argv.includes('--help')) {
|
13
13
|
// description + version
|
14
|
-
console.log(`\x1B[1m\x1B[35mPorffor\x1B[0m is a JavaScript engine/runtime
|
14
|
+
console.log(`\x1B[1m\x1B[35mPorffor\x1B[0m is a JavaScript/TypeScript engine/compiler/runtime. \x1B[90m(${globalThis.version})\x1B[0m`);
|
15
15
|
|
16
16
|
// basic usage
|
17
|
-
console.log(`Usage: \x1B[1mporf
|
17
|
+
console.log(`Usage: \x1B[1mporf <command> [...prefs] path/to/script.js [...args]\x1B[0m`);
|
18
18
|
|
19
19
|
// commands
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
wasm: [ 34, '
|
20
|
+
for (let [ cmd, [ color, post, desc ] ] of Object.entries({
|
21
|
+
'Compile': [],
|
22
|
+
'': [ 34, 'foo.js', 'Compile and execute a file' ],
|
23
|
+
wasm: [ 34, 'foo.js foo.wasm', 'Compile to a Wasm binary' ],
|
24
|
+
c: [ 94, 'foo.js foo.c', 'Compile to C source code' ],
|
25
|
+
native: [ 94, 'foo.js foo', 'Compile to a native binary' ],
|
26
|
+
|
27
|
+
'Profile': [],
|
28
|
+
flamegraph: [ 93, 'foo.js', 'View detailed func-by-func performance' ],
|
29
|
+
hotlines: [ 93, 'foo.js', 'View source with line-by-line performance' ],
|
30
|
+
|
31
|
+
'Debug': [],
|
32
|
+
debug: [ 33, 'foo.js', 'Debug the source of a file' ],
|
33
|
+
dissect: [ 33, 'foo.js', 'Debug the compiled Wasm of a file' ],
|
34
|
+
})) {
|
35
|
+
if (color == null) {
|
36
|
+
// header
|
37
|
+
console.log(`\n\x1B[1m\x1B[4m${cmd}\x1B[0m`);
|
38
|
+
continue;
|
39
|
+
}
|
24
40
|
|
25
|
-
|
26
|
-
native: [ 31, 'Compile a JS file to a native binary\n' ],
|
41
|
+
if (cmd.length > 0) post = ' ' + post;
|
27
42
|
|
28
|
-
|
29
|
-
debug: [ 33, 'Debug a JS file' ],
|
30
|
-
'debug-wasm': [ 33, 'Debug the compiled Wasm of a JS file' ],
|
31
|
-
})) {
|
32
|
-
console.log(` \x1B[1m\x1B[${color}m${cmd}\x1B[0m${' '.repeat(20 - cmd.length - (desc.startsWith('๐งช') ? 3 : 0))}${desc}`);
|
43
|
+
console.log(` \x1B[90mporf\x1B[0m \x1B[1m\x1B[${color}m${cmd}\x1B[0m\x1B[2m${post}\x1B[0m ${' '.repeat(30 - cmd.length - post.length)}${desc}`);
|
33
44
|
}
|
34
45
|
|
35
|
-
// console.log();
|
36
|
-
|
37
|
-
// // options
|
38
|
-
// console.log(`\n\u001b[4mCommands\x1B[0m`);
|
39
|
-
// for (const [ cmd, [ color, desc ] ] of Object.entries({
|
40
|
-
// run: [ 34, 'Run a JS file' ],
|
41
|
-
// wasm: [ 34, 'Compile a JS file to a Wasm binary\n' ],
|
42
|
-
// c: [ 31, 'Compile a JS file to C source code' ],
|
43
|
-
// native: [ 31, 'Compile a JS file to a native binary\n' ],
|
44
|
-
// profile: [ 33, 'Profile a JS file' ],
|
45
|
-
// debug: [ 33, 'Debug a JS file' ],
|
46
|
-
// 'debug-wasm': [ 33, 'Debug the compiled Wasm of a JS file' ]
|
47
|
-
// })) {
|
48
|
-
// console.log(` \x1B[1m\x1B[${color}m${cmd}\x1B[0m${' '.repeat(20 - cmd.length - (desc.startsWith('๐งช') ? 3 : 0))}${desc}`);
|
49
|
-
// }
|
50
|
-
|
51
46
|
console.log();
|
52
47
|
process.exit(0);
|
53
48
|
}
|
@@ -59,7 +54,7 @@ const done = async () => {
|
|
59
54
|
};
|
60
55
|
|
61
56
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
62
|
-
if (['precompile', 'run', 'wasm', 'native', 'c', '
|
57
|
+
if (['precompile', 'run', 'wasm', 'native', 'c', 'hotlines', 'debug', 'dissect'].includes(file)) {
|
63
58
|
// remove this arg
|
64
59
|
process.argv.splice(process.argv.indexOf(file), 1);
|
65
60
|
|
@@ -68,8 +63,8 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm
|
|
68
63
|
await done();
|
69
64
|
}
|
70
65
|
|
71
|
-
if (file === '
|
72
|
-
await import('./
|
66
|
+
if (file === 'hotlines') {
|
67
|
+
await import('./hotlines.js');
|
73
68
|
await done();
|
74
69
|
}
|
75
70
|
|
@@ -82,7 +77,7 @@ if (['precompile', 'run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm
|
|
82
77
|
process.argv.push(`--target=${file}`);
|
83
78
|
}
|
84
79
|
|
85
|
-
if (file === '
|
80
|
+
if (file === 'dissect') {
|
86
81
|
process.argv.push('--asur', '--wasm-debug');
|
87
82
|
}
|
88
83
|
|
File without changes
|