jz 0.1.1 → 0.2.1
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 +256 -90
- package/cli.js +34 -8
- package/index.js +100 -14
- package/module/array.js +396 -133
- package/module/collection.js +455 -212
- package/module/console.js +169 -88
- package/module/core.js +246 -144
- package/module/date.js +783 -0
- package/module/function.js +81 -21
- package/module/index.js +2 -1
- package/module/json.js +483 -138
- package/module/math.js +79 -39
- package/module/number.js +188 -78
- package/module/object.js +227 -47
- package/module/regex.js +33 -30
- package/module/schema.js +14 -17
- package/module/string.js +439 -235
- package/module/symbol.js +4 -3
- package/module/timer.js +89 -31
- package/module/typedarray.js +174 -44
- package/package.json +3 -10
- package/src/analyze.js +627 -133
- package/src/autoload.js +15 -7
- package/src/compile.js +399 -70
- package/src/ctx.js +41 -12
- package/src/emit.js +658 -145
- package/src/host.js +244 -51
- package/src/ir.js +87 -31
- package/src/jzify.js +181 -24
- package/src/narrow.js +32 -4
- package/src/optimize.js +628 -42
- package/src/plan.js +1167 -4
- package/src/prepare.js +322 -75
- package/src/vectorize.js +1016 -0
- package/wasi.js +13 -0
- package/src/key.js +0 -73
- package/src/source.js +0 -76
package/src/autoload.js
CHANGED
|
@@ -14,7 +14,7 @@ export const PROP_MODULES = Object.assign(Object.create(null), {
|
|
|
14
14
|
every: ['core', 'array'], some: ['core', 'array'], flat: ['core', 'array'], flatMap: ['core', 'array'],
|
|
15
15
|
join: ['core', 'array'], copyWithin: ['core', 'array'], at: ['core', 'array'],
|
|
16
16
|
charAt: ['core', 'string'], charCodeAt: ['core', 'string'], codePointAt: ['core', 'string'],
|
|
17
|
-
toUpperCase: ['core', 'string'], toLowerCase: ['core', 'string'], trim: ['core', 'string'],
|
|
17
|
+
toUpperCase: ['core', 'string'], toLowerCase: ['core', 'string'], toLocaleLowerCase: ['core', 'string'], trim: ['core', 'string'],
|
|
18
18
|
trimStart: ['core', 'string'], trimEnd: ['core', 'string'],
|
|
19
19
|
split: ['core', 'string'], replace: ['core', 'string'], replaceAll: ['core', 'string'],
|
|
20
20
|
repeat: ['core', 'string'], startsWith: ['core', 'string'], endsWith: ['core', 'string'],
|
|
@@ -61,10 +61,15 @@ export const CALL_MODULES = dict({
|
|
|
61
61
|
'console.warn': ['core', 'string', 'number', 'console'],
|
|
62
62
|
'console.error': ['core', 'string', 'number', 'console'],
|
|
63
63
|
'Object.fromEntries': ['collection', 'string'],
|
|
64
|
-
'Object.keys': ['string'],
|
|
65
|
-
'Object.
|
|
64
|
+
'Object.keys': ['core', 'object', 'string'],
|
|
65
|
+
'Object.values': ['core', 'object', 'string'],
|
|
66
|
+
'Object.entries': ['core', 'object', 'string'],
|
|
67
|
+
'Object.assign': ['core', 'object'],
|
|
68
|
+
'Object.create': ['core', 'object'],
|
|
69
|
+
'Date.UTC': ['core', 'date'],
|
|
66
70
|
'Date.now': ['core', 'console'],
|
|
67
71
|
'performance.now': ['core', 'console'],
|
|
72
|
+
'readStdin': ['core', 'console'],
|
|
68
73
|
'String.fromCharCode': ['core', 'string'],
|
|
69
74
|
'String.fromCodePoint': ['core', 'string'],
|
|
70
75
|
'BigInt.asIntN': ['number'],
|
|
@@ -85,14 +90,15 @@ export const GENERIC_METHOD_MODULES = dict({
|
|
|
85
90
|
toFixed: ['core', 'string', 'number'],
|
|
86
91
|
toPrecision: ['core', 'string', 'number'],
|
|
87
92
|
toExponential: ['core', 'string', 'number'],
|
|
93
|
+
hasOwnProperty: ['core', 'object', 'string', 'collection'],
|
|
88
94
|
})
|
|
89
95
|
|
|
90
|
-
export const CTORS = ['Float64Array','Float32Array','Int32Array','Uint32Array','Int16Array','Uint16Array','Int8Array','Uint8Array','BigInt64Array','BigUint64Array','Set','Map']
|
|
96
|
+
export const CTORS = ['Float64Array','Float32Array','Int32Array','Uint32Array','Int16Array','Uint16Array','Int8Array','Uint8Array','BigInt64Array','BigUint64Array','Set','Map','Date']
|
|
91
97
|
export const TYPED_CTORS = ['Float64Array','Float32Array','Int32Array','Uint32Array','Int16Array','Uint16Array','Int8Array','Uint8Array','BigInt64Array','BigUint64Array','ArrayBuffer','DataView']
|
|
92
98
|
export const COLLECTION_CTORS = ['Set', 'Map']
|
|
93
99
|
export const TIMER_NAMES = new Set(['setTimeout', 'clearTimeout', 'setInterval', 'clearInterval'])
|
|
94
100
|
|
|
95
|
-
export const MOD_ALIAS = { Number: 'number', Array: 'array', Object: 'object', Symbol: 'symbol', JSON: 'json', BigInt: 'number', Error: 'core', TextEncoder: 'string', TextDecoder: 'string' }
|
|
101
|
+
export const MOD_ALIAS = { Number: 'number', Array: 'array', Object: 'object', Symbol: 'symbol', JSON: 'json', Date: 'date', BigInt: 'number', Error: 'core', TextEncoder: 'string', TextDecoder: 'string' }
|
|
96
102
|
|
|
97
103
|
const MOD_DEPS = {
|
|
98
104
|
number: ['core', 'string'],
|
|
@@ -102,6 +108,7 @@ const MOD_DEPS = {
|
|
|
102
108
|
collection: ['core', 'number'],
|
|
103
109
|
symbol: ['core'],
|
|
104
110
|
json: ['core', 'string', 'number', 'collection'],
|
|
111
|
+
date: ['core', 'number', 'string'],
|
|
105
112
|
console: ['core', 'string', 'number'],
|
|
106
113
|
regex: ['core', 'string', 'array'],
|
|
107
114
|
}
|
|
@@ -155,12 +162,13 @@ export const includeForProperty = prop => {
|
|
|
155
162
|
}
|
|
156
163
|
|
|
157
164
|
export const runtimeCtorKind = name =>
|
|
158
|
-
TYPED_CTORS.includes(name) ? 'typedarray' : COLLECTION_CTORS.includes(name) ? 'collection' : null
|
|
165
|
+
TYPED_CTORS.includes(name) ? 'typedarray' : COLLECTION_CTORS.includes(name) ? 'collection' : name === 'Date' ? 'date' : null
|
|
159
166
|
|
|
160
167
|
export const includeForRuntimeCtor = name => {
|
|
161
168
|
const kind = runtimeCtorKind(name)
|
|
162
169
|
if (kind === 'typedarray') includeMods('core', 'typedarray')
|
|
163
170
|
else if (kind === 'collection') includeMods('core', 'collection')
|
|
171
|
+
else if (kind === 'date') includeMods('core', 'console', 'date')
|
|
164
172
|
return kind
|
|
165
173
|
}
|
|
166
174
|
|
|
@@ -172,4 +180,4 @@ export function includeModule(name) {
|
|
|
172
180
|
ctx.module.modules[modName] = true
|
|
173
181
|
for (const dep of MOD_DEPS[modName] || []) includeModule(dep)
|
|
174
182
|
init(ctx)
|
|
175
|
-
}
|
|
183
|
+
}
|