jz 0.5.1 → 0.7.0
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 +315 -318
- package/bench/README.md +369 -0
- package/bench/bench.svg +102 -0
- package/cli.js +104 -30
- package/dist/interop.js +1 -0
- package/dist/jz.js +6024 -0
- package/index.d.ts +126 -0
- package/index.js +362 -84
- package/interop.js +159 -186
- package/jz.svg +5 -0
- package/jzify/arguments.js +97 -0
- package/jzify/bundler.js +382 -0
- package/jzify/classes.js +328 -0
- package/jzify/hoist-vars.js +177 -0
- package/jzify/index.js +51 -0
- package/jzify/names.js +37 -0
- package/jzify/switch.js +106 -0
- package/jzify/transform.js +349 -0
- package/layout.js +184 -0
- package/module/array.js +377 -176
- package/module/collection.js +639 -145
- package/module/console.js +55 -43
- package/module/core.js +264 -153
- package/module/date.js +15 -3
- package/module/function.js +73 -6
- package/module/index.js +2 -1
- package/module/json.js +226 -61
- package/module/math.js +551 -187
- package/module/number.js +327 -60
- package/module/object.js +474 -184
- package/module/regex.js +255 -25
- package/module/schema.js +24 -6
- package/module/simd.js +117 -0
- package/module/string.js +621 -226
- package/module/symbol.js +1 -1
- package/module/timer.js +9 -14
- package/module/typedarray.js +459 -73
- package/package.json +58 -14
- package/src/abi/index.js +39 -23
- package/src/abi/string.js +38 -41
- package/src/ast.js +460 -0
- package/src/autoload.js +29 -24
- package/src/bridge.js +111 -0
- package/src/compile/analyze-scans.js +824 -0
- package/src/compile/analyze.js +1600 -0
- package/src/compile/emit-assign.js +411 -0
- package/src/compile/emit.js +3512 -0
- package/src/compile/flow-types.js +103 -0
- package/src/{compile.js → compile/index.js} +778 -128
- package/src/{infer.js → compile/infer.js} +62 -98
- package/src/compile/loop-divmod.js +155 -0
- package/src/{narrow.js → compile/narrow.js} +409 -106
- package/src/compile/peel-stencil.js +261 -0
- package/src/compile/plan/advise.js +370 -0
- package/src/compile/plan/common.js +150 -0
- package/src/compile/plan/index.js +122 -0
- package/src/compile/plan/inline.js +682 -0
- package/src/compile/plan/literals.js +1199 -0
- package/src/compile/plan/loops.js +472 -0
- package/src/compile/plan/scope.js +649 -0
- package/src/compile/program-facts.js +423 -0
- package/src/ctx.js +220 -64
- package/src/ir.js +589 -172
- package/src/kind-traits.js +132 -0
- package/src/kind.js +524 -0
- package/src/op-policy.js +57 -0
- package/src/{optimize.js → optimize/index.js} +1432 -473
- package/src/optimize/vectorize.js +4660 -0
- package/src/param-reps.js +65 -0
- package/src/parse.js +44 -0
- package/src/{prepare.js → prepare/index.js} +649 -205
- package/src/prepare/lift-iife.js +149 -0
- package/src/reps.js +116 -0
- package/src/resolve.js +12 -3
- package/src/static.js +208 -0
- package/src/type.js +651 -0
- package/src/{assemble.js → wat/assemble.js} +275 -55
- package/src/wat/optimize.js +3938 -0
- package/transform.js +21 -0
- package/wasi.js +47 -5
- package/src/analyze.js +0 -3818
- package/src/emit.js +0 -3040
- package/src/jzify.js +0 -1580
- package/src/plan.js +0 -2132
- package/src/vectorize.js +0 -1088
- /package/src/{codegen.js → wat/codegen.js} +0 -0
package/src/op-policy.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared op policy for jzify (transform) and prepare (reject).
|
|
3
|
+
*
|
|
4
|
+
* `.jz` source bypasses jzify, so prepare must enforce reject rules for both paths.
|
|
5
|
+
* jzify lowers `var`/`function`/`class`/`arguments` before prepare; prepare rejects
|
|
6
|
+
* survivors. Identifiers (`this`, `eval`, …) have no safe lowering in either pass.
|
|
7
|
+
*
|
|
8
|
+
* @module op-policy
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Ops prepare rejects when they appear in the AST (handler or identifier). */
|
|
12
|
+
export const REJECT_OPS = {
|
|
13
|
+
async: 'async/await not supported: WASM is synchronous',
|
|
14
|
+
await: 'async/await not supported: WASM is synchronous',
|
|
15
|
+
class: 'class not supported: use object literals',
|
|
16
|
+
yield: 'generators not supported: use loops',
|
|
17
|
+
instanceof: 'instanceof not supported: use typeof',
|
|
18
|
+
with: '`with` not supported: deprecated',
|
|
19
|
+
':': 'labeled statements not supported',
|
|
20
|
+
var: '`var` not supported: use let/const',
|
|
21
|
+
function: '`function` not supported: use arrow functions',
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** Bare identifiers prepare rejects (no jzify lowering). */
|
|
25
|
+
export const REJECT_IDENTS = {
|
|
26
|
+
with: '`with` not supported',
|
|
27
|
+
class: '`class` not supported',
|
|
28
|
+
yield: '`yield` not supported',
|
|
29
|
+
this: '`this` not supported: use explicit parameter',
|
|
30
|
+
super: '`super` not supported: no class inheritance',
|
|
31
|
+
arguments: '`arguments` not supported: use rest params',
|
|
32
|
+
eval: '`eval` not supported',
|
|
33
|
+
// `const` is an always-reserved word (like `class`/`with` above) — never a valid
|
|
34
|
+
// binding/identifier name in any mode; subscript parses it as a plain identifier,
|
|
35
|
+
// so reject it. NOT `let`: `let` is only *strict-mode* reserved and is a legal
|
|
36
|
+
// identifier in sloppy JS (`var let = 5`), so rejecting it would refuse valid JS
|
|
37
|
+
// (test262 language/expressions/object/let-non-strict-*).
|
|
38
|
+
const: '`const` is a reserved word, not a valid name',
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** jzify-only errors for class lowering (no prepare counterpart). */
|
|
42
|
+
export const JZIFY_CLASS_ERRORS = {
|
|
43
|
+
computedMember: 'non-constant computed class member names are not supported',
|
|
44
|
+
computedStaticField: 'non-constant computed static class fields are not supported',
|
|
45
|
+
computedField: 'non-constant computed/destructured class fields are not supported',
|
|
46
|
+
computedStaticMember: 'non-constant computed static class member names are not supported',
|
|
47
|
+
accessor: 'class getters/setters are not supported — jz objects have no accessors',
|
|
48
|
+
staticMember: '`static` class members are not supported yet',
|
|
49
|
+
superProp: '`super` property access is not supported yet',
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Build prepare handler map from shared reject messages. */
|
|
53
|
+
export function rejectHandlers(errFn) {
|
|
54
|
+
const out = {}
|
|
55
|
+
for (const [op, msg] of Object.entries(REJECT_OPS)) out[op] = () => errFn(msg)
|
|
56
|
+
return out
|
|
57
|
+
}
|