yuku-codegen 0.5.19 → 0.5.21
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/encode.js +16 -29
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/package.json +13 -13
package/encode.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
// generated by tools/gen_estree_encoder.zig, do not edit
|
|
2
|
-
//
|
|
3
|
-
// Encodes an ESTree object into the Yuku transfer-format buffer.
|
|
4
2
|
const NULL = 0xFFFFFFFF;
|
|
5
3
|
const _enc = new TextEncoder();
|
|
6
4
|
const NODE_SIZE = 48;
|
|
@@ -147,7 +145,6 @@ function encode(program, lineStarts) {
|
|
|
147
145
|
}
|
|
148
146
|
function asStart(n) { return (n && typeof n.start === "number") ? n.start : 0; }
|
|
149
147
|
function asEnd(n) { return (n && typeof n.end === "number") ? n.end : 0; }
|
|
150
|
-
// called by every enc_* to register the node's `.comments` array
|
|
151
148
|
function recordComments(n, idx) {
|
|
152
149
|
if (idx !== NULL && n && Array.isArray(n.comments) && n.comments.length > 0) {
|
|
153
150
|
commentsByIdx.set(idx, n.comments);
|
|
@@ -162,7 +159,7 @@ function encode(program, lineStarts) {
|
|
|
162
159
|
if (n == null) return NULL;
|
|
163
160
|
return enc_label_identifier(n);
|
|
164
161
|
}
|
|
165
|
-
function
|
|
162
|
+
function encName(n) {
|
|
166
163
|
if (n == null) return NULL;
|
|
167
164
|
if (n.type === "Identifier") return enc_identifier_name(n);
|
|
168
165
|
return encNode(n);
|
|
@@ -372,7 +369,7 @@ function encode(program, lineStarts) {
|
|
|
372
369
|
function enc_object_property(n) {
|
|
373
370
|
const k = n.key == null
|
|
374
371
|
? NULL
|
|
375
|
-
: (n.computed ? encNode(n.key) :
|
|
372
|
+
: (n.computed ? encNode(n.key) : encName(n.key));
|
|
376
373
|
const v = n.value == null ? NULL : encNode(n.value);
|
|
377
374
|
const idx = alloc();
|
|
378
375
|
tagAt(idx, 17);
|
|
@@ -390,7 +387,7 @@ function encode(program, lineStarts) {
|
|
|
390
387
|
const o = n.object == null ? NULL : encNode(n.object);
|
|
391
388
|
const p = n.property == null
|
|
392
389
|
? NULL
|
|
393
|
-
: (n.computed ? encNode(n.property) :
|
|
390
|
+
: (n.computed ? encNode(n.property) : encName(n.property));
|
|
394
391
|
const idx = alloc();
|
|
395
392
|
tagAt(idx, 18);
|
|
396
393
|
slotAt(idx, 0, o); slotAt(idx, 1, p);
|
|
@@ -525,7 +522,7 @@ function encode(program, lineStarts) {
|
|
|
525
522
|
}
|
|
526
523
|
function enc_method_definition(n, abstract) {
|
|
527
524
|
const decs = encArr(n.decorators, encNode);
|
|
528
|
-
const k = n.computed ? encNode(n.key) :
|
|
525
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
529
526
|
const v = encNode(n.value);
|
|
530
527
|
const idx = alloc();
|
|
531
528
|
tagAt(idx, 29);
|
|
@@ -547,7 +544,7 @@ function encode(program, lineStarts) {
|
|
|
547
544
|
}
|
|
548
545
|
function enc_property_definition(n, accessor, abstract) {
|
|
549
546
|
const decs = encArr(n.decorators, encNode);
|
|
550
|
-
const k = n.computed ? encNode(n.key) :
|
|
547
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
551
548
|
const v = n.value == null ? NULL : encNode(n.value);
|
|
552
549
|
const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
|
|
553
550
|
const idx = alloc();
|
|
@@ -1066,7 +1063,7 @@ function encode(program, lineStarts) {
|
|
|
1066
1063
|
function enc_binding_property(p) {
|
|
1067
1064
|
const k = p.key == null
|
|
1068
1065
|
? NULL
|
|
1069
|
-
: (p.computed ? encNode(p.key) :
|
|
1066
|
+
: (p.computed ? encNode(p.key) : encName(p.key));
|
|
1070
1067
|
const v = p.value == null ? NULL : encBindingTarget(p.value);
|
|
1071
1068
|
const idx = alloc();
|
|
1072
1069
|
tagAt(idx, 73);
|
|
@@ -1119,7 +1116,7 @@ function encode(program, lineStarts) {
|
|
|
1119
1116
|
return idx;
|
|
1120
1117
|
}
|
|
1121
1118
|
function enc_import_specifier(n) {
|
|
1122
|
-
const c_imported = n.imported == null ? NULL :
|
|
1119
|
+
const c_imported = n.imported == null ? NULL : encName(n.imported);
|
|
1123
1120
|
const c_local = n.local == null ? NULL : encBindingTarget(n.local);
|
|
1124
1121
|
const idx = alloc();
|
|
1125
1122
|
tagAt(idx, 77);
|
|
@@ -1149,7 +1146,7 @@ function encode(program, lineStarts) {
|
|
|
1149
1146
|
return idx;
|
|
1150
1147
|
}
|
|
1151
1148
|
function enc_import_attribute(n) {
|
|
1152
|
-
const c_key = n.key == null ? NULL :
|
|
1149
|
+
const c_key = n.key == null ? NULL : encName(n.key);
|
|
1153
1150
|
const c_value = n.value == null ? NULL : encNode(n.value);
|
|
1154
1151
|
const idx = alloc();
|
|
1155
1152
|
tagAt(idx, 80);
|
|
@@ -1187,7 +1184,7 @@ function encode(program, lineStarts) {
|
|
|
1187
1184
|
return idx;
|
|
1188
1185
|
}
|
|
1189
1186
|
function enc_export_all_declaration(n) {
|
|
1190
|
-
const c_exported = n.exported == null ? NULL :
|
|
1187
|
+
const c_exported = n.exported == null ? NULL : encName(n.exported);
|
|
1191
1188
|
const c_source = n.source == null ? NULL : encNode(n.source);
|
|
1192
1189
|
const c_attributes = encArr(n.attributes, encNode);
|
|
1193
1190
|
const idx = alloc();
|
|
@@ -1203,7 +1200,7 @@ function encode(program, lineStarts) {
|
|
|
1203
1200
|
}
|
|
1204
1201
|
function enc_export_specifier(n) {
|
|
1205
1202
|
const c_local = n.local == null ? NULL : encNode(n.local);
|
|
1206
|
-
const c_exported = n.exported == null ? NULL :
|
|
1203
|
+
const c_exported = n.exported == null ? NULL : encName(n.exported);
|
|
1207
1204
|
const idx = alloc();
|
|
1208
1205
|
tagAt(idx, 84);
|
|
1209
1206
|
slotAt(idx, 0, c_local);
|
|
@@ -1333,7 +1330,7 @@ function encode(program, lineStarts) {
|
|
|
1333
1330
|
}
|
|
1334
1331
|
function enc_ts_qualified_name(n) {
|
|
1335
1332
|
const c_left = n.left == null ? NULL : encNode(n.left);
|
|
1336
|
-
const c_right = n.right == null ? NULL :
|
|
1333
|
+
const c_right = n.right == null ? NULL : encName(n.right);
|
|
1337
1334
|
const idx = alloc();
|
|
1338
1335
|
tagAt(idx, 101);
|
|
1339
1336
|
slotAt(idx, 0, c_left);
|
|
@@ -1356,7 +1353,7 @@ function encode(program, lineStarts) {
|
|
|
1356
1353
|
function enc_ts_import_type(n) {
|
|
1357
1354
|
const c_source = n.source == null ? NULL : encNode(n.source);
|
|
1358
1355
|
const c_options = n.options == null ? NULL : encNode(n.options);
|
|
1359
|
-
const c_qualifier = n.qualifier == null ? NULL :
|
|
1356
|
+
const c_qualifier = n.qualifier == null ? NULL : encName(n.qualifier);
|
|
1360
1357
|
const c_type_arguments = n.typeArguments == null ? NULL : encNode(n.typeArguments);
|
|
1361
1358
|
const idx = alloc();
|
|
1362
1359
|
tagAt(idx, 103);
|
|
@@ -1635,7 +1632,7 @@ function encode(program, lineStarts) {
|
|
|
1635
1632
|
return idx;
|
|
1636
1633
|
}
|
|
1637
1634
|
function enc_ts_property_signature(n) {
|
|
1638
|
-
const k = n.computed ? encNode(n.key) :
|
|
1635
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
1639
1636
|
const ta = n.typeAnnotation == null ? NULL : encNode(n.typeAnnotation);
|
|
1640
1637
|
const idx = alloc();
|
|
1641
1638
|
tagAt(idx, 129);
|
|
@@ -1649,7 +1646,7 @@ function encode(program, lineStarts) {
|
|
|
1649
1646
|
return idx;
|
|
1650
1647
|
}
|
|
1651
1648
|
function enc_ts_method_signature(n) {
|
|
1652
|
-
const k = n.computed ? encNode(n.key) :
|
|
1649
|
+
const k = n.computed ? encNode(n.key) : encName(n.key);
|
|
1653
1650
|
const tp = n.typeParameters == null ? NULL : encNode(n.typeParameters);
|
|
1654
1651
|
const params = encFormalParameters(n.params);
|
|
1655
1652
|
const rt_ = n.returnType == null ? NULL : encNode(n.returnType);
|
|
@@ -1788,7 +1785,7 @@ function encode(program, lineStarts) {
|
|
|
1788
1785
|
return idx;
|
|
1789
1786
|
}
|
|
1790
1787
|
function enc_ts_enum_member(n) {
|
|
1791
|
-
const id = n.computed ? encNode(n.id) :
|
|
1788
|
+
const id = n.computed ? encNode(n.id) : encName(n.id);
|
|
1792
1789
|
const init = n.initializer == null ? NULL : encNode(n.initializer);
|
|
1793
1790
|
const idx = alloc();
|
|
1794
1791
|
tagAt(idx, 141);
|
|
@@ -2098,19 +2095,11 @@ function encode(program, lineStarts) {
|
|
|
2098
2095
|
recordComments(n, idx);
|
|
2099
2096
|
return idx;
|
|
2100
2097
|
}
|
|
2101
|
-
// encoded node index -> its `.comments` array
|
|
2102
2098
|
const commentsByIdx = new Map();
|
|
2103
2099
|
function encNode(n) {
|
|
2104
2100
|
if (n == null) return NULL;
|
|
2105
2101
|
switch (n.type) {
|
|
2106
|
-
case "Identifier":
|
|
2107
|
-
switch (n.kind) {
|
|
2108
|
-
case "binding": return enc_binding_identifier(n);
|
|
2109
|
-
case "name": return enc_identifier_name(n);
|
|
2110
|
-
case "label": return enc_label_identifier(n);
|
|
2111
|
-
default: return enc_identifier_reference(n);
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2102
|
+
case "Identifier": return enc_identifier_reference(n);
|
|
2114
2103
|
case "PrivateIdentifier": return enc_private_identifier(n);
|
|
2115
2104
|
case "Literal": {
|
|
2116
2105
|
if (n.regex) return enc_regexp_literal(n);
|
|
@@ -2294,8 +2283,6 @@ function encode(program, lineStarts) {
|
|
|
2294
2283
|
}
|
|
2295
2284
|
const progIdx = encNode(root);
|
|
2296
2285
|
const POSITION_INV = { "before": 0, "after": 1, "inside": 2 };
|
|
2297
|
-
// counting-sort attached comments by host into a prefix-sum offsets
|
|
2298
|
-
// table, then write each at its slot in `attachedBytes`.
|
|
2299
2286
|
const attached = commentsByIdx.size > 0;
|
|
2300
2287
|
let attachedCount = 0;
|
|
2301
2288
|
let offsetsBytes = null;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -7,11 +7,9 @@ function normalizeOptions(options) {
|
|
|
7
7
|
const c = next.comments;
|
|
8
8
|
if (c === true) next.comments = "all";
|
|
9
9
|
else if (c === false) next.comments = "none";
|
|
10
|
-
// `lineStarts` is consumed by the encoder, not the native binding, so strip
|
|
11
|
-
// it from the source-map options. Only V3 metadata reaches the binding.
|
|
12
10
|
const s = next.sourceMaps;
|
|
13
11
|
if (s) {
|
|
14
|
-
const { lineStarts, ...meta } = s;
|
|
12
|
+
const { lineStarts: _, ...meta } = s;
|
|
15
13
|
next.sourceMaps = meta;
|
|
16
14
|
} else {
|
|
17
15
|
next.sourceMaps = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yuku-codegen",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.21",
|
|
4
4
|
"description": "High-performance JavaScript/TypeScript code generator written in Zig",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
"encode.js"
|
|
18
18
|
],
|
|
19
19
|
"optionalDependencies": {
|
|
20
|
-
"@yuku-codegen/binding-linux-x64-gnu": "0.5.
|
|
21
|
-
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.
|
|
22
|
-
"@yuku-codegen/binding-linux-arm-gnu": "0.5.
|
|
23
|
-
"@yuku-codegen/binding-linux-x64-musl": "0.5.
|
|
24
|
-
"@yuku-codegen/binding-linux-arm64-musl": "0.5.
|
|
25
|
-
"@yuku-codegen/binding-linux-arm-musl": "0.5.
|
|
26
|
-
"@yuku-codegen/binding-darwin-x64": "0.5.
|
|
27
|
-
"@yuku-codegen/binding-darwin-arm64": "0.5.
|
|
28
|
-
"@yuku-codegen/binding-win32-x64": "0.5.
|
|
29
|
-
"@yuku-codegen/binding-win32-arm64": "0.5.
|
|
30
|
-
"@yuku-codegen/binding-freebsd-x64": "0.5.
|
|
20
|
+
"@yuku-codegen/binding-linux-x64-gnu": "0.5.21",
|
|
21
|
+
"@yuku-codegen/binding-linux-arm64-gnu": "0.5.21",
|
|
22
|
+
"@yuku-codegen/binding-linux-arm-gnu": "0.5.21",
|
|
23
|
+
"@yuku-codegen/binding-linux-x64-musl": "0.5.21",
|
|
24
|
+
"@yuku-codegen/binding-linux-arm64-musl": "0.5.21",
|
|
25
|
+
"@yuku-codegen/binding-linux-arm-musl": "0.5.21",
|
|
26
|
+
"@yuku-codegen/binding-darwin-x64": "0.5.21",
|
|
27
|
+
"@yuku-codegen/binding-darwin-arm64": "0.5.21",
|
|
28
|
+
"@yuku-codegen/binding-win32-x64": "0.5.21",
|
|
29
|
+
"@yuku-codegen/binding-win32-arm64": "0.5.21",
|
|
30
|
+
"@yuku-codegen/binding-freebsd-x64": "0.5.21"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
33
33
|
"ast",
|
|
@@ -40,6 +40,6 @@
|
|
|
40
40
|
"typescript"
|
|
41
41
|
],
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"yuku-parser": "0.5.
|
|
43
|
+
"yuku-parser": "0.5.19"
|
|
44
44
|
}
|
|
45
45
|
}
|