@galacean/engine-shader-analyzer 0.0.0-stage → 2.0.0-alpha.54

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/module.js ADDED
@@ -0,0 +1,2601 @@
1
+ import { formatDiagnosticSource, GSErrorName, GSError, BaseToken, ASTNode, TreeNode, FnSymbol, Keyword, ParserUtils, EMPTY_BRANCH, isBranchReachable, BuiltinFunction, canBranchesOverlap, sameBranch, ShaderBuiltinSemantic, ShaderCompilerUtils, ESymbolType, getBranchCoverage, TypeSystem, TypeAny, ETokenType, EShaderStage, SymbolInfo, BuiltinVariable, ShaderPosition, GLESShaderInfo, ShaderStructRole, normalizeShaderIncludeMap, normalizeShaderSourceFile, ShaderSourceParser, parseShaderPass, ShaderCoreInfo, branchAnalysis, createParsedShaderPass, mapExpandedShaderRange } from '@galacean/engine-shader-parser/internal/analyzer';
2
+
3
+ function _array_like_to_array(arr, len) {
4
+ if (len == null || len > arr.length) len = arr.length;
5
+
6
+ for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
7
+
8
+ return arr2;
9
+ }
10
+
11
+ function _unsupported_iterable_to_array(o, minLen) {
12
+ if (!o) return;
13
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
14
+
15
+ var n = Object.prototype.toString.call(o).slice(8, -1);
16
+
17
+ if (n === "Object" && o.constructor) n = o.constructor.name;
18
+ if (n === "Map" || n === "Set") return Array.from(n);
19
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
20
+ }
21
+
22
+ function _create_for_of_iterator_helper_loose(o, allowArrayLike) {
23
+ var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
24
+
25
+ if (it) return (it = it.call(o)).next.bind(it);
26
+ // Fallback for engines without symbol support
27
+ if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === "number") {
28
+ if (it) o = it;
29
+
30
+ var i = 0;
31
+
32
+ return function() {
33
+ if (i >= o.length) return { done: true };
34
+
35
+ return { done: false, value: o[i++] };
36
+ };
37
+ }
38
+
39
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
40
+ }
41
+
42
+ /**
43
+ * Semantic classification of a shader diagnostic.
44
+ *
45
+ * Severity is reported separately.
46
+ */ var DiagnosticType = /*#__PURE__*/ function(DiagnosticType) {
47
+ DiagnosticType["SyntaxError"] = "SyntaxError";
48
+ DiagnosticType["PreprocessorError"] = "PreprocessorError";
49
+ DiagnosticType["NoMatchingOverload"] = "NoMatchingOverload";
50
+ DiagnosticType["Redefinition"] = "Redefinition";
51
+ DiagnosticType["UseBeforeDeclaration"] = "UseBeforeDeclaration";
52
+ DiagnosticType["LocalFunctionPrototype"] = "LocalFunctionPrototype";
53
+ DiagnosticType["AmbiguousMacroBranchResolution"] = "AmbiguousMacroBranchResolution";
54
+ DiagnosticType["InvalidSwizzle"] = "InvalidSwizzle";
55
+ DiagnosticType["UndeclaredStructMember"] = "UndeclaredStructMember";
56
+ DiagnosticType["AssignTypeMismatch"] = "AssignTypeMismatch";
57
+ DiagnosticType["InvalidAssignmentTarget"] = "InvalidAssignmentTarget";
58
+ DiagnosticType["ConstDivideByZero"] = "ConstDivideByZero";
59
+ DiagnosticType["ShiftOutOfRange"] = "ShiftOutOfRange";
60
+ DiagnosticType["IndexOutOfBounds"] = "IndexOutOfBounds";
61
+ DiagnosticType["NonIntegerIndex"] = "NonIntegerIndex";
62
+ DiagnosticType["NonIndexableType"] = "NonIndexableType";
63
+ DiagnosticType["ExpectedSampler"] = "ExpectedSampler";
64
+ DiagnosticType["InvalidUnaryOperand"] = "InvalidUnaryOperand";
65
+ DiagnosticType["InvalidBinaryOperands"] = "InvalidBinaryOperands";
66
+ DiagnosticType["ConstructorArgType"] = "ConstructorArgType";
67
+ DiagnosticType["ConstructorArgCount"] = "ConstructorArgCount";
68
+ DiagnosticType["NonConstInitializer"] = "NonConstInitializer";
69
+ DiagnosticType["NonConstArraySize"] = "NonConstArraySize";
70
+ DiagnosticType["EmptyStruct"] = "EmptyStruct";
71
+ DiagnosticType["InvalidArraySize"] = "InvalidArraySize";
72
+ DiagnosticType["InvalidVoidVariable"] = "InvalidVoidVariable";
73
+ DiagnosticType["NonFloatDerivativeArg"] = "NonFloatDerivativeArg";
74
+ DiagnosticType["InvalidReturnType"] = "InvalidReturnType";
75
+ DiagnosticType["MissingReturn"] = "MissingReturn";
76
+ DiagnosticType["NonBoolCondition"] = "NonBoolCondition";
77
+ DiagnosticType["RecursiveFunction"] = "RecursiveFunction";
78
+ DiagnosticType["NonConstructibleReturnType"] = "NonConstructibleReturnType";
79
+ DiagnosticType["MisplacedControlFlow"] = "MisplacedControlFlow";
80
+ DiagnosticType["DerivativeInVertexShader"] = "DerivativeInVertexShader";
81
+ DiagnosticType["InvalidBuiltinStage"] = "InvalidBuiltinStage";
82
+ DiagnosticType["InvalidIOStruct"] = "InvalidIOStruct";
83
+ DiagnosticType["InvalidEntryReturnType"] = "InvalidEntryReturnType";
84
+ DiagnosticType["StructRoleConflict"] = "StructRoleConflict";
85
+ DiagnosticType["DuplicateEntryAssignment"] = "DuplicateEntryAssignment";
86
+ DiagnosticType["MissingEntry"] = "MissingEntry";
87
+ DiagnosticType["EntryNotFound"] = "EntryNotFound";
88
+ DiagnosticType["AmbiguousEntryPoint"] = "AmbiguousEntryPoint";
89
+ DiagnosticType["GlFragColorWithMrt"] = "GlFragColorWithMrt";
90
+ DiagnosticType["LegacyFragmentOutputConflict"] = "LegacyFragmentOutputConflict";
91
+ DiagnosticType["InvalidMrtOutput"] = "InvalidMrtOutput";
92
+ DiagnosticType["BareGlFragData"] = "BareGlFragData";
93
+ DiagnosticType["NonConstFragmentOutputIndex"] = "NonConstFragmentOutputIndex";
94
+ DiagnosticType["NestedIOStruct"] = "NestedIOStruct";
95
+ DiagnosticType["MissingVertexPosition"] = "MissingVertexPosition";
96
+ DiagnosticType["NonFlatIntegerVarying"] = "NonFlatIntegerVarying";
97
+ DiagnosticType["InvalidRenderStateProperty"] = "InvalidRenderStateProperty";
98
+ DiagnosticType["InvalidEnumValue"] = "InvalidEnumValue";
99
+ DiagnosticType["BitwiseOrOnNonBitmask"] = "BitwiseOrOnNonBitmask";
100
+ DiagnosticType["MixedEnumTypes"] = "MixedEnumTypes";
101
+ DiagnosticType["InvalidRenderStateVariable"] = "InvalidRenderStateVariable";
102
+ DiagnosticType["InvalidRenderQueueVariable"] = "InvalidRenderQueueVariable";
103
+ return DiagnosticType;
104
+ }({});
105
+
106
+ /** Severity assigned to a shader diagnostic. */ var DiagnosticSeverity = /*#__PURE__*/ function(DiagnosticSeverity) {
107
+ DiagnosticSeverity["Error"] = "error";
108
+ DiagnosticSeverity["Warning"] = "warning";
109
+ return DiagnosticSeverity;
110
+ }({});
111
+ /**
112
+ * Formats a diagnostic with a source excerpt and caret markers.
113
+ * @param diagnostic - Diagnostic to format.
114
+ * @returns Formatted diagnostic text.
115
+ */ function formatDiagnostic(diagnostic) {
116
+ var _diagnostic_range = diagnostic.range, start = _diagnostic_range.start, end = _diagnostic_range.end;
117
+ return formatDiagnosticSource(diagnostic.relatedSource, {
118
+ start: {
119
+ line: start.line - 1,
120
+ column: start.column - 1
121
+ },
122
+ end: {
123
+ line: end.line - 1,
124
+ column: end.column - 1
125
+ }
126
+ }, diagnostic.code + ": " + diagnostic.message);
127
+ }
128
+
129
+ function _instanceof(left, right) {
130
+ if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
131
+ return !!right[Symbol.hasInstance](left);
132
+ } else return left instanceof right;
133
+ }
134
+
135
+ var diagnosticTypes = new Set(Object.values(DiagnosticType));
136
+ /**
137
+ * Converts a parser error to a structured diagnostic.
138
+ * @param error - Error reported while parsing or analyzing shader source.
139
+ * @returns Structured diagnostic for the error.
140
+ */ function gseErrorToDiagnostic(error) {
141
+ if (!_instanceof(error, GSError)) {
142
+ // Non-GSError (e.g. thrown from lexer/preprocess) — best-effort
143
+ return {
144
+ severity: DiagnosticSeverity.Error,
145
+ code: DiagnosticType.SyntaxError,
146
+ message: error.message,
147
+ range: {
148
+ start: {
149
+ line: 1,
150
+ column: 1,
151
+ offset: 0
152
+ },
153
+ end: {
154
+ line: 1,
155
+ column: 1,
156
+ offset: 0
157
+ }
158
+ }
159
+ };
160
+ }
161
+ var severity = error.name === GSErrorName.CompilationWarn ? DiagnosticSeverity.Warning : DiagnosticSeverity.Error;
162
+ var code = isDiagnosticType(error.code) ? error.code : error.name === GSErrorName.PreprocessorError ? DiagnosticType.PreprocessorError : DiagnosticType.SyntaxError;
163
+ return {
164
+ severity: severity,
165
+ code: code,
166
+ message: error.message,
167
+ sourceFile: error.file,
168
+ range: gSErrorLocationToRange(error.location),
169
+ relatedSource: error.source || undefined
170
+ };
171
+ }
172
+ function isDiagnosticType(code) {
173
+ return code !== undefined && diagnosticTypes.has(code);
174
+ }
175
+ function gSErrorLocationToRange(location) {
176
+ if ("start" in location && "end" in location) {
177
+ // ShaderRange
178
+ return {
179
+ start: {
180
+ line: location.start.line + 1,
181
+ column: location.start.column + 1,
182
+ offset: location.start.index
183
+ },
184
+ end: {
185
+ line: location.end.line + 1,
186
+ column: location.end.column + 1,
187
+ offset: location.end.index
188
+ }
189
+ };
190
+ }
191
+ // ShaderPosition
192
+ return {
193
+ start: {
194
+ line: location.line + 1,
195
+ column: location.column + 1,
196
+ offset: location.index
197
+ },
198
+ end: {
199
+ line: location.line + 1,
200
+ column: location.column + 1,
201
+ offset: location.index
202
+ }
203
+ };
204
+ }
205
+
206
+ var INTEGER_MINIMUM = -0x80000000;
207
+ var INTEGER_END = 0x80000000;
208
+ var TERMINAL_NODE = {
209
+ variable: Infinity,
210
+ ends: [],
211
+ children: []
212
+ };
213
+ // Let ordinary large shaders scale linearly without admitting exponential proof work
214
+ var MIN_DIAGRAM_WORK = 65536;
215
+ var WORK_PER_CONSTRAINT = 128;
216
+ /**
217
+ * Request-owned symbolic macro conditions shared by call-graph reachability and coverage.
218
+ * @internal
219
+ */ var ShaderConditionDiagram = /*#__PURE__*/ function() {
220
+ function ShaderConditionDiagram(branches) {
221
+ this._variables = [];
222
+ this._variableIds = new Map();
223
+ this._nodes = [
224
+ TERMINAL_NODE,
225
+ TERMINAL_NODE,
226
+ TERMINAL_NODE
227
+ ];
228
+ this._unique = new Map();
229
+ this._operations = new Map();
230
+ this._negations = new Map([
231
+ [
232
+ 0,
233
+ 1
234
+ ],
235
+ [
236
+ 1,
237
+ 0
238
+ ],
239
+ [
240
+ 2,
241
+ 2
242
+ ]
243
+ ]);
244
+ this._knownConditions = new Map([
245
+ [
246
+ 0,
247
+ 0
248
+ ],
249
+ [
250
+ 1,
251
+ 1
252
+ ],
253
+ [
254
+ 2,
255
+ 0
256
+ ]
257
+ ]);
258
+ this._conditions = new WeakMap();
259
+ this._sources = new WeakMap();
260
+ this._sourceFacts = new Map();
261
+ this._sourceKeys = new Map();
262
+ this._constraints = new Map();
263
+ this._groups = new Map();
264
+ this._groupRoots = new Map();
265
+ this._branches = [
266
+ new WeakMap(),
267
+ new WeakMap()
268
+ ];
269
+ for(var _iterator = _create_for_of_iterator_helper_loose(branches), _step; !(_step = _iterator()).done;){
270
+ var branch = _step.value;
271
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(branch), _step1; !(_step1 = _iterator1()).done;){
272
+ var constraint = _step1.value;
273
+ var _sourceArm_predicates;
274
+ if (this._constraints.has(constraint)) continue;
275
+ this._constraints.set(constraint, this._constraints.size);
276
+ var condition = constraint.condition, sourceArm = constraint.sourceArm, conditionalGroup = constraint.conditionalGroup, conditionalArm = constraint.conditionalArm;
277
+ var current = sourceArm == null ? void 0 : (_sourceArm_predicates = sourceArm.predicates) == null ? void 0 : _sourceArm_predicates[sourceArm.predicates.length - 1];
278
+ if (condition && condition.kind !== "constant" && current && !current.negated) {
279
+ this._sourceFacts.set(current.condition, condition);
280
+ }
281
+ if (conditionalGroup !== undefined && conditionalArm !== undefined) {
282
+ var arms = this._groups.get(conditionalGroup);
283
+ if (!arms) this._groups.set(conditionalGroup, arms = new Map());
284
+ var previous = arms.get(conditionalArm);
285
+ if (!previous || !previous.sourceArm && sourceArm) arms.set(conditionalArm, constraint);
286
+ }
287
+ }
288
+ }
289
+ var domains = new Map();
290
+ var register = function(key, opaque) {
291
+ var domain = domains.get(key);
292
+ if (!domain) domains.set(key, domain = {
293
+ opaque: opaque,
294
+ points: new Set([
295
+ INTEGER_MINIMUM,
296
+ INTEGER_END
297
+ ])
298
+ });
299
+ return domain;
300
+ };
301
+ var collect = function(condition) {
302
+ if (condition.kind === "constant") return;
303
+ if (condition.kind === "expression" && !condition.opaque) {
304
+ condition.operands.forEach(collect);
305
+ } else if (condition.kind === "expression" || !isExactCondition(condition)) {
306
+ register(opaqueConditionKey(condition), true);
307
+ } else {
308
+ var domain = register(macroKey(condition), false);
309
+ if (condition.kind === "comparison") {
310
+ domain.points.add(condition.value);
311
+ domain.points.add(condition.value + 1);
312
+ }
313
+ }
314
+ };
315
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(this._constraints.keys()), _step2; !(_step2 = _iterator2()).done;){
316
+ var constraint1 = _step2.value;
317
+ var _constraint_precedingConditions, _constraint_sourceArm;
318
+ if (constraint1.condition) collect(constraint1.condition);
319
+ (_constraint_precedingConditions = constraint1.precedingConditions) == null ? void 0 : _constraint_precedingConditions.forEach(collect);
320
+ var _constraint_sourceArm_predicates;
321
+ for(var _iterator3 = _create_for_of_iterator_helper_loose((_constraint_sourceArm_predicates = (_constraint_sourceArm = constraint1.sourceArm) == null ? void 0 : _constraint_sourceArm.predicates) != null ? _constraint_sourceArm_predicates : []), _step3; !(_step3 = _iterator3()).done;){
322
+ var condition1 = _step3.value.condition;
323
+ var known = this._sourceFacts.get(condition1);
324
+ if (known) collect(known);
325
+ else register(this._sourceKey(condition1), true);
326
+ }
327
+ register(this._unknownConstraintKey(constraint1), true);
328
+ }
329
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(this._groups), _step4; !(_step4 = _iterator4()).done;){
330
+ var _step_value = _step4.value, group = _step_value[0], arms1 = _step_value[1];
331
+ var count = groupArmCount(arms1);
332
+ for(var arm = 0; arm < count; arm++)register(groupArmKey(group, arm), true);
333
+ }
334
+ for(var _iterator5 = _create_for_of_iterator_helper_loose(domains), _step5; !(_step5 = _iterator5()).done;){
335
+ var _step_value1 = _step5.value, key = _step_value1[0], domain = _step_value1[1];
336
+ var points = Array.from(domain.points).sort(function(left, right) {
337
+ return left - right;
338
+ });
339
+ this._variableIds.set(key, this._variables.length);
340
+ this._variables.push({
341
+ opaque: domain.opaque,
342
+ points: points,
343
+ indices: new Map(points.map(function(point, index) {
344
+ return [
345
+ point,
346
+ index
347
+ ];
348
+ })),
349
+ size: domain.opaque ? 2 : points.length
350
+ });
351
+ }
352
+ this._remainingWork = Math.max(MIN_DIAGRAM_WORK, this._constraints.size * WORK_PER_CONSTRAINT);
353
+ }
354
+ var _proto = ShaderConditionDiagram.prototype;
355
+ /**
356
+ * Projects source branch constraints into one shared graph root.
357
+ * @param signature - A branch registered when this diagram was constructed.
358
+ * @param ignoreSelfGuarding - Omits canonical include guards for declaration/write coverage.
359
+ * @returns The canonical condition node ID.
360
+ */ _proto.branch = function branch(signature, ignoreSelfGuarding) {
361
+ if (ignoreSelfGuarding === void 0) ignoreSelfGuarding = false;
362
+ var cache = this._branches[Number(ignoreSelfGuarding)];
363
+ var cached = cache.get(signature);
364
+ if (cached !== undefined) return cached;
365
+ var root = ShaderConditionDiagram.TRUE;
366
+ for(var _iterator = _create_for_of_iterator_helper_loose(signature), _step; !(_step = _iterator()).done;){
367
+ var constraint = _step.value;
368
+ if (ignoreSelfGuarding && constraint.selfGuarding) continue;
369
+ root = this.and(root, this._constraint(constraint));
370
+ }
371
+ cache.set(signature, root);
372
+ return root;
373
+ };
374
+ /**
375
+ * Intersects two represented sets of macro configurations.
376
+ * @param left - First condition node ID.
377
+ * @param right - Second condition node ID.
378
+ * @returns Their canonical conjunction.
379
+ */ _proto.and = function and(left, right) {
380
+ return this._apply("and", left, right);
381
+ };
382
+ /**
383
+ * Unions two represented sets of macro configurations.
384
+ * @param left - First condition node ID.
385
+ * @param right - Second condition node ID.
386
+ * @returns Their canonical disjunction.
387
+ */ _proto.or = function or(left, right) {
388
+ return this._apply("or", left, right);
389
+ };
390
+ /**
391
+ * Unions alternatives without retaining every successively longer prefix of the result.
392
+ * @param roots - Alternative condition node IDs.
393
+ * @returns Their canonical disjunction, or FALSE for no alternatives.
394
+ */ _proto.orAll = function orAll(roots) {
395
+ var pending = roots.slice();
396
+ while(pending.length > 1){
397
+ var count = 0;
398
+ for(var index = 0; index < pending.length; index += 2){
399
+ pending[count++] = index + 1 < pending.length ? this.or(pending[index], pending[index + 1]) : pending[index];
400
+ }
401
+ pending.length = count;
402
+ }
403
+ var _pending_;
404
+ return (_pending_ = pending[0]) != null ? _pending_ : ShaderConditionDiagram.FALSE;
405
+ };
406
+ /**
407
+ * Complements a represented set of macro configurations.
408
+ * @param root - Condition node ID.
409
+ * @returns Its canonical negation.
410
+ */ _proto.not = function not(root) {
411
+ return this._transform(root, "not");
412
+ };
413
+ /**
414
+ * Classifies existence of a configuration without guessing unresolved predicates.
415
+ * @param root - Condition node ID.
416
+ * @returns Proven reachability, proven absence, or dependence on unresolved predicates.
417
+ */ _proto.reachability = function reachability(root) {
418
+ return root === 0 ? "unreachable" : this._transform(root, "known") !== 0 ? "reachable" : "unknown";
419
+ };
420
+ /**
421
+ * Classifies whether writes cover every configuration that reaches a reference.
422
+ * @param writes - Union of all writing conditions.
423
+ * @param reference - Condition under which coverage is required.
424
+ * @returns Proven coverage, a concrete missing configuration, or unresolved coverage.
425
+ */ _proto.coverage = function coverage(writes, reference) {
426
+ if (reference === void 0) reference = ShaderConditionDiagram.TRUE;
427
+ var missing = this.and(reference, this.not(writes));
428
+ return missing === 0 ? "covered" : this._transform(missing, "known") !== 0 ? "uncovered" : "unknown";
429
+ };
430
+ /**
431
+ * Selects one known macro assignment that satisfies the condition for every unresolved predicate.
432
+ * @param root - Condition for which a concrete witness is required.
433
+ * @returns A cube fixing known macro variables, or FALSE when no definite witness exists.
434
+ */ _proto.knownWitness = function knownWitness(root) {
435
+ var known = this._transform(root, "known");
436
+ if (known === 0) return 0;
437
+ var choices = [];
438
+ for(var variable = 0; variable < this._variables.length; variable++){
439
+ if (this._variables[variable].opaque) continue;
440
+ var node = this._nodes[known];
441
+ var choice = 0;
442
+ if (node.variable === variable) {
443
+ var edge = node.children.findIndex(function(child) {
444
+ return child !== 0;
445
+ });
446
+ choice = edge ? node.ends[edge - 1] : 0;
447
+ known = node.children[edge];
448
+ }
449
+ choices.push([
450
+ variable,
451
+ choice
452
+ ]);
453
+ }
454
+ var cube = 1;
455
+ for(var index = choices.length - 1; index >= 0; index--){
456
+ var _choices_index = choices[index], variable1 = _choices_index[0], choice1 = _choices_index[1];
457
+ var size = this._variables[variable1].size;
458
+ var ends = [], children = [];
459
+ if (choice1) {
460
+ ends.push(choice1);
461
+ children.push(0);
462
+ }
463
+ ends.push(choice1 + 1);
464
+ children.push(cube);
465
+ if (choice1 + 1 < size) {
466
+ ends.push(size);
467
+ children.push(0);
468
+ }
469
+ cube = this._node(variable1, ends, children);
470
+ if (cube === ShaderConditionDiagram.UNKNOWN) return ShaderConditionDiagram.FALSE;
471
+ }
472
+ return cube;
473
+ };
474
+ _proto._constraint = function _constraint(constraint) {
475
+ if (hasSourceFacts(constraint.sourceArm)) return this._sourceArm(constraint.sourceArm);
476
+ var group = constraint.conditionalGroup;
477
+ var arm = constraint.conditionalArm;
478
+ if (group !== undefined && arm !== undefined) {
479
+ var roots = this._groupRoots.get(group);
480
+ if (!roots) this._groupRoots.set(group, roots = this._group(group));
481
+ return roots.get(arm);
482
+ }
483
+ var _constraint_precedingConditions;
484
+ var conditions = (_constraint_precedingConditions = constraint.precedingConditions) != null ? _constraint_precedingConditions : [];
485
+ var root = constraint.condition ? this._condition(constraint.condition) : conditions.length ? 1 : this._opaque(this._unknownConstraintKey(constraint));
486
+ for(var _iterator = _create_for_of_iterator_helper_loose(conditions), _step; !(_step = _iterator()).done;){
487
+ var condition = _step.value;
488
+ root = this.and(root, this._condition(condition));
489
+ }
490
+ return root;
491
+ };
492
+ _proto._sourceArm = function _sourceArm(arm) {
493
+ if (arm.value !== undefined) return Number(arm.value);
494
+ var root = 1;
495
+ var _arm_predicates;
496
+ for(var _iterator = _create_for_of_iterator_helper_loose((_arm_predicates = arm.predicates) != null ? _arm_predicates : []), _step; !(_step = _iterator()).done;){
497
+ var term = _step.value;
498
+ var condition = this._sources.get(term.condition);
499
+ if (condition === undefined) {
500
+ var known = this._sourceFacts.get(term.condition);
501
+ condition = known ? this._condition(known) : this._opaque(this._sourceKey(term.condition));
502
+ this._sources.set(term.condition, condition);
503
+ }
504
+ root = this.and(root, term.negated ? this.not(condition) : condition);
505
+ }
506
+ return root;
507
+ };
508
+ _proto._group = function _group(group) {
509
+ var arms = this._groups.get(group);
510
+ var count = groupArmCount(arms);
511
+ var representative = arms.values().next().value;
512
+ var roots = new Map();
513
+ var remaining = 1;
514
+ for(var arm = 0; arm < count; arm++){
515
+ var _representative_conditionalReachableArms;
516
+ var constraint = arms.get(arm);
517
+ if (((_representative_conditionalReachableArms = representative.conditionalReachableArms) == null ? void 0 : _representative_conditionalReachableArms[arm]) === false) {
518
+ roots.set(arm, 0);
519
+ continue;
520
+ }
521
+ var last = representative.conditionalComplete && arm === count - 1;
522
+ var condition = last ? 1 : hasSourceFacts(constraint == null ? void 0 : constraint.sourceArm) ? this._sourceArm(constraint.sourceArm) : (constraint == null ? void 0 : constraint.condition) ? this._condition(constraint.condition) : this._opaque(groupArmKey(group, arm));
523
+ var _constraint_precedingConditions;
524
+ for(var _iterator = _create_for_of_iterator_helper_loose((_constraint_precedingConditions = constraint == null ? void 0 : constraint.precedingConditions) != null ? _constraint_precedingConditions : []), _step; !(_step = _iterator()).done;){
525
+ var preceding = _step.value;
526
+ condition = this.and(condition, this._condition(preceding));
527
+ }
528
+ roots.set(arm, this.and(remaining, condition));
529
+ remaining = this.and(remaining, this.not(condition));
530
+ }
531
+ return roots;
532
+ };
533
+ _proto._condition = function _condition(condition) {
534
+ var cached = this._conditions.get(condition);
535
+ if (cached !== undefined) return cached;
536
+ var result;
537
+ if (condition.kind === "constant") result = Number(condition.value);
538
+ else if (condition.kind === "expression" && !condition.opaque) {
539
+ var conjunction = condition.operator === "&&";
540
+ result = Number(conjunction);
541
+ for(var _iterator = _create_for_of_iterator_helper_loose(condition.operands), _step; !(_step = _iterator()).done;){
542
+ var operand = _step.value;
543
+ result = this._apply(conjunction ? "and" : "or", result, this._condition(operand));
544
+ }
545
+ if (condition.negated) result = this.not(result);
546
+ } else if (condition.kind === "expression" || !isExactCondition(condition)) {
547
+ result = this._opaque(opaqueConditionKey(condition));
548
+ if (condition.kind === "expression" && condition.negated) result = this.not(result);
549
+ } else {
550
+ var variable = this._variableIds.get(macroKey(condition));
551
+ var domain = this._variables[variable];
552
+ var ranges;
553
+ if (condition.kind === "defined") ranges = condition.defined ? [
554
+ [
555
+ 1,
556
+ domain.size
557
+ ]
558
+ ] : [
559
+ [
560
+ 0,
561
+ 1
562
+ ]
563
+ ];
564
+ else {
565
+ var start = domain.indices.get(condition.value) + 1;
566
+ var end = domain.indices.get(condition.value + 1) + 1;
567
+ switch(condition.operator){
568
+ case "==":
569
+ ranges = [
570
+ [
571
+ start,
572
+ end
573
+ ]
574
+ ];
575
+ break;
576
+ case "!=":
577
+ ranges = [
578
+ [
579
+ 1,
580
+ start
581
+ ],
582
+ [
583
+ end,
584
+ domain.size
585
+ ]
586
+ ];
587
+ break;
588
+ case "<":
589
+ ranges = [
590
+ [
591
+ 1,
592
+ start
593
+ ]
594
+ ];
595
+ break;
596
+ case "<=":
597
+ ranges = [
598
+ [
599
+ 1,
600
+ end
601
+ ]
602
+ ];
603
+ break;
604
+ case ">":
605
+ ranges = [
606
+ [
607
+ end,
608
+ domain.size
609
+ ]
610
+ ];
611
+ break;
612
+ case ">=":
613
+ ranges = [
614
+ [
615
+ start,
616
+ domain.size
617
+ ]
618
+ ];
619
+ break;
620
+ }
621
+ if (compareZero(condition.operator, condition.value)) ranges.push([
622
+ 0,
623
+ 1
624
+ ]);
625
+ }
626
+ result = this._ranges(variable, ranges);
627
+ }
628
+ this._conditions.set(condition, result);
629
+ return result;
630
+ };
631
+ _proto._sourceKey = function _sourceKey(condition) {
632
+ var key = this._sourceKeys.get(condition);
633
+ if (key === undefined) {
634
+ key = condition.kind === "opaque" ? "source-opaque:" + condition.identity : "source-expression:" + JSON.stringify([
635
+ condition.expression,
636
+ condition.versions
637
+ ]);
638
+ this._sourceKeys.set(condition, key);
639
+ }
640
+ return key;
641
+ };
642
+ _proto._unknownConstraintKey = function _unknownConstraintKey(constraint) {
643
+ return "constraint:" + this._constraints.get(constraint);
644
+ };
645
+ _proto._opaque = function _opaque(key) {
646
+ return this._ranges(this._variableIds.get(key), [
647
+ [
648
+ 1,
649
+ 2
650
+ ]
651
+ ]);
652
+ };
653
+ _proto._ranges = function _ranges(variable, ranges) {
654
+ var _loop = function(index) {
655
+ var start = boundaries[index];
656
+ ends.push(boundaries[index + 1]);
657
+ children.push(Number(ranges.some(function(param) {
658
+ var left = param[0], right = param[1];
659
+ return left <= start && start < right;
660
+ })));
661
+ };
662
+ var size = this._variables[variable].size;
663
+ var boundaries = Array.from(new Set([].concat([
664
+ 0,
665
+ size
666
+ ], ranges.flat()))).sort(function(left, right) {
667
+ return left - right;
668
+ });
669
+ var ends = [], children = [];
670
+ for(var index = 0; index < boundaries.length - 1; index++)_loop(index);
671
+ return this._node(variable, ends, children);
672
+ };
673
+ _proto._node = function _node(variable, ends, children) {
674
+ if ((this._remainingWork -= children.length) < 0) return ShaderConditionDiagram.UNKNOWN;
675
+ var compactEnds = [], compactChildren = [];
676
+ for(var index = 0; index < children.length; index++){
677
+ if (compactChildren[compactChildren.length - 1] === children[index]) compactEnds[compactEnds.length - 1] = ends[index];
678
+ else {
679
+ compactEnds.push(ends[index]);
680
+ compactChildren.push(children[index]);
681
+ }
682
+ }
683
+ if (compactChildren.length === 1) return compactChildren[0];
684
+ var key = variable + "|" + compactEnds.join(",") + "|" + compactChildren.join(",");
685
+ var result = this._unique.get(key);
686
+ if (result === undefined) {
687
+ result = this._nodes.length;
688
+ this._nodes.push({
689
+ variable: variable,
690
+ ends: compactEnds,
691
+ children: compactChildren
692
+ });
693
+ this._unique.set(key, result);
694
+ }
695
+ return result;
696
+ };
697
+ _proto._apply = function _apply(operator, left, right) {
698
+ var cached = this._operationResult(operator, left, right);
699
+ if (cached !== undefined) return cached;
700
+ var pending = [
701
+ [
702
+ left,
703
+ right
704
+ ]
705
+ ];
706
+ while(pending.length){
707
+ if (--this._remainingWork < 0) return ShaderConditionDiagram.UNKNOWN;
708
+ var _pending_ = pending[pending.length - 1], _$left = _pending_[0], _$right = _pending_[1];
709
+ if (this._operationResult(operator, _$left, _$right) !== undefined) {
710
+ pending.pop();
711
+ continue;
712
+ }
713
+ var a = this._nodes[_$left], b = this._nodes[_$right];
714
+ var variable = Math.min(a.variable, b.variable), size = this._variables[variable].size;
715
+ var aEnds = a.variable === variable ? a.ends : [
716
+ size
717
+ ], aChildren = a.variable === variable ? a.children : [
718
+ _$left
719
+ ];
720
+ var bEnds = b.variable === variable ? b.ends : [
721
+ size
722
+ ], bChildren = b.variable === variable ? b.children : [
723
+ _$right
724
+ ];
725
+ if ((this._remainingWork -= aEnds.length + bEnds.length) < 0) return ShaderConditionDiagram.UNKNOWN;
726
+ var ends = [], children = [];
727
+ var ready = true, i = 0, j = 0;
728
+ while(i < aEnds.length && j < bEnds.length){
729
+ var end = Math.min(aEnds[i], bEnds[j]);
730
+ var child = this._operationResult(operator, aChildren[i], bChildren[j]);
731
+ if (child === undefined) {
732
+ pending.push([
733
+ aChildren[i],
734
+ bChildren[j]
735
+ ]);
736
+ ready = false;
737
+ }
738
+ ends.push(end);
739
+ children.push(child);
740
+ if (aEnds[i] === end) i++;
741
+ if (bEnds[j] === end) j++;
742
+ }
743
+ if (!ready) continue;
744
+ this._operations.set(operationKey(operator, _$left, _$right), this._node(variable, ends, children));
745
+ pending.pop();
746
+ }
747
+ return this._operationResult(operator, left, right);
748
+ };
749
+ _proto._operationResult = function _operationResult(operator, left, right) {
750
+ if (left === right) return left;
751
+ if (operator === "and") {
752
+ if (!left || !right) return 0;
753
+ if (left === 1) return right;
754
+ if (right === 1) return left;
755
+ } else {
756
+ if (left === 1 || right === 1) return 1;
757
+ if (!left) return right;
758
+ if (!right) return left;
759
+ }
760
+ return this._operations.get(operationKey(operator, left, right));
761
+ };
762
+ _proto._transform = function _transform(root, mode) {
763
+ var _this = this;
764
+ var cache = mode === "not" ? this._negations : this._knownConditions;
765
+ var cached = cache.get(root);
766
+ if (cached !== undefined) return cached;
767
+ var pending = [
768
+ root
769
+ ];
770
+ while(pending.length){
771
+ var current = pending[pending.length - 1];
772
+ if (cache.has(current)) {
773
+ pending.pop();
774
+ continue;
775
+ }
776
+ var node = this._nodes[current];
777
+ if ((this._remainingWork -= node.children.length + 1) < 0) {
778
+ return mode === "known" ? ShaderConditionDiagram.FALSE : ShaderConditionDiagram.UNKNOWN;
779
+ }
780
+ var ready = true;
781
+ for(var _iterator = _create_for_of_iterator_helper_loose(node.children), _step; !(_step = _iterator()).done;){
782
+ var child = _step.value;
783
+ if (cache.has(child)) continue;
784
+ pending.push(child);
785
+ ready = false;
786
+ }
787
+ if (!ready) continue;
788
+ var children = node.children.map(function(child) {
789
+ return cache.get(child);
790
+ });
791
+ var result = mode === "known" && this._variables[node.variable].opaque ? children.reduce(function(left, right) {
792
+ return _this.and(left, right);
793
+ }, 1) : this._node(node.variable, node.ends, children);
794
+ // Only configurations proven true may survive the witness transform
795
+ if (mode === "known" && result === ShaderConditionDiagram.UNKNOWN) result = ShaderConditionDiagram.FALSE;
796
+ cache.set(current, result);
797
+ if (mode === "not" && this._remainingWork >= 0) cache.set(result, current);
798
+ pending.pop();
799
+ }
800
+ return cache.get(root);
801
+ };
802
+ return ShaderConditionDiagram;
803
+ }();
804
+ ShaderConditionDiagram.FALSE = 0;
805
+ ShaderConditionDiagram.TRUE = 1;
806
+ // An unknown terminal must not correlate independent incomplete proofs
807
+ ShaderConditionDiagram.UNKNOWN = 2;
808
+ function operationKey(operator, left, right) {
809
+ return left < right ? operator + ":" + left + ":" + right : operator + ":" + right + ":" + left;
810
+ }
811
+ function macroKey(condition) {
812
+ return "macro:" + condition.name + ":" + condition.version;
813
+ }
814
+ function hasSourceFacts(arm) {
815
+ return arm !== undefined && (arm.value !== undefined || arm.predicates !== undefined);
816
+ }
817
+ function groupArmKey(group, arm) {
818
+ return "group:" + group + ":" + arm;
819
+ }
820
+ function groupArmCount(arms) {
821
+ var count = 0;
822
+ var _constraint_conditionalArmCount;
823
+ for(var _iterator = _create_for_of_iterator_helper_loose(arms), _step; !(_step = _iterator()).done;){
824
+ var _step_value = _step.value, arm = _step_value[0], constraint = _step_value[1];
825
+ count = Math.max(count, arm + 1, (_constraint_conditionalArmCount = constraint.conditionalArmCount) != null ? _constraint_conditionalArmCount : 0);
826
+ }
827
+ return count;
828
+ }
829
+ function isExactCondition(condition) {
830
+ return condition.kind === "defined" || Number.isInteger(condition.value) && condition.value >= INTEGER_MINIMUM && condition.value < INTEGER_END;
831
+ }
832
+ function opaqueConditionKey(condition) {
833
+ return condition.kind === "expression" ? "expression:" + JSON.stringify([
834
+ condition.expression,
835
+ condition.names,
836
+ condition.versions
837
+ ]) : "invalid:" + condition.name + ":" + condition.version + ":" + (condition.kind === "comparison" ? condition.operator + ":" + condition.value : condition.defined);
838
+ }
839
+ function compareZero(operator, value) {
840
+ switch(operator){
841
+ case "==":
842
+ return value === 0;
843
+ case "!=":
844
+ return value !== 0;
845
+ case "<":
846
+ return value > 0;
847
+ case "<=":
848
+ return value >= 0;
849
+ case ">":
850
+ return value < 0;
851
+ case ">=":
852
+ return value <= 0;
853
+ }
854
+ }
855
+
856
+ /**
857
+ * Analyzer-only graph and reachability information derived from neutral shader IR.
858
+ * @internal
859
+ */ var ShaderAnalysisInfo = /*#__PURE__*/ function() {
860
+ function ShaderAnalysisInfo(ir, coreInfo) {
861
+ this.ir = ir;
862
+ this.coreInfo = coreInfo;
863
+ this._glFragColorReferences = [];
864
+ this._glFragDataConditionalReferences = [];
865
+ this.glFragDataReferences = [];
866
+ this._callFacts = new Map();
867
+ this._writes = new Map();
868
+ this._unknownEffects = new Map();
869
+ this._indexedMacroReferences = new Set();
870
+ this._indexedMacroArguments = new Map();
871
+ this._functionsByName = new Map();
872
+ this._branches = new Set();
873
+ this._reachableByEntry = new Map();
874
+ this._reachableByFunction = new Map();
875
+ this._writeReachableByFunction = new Map();
876
+ this._indexFunctions(ir.program);
877
+ this._indexFunctionBodies();
878
+ for(var _i = 0, _iter = [
879
+ coreInfo.vertexEntry,
880
+ coreInfo.fragmentEntry
881
+ ]; _i < _iter.length; _i++){
882
+ var entry = _iter[_i];
883
+ var _fn_branchSignature;
884
+ for(var _iterator = _create_for_of_iterator_helper_loose(entry.functions), _step; !(_step = _iterator()).done;){
885
+ var fn = _step.value;
886
+ this._branches.add((_fn_branchSignature = fn.branchSignature) != null ? _fn_branchSignature : fn.astNode.protoType.ident.branch);
887
+ }
888
+ }
889
+ this._conditions = new ShaderConditionDiagram(this._branches);
890
+ this._branches.clear();
891
+ }
892
+ var _proto = ShaderAnalysisInfo.prototype;
893
+ /**
894
+ * Finds every function reachable from an entry, including the entry declarations themselves.
895
+ * @param entry - Entry point to traverse.
896
+ * @returns Reachable function identities.
897
+ */ _proto.reachableFunctions = function reachableFunctions(entry) {
898
+ return new Set(this._getReachableConditions(entry).keys());
899
+ };
900
+ /**
901
+ * Determines whether a branch inside a function is reachable from an entry under one consistent
902
+ * macro configuration. An unresolved proof is not treated as evidence for a diagnostic.
903
+ * @param entry - Entry point from which calls originate.
904
+ * @param functionNode - Function containing the branch.
905
+ * @param branch - Branch at the diagnostic site.
906
+ * @returns Whether at least one macro configuration is proven to reach the site.
907
+ */ _proto.isFunctionBranchReachable = function isFunctionBranchReachable(entry, functionNode, branch) {
908
+ var _this__getReachableConditions_get;
909
+ var reachable = (_this__getReachableConditions_get = this._getReachableConditions(entry).get(functionNode)) != null ? _this__getReachableConditions_get : ShaderConditionDiagram.FALSE;
910
+ return this._conditions.reachability(this._conditions.and(reachable, this._conditions.branch(branch))) === "reachable";
911
+ };
912
+ /**
913
+ * Classifies whether every reachable entry configuration writes a source identifier or builtin semantic.
914
+ * @param entry - Entry point whose call graph is inspected.
915
+ * @param target - Leftmost source identifier or builtin semantic of the assignment target.
916
+ * @returns Proven coverage, a proven missing-write configuration, or an unresolved complex condition.
917
+ */ _proto.getReachableWriteCoverage = function getReachableWriteCoverage(entry, target) {
918
+ if (!entry.functions.length) return "unknown";
919
+ var diagram = this._conditions;
920
+ var result = "covered";
921
+ for(var _iterator = _create_for_of_iterator_helper_loose(entry.functions), _step; !(_step = _iterator()).done;){
922
+ var entryFunction = _step.value;
923
+ var writes = [];
924
+ var unknownEffects = [];
925
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this._getFunctionReachableConditions(entryFunction, true)), _step1; !(_step1 = _iterator1()).done;){
926
+ var _step_value = _step1.value, functionNode = _step_value[0], reachable = _step_value[1];
927
+ var _this__unknownEffects_get;
928
+ for(var _iterator2 = _create_for_of_iterator_helper_loose((_this__unknownEffects_get = this._unknownEffects.get(functionNode)) != null ? _this__unknownEffects_get : []), _step2; !(_step2 = _iterator2()).done;){
929
+ var effect = _step2.value;
930
+ unknownEffects.push(diagram.and(reachable, diagram.branch(effect, true)));
931
+ }
932
+ var _this__writes_get;
933
+ for(var _iterator3 = _create_for_of_iterator_helper_loose((_this__writes_get = this._writes.get(functionNode)) != null ? _this__writes_get : []), _step3; !(_step3 = _iterator3()).done;){
934
+ var write = _step3.value;
935
+ if (write.target !== target) continue;
936
+ writes.push(diagram.and(reachable, diagram.branch(write.branch, true)));
937
+ }
938
+ }
939
+ var _entryFunction_branchSignature;
940
+ var entryCondition = diagram.branch((_entryFunction_branchSignature = entryFunction.branchSignature) != null ? _entryFunction_branchSignature : entryFunction.astNode.protoType.ident.branch, true);
941
+ var missing = diagram.and(entryCondition, diagram.not(diagram.orAll(writes)));
942
+ if (missing === ShaderConditionDiagram.FALSE) continue;
943
+ if (diagram.reachability(diagram.and(missing, diagram.not(diagram.orAll(unknownEffects)))) === "reachable") {
944
+ return "uncovered";
945
+ }
946
+ result = "unknown";
947
+ }
948
+ return result;
949
+ };
950
+ /**
951
+ * Classifies whether a function returns under every macro configuration reaching its declaration.
952
+ * @param functionNode - Function whose body is inspected.
953
+ * @returns Proven return coverage, a missing-return configuration, or unresolved coverage.
954
+ */ _proto.getReturnCoverage = function getReturnCoverage(functionNode) {
955
+ var returns = this._returnCondition(functionNode.statements);
956
+ // A body with no possible return is invalid whenever its declaration is selected.
957
+ return returns === ShaderConditionDiagram.FALSE ? "uncovered" : this._conditions.coverage(returns, this._conditions.branch(functionNode.protoType.ident.branch, true));
958
+ };
959
+ /**
960
+ * Finds references to the legacy fragment output that a fragment entry can actually reach.
961
+ * @param entry - Fragment entry whose conditional call paths are inspected.
962
+ * @returns Source ranges proven reachable under at least one consistent macro configuration.
963
+ */ _proto.reachableFragmentOutput0References = function reachableFragmentOutput0References(entry) {
964
+ var locations = [];
965
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._glFragColorReferences), _step; !(_step = _iterator()).done;){
966
+ var reference = _step.value;
967
+ if (this.isFunctionBranchReachable(entry, reference.functionNode, reference.branch)) {
968
+ locations.push(reference.location);
969
+ }
970
+ }
971
+ return locations;
972
+ };
973
+ /**
974
+ * Finds legacy fragment-output references reachable from one exact entry declaration.
975
+ * @param entryFunction - Exact macro-alternative function selected as the fragment entry.
976
+ * @returns Source ranges proven reachable under the entry declaration's macro constraints.
977
+ */ _proto.reachableFragmentOutput0ReferencesFrom = function reachableFragmentOutput0ReferencesFrom(entryFunction) {
978
+ var reachable = this._getFunctionReachableConditions(entryFunction);
979
+ var diagram = this._conditions;
980
+ return this._glFragColorReferences.filter(function(reference) {
981
+ var _reachable_get;
982
+ return diagram.reachability(diagram.and((_reachable_get = reachable.get(reference.functionNode)) != null ? _reachable_get : ShaderConditionDiagram.FALSE, diagram.branch(reference.branch))) === "reachable";
983
+ }).map(function(reference) {
984
+ return reference.location;
985
+ });
986
+ };
987
+ /**
988
+ * Finds a macro configuration in which one fragment entry can reach both legacy output forms.
989
+ * @param entryFunction - Exact macro-alternative function selected as the fragment entry.
990
+ * @returns The conflicting output ranges, or `undefined` when coexistence is disproven or unknown.
991
+ */ _proto.coexistingLegacyFragmentOutputsFrom = function coexistingLegacyFragmentOutputsFrom(entryFunction) {
992
+ var reachable = this._getFunctionReachableConditions(entryFunction);
993
+ var diagram = this._conditions;
994
+ var at = function(reference) {
995
+ var _reachable_get;
996
+ return diagram.and((_reachable_get = reachable.get(reference.functionNode)) != null ? _reachable_get : ShaderConditionDiagram.FALSE, diagram.branch(reference.branch));
997
+ };
998
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._glFragColorReferences), _step; !(_step = _iterator()).done;){
999
+ var output0 = _step.value;
1000
+ var output0Condition = at(output0);
1001
+ if (output0Condition === ShaderConditionDiagram.FALSE) continue;
1002
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(this._glFragDataConditionalReferences), _step1; !(_step1 = _iterator1()).done;){
1003
+ var outputArray = _step1.value;
1004
+ if (diagram.reachability(diagram.and(output0Condition, at(outputArray))) === "reachable") {
1005
+ return {
1006
+ output0: output0.location,
1007
+ outputArray: outputArray.location
1008
+ };
1009
+ }
1010
+ }
1011
+ }
1012
+ return;
1013
+ };
1014
+ /**
1015
+ * Returns every parsed function declaration.
1016
+ * @returns Function identities retained by the neutral IR.
1017
+ */ _proto.functions = function functions() {
1018
+ var _result;
1019
+ var result = [];
1020
+ this._functionsByName.forEach(function(functions) {
1021
+ return (_result = result).push.apply(_result, [].concat(functions));
1022
+ });
1023
+ return result;
1024
+ };
1025
+ /**
1026
+ * Finds satisfiable mutual recursion without enumerating conditional call paths or all simple cycles.
1027
+ * @returns One witness per canonical minimum participant; an opaque-dependent cycle has no fixed chain.
1028
+ */ _proto.mutualRecursionWitnesses = function mutualRecursionWitnesses() {
1029
+ var _this, _loop = function() {
1030
+ var _this2, _loop = function() {
1031
+ var marker = _step1.value;
1032
+ var name = marker.protoType.ident.lexeme;
1033
+ var allowed = new Set(Array.from(component).filter(function(fn) {
1034
+ return fn.protoType.ident.lexeme > name || fn.protoType.ident.lexeme === name && order.get(fn) >= order.get(marker);
1035
+ }));
1036
+ if (allowed.size < 2) return "continue";
1037
+ var declaration = diagram.branch(marker.protoType.ident.branch);
1038
+ var seeds = [];
1039
+ var _this__callFacts_get;
1040
+ for(var _iterator = _create_for_of_iterator_helper_loose((_this__callFacts_get = _this2._callFacts.get(marker)) != null ? _this__callFacts_get : []), _step; !(_step = _iterator()).done;){
1041
+ var call = _step.value;
1042
+ if (call.callee === marker || !allowed.has(call.callee)) continue;
1043
+ seeds.push([
1044
+ call.callee,
1045
+ diagram.and(declaration, _this2._callCondition(call, false))
1046
+ ]);
1047
+ }
1048
+ var _this__propagateConditions_get;
1049
+ var cycleCondition = (_this__propagateConditions_get = _this2._propagateConditions(seeds, false, allowed, marker).get(marker)) != null ? _this__propagateConditions_get : ShaderConditionDiagram.FALSE;
1050
+ if (diagram.reachability(cycleCondition) !== "reachable") return "continue";
1051
+ var witness = diagram.knownWitness(cycleCondition);
1052
+ witnesses.push({
1053
+ marker: marker,
1054
+ cycle: _this2._findCycleWitness(marker, allowed, witness)
1055
+ });
1056
+ };
1057
+ var component = _step.value;
1058
+ var members = functions.filter(function(fn) {
1059
+ return component.has(fn);
1060
+ });
1061
+ var simple = members.every(function(fn) {
1062
+ var _this__callFacts_get;
1063
+ return new Set(((_this__callFacts_get = _this1._callFacts.get(fn)) != null ? _this__callFacts_get : []).filter(function(call) {
1064
+ return call.callee !== fn && component.has(call.callee);
1065
+ }).map(function(call) {
1066
+ return call.callee;
1067
+ })).size === 1;
1068
+ });
1069
+ var minimum = members.reduce(function(left, right) {
1070
+ return right.protoType.ident.lexeme < left.protoType.ident.lexeme ? right : left;
1071
+ });
1072
+ // A simple component has only one non-self cycle, regardless of its conditional edge alternatives.
1073
+ for(var _iterator = _create_for_of_iterator_helper_loose(simple ? [
1074
+ minimum
1075
+ ] : members), _step1; !(_step1 = _iterator()).done;)_this2 = _this, _loop();
1076
+ };
1077
+ var _this1 = this;
1078
+ var witnesses = [];
1079
+ var functions = this.functions();
1080
+ var order = new Map(functions.map(function(fn, index) {
1081
+ return [
1082
+ fn,
1083
+ index
1084
+ ];
1085
+ }));
1086
+ var diagram = this._conditions;
1087
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._cyclicComponents()), _step; !(_step = _iterator()).done;)_this = this, _loop();
1088
+ return witnesses;
1089
+ };
1090
+ _proto._indexFunctions = function _indexFunctions(root) {
1091
+ var pending = [
1092
+ root
1093
+ ];
1094
+ while(pending.length){
1095
+ var node = pending.pop();
1096
+ if (_instanceof(node, BaseToken)) {
1097
+ this._branches.add(node.branch);
1098
+ continue;
1099
+ }
1100
+ this._branches.add(node._branch);
1101
+ if (_instanceof(node, ASTNode.FunctionDefinition)) {
1102
+ var name = node.protoType.ident.lexeme;
1103
+ var _this__functionsByName_get;
1104
+ var functions = (_this__functionsByName_get = this._functionsByName.get(name)) != null ? _this__functionsByName_get : [];
1105
+ functions.push(node);
1106
+ this._functionsByName.set(name, functions);
1107
+ }
1108
+ for(var index = node.children.length - 1; index >= 0; index--){
1109
+ var child = node.children[index];
1110
+ if (_instanceof(child, TreeNode) || _instanceof(child, BaseToken)) pending.push(child);
1111
+ }
1112
+ }
1113
+ };
1114
+ _proto._indexFunctionBodies = function _indexFunctionBodies() {
1115
+ var _this = this;
1116
+ this._functionsByName.forEach(function(functions) {
1117
+ for(var _iterator = _create_for_of_iterator_helper_loose(functions), _step; !(_step = _iterator()).done;){
1118
+ var functionNode = _step.value;
1119
+ _this._walkFunction(functionNode, functionNode.statements);
1120
+ }
1121
+ });
1122
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._callFacts), _step; !(_step = _iterator()).done;){
1123
+ var _loop = function() {
1124
+ var call = _step1.value;
1125
+ var _branchesByCallee_get;
1126
+ var branches = (_branchesByCallee_get = branchesByCallee.get(call.callee)) != null ? _branchesByCallee_get : [];
1127
+ if (branches.some(function(branch) {
1128
+ return sameBranch(branch, call.branch);
1129
+ })) return "continue";
1130
+ branches.push(call.branch);
1131
+ branchesByCallee.set(call.callee, branches);
1132
+ unique.push(call);
1133
+ };
1134
+ var _step_value = _step.value, caller = _step_value[0], calls = _step_value[1];
1135
+ var unique = [];
1136
+ var branchesByCallee = new Map();
1137
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(calls), _step1; !(_step1 = _iterator1()).done;)_loop();
1138
+ this._callFacts.set(caller, unique);
1139
+ }
1140
+ };
1141
+ _proto._walkFunction = function _walkFunction(functionNode, node) {
1142
+ var _this = this;
1143
+ walkEffectiveShaderSyntax(node, function(node, branch, location) {
1144
+ _this._branches.add(branch);
1145
+ if (_instanceof(node, ASTNode.PostfixExpression) && node.children.length === 4) {
1146
+ var base = node.children[0];
1147
+ if (_instanceof(base, TreeNode)) {
1148
+ var target = assignmentTargetBase(base);
1149
+ if (_instanceof(target, ASTNode.MacroCallSymbol) || _instanceof(target, ASTNode.MacroCallFunction)) {
1150
+ _this._indexedMacroReferences.add(target.location.start.index);
1151
+ }
1152
+ }
1153
+ }
1154
+ if (_instanceof(node, ASTNode.FunctionCallGeneric)) _this._recordCall(functionNode, node, branch);
1155
+ if (_instanceof(node, ASTNode.VariableIdentifier)) {
1156
+ if (node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutput0) {
1157
+ _this._glFragColorReferences.push({
1158
+ functionNode: functionNode,
1159
+ location: location,
1160
+ branch: branch
1161
+ });
1162
+ } else if (node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray) {
1163
+ var _this__indexedMacroArguments_get;
1164
+ if (!((_this__indexedMacroArguments_get = _this._indexedMacroArguments.get(node)) != null ? _this__indexedMacroArguments_get : []).some(function(indexedBranch) {
1165
+ return sameBranch(indexedBranch, branch);
1166
+ })) {
1167
+ _this.glFragDataReferences.push(location);
1168
+ }
1169
+ _this._glFragDataConditionalReferences.push({
1170
+ functionNode: functionNode,
1171
+ location: location,
1172
+ branch: branch
1173
+ });
1174
+ }
1175
+ }
1176
+ if (_instanceof(node, ASTNode.AssignmentExpression) && node.children.length === 3) {
1177
+ var lhs = node.children[0];
1178
+ if (_instanceof(lhs, TreeNode)) {
1179
+ _this._recordAssignmentTarget(functionNode, lhs, branch);
1180
+ }
1181
+ }
1182
+ }, function(syntax, branch, location) {
1183
+ _this._branches.add(branch);
1184
+ var indexedAlias = _this._indexedMacroReferences.has(location.start.index);
1185
+ if (indexedAlias && _instanceof(syntax.valueTarget, TreeNode)) {
1186
+ var argument = assignmentTargetBase(syntax.valueTarget);
1187
+ if (_instanceof(argument, ASTNode.VariableIdentifier)) {
1188
+ var _this__indexedMacroArguments_get;
1189
+ var branches = (_this__indexedMacroArguments_get = _this._indexedMacroArguments.get(argument)) != null ? _this__indexedMacroArguments_get : [];
1190
+ branches.push(branch);
1191
+ _this._indexedMacroArguments.set(argument, branches);
1192
+ }
1193
+ }
1194
+ var _syntax_writtenTargets;
1195
+ for(var _iterator = _create_for_of_iterator_helper_loose((_syntax_writtenTargets = syntax.writtenTargets) != null ? _syntax_writtenTargets : []), _step; !(_step = _iterator()).done;){
1196
+ var target = _step.value;
1197
+ _this._recordAssignmentTarget(functionNode, target, branch);
1198
+ }
1199
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(syntax.references), _step1; !(_step1 = _iterator1()).done;){
1200
+ var reference = _step1.value;
1201
+ if (reference.builtinSemantic === ShaderBuiltinSemantic.FragmentOutput0) {
1202
+ _this._glFragColorReferences.push({
1203
+ functionNode: functionNode,
1204
+ location: location,
1205
+ branch: branch
1206
+ });
1207
+ } else if (reference.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray) {
1208
+ if (!reference.indexed && !(indexedAlias && syntax.valueTarget === ShaderBuiltinSemantic.FragmentOutputArray)) {
1209
+ _this.glFragDataReferences.push(location);
1210
+ }
1211
+ _this._glFragDataConditionalReferences.push({
1212
+ functionNode: functionNode,
1213
+ location: location,
1214
+ branch: branch
1215
+ });
1216
+ }
1217
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(reference.functions), _step2; !(_step2 = _iterator2()).done;){
1218
+ var candidate = _step2.value;
1219
+ var _this__callFacts_get;
1220
+ var facts = (_this__callFacts_get = _this._callFacts.get(functionNode)) != null ? _this__callFacts_get : [];
1221
+ facts.push({
1222
+ callee: candidate.astNode,
1223
+ branch: branch
1224
+ });
1225
+ _this._callFacts.set(functionNode, facts);
1226
+ }
1227
+ }
1228
+ }, EMPTY_BRANCH, undefined, function(branch) {
1229
+ _this._branches.add(branch);
1230
+ var _this__unknownEffects_get;
1231
+ var effects = (_this__unknownEffects_get = _this._unknownEffects.get(functionNode)) != null ? _this__unknownEffects_get : [];
1232
+ effects.push(branch);
1233
+ _this._unknownEffects.set(functionNode, effects);
1234
+ });
1235
+ };
1236
+ _proto._recordCall = function _recordCall(caller, call, branch) {
1237
+ if (branch === void 0) branch = call._branch;
1238
+ var _call_fnSymbols;
1239
+ var candidates = (_call_fnSymbols = call.fnSymbols) != null ? _call_fnSymbols : _instanceof(call.fnSymbol, FnSymbol) ? [
1240
+ call.fnSymbol
1241
+ ] : [];
1242
+ if (!candidates.length) return;
1243
+ var _this__callFacts_get;
1244
+ var facts = (_this__callFacts_get = this._callFacts.get(caller)) != null ? _this__callFacts_get : [];
1245
+ for(var _iterator = _create_for_of_iterator_helper_loose(candidates), _step; !(_step = _iterator()).done;){
1246
+ var candidate = _step.value;
1247
+ facts.push({
1248
+ callee: candidate.astNode,
1249
+ branch: branch
1250
+ });
1251
+ this._recordOutputParameterWrites(caller, call, candidate, branch);
1252
+ }
1253
+ this._callFacts.set(caller, facts);
1254
+ };
1255
+ _proto._returnCondition = function _returnCondition(root) {
1256
+ var diagram = this._conditions;
1257
+ var returns = [];
1258
+ var pending = [
1259
+ {
1260
+ node: root,
1261
+ returns: returns
1262
+ }
1263
+ ];
1264
+ while(pending.length){
1265
+ var current = pending.pop();
1266
+ if ("left" in current) {
1267
+ // A runtime if/else guarantees a return only where both arms terminate.
1268
+ current.returns.push(diagram.and(diagram.orAll(current.left), diagram.orAll(current.right)));
1269
+ continue;
1270
+ }
1271
+ var node = current.node, returns1 = current.returns;
1272
+ var branch = diagram.branch(node._branch, true);
1273
+ if (branch === ShaderConditionDiagram.FALSE) continue;
1274
+ if (_instanceof(node, ASTNode.JumpStatement)) {
1275
+ var keyword = node.children[0];
1276
+ if (_instanceof(keyword, BaseToken) && keyword.type === Keyword.RETURN) returns1.push(branch);
1277
+ } else if (_instanceof(node, ASTNode.SelectionStatement)) {
1278
+ if (node.children.length !== 7) continue;
1279
+ var left = [], right = [];
1280
+ pending.push({
1281
+ left: left,
1282
+ right: right,
1283
+ returns: returns1
1284
+ });
1285
+ pending.push({
1286
+ node: node.children[6],
1287
+ returns: right
1288
+ });
1289
+ pending.push({
1290
+ node: node.children[4],
1291
+ returns: left
1292
+ });
1293
+ } else if (_instanceof(node, ASTNode.IterationStatement)) {
1294
+ // Loop termination is not proven here, so missing return coverage remains unknown
1295
+ returns1.push(diagram.and(branch, ShaderConditionDiagram.UNKNOWN));
1296
+ } else if (_instanceof(node, ASTNode.Statement) || _instanceof(node, ASTNode.SimpleStatement) || _instanceof(node, ASTNode.CompoundStatement) || _instanceof(node, ASTNode.CompoundStatementNoScope) || _instanceof(node, ASTNode.StatementList) || _instanceof(node, ASTNode.MacroIfStatement) || _instanceof(node, ASTNode.MacroBranch)) {
1297
+ // Flatten sequential containers before unioning, including left-recursive statement lists.
1298
+ for(var index = node.children.length - 1; index >= 0; index--){
1299
+ var child = node.children[index];
1300
+ if (_instanceof(child, TreeNode)) pending.push({
1301
+ node: child,
1302
+ returns: returns1
1303
+ });
1304
+ }
1305
+ }
1306
+ }
1307
+ return diagram.orAll(returns);
1308
+ };
1309
+ _proto._getReachableConditions = function _getReachableConditions(entry) {
1310
+ var _this = this;
1311
+ var cached = this._reachableByEntry.get(entry);
1312
+ if (cached) return cached;
1313
+ var reachable = entry.functions.length === 1 ? this._getFunctionReachableConditions(entry.functions[0]) : this._propagateConditions(entry.functions.map(function(fn) {
1314
+ var _fn_branchSignature;
1315
+ return [
1316
+ fn.astNode,
1317
+ _this._conditions.branch((_fn_branchSignature = fn.branchSignature) != null ? _fn_branchSignature : fn.astNode.protoType.ident.branch)
1318
+ ];
1319
+ }), false);
1320
+ this._reachableByEntry.set(entry, reachable);
1321
+ return reachable;
1322
+ };
1323
+ _proto._getFunctionReachableConditions = function _getFunctionReachableConditions(entry, forWrites) {
1324
+ if (forWrites === void 0) forWrites = false;
1325
+ var cache = forWrites ? this._writeReachableByFunction : this._reachableByFunction;
1326
+ var cached = cache.get(entry);
1327
+ if (cached) return cached;
1328
+ var _entry_branchSignature;
1329
+ var reachable = this._propagateConditions([
1330
+ [
1331
+ entry.astNode,
1332
+ this._conditions.branch((_entry_branchSignature = entry.branchSignature) != null ? _entry_branchSignature : entry.astNode.protoType.ident.branch, forWrites)
1333
+ ]
1334
+ ], forWrites);
1335
+ cache.set(entry, reachable);
1336
+ return reachable;
1337
+ };
1338
+ _proto._callCondition = function _callCondition(call, forWrites) {
1339
+ return this._conditions.and(this._conditions.branch(call.branch, forWrites), this._conditions.branch(call.callee.protoType.ident.branch, forWrites));
1340
+ };
1341
+ _proto._propagateConditions = function _propagateConditions(seeds, forWrites, allowed, terminal) {
1342
+ var diagram = this._conditions;
1343
+ var reachable = new Map();
1344
+ var queued = new Map();
1345
+ var pending = [];
1346
+ var enqueue = function(fn, condition) {
1347
+ if (condition === ShaderConditionDiagram.FALSE || allowed && !allowed.has(fn)) return;
1348
+ var incoming = queued.get(fn);
1349
+ if (incoming) {
1350
+ incoming.push(condition);
1351
+ } else {
1352
+ queued.set(fn, [
1353
+ condition
1354
+ ]);
1355
+ pending.push(fn);
1356
+ }
1357
+ };
1358
+ for(var _iterator = _create_for_of_iterator_helper_loose(seeds), _step; !(_step = _iterator()).done;){
1359
+ var _step_value = _step.value, fn = _step_value[0], condition = _step_value[1];
1360
+ enqueue(fn, condition);
1361
+ }
1362
+ for(var index = 0; index < pending.length; index++){
1363
+ var fn1 = pending[index];
1364
+ var incoming = queued.get(fn1);
1365
+ queued.delete(fn1);
1366
+ var _reachable_get;
1367
+ var previous = (_reachable_get = reachable.get(fn1)) != null ? _reachable_get : ShaderConditionDiagram.FALSE;
1368
+ incoming.push(previous);
1369
+ // Batch incoming edges so high fan-in does not build every prefix of the same union.
1370
+ var condition1 = diagram.orAll(incoming);
1371
+ if (condition1 === previous) continue;
1372
+ reachable.set(fn1, condition1);
1373
+ if (fn1 === terminal) continue;
1374
+ var _this__callFacts_get;
1375
+ for(var _iterator1 = _create_for_of_iterator_helper_loose((_this__callFacts_get = this._callFacts.get(fn1)) != null ? _this__callFacts_get : []), _step1; !(_step1 = _iterator1()).done;){
1376
+ var call = _step1.value;
1377
+ enqueue(call.callee, diagram.and(condition1, this._callCondition(call, forWrites)));
1378
+ }
1379
+ }
1380
+ return reachable;
1381
+ };
1382
+ _proto._cyclicComponents = function _cyclicComponents() {
1383
+ var functions = this.functions();
1384
+ var reverse = new Map();
1385
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._callFacts), _step; !(_step = _iterator()).done;){
1386
+ var _step_value = _step.value, caller = _step_value[0], calls = _step_value[1];
1387
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(calls), _step1; !(_step1 = _iterator1()).done;){
1388
+ var callee = _step1.value.callee;
1389
+ var _reverse_get;
1390
+ var incoming = (_reverse_get = reverse.get(callee)) != null ? _reverse_get : [];
1391
+ incoming.push(caller);
1392
+ reverse.set(callee, incoming);
1393
+ }
1394
+ }
1395
+ var visited = new Set();
1396
+ var finished = [];
1397
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(functions), _step2; !(_step2 = _iterator2()).done;){
1398
+ var start = _step2.value;
1399
+ if (visited.has(start)) continue;
1400
+ var pending = [
1401
+ {
1402
+ node: start,
1403
+ finish: false
1404
+ }
1405
+ ];
1406
+ while(pending.length){
1407
+ var _pending_pop = pending.pop(), node = _pending_pop.node, finish = _pending_pop.finish;
1408
+ if (finish) {
1409
+ finished.push(node);
1410
+ continue;
1411
+ }
1412
+ if (visited.has(node)) continue;
1413
+ visited.add(node);
1414
+ pending.push({
1415
+ node: node,
1416
+ finish: true
1417
+ });
1418
+ var _this__callFacts_get;
1419
+ for(var _iterator3 = _create_for_of_iterator_helper_loose((_this__callFacts_get = this._callFacts.get(node)) != null ? _this__callFacts_get : []), _step3; !(_step3 = _iterator3()).done;){
1420
+ var callee1 = _step3.value.callee;
1421
+ pending.push({
1422
+ node: callee1,
1423
+ finish: false
1424
+ });
1425
+ }
1426
+ }
1427
+ }
1428
+ visited.clear();
1429
+ var components = [];
1430
+ while(finished.length){
1431
+ var start1 = finished.pop();
1432
+ if (visited.has(start1)) continue;
1433
+ var component = new Set();
1434
+ var pending1 = [
1435
+ start1
1436
+ ];
1437
+ while(pending1.length){
1438
+ var _pending;
1439
+ var node1 = pending1.pop();
1440
+ if (visited.has(node1)) continue;
1441
+ visited.add(node1);
1442
+ component.add(node1);
1443
+ var _reverse_get1;
1444
+ (_pending = pending1).push.apply(_pending, [].concat((_reverse_get1 = reverse.get(node1)) != null ? _reverse_get1 : []));
1445
+ }
1446
+ if (component.size > 1) components.push(component);
1447
+ }
1448
+ return components;
1449
+ };
1450
+ _proto._findCycleWitness = function _findCycleWitness(marker, allowed, witness) {
1451
+ if (witness === ShaderConditionDiagram.FALSE) return;
1452
+ var visited = new Set([
1453
+ marker
1454
+ ]);
1455
+ var stack = [
1456
+ {
1457
+ node: marker,
1458
+ next: 0
1459
+ }
1460
+ ];
1461
+ while(stack.length){
1462
+ var frame = stack[stack.length - 1];
1463
+ var _this__callFacts_get;
1464
+ var calls = (_this__callFacts_get = this._callFacts.get(frame.node)) != null ? _this__callFacts_get : [];
1465
+ if (frame.next === calls.length) {
1466
+ stack.pop();
1467
+ continue;
1468
+ }
1469
+ var call = calls[frame.next++];
1470
+ if (!allowed.has(call.callee) || call.callee === frame.node || this._conditions.coverage(this._callCondition(call, false), witness) !== "covered") continue;
1471
+ if (call.callee === marker && stack.length > 1) return stack.map(function(item) {
1472
+ return item.node;
1473
+ });
1474
+ if (!visited.has(call.callee)) {
1475
+ visited.add(call.callee);
1476
+ stack.push({
1477
+ node: call.callee,
1478
+ next: 0
1479
+ });
1480
+ }
1481
+ }
1482
+ };
1483
+ _proto._recordOutputParameterWrites = function _recordOutputParameterWrites(caller, call, callee, callBranch) {
1484
+ var argumentList = call.children[2];
1485
+ if (!_instanceof(argumentList, ASTNode.FunctionCallParameterList)) return;
1486
+ var _callee_astNode_protoType_parameterList;
1487
+ var parameters = (_callee_astNode_protoType_parameterList = callee.astNode.protoType.parameterList) != null ? _callee_astNode_protoType_parameterList : [];
1488
+ for(var i = 0, n = Math.min(parameters.length, argumentList.paramNodes.length); i < n; i++){
1489
+ var parameter = parameters[i].astNode;
1490
+ if (!_instanceof(parameter, ASTNode.ParameterDeclaration)) continue;
1491
+ if (!ParserUtils.hasQualifier(parameter, Keyword.OUT) && !ParserUtils.hasQualifier(parameter, Keyword.INOUT)) {
1492
+ continue;
1493
+ }
1494
+ var argument = argumentList.paramNodes[i];
1495
+ if (!_instanceof(argument, TreeNode)) continue;
1496
+ var _callee_branchSignature;
1497
+ var branch = combineBranches(callBranch, (_callee_branchSignature = callee.branchSignature) != null ? _callee_branchSignature : EMPTY_BRANCH);
1498
+ if (branch) this._recordAssignmentTarget(caller, argument, branch);
1499
+ }
1500
+ };
1501
+ _proto._recordAssignmentTarget = function _recordAssignmentTarget(functionNode, target, branch) {
1502
+ if (typeof target === "string") {
1503
+ this._recordWrite(functionNode, target, branch);
1504
+ return;
1505
+ }
1506
+ var current = assignmentTargetBase(target);
1507
+ if (_instanceof(current, ASTNode.MacroCallSymbol) || _instanceof(current, ASTNode.MacroCallFunction)) {
1508
+ var _current_expandedSyntax;
1509
+ for(var _iterator = _create_for_of_iterator_helper_loose((_current_expandedSyntax = current.expandedSyntax) != null ? _current_expandedSyntax : []), _step; !(_step = _iterator()).done;){
1510
+ var syntax = _step.value;
1511
+ if (syntax.valueTarget === undefined) continue;
1512
+ var targetBranch = combineBranches(branch, syntax.branch);
1513
+ if (targetBranch) this._recordAssignmentTarget(functionNode, syntax.valueTarget, targetBranch);
1514
+ }
1515
+ return;
1516
+ }
1517
+ if (_instanceof(current, ASTNode.VariableIdentifier)) {
1518
+ var child = current.children[0];
1519
+ var _current_builtinSemantic;
1520
+ var name = (_current_builtinSemantic = current.builtinSemantic) != null ? _current_builtinSemantic : _instanceof(child, BaseToken) ? child.lexeme : undefined;
1521
+ if (name !== undefined) this._recordWrite(functionNode, name, branch);
1522
+ }
1523
+ };
1524
+ _proto._recordWrite = function _recordWrite(functionNode, target, branch) {
1525
+ this._branches.add(branch);
1526
+ var _this__writes_get;
1527
+ var writes = (_this__writes_get = this._writes.get(functionNode)) != null ? _this__writes_get : [];
1528
+ writes.push({
1529
+ target: target,
1530
+ branch: branch
1531
+ });
1532
+ this._writes.set(functionNode, writes);
1533
+ };
1534
+ return ShaderAnalysisInfo;
1535
+ }();
1536
+ /**
1537
+ * Visits effective source syntax while leaving unresolved macro arguments unproven.
1538
+ * @param node - Source syntax to inspect.
1539
+ * @param visit - Receives ordinary syntax and its effective branch and location.
1540
+ * @param visitMacro - Receives proven macro expansion facts at the invocation location.
1541
+ * @param incoming - Additional constraints from a containing macro expansion.
1542
+ * @param mappedLocation - Invocation location for syntax projected from a macro argument.
1543
+ * @param visitUnknown - Receives branches where macro execution effects cannot be proven.
1544
+ * @internal
1545
+ */ function walkEffectiveShaderSyntax(node, visit, visitMacro, incoming, mappedLocation, visitUnknown) {
1546
+ if (incoming === void 0) incoming = EMPTY_BRANCH;
1547
+ var pending = [
1548
+ {
1549
+ node: node,
1550
+ incoming: incoming,
1551
+ mappedLocation: mappedLocation
1552
+ }
1553
+ ];
1554
+ while(pending.length){
1555
+ var current = pending.pop();
1556
+ if ("syntax" in current) {
1557
+ var syntax = current.syntax, branch = current.branch, location = current.location;
1558
+ visitMacro(syntax, branch, location);
1559
+ if (syntax.hasUnknownEffects) visitUnknown == null ? void 0 : visitUnknown(branch);
1560
+ for(var index = syntax.arguments.length - 1; index >= 0; index--){
1561
+ pending.push({
1562
+ node: syntax.arguments[index],
1563
+ incoming: branch,
1564
+ mappedLocation: location
1565
+ });
1566
+ }
1567
+ continue;
1568
+ }
1569
+ var _$node = current.node, _$incoming = current.incoming, _$mappedLocation = current.mappedLocation;
1570
+ var branch1 = combineBranches(_$incoming, _$node._branch);
1571
+ if (!branch1 || !isBranchReachable(branch1) || _instanceof(_$node, ASTNode.MacroDefine)) continue;
1572
+ var location1 = _$mappedLocation != null ? _$mappedLocation : _$node.location;
1573
+ if (_instanceof(_$node, ASTNode.MacroCallSymbol) || _instanceof(_$node, ASTNode.MacroCallFunction)) {
1574
+ var _node_expandedSyntax, _node_expandedSyntax1;
1575
+ if (!((_node_expandedSyntax = _$node.expandedSyntax) == null ? void 0 : _node_expandedSyntax.length)) visitUnknown == null ? void 0 : visitUnknown(branch1);
1576
+ var _node_expandedSyntax_length;
1577
+ for(var index1 = ((_node_expandedSyntax_length = (_node_expandedSyntax1 = _$node.expandedSyntax) == null ? void 0 : _node_expandedSyntax1.length) != null ? _node_expandedSyntax_length : 0) - 1; index1 >= 0; index1--){
1578
+ var syntax1 = _$node.expandedSyntax[index1];
1579
+ var expandedBranch = combineBranches(branch1, syntax1.branch);
1580
+ if (expandedBranch) pending.push({
1581
+ syntax: syntax1,
1582
+ branch: expandedBranch,
1583
+ location: location1
1584
+ });
1585
+ }
1586
+ continue;
1587
+ }
1588
+ visit(_$node, branch1, location1);
1589
+ if (_instanceof(_$node, ASTNode.FunctionCallGeneric)) {
1590
+ var _node_fnSymbols;
1591
+ var identifier = _$node.children[0];
1592
+ if (!identifier.isBuiltin && !BuiltinFunction.isExist(identifier.lexeme) && !(((_node_fnSymbols = _$node.fnSymbols) == null ? void 0 : _node_fnSymbols.length) || _instanceof(_$node.fnSymbol, FnSymbol))) {
1593
+ visitUnknown == null ? void 0 : visitUnknown(branch1);
1594
+ continue;
1595
+ }
1596
+ }
1597
+ for(var index2 = _$node.children.length - 1; index2 >= 0; index2--){
1598
+ var child = _$node.children[index2];
1599
+ // Container branches describe their first token, not every following sibling statement.
1600
+ if (_instanceof(child, TreeNode)) pending.push({
1601
+ node: child,
1602
+ incoming: _$incoming,
1603
+ mappedLocation: _$mappedLocation
1604
+ });
1605
+ }
1606
+ }
1607
+ }
1608
+ function combineBranches(left, right) {
1609
+ var _loop = function() {
1610
+ var constraint = _step.value;
1611
+ if (combined.includes(constraint)) return "continue";
1612
+ if (constraint.conditionalGroup !== undefined && combined.some(function(existing) {
1613
+ return existing.conditionalGroup === constraint.conditionalGroup && existing.conditionalArm === constraint.conditionalArm;
1614
+ })) {
1615
+ return "continue";
1616
+ }
1617
+ combined.push(constraint);
1618
+ };
1619
+ if (!canBranchesOverlap(left, right)) return;
1620
+ if (!left.length) return right;
1621
+ if (!right.length) return left;
1622
+ var combined = left.slice();
1623
+ for(var _iterator = _create_for_of_iterator_helper_loose(right), _step; !(_step = _iterator()).done;)_loop();
1624
+ return combined;
1625
+ }
1626
+ function assignmentTargetBase(node) {
1627
+ var current = node;
1628
+ while(true){
1629
+ if (_instanceof(current, ASTNode.PostfixExpression) || _instanceof(current, ASTNode.VariableIdentifier) || _instanceof(current, ASTNode.ExpressionAstNode) && current.children.length === 1) {
1630
+ var child = current.children[0];
1631
+ if (_instanceof(child, TreeNode)) {
1632
+ current = child;
1633
+ continue;
1634
+ }
1635
+ } else if (_instanceof(current, ASTNode.PrimaryExpression) && current.children.length === 3) {
1636
+ var child1 = current.children[1];
1637
+ if (_instanceof(child1, TreeNode)) {
1638
+ current = child1;
1639
+ continue;
1640
+ }
1641
+ }
1642
+ return current;
1643
+ }
1644
+ }
1645
+
1646
+ /** Fragment-only derivative builtins (GLSL ES 3.00 §8.9) — illegal in the vertex stage. */ var DERIVATIVE_BUILTINS = new Set([
1647
+ "dFdx",
1648
+ "dFdy",
1649
+ "fwidth"
1650
+ ]);
1651
+ /**
1652
+ * Post-parse validation pass. Walks the already-typed AST (the parser built the symbol table and
1653
+ * inferred `.type` inline; only validation moved here) and collects diagnostics. The parsed pass
1654
+ * source is retained by the neutral IR and attached to diagnostics emitted by this pass.
1655
+ */ var ShaderValidator = /*#__PURE__*/ function() {
1656
+ function ShaderValidator(_analysis) {
1657
+ this._analysis = _analysis;
1658
+ this._typeLookup = new SymbolInfo("", ESymbolType.STRUCT);
1659
+ this._errors = [];
1660
+ this._indexedGlFragDataStarts = new Set();
1661
+ this._stageRestrictedSites = new Map();
1662
+ this._source = _analysis.ir.source;
1663
+ this._shaderData = _analysis.ir.shaderData;
1664
+ }
1665
+ var _proto = ShaderValidator.prototype;
1666
+ _proto._walk = function _walk(root, context) {
1667
+ var pending = [
1668
+ {
1669
+ node: root,
1670
+ ctx: context
1671
+ }
1672
+ ];
1673
+ while(pending.length){
1674
+ var _pending_pop = pending.pop(), node = _pending_pop.node, ctx = _pending_pop.ctx;
1675
+ if (!isBranchReachable(node._branch)) continue;
1676
+ if (_instanceof(node, ASTNode.MacroDefine)) continue;
1677
+ // A FunctionDefinition becomes the enclosing function for its subtree (GLSL has no nested
1678
+ // functions, so it always replaces rather than nests); an iteration statement (for/while/do)
1679
+ // raises the loop depth for its subtree.
1680
+ var childCtx = ctx;
1681
+ if (_instanceof(node, ASTNode.FunctionDefinition)) {
1682
+ this._checkFunctionReturn(node);
1683
+ childCtx = {
1684
+ currentFunction: node,
1685
+ loopDepth: ctx.loopDepth
1686
+ };
1687
+ } else if (_instanceof(node, ASTNode.IterationStatement)) {
1688
+ childCtx = {
1689
+ currentFunction: ctx.currentFunction,
1690
+ loopDepth: ctx.loopDepth + 1
1691
+ };
1692
+ } else if (_instanceof(node, ASTNode.JumpStatement)) {
1693
+ this._checkJump(node, ctx);
1694
+ } else if (_instanceof(node, ASTNode.FunctionCallGeneric)) {
1695
+ this._checkRecursiveCall(node, ctx);
1696
+ this._checkDerivativeCall(node);
1697
+ } else if (_instanceof(node, ASTNode.UnaryExpression)) {
1698
+ this._checkUnaryOperand(node);
1699
+ } else if (_instanceof(node, ASTNode.MultiplicativeExpression)) {
1700
+ if (!this._checkArithmeticOperation(node)) {
1701
+ this._checkConstDivideByZero(node);
1702
+ }
1703
+ } else if (_instanceof(node, ASTNode.AdditiveExpression)) {
1704
+ this._checkArithmeticOperation(node);
1705
+ } else if (_instanceof(node, ASTNode.ShiftExpression)) {
1706
+ this._checkShiftRange(node);
1707
+ this._checkIntegerBinaryOperands(node);
1708
+ } else if (_instanceof(node, ASTNode.AndExpression) || _instanceof(node, ASTNode.ExclusiveOrExpression) || _instanceof(node, ASTNode.InclusiveOrExpression)) {
1709
+ this._checkIntegerBinaryOperands(node);
1710
+ } else if (_instanceof(node, ASTNode.LogicalAndExpression) || _instanceof(node, ASTNode.LogicalXorExpression) || _instanceof(node, ASTNode.LogicalOrExpression)) {
1711
+ this._checkScalarBoolBinaryOperands(node);
1712
+ } else if (_instanceof(node, ASTNode.PostfixExpression)) {
1713
+ this._checkPostfix(node);
1714
+ } else if (_instanceof(node, ASTNode.FunctionProtoType)) {
1715
+ this._checkLocalFunctionPrototype(node, ctx);
1716
+ } else if (_instanceof(node, ASTNode.StructSpecifier)) {
1717
+ this._checkStructSpecifier(node);
1718
+ } else if (_instanceof(node, ASTNode.TypeSpecifier) && !_instanceof(node.parent, ASTNode.FunctionIdentifier)) {
1719
+ this._checkCustomTypeReference(node);
1720
+ } else if (_instanceof(node, ASTNode.SingleDeclaration) || _instanceof(node, ASTNode.VariableDeclaration)) {
1721
+ this._checkVariableDeclarator(node.declarator);
1722
+ } else if (_instanceof(node, ASTNode.InitDeclaratorList) && node.declarator) {
1723
+ this._checkVariableDeclarator(node.declarator);
1724
+ } else if (_instanceof(node, ASTNode.ArraySpecifier)) {
1725
+ this._checkArraySpecifier(node);
1726
+ }
1727
+ for(var index = node.children.length - 1; index >= 0; index--){
1728
+ var child = node.children[index];
1729
+ if (_instanceof(child, TreeNode)) pending.push({
1730
+ node: child,
1731
+ ctx: childCtx
1732
+ });
1733
+ }
1734
+ }
1735
+ };
1736
+ /**
1737
+ * `gl_FragData` is a fragment-output *array* — legal only when indexed (`gl_FragData[i] = ...`).
1738
+ * A bare reference (r-value, l-value, swizzle, function arg) is invalid GLSL. `ShaderAnalysisInfo`
1739
+ * collects every `gl_FragData` location; `_checkPostfix`
1740
+ * records the base of every `gl_FragData[i]` shape in `_indexedGlFragDataStarts`. Anything left
1741
+ * over — first occurrence only — is reported here.
1742
+ */ _proto._reportBareGlFragData = function _reportBareGlFragData() {
1743
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._analysis.glFragDataReferences), _step; !(_step = _iterator()).done;){
1744
+ var loc = _step.value;
1745
+ if (this._indexedGlFragDataStarts.has(loc.start.index)) continue;
1746
+ this._push("'gl_FragData' must be indexed — write to `gl_FragData[i]` or return an MRT struct.", loc, DiagnosticType.BareGlFragData);
1747
+ return;
1748
+ }
1749
+ };
1750
+ _proto._push = function _push(message, location, code) {
1751
+ this._errors.push(ShaderCompilerUtils.createGSError(message, GSErrorName.CompilationError, this._source, location, code));
1752
+ };
1753
+ _proto._checkCustomTypeReference = function _checkCustomTypeReference(node) {
1754
+ if (!node.isCustom) return;
1755
+ var typeName = node.children[0].children[0];
1756
+ if (!_instanceof(typeName, BaseToken)) return;
1757
+ // Later inherited overrides can remove a declaration from the final table without changing its earlier visibility.
1758
+ var structs = node.structDeclarations;
1759
+ if (!structs.length) {
1760
+ var lookup = this._typeLookup;
1761
+ lookup.set(typeName.lexeme, ESymbolType.STRUCT);
1762
+ if (this._shaderData.symbolTable.hasSymbol(lookup)) {
1763
+ this._push("Type '" + typeName.lexeme + "' is declared only after this reference or in an unavailable macro branch.", typeName.location, DiagnosticType.UseBeforeDeclaration);
1764
+ }
1765
+ return;
1766
+ }
1767
+ var coverage = getBranchCoverage(structs.map(function(struct) {
1768
+ return struct._branch;
1769
+ }), node._branch);
1770
+ if (coverage === "uncovered") {
1771
+ this._push("Type '" + typeName.lexeme + "' is unavailable under at least one macro configuration reaching this reference.", typeName.location, DiagnosticType.UseBeforeDeclaration);
1772
+ }
1773
+ };
1774
+ _proto._checkVariableDeclarator = function _checkVariableDeclarator(declarator) {
1775
+ var identifier = declarator.identifier, initializer = declarator.initializer, isConst = declarator.isConst, typeInfo = declarator.typeInfo;
1776
+ if (typeInfo.type === Keyword.VOID) {
1777
+ this._push("Illegal use of type 'void' — '" + identifier.lexeme + "' cannot be declared as void.", identifier.location, DiagnosticType.InvalidVoidVariable);
1778
+ }
1779
+ if (initializer && !typeInfo.arraySpecifier && !TypeSystem.isAssignable(typeInfo.type, initializer.type)) {
1780
+ this._push("Cannot initialize '" + identifier.lexeme + "' of type '" + TypeSystem.typeName(typeInfo.type) + "' from '" + TypeSystem.typeName(initializer.type) + "'.", initializer.location, DiagnosticType.AssignTypeMismatch);
1781
+ }
1782
+ if (initializer && isConst && !ParserUtils.isConstExpr(initializer)) {
1783
+ this._push("'" + identifier.lexeme + "': const initializer must be a constant expression.", initializer.location, DiagnosticType.NonConstInitializer);
1784
+ }
1785
+ };
1786
+ _proto._checkArraySpecifier = function _checkArraySpecifier(node) {
1787
+ if (typeof node.size !== "number" || node.size > 0) return;
1788
+ var expression = node.children[1];
1789
+ if (!_instanceof(expression, TreeNode)) return;
1790
+ this._push("Array size " + node.size + " must be greater than zero.", expression.location, DiagnosticType.InvalidArraySize);
1791
+ };
1792
+ /**
1793
+ * Unary operand-type rules: `!` needs bool, `~` needs integer, `-`/`+` need numeric. The operand
1794
+ * type is read directly (not the deduced result), so this fires for known operands and skips
1795
+ * TypeAny (continue-with-unknown); `++`/`--` reduce with a raw token child and are not handled here.
1796
+ */ _proto._checkUnaryOperand = function _checkUnaryOperand(node) {
1797
+ if (node.children.length !== 2) return;
1798
+ var firstChild = node.children[0];
1799
+ if (!_instanceof(firstChild, ASTNode.UnaryOperator)) return;
1800
+ var opToken = firstChild.children[0];
1801
+ var operand = node.children[1];
1802
+ var t = operand.type;
1803
+ if (!_instanceof(opToken, BaseToken) || t === TypeAny) return;
1804
+ var bad = false;
1805
+ switch(opToken.type){
1806
+ case ETokenType.BANG:
1807
+ bad = t !== Keyword.BOOL;
1808
+ break;
1809
+ case ETokenType.TILDE:
1810
+ bad = !TypeSystem.isIntegerType(t);
1811
+ break;
1812
+ case ETokenType.DASH:
1813
+ case ETokenType.PLUS:
1814
+ bad = TypeSystem.isBoolType(t) || TypeSystem.isSamplerType(t) || typeof t === "string";
1815
+ break;
1816
+ }
1817
+ if (bad) {
1818
+ this._push("Operator '" + opToken.lexeme + "' cannot be applied to operand of type '" + TypeSystem.typeName(t) + "'.", node.location, DiagnosticType.InvalidUnaryOperand);
1819
+ }
1820
+ };
1821
+ /** Validate and infer arithmetic from the same TypeSystem operation result used by the parser. */ _proto._checkArithmeticOperation = function _checkArithmeticOperation(node) {
1822
+ if (node.children.length !== 3) return false;
1823
+ var left = node.children[0];
1824
+ var right = node.children[2];
1825
+ var operator = node.children[1];
1826
+ if (!_instanceof(left, ASTNode.ExpressionAstNode) || !_instanceof(right, ASTNode.ExpressionAstNode)) return false;
1827
+ var operatorLexeme = _instanceof(operator, BaseToken) ? operator.lexeme : "op";
1828
+ var result = TypeSystem.arithmeticOperation(left.type, right.type, operatorLexeme);
1829
+ if (result.valid !== false) return false;
1830
+ this._push("Operator '" + operatorLexeme + "' cannot combine '" + TypeSystem.typeName(left.type) + "' and '" + TypeSystem.typeName(right.type) + "'.", node.location, DiagnosticType.InvalidBinaryOperands);
1831
+ return true;
1832
+ };
1833
+ /**
1834
+ * GLSL ES §6.1: function declarations (prototypes) may only appear at global scope. The grammar
1835
+ * accepts `int g();` inside a function body, so without this check the parser cascades into a
1836
+ * misleading `EntryNotFound`. A `FunctionProtoType` wrapped in a `FunctionDefinition` is the
1837
+ * body path — that's a legal definition, not a prototype declaration.
1838
+ */ _proto._checkLocalFunctionPrototype = function _checkLocalFunctionPrototype(node, ctx) {
1839
+ if (!ctx.currentFunction) return;
1840
+ if (_instanceof(node.parent, ASTNode.FunctionDefinition)) return;
1841
+ this._push("Function prototype '" + node.ident.lexeme + "' cannot be declared inside a function body — declare it at global scope.", node.location, DiagnosticType.LocalFunctionPrototype);
1842
+ };
1843
+ /**
1844
+ * `<<` `>>` `&` `|` `^` all take integer scalar-or-vector operands per §5.9.
1845
+ */ _proto._checkIntegerBinaryOperands = function _checkIntegerBinaryOperands(node) {
1846
+ if (node.children.length !== 3) return;
1847
+ var op = node.children[1];
1848
+ var opLexeme = _instanceof(op, BaseToken) ? op.lexeme : "op";
1849
+ var bad = this._firstNonIntegerOperand(node.children[0], node.children[2]);
1850
+ if (bad) {
1851
+ this._push("Operator '" + opLexeme + "' requires integer operands, got '" + TypeSystem.typeName(bad.type) + "'.", bad.location, DiagnosticType.InvalidBinaryOperands);
1852
+ }
1853
+ };
1854
+ /**
1855
+ * `&&` `||` `^^` — each operand must be `bool` scalar per §5.9. GLSL ES rejects `bvecN` operands
1856
+ * (desktop-GL 4.x does allow it; ES 3.00 does not).
1857
+ */ _proto._checkScalarBoolBinaryOperands = function _checkScalarBoolBinaryOperands(node) {
1858
+ if (node.children.length !== 3) return;
1859
+ var op = node.children[1];
1860
+ var opLexeme = _instanceof(op, BaseToken) ? op.lexeme : "op";
1861
+ var bad = this._firstNonScalarBoolOperand(node.children[0], node.children[2]);
1862
+ if (bad) {
1863
+ this._push("Operator '" + opLexeme + "' requires scalar bool operands, got '" + TypeSystem.typeName(bad.type) + "'.", bad.location, DiagnosticType.InvalidBinaryOperands);
1864
+ }
1865
+ };
1866
+ /** First operand whose direct type is neither integer nor `TypeAny`. */ _proto._firstNonIntegerOperand = function _firstNonIntegerOperand(a, b) {
1867
+ if (_instanceof(a, ASTNode.ExpressionAstNode) && a.type !== TypeAny && !TypeSystem.isIntegerType(a.type)) return a;
1868
+ if (_instanceof(b, ASTNode.ExpressionAstNode) && b.type !== TypeAny && !TypeSystem.isIntegerType(b.type)) return b;
1869
+ return undefined;
1870
+ };
1871
+ /** First operand whose direct type is neither `bool` nor `TypeAny`. */ _proto._firstNonScalarBoolOperand = function _firstNonScalarBoolOperand(a, b) {
1872
+ if (_instanceof(a, ASTNode.ExpressionAstNode) && a.type !== TypeAny && a.type !== Keyword.BOOL) return a;
1873
+ if (_instanceof(b, ASTNode.ExpressionAstNode) && b.type !== TypeAny && b.type !== Keyword.BOOL) return b;
1874
+ return undefined;
1875
+ };
1876
+ /**
1877
+ * Integer division/modulo by a compile-time constant zero is an error; float `1.0/0.0` yields Inf
1878
+ * (unspecified, not an error). `%` is integer-only in GLSL ES; `/` qualifies only when the result
1879
+ * type deduced to an integer (int/int) — FLOAT or TypeAny don't flag. Only reached with clean
1880
+ * operands (the arithmetic-operand check already suppressed bad ones), so it scans operands once.
1881
+ */ _proto._checkConstDivideByZero = function _checkConstDivideByZero(node) {
1882
+ if (node.children.length !== 3) return;
1883
+ var op = node.children[1];
1884
+ // Gate on the operator before touching operands: only `/` and `%` can divide by zero.
1885
+ if (!_instanceof(op, BaseToken) || op.type !== ETokenType.PERCENT && op.type !== ETokenType.SLASH) return;
1886
+ if (op.type === ETokenType.SLASH && !TypeSystem.isIntegerType(node.type)) return;
1887
+ var divisor = node.children[2];
1888
+ if (_instanceof(divisor, TreeNode) && ParserUtils.constNumericValue(divisor) === 0) {
1889
+ this._push(op.type === ETokenType.PERCENT ? "Modulo by constant zero." : "Division by constant zero.", divisor.location, DiagnosticType.ConstDivideByZero);
1890
+ }
1891
+ };
1892
+ /** A shift by a constant amount outside [0, 32) is out of range — GLSL ES int/uint are 32-bit. */ _proto._checkShiftRange = function _checkShiftRange(node) {
1893
+ if (node.children.length !== 3) return;
1894
+ var amount = node.children[2];
1895
+ if (!_instanceof(amount, TreeNode)) return;
1896
+ var n = ParserUtils.constNumericValue(amount);
1897
+ if (n !== undefined && (n < 0 || n >= 32)) {
1898
+ this._push("Shift amount " + n + " is out of range; must be in [0, 32).", amount.location, DiagnosticType.ShiftOutOfRange);
1899
+ }
1900
+ };
1901
+ /**
1902
+ * Stateless postfix checks: an invalid swizzle on a known vector (`InvalidSwizzle`), and the
1903
+ * `base[index]` family — `gl_FragData[i]` (`GlFragData`), a scalar non-array base (`NonIndexableType`),
1904
+ * a non-integer index (`NonIntegerIndex`), and a constant index past a known vector/array size
1905
+ * (`IndexOutOfBounds`). The struct-field (`else if`) path stays inline in the parser since it reads the
1906
+ * symbol table; preserve the original control flow here (early returns, gl_FragData-vs-index branching).
1907
+ */ _proto._checkPostfix = function _checkPostfix(node) {
1908
+ var children = node.children;
1909
+ if (children.length === 2) return;
1910
+ if (children.length === 3 && _instanceof(children[2], BaseToken)) {
1911
+ var base = children[0];
1912
+ var field = children[2];
1913
+ // GLSL ES §5.5: `.field` on a receiver that is not a struct, scalar, or vector is invalid.
1914
+ // The driver rejects `s.rr` (sampler) or `f().xx` (void return) with "field selection requires
1915
+ // structure, vector, or interface block on left hand side". Skip TypeAny — unknown types keep
1916
+ // the wiggle room. Struct types are strings; `ParserUtils.swizzleError` already returns null
1917
+ // for them and the parser's inline UndeclaredStructMember path takes over.
1918
+ var baseType = base.type;
1919
+ if (baseType !== undefined && baseType !== TypeAny && typeof baseType !== "string" && TypeSystem.vectorComponentCount(baseType) === 0 && !TypeSystem.isScalarType(baseType)) {
1920
+ this._push("Field selection '." + field.lexeme + "' requires a structure, vector, or scalar receiver — got '" + TypeSystem.typeName(baseType) + "'.", field.location, DiagnosticType.InvalidSwizzle);
1921
+ return;
1922
+ }
1923
+ var swizzleError = ParserUtils.swizzleError(base.type, field.lexeme);
1924
+ if (swizzleError) {
1925
+ this._push(swizzleError, field.location, DiagnosticType.InvalidSwizzle);
1926
+ }
1927
+ } else if (children.length === 4) {
1928
+ // `base [ index ]`.
1929
+ var base1 = children[0];
1930
+ var index = children[2];
1931
+ // `gl_FragData[i]` — record the base's location so `_reportBareGlFragData` treats this
1932
+ // occurrence as legal rather than reporting it as a bare use.
1933
+ var baseIdentifier = ParserUtils.unwrapBareIdentifier(base1, {
1934
+ allowParens: true
1935
+ });
1936
+ var isFragmentOutputArray = (baseIdentifier == null ? void 0 : baseIdentifier.builtinSemantic) === ShaderBuiltinSemantic.FragmentOutputArray;
1937
+ if (isFragmentOutputArray) {
1938
+ this._indexedGlFragDataStarts.add(baseIdentifier.location.start.index);
1939
+ }
1940
+ // A scalar (non-array) base can't be indexed at all. Resolve the base to a bare variable so an
1941
+ // array (`a[3]`) or a vector (`v[0]`) is excluded; non-variable/compound bases stay unknown.
1942
+ if (TypeSystem.isScalarType(base1.type)) {
1943
+ var baseIdent = ParserUtils.unwrapBareIdentifier(base1, {
1944
+ allowParens: true
1945
+ });
1946
+ if (baseIdent && !baseIdent.isArray) {
1947
+ var m = "Type '" + TypeSystem.typeName(base1.type) + "' is not indexable.";
1948
+ this._push(m, base1.location, DiagnosticType.NonIndexableType);
1949
+ }
1950
+ }
1951
+ if (!_instanceof(index, ASTNode.ExpressionAstNode)) return;
1952
+ // The index must be an integer; a constant integer index past a known vector's size is out of bounds.
1953
+ var indexType = index.type;
1954
+ if (indexType !== TypeAny && indexType !== Keyword.INT && indexType !== Keyword.UINT) {
1955
+ var m1 = "Index must be an integer, got '" + TypeSystem.typeName(indexType) + "'.";
1956
+ this._push(m1, index.location, DiagnosticType.NonIntegerIndex);
1957
+ return;
1958
+ }
1959
+ if (isFragmentOutputArray && !ParserUtils.isConstExpr(index)) {
1960
+ this._push("Fragment output array index must be a constant integral expression.", index.location, DiagnosticType.NonConstFragmentOutputIndex);
1961
+ }
1962
+ if (isFragmentOutputArray) {
1963
+ var outputIndex = ParserUtils.constIntegerValue(index);
1964
+ if (outputIndex !== undefined && outputIndex < 0) {
1965
+ this._push("Fragment output index " + outputIndex + " is out of bounds.", index.location, DiagnosticType.IndexOutOfBounds);
1966
+ }
1967
+ }
1968
+ // Array-of-vector base like `ivec2 arr[N]` — a[i] indexes the outer array, not the inner
1969
+ // vec2. Skip the vector-bounds check when the base is an array; the array-size check
1970
+ // still runs below when the array size is known at compile time.
1971
+ var baseArrayIdent = ParserUtils.unwrapBareIdentifier(base1, {
1972
+ allowParens: true
1973
+ });
1974
+ var baseIsArray = !!(baseArrayIdent == null ? void 0 : baseArrayIdent.isArray);
1975
+ var size = baseIsArray ? 0 : TypeSystem.vectorComponentCount(base1.type);
1976
+ if (size > 0) {
1977
+ var n = ParserUtils.constNumericValue(index);
1978
+ if (n !== undefined && (n < 0 || n >= size)) {
1979
+ var m2 = "Index " + n + " is out of bounds for a " + size + "-component vector.";
1980
+ this._push(m2, index.location, DiagnosticType.IndexOutOfBounds);
1981
+ }
1982
+ } else {
1983
+ // A constant index past a fixed-size array's bounds is out of bounds — the spec
1984
+ // requires bounds-checking fixed-size arrays as well as vectors. Unsized / non-array
1985
+ // bases keep arraySize undefined.
1986
+ var baseIdent1 = ParserUtils.unwrapBareIdentifier(base1, {
1987
+ allowParens: true
1988
+ });
1989
+ var arraySize = baseIdent1 == null ? void 0 : baseIdent1.arraySize;
1990
+ if (arraySize !== undefined) {
1991
+ var n1 = ParserUtils.constNumericValue(index);
1992
+ if (n1 !== undefined && (n1 < 0 || n1 >= arraySize)) {
1993
+ var m3 = "Index " + n1 + " is out of bounds for an array of size " + arraySize + ".";
1994
+ this._push(m3, index.location, DiagnosticType.IndexOutOfBounds);
1995
+ }
1996
+ }
1997
+ }
1998
+ }
1999
+ };
2000
+ /** Diagnose only a proven fallthrough; unresolved macro conditions remain inconclusive. */ _proto._checkFunctionReturn = function _checkFunctionReturn(node) {
2001
+ var returnType = node.protoType.returnType;
2002
+ if (returnType.type === Keyword.VOID) return;
2003
+ if (this._analysis.getReturnCoverage(node) === "uncovered") {
2004
+ this._push("No return statement found.", returnType.location, DiagnosticType.MissingReturn);
2005
+ }
2006
+ };
2007
+ /**
2008
+ * Jump-statement checks needing walk-local context: `InvalidReturnType` fires per-jump — a value
2009
+ * return in a `void` function, or a `return value;` whose value isn't assignable to the declared
2010
+ * non-void return type. A `break`/`continue` at loop depth 0 (outside any loop) is
2011
+ * `MisplacedControlFlow`. A discard site is checked against stage reachability after the walk.
2012
+ */ _proto._checkJump = function _checkJump(node, ctx) {
2013
+ var children = node.children;
2014
+ var keyword = ASTNode._unwrapToken(children[0]).type;
2015
+ if (keyword === Keyword.RETURN) {
2016
+ if (!ctx.currentFunction) return;
2017
+ var declared = ctx.currentFunction.protoType.returnType.type;
2018
+ if (declared === Keyword.VOID) {
2019
+ // `void f() { return value; }` — the value at children[1] is illegal.
2020
+ if (children.length === 3) {
2021
+ this._push("Return in void function.", children[1].location, DiagnosticType.InvalidReturnType);
2022
+ }
2023
+ } else if (children.length !== 3) {
2024
+ this._push("Return in a non-void function must provide a value.", node.location, DiagnosticType.InvalidReturnType);
2025
+ } else {
2026
+ var returned = children[1].type;
2027
+ if (declared != undefined && !TypeSystem.isAssignable(declared, returned)) {
2028
+ this._push("Cannot return a value of type '" + TypeSystem.typeName(returned) + "' from a function returning '" + TypeSystem.typeName(declared) + "'.", children[1].location, DiagnosticType.InvalidReturnType);
2029
+ }
2030
+ }
2031
+ } else if ((keyword === Keyword.BREAK || keyword === Keyword.CONTINUE) && ctx.loopDepth === 0) {
2032
+ this._push("'" + (keyword === Keyword.BREAK ? "break" : "continue") + "' is only allowed inside a loop.", node.location, DiagnosticType.MisplacedControlFlow);
2033
+ }
2034
+ };
2035
+ /**
2036
+ * GLSL forbids recursion: a call whose callee name AND parameter signature match the enclosing
2037
+ * function (the same overload) is `RecursiveFunction`. The parser short-circuits this same case
2038
+ * during overload resolution (so it isn't mis-reported as Undefined/NoMatchingOverload); the
2039
+ * exact-signature match avoids flagging a call to a different overload of the same name.
2040
+ */ _proto._checkRecursiveCall = function _checkRecursiveCall(node, ctx) {
2041
+ var currentFunction = ctx.currentFunction;
2042
+ if (!currentFunction) return;
2043
+ var functionIdentifier = node.children[0];
2044
+ if (functionIdentifier.isBuiltin) return;
2045
+ var fnIdent = functionIdentifier.ident;
2046
+ var proto = currentFunction.protoType;
2047
+ var _node_fnSymbols;
2048
+ var callees = (_node_fnSymbols = node.fnSymbols) != null ? _node_fnSymbols : _instanceof(node.fnSymbol, FnSymbol) ? [
2049
+ node.fnSymbol
2050
+ ] : [];
2051
+ if (callees.length) {
2052
+ if (!callees.some(function(callee) {
2053
+ return callee.astNode === currentFunction;
2054
+ })) return;
2055
+ this._push("Recursive call to '" + fnIdent + "' is not allowed (GLSL forbids recursion).", functionIdentifier.location, DiagnosticType.RecursiveFunction);
2056
+ return;
2057
+ }
2058
+ if (proto.ident.lexeme !== fnIdent) return;
2059
+ var callSig;
2060
+ if (node.children.length === 4 && _instanceof(node.children[2], ASTNode.FunctionCallParameterList)) {
2061
+ callSig = node.children[2].paramSig;
2062
+ }
2063
+ var _proto_paramSig;
2064
+ var headerSig = (_proto_paramSig = proto.paramSig) != null ? _proto_paramSig : [];
2065
+ var cSig = callSig != null ? callSig : [];
2066
+ if (headerSig.length === cSig.length && headerSig.every(function(t, i) {
2067
+ return t === cSig[i];
2068
+ })) {
2069
+ this._push("Recursive call to '" + fnIdent + "' is not allowed (GLSL forbids recursion).", node.location, DiagnosticType.RecursiveFunction);
2070
+ }
2071
+ };
2072
+ /**
2073
+ * Reports one mutual-recursion witness per canonical participant. Direct self-recursion is
2074
+ * already reported at the call site by `_checkRecursiveCall`.
2075
+ */ _proto._reportMutualRecursion = function _reportMutualRecursion() {
2076
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._analysis.mutualRecursionWitnesses()), _step; !(_step = _iterator()).done;){
2077
+ var _step_value = _step.value, marker = _step_value.marker, cycle = _step_value.cycle;
2078
+ this._push(cycle ? "Mutual recursion detected in call chain: " + cycle.map(function(fn) {
2079
+ return fn.protoType.ident.lexeme;
2080
+ }).join(" → ") + " → " + cycle[0].protoType.ident.lexeme + " (GLSL forbids recursion)." : "Mutual recursion detected involving function '" + marker.protoType.ident.lexeme + "' (GLSL forbids recursion).", marker.protoType.ident.location, DiagnosticType.RecursiveFunction);
2081
+ }
2082
+ };
2083
+ /**
2084
+ * Resolves stage restrictions through the shared branch-aware call graph, including entry bodies.
2085
+ * Uncalled helpers and incompatible macro paths do not establish a stage violation.
2086
+ */ _proto._reportStageRestrictions = function _reportStageRestrictions() {
2087
+ if (!this._stageRestrictedSites.size) return;
2088
+ var _this__analysis_coreInfo = this._analysis.coreInfo, vertexEntry = _this__analysis_coreInfo.vertexEntry, fragmentEntry = _this__analysis_coreInfo.fragmentEntry;
2089
+ for(var _i = 0, _iter = [
2090
+ vertexEntry,
2091
+ fragmentEntry
2092
+ ]; _i < _iter.length; _i++){
2093
+ var entry = _iter[_i];
2094
+ var reported = new Set();
2095
+ var stage = entry.stage === EShaderStage.VERTEX ? "vertex" : "fragment";
2096
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._analysis.reachableFunctions(entry)), _step; !(_step = _iterator()).done;){
2097
+ var fn = _step.value;
2098
+ var _this__stageRestrictedSites_get;
2099
+ for(var _iterator1 = _create_for_of_iterator_helper_loose((_this__stageRestrictedSites_get = this._stageRestrictedSites.get(fn)) != null ? _this__stageRestrictedSites_get : []), _step1; !(_step1 = _iterator1()).done;){
2100
+ var site = _step1.value;
2101
+ if (site.scope === entry.stage || !this._analysis.isFunctionBranchReachable(entry, fn, site.branch)) continue;
2102
+ var key = site.type + ":" + site.location.start.index + ":" + site.location.end.index + ":" + site.description;
2103
+ if (reported.has(key)) continue;
2104
+ reported.add(key);
2105
+ var allowed = site.scope === EShaderStage.VERTEX ? "vertex" : "fragment";
2106
+ this._push(site.description + " is only allowed in the " + allowed + " shader, but is reachable from the " + stage + " entry via '" + fn.protoType.ident.lexeme + "'.", site.location, site.type);
2107
+ }
2108
+ }
2109
+ }
2110
+ };
2111
+ _proto._recordStageRestriction = function _recordStageRestriction(ctx, site) {
2112
+ if (!ctx.currentFunction) return;
2113
+ var sites = this._stageRestrictedSites.get(ctx.currentFunction);
2114
+ if (!sites) this._stageRestrictedSites.set(ctx.currentFunction, sites = []);
2115
+ sites.push(site);
2116
+ };
2117
+ _proto._collectStageRestrictions = function _collectStageRestrictions() {
2118
+ var _loop = function() {
2119
+ var fn = _step.value;
2120
+ var ctx = {
2121
+ currentFunction: fn,
2122
+ loopDepth: 0
2123
+ };
2124
+ var record = function(name, call, branch, location) {
2125
+ if (call) {
2126
+ if (DERIVATIVE_BUILTINS.has(name)) _this._recordStageRestriction(ctx, {
2127
+ description: "Derivative function '" + name + "'",
2128
+ scope: EShaderStage.FRAGMENT,
2129
+ type: DiagnosticType.DerivativeInVertexShader,
2130
+ location: location,
2131
+ branch: branch
2132
+ });
2133
+ return;
2134
+ }
2135
+ var builtin = BuiltinVariable.getVar(name);
2136
+ if (!builtin || builtin.scope === EShaderStage.ALL) return;
2137
+ _this._recordStageRestriction(ctx, {
2138
+ description: "Builtin variable '" + name + "'",
2139
+ scope: builtin.scope,
2140
+ type: DiagnosticType.InvalidBuiltinStage,
2141
+ location: location,
2142
+ branch: branch
2143
+ });
2144
+ };
2145
+ var discard = function(branch, location) {
2146
+ return _this._recordStageRestriction(ctx, {
2147
+ description: "'discard'",
2148
+ scope: EShaderStage.FRAGMENT,
2149
+ type: DiagnosticType.MisplacedControlFlow,
2150
+ location: location,
2151
+ branch: branch
2152
+ });
2153
+ };
2154
+ walkEffectiveShaderSyntax(fn.statements, function(node, branch, location) {
2155
+ if (_instanceof(node, ASTNode.JumpStatement) && ASTNode._unwrapToken(node.children[0]).type === Keyword.DISCARD) {
2156
+ discard(branch, location);
2157
+ } else if (_instanceof(node, ASTNode.FunctionCallGeneric)) {
2158
+ var identifier = node.children[0];
2159
+ if (!identifier.isBuiltin) record(identifier.lexeme, true, branch, location);
2160
+ } else if (_instanceof(node, ASTNode.VariableIdentifier)) {
2161
+ var _BuiltinVariable_getVar;
2162
+ var child = node.children[0];
2163
+ if (_instanceof(child, BaseToken) && !node.resolvedSymbols().length && node.typeInfo === ((_BuiltinVariable_getVar = BuiltinVariable.getVar(child.lexeme)) == null ? void 0 : _BuiltinVariable_getVar.type)) {
2164
+ record(child.lexeme, false, branch, location);
2165
+ }
2166
+ }
2167
+ }, function(syntax, branch, location) {
2168
+ if (syntax.keywords.includes(Keyword.DISCARD)) discard(branch, location);
2169
+ for(var _iterator = _create_for_of_iterator_helper_loose(syntax.references), _step; !(_step = _iterator()).done;){
2170
+ var reference = _step.value;
2171
+ record(reference.name, reference.call, branch, location);
2172
+ }
2173
+ });
2174
+ };
2175
+ var _this = this;
2176
+ for(var _iterator = _create_for_of_iterator_helper_loose(this._analysis.functions()), _step; !(_step = _iterator()).done;)_loop();
2177
+ };
2178
+ /**
2179
+ * Fragment-only derivative builtins (`dFdx`/`dFdy`/`fwidth`) — illegal in the vertex shader
2180
+ * (`DerivativeInVertexShader`) and require a float/floatN argument (`NonFloatDerivativeArg`).
2181
+ * Only user-callable functions reach here (isBuiltin=false, since the identifier is a string name,
2182
+ * not a type keyword); constructors like `vec3(...)` never match a derivative name.
2183
+ */ _proto._checkDerivativeCall = function _checkDerivativeCall(node) {
2184
+ var functionIdentifier = node.children[0];
2185
+ if (functionIdentifier.isBuiltin) return;
2186
+ var name = functionIdentifier.lexeme;
2187
+ if (!DERIVATIVE_BUILTINS.has(name)) return;
2188
+ // Spec: derivative builtins take `genType` (float/vec2/vec3/vec4); anything else is a type error.
2189
+ if (node.children.length === 4 && _instanceof(node.children[2], ASTNode.FunctionCallParameterList)) {
2190
+ var list = node.children[2];
2191
+ var paramSig = list.paramSig;
2192
+ if (paramSig.length === 1) {
2193
+ var t = paramSig[0];
2194
+ if (t !== TypeAny && !ShaderValidator._isFloatOrFloatVector(t)) {
2195
+ var argNode = list.paramNodes[0];
2196
+ var _argNode_location;
2197
+ this._push("'" + name + "' expects a float or floatN argument, got '" + TypeSystem.typeName(t) + "'.", (_argNode_location = argNode == null ? void 0 : argNode.location) != null ? _argNode_location : list.location, DiagnosticType.NonFloatDerivativeArg);
2198
+ }
2199
+ }
2200
+ }
2201
+ };
2202
+ /**
2203
+ * `struct Foo { ... }` — flags an empty body (`EmptyStruct`). An empty body is unreachable via
2204
+ * the plain grammar (`struct_declaration_list` requires ≥1 declaration → SyntaxError first), but a
2205
+ * fully-macro-guarded body can reduce to zero collected props; the check catches that shape rather
2206
+ * than the surface form.
2207
+ */ _proto._checkStructSpecifier = function _checkStructSpecifier(node) {
2208
+ var propList = node.propList;
2209
+ if (!propList || propList.length === 0) {
2210
+ var _node_ident;
2211
+ var _node_ident_location;
2212
+ var location = (_node_ident_location = (_node_ident = node.ident) == null ? void 0 : _node_ident.location) != null ? _node_ident_location : node.location;
2213
+ this._push("Struct declaration must contain at least one member.", location, DiagnosticType.EmptyStruct);
2214
+ }
2215
+ };
2216
+ /**
2217
+ * Validate an already-parsed program and return collected diagnostics.
2218
+ * @param analysis neutral IR plus analyzer-only graph information
2219
+ * @returns diagnostics as `GSError[]`
2220
+ */ ShaderValidator.validate = function validate(analysis) {
2221
+ var v = new ShaderValidator(analysis);
2222
+ v._walk(analysis.ir.program, {
2223
+ currentFunction: null,
2224
+ loopDepth: 0
2225
+ });
2226
+ v._collectStageRestrictions();
2227
+ v._reportMutualRecursion();
2228
+ v._reportStageRestrictions();
2229
+ v._reportBareGlFragData();
2230
+ return v._errors;
2231
+ };
2232
+ /** float / vec2 / vec3 / vec4 — the `genType` family derivative builtins accept. */ ShaderValidator._isFloatOrFloatVector = function _isFloatOrFloatVector(t) {
2233
+ return t === Keyword.FLOAT || t === Keyword.VEC2 || t === Keyword.VEC3 || t === Keyword.VEC4;
2234
+ };
2235
+ return ShaderValidator;
2236
+ }();
2237
+
2238
+ var zeroPosition = new ShaderPosition();
2239
+ zeroPosition.set(0, 0, 0);
2240
+ Object.freeze(zeroPosition);
2241
+ /**
2242
+ * Validates pipeline IO facts produced by `ShaderCoreInfo`.
2243
+ * @internal
2244
+ */ var ShaderIOValidator = /*#__PURE__*/ function() {
2245
+ function ShaderIOValidator() {}
2246
+ /**
2247
+ * Validates stage entries and IO without participating in backend generation.
2248
+ * @param analysis - Analyzer-only facts and their neutral/core backing data.
2249
+ * @param vertexEntryLocation - ShaderLab source range of the vertex entry binding.
2250
+ * @param fragmentEntryLocation - ShaderLab source range of the fragment entry binding.
2251
+ * @param entrySource - Complete ShaderLab source containing the entry bindings.
2252
+ * @returns Analyzer errors for invalid pipeline IO.
2253
+ */ ShaderIOValidator.validate = function validate(analysis, vertexEntryLocation, fragmentEntryLocation, entrySource) {
2254
+ var ir = analysis.ir, coreInfo = analysis.coreInfo;
2255
+ var source = ir.source;
2256
+ var glesInfo = new GLESShaderInfo(ir, coreInfo);
2257
+ var errors = [];
2258
+ if (coreInfo.vertexEntry.name && !coreInfo.vertexEntry.functions.length) {
2259
+ this._entryNotFound(errors, coreInfo.vertexEntry.name, vertexEntryLocation, entrySource != null ? entrySource : source);
2260
+ }
2261
+ if (coreInfo.fragmentEntry.name && !coreInfo.fragmentEntry.functions.length) {
2262
+ this._entryNotFound(errors, coreInfo.fragmentEntry.name, fragmentEntryLocation, entrySource != null ? entrySource : source);
2263
+ }
2264
+ if (coreInfo.vertexEntry.hasDefiniteAmbiguity) {
2265
+ this._ambiguousEntry(errors, coreInfo.vertexEntry.name, vertexEntryLocation, entrySource, coreInfo.vertexEntry.functions[1].astNode.protoType.ident.location, source);
2266
+ }
2267
+ if (coreInfo.fragmentEntry.hasDefiniteAmbiguity) {
2268
+ this._ambiguousEntry(errors, coreInfo.fragmentEntry.name, fragmentEntryLocation, entrySource, coreInfo.fragmentEntry.functions[1].astNode.protoType.ident.location, source);
2269
+ }
2270
+ this._validateVertex(analysis, errors);
2271
+ this._validateFragment(analysis, errors);
2272
+ this._validateRoleConflicts(analysis, errors);
2273
+ this._validateStructMembers(analysis, errors);
2274
+ this._validateMrtOutputs(analysis, glesInfo, errors);
2275
+ for(var _iterator = _create_for_of_iterator_helper_loose(glesInfo.invalidMrtReturnLocations), _step; !(_step = _iterator()).done;){
2276
+ var location = _step.value;
2277
+ this._error(errors, DiagnosticType.InvalidMrtOutput, "MRT fragment entries must return a struct variable after assigning its members.", location, source);
2278
+ }
2279
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(glesInfo.invalidVaryingReturnLocations), _step1; !(_step1 = _iterator1()).done;){
2280
+ var location1 = _step1.value;
2281
+ this._error(errors, DiagnosticType.InvalidEntryReturnType, "Vertex entries returning varyings must return a struct variable or a function result of the same type.", location1, source);
2282
+ }
2283
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(glesInfo.structMemberOwnerIssues), _step2; !(_step2 = _iterator2()).done;){
2284
+ var issue = _step2.value;
2285
+ if (issue.certainty !== "definite") continue;
2286
+ this._error(errors, DiagnosticType.AmbiguousMacroBranchResolution, issue.kind === "runtime-expanded-io-owner" ? "This macro member owner resolves to stage IO only after runtime substitution and cannot be lowered safely." : issue.kind === "incompatible-io-member" ? "This member is not available on every stage IO owner selected by the macro configuration." : "This member reference may resolve to stage IO or an ordinary variable across runtime macro configurations.", issue.location, source);
2287
+ }
2288
+ for(var _iterator3 = _create_for_of_iterator_helper_loose(coreInfo.fragmentEntry.functions), _step3; !(_step3 = _iterator3()).done;){
2289
+ var fragmentFunction = _step3.value;
2290
+ var returnStructs = fragmentFunction.astNode.protoType.returnType.typeSpecifier.structDeclarations;
2291
+ var returnsMrt = returnStructs.some(function(struct) {
2292
+ return coreInfo.io.mrtStructs.includes(struct);
2293
+ });
2294
+ if (!returnsMrt) continue;
2295
+ var reachableFragmentOutputs = analysis.reachableFragmentOutput0ReferencesFrom(fragmentFunction);
2296
+ if (reachableFragmentOutputs.length) {
2297
+ this._error(errors, DiagnosticType.GlFragColorWithMrt, "gl_FragColor cannot be used with MRT (Multiple Render Targets).", reachableFragmentOutputs[0], source);
2298
+ break;
2299
+ }
2300
+ }
2301
+ for(var _iterator4 = _create_for_of_iterator_helper_loose(coreInfo.fragmentEntry.functions), _step4; !(_step4 = _iterator4()).done;){
2302
+ var fragmentFunction1 = _step4.value;
2303
+ var conflict = analysis.coexistingLegacyFragmentOutputsFrom(fragmentFunction1);
2304
+ if (!conflict) continue;
2305
+ this._error(errors, DiagnosticType.LegacyFragmentOutputConflict, "gl_FragColor and gl_FragData cannot be used in the same fragment shader configuration.", conflict.outputArray, source);
2306
+ break;
2307
+ }
2308
+ if (coreInfo.vertexEntry.functions.length && analysis.getReachableWriteCoverage(coreInfo.vertexEntry, ShaderBuiltinSemantic.VertexPosition) === "uncovered") {
2309
+ this._error(errors, DiagnosticType.MissingVertexPosition, "Vertex shader must write gl_Position.", coreInfo.vertexEntry.functions[0].astNode.protoType.returnType.location, source);
2310
+ }
2311
+ return errors;
2312
+ };
2313
+ ShaderIOValidator._validateVertex = function _validateVertex(analysis, errors) {
2314
+ var coreInfo = analysis.coreInfo, ir = analysis.ir;
2315
+ for(var _iterator = _create_for_of_iterator_helper_loose(coreInfo.vertexEntry.functions), _step; !(_step = _iterator()).done;){
2316
+ var functionSymbol = _step.value;
2317
+ var _proto_parameterList;
2318
+ var proto = functionSymbol.astNode.protoType;
2319
+ var returnType = proto.returnType;
2320
+ if (typeof returnType.type === "string") {
2321
+ if (!returnType.typeSpecifier.structDeclarations.length) {
2322
+ this._error(errors, DiagnosticType.InvalidIOStruct, 'Invalid varying struct: "' + returnType.type + '".', returnType.location, ir.source);
2323
+ }
2324
+ } else if (returnType.type !== Keyword.VOID) {
2325
+ this._error(errors, DiagnosticType.InvalidEntryReturnType, "vertex main entry can only return struct or void.", returnType.location, ir.source);
2326
+ }
2327
+ var attribute = (_proto_parameterList = proto.parameterList) == null ? void 0 : _proto_parameterList[0];
2328
+ if (attribute && typeof attribute.typeInfo.type === "string") {
2329
+ if (!attribute.typeInfo.structDeclarations.length) {
2330
+ this._error(errors, DiagnosticType.InvalidIOStruct, 'Invalid attribute struct: "' + attribute.typeInfo.type + '".', attribute.astNode.location, ir.source);
2331
+ }
2332
+ }
2333
+ }
2334
+ };
2335
+ ShaderIOValidator._validateFragment = function _validateFragment(analysis, errors) {
2336
+ var coreInfo = analysis.coreInfo, ir = analysis.ir;
2337
+ for(var _iterator = _create_for_of_iterator_helper_loose(coreInfo.fragmentEntry.functions), _step; !(_step = _iterator()).done;){
2338
+ var functionSymbol = _step.value;
2339
+ var returnType = functionSymbol.astNode.protoType.returnType;
2340
+ if (typeof returnType.type === "string") {
2341
+ if (!returnType.typeSpecifier.structDeclarations.length) {
2342
+ this._error(errors, DiagnosticType.InvalidIOStruct, "Invalid MRT struct: " + returnType.type, returnType.location, ir.source);
2343
+ }
2344
+ } else if (returnType.type !== Keyword.VOID && returnType.type !== Keyword.VEC4) {
2345
+ this._error(errors, DiagnosticType.InvalidEntryReturnType, "fragment main entry can only return struct, vec4, or void.", returnType.location, ir.source);
2346
+ }
2347
+ }
2348
+ };
2349
+ ShaderIOValidator._validateRoleConflicts = function _validateRoleConflicts(analysis, errors) {
2350
+ for(var _iterator = _create_for_of_iterator_helper_loose(analysis.coreInfo.roleConflicts), _step; !(_step = _iterator()).done;){
2351
+ var conflict = _step.value;
2352
+ this._error(errors, DiagnosticType.StructRoleConflict, "Cannot use the same struct as " + conflict.roles.join(" and ") + ".", conflict.struct.location, analysis.ir.source);
2353
+ }
2354
+ };
2355
+ ShaderIOValidator._validateStructMembers = function _validateStructMembers(analysis, errors) {
2356
+ var _this = this;
2357
+ var io = analysis.coreInfo.io;
2358
+ var inspect = function(structs, role) {
2359
+ for(var _iterator = _create_for_of_iterator_helper_loose(structs), _step; !(_step = _iterator()).done;){
2360
+ var struct = _step.value;
2361
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(struct.propList), _step1; !(_step1 = _iterator1()).done;){
2362
+ var prop = _step1.value;
2363
+ if (typeof prop.typeInfo.type === "string") {
2364
+ _this._error(errors, DiagnosticType.NestedIOStruct, "IO struct member '" + prop.ident.lexeme + "' cannot be a struct ('" + prop.typeInfo.type + "'); nested IO structs are not allowed.", prop.ident.location, analysis.ir.source);
2365
+ } else if (role === ShaderStructRole.Varying && !prop.isFlat && TypeSystem.isIntegerType(prop.typeInfo.type)) {
2366
+ _this._error(errors, DiagnosticType.NonFlatIntegerVarying, "Integer varying '" + prop.ident.lexeme + "' must be declared 'flat'.", prop.ident.location, analysis.ir.source);
2367
+ }
2368
+ }
2369
+ }
2370
+ };
2371
+ inspect(io.attributeStructs, ShaderStructRole.Attribute);
2372
+ inspect(io.varyingStructs, ShaderStructRole.Varying);
2373
+ inspect(io.mrtStructs, ShaderStructRole.Mrt);
2374
+ };
2375
+ ShaderIOValidator._validateMrtOutputs = function _validateMrtOutputs(analysis, glesInfo, errors) {
2376
+ for(var _iterator = _create_for_of_iterator_helper_loose(glesInfo.mrtOutputIssues), _step; !(_step = _iterator()).done;){
2377
+ var issue = _step.value;
2378
+ var prop = issue.prop;
2379
+ var message = void 0;
2380
+ switch(issue.kind){
2381
+ case "missing-location":
2382
+ message = "MRT output '" + prop.ident.lexeme + "' requires layout(location = N).";
2383
+ break;
2384
+ case "invalid-location":
2385
+ message = "MRT output '" + prop.ident.lexeme + "' requires a non-negative integer location.";
2386
+ break;
2387
+ case "duplicate-location":
2388
+ message = "MRT output location " + prop.mrtIndex + " is already used by another member.";
2389
+ break;
2390
+ default:
2391
+ message = "MRT output '" + prop.ident.lexeme + "' must have type vec4 for GLES portability.";
2392
+ break;
2393
+ }
2394
+ this._error(errors, DiagnosticType.InvalidMrtOutput, message, prop.ident.location, analysis.ir.source);
2395
+ }
2396
+ };
2397
+ ShaderIOValidator._entryNotFound = function _entryNotFound(errors, entry, location, source) {
2398
+ this._error(errors, DiagnosticType.EntryNotFound, "Entry function '" + entry + "' not found.", location != null ? location : zeroPosition, source);
2399
+ };
2400
+ ShaderIOValidator._ambiguousEntry = function _ambiguousEntry(errors, entry, bindingLocation, entrySource, declarationLocation, passSource) {
2401
+ this._error(errors, DiagnosticType.AmbiguousEntryPoint, "Entry function '" + entry + "' resolves to multiple declarations in the same macro configuration.", bindingLocation != null ? bindingLocation : declarationLocation, bindingLocation && entrySource ? entrySource : passSource);
2402
+ };
2403
+ ShaderIOValidator._error = function _error(errors, code, message, location, source) {
2404
+ errors.push(ShaderCompilerUtils.createGSError(message, GSErrorName.CompilationError, source, location, code));
2405
+ };
2406
+ return ShaderIOValidator;
2407
+ }();
2408
+
2409
+ /**
2410
+ * Converts a source offset to the analyzer's one-based diagnostic position.
2411
+ * @param source - Source text containing the offset.
2412
+ * @param offset - Zero-based UTF-16 offset into the source.
2413
+ * @returns One-based line and column plus the original offset.
2414
+ * @internal
2415
+ */ function positionAt(source, offset) {
2416
+ var line = 1;
2417
+ var column = 1;
2418
+ for(var index = 0; index < offset; index++){
2419
+ if (source.charCodeAt(index) === 10) {
2420
+ line++;
2421
+ column = 1;
2422
+ } else {
2423
+ column++;
2424
+ }
2425
+ }
2426
+ return {
2427
+ line: line,
2428
+ column: column,
2429
+ offset: offset
2430
+ };
2431
+ }
2432
+
2433
+ /**
2434
+ * Analyzes ShaderLab source and GLSL semantics without generating backend source.
2435
+ *
2436
+ * Parser-owned definite failures remain attached to reusable pass handles so backend admission reaches the same
2437
+ * conclusion. Analyzer-only validation stays independent from GLES code generation.
2438
+ */ var ShaderAnalyzer = /*#__PURE__*/ function() {
2439
+ function ShaderAnalyzer() {}
2440
+ /**
2441
+ * Analyzes shader source.
2442
+ * @param source - ShaderLab source to analyze.
2443
+ * @param options - Analysis options.
2444
+ * @returns Structured diagnostics and reusable parsed-pass handles.
2445
+ * @throws Error when include keys collide after normalization or `sourceFile` is not a valid absolute URL.
2446
+ */ ShaderAnalyzer.analyze = function analyze(source, options) {
2447
+ var passes = [];
2448
+ var diagnostics = ShaderAnalyzer._analyzeSource(source, passes, options);
2449
+ return Object.freeze({
2450
+ diagnostics: diagnostics,
2451
+ passes: Object.freeze(passes)
2452
+ });
2453
+ };
2454
+ ShaderAnalyzer._analyzeSource = function _analyzeSource(source, parsedPasses, options) {
2455
+ var _diagnostics;
2456
+ var includeMap = normalizeShaderIncludeMap(options == null ? void 0 : options.includeMap);
2457
+ var sourceFile = normalizeShaderSourceFile(options == null ? void 0 : options.sourceFile);
2458
+ var chunkOutputCache = new Map();
2459
+ var diagnostics = [];
2460
+ var sourceResult = ShaderSourceParser.parseWithErrors(source);
2461
+ var shaderSource = sourceResult.shaderSource;
2462
+ var retainParsedPasses = sourceResult.errors.length === 0;
2463
+ (_diagnostics = diagnostics).push.apply(_diagnostics, [].concat(sourceResult.errors.map(function(error) {
2464
+ return gseErrorToDiagnostic(error);
2465
+ })));
2466
+ for(var _iterator = _create_for_of_iterator_helper_loose(shaderSource.subShaders), _step; !(_step = _iterator()).done;){
2467
+ var subShader = _step.value;
2468
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(subShader.passes), _step1; !(_step1 = _iterator1()).done;){
2469
+ var pass = _step1.value;
2470
+ if (pass.isUsePass) continue;
2471
+ var statements = shaderSource.pendingContents.concat(subShader.pendingContents, pass.pendingContents);
2472
+ ShaderAnalyzer._analyzePass(pass, statements, source, diagnostics, includeMap, chunkOutputCache, sourceFile, retainParsedPasses ? parsedPasses : undefined);
2473
+ }
2474
+ }
2475
+ if (sourceFile) {
2476
+ var _diagnostic;
2477
+ var _sourceFile;
2478
+ for(var _iterator2 = _create_for_of_iterator_helper_loose(diagnostics), _step2; !(_step2 = _iterator2()).done;){
2479
+ var diagnostic = _step2.value;
2480
+ (_sourceFile = (_diagnostic = diagnostic).sourceFile) != null ? _sourceFile : _diagnostic.sourceFile = sourceFile;
2481
+ }
2482
+ }
2483
+ return Object.freeze(diagnostics);
2484
+ };
2485
+ ShaderAnalyzer._analyzePass = function _analyzePass(pass, statements, source, diagnostics, includeMap, chunkOutputCache, sourceFile, parsedPasses) {
2486
+ if (pass.contents.trim().length === 0 && (!pass.vertexEntry || !pass.fragmentEntry)) return;
2487
+ var vertexEntry = pass.vertexEntry, fragmentEntry = pass.fragmentEntry;
2488
+ var passDiagnostics = [];
2489
+ var shouldSkipSemanticValidation = false;
2490
+ var parsed = parseShaderPass(pass.contents, includeMap, chunkOutputCache, sourceFile, pass.contentScopeStarts);
2491
+ var ir = parsed.ir, errors = parsed.errors;
2492
+ var coreInfo = ir ? ShaderCoreInfo.create(ir, vertexEntry, fragmentEntry, branchAnalysis.getDeclarationCoexistence, branchAnalysis.getBranchCoverage) : undefined;
2493
+ parsedPasses == null ? void 0 : parsedPasses.push(createParsedShaderPass(parsed, vertexEntry, fragmentEntry, coreInfo));
2494
+ for(var _iterator = _create_for_of_iterator_helper_loose(errors), _step; !(_step = _iterator()).done;){
2495
+ var error = _step.value;
2496
+ var diagnostic = gseErrorToDiagnostic(error);
2497
+ if (diagnostic.code === DiagnosticType.PreprocessorError) shouldSkipSemanticValidation = true;
2498
+ if (!shouldSkipSemanticValidation || diagnostic.code === DiagnosticType.SyntaxError || diagnostic.code === DiagnosticType.PreprocessorError) {
2499
+ passDiagnostics.push(diagnostic);
2500
+ }
2501
+ }
2502
+ if (ir && coreInfo && !shouldSkipSemanticValidation) {
2503
+ var _passDiagnostics, _passDiagnostics1;
2504
+ var analysisInfo = new ShaderAnalysisInfo(ir, coreInfo);
2505
+ (_passDiagnostics = passDiagnostics).push.apply(_passDiagnostics, [].concat(ShaderValidator.validate(analysisInfo).map(function(error) {
2506
+ return gseErrorToDiagnostic(error);
2507
+ })));
2508
+ (_passDiagnostics1 = passDiagnostics).push.apply(_passDiagnostics1, [].concat(ShaderIOValidator.validate(analysisInfo, pass.vertexEntryLocation, pass.fragmentEntryLocation, source).map(function(error) {
2509
+ return gseErrorToDiagnostic(error);
2510
+ })));
2511
+ }
2512
+ var sourceMap = createPassSourceMap(statements);
2513
+ for(var _iterator1 = _create_for_of_iterator_helper_loose(passDiagnostics), _step1; !(_step1 = _iterator1()).done;){
2514
+ var diagnostic1 = _step1.value;
2515
+ var _diagnostic;
2516
+ if (diagnostic1.relatedSource === parsed.expandedSource) {
2517
+ remapExpandedDiagnostic(diagnostic1, parsed.sourceMap);
2518
+ }
2519
+ if (sourceMap.generatedSource === pass.contents && diagnostic1.relatedSource === pass.contents) {
2520
+ remapDiagnostic(diagnostic1, sourceMap.segments, source);
2521
+ }
2522
+ var _sourceFile;
2523
+ (_sourceFile = (_diagnostic = diagnostic1).sourceFile) != null ? _sourceFile : _diagnostic.sourceFile = sourceFile;
2524
+ diagnostics.push(diagnostic1);
2525
+ }
2526
+ };
2527
+ return ShaderAnalyzer;
2528
+ }();
2529
+ function remapExpandedDiagnostic(diagnostic, segments) {
2530
+ var mapped = mapExpandedShaderRange(diagnostic.range.start.offset, diagnostic.range.end.offset, segments);
2531
+ if (!mapped) return;
2532
+ diagnostic.range = {
2533
+ start: {
2534
+ offset: mapped.start.index,
2535
+ line: mapped.start.line + 1,
2536
+ column: mapped.start.column + 1
2537
+ },
2538
+ end: {
2539
+ offset: mapped.end.index,
2540
+ line: mapped.end.line + 1,
2541
+ column: mapped.end.column + 1
2542
+ }
2543
+ };
2544
+ diagnostic.relatedSource = mapped.source;
2545
+ var _mapped_sourceFile;
2546
+ diagnostic.sourceFile = (_mapped_sourceFile = mapped.sourceFile) != null ? _mapped_sourceFile : diagnostic.sourceFile;
2547
+ }
2548
+ function createPassSourceMap(statements) {
2549
+ var segments = [];
2550
+ var generatedSource = "";
2551
+ for(var index = 0; index < statements.length; index++){
2552
+ if (index > 0) generatedSource += "\n";
2553
+ var statement = statements[index];
2554
+ var generatedStart = generatedSource.length;
2555
+ generatedSource += statement.content;
2556
+ segments.push({
2557
+ generatedStart: generatedStart,
2558
+ generatedEnd: generatedSource.length,
2559
+ sourceStart: statement.range.start.index
2560
+ });
2561
+ }
2562
+ return {
2563
+ generatedSource: generatedSource,
2564
+ segments: segments
2565
+ };
2566
+ }
2567
+ function remapDiagnostic(diagnostic, segments, source) {
2568
+ var start = remapOffset(diagnostic.range.start.offset, segments);
2569
+ if (start === undefined) return;
2570
+ var _remapOffset;
2571
+ var end = (_remapOffset = remapOffset(diagnostic.range.end.offset, segments)) != null ? _remapOffset : start;
2572
+ diagnostic.range = {
2573
+ start: positionAt(source, start),
2574
+ end: positionAt(source, end)
2575
+ };
2576
+ diagnostic.relatedSource = source;
2577
+ }
2578
+ function remapOffset(offset, segments) {
2579
+ for(var index = 0; index < segments.length; index++){
2580
+ var segment = segments[index];
2581
+ if (offset >= segment.generatedStart && offset <= segment.generatedEnd) {
2582
+ return segment.sourceStart + offset - segment.generatedStart;
2583
+ }
2584
+ }
2585
+ }
2586
+
2587
+ /** High-level category assigned to a diagnostic type. */ var DiagnosticCategory = /*#__PURE__*/ function(DiagnosticCategory) {
2588
+ DiagnosticCategory["Syntax"] = "syntax";
2589
+ DiagnosticCategory["Symbol"] = "symbol";
2590
+ DiagnosticCategory["Type"] = "type";
2591
+ DiagnosticCategory["Constant"] = "constant";
2592
+ DiagnosticCategory["ControlFlow"] = "controlFlow";
2593
+ DiagnosticCategory["PipelineIO"] = "pipelineIO";
2594
+ DiagnosticCategory["RenderState"] = "renderState";
2595
+ return DiagnosticCategory;
2596
+ }({});
2597
+ var _obj;
2598
+ /** Maps every diagnostic type to its high-level category. */ var DIAGNOSTIC_CATEGORY = (_obj = {}, _obj[DiagnosticType.SyntaxError] = "syntax", _obj[DiagnosticType.PreprocessorError] = "syntax", _obj[DiagnosticType.NoMatchingOverload] = "symbol", _obj[DiagnosticType.Redefinition] = "symbol", _obj[DiagnosticType.UseBeforeDeclaration] = "symbol", _obj[DiagnosticType.RecursiveFunction] = "symbol", _obj[DiagnosticType.LocalFunctionPrototype] = "symbol", _obj[DiagnosticType.AmbiguousMacroBranchResolution] = "symbol", _obj[DiagnosticType.InvalidSwizzle] = "type", _obj[DiagnosticType.UndeclaredStructMember] = "type", _obj[DiagnosticType.AssignTypeMismatch] = "type", _obj[DiagnosticType.InvalidAssignmentTarget] = "type", _obj[DiagnosticType.ConstDivideByZero] = "type", _obj[DiagnosticType.ShiftOutOfRange] = "type", _obj[DiagnosticType.IndexOutOfBounds] = "type", _obj[DiagnosticType.NonIntegerIndex] = "type", _obj[DiagnosticType.NonIndexableType] = "type", _obj[DiagnosticType.ExpectedSampler] = "type", _obj[DiagnosticType.InvalidUnaryOperand] = "type", _obj[DiagnosticType.InvalidBinaryOperands] = "type", _obj[DiagnosticType.ConstructorArgType] = "type", _obj[DiagnosticType.ConstructorArgCount] = "type", _obj[DiagnosticType.EmptyStruct] = "type", _obj[DiagnosticType.InvalidArraySize] = "type", _obj[DiagnosticType.InvalidVoidVariable] = "type", _obj[DiagnosticType.NonFloatDerivativeArg] = "type", _obj[DiagnosticType.NonConstInitializer] = "constant", _obj[DiagnosticType.NonConstArraySize] = "constant", _obj[DiagnosticType.NonConstructibleReturnType] = "constant", _obj[DiagnosticType.InvalidReturnType] = "controlFlow", _obj[DiagnosticType.MissingReturn] = "controlFlow", _obj[DiagnosticType.NonBoolCondition] = "controlFlow", _obj[DiagnosticType.MisplacedControlFlow] = "controlFlow", _obj[DiagnosticType.InvalidEntryReturnType] = "controlFlow", _obj[DiagnosticType.DerivativeInVertexShader] = "controlFlow", _obj[DiagnosticType.InvalidIOStruct] = "pipelineIO", _obj[DiagnosticType.InvalidBuiltinStage] = "pipelineIO", _obj[DiagnosticType.StructRoleConflict] = "pipelineIO", _obj[DiagnosticType.DuplicateEntryAssignment] = "pipelineIO", _obj[DiagnosticType.MissingEntry] = "pipelineIO", _obj[DiagnosticType.EntryNotFound] = "pipelineIO", _obj[DiagnosticType.AmbiguousEntryPoint] = "pipelineIO", _obj[DiagnosticType.GlFragColorWithMrt] = "pipelineIO", _obj[DiagnosticType.LegacyFragmentOutputConflict] = "pipelineIO", _obj[DiagnosticType.InvalidMrtOutput] = "pipelineIO", _obj[DiagnosticType.BareGlFragData] = "pipelineIO", _obj[DiagnosticType.NonConstFragmentOutputIndex] = "pipelineIO", _obj[DiagnosticType.NestedIOStruct] = "pipelineIO", _obj[DiagnosticType.MissingVertexPosition] = "pipelineIO", _obj[DiagnosticType.NonFlatIntegerVarying] = "pipelineIO", _obj[DiagnosticType.InvalidRenderStateProperty] = "renderState", _obj[DiagnosticType.InvalidEnumValue] = "renderState", _obj[DiagnosticType.BitwiseOrOnNonBitmask] = "renderState", _obj[DiagnosticType.MixedEnumTypes] = "renderState", _obj[DiagnosticType.InvalidRenderStateVariable] = "renderState", _obj[DiagnosticType.InvalidRenderQueueVariable] = "renderState", _obj);
2599
+
2600
+ export { DIAGNOSTIC_CATEGORY, DiagnosticCategory, DiagnosticSeverity, DiagnosticType, ShaderAnalyzer, formatDiagnostic };
2601
+ //# sourceMappingURL=module.js.map