porffor 0.14.0-b481bfc5f → 0.14.0-b880d42f1
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 +4 -2
- package/compiler/2c.js +65 -2
- package/compiler/assemble.js +14 -0
- package/compiler/builtins/annexb_string.ts +1 -0
- package/compiler/builtins/array.ts +78 -0
- package/compiler/builtins/base64.ts +1 -0
- package/compiler/builtins/boolean.ts +2 -0
- package/compiler/builtins/crypto.ts +1 -0
- package/compiler/builtins/date.ts +2 -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/set.ts +2 -0
- package/compiler/builtins/string.ts +1 -0
- package/compiler/builtins/symbol.ts +2 -0
- package/compiler/builtins.js +26 -4
- package/compiler/codegen.js +241 -154
- package/compiler/generated_builtins.js +318 -31
- package/compiler/index.js +1 -1
- package/compiler/parse.js +1 -1
- package/compiler/precompile.js +5 -4
- package/package.json +1 -1
- package/runner/index.js +4 -3
package/compiler/index.js
CHANGED
@@ -84,7 +84,7 @@ export default (code, flags) => {
|
|
84
84
|
else compiler = [ compiler ];
|
85
85
|
|
86
86
|
const tmpfile = 'porffor_tmp.c';
|
87
|
-
const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-march=native', '-s', '-ffast-math', '-fno-exceptions' ];
|
87
|
+
const args = [ ...compiler, tmpfile, '-o', outFile ?? (process.platform === 'win32' ? 'out.exe' : 'out'), '-' + cO, '-flto=thin', '-march=native', '-s', '-ffast-math', '-fno-exceptions', '-fno-ident', '-fno-asynchronous-unwind-tables', '-ffunction-sections', '-fdata-sections', '-Wl,--gc-sections' ];
|
88
88
|
|
89
89
|
const c = toc(out);
|
90
90
|
fs.writeFileSync(tmpfile, c);
|
package/compiler/parse.js
CHANGED
@@ -7,7 +7,7 @@ if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
|
|
7
7
|
globalThis.process = { argv: ['', '', ...Deno.args], stdout: { write: str => Deno.writeAllSync(Deno.stdout, textEncoder.encode(str)) } };
|
8
8
|
}
|
9
9
|
|
10
|
-
const file = process.argv.slice(2).find(x => x[0] !== '-');
|
10
|
+
const file = process.argv.slice(2).find(x => x[0] !== '-' && !['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(x));
|
11
11
|
|
12
12
|
// should we try to support types (while parsing)
|
13
13
|
const types = Prefs.parseTypes || file?.endsWith('.ts');
|
package/compiler/precompile.js
CHANGED
@@ -18,9 +18,9 @@ const compile = async (file, [ _funcs, _globals ]) => {
|
|
18
18
|
first = source.slice(0, source.indexOf('\n'));
|
19
19
|
}
|
20
20
|
|
21
|
-
let args = ['--bytestring', '--todo-time=compile', '--
|
21
|
+
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'];
|
22
22
|
if (first.startsWith('// @porf')) {
|
23
|
-
args =
|
23
|
+
args = first.slice('// @porf '.length).split(' ').concat(args);
|
24
24
|
}
|
25
25
|
process.argv = argv.concat(args);
|
26
26
|
|
@@ -111,8 +111,9 @@ ${funcs.map(x => {
|
|
111
111
|
${x.returnType != null ? `returnType: ${JSON.stringify(x.returnType)}` : 'typedReturns: true'},
|
112
112
|
locals: ${JSON.stringify(Object.values(x.locals).slice(x.params.length).map(x => x.type))},
|
113
113
|
localNames: ${JSON.stringify(Object.keys(x.locals))},
|
114
|
-
${x.data && x.data.length > 0 ? ` data: ${JSON.stringify(x.data)}
|
115
|
-
|
114
|
+
${x.data && x.data.length > 0 ? ` data: ${JSON.stringify(x.data)},` : ''}
|
115
|
+
${x.table ? ` table: true` : ''}
|
116
|
+
};`.replaceAll('\n\n', '\n').replaceAll('\n\n', '\n').replaceAll('\n\n', '\n');
|
116
117
|
}).join('\n')}
|
117
118
|
};`;
|
118
119
|
};
|
package/package.json
CHANGED
package/runner/index.js
CHANGED
@@ -60,8 +60,10 @@ if (process.argv.includes('--help')) {
|
|
60
60
|
|
61
61
|
let file = process.argv.slice(2).find(x => x[0] !== '-');
|
62
62
|
if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(file)) {
|
63
|
+
// remove this arg
|
64
|
+
process.argv.splice(process.argv.indexOf(file), 1);
|
65
|
+
|
63
66
|
if (file === 'profile') {
|
64
|
-
process.argv.splice(process.argv.indexOf(file), 1);
|
65
67
|
await import('./profiler.js');
|
66
68
|
await new Promise(() => {}); // do nothing for the rest of this file
|
67
69
|
}
|
@@ -75,12 +77,11 @@ if (['run', 'wasm', 'native', 'c', 'profile', 'debug', 'debug-wasm'].includes(fi
|
|
75
77
|
}
|
76
78
|
|
77
79
|
if (file === 'debug') {
|
78
|
-
process.argv.splice(process.argv.indexOf(file), 1);
|
79
80
|
await import('./debug.js');
|
80
81
|
await new Promise(() => {}); // do nothing for the rest of this file
|
81
82
|
}
|
82
83
|
|
83
|
-
file = process.argv.slice(
|
84
|
+
file = process.argv.slice(2).find(x => x[0] !== '-');
|
84
85
|
|
85
86
|
const nonOptOutFile = process.argv.slice(process.argv.indexOf(file) + 1).find(x => x[0] !== '-');
|
86
87
|
if (nonOptOutFile) {
|