parseman 0.61.2 → 0.61.3
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/dist/analysis/diagnostics.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/index.js +26 -17
- package/dist/index.js.map +2 -2
- package/dist/plugin/evaluator.d.ts.map +1 -1
- package/dist/plugin/index.d.ts +7 -3
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +93 -38
- package/dist/plugin/index.js.map +3 -3
- package/dist/table/compile-rule-map.d.ts.map +1 -1
- package/dist/table/index.js +26 -17
- package/dist/table/index.js.map +1 -1
- package/dist/table/select-hot.d.ts +20 -1
- package/dist/table/select-hot.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/plugin/evaluator.ts +42 -2
- package/src/plugin/index.ts +37 -13
- package/src/table/compile-rule-map.ts +8 -21
- package/src/table/select-hot.ts +35 -4
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAwC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/plugin/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,UAAU,EAAE,IAAI,EAMjB,MAAM,oBAAoB,CAAA;AAC3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAG7C,OAAO,EAAwC,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,0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+71,13 @@ export type ParsecraftPluginOptions = {
|
|
|
71
71
|
*/
|
|
72
72
|
assemblyProfile?: AssemblyProfile;
|
|
73
73
|
/**
|
|
74
|
-
* Generated assembly bytes each module may spend, as a multiple of its own
|
|
75
|
-
*
|
|
74
|
+
* Generated assembly bytes each module may spend, as a multiple of its own code,
|
|
75
|
+
* comments and whitespace aside. **Default `0.5`.** `0` ships no assembly. The right number is
|
|
76
76
|
* per grammar: a larger one parses faster in steady state and costs import and
|
|
77
77
|
* first-parse time, so measure both, and keep the artifact within 5× its source
|
|
78
|
-
* (docs/design/runtime-and-size-contract.md, rules 4 and 6).
|
|
78
|
+
* (docs/design/runtime-and-size-contract.md, rules 4 and 6). A larger budget never
|
|
79
|
+
* loses a site, with one limit: a module with two AST grammars spends it in order, so
|
|
80
|
+
* a larger budget can buy the first a big site and leave the second fewer.
|
|
79
81
|
*/
|
|
80
82
|
assemblyBudget?: number;
|
|
81
83
|
};
|
|
@@ -96,6 +98,8 @@ export type TransformMacroResult = {
|
|
|
96
98
|
map: ReturnType<MagicString['generateMap']>;
|
|
97
99
|
/** Diagnostics for macro-referencing shapes that fell back to the interpreter. */
|
|
98
100
|
warnings: string[];
|
|
101
|
+
/** The sites the module's `assemblyBudget` bought, by program offset, in rank order. */
|
|
102
|
+
assemblySites: number[];
|
|
99
103
|
};
|
|
100
104
|
/**
|
|
101
105
|
* Transform one module, ALWAYS releasing the process-global capture state.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAyBA,OAAO,WAAW,MAAM,cAAc,CAAA;AActC,OAAO,EAAsC,KAAK,OAAO,EAAE,MAAM,uBAAuB,CAAA;AA6BxF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAA;AACzE;;;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,CAAC,EAAE,WAAW,GACxB,oBAAoB,GAAG,IAAI,CAW7B"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import * as fs2 from "node:fs";
|
|
3
3
|
import * as path2 from "node:path";
|
|
4
4
|
import { createUnplugin } from "unplugin";
|
|
5
|
-
import { parseSync as
|
|
5
|
+
import { parseSync as parseSync6 } from "oxc-parser";
|
|
6
6
|
import { ResolverFactory } from "oxc-resolver";
|
|
7
7
|
import MagicString from "magic-string";
|
|
8
8
|
|
|
@@ -2081,6 +2081,9 @@ function linkRules(recipes, link) {
|
|
|
2081
2081
|
return cache;
|
|
2082
2082
|
}
|
|
2083
2083
|
|
|
2084
|
+
// src/plugin/evaluator.ts
|
|
2085
|
+
import { parseSync as parseSync2 } from "oxc-parser";
|
|
2086
|
+
|
|
2084
2087
|
// src/combinators/probe.ts
|
|
2085
2088
|
function failAt(ctx, expected, pos) {
|
|
2086
2089
|
const r = { ok: false, expected, span: { start: pos, end: pos } };
|
|
@@ -5619,7 +5622,7 @@ function sourceLeaf(root, fn) {
|
|
|
5619
5622
|
}
|
|
5620
5623
|
|
|
5621
5624
|
// src/version.ts
|
|
5622
|
-
var PARSEMAN_VERSION = "0.61.
|
|
5625
|
+
var PARSEMAN_VERSION = "0.61.3";
|
|
5623
5626
|
|
|
5624
5627
|
// src/table/lex-body.ts
|
|
5625
5628
|
function buildLexBodyRecognizer(spec, constants) {
|
|
@@ -19148,13 +19151,21 @@ function selectHotSites(code, entries, siteBytes, budget, profile) {
|
|
|
19148
19151
|
let spent = 0;
|
|
19149
19152
|
for (const ip of ranked) {
|
|
19150
19153
|
if (w(ip) === 0) break;
|
|
19151
|
-
|
|
19152
|
-
if (spent
|
|
19153
|
-
spent += bytes;
|
|
19154
|
+
spent += siteBytes.get(ip);
|
|
19155
|
+
if (spent > budget) break;
|
|
19154
19156
|
selected.add(ip);
|
|
19155
19157
|
}
|
|
19156
19158
|
return selected;
|
|
19157
19159
|
}
|
|
19160
|
+
function fitHotSites(code, entries, siteBytes, fixed, ceiling, sourceBytes, profile) {
|
|
19161
|
+
const ranked = [...selectHotSites(code, entries, siteBytes, ceiling - fixed, profile)];
|
|
19162
|
+
for (; ranked.length > 0; ranked.pop()) {
|
|
19163
|
+
const sites = new Set(ranked);
|
|
19164
|
+
const bytes = sourceBytes(sites);
|
|
19165
|
+
if (bytes <= ceiling) return { sites, bytes };
|
|
19166
|
+
}
|
|
19167
|
+
return void 0;
|
|
19168
|
+
}
|
|
19158
19169
|
function staticWeights(code, entries) {
|
|
19159
19170
|
let weight = /* @__PURE__ */ new Map();
|
|
19160
19171
|
const kids = [];
|
|
@@ -19294,19 +19305,20 @@ function compileRuleMap(ruleMap, opts = {}) {
|
|
|
19294
19305
|
}
|
|
19295
19306
|
const ceiling = budget / SUPERCOMPILE_GROWTH;
|
|
19296
19307
|
if (ceiling <= fixed) return none;
|
|
19297
|
-
|
|
19298
|
-
|
|
19299
|
-
|
|
19300
|
-
|
|
19301
|
-
|
|
19302
|
-
|
|
19303
|
-
|
|
19304
|
-
|
|
19305
|
-
|
|
19306
|
-
|
|
19307
|
-
|
|
19308
|
-
|
|
19309
|
-
|
|
19308
|
+
const fit = fitHotSites(
|
|
19309
|
+
artifact.code,
|
|
19310
|
+
Object.values(artifact.rules),
|
|
19311
|
+
siteBytes,
|
|
19312
|
+
fixed,
|
|
19313
|
+
ceiling,
|
|
19314
|
+
(sites) => emitAssemblySource(table, artifact, cfg, roots, true, sites, true).source.length,
|
|
19315
|
+
profile
|
|
19316
|
+
);
|
|
19317
|
+
if (fit !== void 0) return { sites: fit.sites, bytes: Math.ceil(fit.bytes * SUPERCOMPILE_GROWTH) };
|
|
19318
|
+
return {
|
|
19319
|
+
...none,
|
|
19320
|
+
refusal: `a site within its ${Math.floor(ceiling)} B selection ceiling (the prelude alone is ${fixed} B)`
|
|
19321
|
+
};
|
|
19310
19322
|
};
|
|
19311
19323
|
return {
|
|
19312
19324
|
keys: ruleMap.map(([key]) => key),
|
|
@@ -20719,7 +20731,7 @@ function stripTsFromSource(node2, code) {
|
|
|
20719
20731
|
walk(node2);
|
|
20720
20732
|
const start = node2.start;
|
|
20721
20733
|
const end = node2.end;
|
|
20722
|
-
if (cuts.length === 0) return code.slice(start, end);
|
|
20734
|
+
if (cuts.length === 0) return stripComments(code.slice(start, end));
|
|
20723
20735
|
cuts.sort((a, b) => a[0] - b[0]);
|
|
20724
20736
|
let out = "";
|
|
20725
20737
|
let cur = start;
|
|
@@ -20728,7 +20740,36 @@ function stripTsFromSource(node2, code) {
|
|
|
20728
20740
|
out += code.slice(cur, s);
|
|
20729
20741
|
cur = e;
|
|
20730
20742
|
}
|
|
20731
|
-
return out + code.slice(cur, end);
|
|
20743
|
+
return stripComments(out + code.slice(cur, end));
|
|
20744
|
+
}
|
|
20745
|
+
var LINE_TERMINATOR = /[\n\r\u2028\u2029]/;
|
|
20746
|
+
function stripComments(text) {
|
|
20747
|
+
if (!text.includes("/*") && !text.includes("//")) return text;
|
|
20748
|
+
const wrapped = `(${text})`;
|
|
20749
|
+
let out = "";
|
|
20750
|
+
let cur = 0;
|
|
20751
|
+
let lineEnd = false;
|
|
20752
|
+
const comments = parseSync2("reducer.ts", wrapped).comments;
|
|
20753
|
+
comments.forEach((c, i) => {
|
|
20754
|
+
const before = text.slice(cur, c.start - 1);
|
|
20755
|
+
const kept = before.trimEnd();
|
|
20756
|
+
out += kept;
|
|
20757
|
+
lineEnd ||= LINE_TERMINATOR.test(before.slice(kept.length)) || LINE_TERMINATOR.test(c.value);
|
|
20758
|
+
cur = c.end - 1;
|
|
20759
|
+
const after = /^\s*/.exec(text.slice(cur))[0];
|
|
20760
|
+
const endsLine = LINE_TERMINATOR.test(after);
|
|
20761
|
+
if (comments[i + 1]?.start === c.end + after.length) {
|
|
20762
|
+
lineEnd ||= endsLine;
|
|
20763
|
+
cur += after.length;
|
|
20764
|
+
return;
|
|
20765
|
+
}
|
|
20766
|
+
if (out !== "" && cur + after.length < text.length && !endsLine) {
|
|
20767
|
+
if (lineEnd) out += "\n";
|
|
20768
|
+
else if (after === "") out += " ";
|
|
20769
|
+
}
|
|
20770
|
+
lineEnd = false;
|
|
20771
|
+
});
|
|
20772
|
+
return out + text.slice(cur);
|
|
20732
20773
|
}
|
|
20733
20774
|
var UnevaluatedExtra = class {
|
|
20734
20775
|
};
|
|
@@ -21754,7 +21795,7 @@ function referencesAny(node2, names, scope2) {
|
|
|
21754
21795
|
import * as fs from "node:fs";
|
|
21755
21796
|
import * as path from "node:path";
|
|
21756
21797
|
import { createRequire } from "node:module";
|
|
21757
|
-
import { parseSync as
|
|
21798
|
+
import { parseSync as parseSync3 } from "oxc-parser";
|
|
21758
21799
|
var FUNCTION_TYPES = /* @__PURE__ */ new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"]);
|
|
21759
21800
|
var SCOPE_TYPES = /* @__PURE__ */ new Set([
|
|
21760
21801
|
...FUNCTION_TYPES,
|
|
@@ -21960,7 +22001,7 @@ function analyseModuleFile(file) {
|
|
|
21960
22001
|
let mod = null;
|
|
21961
22002
|
try {
|
|
21962
22003
|
const src = fs.readFileSync(file, "utf8");
|
|
21963
|
-
const r =
|
|
22004
|
+
const r = parseSync3(file, src);
|
|
21964
22005
|
if (r.errors.length === 0) {
|
|
21965
22006
|
const body = r.program.body;
|
|
21966
22007
|
const scopes = buildScopeTree(body, src.length);
|
|
@@ -22138,7 +22179,7 @@ function createReducerResolver(entryFile, body, src) {
|
|
|
22138
22179
|
}
|
|
22139
22180
|
|
|
22140
22181
|
// src/plugin/free-identifiers.ts
|
|
22141
|
-
import { parseSync as
|
|
22182
|
+
import { parseSync as parseSync4 } from "oxc-parser";
|
|
22142
22183
|
var isNode = (v) => typeof v === "object" && v !== null && typeof v.type === "string";
|
|
22143
22184
|
var TYPE_KEYS = /* @__PURE__ */ new Set([
|
|
22144
22185
|
"typeAnnotation",
|
|
@@ -22286,7 +22327,7 @@ function describeTopLevel(stmt) {
|
|
|
22286
22327
|
function findFreeIdentifiers(code, filename) {
|
|
22287
22328
|
let parsed;
|
|
22288
22329
|
try {
|
|
22289
|
-
parsed =
|
|
22330
|
+
parsed = parseSync4(filename, code);
|
|
22290
22331
|
} catch {
|
|
22291
22332
|
return [];
|
|
22292
22333
|
}
|
|
@@ -22363,7 +22404,7 @@ function findFreeIdentifiers(code, filename) {
|
|
|
22363
22404
|
}
|
|
22364
22405
|
|
|
22365
22406
|
// src/plugin/entry-supercompiler.ts
|
|
22366
|
-
import { parseSync as
|
|
22407
|
+
import { parseSync as parseSync5 } from "oxc-parser";
|
|
22367
22408
|
var PIECE = /^_pf(\d+)$/;
|
|
22368
22409
|
var WRAP = "function __parseman_supercompile__(){\n";
|
|
22369
22410
|
var SUFFIX = "\n}";
|
|
@@ -22512,7 +22553,7 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
|
|
|
22512
22553
|
}
|
|
22513
22554
|
if (!candidate.supercompile.activated) return replacement;
|
|
22514
22555
|
const prefix = "const __parseman_macro_replacement__=";
|
|
22515
|
-
const parsed =
|
|
22556
|
+
const parsed = parseSync5("parseman-entry-supercompile-replacement.js", prefix + replacement);
|
|
22516
22557
|
if (parsed.errors.length > 0) return replacement;
|
|
22517
22558
|
const program = parsed.program;
|
|
22518
22559
|
const declaration = nodes(program.body)[0];
|
|
@@ -22533,12 +22574,12 @@ function supercompileRuleMapReplacement(prog, replacement, select) {
|
|
|
22533
22574
|
const end = body.end - prefix.length - 1;
|
|
22534
22575
|
if (replacement.slice(start, end) !== FACTORY_ARITY_GUARD + canonical2.source + "\n") return replacement;
|
|
22535
22576
|
const transformed = replacement.slice(0, start) + FACTORY_ARITY_GUARD + candidate.source + "\n" + replacement.slice(end);
|
|
22536
|
-
const checked =
|
|
22577
|
+
const checked = parseSync5("parseman-entry-supercompile-replacement-result.js", prefix + transformed);
|
|
22537
22578
|
return checked.errors.length === 0 ? transformed : replacement;
|
|
22538
22579
|
}
|
|
22539
22580
|
function supercompileEmittedAssembly(prog, _cfg, extraIps, emitted) {
|
|
22540
22581
|
const source = emitted.source;
|
|
22541
|
-
const parsed =
|
|
22582
|
+
const parsed = parseSync5("parseman-entry-supercompile.js", WRAP + source + SUFFIX);
|
|
22542
22583
|
if (parsed.errors.length > 0) {
|
|
22543
22584
|
const zero = { functionsBefore: 0, pieceCallsBefore: 0, sourceBefore: source.length, barriers: {} };
|
|
22544
22585
|
return fallback(emitted, "canonical emitted source did not parse", zero);
|
|
@@ -22764,7 +22805,7 @@ ${nested}
|
|
|
22764
22805
|
}
|
|
22765
22806
|
const functionsAfter = roots.length;
|
|
22766
22807
|
const removed = fns.size - functionsAfter;
|
|
22767
|
-
const checked =
|
|
22808
|
+
const checked = parseSync5("parseman-entry-supercompile-result.js", WRAP + candidate + SUFFIX);
|
|
22768
22809
|
if (checked.errors.length > 0) return fallback(emitted, "structured candidate did not parse", before);
|
|
22769
22810
|
const declared = /* @__PURE__ */ new Set();
|
|
22770
22811
|
const referenced = /* @__PURE__ */ new Set();
|
|
@@ -23039,7 +23080,17 @@ function corpusTexts(profile) {
|
|
|
23039
23080
|
});
|
|
23040
23081
|
}
|
|
23041
23082
|
var PARSEMAN_MODULE = "parseman";
|
|
23042
|
-
var DEFAULT_ASSEMBLY_BUDGET = 0.
|
|
23083
|
+
var DEFAULT_ASSEMBLY_BUDGET = 0.5;
|
|
23084
|
+
function codeBytes(code, comments, end = code.length) {
|
|
23085
|
+
let bytes = 0;
|
|
23086
|
+
let at = 0;
|
|
23087
|
+
for (const c of comments) {
|
|
23088
|
+
if (c.start >= end) break;
|
|
23089
|
+
bytes += code.slice(at, c.start).replace(/\s+/g, "").length;
|
|
23090
|
+
at = c.end;
|
|
23091
|
+
}
|
|
23092
|
+
return bytes + code.slice(at, end).replace(/\s+/g, "").length;
|
|
23093
|
+
}
|
|
23043
23094
|
var LinkRefusal = class extends Error {
|
|
23044
23095
|
};
|
|
23045
23096
|
function reasonSuffix(runtimeOnly) {
|
|
@@ -23140,7 +23191,7 @@ function parseModuleCached(filePath) {
|
|
|
23140
23191
|
let parsed = null;
|
|
23141
23192
|
try {
|
|
23142
23193
|
const src = fs2.readFileSync(filePath, "utf8");
|
|
23143
|
-
const r =
|
|
23194
|
+
const r = parseSync6(filePath, src);
|
|
23144
23195
|
if (r.errors.length === 0) parsed = { body: r.program.body, src };
|
|
23145
23196
|
} catch {
|
|
23146
23197
|
}
|
|
@@ -23181,7 +23232,7 @@ async function followCarried(sinks, moduleId, name, depth = 0) {
|
|
|
23181
23232
|
if (own !== void 0) return { items: own, recorder: moduleId };
|
|
23182
23233
|
const code = this.getModuleInfo(moduleId)?.code;
|
|
23183
23234
|
if (!code) return void 0;
|
|
23184
|
-
const parsed =
|
|
23235
|
+
const parsed = parseSync6(moduleId, code);
|
|
23185
23236
|
if (parsed.errors.length > 0) return void 0;
|
|
23186
23237
|
const origin = exportOrigin(parsed.program.body, name);
|
|
23187
23238
|
if (origin === "local") return null;
|
|
@@ -23415,7 +23466,7 @@ function lowerPrivateSourceModule(file, moduleAliases, warnUnloweredRegex, recov
|
|
|
23415
23466
|
const source = fs2.readFileSync(file, "utf8");
|
|
23416
23467
|
const transformed = transformMacro(source, file, moduleAliases, warnUnloweredRegex, recovery);
|
|
23417
23468
|
if (!transformed || transformed.warnings.length > 0) return null;
|
|
23418
|
-
const parsed =
|
|
23469
|
+
const parsed = parseSync6(file, transformed.code);
|
|
23419
23470
|
parsedModule = parsed.errors.length === 0 ? { body: parsed.program.body, src: transformed.code } : null;
|
|
23420
23471
|
return parsedModule;
|
|
23421
23472
|
} catch {
|
|
@@ -23438,7 +23489,7 @@ function transformMacro(code, id, moduleAliases = /* @__PURE__ */ new Set([PARSE
|
|
|
23438
23489
|
function transformMacroImpl(code, id, moduleAliases, warnUnloweredRegex, recovery, grammarCoverage, assemblyProfile, assemblyBudgetShare, carriedSink) {
|
|
23439
23490
|
let result;
|
|
23440
23491
|
try {
|
|
23441
|
-
result =
|
|
23492
|
+
result = parseSync6(id, code);
|
|
23442
23493
|
} catch {
|
|
23443
23494
|
return null;
|
|
23444
23495
|
}
|
|
@@ -23997,6 +24048,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
23997
24048
|
const localRuleMaps = /* @__PURE__ */ new Map();
|
|
23998
24049
|
const localGrammarTrivia = /* @__PURE__ */ new Map();
|
|
23999
24050
|
const localGrammarScanSkip = /* @__PURE__ */ new Map();
|
|
24051
|
+
const callLabel = (fn, start) => `${fn}${codeBytes(code, result.comments, start)}`;
|
|
24000
24052
|
const nsFor = (label2) => `_${createHash("sha1").update(`${id}#${label2}`).digest("hex").slice(0, 8)}_`;
|
|
24001
24053
|
const isSpread = (it) => "__spreadLocal" in it;
|
|
24002
24054
|
const isIR = (it) => "ir" in it;
|
|
@@ -24252,7 +24304,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24252
24304
|
const carried = [];
|
|
24253
24305
|
const importedFactories = [];
|
|
24254
24306
|
for (let i = 0; i < elements.length; i++) {
|
|
24255
|
-
const r = argPieces(elements[i],
|
|
24307
|
+
const r = argPieces(elements[i], `${callLabel("compose", init.start)}_${i}`, composing);
|
|
24256
24308
|
if (!r) {
|
|
24257
24309
|
const el = elements[i];
|
|
24258
24310
|
const name = el.type === "Identifier" ? el.name : void 0;
|
|
@@ -24315,7 +24367,8 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24315
24367
|
warn(init.start, "compose(): a carried piece has no re-lowerable IR; leaving the runtime compose() in place");
|
|
24316
24368
|
return null;
|
|
24317
24369
|
};
|
|
24318
|
-
let assemblyBudget = Math.floor(code.
|
|
24370
|
+
let assemblyBudget = Math.floor(codeBytes(code, result.comments) * assemblyBudgetShare);
|
|
24371
|
+
const assemblySites = [];
|
|
24319
24372
|
let leafDeclared;
|
|
24320
24373
|
const declaresLeaf = () => leafDeclared ??= body.some((stmt) => {
|
|
24321
24374
|
const vd = unwrapVd(stmt);
|
|
@@ -24328,6 +24381,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24328
24381
|
warnings.push(`${id}:${lineOf(pos)} \u2014 ${label2}: its precompiled assembly cannot emit ${refusal}; the artifact runs on the closure engine`);
|
|
24329
24382
|
}
|
|
24330
24383
|
assemblyBudget -= bytes;
|
|
24384
|
+
assemblySites.push(...sites);
|
|
24331
24385
|
return sites;
|
|
24332
24386
|
};
|
|
24333
24387
|
const profileOf = (compiled) => {
|
|
@@ -24389,7 +24443,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24389
24443
|
let localRules = null;
|
|
24390
24444
|
const importedFactories = [];
|
|
24391
24445
|
if (isRulesCall(localArg)) {
|
|
24392
|
-
const evaluated = evaluateRulesFactory(localArg,
|
|
24446
|
+
const evaluated = evaluateRulesFactory(localArg, callLabel("composeLeaf", init.start));
|
|
24393
24447
|
localRules = evaluated?.ruleMap ?? null;
|
|
24394
24448
|
if (evaluated?.importedFactory) importedFactories.push(evaluated.importedFactory);
|
|
24395
24449
|
} else if (localArg.type === "Identifier") {
|
|
@@ -24404,7 +24458,7 @@ ${names.map((n) => ` - ${n}`).join("\n")}` : " (it is not a static combinator/v
|
|
|
24404
24458
|
const composing = composingTrivia(elements);
|
|
24405
24459
|
const carried = [];
|
|
24406
24460
|
for (let i = 0; i < elements.length - 1; i++) {
|
|
24407
|
-
const r = argPieces(elements[i],
|
|
24461
|
+
const r = argPieces(elements[i], `${callLabel("composeLeaf", init.start)}_${i}`, composing);
|
|
24408
24462
|
if (!r) {
|
|
24409
24463
|
warn(init.start, `composeLeaf(): argument ${i} isn't a build-resolvable recognition grammar`);
|
|
24410
24464
|
return null;
|
|
@@ -24880,6 +24934,7 @@ ${lines2.join("\n")}`);
|
|
|
24880
24934
|
for (const l of lines2) warnings.push(`${id}: ${l}`);
|
|
24881
24935
|
}
|
|
24882
24936
|
return {
|
|
24937
|
+
assemblySites: applied.length > 0 ? assemblySites : [],
|
|
24883
24938
|
code: ms.toString(),
|
|
24884
24939
|
map: ms.generateMap({ hires: true }),
|
|
24885
24940
|
warnings
|