@galacean/engine-shader-compiler 2.0.0-alpha.55 → 2.0.0-alpha.56
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/browser.js +575 -315
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/main.js +566 -309
- package/dist/main.js.map +1 -1
- package/dist/module.js +567 -310
- package/dist/module.js.map +1 -1
- package/dist/precompile.main.js +566 -308
- package/dist/precompile.main.js.map +1 -1
- package/dist/precompile.module.js +567 -309
- package/dist/precompile.module.js.map +1 -1
- package/package.json +5 -5
- package/types/codeGen/CodeGenVisitor.d.ts +9 -2
- package/types/codeGen/GLES100.d.ts +3 -3
- package/types/codeGen/GLES300.d.ts +4 -1
- package/types/codeGen/GLESVisitor.d.ts +45 -2
- package/types/codeGen/NameAllocator.d.ts +36 -0
- package/types/codeGen/VisitorContext.d.ts +2 -24
package/dist/browser.min.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.min.js","sources":["../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_instanceof.js","../../design/dist/module.js","../../shader-parser/dist/shared/GLESShaderInfo.module.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_type_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_set_prototype_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_inherits.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_is_native_reflect_construct.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_construct.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_get_prototype_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_wrap_native_super.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_is_native_function.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_array_like_to_array.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_for_of_iterator_helper_loose.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js","../src/codeGen/VisitorContext.ts","../src/TempArray.ts","../src/codeGen/CodeGenVisitor.ts","../src/ShaderInstructionEncoder.ts","../src/codeGen/GLESVisitor.ts","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_class.js","../src/codeGen/GLES100.ts","../src/codeGen/GLES300.ts","../src/GLESBackend.ts","../src/ShaderCompilation.ts","../src/ShaderCompiler.ts","../src/index.ts"],"sourcesContent":["function _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else return left instanceof right;\n}\nexport { _instanceof as _ };\n","function _extends() {\n _extends = Object.assign || function assign(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\n\nfunction _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nvar binaryPrecedence = {\n \"||\": 1,\n \"&&\": 2,\n \"|\": 3,\n \"^\": 4,\n \"&\": 5,\n \"==\": 6,\n \"!=\": 6,\n \"<\": 7,\n \"<=\": 7,\n \">\": 7,\n \">=\": 7,\n \"<<\": 8,\n \">>\": 8,\n \"+\": 9,\n \"-\": 9,\n \"*\": 10,\n \"/\": 10,\n \"%\": 10\n};\nvar MAX_EXPRESSION_NESTING = 256;\nvar MAX_MACRO_EXPANSION_DEPTH = 256;\nvar MAX_MACRO_EXPANSION_TOKENS = 65536;\n/**\n * Parses the complete integer-expression grammar used by `#if` and `#elif`.\n * @param expression - Text after the preprocessor directive.\n * @returns A serializable tree or a structured parse failure.\n */ function parsePreprocessorExpression(expression) {\n return new ExpressionParser(expression).parse();\n}\n/**\n * Resolves `defined` operators and removes comments with the expression parser's tokenization rules.\n * @param expression - Expression before ordinary macro replacement.\n * @param isDefined - Resolves whether one macro name is defined, or returns `undefined` when external state decides.\n * @returns Token-normalized expression with every known `defined` operator replaced by `0` or `1`.\n */ function resolvePreprocessorDefinedOperators(expression, isDefined) {\n var tokens = tokenize(expression);\n var parts = [];\n for(var index = 0; index < tokens.length - 1; index++){\n var token = tokens[index];\n if (token.kind !== \"identifier\" || token.text !== \"defined\") {\n parts.push(token.text);\n continue;\n }\n var next = tokens[index + 1];\n var parenthesized = (next == null ? void 0 : next.text) === \"(\";\n var name = tokens[index + (parenthesized ? 2 : 1)];\n var close = parenthesized ? tokens[index + 3] : name;\n if ((name == null ? void 0 : name.kind) !== \"identifier\" || name.text === \"defined\" || parenthesized && (close == null ? void 0 : close.text) !== \")\") {\n parts.push(token.text);\n continue;\n }\n var defined = isDefined(name.text);\n if (defined === undefined) {\n parts.push(\"defined\");\n if (parenthesized) parts.push(\"(\");\n parts.push(name.text);\n if (parenthesized) parts.push(\")\");\n } else {\n parts.push(defined ? \"1\" : \"0\");\n }\n index += parenthesized ? 3 : 1;\n }\n return parts.join(\" \");\n}\n/**\n * Expands object-like and function-like macros with the expression parser's tokenization rules.\n * @param expression - Expression after any caller-owned `defined` resolution.\n * @param resolveMacro - Resolves source or runtime macro definitions by name.\n * @returns Token-normalized expansion or a deterministic depth error.\n */ function expandPreprocessorExpressionMacros(expression, resolveMacro) {\n var expanded = expandMacroTokens(tokenize(expression).slice(0, -1), resolveMacro, tokenize, true, 0, {\n remaining: MAX_MACRO_EXPANSION_TOKENS\n });\n return typeof expanded === \"string\" ? {\n expression: \"\",\n error: expanded\n } : {\n expression: expanded.map(function(token) {\n return token.text;\n }).join(\" \")\n };\n}\n/**\n * Expands shader macros using the same argument prescan and rescan rules as conditional expressions.\n * @param source - Shader text without macro definition or conditional directives.\n * @param resolveMacro - Resolves the macro state active at this source location.\n * @returns Expanded shader source, or a deterministic expansion-limit error.\n */ function expandShaderMacros(source, resolveMacro) {\n var expanded = expandMacroTokens(tokenizeShader(source).slice(0, -1), resolveMacro, tokenizeShaderReplacement, false, 0, {\n remaining: MAX_MACRO_EXPANSION_TOKENS\n });\n return typeof expanded === \"string\" ? {\n source: \"\",\n error: expanded\n } : {\n source: serializeShaderTokens(expanded)\n };\n}\nfunction expandMacroTokens(input, resolveMacro, tokenizeReplacement, protectDefined, depth, budget) {\n var tokens = input.slice();\n var output = [];\n var index = 0;\n while(index < tokens.length){\n var // Rescan in place so an object alias can form a call with the following original tokens\n _tokens;\n var _token_disabledMacros, _tokens_openParen;\n var token = tokens[index];\n if (protectDefined && token.text === \"defined\") {\n var _tokens_index;\n output.push(token);\n index++;\n var count = ((_tokens_index = tokens[index]) == null ? void 0 : _tokens_index.text) === \"(\" ? 3 : 1;\n for(var i = 0; i < count && index < tokens.length; i++)output.push(tokens[index++]);\n continue;\n }\n var macro = token.kind === \"identifier\" && !((_token_disabledMacros = token.disabledMacros) == null ? void 0 : _token_disabledMacros.has(token.text)) ? resolveMacro(token.text) : undefined;\n var openParen = index + 1;\n if (macro == null ? void 0 : macro.parameters) {\n var _tokens_openParen1;\n while(((_tokens_openParen1 = tokens[openParen]) == null ? void 0 : _tokens_openParen1.kind) === \"trivia\")openParen++;\n }\n if (!macro || macro.parameters && ((_tokens_openParen = tokens[openParen]) == null ? void 0 : _tokens_openParen.text) !== \"(\") {\n output.push(token);\n index++;\n continue;\n }\n var _token_expansionDepth;\n var expansionDepth = Math.max(depth, (_token_expansionDepth = token.expansionDepth) != null ? _token_expansionDepth : 0) + 1;\n if (expansionDepth > MAX_MACRO_EXPANSION_DEPTH) {\n return \"Preprocessor macro expansion exceeds \" + MAX_MACRO_EXPANSION_DEPTH + \" nested replacements.\";\n }\n var invocationEnd = index;\n var args = [];\n var disabledMacros = new Set(token.disabledMacros);\n if (macro.parameters) {\n var invocation = parseMacroInvocation(tokens, openParen);\n if (!invocation) {\n output.push(token);\n index++;\n continue;\n }\n args = invocation.arguments;\n if (macro.parameters.length === 0 && args.length === 1 && args[0].every(function(token) {\n return token.kind === \"trivia\";\n })) {\n args = [];\n }\n if (args.length !== macro.parameters.length) {\n output.push(token);\n index++;\n continue;\n }\n invocationEnd = invocation.end;\n // A function invocation inherits only exclusions present at both invocation boundaries\n var closingExclusions = tokens[invocationEnd].disabledMacros;\n for(var _iterator = _create_for_of_iterator_helper_loose(disabledMacros), _step; !(_step = _iterator()).done;){\n var name = _step.value;\n if (!(closingExclusions == null ? void 0 : closingExclusions.has(name))) disabledMacros.delete(name);\n }\n }\n disabledMacros.add(token.text);\n var replacement = [];\n var expandedArguments = new Map();\n for(var _iterator1 = _create_for_of_iterator_helper_loose(tokenizeReplacement(macro.body).slice(0, -1)), _step1; !(_step1 = _iterator1()).done;){\n var _loop = function() {\n var part = _step2.value;\n var _part_disabledMacros;\n if (--budget.remaining < 0) return {\n v: \"Preprocessor macro expansion exceeds \" + MAX_MACRO_EXPANSION_TOKENS + \" replacement tokens.\"\n };\n // Only macro names and invocation closing boundaries carry exclusions into later rescans.\n if (part.kind !== \"identifier\" && part.text !== \")\") {\n replacement.push(part);\n return \"continue\";\n }\n var exclusions = disabledMacros;\n if ((_part_disabledMacros = part.disabledMacros) == null ? void 0 : _part_disabledMacros.size) {\n exclusions = new Set(disabledMacros);\n part.disabledMacros.forEach(function(name) {\n return exclusions.add(name);\n });\n }\n var _part_expansionDepth;\n replacement.push(_extends({}, part, {\n disabledMacros: exclusions,\n expansionDepth: Math.max(expansionDepth, (_part_expansionDepth = part.expansionDepth) != null ? _part_expansionDepth : 0)\n }));\n };\n var bodyToken = _step1.value;\n var _macro_parameters;\n var _macro_parameters_indexOf;\n var parameter = bodyToken.kind === \"identifier\" ? (_macro_parameters_indexOf = (_macro_parameters = macro.parameters) == null ? void 0 : _macro_parameters.indexOf(bodyToken.text)) != null ? _macro_parameters_indexOf : -1 : -1;\n var substituted = [\n bodyToken\n ];\n if (parameter >= 0) {\n var argument = expandedArguments.get(parameter);\n if (!argument) {\n // Arguments expand before this invocation disables its own name, including ID(ID(1))\n var expanded = expandMacroTokens(args[parameter], resolveMacro, tokenizeReplacement, protectDefined, expansionDepth, budget);\n if (typeof expanded === \"string\") return expanded;\n expandedArguments.set(parameter, argument = expanded);\n }\n substituted = argument;\n }\n for(var _iterator2 = _create_for_of_iterator_helper_loose(substituted), _step2; !(_step2 = _iterator2()).done;){\n var _ret = _loop();\n if (_type_of(_ret) === \"object\") return _ret.v;\n }\n }\n (_tokens = tokens).splice.apply(_tokens, [].concat([\n index,\n invocationEnd - index + 1\n ], replacement));\n }\n return output;\n}\nvar shaderMultiOperators = new Set([\n \"<<=\",\n \">>=\",\n \"++\",\n \"--\",\n \"<<\",\n \">>\",\n \"<=\",\n \">=\",\n \"==\",\n \"!=\",\n \"&&\",\n \"||\",\n \"^^\",\n \"+=\",\n \"-=\",\n \"*=\",\n \"/=\",\n \"%=\",\n \"&=\",\n \"^=\",\n \"|=\",\n \"##\"\n]);\n// Shader replacement lists use preprocessing numbers, not the integer-only #if grammar.\nfunction tokenizeShader(source, removeComments) {\n if (removeComments === void 0) removeComments = false;\n var tokens = [];\n var index = 0;\n while(index < source.length){\n var start = index;\n var char = source.charCodeAt(index++);\n var kind = void 0;\n var comment = false;\n var _source_index;\n if (isWhitespace(char)) {\n kind = \"trivia\";\n while(isWhitespace(source.charCodeAt(index)))index++;\n } else if (char === 47 && source[index] === \"/\") {\n kind = \"trivia\";\n comment = true;\n while(index < source.length && source[index] !== \"\\n\" && source[index] !== \"\\r\")index++;\n } else if (char === 47 && source[index] === \"*\") {\n kind = \"trivia\";\n comment = true;\n var close = source.indexOf(\"*/\", index + 1);\n index = close < 0 ? source.length : close + 2;\n } else if (char === 34 || char === 39) {\n kind = \"invalid\";\n while(index < source.length){\n var next = source.charCodeAt(index++);\n if (next === 92) index = Math.min(index + 1, source.length);\n else if (next === char) break;\n }\n } else if (isIdentifierStart(char)) {\n kind = \"identifier\";\n while(isIdentifierPart(source.charCodeAt(index)))index++;\n } else if (char >= 48 && char <= 57 || char === 46 && /[0-9]/.test((_source_index = source[index]) != null ? _source_index : \"\")) {\n kind = \"number\";\n while(index < source.length){\n var next1 = source.charCodeAt(index);\n if (isIdentifierPart(next1) || next1 === 46) index++;\n else if ((next1 === 43 || next1 === 45) && /[eEpP]/.test(source[index - 1])) index++;\n else break;\n }\n } else {\n kind = \"operator\";\n if (char === 60 || char === 62) {\n if (shaderMultiOperators.has(source.slice(start, start + 3))) index = start + 3;\n else if (shaderMultiOperators.has(source.slice(start, start + 2))) index = start + 2;\n } else if (\"+-*/%&|^!=#\".includes(source[start]) && shaderMultiOperators.has(source.slice(start, start + 2))) {\n index = start + 2;\n }\n }\n var text = source.slice(start, index);\n tokens.push({\n kind: kind,\n text: removeComments && comment ? text.replace(/[^\\r\\n]/g, \"\") || \" \" : text,\n start: start,\n end: index\n });\n }\n tokens.push({\n kind: \"end\",\n text: \"\",\n start: index,\n end: index\n });\n return tokens;\n}\nfunction tokenizeShaderReplacement(source) {\n // A comment in a replacement list is whitespace; a trailing // must not swallow the caller's suffix.\n return tokenizeShader(source, true);\n}\nfunction serializeShaderTokens(tokens) {\n var parts = [];\n var previous;\n for(var _iterator = _create_for_of_iterator_helper_loose(tokens), _step; !(_step = _iterator()).done;){\n var token = _step.value;\n if (previous && previous.kind !== \"trivia\" && token.kind !== \"trivia\") {\n var word = previous.kind === \"identifier\" || previous.kind === \"number\";\n var nextWord = token.kind === \"identifier\" || token.kind === \"number\";\n var joined = previous.kind === \"operator\" && token.kind === \"operator\" ? previous.text + token.text : \"\";\n // Replacement must not join two preprocessing tokens into a new number, operator or comment.\n if (word && nextWord || previous.kind === \"number\" && (token.text === \".\" || /[eEpP]$/.test(previous.text) && /^[+-]/.test(token.text)) || previous.text === \".\" && token.kind === \"number\" || joined && previous.text.length < 2 && shaderMultiOperators.has(joined.slice(0, 2)) || joined && previous.text.length < 3 && shaderMultiOperators.has(joined.slice(0, 3)) || joined.startsWith(\"//\") || joined.startsWith(\"/*\")) parts.push(\" \");\n }\n parts.push(token.text);\n previous = token;\n }\n return parts.join(\"\");\n}\nfunction parseMacroInvocation(tokens, openParen) {\n var args = [\n []\n ];\n var depth = 1;\n for(var index = openParen + 1; index < tokens.length; index++){\n var token = tokens[index];\n if (token.text === \"(\") {\n depth++;\n args[args.length - 1].push(token);\n } else if (token.text === \")\") {\n if (--depth === 0) {\n for(var _iterator = _create_for_of_iterator_helper_loose(args), _step; !(_step = _iterator()).done;){\n var argument = _step.value;\n trimMacroArgument(argument);\n }\n return {\n arguments: args,\n end: index\n };\n }\n args[args.length - 1].push(token);\n } else if (token.text === \",\" && depth === 1) {\n args.push([]);\n } else {\n args[args.length - 1].push(token);\n }\n }\n}\nfunction trimMacroArgument(tokens) {\n // Call-site padding is not part of the replacement. Keep comments and line breaks intact.\n for(var _i = 0, _iter = [\n false,\n true\n ]; _i < _iter.length; _i++){\n var trailing = _iter[_i];\n while(tokens.length){\n var index = trailing ? tokens.length - 1 : 0;\n var token = tokens[index];\n if (token.kind !== \"trivia\") break;\n var text = token.text.replace(trailing ? /[ \\t\\v\\f]+$/ : /^[ \\t\\v\\f]+/, \"\");\n if (text === token.text) break;\n if (text) {\n tokens[index] = _extends({}, token, {\n text: text\n });\n break;\n }\n if (trailing) tokens.pop();\n else tokens.shift();\n }\n }\n}\n/**\n * Evaluates an expression whose result is independent of macro state.\n * @param expression - Complete preprocessor expression text.\n * @returns 32-bit result, or `undefined` when the expression is invalid, state-dependent, or unevaluable.\n */ function evaluateContextFreePreprocessorExpression(expression) {\n var parsed = parsePreprocessorExpression(expression);\n return parsed.ok ? evaluateContextFreePreprocessorCondition(parsed.condition) : undefined;\n}\n/**\n * Evaluates a parsed condition whose result is independent of macro state.\n * @param condition - Parsed preprocessor expression tree.\n * @returns 32-bit result, or `undefined` when macro state or an invalid operation affects the result.\n */ function evaluateContextFreePreprocessorCondition(condition) {\n var evaluated = evaluateStaticallyKnownPreprocessorCondition(condition);\n return typeof evaluated === \"number\" ? evaluated : undefined;\n}\n/**\n * Evaluates the part of a preprocessor expression determined by known source macro state.\n * @param condition - Parsed preprocessor expression tree.\n * @param context - Partially known macro values and definition states.\n * @returns 32-bit result, or `undefined` when any reachable input remains unknown.\n */ function evaluatePartiallyKnownPreprocessorCondition(condition, context) {\n return evaluatePartiallyKnownPreprocessorConditionResult(condition, context).value;\n}\n/**\n * Evaluates the known portion of an expression while preserving definite evaluation failures.\n * @param condition - Parsed preprocessor expression tree.\n * @param context - Partially known macro values and definition states.\n * @returns Known value, definite error, or an empty result when external state still matters.\n */ function evaluatePartiallyKnownPreprocessorConditionResult(condition, context) {\n var evaluated = evaluateStaticallyKnownPreprocessorCondition(condition, context);\n return typeof evaluated === \"number\" ? {\n value: evaluated\n } : typeof evaluated === \"string\" ? {\n error: evaluated\n } : {};\n}\n/**\n * Evaluates a parsed preprocessor expression with signed 32-bit arithmetic matching ANGLE's preprocessor.\n * @param condition - Serializable expression tree.\n * @param context - Active macro value and definition resolver.\n * @returns Signed 32-bit result; nonzero values are true.\n * @throws Error when an active expression divides by zero or contains a deferred node.\n */ function evaluatePreprocessorExpression(condition, context) {\n var evaluated = evaluatePreprocessorExpressionInternal(condition, context);\n if (typeof evaluated === \"string\") throw new Error(evaluated);\n return evaluated;\n}\nvar DIVISION_BY_ZERO_ERROR = \"Division by zero in active preprocessor expression.\";\nvar MODULO_BY_ZERO_ERROR = \"Modulo by zero in active preprocessor expression.\";\nvar INVALID_SHIFT_COUNT_ERROR = \"Shift count must be between 0 and 31 in active preprocessor expression.\";\nfunction evaluatePreprocessorExpressionInternal(condition, context) {\n switch(condition.t){\n case \"def\":\n return context.isDefined(condition.m) ? 1 : 0;\n case \"ndef\":\n return context.isDefined(condition.m) ? 0 : 1;\n case \"cmp\":\n return evaluateBinaryExpression(context.resolveIdentifier(condition.m), condition.op, condition.v);\n case \"and\":\n {\n var left = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left === \"string\" || left === 0) return left;\n var right = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right === \"string\" ? right : right !== 0 ? 1 : 0;\n }\n case \"or\":\n {\n var left1 = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left1 === \"string\") return left1;\n if (left1 !== 0) return 1;\n var right1 = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right1 === \"string\" ? right1 : right1 !== 0 ? 1 : 0;\n }\n case \"not\":\n {\n var value = evaluatePreprocessorExpressionInternal(condition.c, context);\n return typeof value === \"string\" ? value : value === 0 ? 1 : 0;\n }\n case \"bool\":\n return condition.v ? 1 : 0;\n case \"num\":\n return condition.v;\n case \"id\":\n return context.resolveIdentifier(condition.m);\n case \"unary\":\n {\n var value1 = evaluatePreprocessorExpressionInternal(condition.c, context);\n if (typeof value1 === \"string\") return value1;\n return condition.op === \"+\" ? value1 | 0 : condition.op === \"-\" ? -value1 | 0 : ~value1;\n }\n case \"binary\":\n {\n var left2 = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left2 === \"string\") return left2;\n var right2 = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right2 === \"string\" ? right2 : evaluateBinaryExpression(left2, condition.op, right2);\n }\n case \"deferred\":\n return \"Deferred preprocessor expressions must be expanded before evaluation.\";\n }\n}\nvar ExpressionParser = /*#__PURE__*/ function() {\n function ExpressionParser(expression) {\n this._index = 0;\n this._sawExpandableIdentifier = false;\n this._rightEdgeExpandable = false;\n this._nestingDepth = 0;\n this._tokens = tokenize(expression);\n }\n var _proto = ExpressionParser.prototype;\n _proto.parse = function parse() {\n var condition = this._parseRoot();\n var invalid = this._invalidResult();\n if (invalid) return invalid;\n var evaluated = this._sawExpandableIdentifier ? undefined : evaluateStaticallyKnownPreprocessorCondition(condition);\n return _extends({\n ok: true,\n condition: condition,\n hasExpandableIdentifier: this._sawExpandableIdentifier\n }, typeof evaluated === \"string\" ? {\n evaluationError: evaluated\n } : undefined);\n };\n _proto._parseRoot = function _parseRoot() {\n var condition = this._parseBinary(1);\n if (!this._failure) {\n var token = this._current();\n if (token.kind !== \"end\") {\n var unexpectedExpandableIdentifier = token.kind === \"identifier\" && token.text !== \"defined\";\n this._sawExpandableIdentifier || (this._sawExpandableIdentifier = unexpectedExpandableIdentifier);\n var unsupportedConditionalOperator = token.text === \"?\" || token.text === \":\";\n var certain = unsupportedConditionalOperator || !this._rightEdgeExpandable && !unexpectedExpandableIdentifier && !(token.text === \")\" && this._sawExpandableIdentifier);\n this._fail(\"Unexpected token '\" + token.text + \"' in preprocessor expression.\", token, certain);\n }\n }\n return condition;\n };\n _proto._invalidResult = function _invalidResult() {\n if (this._failure) {\n // A macro supplying a closing delimiter may be the token where parsing stopped.\n for(var i = this._index; i < this._tokens.length; i++){\n var token = this._tokens[i];\n if (token.kind === \"identifier\" && token.text !== \"defined\") {\n this._sawExpandableIdentifier = true;\n break;\n }\n }\n }\n return this._failure ? {\n ok: false,\n error: this._failure,\n hasExpandableIdentifier: this._sawExpandableIdentifier\n } : undefined;\n };\n _proto._parseBinary = function _parseBinary(minPrecedence) {\n var left = this._parseUnary();\n if (this._failure || !left) return undefined;\n while(true){\n var token = this._current();\n var precedence = binaryPrecedence[token.text];\n if (precedence === undefined || precedence < minPrecedence) return left;\n this._index++;\n var right = this._parseBinary(precedence + 1);\n if (this._failure || !right) return undefined;\n if (token.text === \"&&\") left = {\n t: \"and\",\n l: left,\n r: right\n };\n else if (token.text === \"||\") left = {\n t: \"or\",\n l: left,\n r: right\n };\n else left = {\n t: \"binary\",\n op: token.text,\n l: left,\n r: right\n };\n }\n };\n _proto._parseUnary = function _parseUnary() {\n var token = this._current();\n if (token.kind === \"operator\" && (token.text === \"+\" || token.text === \"-\" || token.text === \"!\" || token.text === \"~\")) {\n if (!this._enterNesting(token)) return;\n this._index++;\n var condition = this._parseUnary();\n this._nestingDepth--;\n if (!condition) return undefined;\n return token.text === \"!\" ? {\n t: \"not\",\n c: condition\n } : {\n t: \"unary\",\n op: token.text,\n c: condition\n };\n }\n return this._parsePrimary();\n };\n _proto._parsePrimary = function _parsePrimary() {\n var token = this._current();\n if (token.kind === \"number\") {\n this._index++;\n this._rightEdgeExpandable = false;\n var value = parseIntegerLiteral(token.text);\n if (value === undefined) {\n this._fail(\"Integer literal exceeds 32 bits in preprocessor expression.\", token, true);\n return undefined;\n }\n return {\n t: \"num\",\n v: value\n };\n }\n if (token.kind === \"identifier\") {\n if (token.text === \"defined\") return this._parseDefined();\n this._sawExpandableIdentifier = true;\n this._rightEdgeExpandable = true;\n this._index++;\n return {\n t: \"id\",\n m: token.text\n };\n }\n if (this._consume(\"(\")) {\n if (!this._enterNesting(token)) return;\n var condition = this._parseBinary(1);\n if (!this._failure && !this._consume(\")\")) {\n this._fail(\"Expected ')' in preprocessor expression.\", this._current(), false);\n }\n if (!this._failure) this._rightEdgeExpandable = false;\n this._nestingDepth--;\n return condition;\n }\n if (token.kind === \"end\") {\n this._fail(\"Expected an operand before the end of the preprocessor expression.\", token, true);\n } else {\n this._fail(\"Expected an operand, found '\" + token.text + \"'.\", token, true);\n }\n return undefined;\n };\n _proto._parseDefined = function _parseDefined() {\n this._index++;\n this._rightEdgeExpandable = false;\n var parenthesized = this._consume(\"(\");\n var name = this._current();\n if (name.kind !== \"identifier\" || name.text === \"defined\") {\n this._fail(\"Expected a macro name after 'defined'.\", name, true);\n return undefined;\n }\n this._index++;\n if (parenthesized && !this._consume(\")\")) {\n this._fail(\"Expected ')' after the macro name in 'defined(...)'.\", this._current(), true);\n return undefined;\n }\n return {\n t: \"def\",\n m: name.text\n };\n };\n _proto._consume = function _consume(text) {\n if (this._current().text !== text) return false;\n this._index++;\n return true;\n };\n _proto._enterNesting = function _enterNesting(token) {\n if (this._nestingDepth >= MAX_EXPRESSION_NESTING) {\n this._fail(\"Preprocessor expression nesting exceeds the supported depth of \" + MAX_EXPRESSION_NESTING + \".\", token, true);\n return false;\n }\n this._nestingDepth++;\n return true;\n };\n _proto._current = function _current() {\n return this._tokens[this._index];\n };\n _proto._fail = function _fail(message, token, certain) {\n var _this__failure;\n (_this__failure = this._failure) != null ? _this__failure : this._failure = {\n message: message,\n start: token.start,\n end: Math.max(token.end, token.start + 1),\n certain: certain\n };\n };\n return ExpressionParser;\n}();\nfunction tokenize(expression) {\n var tokens = [];\n var index = 0;\n while(index < expression.length){\n var charCode = expression.charCodeAt(index);\n if (isWhitespace(charCode)) {\n index++;\n continue;\n }\n if (charCode === 47 && expression.charCodeAt(index + 1) === 47) break;\n if (charCode === 47 && expression.charCodeAt(index + 1) === 42) {\n var end = expression.indexOf(\"*/\", index + 2);\n if (end < 0) {\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(index),\n start: index,\n end: expression.length\n });\n index = expression.length;\n } else {\n index = end + 2;\n }\n continue;\n }\n if (isIdentifierStart(charCode)) {\n var start = index++;\n while(index < expression.length && isIdentifierPart(expression.charCodeAt(index)))index++;\n tokens.push({\n kind: \"identifier\",\n text: expression.slice(start, index),\n start: start,\n end: index\n });\n continue;\n }\n if (charCode >= 48 && charCode <= 57) {\n var start1 = index;\n if (charCode === 48 && (expression.charCodeAt(index + 1) === 88 || expression.charCodeAt(index + 1) === 120)) {\n index += 2;\n var digitStart = index;\n while(index < expression.length && isHexDigit(expression.charCodeAt(index)))index++;\n if (index === digitStart) {\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n } else if (charCode === 48) {\n index++;\n while(index < expression.length && expression.charCodeAt(index) >= 48 && expression.charCodeAt(index) <= 55)index++;\n } else {\n index++;\n while(index < expression.length && expression.charCodeAt(index) >= 48 && expression.charCodeAt(index) <= 57)index++;\n }\n var suffixStart = index;\n while(isIntegerSuffix(expression.charCodeAt(index)))index++;\n var suffix = expression.slice(suffixStart, index);\n if (!isValidIntegerSuffix(suffix) || isIdentifierStart(expression.charCodeAt(index))) {\n while(isIdentifierPart(expression.charCodeAt(index)))index++;\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n tokens.push({\n kind: \"number\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n var nextCharCode = expression.charCodeAt(index + 1);\n if (isDoubleOperator(charCode, nextCharCode)) {\n tokens.push({\n kind: \"operator\",\n text: expression.slice(index, index + 2),\n start: index,\n end: index + 2\n });\n index += 2;\n continue;\n }\n if (isSingleOperator(charCode)) {\n tokens.push({\n kind: \"operator\",\n text: expression[index],\n start: index,\n end: index + 1\n });\n index++;\n continue;\n }\n tokens.push({\n kind: \"invalid\",\n text: expression[index],\n start: index,\n end: index + 1\n });\n index++;\n }\n tokens.push({\n kind: \"end\",\n text: \"\",\n start: index,\n end: index\n });\n return tokens;\n}\nfunction parseIntegerLiteral(literal) {\n var end = literal.length;\n while(end > 0 && isIntegerSuffix(literal.charCodeAt(end - 1)))end--;\n var value;\n if (literal.charCodeAt(0) === 48) {\n var prefix = literal.charCodeAt(1);\n if (prefix === 88 || prefix === 120) value = parseInt(literal.slice(2, end), 16);\n else if (end > 1) value = parseInt(literal.slice(0, end), 8);\n else value = 0;\n } else {\n value = Number(literal.slice(0, end));\n }\n return value <= 0xffffffff ? value | 0 : undefined;\n}\nfunction evaluateBinaryExpression(left, operator, right) {\n switch(operator){\n case \"||\":\n return left !== 0 || right !== 0 ? 1 : 0;\n case \"&&\":\n return left !== 0 && right !== 0 ? 1 : 0;\n case \"|\":\n return left | right;\n case \"^\":\n return left ^ right;\n case \"&\":\n return left & right;\n case \"==\":\n return left === right ? 1 : 0;\n case \"!=\":\n return left !== right ? 1 : 0;\n case \"<\":\n return left < right ? 1 : 0;\n case \"<=\":\n return left <= right ? 1 : 0;\n case \">\":\n return left > right ? 1 : 0;\n case \">=\":\n return left >= right ? 1 : 0;\n case \"<<\":\n {\n if (right < 0 || right > 31) return INVALID_SHIFT_COUNT_ERROR;\n return left << right;\n }\n case \">>\":\n {\n if (right < 0 || right > 31) return INVALID_SHIFT_COUNT_ERROR;\n return left >>> right | 0;\n }\n case \"+\":\n return left + right | 0;\n case \"-\":\n return left - right | 0;\n case \"*\":\n return Math.imul(left, right);\n case \"/\":\n if (right === 0) return DIVISION_BY_ZERO_ERROR;\n if (left === -0x80000000 && right === -1) return 0x7fffffff;\n return Math.trunc(left / right) | 0;\n case \"%\":\n if (right === 0) return MODULO_BY_ZERO_ERROR;\n return left % right | 0;\n default:\n throw new Error(\"Unsupported preprocessor operator '\" + operator + \"'.\");\n }\n}\nfunction validateBinaryRightOperand(operator, right) {\n if ((operator === \"/\" || operator === \"%\") && right === 0) {\n return operator === \"/\" ? DIVISION_BY_ZERO_ERROR : MODULO_BY_ZERO_ERROR;\n }\n if ((operator === \"<<\" || operator === \">>\") && right !== undefined && (right < 0 || right > 31)) {\n return INVALID_SHIFT_COUNT_ERROR;\n }\n}\nfunction evaluateStaticallyKnownPreprocessorCondition(condition, context) {\n switch(condition.t){\n case \"and\":\n {\n var left = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n if (typeof left === \"string\") return left;\n if (left === 0) return 0;\n var right = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof right === \"string\") return left === undefined ? undefined : right;\n if (right === 0) return 0;\n return left === undefined || right === undefined ? undefined : 1;\n }\n case \"or\":\n {\n var left1 = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n if (typeof left1 === \"string\") return left1;\n if (left1 !== undefined && left1 !== 0) return 1;\n var right1 = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof right1 === \"string\") return left1 === undefined ? undefined : right1;\n if (right1 !== undefined && right1 !== 0) return 1;\n return left1 === undefined || right1 === undefined ? undefined : 0;\n }\n case \"binary\":\n {\n var left2 = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n var right2 = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof left2 === \"string\") return left2;\n if (typeof right2 === \"string\") return right2;\n var rightOperandError = validateBinaryRightOperand(condition.op, right2);\n if (rightOperandError) return rightOperandError;\n if (left2 === undefined || right2 === undefined) {\n return context ? evaluateBoundedIdentifierComparison(condition, left2, right2) : undefined;\n }\n var value = evaluateBinaryExpression(left2, condition.op, right2);\n return value;\n }\n case \"not\":\n {\n var value1 = evaluateStaticallyKnownPreprocessorCondition(condition.c, context);\n if (typeof value1 === \"string\") return value1;\n return value1 === undefined ? undefined : value1 === 0 ? 1 : 0;\n }\n case \"unary\":\n {\n var value2 = evaluateStaticallyKnownPreprocessorCondition(condition.c, context);\n if (typeof value2 === \"string\") return value2;\n if (value2 === undefined) return undefined;\n return condition.op === \"+\" ? value2 | 0 : condition.op === \"-\" ? -value2 | 0 : ~value2;\n }\n case \"bool\":\n return condition.v ? 1 : 0;\n case \"num\":\n return condition.v;\n case \"def\":\n {\n var defined = context == null ? void 0 : context.isDefined(condition.m);\n return defined === undefined ? undefined : defined ? 1 : 0;\n }\n case \"ndef\":\n {\n var defined1 = context == null ? void 0 : context.isDefined(condition.m);\n return defined1 === undefined ? undefined : defined1 ? 0 : 1;\n }\n case \"cmp\":\n {\n var resolved = context == null ? void 0 : context.resolveIdentifier(condition.m);\n if (resolved == null ? void 0 : resolved.error) return resolved.error;\n var value3 = resolved == null ? void 0 : resolved.value;\n if (value3 === undefined) return context ? evaluateUnknownSignedComparison(condition.op, condition.v) : undefined;\n var result = evaluateBinaryExpression(value3, condition.op, condition.v);\n return typeof result === \"string\" ? undefined : result;\n }\n case \"id\":\n {\n var resolved1 = context == null ? void 0 : context.resolveIdentifier(condition.m);\n return (resolved1 == null ? void 0 : resolved1.error) ? resolved1.error : resolved1 == null ? void 0 : resolved1.value;\n }\n case \"deferred\":\n return undefined;\n }\n}\nfunction evaluateBoundedIdentifierComparison(condition, left, right) {\n if (!isComparisonOperator(condition.op)) return undefined;\n if (condition.l.t === \"id\" && left === undefined && right !== undefined) {\n return evaluateUnknownSignedComparison(condition.op, right);\n }\n if (condition.r.t === \"id\" && right === undefined && left !== undefined) {\n return evaluateUnknownSignedComparison(reverseComparison(condition.op), left);\n }\n return undefined;\n}\nfunction evaluateUnknownSignedComparison(operator, value) {\n if (!isComparisonOperator(operator) || operator === \"==\" || operator === \"!=\") return undefined;\n var atMinimum = evaluateBinaryExpression(-0x80000000, operator, value);\n var atMaximum = evaluateBinaryExpression(0x7fffffff, operator, value);\n return typeof atMinimum === \"number\" && atMinimum === atMaximum ? atMinimum : undefined;\n}\nfunction isComparisonOperator(operator) {\n return operator === \"==\" || operator === \"!=\" || operator === \"<\" || operator === \"<=\" || operator === \">\" || operator === \">=\";\n}\nfunction reverseComparison(operator) {\n switch(operator){\n case \"<\":\n return \">\";\n case \"<=\":\n return \">=\";\n case \">\":\n return \"<\";\n case \">=\":\n return \"<=\";\n default:\n return operator;\n }\n}\nfunction isWhitespace(charCode) {\n return charCode === 32 || charCode >= 9 && charCode <= 13;\n}\nfunction isIdentifierStart(charCode) {\n return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode === 95;\n}\nfunction isIdentifierPart(charCode) {\n return isIdentifierStart(charCode) || charCode >= 48 && charCode <= 57;\n}\nfunction isHexDigit(charCode) {\n return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;\n}\nfunction isIntegerSuffix(charCode) {\n return charCode === 85 || charCode === 117;\n}\nfunction isValidIntegerSuffix(suffix) {\n return suffix === \"\" || suffix === \"u\" || suffix === \"U\";\n}\nfunction isDoubleOperator(charCode, nextCharCode) {\n return charCode === 124 && nextCharCode === 124 || charCode === 38 && nextCharCode === 38 || (charCode === 33 || charCode === 61) && nextCharCode === 61 || (charCode === 60 || charCode === 62) && (nextCharCode === 61 || nextCharCode === charCode);\n}\nfunction isSingleOperator(charCode) {\n return charCode === 33 || charCode === 37 || charCode === 38 || charCode === 40 || charCode === 41 || charCode === 42 || charCode === 43 || charCode === 45 || charCode === 47 || charCode === 58 || charCode === 60 || charCode === 62 || charCode === 63 || charCode === 94 || charCode === 124 || charCode === 126;\n}\n\nvar SHADER_ROOT_URL = \"shaders://root/\";\nvar ABSOLUTE_URL_PATTERN = /^[A-Za-z][A-Za-z\\d+.-]*:/;\n/**\n * Converts a registered shader-include key to its canonical lookup form.\n * @param includeKey - Logical project path, project-root path, or absolute URL.\n * @returns Canonical registry key without the virtual shader-root prefix.\n * @throws Error when the key is empty or an absolute URL is malformed.\n */ function normalizeShaderIncludeKey(includeKey) {\n var normalized = includeKey.trim().replace(/\\\\/g, \"/\");\n if (!normalized) throw new Error(\"Shader include key cannot be empty.\");\n if (normalized.startsWith(SHADER_ROOT_URL)) {\n var key = new URL(normalized).href.slice(SHADER_ROOT_URL.length);\n if (!key) throw new Error(\"Shader include key cannot be the virtual shader root.\");\n return key;\n }\n if (ABSOLUTE_URL_PATTERN.test(normalized)) {\n return new URL(normalized).href;\n }\n return new URL(normalized.replace(/^\\/+/, \"\"), SHADER_ROOT_URL).href.slice(SHADER_ROOT_URL.length);\n}\n\nexport { evaluateContextFreePreprocessorCondition, evaluateContextFreePreprocessorExpression, evaluatePartiallyKnownPreprocessorCondition, evaluatePartiallyKnownPreprocessorConditionResult, evaluatePreprocessorExpression, expandPreprocessorExpressionMacros, expandShaderMacros, normalizeShaderIncludeKey, parsePreprocessorExpression, resolvePreprocessorDefinedOperators };\n//# sourceMappingURL=module.js.map\n","import{parsePreprocessorExpression,evaluateContextFreePreprocessorCondition,normalizeShaderIncludeKey,resolvePreprocessorDefinedOperators,expandPreprocessorExpressionMacros,evaluatePartiallyKnownPreprocessorConditionResult}from\"@galacean/engine-design\";import{Logger,RenderStateElementKey,RenderQueueType,CompareFunction,StencilOperation,BlendOperation,BlendFactor,CullMode,ColorWriteMask}from\"@galacean/engine-core\";import{Color}from\"@galacean/engine-math\";var ShaderRange=function(){function ShaderRange(){}var _proto=ShaderRange.prototype;_proto.set=function set(start,end){this.start=start;this.end=end};return ShaderRange}();var ShaderPosition=function(){function ShaderPosition(){}var _proto=ShaderPosition.prototype;_proto.set=function set(index,line,column){this.index=index;this.line=line;this.column=column};return ShaderPosition}();var ETokenType=function(ETokenType){ETokenType[ETokenType[\"ID\"]=1e3]=\"ID\";ETokenType[ETokenType[\"FLOAT_CONSTANT\"]=1001]=\"FLOAT_CONSTANT\";ETokenType[ETokenType[\"INT_CONSTANT\"]=1002]=\"INT_CONSTANT\";ETokenType[ETokenType[\"STRING_CONST\"]=1003]=\"STRING_CONST\";ETokenType[ETokenType[\"LEFT_OP\"]=1004]=\"LEFT_OP\";ETokenType[ETokenType[\"RIGHT_OP\"]=1005]=\"RIGHT_OP\";ETokenType[ETokenType[\"INC_OP\"]=1006]=\"INC_OP\";ETokenType[ETokenType[\"DEC_OP\"]=1007]=\"DEC_OP\";ETokenType[ETokenType[\"LE_OP\"]=1008]=\"LE_OP\";ETokenType[ETokenType[\"GE_OP\"]=1009]=\"GE_OP\";ETokenType[ETokenType[\"EQ_OP\"]=1010]=\"EQ_OP\";ETokenType[ETokenType[\"NE_OP\"]=1011]=\"NE_OP\";ETokenType[ETokenType[\"AND_OP\"]=1012]=\"AND_OP\";ETokenType[ETokenType[\"OR_OP\"]=1013]=\"OR_OP\";ETokenType[ETokenType[\"XOR_OP\"]=1014]=\"XOR_OP\";ETokenType[ETokenType[\"MUL_ASSIGN\"]=1015]=\"MUL_ASSIGN\";ETokenType[ETokenType[\"DIV_ASSIGN\"]=1016]=\"DIV_ASSIGN\";ETokenType[ETokenType[\"ADD_ASSIGN\"]=1017]=\"ADD_ASSIGN\";ETokenType[ETokenType[\"SUB_ASSIGN\"]=1018]=\"SUB_ASSIGN\";ETokenType[ETokenType[\"MOD_ASSIGN\"]=1019]=\"MOD_ASSIGN\";ETokenType[ETokenType[\"LEFT_ASSIGN\"]=1020]=\"LEFT_ASSIGN\";ETokenType[ETokenType[\"RIGHT_ASSIGN\"]=1021]=\"RIGHT_ASSIGN\";ETokenType[ETokenType[\"AND_ASSIGN\"]=1022]=\"AND_ASSIGN\";ETokenType[ETokenType[\"XOR_ASSIGN\"]=1023]=\"XOR_ASSIGN\";ETokenType[ETokenType[\"OR_ASSIGN\"]=1024]=\"OR_ASSIGN\";ETokenType[ETokenType[\"LEFT_PAREN\"]=1025]=\"LEFT_PAREN\";ETokenType[ETokenType[\"RIGHT_PAREN\"]=1026]=\"RIGHT_PAREN\";ETokenType[ETokenType[\"LEFT_BRACKET\"]=1027]=\"LEFT_BRACKET\";ETokenType[ETokenType[\"RIGHT_BRACKET\"]=1028]=\"RIGHT_BRACKET\";ETokenType[ETokenType[\"LEFT_BRACE\"]=1029]=\"LEFT_BRACE\";ETokenType[ETokenType[\"RIGHT_BRACE\"]=1030]=\"RIGHT_BRACE\";ETokenType[ETokenType[\"DOT\"]=1031]=\"DOT\";ETokenType[ETokenType[\"COMMA\"]=1032]=\"COMMA\";ETokenType[ETokenType[\"COLON\"]=1033]=\"COLON\";ETokenType[ETokenType[\"EQUAL\"]=1034]=\"EQUAL\";ETokenType[ETokenType[\"SEMICOLON\"]=1035]=\"SEMICOLON\";ETokenType[ETokenType[\"BANG\"]=1036]=\"BANG\";ETokenType[ETokenType[\"DASH\"]=1037]=\"DASH\";ETokenType[ETokenType[\"TILDE\"]=1038]=\"TILDE\";ETokenType[ETokenType[\"PLUS\"]=1039]=\"PLUS\";ETokenType[ETokenType[\"STAR\"]=1040]=\"STAR\";ETokenType[ETokenType[\"SLASH\"]=1041]=\"SLASH\";ETokenType[ETokenType[\"PERCENT\"]=1042]=\"PERCENT\";ETokenType[ETokenType[\"LEFT_ANGLE\"]=1043]=\"LEFT_ANGLE\";ETokenType[ETokenType[\"RIGHT_ANGLE\"]=1044]=\"RIGHT_ANGLE\";ETokenType[ETokenType[\"VERTICAL_BAR\"]=1045]=\"VERTICAL_BAR\";ETokenType[ETokenType[\"CARET\"]=1046]=\"CARET\";ETokenType[ETokenType[\"AMPERSAND\"]=1047]=\"AMPERSAND\";ETokenType[ETokenType[\"QUESTION\"]=1048]=\"QUESTION\";ETokenType[ETokenType[\"NotWord\"]=1049]=\"NotWord\";ETokenType[ETokenType[\"EPSILON\"]=1998]=\"EPSILON\";ETokenType[ETokenType[\"EOF\"]=1999]=\"EOF\";return ETokenType}({});var TypeAny=3e3;var Keyword=function(Keyword){Keyword[Keyword[\"CONST\"]=0]=\"CONST\";Keyword[Keyword[\"BOOL\"]=1]=\"BOOL\";Keyword[Keyword[\"FLOAT\"]=2]=\"FLOAT\";Keyword[Keyword[\"DOUBLE\"]=3]=\"DOUBLE\";Keyword[Keyword[\"INT\"]=4]=\"INT\";Keyword[Keyword[\"UINT\"]=5]=\"UINT\";Keyword[Keyword[\"BREAK\"]=6]=\"BREAK\";Keyword[Keyword[\"CONTINUE\"]=7]=\"CONTINUE\";Keyword[Keyword[\"DO\"]=8]=\"DO\";Keyword[Keyword[\"ELSE\"]=9]=\"ELSE\";Keyword[Keyword[\"FOR\"]=10]=\"FOR\";Keyword[Keyword[\"IF\"]=11]=\"IF\";Keyword[Keyword[\"WHILE\"]=12]=\"WHILE\";Keyword[Keyword[\"DISCARD\"]=13]=\"DISCARD\";Keyword[Keyword[\"RETURN\"]=14]=\"RETURN\";Keyword[Keyword[\"BVEC2\"]=15]=\"BVEC2\";Keyword[Keyword[\"BVEC3\"]=16]=\"BVEC3\";Keyword[Keyword[\"BVEC4\"]=17]=\"BVEC4\";Keyword[Keyword[\"IVEC2\"]=18]=\"IVEC2\";Keyword[Keyword[\"IVEC3\"]=19]=\"IVEC3\";Keyword[Keyword[\"IVEC4\"]=20]=\"IVEC4\";Keyword[Keyword[\"UVEC2\"]=21]=\"UVEC2\";Keyword[Keyword[\"UVEC3\"]=22]=\"UVEC3\";Keyword[Keyword[\"UVEC4\"]=23]=\"UVEC4\";Keyword[Keyword[\"VEC2\"]=24]=\"VEC2\";Keyword[Keyword[\"VEC3\"]=25]=\"VEC3\";Keyword[Keyword[\"VEC4\"]=26]=\"VEC4\";Keyword[Keyword[\"VEC4_ARRAY\"]=27]=\"VEC4_ARRAY\";Keyword[Keyword[\"MAT2\"]=28]=\"MAT2\";Keyword[Keyword[\"MAT3\"]=29]=\"MAT3\";Keyword[Keyword[\"MAT4\"]=30]=\"MAT4\";Keyword[Keyword[\"MAT2X3\"]=31]=\"MAT2X3\";Keyword[Keyword[\"MAT2X4\"]=32]=\"MAT2X4\";Keyword[Keyword[\"MAT3X2\"]=33]=\"MAT3X2\";Keyword[Keyword[\"MAT3X4\"]=34]=\"MAT3X4\";Keyword[Keyword[\"MAT4X2\"]=35]=\"MAT4X2\";Keyword[Keyword[\"MAT4X3\"]=36]=\"MAT4X3\";Keyword[Keyword[\"IN\"]=37]=\"IN\";Keyword[Keyword[\"OUT\"]=38]=\"OUT\";Keyword[Keyword[\"INOUT\"]=39]=\"INOUT\";Keyword[Keyword[\"CENTROID\"]=40]=\"CENTROID\";Keyword[Keyword[\"SAMPLER2D\"]=41]=\"SAMPLER2D\";Keyword[Keyword[\"SAMPLER3D\"]=42]=\"SAMPLER3D\";Keyword[Keyword[\"SAMPLER_CUBE\"]=43]=\"SAMPLER_CUBE\";Keyword[Keyword[\"SAMPLER2D_SHADOW\"]=44]=\"SAMPLER2D_SHADOW\";Keyword[Keyword[\"SAMPLER_CUBE_SHADOW\"]=45]=\"SAMPLER_CUBE_SHADOW\";Keyword[Keyword[\"SAMPLER2D_ARRAY\"]=46]=\"SAMPLER2D_ARRAY\";Keyword[Keyword[\"SAMPLER2D_ARRAY_SHADOW\"]=47]=\"SAMPLER2D_ARRAY_SHADOW\";Keyword[Keyword[\"I_SAMPLER2D\"]=48]=\"I_SAMPLER2D\";Keyword[Keyword[\"I_SAMPLER3D\"]=49]=\"I_SAMPLER3D\";Keyword[Keyword[\"I_SAMPLER_CUBE\"]=50]=\"I_SAMPLER_CUBE\";Keyword[Keyword[\"I_SAMPLER2D_ARRAY\"]=51]=\"I_SAMPLER2D_ARRAY\";Keyword[Keyword[\"U_SAMPLER2D\"]=52]=\"U_SAMPLER2D\";Keyword[Keyword[\"U_SAMPLER3D\"]=53]=\"U_SAMPLER3D\";Keyword[Keyword[\"U_SAMPLER_CUBE\"]=54]=\"U_SAMPLER_CUBE\";Keyword[Keyword[\"U_SAMPLER2D_ARRAY\"]=55]=\"U_SAMPLER2D_ARRAY\";Keyword[Keyword[\"STRUCT\"]=56]=\"STRUCT\";Keyword[Keyword[\"LAYOUT\"]=57]=\"LAYOUT\";Keyword[Keyword[\"LOCATION\"]=58]=\"LOCATION\";Keyword[Keyword[\"VOID\"]=59]=\"VOID\";Keyword[Keyword[\"PRECISION\"]=60]=\"PRECISION\";Keyword[Keyword[\"PRECISE\"]=61]=\"PRECISE\";Keyword[Keyword[\"HIGHP\"]=62]=\"HIGHP\";Keyword[Keyword[\"MEDIUMP\"]=63]=\"MEDIUMP\";Keyword[Keyword[\"LOWP\"]=64]=\"LOWP\";Keyword[Keyword[\"INVARIANT\"]=65]=\"INVARIANT\";Keyword[Keyword[\"SMOOTH\"]=66]=\"SMOOTH\";Keyword[Keyword[\"FLAT\"]=67]=\"FLAT\";Keyword[Keyword[\"NOPERSPECTIVE\"]=68]=\"NOPERSPECTIVE\";Keyword[Keyword[\"True\"]=69]=\"True\";Keyword[Keyword[\"False\"]=70]=\"False\";Keyword[Keyword[\"LeftBrace\"]=71]=\"LeftBrace\";Keyword[Keyword[\"RightBrace\"]=72]=\"RightBrace\";Keyword[Keyword[\"Equal\"]=73]=\"Equal\";Keyword[Keyword[\"BitwiseOr\"]=74]=\"BitwiseOr\";Keyword[Keyword[\"GSRenderQueueType\"]=75]=\"GSRenderQueueType\";Keyword[Keyword[\"GSBlendState\"]=76]=\"GSBlendState\";Keyword[Keyword[\"GSDepthState\"]=77]=\"GSDepthState\";Keyword[Keyword[\"GSStencilState\"]=78]=\"GSStencilState\";Keyword[Keyword[\"GSRasterState\"]=79]=\"GSRasterState\";Keyword[Keyword[\"GSEditorProperties\"]=80]=\"GSEditorProperties\";Keyword[Keyword[\"GSEditorMacros\"]=81]=\"GSEditorMacros\";Keyword[Keyword[\"GSEditor\"]=82]=\"GSEditor\";Keyword[Keyword[\"GSTags\"]=83]=\"GSTags\";Keyword[Keyword[\"GSVertexShader\"]=84]=\"GSVertexShader\";Keyword[Keyword[\"GSFragmentShader\"]=85]=\"GSFragmentShader\";Keyword[Keyword[\"GSSubShader\"]=86]=\"GSSubShader\";Keyword[Keyword[\"GSPass\"]=87]=\"GSPass\";Keyword[Keyword[\"GSBlendFactor\"]=88]=\"GSBlendFactor\";Keyword[Keyword[\"GSBlendOperation\"]=89]=\"GSBlendOperation\";Keyword[Keyword[\"GSBool\"]=90]=\"GSBool\";Keyword[Keyword[\"GSNumber\"]=91]=\"GSNumber\";Keyword[Keyword[\"GSColor\"]=92]=\"GSColor\";Keyword[Keyword[\"GSCompareFunction\"]=93]=\"GSCompareFunction\";Keyword[Keyword[\"GSStencilOperation\"]=94]=\"GSStencilOperation\";Keyword[Keyword[\"GSCullMode\"]=95]=\"GSCullMode\";Keyword[Keyword[\"GSColorWriteMask\"]=96]=\"GSColorWriteMask\";Keyword[Keyword[\"GSUsePass\"]=97]=\"GSUsePass\";Keyword[Keyword[\"MACRO_IF\"]=98]=\"MACRO_IF\";Keyword[Keyword[\"MACRO_IFDEF\"]=99]=\"MACRO_IFDEF\";Keyword[Keyword[\"MACRO_IFNDEF\"]=100]=\"MACRO_IFNDEF\";Keyword[Keyword[\"MACRO_ELSE\"]=101]=\"MACRO_ELSE\";Keyword[Keyword[\"MACRO_ELIF\"]=102]=\"MACRO_ELIF\";Keyword[Keyword[\"MACRO_ENDIF\"]=103]=\"MACRO_ENDIF\";Keyword[Keyword[\"MACRO_UNDEF\"]=104]=\"MACRO_UNDEF\";Keyword[Keyword[\"MACRO_DEFINE_EXPRESSION\"]=105]=\"MACRO_DEFINE_EXPRESSION\";Keyword[Keyword[\"MACRO_CONDITIONAL_EXPRESSION\"]=106]=\"MACRO_CONDITIONAL_EXPRESSION\";Keyword[Keyword[\"MACRO_CALL\"]=107]=\"MACRO_CALL\";Keyword[Keyword[\"MACRO_DEFINE\"]=108]=\"MACRO_DEFINE\";Keyword[Keyword[\"MACRO_DEFINE_END\"]=109]=\"MACRO_DEFINE_END\";Keyword[Keyword[\"MACRO_DEFINE_PARAMS\"]=110]=\"MACRO_DEFINE_PARAMS\";return Keyword}({});function _instanceof(left,right){if(right!=null&&typeof Symbol!==\"undefined\"&&right[Symbol.hasInstance]){return!!right[Symbol.hasInstance](left)}else return left instanceof right}function _type_of(obj){\"@swc/helpers - typeof\";return obj&&typeof Symbol!==\"undefined\"&&obj.constructor===Symbol?\"symbol\":typeof obj}function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o===\"string\")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n===\"Object\"&&o.constructor)n=o.constructor.name;if(n===\"Map\"||n===\"Set\")return Array.from(n);if(n===\"Arguments\"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _create_for_of_iterator_helper_loose(o,allowArrayLike){var it=typeof Symbol!==\"undefined\"&&o[Symbol.iterator]||o[\"@@iterator\"];if(it)return(it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupported_iterable_to_array(o))||allowArrayLike&&o&&typeof o.length===\"number\"){if(it)o=it;var i=0;return function(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}function sameBranch(a,b){if(a.length!==b.length)return false;for(var i=0,n=a.length;i<n;i++){var left=a[i];var right=b[i];if(left.name!==right.name||left.defined!==right.defined)return false;if(!sameCondition(left.condition,right.condition))return false;var leftPreceding=left.precedingConditions;var rightPreceding=right.precedingConditions;var _leftPreceding_length,_rightPreceding_length;if(((_leftPreceding_length=leftPreceding==null?void 0:leftPreceding.length)!=null?_leftPreceding_length:0)!==((_rightPreceding_length=rightPreceding==null?void 0:rightPreceding.length)!=null?_rightPreceding_length:0))return false;var _leftPreceding_length1;for(var j=0,m=(_leftPreceding_length1=leftPreceding==null?void 0:leftPreceding.length)!=null?_leftPreceding_length1:0;j<m;j++){if(!sameCondition(leftPreceding[j],rightPreceding[j]))return false}}return true}function isLexicalBranchVisibleFrom(declaration,reference){for(var i=0;i<declaration.length;i++){var _declarationConstraint_sourceArm;var declarationConstraint=declaration[i];if(((_declarationConstraint_sourceArm=declarationConstraint.sourceArm)==null?void 0:_declarationConstraint_sourceArm.value)===true)continue;var group=declarationConstraint.conditionalGroup;if(group===undefined)return false;var matched=false;for(var j=0;j<reference.length;j++){var referenceConstraint=reference[j];if(referenceConstraint.conditionalGroup!==group)continue;if(referenceConstraint.conditionalArm!==declarationConstraint.conditionalArm)return false;matched=true;break}if(!matched)return false}return true}function getLexicalBranchCoverage(candidates,reference){return coverLexicalArms(candidates,reference,{remaining:256})?\"covered\":\"unknown\"}function coverLexicalArms(candidates,reference,budget){var _loop=function(arm){var _completeArm_conditionalReachableArms;if(referenceArm!==undefined&&arm!==referenceArm)return\"continue\";if(((_completeArm_conditionalReachableArms=completeArm.conditionalReachableArms)==null?void 0:_completeArm_conditionalReachableArms[arm])===false)return\"continue\";var armCandidates=compatible.filter(function(candidate){return candidate.every(function(constraint){return constraint.conditionalGroup!==group||constraint.conditionalArm===arm})}).map(function(candidate){return candidate.filter(function(constraint){return constraint.conditionalGroup!==group})});if(!coverLexicalArms(armCandidates,remainingReference,budget))return{v:false}};var _reference_find;if(candidates.some(function(candidate){return isLexicalBranchVisibleFrom(candidate,reference)}))return true;if(--budget.remaining<0)return false;var compatible=candidates.filter(function(candidate){return getLexicalDeclarationCoexistence(candidate,reference)!==\"exclusive\"});var completeArm;for(var _iterator=_create_for_of_iterator_helper_loose(compatible),_step;!(_step=_iterator()).done;){var candidate=_step.value;completeArm=candidate.find(function(arm){return arm.conditionalComplete&&arm.conditionalGroup!==undefined&&arm.conditionalArmCount});if(completeArm)break}if(!completeArm)return false;var group=completeArm.conditionalGroup;var referenceArm=(_reference_find=reference.find(function(arm){return arm.conditionalGroup===group}))==null?void 0:_reference_find.conditionalArm;var remainingReference=reference.filter(function(arm){return arm.conditionalGroup!==group});for(var arm=0;arm<completeArm.conditionalArmCount;arm++){var _ret=_loop(arm);if(_type_of(_ret)===\"object\")return _ret.v}return true}function getLexicalDeclarationCoexistence(earlier,later){for(var _iterator=_create_for_of_iterator_helper_loose(earlier),_step;!(_step=_iterator()).done;){var left=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(later),_step1;!(_step1=_iterator1()).done;){var right=_step1.value;if(left.conditionalGroup!==undefined&&left.conditionalGroup===right.conditionalGroup&&left.conditionalArm!==right.conditionalArm){return\"exclusive\"}}}for(var _iterator2=_create_for_of_iterator_helper_loose(earlier),_step2;!(_step2=_iterator2()).done;){var constraint=_step2.value;if(constraint.condition!==undefined)return\"unknown\"}for(var _iterator3=_create_for_of_iterator_helper_loose(later),_step3;!(_step3=_iterator3()).done;){var constraint1=_step3.value;if(constraint1.condition!==undefined)return\"unknown\"}return\"coexist\"}function sameCondition(left,right){if(!left||!right)return left===right;if(left.kind!==right.kind)return false;if(left.kind===\"constant\")return right.kind===\"constant\"&&left.value===right.value;if(right.kind===\"constant\")return false;if(left.kind===\"expression\")return right.kind===\"expression\"&&sameExpression(left,right)&&left.negated===right.negated;if(right.kind===\"expression\")return false;if(left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"&&right.kind===\"defined\")return left.defined===right.defined;return left.kind===\"comparison\"&&right.kind===\"comparison\"&&left.operator===right.operator&&left.value===right.value}function sameExpression(left,right){if(left.expression!==right.expression||left.opaque!==right.opaque||left.names.length!==right.names.length){return false}for(var i=0,n=left.names.length;i<n;i++){if(left.names[i]!==right.names[i]||left.versions[i]!==right.versions[i])return false}return true}var EMPTY_BRANCH=Object.freeze([]);var BaseToken=function(){function BaseToken(_objectPool){this._objectPool=_objectPool;this.branch=EMPTY_BRANCH;this.inMacroDefinition=false}var _proto=BaseToken.prototype;_proto.set=function set(type,lexeme,arg){this.type=type;this.lexeme=lexeme;this.branch=EMPTY_BRANCH;this.inMacroDefinition=false;if(_instanceof(arg,ShaderRange)){this.location=arg}else{var end=this._objectPool?this._objectPool.createPosition(arg.index+lexeme.length,arg.line,arg.column+lexeme.length):createPosition(arg.index+lexeme.length,arg.line,arg.column+lexeme.length);this.location=this._objectPool?this._objectPool.createRange(arg,end):createRange(arg,end)}};return BaseToken}();function createPosition(index,line,column){var position=new ShaderPosition;position.set(index,line,column);return position}function createRange(start,end){var range=new ShaderRange;range.set(start,end);return range}var EOF=new BaseToken;var EOF_POSITION=createPosition(0,0,0);EOF.set(ETokenType.EOF,\"/EOF\",createRange(EOF_POSITION,EOF_POSITION));function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if(\"value\"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _inherits(subClass,superClass){if(typeof superClass!==\"function\"&&superClass!==null){throw new TypeError(\"Super expression must either be null or a function\")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}function _construct(Parent,args,Class){if(_is_native_reflect_construct())_construct=Reflect.construct;else{_construct=function construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor;if(Class)_set_prototype_of(instance,Class.prototype);return instance}}return _construct.apply(null,arguments)}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _is_native_function(fn){return Function.toString.call(fn).indexOf(\"[native code]\")!==-1}function _wrap_native_super(Class){var _cache=typeof Map===\"function\"?new Map:undefined;_wrap_native_super=function(Class){if(Class===null||!_is_native_function(Class))return Class;if(typeof Class!==\"function\")throw new TypeError(\"Super expression must either be null or a function\");if(typeof _cache!==\"undefined\"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper)}function Wrapper(){return _construct(Class,arguments,_get_prototype_of(this).constructor)}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _set_prototype_of(Wrapper,Class)};return _wrap_native_super(Class)}function formatDiagnosticSource(source,range,header,contextLines){if(contextLines===void 0)contextLines=5;if(!source)return header;var lines=source.split(\"\\n\");var start=range.start,end=range.end;var from=Math.max(0,start.line-contextLines);var to=Math.min(lines.length-1,end.line+contextLines);var gutterWidth=String(to+1).length;var gutterPad=\" \".repeat(gutterWidth);var out=header+\"\\n\";for(var i=from;i<=to;i++){out+=String(i+1).padStart(gutterWidth)+\" | \"+lines[i]+\"\\n\";if(start.line<=i&&i<=end.line){var cs=i===start.line?start.column:0;var ce=i===end.line?end.column:lines[i].length;out+=gutterPad+\" | \"+\" \".repeat(cs)+\"^\".repeat(Math.max(ce-cs,1))+\"\\n\"}}return out}var GSError=function(Error1){_inherits(GSError,Error1);function GSError(name,message,location,source,file,code){var _this;_this=Error1.call(this,message)||this,_this.location=location,_this.source=source,_this.file=file,_this.code=code;_this.name=name;return _this}var _proto=GSError.prototype;_proto.toString=function toString(){var location=this.location;var range=\"start\"in location?location:{start:location,end:location};return formatDiagnosticSource(this.source||undefined,range,this.name+\": \"+this.message)};return GSError}(_wrap_native_super(Error));var GSErrorName=function(GSErrorName){GSErrorName[\"PreprocessorError\"]=\"PreprocessorError\";GSErrorName[\"CompilationError\"]=\"CompilationError\";GSErrorName[\"ScannerError\"]=\"ScannerError\";GSErrorName[\"CompilationWarn\"]=\"CompilationWarning\";return GSErrorName}({});var ShaderCompilerUtils=function(){function ShaderCompilerUtils(){}ShaderCompilerUtils.createPosition=function createPosition(index,line,column){if(line===void 0)line=0;if(column===void 0)column=0;var position=new ShaderPosition;position.set(index,line,column);return position};ShaderCompilerUtils.createRange=function createRange(start,end){var range=new ShaderRange;range.set(start,end);return range};ShaderCompilerUtils.createGSError=function createGSError(message,errorName,source,location,code,file){return new GSError(errorName,message,location,source,file,code)};return ShaderCompilerUtils}();var BaseLexer=function(){function BaseLexer(source,_objectPool){this._objectPool=_objectPool;this._currentIndex=0;this._column=0;this._line=0;this.setSource(source!=null?source:\"\")}var _proto=BaseLexer.prototype;_proto.setSource=function setSource(source){this._source=source;this._currentIndex=0;this._line=this._column=0};_proto.getShaderPosition=function getShaderPosition(backOffset){if(backOffset===void 0)backOffset=0;var index=this._currentIndex-backOffset;return this._createPosition(index,this._line,this._column-backOffset)};_proto._createPosition=function _createPosition(index,line,column){return this._objectPool?this._objectPool.createPosition(index,line,column):ShaderCompilerUtils.createPosition(index,line,column)};_proto._createToken=function _createToken(){return this._objectPool?this._objectPool.createToken():new BaseToken};_proto._createEOFToken=function _createEOFToken(){var position=this.getShaderPosition();var token=this._createToken();token.set(ETokenType.EOF,\"/EOF\",this._createRange(position,position));return token};_proto._createRange=function _createRange(start,end){return this._objectPool?this._objectPool.createRange(start,end):ShaderCompilerUtils.createRange(start,end)};_proto.isEnd=function isEnd(){return this._currentIndex>=this._source.length};_proto.getCurChar=function getCurChar(){return this._source[this._currentIndex]};_proto.getCurCharCode=function getCurCharCode(){return this._source.charCodeAt(this._currentIndex)};_proto.advance=function advance(count){var source=this._source;var startIndex=this._currentIndex;for(var i=0;i<count;i++){if(source.charCodeAt(startIndex+i)===10){this._line+=1;this._column=0}else{this._column+=1}}this._currentIndex+=count};_proto.skipSpace=function skipSpace(includeLineBreak){while(BaseLexer.isWhiteSpaceChar(this.getCurCharCode(),includeLineBreak)){this.advance(1)}};_proto.skipCommentsAndSpace=function skipCommentsAndSpace(){var source=this._source;var length=source.length;var index=this._currentIndex;while(index<length){while(index<length&&BaseLexer.isWhiteSpaceChar(source.charCodeAt(index),true)){index++}var afterBlock=BaseLexer._skipBlockComment(source,index,length);if(afterBlock!==index){index=afterBlock;continue}var afterLine=BaseLexer._skipLineComment(source,index,length);if(afterLine!==index){index=afterLine;continue}break}this.advance(index-this._currentIndex)};_proto.peek=function peek(to){var offset=this._currentIndex;return this._source.substring(offset,offset+to)};_proto.scanLexeme=function scanLexeme(lexeme){this.skipCommentsAndSpace();var length=lexeme.length;var peek=this.peek(length);if(peek!==lexeme){this.throwError(this.getShaderPosition(0),'Expect lexeme \"'+lexeme+'\", but got \"'+peek+'\"')}this.advance(length)};_proto.scanTwoExpectedLexemes=function scanTwoExpectedLexemes(lexeme1,lexeme2){this.skipCommentsAndSpace();if(this.peek(lexeme1.length)===lexeme1){this.advance(lexeme1.length);return lexeme1}if(this.peek(lexeme2.length)===lexeme2){this.advance(lexeme2.length);return lexeme2}return null};_proto.throwError=function throwError(pos){for(var _len=arguments.length,msgs=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){msgs[_key-1]=arguments[_key]}var error=ShaderCompilerUtils.createGSError(msgs.join(\" \"),GSErrorName.ScannerError,this._source,pos);throw error};_proto.scanPairedChar=function scanPairedChar(left,right,balanced,skipLeading){if(!skipLeading){this.scanLexeme(left)}var start=this._currentIndex;var source=this._source;var sourceLength=source.length;var currentIndex=this._currentIndex;if(balanced){var level=1;while(currentIndex<sourceLength){var currentChar=source[currentIndex];if(currentChar===right&&--level===0){break}else if(currentChar===left){level++}currentIndex++}}else{while(currentIndex<sourceLength){if(source[currentIndex]===right){break}currentIndex++}}if(currentIndex===sourceLength){this.throwError(this.getShaderPosition(),'Expect closing character \"'+right+'\" before end of source.')}this.advance(currentIndex+1-this._currentIndex);return source.substring(start,currentIndex)};BaseLexer.isDigit=function isDigit(charCode){return charCode>=48&&charCode<=57};BaseLexer.isHexDigit=function isHexDigit(charCode){return charCode>=48&&charCode<=57||charCode>=65&&charCode<=70||charCode>=97&&charCode<=102};BaseLexer.isAlpha=function isAlpha(charCode){return charCode===95||charCode>=65&&charCode<=90||charCode>=97&&charCode<=122};BaseLexer.isAlnum=function isAlnum(charCode){return BaseLexer.isAlpha(charCode)||BaseLexer.isDigit(charCode)};BaseLexer.isPreprocessorStartChar=function isPreprocessorStartChar(charCode){return charCode===35};BaseLexer._skipBlockComment=function _skipBlockComment(src,i,len){if(src.charCodeAt(i)!==47||i+1>=len||src.charCodeAt(i+1)!==42)return i;var j=i+2;while(j+1<len){if(src.charCodeAt(j)===42&&src.charCodeAt(j+1)===47)return j+2;j++}return len};BaseLexer._skipLineComment=function _skipLineComment(src,i,len){if(src.charCodeAt(i)!==47||i+1>=len||src.charCodeAt(i+1)!==47)return i;var j=i+2;while(j<len){var c=src.charCodeAt(j);if(c===10||c===13)break;j++}return j};BaseLexer.isWhiteSpaceChar=function isWhiteSpaceChar(charCode,includeBreak){if(charCode===32||charCode===9){return true}return includeBreak&&(charCode===10||charCode===13)};_create_class(BaseLexer,[{key:\"currentIndex\",get:function get(){return this._currentIndex}},{key:\"source\",get:function get(){return this._source}},{key:\"line\",get:function get(){return this._line}},{key:\"column\",get:function get(){return this._column}}]);return BaseLexer}();function parsePreprocessorCondition(expression){var condition=tryParsePreprocessorCondition(expression);if(!condition)throw new Error(\"Unsupported or malformed preprocessor condition '\"+expression+\"'.\");return condition}function tryParsePreprocessorCondition(expression,parsedExpression){if(parsedExpression===void 0)parsedExpression=parsePreprocessorExpression(expression);var result=parsedExpression;if(!result.ok||result.evaluationError)return undefined;var constantValue=evaluateContextFreePreprocessorCondition(result.condition);if(constantValue!==undefined){return result.hasExpandableIdentifier?undefined:{t:\"bool\",v:constantValue!==0}}return toPreprocessorCondition(result.condition)}function toPreprocessorCondition(condition){switch(condition.t){case\"def\":return condition;case\"and\":{var left=toPreprocessorCondition(condition.l);var right=toPreprocessorCondition(condition.r);return left&&right?{t:\"and\",l:left,r:right}:undefined}case\"or\":{var left1=toPreprocessorCondition(condition.l);var right1=toPreprocessorCondition(condition.r);return left1&&right1?{t:\"or\",l:left1,r:right1}:undefined}case\"not\":{var child=toPreprocessorCondition(condition.c);return child?{t:\"not\",c:child}:undefined}case\"id\":return{t:\"cmp\",m:condition.m,op:\"!=\",v:0};case\"binary\":return toComparisonCondition(condition);case\"num\":return{t:\"bool\",v:condition.v!==0};case\"bool\":case\"cmp\":return condition;case\"ndef\":return{t:\"not\",c:{t:\"def\",m:condition.m}};case\"unary\":return undefined;case\"deferred\":return undefined}}function toComparisonCondition(condition){if(!isComparisonOperator(condition.op))return undefined;var right=evaluateContextFreePreprocessorCondition(condition.r);if(condition.l.t===\"id\"&&right!==undefined){return{t:\"cmp\",m:condition.l.m,op:condition.op,v:right}}var left=evaluateContextFreePreprocessorCondition(condition.l);if(condition.r.t===\"id\"&&left!==undefined){return{t:\"cmp\",m:condition.r.m,op:reverseComparison(condition.op),v:left}}return evaluateStaticCondition(condition)}function isComparisonOperator(operator){return operator===\"==\"||operator===\"!=\"||operator===\">\"||operator===\">=\"||operator===\"<\"||operator===\"<=\"}function reverseComparison(operator){switch(operator){case\"<\":return\">\";case\"<=\":return\">=\";case\">\":return\"<\";case\">=\":return\"<=\";default:return operator}}function evaluateStaticCondition(condition){var value=evaluateContextFreePreprocessorCondition(condition);return value===undefined?undefined:{t:\"bool\",v:value!==0}}function _extends(){_extends=Object.assign||function assign(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key]}return target};return _extends.apply(this,arguments)}var INT_MIN=-0x80000000;var INT_MAX=0x7fffffff;var INTEGER_RANGE=[INT_MIN,INT_MAX];var BOOLEAN_RANGE=[0,1];function normalizePreprocessorCondition(condition){return normalize(condition,new WeakMap)}function getPreprocessorConditionRange(condition,cache){if(cache===void 0)cache=new WeakMap;return getRange(condition,cache)}function getRange(condition,cache){if(cache.has(condition))return cache.get(condition);var result=computeRange(condition,cache);cache.set(condition,result);return result}function computeRange(condition,cache){switch(condition.t){case\"num\":return[condition.v,condition.v];case\"bool\":return[Number(condition.v),Number(condition.v)];case\"def\":case\"ndef\":return BOOLEAN_RANGE;case\"not\":{var child=getRange(condition.c,cache);return child&&(excludesZero(child)?[0,0]:child[0]===child[1]?[1,1]:BOOLEAN_RANGE)}case\"and\":case\"or\":{var left=getRange(condition.l,cache);if(!left)return;var conjunction=condition.t===\"and\";if(conjunction&&left[0]===0&&left[1]===0)return[0,0];if(!conjunction&&excludesZero(left))return[1,1];var right=getRange(condition.r,cache);if(!right)return;if(conjunction&&right[0]===0&&right[1]===0)return[0,0];if(!conjunction&&excludesZero(right))return[1,1];if(excludesZero(left)&&excludesZero(right))return[1,1];if(left[0]===0&&left[1]===0&&right[0]===0&&right[1]===0)return[0,0];return BOOLEAN_RANGE}case\"unary\":{var child1=getRange(condition.c,cache);if(!child1)return;if(child1[0]===child1[1])return constantRange(_extends({},condition,{c:numeric(child1[0])}));if(condition.op===\"+\")return child1;if(condition.op===\"~\")return[~child1[1],~child1[0]];return child1[0]===INT_MIN?INTEGER_RANGE:[-child1[1],-child1[0]]}case\"binary\":{var left1=getRange(condition.l,cache);var right1=getRange(condition.r,cache);if(!left1||!right1)return;if(left1[0]===left1[1]&&right1[0]===right1[1]){return constantRange(_extends({},condition,{l:numeric(left1[0]),r:numeric(right1[0])}))}if(isComparison(condition.op))return BOOLEAN_RANGE;switch(condition.op){case\"+\":return boundedRange(left1[0]+right1[0],left1[1]+right1[1]);case\"-\":return boundedRange(left1[0]-right1[1],left1[1]-right1[0]);case\"*\":{var _Math,_Math1;var products=[left1[0]*right1[0],left1[0]*right1[1],left1[1]*right1[0],left1[1]*right1[1]];return boundedRange((_Math=Math).min.apply(_Math,[].concat(products)),(_Math1=Math).max.apply(_Math1,[].concat(products)))}case\"/\":case\"%\":return excludesZero(right1)?INTEGER_RANGE:undefined;case\"<<\":case\">>\":return right1[0]>=0&&right1[1]<=31?INTEGER_RANGE:undefined;default:return left1[0]>=0&&left1[1]<=1&&right1[0]>=0&&right1[1]<=1?BOOLEAN_RANGE:INTEGER_RANGE}}default:return}}function normalize(condition,cache){var range=getRange(condition,cache);if(!range)return condition;if(excludesZero(range))return boolean(true);if(range[0]===0&&range[1]===0)return boolean(false);switch(condition.t){case\"not\":return negate(normalize(condition.c,cache));case\"and\":case\"or\":return combine(condition.t,normalize(condition.l,cache),normalize(condition.r,cache));case\"binary\":if(isComparison(condition.op)){var left=getRange(condition.l,cache);var right=getRange(condition.r,cache);if(right[0]===right[1])return compare(condition.l,condition.op,right[0],cache);if(left[0]===left[1])return compare(condition.r,reverse(condition.op),left[0],cache)}break}var _arithmeticTruth;return(_arithmeticTruth=arithmeticTruth(condition,cache))!=null?_arithmeticTruth:condition}function arithmeticTruth(condition,cache){if(condition.t===\"def\"||condition.t===\"ndef\")return condition;if(condition.t===\"unary\"&&condition.op!==\"~\")return normalize(condition.c,cache);if(condition.t!==\"binary\")return;var left=getRange(condition.l,cache);var right=getRange(condition.r,cache);if(condition.op===\"+\"&&unwrappedSum(left,right)){if(left[0]>=0&&right[0]>=0||left[1]<=0&&right[1]<=0){return combine(\"or\",normalize(condition.l,cache),normalize(condition.r,cache))}}if(condition.op===\"|\"){return combine(\"or\",normalize(condition.l,cache),normalize(condition.r,cache))}if(condition.op===\"&\"&&left[0]>=0&&left[1]<=1&&right[0]>=0&&right[1]<=1){return combine(\"and\",normalize(condition.l,cache),normalize(condition.r,cache))}}function compare(expression,operator,value,cache){switch(operator){case\"<\":return lessThan(expression,value,cache);case\"<=\":return lessThan(expression,value+1,cache);case\">\":return negate(lessThan(expression,value+1,cache));case\">=\":return negate(lessThan(expression,value,cache));case\"==\":return combine(\"and\",negate(lessThan(expression,value,cache)),lessThan(expression,value+1,cache));case\"!=\":return combine(\"or\",lessThan(expression,value,cache),negate(lessThan(expression,value+1,cache)))}}function lessThan(expression,value,cache){var range=getRange(expression,cache);if(range[1]<value)return boolean(true);if(range[0]>=value)return boolean(false);if(range[0]===0&&value===1||range[1]===0&&value===0){var truth=arithmeticTruth(expression,cache);if(truth)return range[0]===0?negate(truth):truth}if(value===range[0]+1||value===range[1]){var maximum=value===range[1];var endpoint=sumEndpoint(expression,maximum,cache);if(endpoint)return maximum?negate(endpoint):endpoint}return{t:\"binary\",op:\"<\",l:expression,r:numeric(value)}}function sumEndpoint(expression,maximum,cache){if(expression.t!==\"binary\"||expression.op!==\"+\")return;var left=getRange(expression.l,cache);var right=getRange(expression.r,cache);if(!unwrappedSum(left,right))return;var bound=maximum?1:0;return combine(\"and\",compare(expression.l,\"==\",left[bound],cache),compare(expression.r,\"==\",right[bound],cache))}function combine(operator,left,right){if(left.t===\"bool\")return left.v===(operator===\"and\")?right:left;if(right.t===\"bool\")return right.v===(operator===\"and\")?left:right;return{t:operator,l:left,r:right}}function negate(condition){switch(condition.t){case\"bool\":return boolean(!condition.v);case\"def\":return{t:\"ndef\",m:condition.m};case\"ndef\":return{t:\"def\",m:condition.m};case\"not\":return condition.c;case\"and\":case\"or\":return combine(condition.t===\"and\"?\"or\":\"and\",negate(condition.l),negate(condition.r));default:return{t:\"not\",c:condition}}}function unwrappedSum(left,right){return left[0]+right[0]>=INT_MIN&&left[1]+right[1]<=INT_MAX}function boundedRange(minimum,maximum){return minimum>=INT_MIN&&maximum<=INT_MAX?[minimum,maximum]:INTEGER_RANGE}function constantRange(condition){var value=evaluateContextFreePreprocessorCondition(condition);return value===undefined?undefined:[value,value]}function excludesZero(range){return range[0]>0||range[1]<0}function numeric(value){return{t:\"num\",v:value}}function boolean(value){return{t:\"bool\",v:value}}function isComparison(operator){return[\"<\",\"<=\",\">\",\">=\",\"==\",\"!=\"].includes(operator)}function reverse(operator){switch(operator){case\"<\":return\">\";case\"<=\":return\">=\";case\">\":return\"<\";case\">=\":return\"<=\";default:return operator}}var MAX_DIAGRAM_WORK=16384;var EXHAUSTED=Symbol(\"condition diagram budget\");function provePreprocessorConditionCoverage(declarations,reference){var diagram=new ConditionDiagram;try{var source=diagram.predicates(reference);var target=diagram.constant(0);for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var declaration=_step.value;target=diagram.apply(\"or\",target,diagram.predicates(declaration))}return diagram.coverage(diagram.apply(\"or\",diagram.apply(\"not\",source),target))}catch(error){if(error!==EXHAUSTED)throw error;return undefined}}var ConditionDiagram=function(){function ConditionDiagram(){this._nodes=[];this._constants=new Map;this._variables=new Map;this._opaqueVariables=new Set;this._branches=new Map;this._operations=new Map;this._expressions=new Map;this._remaining=MAX_DIAGRAM_WORK}var _proto=ConditionDiagram.prototype;_proto.coverage=function coverage(root){var pending=[{id:root,opaque:false}];var visited=[new Set,new Set];var unknown=false;while(pending.length){var _pending_pop=pending.pop(),id=_pending_pop.id,opaque=_pending_pop.opaque;var seen=visited[Number(opaque)];if(seen.has(id))continue;seen.add(id);this._spend();var node=this._nodes[id];if(node.variable!==Infinity){var uncertain=opaque||this._opaqueVariables.has(node.variable);pending.push({id:node.low,opaque:uncertain},{id:node.high,opaque:uncertain})}else if(node.value===0){if(!opaque)return false;unknown=true}else if(node.value===undefined)unknown=true}return unknown?undefined:true};_proto.constant=function constant(value){var id=this._constants.get(value);if(id===undefined){this._spend();id=this._nodes.length;this._nodes.push({variable:Infinity,low:0,high:0,value:value});this._constants.set(value,id)}return id};_proto.predicates=function predicates(predicates){if(typeof predicates===\"boolean\")return this.constant(Number(predicates));var value=this.constant(1);for(var _iterator=_create_for_of_iterator_helper_loose(predicates),_step;!(_step=_iterator()).done;){var _step_value=_step.value,condition=_step_value.condition,negated=_step_value.negated;var expression=condition.kind===\"opaque\"?this._variable(\"opaque:\"+condition.identity,true):this._expression(condition.expression,condition);value=this.apply(\"and\",value,this.apply(negated?\"not\":\"truth\",expression))}return value};_proto.apply=function apply(operator,left,right){if(right===void 0)right=left;var key=operator+\":\"+left+\":\"+right;var cached=this._operations.get(key);if(cached!==undefined)return cached;this._spend();var a=this._nodes[left];var b=this._nodes[right];var result;if(a.variable===Infinity&&a.value===undefined){result=left}else if(a.variable===Infinity&&operator===\"and\"&&a.value===0){result=this.constant(0)}else if(a.variable===Infinity&&operator===\"or\"&&a.value!==0){result=this.constant(1)}else if(a.variable===Infinity&&b.variable===Infinity){result=this._evaluate(operator,a.value,b.value)}else{var variable=Math.min(a.variable,b.variable);result=this._branch(variable,this.apply(operator,a.variable===variable?a.low:left,b.variable===variable?b.low:right),this.apply(operator,a.variable===variable?a.high:left,b.variable===variable?b.high:right))}this._operations.set(key,result);return result};_proto._expression=function _expression(expression,owner){var cache=this._expressions.get(owner);if(!cache)this._expressions.set(owner,cache=new Map);var cached=cache.get(expression);if(cached!==undefined)return cached;var result;switch(expression.t){case\"bool\":result=this.constant(Number(expression.v));break;case\"num\":result=this.constant(expression.v);break;case\"def\":case\"ndef\":result=this._variable(\"defined:\"+expression.m+\":\"+owner.versions[expression.m]);if(expression.t===\"ndef\")result=this.apply(\"not\",result);break;case\"not\":result=this.apply(\"not\",this._expression(expression.c,owner));break;case\"unary\":result=this.apply(expression.op===\"+\"?\"positive\":expression.op===\"-\"?\"negative\":\"complement\",this._expression(expression.c,owner));break;case\"and\":case\"or\":case\"binary\":{var operator=expression.t===\"binary\"?expression.op:expression.t;result=[\"and\",\"or\",\"+\",\"*\",\"&\",\"|\",\"^\"].includes(operator)?this._associativeExpression(expression,owner,operator):this.apply(operator,this._expression(expression.l,owner),this._expression(expression.r,owner));break}default:result=this.constant();break}cache.set(expression,result);return result};_proto._associativeExpression=function _associativeExpression(expression,owner,operator){var pending=[expression];var operands=[];while(pending.length){var node=pending.pop();if(node.t===\"binary\"&&node.op===operator||(node.t===\"and\"||node.t===\"or\")&&node.t===operator){pending.push(node.r,node.l)}else{operands.push(this._expression(node,owner))}}while(operands.length>1){var count=0;for(var index=0;index<operands.length;index+=2){operands[count++]=index+1<operands.length?this.apply(operator,operands[index],operands[index+1]):operands[index]}operands.length=count}return operands[0]};_proto._variable=function _variable(identity,opaque){if(opaque===void 0)opaque=false;var variable=this._variables.get(identity);if(variable===undefined)this._variables.set(identity,variable=this._variables.size);if(opaque)this._opaqueVariables.add(variable);return this._branch(variable,this.constant(0),this.constant(1))};_proto._branch=function _branch(variable,low,high){if(low===high)return low;var key=variable+\":\"+low+\":\"+high;var id=this._branches.get(key);if(id===undefined){this._spend();id=this._nodes.length;this._nodes.push({variable:variable,low:low,high:high});this._branches.set(key,id)}return id};_proto._evaluate=function _evaluate(operator,left,right){if(operator===\"truth\")return this.constant(Number(left!==0));if(operator===\"not\")return this.constant(Number(left===0));var l={t:\"num\",v:left};var expression;if(operator===\"positive\"||operator===\"negative\"||operator===\"complement\"){expression={t:\"unary\",op:operator===\"positive\"?\"+\":operator===\"negative\"?\"-\":\"~\",c:l}}else{if(right===undefined)return this.constant();var r={t:\"num\",v:right};expression=operator===\"and\"||operator===\"or\"?{t:operator,l:l,r:r}:{t:\"binary\",op:operator,l:l,r:r}}var value;try{value=evaluateContextFreePreprocessorCondition(expression)}catch(e){value=undefined}return this.constant(value)};_proto._spend=function _spend(){if(--this._remaining<0)throw EXHAUSTED};return ConditionDiagram}();function capturePreprocessorCondition(expression,versions){var dependencies=Object.create(null);var pending=[expression];while(pending.length){var condition=pending.pop();switch(condition.t){case\"def\":case\"ndef\":var _versions_condition_m;dependencies[condition.m]=(_versions_condition_m=versions[condition.m])!=null?_versions_condition_m:0;break;case\"not\":case\"unary\":pending.push(condition.c);break;case\"and\":case\"or\":case\"binary\":pending.push(condition.l,condition.r);break}}return{kind:\"expression\",expression:expression,versions:dependencies}}function canInheritanceBranchesCover(declarations,reference){return proveInheritanceBranchesCover(declarations,reference)===true}function proveInheritanceBranchesCover(declarations,reference){var facts=getPredicates(reference);var alternatives=declarations.map(getPredicates);if(alternatives.includes(true)||facts===false)return true;if(facts===undefined)return undefined;var required=alternatives.filter(function(predicates){return predicates!==undefined});var normalized=new Map;function normalize(predicates){if(typeof predicates===\"boolean\")return predicates;return predicates.map(function(param){var condition=param.condition,negated=param.negated;var canonical=normalized.get(condition);if(!canonical){canonical=condition.kind===\"opaque\"?condition:_extends({},condition,{expression:normalizePreprocessorCondition(condition.expression)});normalized.set(condition,canonical)}return{condition:canonical,negated:negated}})}required=required.map(normalize);facts=normalize(facts);var rangeCache=new WeakMap;if(required.some(function(alternative){return proveCanonicalCoverage(alternative,facts,rangeCache)}))return true;var proof=provePreprocessorConditionCoverage(required,facts);return proof===false&&alternatives.includes(undefined)?undefined:proof}function getPredicates(branch){var predicates=[];for(var _iterator=_create_for_of_iterator_helper_loose(branch),_step;!(_step=_iterator()).done;){var sourceArm=_step.value.sourceArm;var _predicates;if((sourceArm==null?void 0:sourceArm.value)===true)continue;if((sourceArm==null?void 0:sourceArm.value)===false)return false;if(!(sourceArm==null?void 0:sourceArm.predicates))return;(_predicates=predicates).push.apply(_predicates,[].concat(sourceArm.predicates))}return predicates.length?predicates:true}function proveCanonicalCoverage(required,facts,rangeCache){var known=new Set;var ranges=new Map;var keys=new Map;var identities=new Map;var rangeOf=function(expression){return getPreprocessorConditionRange(expression,rangeCache)};var impossible=facts===false;function intern(signature){var identity=identities.get(signature);if(identity===undefined)identities.set(signature,identity=identities.size+1);return identity}function key(expression,owner){var cache=keys.get(owner);if(!cache)keys.set(owner,cache=new Map);var result=cache.get(expression);if(result===undefined){result=canonicalExpressionKey(expression,owner.kind===\"expression\"?owner.versions:{},function(child){return key(child,owner)},rangeOf,intern);cache.set(expression,result)}return result}function interval(expression,negated,owner){var numeric=expression;var allowed;if(expression.t===\"binary\"&&expression.op===\"<\"&&expression.r.t===\"num\"){numeric=expression.l;allowed=negated?[expression.r.v,0x7fffffff]:[-0x80000000,expression.r.v-1]}else if(negated){allowed=[0,0]}else{var domain=rangeOf(numeric);if(!domain||domain[0]<0&&domain[1]>0)return;allowed=domain[0]>=0?[1,0x7fffffff]:[-0x80000000,-1]}var domain1=rangeOf(numeric);if(!domain1)return;return{key:key(numeric,owner),domain:domain1,allowed:[Math.max(domain1[0],allowed[0]),Math.min(domain1[1],allowed[1])]}}function visit(owner,expression,negated,record){if(owner.kind===\"opaque\"){var identity=(negated?-1:1)*intern(opaqueKey(owner.identity));if(record)known.add(identity);return known.has(identity)}if(!expression)return false;if(expression.t===\"not\")return visit(owner,expression.c,!negated,record);if(expression.t===\"bool\"||expression.t===\"num\"){var value=Boolean(expression.v)!==negated;if(record&&!value)impossible=true;return value}var identity1=(negated?-1:1)*key(expression,owner);if(record)known.add(identity1);else if(known.has(identity1))return true;if(expression.t===\"and\"||expression.t===\"or\"){if(!rangeOf(expression))return false;var conjunction=expression.t===\"and\"!==negated;if(record&&!conjunction)return false;var left=visit(owner,expression.l,negated,record);var right=visit(owner,expression.r,negated,record);return conjunction?left&&right:left||right}var constraint=interval(expression,negated,owner);if(!constraint)return false;var _ranges_get;var previous=(_ranges_get=ranges.get(constraint.key))!=null?_ranges_get:constraint.domain;var allowed=constraint.allowed;if(record){var narrowed=[Math.max(previous[0],allowed[0]),Math.min(previous[1],allowed[1])];if(narrowed[0]>narrowed[1])impossible=true;ranges.set(constraint.key,narrowed);return true}return previous[0]>=allowed[0]&&previous[1]<=allowed[1]}if(typeof facts!==\"boolean\"){for(var _iterator=_create_for_of_iterator_helper_loose(facts),_step;!(_step=_iterator()).done;){var _step_value=_step.value,condition=_step_value.condition,negated=_step_value.negated;visit(condition,condition.kind===\"expression\"?condition.expression:undefined,negated,true)}}return impossible||(typeof required===\"boolean\"?required:required.every(function(param){var condition=param.condition,negated=param.negated;return visit(condition,condition.kind===\"expression\"?condition.expression:undefined,negated,false)}))}function canonicalExpressionKey(expression,versions,key,rangeOf,intern){var range=rangeOf(expression);if(range&&range[0]===range[1])return intern(\"num:\"+range[0]);switch(expression.t){case\"def\":case\"ndef\":return intern(expression.t+\":\"+definedKey(expression.m,versions[expression.m]));case\"not\":return intern(\"not(\"+key(expression.c)+\")\");case\"unary\":return intern(expression.op+\"(\"+key(expression.c)+\")\");case\"and\":case\"or\":case\"binary\":{var operator=expression.t===\"binary\"?expression.op:expression.t;var numeric=[\"+\",\"*\",\"&\",\"|\",\"^\"].includes(operator);if(numeric||(operator===\"and\"||operator===\"or\")&&range){var terms=[];var constant;var collect=function(node){if(node.t===\"binary\"&&node.op===operator||(node.t===\"and\"||node.t===\"or\")&&node.t===operator){collect(node.l);collect(node.r)}else{var value=rangeOf(node);if(numeric&&value&&value[0]===value[1]){constant=constant===undefined?value[0]:evaluateContextFreePreprocessorCondition({t:\"binary\",op:operator,l:{t:\"num\",v:constant},r:{t:\"num\",v:value[0]}})}else terms.push(key(node))}};collect(expression);var identity=operator===\"*\"?1:operator===\"&\"?-1:0;if(numeric&&constant!==undefined&&(constant!==identity||!terms.length)){terms.push(intern(\"num:\"+constant))}terms.sort(function(left,right){return left-right});return terms.length===1?terms[0]:intern(operator+\"(\"+terms.join(\",\")+\")\")}return intern(operator+\"(\"+key(expression.l)+\",\"+key(expression.r)+\")\")}default:return intern(JSON.stringify(expression))}}function definedKey(name,version){return\"defined:\"+name+\":\"+version}function opaqueKey(identity){return\"opaque:\"+identity}var SymbolTable=function(){function SymbolTable(){this._table=new Map}var _proto=SymbolTable.prototype;_proto.insert=function insert(symbol,isInMacroBranch,branchSignature,branchSemantics){if(isInMacroBranch===void 0)isInMacroBranch=false;if(branchSignature===void 0)branchSignature=EMPTY_BRANCH;symbol.isInMacroBranch=isInMacroBranch;symbol.branchSignature=branchSignature;var _this__table_get;var entry=(_this__table_get=this._table.get(symbol.ident))!=null?_this__table_get:[];var _symbol_sourceScope;var sourceScope=(_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0;if(sourceScope>0){for(var i=entry.length-1;i>=0;i--){var existing=entry[i];var _existing_sourceScope;var inheritedScope=(_existing_sourceScope=existing.sourceScope)!=null?_existing_sourceScope:0;if(!existing.equal(symbol)||inheritedScope>=sourceScope)continue;var alternatives=[branchSignature];for(var _iterator=_create_for_of_iterator_helper_loose(entry),_step;!(_step=_iterator()).done;){var candidate=_step.value;var _candidate_sourceScope;if(((_candidate_sourceScope=candidate.sourceScope)!=null?_candidate_sourceScope:0)>inheritedScope&&candidate.equal(symbol)){var _candidate_branchSignature;alternatives.push((_candidate_branchSignature=candidate.branchSignature)!=null?_candidate_branchSignature:EMPTY_BRANCH)}}var _existing_branchSignature;if(canInheritanceBranchesCover(alternatives,(_existing_branchSignature=existing.branchSignature)!=null?_existing_branchSignature:EMPTY_BRANCH)){entry.splice(i,1)}}}if(!branchSemantics){return this._insertWithoutBranchAnalysis(entry,symbol)}var conflict=\"none\";for(var i1=0,n=entry.length;i1<n;i1++){var existing1=entry[i1];if(!existing1.equal(symbol))continue;var _existing_sourceScope1;if(((_existing_sourceScope1=existing1.sourceScope)!=null?_existing_sourceScope1:0)<sourceScope)continue;var _existing_branchSignature1;var existingBranch=(_existing_branchSignature1=existing1.branchSignature)!=null?_existing_branchSignature1:EMPTY_BRANCH;if(existingBranch.length===0&&branchSignature.length===0){entry[i1]=symbol;return\"coexist\"}var coexistence=branchSemantics.getDeclarationCoexistence(existingBranch,branchSignature);if(coexistence===\"coexist\")conflict=\"coexist\";else if(coexistence===\"unknown\"&&conflict===\"none\")conflict=\"unknown\"}entry.push(symbol);this._table.set(symbol.ident,entry);return conflict};_proto._insertWithoutBranchAnalysis=function _insertWithoutBranchAnalysis(entry,symbol){for(var i=0,n=entry.length;i<n;i++){var _entry_i_sourceScope,_symbol_sourceScope;if(entry[i].isInMacroBranch||((_entry_i_sourceScope=entry[i].sourceScope)!=null?_entry_i_sourceScope:0)!==((_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0)||!entry[i].equal(symbol))continue;entry[i]=symbol;return\"coexist\"}entry.push(symbol);this._table.set(symbol.ident,entry);return\"none\"};_proto.getInheritedConflict=function getInheritedConflict(symbol,branchSemantics,isDeferred){var entry=this._table.get(symbol.ident);if(!(entry==null?void 0:entry.includes(symbol)))return\"none\";var conflict=\"none\";for(var _iterator=_create_for_of_iterator_helper_loose(entry),_step;!(_step=_iterator()).done;){var existing=_step.value;var _existing_sourceScope,_symbol_sourceScope;if(((_existing_sourceScope=existing.sourceScope)!=null?_existing_sourceScope:0)>=((_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0)||!existing.equal(symbol))continue;if(isDeferred==null?void 0:isDeferred(existing,symbol))continue;var _existing_branchSignature,_symbol_branchSignature;var coexistence=branchSemantics.getDeclarationCoexistence((_existing_branchSignature=existing.branchSignature)!=null?_existing_branchSignature:EMPTY_BRANCH,(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH);if(coexistence===\"coexist\")return\"coexist\";if(coexistence===\"unknown\")conflict=\"unknown\"}return conflict};_proto.getSymbol=function getSymbol(symbol,includeMacro,callsiteBranch,branchSemantics){if(includeMacro===void 0)includeMacro=false;var entry=this._table.get(symbol.ident);if(entry){for(var i=entry.length-1;i>=0;i--){var item=entry[i];var visible=includeMacro||!item.isInMacroBranch;if(branchSemantics&&callsiteBranch!==undefined){var _item_branchSignature;visible=branchSemantics.isBranchVisibleFrom((_item_branchSignature=item.branchSignature)!=null?_item_branchSignature:EMPTY_BRANCH,callsiteBranch)}if(!visible)continue;if(item.equal(symbol))return item}}};_proto.getSymbols=function getSymbols(symbol,includeMacro,out){if(includeMacro===void 0)includeMacro=false;out.length=0;this._getSymbols(symbol,includeMacro,out);return out};_proto.hasSymbol=function hasSymbol(symbol){var entry=this._table.get(symbol.ident);if(!entry)return false;for(var i=0,n=entry.length;i<n;i++){if(entry[i].equal(symbol))return true}return false};_proto._getSymbols=function _getSymbols(symbol,includeMacro,out,callsiteBranch,branchSemantics){if(includeMacro===void 0)includeMacro=false;var entry=this._table.get(symbol.ident);if(entry){for(var i=entry.length-1;i>=0;i--){var item=entry[i];var visible=includeMacro||!item.isInMacroBranch;if(callsiteBranch!==undefined){var _item_branchSignature,_item_branchSignature1;visible=branchSemantics?branchSemantics.canBranchesOverlap((_item_branchSignature=item.branchSignature)!=null?_item_branchSignature:EMPTY_BRANCH,callsiteBranch):getLexicalDeclarationCoexistence((_item_branchSignature1=item.branchSignature)!=null?_item_branchSignature1:EMPTY_BRANCH,callsiteBranch)!==\"exclusive\"}if(!visible)continue;if(item.equal(symbol))out.push(item)}}return out};_proto.forEach=function forEach(callback){for(var _iterator=_create_for_of_iterator_helper_loose(this._table.values()),_step;!(_step=_iterator()).done;){var entries=_step.value;for(var i=0,n=entries.length;i<n;i++){callback(entries[i])}}};return SymbolTable}();var SymbolTableStack=function(){function SymbolTableStack(){this.stack=[];this._macroLevel=0;this._currentBranch=EMPTY_BRANCH}var _proto=SymbolTableStack.prototype;_proto.pushScope=function pushScope(scope){this.stack.push(scope)};_proto.clear=function clear(){this.stack.length=0;this._macroLevel=0;this._currentBranch=EMPTY_BRANCH};_proto.popScope=function popScope(){return this.stack.pop()};_proto.insert=function insert(symbol,branchSignature){if(branchSignature===void 0)branchSignature=this._currentBranch;return this.scope.insert(symbol,this.isInMacroBranch,branchSignature,this.branchSemantics)};_proto.lookup=function lookup(symbol,includeMacro,callsiteBranch){if(includeMacro===void 0)includeMacro=false;for(var i=this.stack.length-1;i>=0;i--){var symbolTable=this.stack[i];var result=symbolTable.getSymbol(symbol,includeMacro,callsiteBranch,this.branchSemantics);if(result)return result}return undefined};_proto.hasSymbol=function hasSymbol(symbol){for(var i=this.stack.length-1;i>=0;i--){if(this.stack[i].hasSymbol(symbol))return true}return false};_proto.lookupAll=function lookupAll(symbol,includeMacro,out,callsiteBranch){if(includeMacro===void 0)includeMacro=false;out.length=0;for(var i=this.stack.length-1;i>=0;i--){var symbolTable=this.stack[i];symbolTable._getSymbols(symbol,includeMacro,out,callsiteBranch,this.branchSemantics);if(out.length>0)break}return out};_proto.lookupAllWithRuntimeFallbacks=function lookupAllWithRuntimeFallbacks(symbol,includeMacro,out,runtimeFallbacks,callsiteBranch){out.length=0;runtimeFallbacks.length=0;for(var i=this.stack.length-1;i>=0;i--){if(!out.length){this.stack[i]._getSymbols(symbol,includeMacro,out,callsiteBranch,this.branchSemantics);if(!out.length)continue;if(this._runtimeCandidatesCoverCallsite(out,callsiteBranch))break}else{var fallbackStart=runtimeFallbacks.length;this.stack[i]._getSymbols(symbol,includeMacro,runtimeFallbacks,callsiteBranch,this.branchSemantics);if(runtimeFallbacks.length>fallbackStart&&this._runtimeCandidatesCoverCallsite(runtimeFallbacks,callsiteBranch)){break}}}return out};_proto._runtimeCandidatesCoverCallsite=function _runtimeCandidatesCoverCallsite(candidates,callsiteBranch){for(var i=0;i<candidates.length;i++){var candidate=candidates[i];var _candidate_branchSignature;if(!candidate.isInMacroBranch||callsiteBranch&&isLexicalBranchVisibleFrom((_candidate_branchSignature=candidate.branchSignature)!=null?_candidate_branchSignature:EMPTY_BRANCH,callsiteBranch)){return true}}return false};_create_class(SymbolTableStack,[{key:\"scope\",get:function get(){return this.stack[this.stack.length-1]}},{key:\"isInMacroBranch\",get:function get(){return this._macroLevel>0}}]);return SymbolTableStack}();var EShaderStage=function(EShaderStage){EShaderStage[EShaderStage[\"VERTEX\"]=0]=\"VERTEX\";EShaderStage[EShaderStage[\"FRAGMENT\"]=1]=\"FRAGMENT\";EShaderStage[EShaderStage[\"ALL\"]=2]=\"ALL\";return EShaderStage}({});function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect===\"object\"&&typeof Reflect.decorate===\"function\")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r}function __generator(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g=Object.create((typeof Iterator===\"function\"?Iterator:Object).prototype);return g.next=verb(0),g[\"throw\"]=verb(1),g[\"return\"]=verb(2),typeof Symbol===\"function\"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError(\"Generator is already executing.\");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y[\"return\"]:op[0]?y[\"throw\"]||((t=y[\"return\"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}function __values(o){var s=typeof Symbol===\"function\"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length===\"number\")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw new TypeError(s?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}typeof SuppressedError===\"function\"?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name=\"SuppressedError\",e.error=error,e.suppressed=suppressed,e};var Lexer=function(BaseLexer1){_inherits(Lexer,BaseLexer1);function Lexer(source,macroDefineList,objectPool,_conditionalArms){var _this;_this=BaseLexer1.call(this,source,objectPool)||this,_this.macroDefineList=macroDefineList,_this._conditionalArms=_conditionalArms,_this.preprocessorExpressions=new Map,_this._needScanMacroConditionExpression=false,_this._inMacroDefineValue=false,_this._macroDefineExpectsNameToken=false,_this._macroDefineExpectsParamsToken=false,_this._currentMacroName=\"\",_this._currentMacroParamsLexeme=undefined,_this._currentMacroValueStart=-1,_this._branchStack=[],_this._branchSnapshot=EMPTY_BRANCH,_this._conditionalGroup=0,_this._pendingBranchPushDefined=null,_this._pendingCodegenConditional=null,_this._codegenConditionalFrames=[];return _this}var _proto=Lexer.prototype;_proto.tokenize=function tokenize(){return __generator(this,function(_state){switch(_state.label){case 0:return[5,__values(this._tokenizeForCodegen())];case 1:_state.sent();return[2,this._createEOFToken()]}})};_proto._tokenizeForCodegen=function _tokenizeForCodegen(){var tok,parsedCondition,conditionalGroup,arm,index,previous,frame,definitelyMatched,condition,_previous_conditionalArm,isMacroName,conditionalGroup1,arm1,_this__conditionalArms,_this__conditionalArms1,_this__conditionalArms2,_this__conditionalArms3,index1,previous1,_this__conditionalArms4,frame1,condition1,_previous_conditionalArm1,frame2,reachableArms,_iterator,_step,arm2;return __generator(this,function(_state){switch(_state.label){case 0:if(!!this.isEnd())return[3,2];tok=this.scanToken();if(this._pendingCodegenConditional&&tok.type===Keyword.MACRO_CONDITIONAL_EXPRESSION){parsedCondition=this._parseCodegenConstantCondition(tok.lexeme);if(this._pendingCodegenConditional===\"push\"){conditionalGroup=++this._conditionalGroup;arm={name:\"__if_\"+conditionalGroup,defined:true,sourceArm:this._pendingCodegenArm,conditionalGroup:conditionalGroup,conditionalArm:0,condition:parsedCondition};this._branchStack.push(arm);this._codegenConditionalFrames.push({arms:[arm],definitelyMatched:(parsedCondition==null?void 0:parsedCondition.kind)===\"constant\"&&parsedCondition.value})}else{index=this._branchStack.length-1;previous=this._branchStack[index];if(previous){frame=this._codegenConditionalFrames[index];definitelyMatched=frame.definitelyMatched;condition=definitelyMatched?{kind:\"constant\",value:false}:parsedCondition;this._branchStack[index]={name:previous.name,defined:true,conditionalGroup:previous.conditionalGroup,conditionalArm:((_previous_conditionalArm=previous.conditionalArm)!=null?_previous_conditionalArm:0)+1,sourceArm:this._pendingCodegenArm,condition:condition};frame.arms.push(this._branchStack[index]);if(!definitelyMatched&&(parsedCondition==null?void 0:parsedCondition.kind)===\"constant\"&&parsedCondition.value){frame.definitelyMatched=true}}}this._pendingCodegenConditional=null}isMacroName=tok.type===ETokenType.ID||tok.type===Keyword.MACRO_CALL;if(this._pendingBranchPushDefined!==null&&isMacroName){conditionalGroup1=++this._conditionalGroup;arm1={name:tok.lexeme,defined:this._pendingBranchPushDefined,sourceArm:this._pendingCodegenArm,conditionalGroup:conditionalGroup1,conditionalArm:0};this._branchStack.push(arm1);this._codegenConditionalFrames.push({arms:[arm1],definitelyMatched:false});this._pendingBranchPushDefined=null}if(this._branchStack.length>0)tok.branch=this._captureBranchSignature();switch(tok.type){case Keyword.MACRO_IFDEF:this._pendingCodegenArm=(_this__conditionalArms=this._conditionalArms)==null?void 0:_this__conditionalArms.get(tok.location.start.index);this._pendingBranchPushDefined=true;break;case Keyword.MACRO_IFNDEF:this._pendingCodegenArm=(_this__conditionalArms1=this._conditionalArms)==null?void 0:_this__conditionalArms1.get(tok.location.start.index);this._pendingBranchPushDefined=false;break;case Keyword.MACRO_IF:this._pendingCodegenArm=(_this__conditionalArms2=this._conditionalArms)==null?void 0:_this__conditionalArms2.get(tok.location.start.index);this._pendingCodegenConditional=\"push\";break;case Keyword.MACRO_ELIF:this._pendingCodegenArm=(_this__conditionalArms3=this._conditionalArms)==null?void 0:_this__conditionalArms3.get(tok.location.start.index);this._pendingCodegenConditional=\"advance\";break;case Keyword.MACRO_ELSE:{index1=this._branchStack.length-1;previous1=this._branchStack[index1];if(previous1){frame1=this._codegenConditionalFrames[index1];condition1=frame1.definitelyMatched?{kind:\"constant\",value:false}:undefined;this._branchStack[index1]={name:previous1.name,defined:!previous1.defined,sourceArm:(_this__conditionalArms4=this._conditionalArms)==null?void 0:_this__conditionalArms4.get(tok.location.start.index),conditionalGroup:previous1.conditionalGroup,conditionalArm:((_previous_conditionalArm1=previous1.conditionalArm)!=null?_previous_conditionalArm1:0)+1,condition:condition1};frame1.arms.push(this._branchStack[index1]);frame1.definitelyMatched=true}break}case Keyword.MACRO_ENDIF:{this._branchStack.pop();frame2=this._codegenConditionalFrames.pop();if(frame2==null?void 0:frame2.definitelyMatched){reachableArms=frame2.arms.map(function(arm){var _arm_condition;return((_arm_condition=arm.condition)==null?void 0:_arm_condition.kind)!==\"constant\"||arm.condition.value});for(_iterator=_create_for_of_iterator_helper_loose(frame2.arms);!(_step=_iterator()).done;){arm2=_step.value;arm2.conditionalComplete=true;arm2.conditionalArmCount=frame2.arms.length;arm2.conditionalReachableArms=reachableArms}}break}}return[4,tok];case 1:_state.sent();return[3,0];case 2:return[2,this._createEOFToken()]}})};_proto._parseCodegenConstantCondition=function _parseCodegenConstantCondition(expression){var parsed=this.preprocessorExpressions.get(expression.trim());var value=(parsed==null?void 0:parsed.ok)&&!parsed.hasExpandableIdentifier?evaluateContextFreePreprocessorCondition(parsed.condition):undefined;return value===undefined?undefined:{kind:\"constant\",value:value!==0}};_proto._isBranchReachable=function _isBranchReachable(branch){return Lexer._isCodegenBranchReachable(branch)};_proto._sameDefinitionBranch=function _sameDefinitionBranch(left,right){return Lexer._sameCodegenBranch(left,right)};_proto._branchesOverlap=function _branchesOverlap(left,right){return getLexicalDeclarationCoexistence(left,right)!==\"exclusive\"};_proto.scanToken=function scanToken(){if(this._inMacroDefineValue){this._skipInlineSpaceAndComments();if(this.isEnd()||this._isAtLineBreak()){return this._emitMacroDefineEnd()}if(this._macroDefineExpectsParamsToken){this._macroDefineExpectsParamsToken=false;if(this.getCurChar()===\"(\"){return this._scanMacroDefineParams()}}}else{this.skipCommentsAndSpace();if(this.isEnd()){return this._createEOFToken()}}if(this._needScanMacroConditionExpression){this._needScanMacroConditionExpression=false;return this._scanMacroConditionExpression()}var curCharCode=this.getCurCharCode();if(BaseLexer.isPreprocessorStartChar(curCharCode)){return this._scanDirectives()}if(BaseLexer.isAlpha(curCharCode)){return this._scanWord()}if(BaseLexer.isDigit(curCharCode)){return this._scanNum()}var start=this.getShaderPosition();var token=this._createToken();var curChar;switch(this.getCurChar()){case\"<\":this.advance(1);curChar=this.getCurChar();if(curChar===\"<\"){this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.LEFT_ASSIGN,\"<<=\",start);break}token.set(ETokenType.LEFT_OP,\"<<\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.LE_OP,\"<=\",start);break}token.set(ETokenType.LEFT_ANGLE,\"<\",start);break;case\">\":this.advance(1);curChar=this.getCurChar();if(curChar===\">\"){this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.RIGHT_ASSIGN,\">>=\",start);break}token.set(ETokenType.RIGHT_OP,\">>\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.GE_OP,\">=\",start);break}token.set(ETokenType.RIGHT_ANGLE,\">\",start);break;case\"+\":this.advance(1);curChar=this.getCurChar();if(curChar===\"+\"){this.advance(1);token.set(ETokenType.INC_OP,\"++\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.ADD_ASSIGN,\"+=\",start);break}token.set(ETokenType.PLUS,\"+\",start);break;case\"-\":this.advance(1);curChar=this.getCurChar();if(curChar===\"-\"){this.advance(1);token.set(ETokenType.DEC_OP,\"--\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.SUB_ASSIGN,\"-=\",start);break}token.set(ETokenType.DASH,\"-\",start);break;case\"=\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.EQ_OP,\"==\",start);break}token.set(ETokenType.EQUAL,\"=\",start);break;case\"!\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.NE_OP,\"!=\",start);break}token.set(ETokenType.BANG,\"!\",start);break;case\"&\":this.advance(1);curChar=this.getCurChar();if(curChar===\"&\"){this.advance(1);token.set(ETokenType.AND_OP,\"&&\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.AND_ASSIGN,\"&=\",start);break}token.set(ETokenType.AMPERSAND,\"&\",start);break;case\"|\":this.advance(1);curChar=this.getCurChar();if(curChar===\"|\"){this.advance(1);token.set(ETokenType.OR_OP,\"||\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.OR_ASSIGN,\"|=\",start);break}token.set(ETokenType.VERTICAL_BAR,\"|\",start);break;case\"^\":this.advance(1);curChar=this.getCurChar();if(curChar===\"^\"){this.advance(1);token.set(ETokenType.XOR_OP,\"^^\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.XOR_ASSIGN,\"^=\",start);break}token.set(ETokenType.CARET,\"^\",start);break;case\"*\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.MUL_ASSIGN,\"*=\",start);break}token.set(ETokenType.STAR,\"*\",start);break;case\"/\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.DIV_ASSIGN,\"/=\",start);break}token.set(ETokenType.SLASH,\"/\",start);break;case\"%\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.MOD_ASSIGN,\"%=\",start);break}token.set(ETokenType.PERCENT,\"%\",start);break;case\"(\":this.advance(1);token.set(ETokenType.LEFT_PAREN,\"(\",start);break;case\")\":this.advance(1);token.set(ETokenType.RIGHT_PAREN,\")\",start);break;case\"{\":this.advance(1);token.set(ETokenType.LEFT_BRACE,\"{\",start);break;case\"}\":this.advance(1);token.set(ETokenType.RIGHT_BRACE,\"}\",start);break;case\"[\":this.advance(1);token.set(ETokenType.LEFT_BRACKET,\"[\",start);break;case\"]\":this.advance(1);token.set(ETokenType.RIGHT_BRACKET,\"]\",start);break;case\".\":this.advance(1);if(BaseLexer.isDigit(this.getCurCharCode())){return this._scanNumAfterDot()}token.set(ETokenType.DOT,\".\",start);break;case\",\":this.advance(1);token.set(ETokenType.COMMA,\",\",start);break;case\":\":this.advance(1);token.set(ETokenType.COLON,\":\",start);return token;case\";\":this.advance(1);token.set(ETokenType.SEMICOLON,\";\",start);break;case\"~\":this.advance(1);token.set(ETokenType.TILDE,\"~\",start);break;case\"?\":this.advance(1);token.set(ETokenType.QUESTION,\"?\",start);break;case'\"':this.advance(1);return this._scanStringConst();default:this.throwError(this.getShaderPosition(0),\"Unexpected character \"+this.getCurChar())}return token};_proto._scanStringConst=function _scanStringConst(){var start=this.getShaderPosition();var buffer=[];while(this.getCurChar()!=='\"'){if(this.isEnd()){var quote=this._createPosition(start.index-1,start.line,start.column-1);this.throwError(this._createRange(quote,start),\"Unterminated string literal.\")}buffer.push(this.getCurChar());this.advance(1)}this.advance(1);var range=this._createRange(start,this.getShaderPosition());var token=this._createToken();token.set(ETokenType.STRING_CONST,buffer.join(\"\"),range);return token};_proto._scanNumAfterDot=function _scanNumAfterDot(){var buffer=[\".\"];while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}this._scanFloatSuffix(buffer);var token=this._createToken();token.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token};_proto._scanUtilBreakLine=function _scanUtilBreakLine(outBuffer){var src=this._source;var len=src.length;while(!this.isEnd()){var afterContinuation=Lexer._skipLineContinuation(src,this._currentIndex,len);if(afterContinuation!==this._currentIndex){this.advance(afterContinuation-this._currentIndex);continue}var c=src.charCodeAt(this._currentIndex);if(c===10)break;outBuffer.push(src[this._currentIndex]);this.advance(1)}};_proto._scanDirectives=function _scanDirectives(){var buffer=[this.getCurChar()];var start=this.getShaderPosition();this.advance(1);this.skipSpace(false);while(BaseLexer.isAlpha(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var token=this._createToken();var word=buffer.join(\"\");if(word===\"#define\"){var branchReachable=this._isBranchReachable(this._branchStack);if(!branchReachable){this._scanUtilBreakLine(buffer);token.set(Keyword.MACRO_DEFINE_EXPRESSION,\"\\n\"+buffer.join(\"\")+\"\\n\",start);return token}var peek=this._peekMacroDefine();if(peek&&peek.isExpression){this._inMacroDefineValue=true;this._macroDefineExpectsNameToken=true;token.set(Keyword.MACRO_DEFINE,\"#define\",start)}else{this._scanUtilBreakLine(buffer);var lexeme=\"\\n\"+buffer.join(\"\")+\"\\n\";if(peek){this._registerMacroDefine(peek.name,peek.paramsLexeme,peek.valueStart,peek.valueEnd)}token.set(Keyword.MACRO_DEFINE_EXPRESSION,lexeme,start)}}else{var kt=Lexer._lexemeTable[word];token.set(kt!=null?kt:ETokenType.ID,word,start);if(word===\"#if\"||word===\"#elif\"){this._needScanMacroConditionExpression=true}}return token};_proto._isAtLineBreak=function _isAtLineBreak(){var c=this.getCurChar();return c===\"\\n\"||c===\"\\r\"};_proto._peekMacroDefine=function _peekMacroDefine(){var src=this._source;var len=src.length;var i=Lexer._skipNonSemantic(src,this._currentIndex,len);if(!(i<len&&BaseLexer.isAlpha(src.charCodeAt(i))))return null;var nameStart=i;while(i<len&&BaseLexer.isAlnum(src.charCodeAt(i)))i++;var name=src.slice(nameStart,i);var paramsLexeme;if(i<len&&src.charCodeAt(i)===40){var paramsStart=i;var depth=1;i++;while(i<len&&depth>0){i=Lexer._skipNonSemantic(src,i,len);if(i>=len)break;var c=src.charCodeAt(i);if(c===10||c===13){return{name:name,paramsLexeme:undefined,valueStart:i,valueEnd:i,isExpression:false}}if(c===40)depth++;else if(c===41)depth--;i++}paramsLexeme=src.slice(paramsStart,i)}var valueStart=i;var parenDepth=0;var bracketDepth=0;var firstStart=-1;var firstEnd=-1;var firstFollowedByParen=false;var topLevelLast=-1;while(i<len){var skipped=Lexer._skipNonSemantic(src,i,len);if(skipped!==i){i=skipped;continue}var c1=src.charCodeAt(i);if(c1===10||c1===13)break;if(firstStart===-1){firstStart=i;if(BaseLexer.isAlpha(c1)){while(i<len&&BaseLexer.isAlnum(src.charCodeAt(i)))i++;firstEnd=i;var after=Lexer._skipNonSemantic(src,i,len);firstFollowedByParen=after<len&&src.charCodeAt(after)===40;topLevelLast=firstEnd-1;continue}}if(c1===40)parenDepth++;else if(c1===41)parenDepth--;else if(c1===91)bracketDepth++;else if(c1===93)bracketDepth--;if(parenDepth===0&&bracketDepth===0)topLevelLast=i;i++}var result={name:name,paramsLexeme:paramsLexeme,valueStart:valueStart,valueEnd:i,isExpression:false};if(firstStart===-1)return result;if(firstEnd!==-1&&!firstFollowedByParen&&Lexer._isNonExpressionLeadingKeyword(src.slice(firstStart,firstEnd))){return result}var head=src.charCodeAt(firstStart);var tail=topLevelLast>=0?src.charCodeAt(topLevelLast):0;var headIllegal=!BaseLexer.isAlnum(head)&&head!==40&&head!==46&&head!==45&&head!==43&&head!==33&&head!==126;var tailIllegal=!BaseLexer.isAlnum(tail)&&tail!==41&&tail!==93;if(parenDepth!==0||bracketDepth!==0||headIllegal||tailIllegal)return result;result.isExpression=true;return result};_proto._skipInlineSpaceAndComments=function _skipInlineSpaceAndComments(){var next=Lexer._skipNonSemantic(this._source,this._currentIndex,this._source.length);if(next>this._currentIndex)this.advance(next-this._currentIndex)};_proto._scanMacroDefineParams=function _scanMacroDefineParams(){var start=this.getShaderPosition();var src=this._source;var len=src.length;var buffer=[];var depth=0;while(this._currentIndex<len){var afterContinuation=Lexer._skipLineContinuation(src,this._currentIndex,len);if(afterContinuation!==this._currentIndex){this.advance(afterContinuation-this._currentIndex);continue}var ch=src[this._currentIndex];buffer.push(ch);if(ch===\"(\")depth++;else if(ch===\")\"){depth--;this.advance(1);if(depth===0)break;continue}this.advance(1)}var token=this._createToken();var lexeme=buffer.join(\"\");this._currentMacroParamsLexeme=lexeme;this._currentMacroValueStart=this._currentIndex;token.set(Keyword.MACRO_DEFINE_PARAMS,lexeme,start);return token};_proto._emitMacroDefineEnd=function _emitMacroDefineEnd(){var start=this.getShaderPosition();var valueEnd=this._currentIndex;var source=this._source;if(this._currentIndex<source.length){var c=source.charCodeAt(this._currentIndex);if(c===13&&source.charCodeAt(this._currentIndex+1)===10){this.advance(2)}else if(c===10||c===13){this.advance(1)}}this._registerMacroDefine(this._currentMacroName,this._currentMacroParamsLexeme,this._currentMacroValueStart,valueEnd);this._inMacroDefineValue=false;var token=this._createToken();token.set(Keyword.MACRO_DEFINE_END,\"\\n\",start);return token};_proto._registerMacroDefine=function _registerMacroDefine(name,paramsLexeme,valueStart,valueEnd){var params=paramsLexeme?paramsLexeme.slice(1,-1).split(\",\").map(function(p){return p.trim()}).filter(Boolean):[];var dedupKey=(paramsLexeme!=null?paramsLexeme:\"\")+\"=\"+Lexer._normalizeValueText(this._source,valueStart,valueEnd);var info={isFunction:paramsLexeme!==undefined,params:params,dedupKey:dedupKey,branch:this._captureBranchSignature()};var arr=this.macroDefineList[name];if(!arr){this.macroDefineList[name]=[info]}else{var duplicate=false;for(var i=0,n=arr.length;i<n;i++){var e=arr[i];if(e.dedupKey===dedupKey&&this._sameDefinitionBranch(e.branch,info.branch)){duplicate=true;break}}if(!duplicate)arr.push(info)}};_proto._captureBranchSignature=function _captureBranchSignature(){var stack=this._branchStack;var snapshot=this._branchSnapshot;if(stack.length===snapshot.length){var unchanged=true;for(var i=0;i<stack.length;i++){if(stack[i]!==snapshot[i]){unchanged=false;break}}if(unchanged)return snapshot}return this._branchSnapshot=stack.length===0?EMPTY_BRANCH:stack.slice()};_proto._scanMacroConditionExpression=function _scanMacroConditionExpression(){var buffer=new Array;var start=this.getShaderPosition();var source=this._source;while(!this.isEnd()){var afterContinuation=Lexer._skipLineContinuation(source,this._currentIndex,source.length);if(afterContinuation!==this._currentIndex){while(this._currentIndex<afterContinuation){var character=source[this._currentIndex];buffer.push(character===\"\\\\\"?\" \":character);this.advance(1)}continue}if(source.charCodeAt(this._currentIndex)===10)break;buffer.push(source[this._currentIndex]);this.advance(1)}var word=buffer.join(\"\");var result=parsePreprocessorExpression(word);var emittedWord=word.replace(/[\\r\\n]/g,\" \");this.preprocessorExpressions.set(emittedWord.trim(),result);var token=this._createToken();token.set(Keyword.MACRO_CONDITIONAL_EXPRESSION,emittedWord,start);return token};_proto._scanWord=function _scanWord(){var buffer=[this.getCurChar()];var start=this.getShaderPosition();this.advance(1);while(BaseLexer.isAlnum(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var token=this._createToken();var word=buffer.join(\"\");var kt=Lexer._lexemeTable[word];if(this._macroDefineExpectsNameToken){this._macroDefineExpectsNameToken=false;this._currentMacroName=word;this._currentMacroParamsLexeme=undefined;if(this._inMacroDefineValue){this._macroDefineExpectsParamsToken=this.getCurChar()===\"(\";this._currentMacroValueStart=this._currentIndex}token.set(ETokenType.ID,word,start)}else if(this._isVisibleMacro(word)){token.set(Keyword.MACRO_CALL,word,start)}else{token.set(kt!=null?kt:ETokenType.ID,word,start)}return token};_proto._isVisibleMacro=function _isVisibleMacro(word){var defs=this.macroDefineList[word];if(!defs||defs.length===0)return false;var callSiteBranch=this._branchStack;for(var i=0,n=defs.length;i<n;i++){if(this._branchesOverlap(defs[i].branch,callSiteBranch)){return true}}return false};_proto._scanNum=function _scanNum(){var buffer=[];if(this.getCurChar()===\"0\"){var nextCode=this._source.charCodeAt(this._currentIndex+1);if(nextCode===120||nextCode===88){buffer.push(this.getCurChar());this.advance(1);buffer.push(this.getCurChar());this.advance(1);while(BaseLexer.isHexDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}if(buffer.length===2){this.throwError(this.getShaderPosition(0),\"lexing error, hex literal needs at least one digit.\")}this._scanIntegerSuffix(buffer);var token=this._createToken();token.set(ETokenType.INT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token}}while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var curChar=this.getCurChar();if(curChar===\".\"){buffer.push(curChar);this.advance(1);while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}this._scanFloatSuffix(buffer);var token1=this._createToken();token1.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token1}else if(curChar===\"e\"||curChar===\"E\"){this._scanFloatSuffix(buffer);var token2=this._createToken();token2.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token2}else if(curChar===\"f\"||curChar===\"F\"){buffer.push(curChar);this.advance(1);var token3=this._createToken();token3.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token3}else{this._scanIntegerSuffix(buffer);var token4=this._createToken();token4.set(ETokenType.INT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token4}};_proto._scanFloatSuffix=function _scanFloatSuffix(buffer){var curChar=this.getCurChar();if(curChar===\"e\"||curChar===\"E\"){buffer.push(curChar);this.advance(1);curChar=this.getCurChar();if(curChar===\"+\"||curChar===\"-\"){buffer.push(curChar);this.advance(1);curChar=this.getCurChar()}if(!BaseLexer.isDigit(this.getCurCharCode()))this.throwError(this.getShaderPosition(0),\"lexing error, invalid exponent suffix.\");do{buffer.push(curChar);this.advance(1);curChar=this.getCurChar()}while(BaseLexer.isDigit(this.getCurCharCode()))}if(curChar===\"f\"||curChar===\"F\"){buffer.push(curChar);this.advance(1)}};_proto._scanIntegerSuffix=function _scanIntegerSuffix(buffer){var curChar=this.getCurChar();if(curChar===\"u\"||curChar===\"U\"){buffer.push(curChar);this.advance(1)}};Lexer._isCodegenBranchReachable=function _isCodegenBranchReachable(branch){for(var i=0;i<branch.length;i++){var condition=branch[i].condition;if((condition==null?void 0:condition.kind)===\"constant\"&&!condition.value)return false}return true};Lexer._isNonExpressionLeadingKeyword=function _isNonExpressionLeadingKeyword(lexeme){var kw=Lexer._lexemeTable[lexeme];return kw!==undefined&&kw!==Keyword.True&&kw!==Keyword.False&&!lexeme.startsWith(\"#\")};Lexer._skipLineContinuation=function _skipLineContinuation(src,i,len){if(src.charCodeAt(i)!==92||i+1>=len)return i;var n=src.charCodeAt(i+1);if(n===10)return i+2;if(n===13)return i+2<len&&src.charCodeAt(i+2)===10?i+3:i+2;return i};Lexer._skipNonSemantic=function _skipNonSemantic(src,from,len){var i=from;while(i<len){var c=src.charCodeAt(i);if(c===32||c===9){i++;continue}var afterContinuation=Lexer._skipLineContinuation(src,i,len);if(afterContinuation!==i){i=afterContinuation;continue}var afterBlock=Lexer._skipBlockComment(src,i,len);if(afterBlock!==i){i=afterBlock;continue}var afterLine=Lexer._skipLineComment(src,i,len);if(afterLine!==i){i=afterLine;continue}break}return i};Lexer._normalizeValueText=function _normalizeValueText(src,start,end){var out=\"\";var i=start;var pendingSpace=false;while(i<end){var skipped=Lexer._skipNonSemantic(src,i,end);if(skipped!==i){pendingSpace=out.length>0;i=skipped;continue}var c=src.charCodeAt(i);if(c===32||c===9){pendingSpace=out.length>0;i++;continue}if(pendingSpace){out+=\" \";pendingSpace=false}out+=src[i];i++}return out};Lexer._sameCodegenBranch=function _sameCodegenBranch(left,right){if(left.length!==right.length)return false;for(var i=0;i<left.length;i++){if(left[i].conditionalGroup!==right[i].conditionalGroup||left[i].conditionalArm!==right[i].conditionalArm){return false}}return true};return Lexer}(BaseLexer);Lexer._lexemeTable={const:Keyword.CONST,bool:Keyword.BOOL,float:Keyword.FLOAT,double:Keyword.DOUBLE,int:Keyword.INT,uint:Keyword.UINT,break:Keyword.BREAK,continue:Keyword.CONTINUE,do:Keyword.DO,else:Keyword.ELSE,for:Keyword.FOR,if:Keyword.IF,while:Keyword.WHILE,discard:Keyword.DISCARD,return:Keyword.RETURN,bvec2:Keyword.BVEC2,bvec3:Keyword.BVEC3,bvec4:Keyword.BVEC4,ivec2:Keyword.IVEC2,ivec3:Keyword.IVEC3,ivec4:Keyword.IVEC4,uvec2:Keyword.UVEC2,uvec3:Keyword.UVEC3,uvec4:Keyword.UVEC4,vec2:Keyword.VEC2,vec3:Keyword.VEC3,vec4:Keyword.VEC4,mat2:Keyword.MAT2,mat3:Keyword.MAT3,mat4:Keyword.MAT4,mat2x3:Keyword.MAT2X3,mat2x4:Keyword.MAT2X4,mat3x2:Keyword.MAT3X2,mat3x4:Keyword.MAT3X4,mat4x2:Keyword.MAT4X2,mat4x3:Keyword.MAT4X3,in:Keyword.IN,out:Keyword.OUT,inout:Keyword.INOUT,sampler2D:Keyword.SAMPLER2D,samplerCube:Keyword.SAMPLER_CUBE,sampler3D:Keyword.SAMPLER3D,sampler2DShadow:Keyword.SAMPLER2D_SHADOW,samplerCubeShadow:Keyword.SAMPLER_CUBE_SHADOW,sampler2DArray:Keyword.SAMPLER2D_ARRAY,sampler2DArrayShadow:Keyword.SAMPLER2D_ARRAY_SHADOW,isampler2D:Keyword.I_SAMPLER2D,isampler3D:Keyword.I_SAMPLER3D,isamplerCube:Keyword.I_SAMPLER_CUBE,isampler2DArray:Keyword.I_SAMPLER2D_ARRAY,usampler2D:Keyword.U_SAMPLER2D,usampler3D:Keyword.U_SAMPLER3D,usamplerCube:Keyword.U_SAMPLER_CUBE,usampler2DArray:Keyword.U_SAMPLER2D_ARRAY,struct:Keyword.STRUCT,void:Keyword.VOID,true:Keyword.True,false:Keyword.False,precision:Keyword.PRECISION,precise:Keyword.PRECISE,highp:Keyword.HIGHP,mediump:Keyword.MEDIUMP,lowp:Keyword.LOWP,invariant:Keyword.INVARIANT,flat:Keyword.FLAT,smooth:Keyword.SMOOTH,noperspective:Keyword.NOPERSPECTIVE,centroid:Keyword.CENTROID,layout:Keyword.LAYOUT,location:Keyword.LOCATION,\"#if\":Keyword.MACRO_IF,\"#ifdef\":Keyword.MACRO_IFDEF,\"#ifndef\":Keyword.MACRO_IFNDEF,\"#else\":Keyword.MACRO_ELSE,\"#elif\":Keyword.MACRO_ELIF,\"#endif\":Keyword.MACRO_ENDIF,\"#undef\":Keyword.MACRO_UNDEF};var NoneTerminal=function(NoneTerminal){NoneTerminal[NoneTerminal[\"START\"]=2e3]=\"START\";NoneTerminal[NoneTerminal[\"gs_shader_program\"]=2001]=\"gs_shader_program\";NoneTerminal[NoneTerminal[\"global_declaration\"]=2002]=\"global_declaration\";NoneTerminal[NoneTerminal[\"variable_declaration\"]=2003]=\"variable_declaration\";NoneTerminal[NoneTerminal[\"variable_declaration_list\"]=2004]=\"variable_declaration_list\";NoneTerminal[NoneTerminal[\"variable_declaration_statement\"]=2005]=\"variable_declaration_statement\";NoneTerminal[NoneTerminal[\"array_specifier_list\"]=2006]=\"array_specifier_list\";NoneTerminal[NoneTerminal[\"array_specifier\"]=2007]=\"array_specifier\";NoneTerminal[NoneTerminal[\"ext_builtin_type_specifier_nonarray\"]=2008]=\"ext_builtin_type_specifier_nonarray\";NoneTerminal[NoneTerminal[\"precision_specifier\"]=2009]=\"precision_specifier\";NoneTerminal[NoneTerminal[\"variable_identifier\"]=2010]=\"variable_identifier\";NoneTerminal[NoneTerminal[\"variable_identifier_node\"]=2011]=\"variable_identifier_node\";NoneTerminal[NoneTerminal[\"primary_expression\"]=2012]=\"primary_expression\";NoneTerminal[NoneTerminal[\"postfix_expression\"]=2013]=\"postfix_expression\";NoneTerminal[NoneTerminal[\"integer_expression\"]=2014]=\"integer_expression\";NoneTerminal[NoneTerminal[\"function_call\"]=2015]=\"function_call\";NoneTerminal[NoneTerminal[\"function_call_generic\"]=2016]=\"function_call_generic\";NoneTerminal[NoneTerminal[\"function_call_header_no_parameters\"]=2017]=\"function_call_header_no_parameters\";NoneTerminal[NoneTerminal[\"function_call_header_with_parameters\"]=2018]=\"function_call_header_with_parameters\";NoneTerminal[NoneTerminal[\"function_call_parameter_list\"]=2019]=\"function_call_parameter_list\";NoneTerminal[NoneTerminal[\"function_call_header\"]=2020]=\"function_call_header\";NoneTerminal[NoneTerminal[\"function_identifier\"]=2021]=\"function_identifier\";NoneTerminal[NoneTerminal[\"constructor_identifier\"]=2022]=\"constructor_identifier\";NoneTerminal[NoneTerminal[\"unary_expression\"]=2023]=\"unary_expression\";NoneTerminal[NoneTerminal[\"unary_operator\"]=2024]=\"unary_operator\";NoneTerminal[NoneTerminal[\"multiplicative_expression\"]=2025]=\"multiplicative_expression\";NoneTerminal[NoneTerminal[\"additive_expression\"]=2026]=\"additive_expression\";NoneTerminal[NoneTerminal[\"shift_expression\"]=2027]=\"shift_expression\";NoneTerminal[NoneTerminal[\"relational_expression\"]=2028]=\"relational_expression\";NoneTerminal[NoneTerminal[\"equality_expression\"]=2029]=\"equality_expression\";NoneTerminal[NoneTerminal[\"and_expression\"]=2030]=\"and_expression\";NoneTerminal[NoneTerminal[\"inclusive_or_expression\"]=2031]=\"inclusive_or_expression\";NoneTerminal[NoneTerminal[\"exclusive_or_expression\"]=2032]=\"exclusive_or_expression\";NoneTerminal[NoneTerminal[\"logical_and_expression\"]=2033]=\"logical_and_expression\";NoneTerminal[NoneTerminal[\"logical_xor_expression\"]=2034]=\"logical_xor_expression\";NoneTerminal[NoneTerminal[\"logical_or_expression\"]=2035]=\"logical_or_expression\";NoneTerminal[NoneTerminal[\"conditional_expression\"]=2036]=\"conditional_expression\";NoneTerminal[NoneTerminal[\"assignment_expression\"]=2037]=\"assignment_expression\";NoneTerminal[NoneTerminal[\"assignment_operator\"]=2038]=\"assignment_operator\";NoneTerminal[NoneTerminal[\"expression\"]=2039]=\"expression\";NoneTerminal[NoneTerminal[\"integer_constant_expression\"]=2040]=\"integer_constant_expression\";NoneTerminal[NoneTerminal[\"integer_constant_expression_operator\"]=2041]=\"integer_constant_expression_operator\";NoneTerminal[NoneTerminal[\"declaration\"]=2042]=\"declaration\";NoneTerminal[NoneTerminal[\"function_prototype\"]=2043]=\"function_prototype\";NoneTerminal[NoneTerminal[\"function_declarator\"]=2044]=\"function_declarator\";NoneTerminal[NoneTerminal[\"function_header_with_parameters\"]=2045]=\"function_header_with_parameters\";NoneTerminal[NoneTerminal[\"function_header\"]=2046]=\"function_header\";NoneTerminal[NoneTerminal[\"function_parameter_list\"]=2047]=\"function_parameter_list\";NoneTerminal[NoneTerminal[\"parameter_declarator\"]=2048]=\"parameter_declarator\";NoneTerminal[NoneTerminal[\"parameter_declaration\"]=2049]=\"parameter_declaration\";NoneTerminal[NoneTerminal[\"parameter_qualifier\"]=2050]=\"parameter_qualifier\";NoneTerminal[NoneTerminal[\"parameter_type_specifier\"]=2051]=\"parameter_type_specifier\";NoneTerminal[NoneTerminal[\"init_declarator_list\"]=2052]=\"init_declarator_list\";NoneTerminal[NoneTerminal[\"single_declaration\"]=2053]=\"single_declaration\";NoneTerminal[NoneTerminal[\"fully_specified_type\"]=2054]=\"fully_specified_type\";NoneTerminal[NoneTerminal[\"type_qualifier\"]=2055]=\"type_qualifier\";NoneTerminal[NoneTerminal[\"single_type_qualifier\"]=2056]=\"single_type_qualifier\";NoneTerminal[NoneTerminal[\"storage_qualifier\"]=2057]=\"storage_qualifier\";NoneTerminal[NoneTerminal[\"precision_qualifier\"]=2058]=\"precision_qualifier\";NoneTerminal[NoneTerminal[\"interpolation_qualifier\"]=2059]=\"interpolation_qualifier\";NoneTerminal[NoneTerminal[\"invariant_qualifier\"]=2060]=\"invariant_qualifier\";NoneTerminal[NoneTerminal[\"type_specifier\"]=2061]=\"type_specifier\";NoneTerminal[NoneTerminal[\"type_specifier_nonarray\"]=2062]=\"type_specifier_nonarray\";NoneTerminal[NoneTerminal[\"type_specifier_no_prec\"]=2063]=\"type_specifier_no_prec\";NoneTerminal[NoneTerminal[\"basic_type\"]=2064]=\"basic_type\";NoneTerminal[NoneTerminal[\"struct_specifier\"]=2065]=\"struct_specifier\";NoneTerminal[NoneTerminal[\"struct_declaration_list\"]=2066]=\"struct_declaration_list\";NoneTerminal[NoneTerminal[\"struct_declaration\"]=2067]=\"struct_declaration\";NoneTerminal[NoneTerminal[\"layout_qualifier\"]=2068]=\"layout_qualifier\";NoneTerminal[NoneTerminal[\"struct_declarator_list\"]=2069]=\"struct_declarator_list\";NoneTerminal[NoneTerminal[\"struct_declarator\"]=2070]=\"struct_declarator\";NoneTerminal[NoneTerminal[\"identifier_list\"]=2071]=\"identifier_list\";NoneTerminal[NoneTerminal[\"decl_identifier\"]=2072]=\"decl_identifier\";NoneTerminal[NoneTerminal[\"initializer\"]=2073]=\"initializer\";NoneTerminal[NoneTerminal[\"initializer_list\"]=2074]=\"initializer_list\";NoneTerminal[NoneTerminal[\"declaration_statement\"]=2075]=\"declaration_statement\";NoneTerminal[NoneTerminal[\"simple_statement\"]=2076]=\"simple_statement\";NoneTerminal[NoneTerminal[\"compound_statement_no_scope\"]=2077]=\"compound_statement_no_scope\";NoneTerminal[NoneTerminal[\"statement_with_scope\"]=2078]=\"statement_with_scope\";NoneTerminal[NoneTerminal[\"compound_statement\"]=2079]=\"compound_statement\";NoneTerminal[NoneTerminal[\"statement\"]=2080]=\"statement\";NoneTerminal[NoneTerminal[\"statement_list\"]=2081]=\"statement_list\";NoneTerminal[NoneTerminal[\"iteration_statement_no_new_scope\"]=2082]=\"iteration_statement_no_new_scope\";NoneTerminal[NoneTerminal[\"expression_statement\"]=2083]=\"expression_statement\";NoneTerminal[NoneTerminal[\"selection_statement\"]=2084]=\"selection_statement\";NoneTerminal[NoneTerminal[\"selection_rest_statement\"]=2085]=\"selection_rest_statement\";NoneTerminal[NoneTerminal[\"condition\"]=2086]=\"condition\";NoneTerminal[NoneTerminal[\"conditionopt\"]=2087]=\"conditionopt\";NoneTerminal[NoneTerminal[\"iteration_statement\"]=2088]=\"iteration_statement\";NoneTerminal[NoneTerminal[\"for_init_statement\"]=2089]=\"for_init_statement\";NoneTerminal[NoneTerminal[\"for_rest_statement\"]=2090]=\"for_rest_statement\";NoneTerminal[NoneTerminal[\"jump_statement\"]=2091]=\"jump_statement\";NoneTerminal[NoneTerminal[\"external_declaration\"]=2092]=\"external_declaration\";NoneTerminal[NoneTerminal[\"function_definition\"]=2093]=\"function_definition\";NoneTerminal[NoneTerminal[\"field_selection\"]=2094]=\"field_selection\";NoneTerminal[NoneTerminal[\"bool_constant\"]=2095]=\"bool_constant\";NoneTerminal[NoneTerminal[\"function_identifier_node\"]=2096]=\"function_identifier_node\";NoneTerminal[NoneTerminal[\"typename_identifier_node\"]=2097]=\"typename_identifier_node\";NoneTerminal[NoneTerminal[\"scope_brace\"]=2098]=\"scope_brace\";NoneTerminal[NoneTerminal[\"scope_end_brace\"]=2099]=\"scope_end_brace\";NoneTerminal[NoneTerminal[\"macro_undef\"]=2100]=\"macro_undef\";NoneTerminal[NoneTerminal[\"macro_push_context\"]=2101]=\"macro_push_context\";NoneTerminal[NoneTerminal[\"macro_pop_context\"]=2102]=\"macro_pop_context\";NoneTerminal[NoneTerminal[\"macro_elif_expression\"]=2103]=\"macro_elif_expression\";NoneTerminal[NoneTerminal[\"macro_else_expression\"]=2104]=\"macro_else_expression\";NoneTerminal[NoneTerminal[\"global_macro_if_statement\"]=2105]=\"global_macro_if_statement\";NoneTerminal[NoneTerminal[\"global_macro_declaration\"]=2106]=\"global_macro_declaration\";NoneTerminal[NoneTerminal[\"global_macro_branch\"]=2107]=\"global_macro_branch\";NoneTerminal[NoneTerminal[\"macro_struct_declaration\"]=2108]=\"macro_struct_declaration\";NoneTerminal[NoneTerminal[\"macro_struct_branch\"]=2109]=\"macro_struct_branch\";NoneTerminal[NoneTerminal[\"macro_if_statement\"]=2110]=\"macro_if_statement\";NoneTerminal[NoneTerminal[\"macro_branch\"]=2111]=\"macro_branch\";NoneTerminal[NoneTerminal[\"macro_param_case_list\"]=2112]=\"macro_param_case_list\";NoneTerminal[NoneTerminal[\"macro_param_block\"]=2113]=\"macro_param_block\";NoneTerminal[NoneTerminal[\"macro_parameter_branch\"]=2114]=\"macro_parameter_branch\";NoneTerminal[NoneTerminal[\"macro_call_arg_case_list\"]=2115]=\"macro_call_arg_case_list\";NoneTerminal[NoneTerminal[\"macro_call_arg_block\"]=2116]=\"macro_call_arg_block\";NoneTerminal[NoneTerminal[\"macro_call_arg_branch\"]=2117]=\"macro_call_arg_branch\";NoneTerminal[NoneTerminal[\"macro_call_symbol\"]=2118]=\"macro_call_symbol\";NoneTerminal[NoneTerminal[\"macro_call_function\"]=2119]=\"macro_call_function\";NoneTerminal[NoneTerminal[\"macro_define\"]=2120]=\"macro_define\";NoneTerminal[NoneTerminal[\"_ignore\"]=2121]=\"_ignore\";return NoneTerminal}({});var Production=function Production(goal,derivation){this.goal=goal;this.derivation=derivation;this.id=Production._id++;Production.pool.set(this.id,this)};Production._id=0;Production.pool=new Map;var GenericType=function(GenericType){GenericType[GenericType[\"GenType\"]=200]=\"GenType\";GenericType[GenericType[\"GenIntType\"]=201]=\"GenIntType\";GenericType[GenericType[\"GenUintType\"]=202]=\"GenUintType\";GenericType[GenericType[\"GenBoolType\"]=203]=\"GenBoolType\";GenericType[GenericType[\"Mat\"]=204]=\"Mat\";GenericType[GenericType[\"BoolVec\"]=205]=\"BoolVec\";GenericType[GenericType[\"IntVec\"]=206]=\"IntVec\";GenericType[GenericType[\"UintVec\"]=207]=\"UintVec\";GenericType[GenericType[\"Vec\"]=208]=\"Vec\";GenericType[GenericType[\"GVec4\"]=209]=\"GVec4\";GenericType[GenericType[\"GSampler2D\"]=210]=\"GSampler2D\";GenericType[GenericType[\"GSampler3D\"]=211]=\"GSampler3D\";GenericType[GenericType[\"GSamplerCube\"]=212]=\"GSamplerCube\";GenericType[GenericType[\"GSampler2DArray\"]=213]=\"GSampler2DArray\";return GenericType}({});var _obj;var FamilyMembers=(_obj={},_obj[200]={dimension:0,members:[Keyword.FLOAT,Keyword.VEC2,Keyword.VEC3,Keyword.VEC4]},_obj[201]={dimension:0,members:[Keyword.INT,Keyword.IVEC2,Keyword.IVEC3,Keyword.IVEC4]},_obj[202]={dimension:0,members:[Keyword.UINT,Keyword.UVEC2,Keyword.UVEC3,Keyword.UVEC4]},_obj[203]={dimension:0,members:[Keyword.BOOL,Keyword.BVEC2,Keyword.BVEC3,Keyword.BVEC4]},_obj[208]={dimension:0,members:[Keyword.VEC2,Keyword.VEC3,Keyword.VEC4]},_obj[206]={dimension:0,members:[Keyword.IVEC2,Keyword.IVEC3,Keyword.IVEC4]},_obj[207]={dimension:0,members:[Keyword.UVEC2,Keyword.UVEC3,Keyword.UVEC4]},_obj[205]={dimension:0,members:[Keyword.BVEC2,Keyword.BVEC3,Keyword.BVEC4]},_obj[204]={dimension:0,members:[Keyword.MAT2,Keyword.MAT3,Keyword.MAT4]},_obj[210]={dimension:1,members:[Keyword.SAMPLER2D,Keyword.I_SAMPLER2D,Keyword.U_SAMPLER2D]},_obj[211]={dimension:1,members:[Keyword.SAMPLER3D,Keyword.I_SAMPLER3D,Keyword.U_SAMPLER3D]},_obj[212]={dimension:1,members:[Keyword.SAMPLER_CUBE,Keyword.I_SAMPLER_CUBE,Keyword.U_SAMPLER_CUBE]},_obj[213]={dimension:1,members:[Keyword.SAMPLER2D_ARRAY,Keyword.I_SAMPLER2D_ARRAY,Keyword.U_SAMPLER2D_ARRAY]},_obj[209]={dimension:1,members:[Keyword.VEC4,Keyword.IVEC4,Keyword.UVEC4]},_obj);var BuiltinFunctionTable=new Map;var BuiltinFunction=function(){function BuiltinFunction(ident,returnType,scope){for(var _len=arguments.length,args=new Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){args[_key-3]=arguments[_key]}this.ident=ident;this._returnType=returnType;this.args=args;this.scope=scope}BuiltinFunction._create=function _create(ident,returnType){for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}var fn=_construct(BuiltinFunction,[].concat([ident,returnType,EShaderStage.ALL],args));var _BuiltinFunctionTable_get;var list=(_BuiltinFunctionTable_get=BuiltinFunctionTable.get(ident))!=null?_BuiltinFunctionTable_get:[];list.push(fn);BuiltinFunctionTable.set(ident,list)};BuiltinFunction._createWithScope=function _createWithScope(ident,returnType,scope){for(var _len=arguments.length,args=new Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){args[_key-3]=arguments[_key]}var fn=_construct(BuiltinFunction,[].concat([ident,returnType,scope],args));var _BuiltinFunctionTable_get;var list=(_BuiltinFunctionTable_get=BuiltinFunctionTable.get(ident))!=null?_BuiltinFunctionTable_get:[];list.push(fn);BuiltinFunctionTable.set(ident,list)};BuiltinFunction.resolveOverload=function resolveOverload(funcName,callArgTypes){var overloads=BuiltinFunctionTable.get(funcName);if(!overloads)return undefined;var _callArgTypes_length;var n=(_callArgTypes_length=callArgTypes==null?void 0:callArgTypes.length)!=null?_callArgTypes_length:0;for(var i=0,m=overloads.length;i<m;i++){var candidate=overloads[i];var declaredArgs=candidate.args;if(declaredArgs.length!==n)continue;var sizeLock=-1;var scalarTypeLock=-1;var matched=true;var sizeAmbiguous=false;var scalarTypeAmbiguous=false;for(var j=0;j<n;j++){var declaredType=declaredArgs[j];var actualType=callArgTypes[j];var paramFamily=FamilyMembers[declaredType];if(actualType===TypeAny){if(paramFamily){if(paramFamily.dimension===0)sizeAmbiguous=true;else scalarTypeAmbiguous=true}continue}if(paramFamily){var memberIdx=paramFamily.members.indexOf(actualType);if(memberIdx===-1){matched=false;break}if(paramFamily.dimension===0){if(sizeLock===-1)sizeLock=memberIdx;else if(sizeLock!==memberIdx){matched=false;break}}else{if(scalarTypeLock===-1)scalarTypeLock=memberIdx;else if(scalarTypeLock!==memberIdx){matched=false;break}}}else if(declaredType!==actualType){matched=false;break}}if(!matched)continue;var returnFamily=FamilyMembers[candidate._returnType];if(!returnFamily){candidate._realReturnType=candidate._returnType;return candidate}var returnIsSize=returnFamily.dimension===0;var ambiguous=returnIsSize?sizeAmbiguous:scalarTypeAmbiguous;var returnIdx=returnIsSize?sizeLock:scalarTypeLock;candidate._realReturnType=returnIdx===-1||ambiguous?TypeAny:returnFamily.members[returnIdx];return candidate}return undefined};BuiltinFunction.isExist=function isExist(ident){return BuiltinFunctionTable.has(ident)};_create_class(BuiltinFunction,[{key:\"realReturnType\",get:function get(){return this._realReturnType}}]);return BuiltinFunction}();BuiltinFunction._create(\"radians\",200,200);BuiltinFunction._create(\"degrees\",200,200);BuiltinFunction._create(\"sin\",200,200);BuiltinFunction._create(\"cos\",200,200);BuiltinFunction._create(\"tan\",200,200);BuiltinFunction._create(\"asin\",200,200);BuiltinFunction._create(\"acos\",200,200);BuiltinFunction._create(\"atan\",200,200,200);BuiltinFunction._create(\"atan\",200,200);BuiltinFunction._create(\"sinh\",200,200);BuiltinFunction._create(\"cosh\",200,200);BuiltinFunction._create(\"tanh\",200,200);BuiltinFunction._create(\"asinh\",200,200);BuiltinFunction._create(\"acosh\",200,200);BuiltinFunction._create(\"atanh\",200,200);BuiltinFunction._create(\"pow\",200,200,200);BuiltinFunction._create(\"exp\",200,200);BuiltinFunction._create(\"log\",200,200);BuiltinFunction._create(\"exp2\",200,200);BuiltinFunction._create(\"log2\",200,200);BuiltinFunction._create(\"sqrt\",200,200);BuiltinFunction._create(\"inversesqrt\",200,200);BuiltinFunction._create(\"abs\",200,200);BuiltinFunction._create(\"abs\",201,201);BuiltinFunction._create(\"sign\",200,200);BuiltinFunction._create(\"sign\",201,201);BuiltinFunction._create(\"floor\",200,200);BuiltinFunction._create(\"trunc\",200,200);BuiltinFunction._create(\"round\",200,200);BuiltinFunction._create(\"roundEven\",200,200);BuiltinFunction._create(\"ceil\",200,200);BuiltinFunction._create(\"fract\",200,200);BuiltinFunction._create(\"mod\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"mod\",200,200,200);BuiltinFunction._create(\"min\",200,200,200);BuiltinFunction._create(\"min\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"min\",201,201,201);BuiltinFunction._create(\"min\",201,201,Keyword.INT);BuiltinFunction._create(\"min\",202,202,202);BuiltinFunction._create(\"min\",202,202,Keyword.UINT);BuiltinFunction._create(\"max\",200,200,200);BuiltinFunction._create(\"max\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"max\",201,201,201);BuiltinFunction._create(\"max\",201,201,Keyword.INT);BuiltinFunction._create(\"clamp\",200,200,200,200);BuiltinFunction._create(\"clamp\",200,200,Keyword.FLOAT,Keyword.FLOAT);BuiltinFunction._create(\"clamp\",201,201,201,201);BuiltinFunction._create(\"clamp\",201,201,Keyword.INT,Keyword.INT);BuiltinFunction._create(\"clamp\",202,202,202,202);BuiltinFunction._create(\"clamp\",202,202,Keyword.UINT,Keyword.UINT);BuiltinFunction._create(\"mix\",200,200,200,200);BuiltinFunction._create(\"mix\",200,200,200,Keyword.FLOAT);BuiltinFunction._create(\"mix\",200,200,200,203);BuiltinFunction._create(\"step\",200,200,200);BuiltinFunction._create(\"step\",200,Keyword.FLOAT,200);BuiltinFunction._create(\"smoothstep\",200,200,200,200);BuiltinFunction._create(\"smoothstep\",200,Keyword.FLOAT,Keyword.FLOAT,200);BuiltinFunction._create(\"isnan\",203,200);BuiltinFunction._create(\"isinf\",203,200);BuiltinFunction._create(\"floatBitsToInt\",200,200);BuiltinFunction._create(\"floatBitsToUint\",202,200);BuiltinFunction._create(\"intBitsToFloat\",200,201);BuiltinFunction._create(\"uintBitsToFloat\",200,202);BuiltinFunction._create(\"packSnorm2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackSnorm2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"packUnorm2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackUnorm2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"packHalf2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackHalf2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"length\",Keyword.FLOAT,200);BuiltinFunction._create(\"distance\",Keyword.FLOAT,200,200);BuiltinFunction._create(\"dot\",Keyword.FLOAT,200,200);BuiltinFunction._create(\"cross\",Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"normalize\",200,200);BuiltinFunction._create(\"faceforward\",200,200,200,200);BuiltinFunction._create(\"reflect\",200,200,200);BuiltinFunction._create(\"refract\",200,200,200,Keyword.FLOAT);BuiltinFunction._create(\"matrixCompMult\",204,204,204);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4,Keyword.VEC4,Keyword.VEC4);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2X3,Keyword.VEC3,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3X2,Keyword.VEC2,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2X4,Keyword.VEC4,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4X2,Keyword.VEC2,Keyword.VEC4);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3X4,Keyword.VEC4,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4X3,Keyword.VEC3,Keyword.VEC4);BuiltinFunction._create(\"transpose\",Keyword.MAT2,Keyword.MAT2);BuiltinFunction._create(\"transpose\",Keyword.MAT3,Keyword.MAT3);BuiltinFunction._create(\"transpose\",Keyword.MAT4,Keyword.MAT4);BuiltinFunction._create(\"transpose\",Keyword.MAT2X3,Keyword.MAT3X2);BuiltinFunction._create(\"transpose\",Keyword.MAT3X2,Keyword.MAT2X3);BuiltinFunction._create(\"transpose\",Keyword.MAT4X2,Keyword.MAT2X4);BuiltinFunction._create(\"transpose\",Keyword.MAT2X4,Keyword.MAT4X2);BuiltinFunction._create(\"transpose\",Keyword.MAT3X4,Keyword.MAT4X3);BuiltinFunction._create(\"transpose\",Keyword.MAT4X3,Keyword.MAT3X4);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT2);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT3);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT4);BuiltinFunction._create(\"inverse\",Keyword.MAT2,Keyword.MAT2);BuiltinFunction._create(\"inverse\",Keyword.MAT3,Keyword.MAT3);BuiltinFunction._create(\"inverse\",Keyword.MAT4,Keyword.MAT4);BuiltinFunction._create(\"lessThan\",205,208,208);BuiltinFunction._create(\"lessThan\",205,206,206);BuiltinFunction._create(\"lessThan\",205,207,207);BuiltinFunction._create(\"lessThanEqual\",205,208,208);BuiltinFunction._create(\"lessThanEqual\",205,206,206);BuiltinFunction._create(\"lessThanEqual\",205,207,207);BuiltinFunction._create(\"greaterThan\",205,208,208);BuiltinFunction._create(\"greaterThan\",205,206,206);BuiltinFunction._create(\"greaterThan\",205,207,207);BuiltinFunction._create(\"greaterThanEqual\",205,208,208);BuiltinFunction._create(\"greaterThanEqual\",205,206,206);BuiltinFunction._create(\"greaterThanEqual\",205,207,207);BuiltinFunction._create(\"equal\",205,208,208);BuiltinFunction._create(\"equal\",205,206,206);BuiltinFunction._create(\"equal\",205,207,207);BuiltinFunction._create(\"equal\",205,205,205);BuiltinFunction._create(\"notEqual\",205,208,208);BuiltinFunction._create(\"notEqual\",205,206,206);BuiltinFunction._create(\"notEqual\",205,207,207);BuiltinFunction._create(\"notEqual\",205,205,205);BuiltinFunction._create(\"any\",Keyword.BOOL,205);BuiltinFunction._create(\"all\",Keyword.BOOL,205);BuiltinFunction._create(\"not\",205,205);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,210,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,211,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,212,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,Keyword.SAMPLER2D_SHADOW,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,Keyword.SAMPLER_CUBE_SHADOW,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,213,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.INT);BuiltinFunction._create(\"texture2D\",209,210,Keyword.VEC2);BuiltinFunction._create(\"texture2D\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,210,Keyword.VEC2);BuiltinFunction._create(\"texture\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,211,Keyword.VEC3);BuiltinFunction._create(\"texture\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,212,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"texture\",209,Keyword.SAMPLER2D_ARRAY,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,Keyword.SAMPLER2D_ARRAY,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC3);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",209,211,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,211,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"textureLod\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,213,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLod\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLodEXT\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLodEXT\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCube\",209,212,Keyword.VEC3);BuiltinFunction._create(\"textureCube\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCubeLod\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCubeLodEXT\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,210,Keyword.VEC2,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,210,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureOffset\",209,211,Keyword.VEC3,Keyword.IVEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,211,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"textureOffset\",209,213,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,213,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"texelFetch\",209,210,Keyword.IVEC2,Keyword.INT);BuiltinFunction._create(\"texelFetch\",209,211,Keyword.IVEC3,Keyword.INT);BuiltinFunction._create(\"texelFetch\",209,213,Keyword.IVEC3,Keyword.INT);BuiltinFunction._create(\"texelFetchOffset\",209,210,Keyword.IVEC2,Keyword.INT,Keyword.IVEC2);BuiltinFunction._create(\"texelFetchOffset\",209,211,Keyword.IVEC3,Keyword.INT,Keyword.IVEC3);BuiltinFunction._create(\"texelFetchOffset\",209,213,Keyword.IVEC3,Keyword.INT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC4,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC4,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,211,Keyword.VEC4,Keyword.IVEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,211,Keyword.VEC4,Keyword.IVEC3);BuiltinFunction._create(\"textureProjOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,210,Keyword.VEC2,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,211,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC3);BuiltinFunction._create(\"textureLodOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,213,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLod\",209,210,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",209,210,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",209,211,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLodOffset\",209,210,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLodOffset\",209,210,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLodOffset\",209,211,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC3);BuiltinFunction._create(\"textureProjLodOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureGrad\",209,210,Keyword.VEC2,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",209,211,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",209,212,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",209,213,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGradOffset\",209,210,Keyword.VEC2,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",209,211,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",209,213,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGrad\",209,210,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGrad\",209,210,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGrad\",209,211,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureProjGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,210,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,210,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,211,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureProjGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._createWithScope(\"dFdx\",200,EShaderStage.FRAGMENT,200);BuiltinFunction._createWithScope(\"dFdy\",200,EShaderStage.FRAGMENT,200);BuiltinFunction._createWithScope(\"fwidth\",200,EShaderStage.FRAGMENT,200);var ShaderBuiltinSemantic=function(ShaderBuiltinSemantic){ShaderBuiltinSemantic[\"VertexPosition\"]=\"vertex-position\";ShaderBuiltinSemantic[\"FragmentOutput0\"]=\"fragment-output-0\";ShaderBuiltinSemantic[\"FragmentOutputArray\"]=\"fragment-output-array\";ShaderBuiltinSemantic[\"FragmentDepth\"]=\"fragment-depth\";return ShaderBuiltinSemantic}({});var BuiltinVariableTable=new Map;var BuiltinVariable=function(){function BuiltinVariable(type,lexeme,scope,semantic){this.type=type;this.lexeme=lexeme;this.scope=scope;this.semantic=semantic}BuiltinVariable.createVariable=function createVariable(lexeme,type,scope,semantic){if(scope===void 0)scope=EShaderStage.ALL;var item=new BuiltinVariable(type,lexeme,scope,semantic);BuiltinVariableTable.set(lexeme,item)};BuiltinVariable.getVar=function getVar(ident){return BuiltinVariableTable.get(ident)};return BuiltinVariable}();BuiltinVariable.createVariable(\"gl_VertexID\",Keyword.INT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_InstanceID\",Keyword.INT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_Position\",Keyword.VEC4,EShaderStage.VERTEX,ShaderBuiltinSemantic.VertexPosition);BuiltinVariable.createVariable(\"gl_PointSize\",Keyword.FLOAT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_FragCoord\",Keyword.VEC4,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FrontFacing\",Keyword.BOOL,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FragDepth\",Keyword.FLOAT,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentDepth);BuiltinVariable.createVariable(\"gl_FragDepthEXT\",Keyword.FLOAT,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentDepth);BuiltinVariable.createVariable(\"gl_PointCoord\",Keyword.VEC2,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FragColor\",Keyword.VEC4,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentOutput0);BuiltinVariable.createVariable(\"gl_FragData\",Keyword.VEC4_ARRAY,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentOutputArray);BuiltinVariable.createVariable(\"gl_MaxVertexAttribs\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexUniformVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexOutputVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxFragmentInputVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxCombinedTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxFragmentUniformVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxDrawBuffers\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MinProgramTexelOffset\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxProgramTexelOffset\",Keyword.INT);var SymbolDataType=function SymbolDataType(type,typeLexeme,arraySpecifier,structDeclarations){if(structDeclarations===void 0)structDeclarations=[];this.type=type;this.typeLexeme=typeLexeme;this.arraySpecifier=arraySpecifier;this.structDeclarations=structDeclarations};var ESymbolType=function(ESymbolType){ESymbolType[ESymbolType[\"VAR\"]=0]=\"VAR\";ESymbolType[ESymbolType[\"FN\"]=1]=\"FN\";ESymbolType[ESymbolType[\"STRUCT\"]=2]=\"STRUCT\";ESymbolType[ESymbolType[\"Any\"]=3]=\"Any\";return ESymbolType}({});var SymbolInfo=function(){function SymbolInfo(ident,type,astNode,dataType,paramSignature,isInMacroBranch){if(isInMacroBranch===void 0)isInMacroBranch=false;this.ident=ident;this.type=type;this.astNode=astNode;this.dataType=dataType;this.paramSignature=paramSignature;this.isInMacroBranch=isInMacroBranch;this.sourceScope=0;this.branchSignature=EMPTY_BRANCH}var _proto=SymbolInfo.prototype;_proto.set=function set(ident,symbolType,astNode,dataType,paramSignature){this.ident=ident;this.type=symbolType;this.astNode=astNode;this.dataType=dataType;this.paramSignature=paramSignature};_proto.equal=function equal(symbol){if(symbol.type!==3&&this.type!==symbol.type)return false;if(this.type===1){if(!symbol.astNode&&!symbol.paramSignature)return true;var params=this.astNode.protoType.paramSig;var _symbol_paramSignature;var comparedParams=(_symbol_paramSignature=symbol.paramSignature)!=null?_symbol_paramSignature:symbol.astNode.protoType.paramSig;var length=params==null?void 0:params.length;if(length!==(comparedParams==null?void 0:comparedParams.length))return false;for(var i=0;i<length;i++){var t1=params[i],t2=comparedParams[i];if(t1===TypeAny||t2===TypeAny)continue;if(t1!==t2)return false}return true}return true};return SymbolInfo}();var FnSymbol=function(SymbolInfo){_inherits(FnSymbol,SymbolInfo);function FnSymbol(lexeme,astNode,localVariables,calledFunctions){if(localVariables===void 0)localVariables=[];if(calledFunctions===void 0)calledFunctions=[];var _this;var type=new SymbolDataType(astNode.protoType.returnType.type,astNode.protoType.returnType.typeSpecifier.lexeme,undefined,astNode.protoType.returnType.typeSpecifier.structDeclarations);_this=SymbolInfo.call(this,lexeme,ESymbolType.FN,astNode,type)||this;_this.localVariables=localVariables.slice();_this.calledFunctions=calledFunctions.slice();return _this}return FnSymbol}(SymbolInfo);var StructSymbol=function(SymbolInfo){_inherits(StructSymbol,SymbolInfo);function StructSymbol(lexeme,astNode){return SymbolInfo.call(this,lexeme,ESymbolType.STRUCT,astNode)||this}return StructSymbol}(SymbolInfo);var VarSymbol=function(SymbolInfo){_inherits(VarSymbol,SymbolInfo);function VarSymbol(ident,dataType,isGlobalVariable,initAst,isConst,isUniform){if(isConst===void 0)isConst=false;if(isUniform===void 0)isUniform=false;var _this;_this=SymbolInfo.call(this,ident,ESymbolType.VAR,initAst,dataType)||this;_this.isGlobalVariable=isGlobalVariable;_this.isConst=isConst;_this.isUniform=isUniform;return _this}return VarSymbol}(SymbolInfo);var TypeSystem=function(){function TypeSystem(){}TypeSystem.isAssignable=function isAssignable(target,source){if(target==undefined||source==undefined||target===TypeAny||source===TypeAny)return true;return target===source};TypeSystem.typeName=function typeName(type){if(typeof type===\"string\")return type;if(type==undefined)return\"unknown\";var _Keyword_type;return((_Keyword_type=Keyword[type])!=null?_Keyword_type:String(type)).toLowerCase()};TypeSystem.isSamplerType=function isSamplerType(type){switch(type){case Keyword.SAMPLER2D:case Keyword.SAMPLER3D:case Keyword.SAMPLER_CUBE:case Keyword.SAMPLER2D_SHADOW:case Keyword.SAMPLER_CUBE_SHADOW:case Keyword.SAMPLER2D_ARRAY:case Keyword.SAMPLER2D_ARRAY_SHADOW:case Keyword.I_SAMPLER2D:case Keyword.I_SAMPLER3D:case Keyword.I_SAMPLER_CUBE:case Keyword.I_SAMPLER2D_ARRAY:case Keyword.U_SAMPLER2D:case Keyword.U_SAMPLER3D:case Keyword.U_SAMPLER_CUBE:case Keyword.U_SAMPLER2D_ARRAY:return true;default:return false}};TypeSystem.isBoolType=function isBoolType(type){return type===Keyword.BOOL||type===Keyword.BVEC2||type===Keyword.BVEC3||type===Keyword.BVEC4};TypeSystem.isIntegerType=function isIntegerType(type){switch(type){case Keyword.INT:case Keyword.UINT:case Keyword.IVEC2:case Keyword.IVEC3:case Keyword.IVEC4:case Keyword.UVEC2:case Keyword.UVEC3:case Keyword.UVEC4:return true;default:return false}};TypeSystem.nonArithmeticOperand=function nonArithmeticOperand(type){return type!=undefined&&type!==TypeAny&&(this.isBoolType(type)||this.isSamplerType(type)||typeof type===\"string\")};TypeSystem.isScalarType=function isScalarType(type){return type===Keyword.FLOAT||type===Keyword.INT||type===Keyword.UINT||type===Keyword.BOOL};TypeSystem.arithmeticOperation=function arithmeticOperation(left,right,operator){if(left==undefined||right==undefined||left===TypeAny||right===TypeAny){return{resultType:TypeAny,valid:undefined}}var leftFamily=this._arithmeticFamily(left);var rightFamily=this._arithmeticFamily(right);if(!leftFamily||!rightFamily){return{resultType:TypeAny,valid:false,reason:\"non-arithmetic\"}}if(leftFamily!==rightFamily){return{resultType:TypeAny,valid:false,reason:\"family-mismatch\"}}if(operator===\"%\"&&leftFamily===\"float\"){return{resultType:TypeAny,valid:false,reason:\"integer-required\"}}var leftScalar=this.isScalarType(left);var rightScalar=this.isScalarType(right);if(leftScalar||rightScalar){return{resultType:leftScalar?right:left,valid:true}}var leftVectorSize=this.vectorComponentCount(left);var rightVectorSize=this.vectorComponentCount(right);var leftMatrix=this.matrixDimensions(left);var rightMatrix=this.matrixDimensions(right);if(leftVectorSize&&rightVectorSize){return leftVectorSize===rightVectorSize?{resultType:left,valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(leftMatrix&&rightMatrix){if(operator===\"*\"){return leftMatrix.columns===rightMatrix.rows?{resultType:this._matrixType(rightMatrix.columns,leftMatrix.rows),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}return leftMatrix.columns===rightMatrix.columns&&leftMatrix.rows===rightMatrix.rows?{resultType:left,valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(operator===\"*\"&&leftMatrix&&rightVectorSize){return leftMatrix.columns===rightVectorSize?{resultType:this._vectorType(leftMatrix.rows),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(operator===\"*\"&&leftVectorSize&&rightMatrix){return leftVectorSize===rightMatrix.rows?{resultType:this._vectorType(rightMatrix.columns),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}return{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}};TypeSystem.arithmeticResultType=function arithmeticResultType(a,b,operator){if(operator===void 0)operator=\"+\";return this.arithmeticOperation(a,b,operator).resultType};TypeSystem._arithmeticFamily=function _arithmeticFamily(type){if(typeof type===\"string\"||this.isBoolType(type)||this.isSamplerType(type))return undefined;if(this.matrixDimensions(type))return\"float\";switch(type){case Keyword.FLOAT:case Keyword.VEC2:case Keyword.VEC3:case Keyword.VEC4:return\"float\";case Keyword.INT:case Keyword.IVEC2:case Keyword.IVEC3:case Keyword.IVEC4:return\"int\";case Keyword.UINT:case Keyword.UVEC2:case Keyword.UVEC3:case Keyword.UVEC4:return\"uint\";default:return undefined}};TypeSystem._vectorType=function _vectorType(size){return size===2?Keyword.VEC2:size===3?Keyword.VEC3:size===4?Keyword.VEC4:TypeAny};TypeSystem._matrixType=function _matrixType(columns,rows){var key=\"MAT\"+columns+(columns===rows?\"\":\"X\"+rows);var _Keyword_key;return(_Keyword_key=Keyword[key])!=null?_Keyword_key:TypeAny};TypeSystem.vectorComponentCount=function vectorComponentCount(type){switch(type){case Keyword.VEC2:case Keyword.IVEC2:case Keyword.UVEC2:case Keyword.BVEC2:return 2;case Keyword.VEC3:case Keyword.IVEC3:case Keyword.UVEC3:case Keyword.BVEC3:return 3;case Keyword.VEC4:case Keyword.IVEC4:case Keyword.UVEC4:case Keyword.BVEC4:return 4;default:return 0}};TypeSystem.matrixComponentCount=function matrixComponentCount(type){var dimensions=this.matrixDimensions(type);return dimensions?dimensions.columns*dimensions.rows:0};TypeSystem.matrixDimensions=function matrixDimensions(type){switch(type){case Keyword.MAT2:return{columns:2,rows:2};case Keyword.MAT3:return{columns:3,rows:3};case Keyword.MAT4:return{columns:4,rows:4};case Keyword.MAT2X3:return{columns:2,rows:3};case Keyword.MAT3X2:return{columns:3,rows:2};case Keyword.MAT2X4:return{columns:2,rows:4};case Keyword.MAT4X2:return{columns:4,rows:2};case Keyword.MAT3X4:return{columns:3,rows:4};case Keyword.MAT4X3:return{columns:4,rows:3};default:return undefined}};return TypeSystem}();var ParserUtils=function(){function ParserUtils(){}ParserUtils.unwrapNodeByType=function unwrapNodeByType(node,type){var child=node.children[0];if(_instanceof(child,BaseToken))return;if(child.nt===type)return child;return ParserUtils.unwrapNodeByType(child,type)};ParserUtils.parseMacroParamList=function parseMacroParamList(lexeme){var inner=lexeme.replace(/^\\s*\\(\\s*|\\s*\\)\\s*$/g,\"\");if(!inner)return[];return inner.split(\",\").map(function(s){return s.trim()}).filter(Boolean)};ParserUtils.unwrapBareIdentifier=function unwrapBareIdentifier(node,options){var cur=node;while(true){if(_instanceof(cur,ASTNode.VariableIdentifier))return cur;if(options.allowParens&&_instanceof(cur,ASTNode.PrimaryExpression)&&cur.children.length===3){var inner=cur.children[1];if(!_instanceof(inner,TreeNode))return undefined;cur=inner;continue}if(_instanceof(cur,ASTNode.ExpressionAstNode)&&cur.children.length===1){var child=cur.children[0];if(!_instanceof(child,TreeNode))return undefined;cur=child;continue}return undefined}};ParserUtils.extractDirectIdentLexeme=function extractDirectIdentLexeme(expr){var ident=ParserUtils.unwrapBareIdentifier(expr,{allowParens:true});if(!ident)return null;var child=ident.children[0];return _instanceof(child,BaseToken)?child.lexeme:null};ParserUtils.lastStatement=function lastStatement(node){if(_instanceof(node,ASTNode.Statement)||_instanceof(node,ASTNode.SimpleStatement)||_instanceof(node,ASTNode.CompoundStatement)||_instanceof(node,ASTNode.CompoundStatementNoScope)){if(node.children.length===2)return;for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(!_instanceof(child,TreeNode))continue;var statement=ParserUtils.lastStatement(child);if(statement)return statement}return}if(_instanceof(node,ASTNode.StatementList)){for(var i=node.children.length-1;i>=0;i--){var child1=node.children[i];if(!_instanceof(child1,TreeNode))continue;var statement1=ParserUtils.lastStatement(child1);if(statement1)return statement1}return}return node};ParserUtils.swizzleError=function swizzleError(baseType,swizzle,size){if(size===void 0)size=TypeSystem.vectorComponentCount(baseType);if(size===0)return null;if(swizzle.length<1||swizzle.length>4){return'Invalid swizzle \".'+swizzle+'\": a vector swizzle selects 1-4 components.'}var sets=ParserUtils._swizzleSets;var setIndex=-1;for(var _iterator=_create_for_of_iterator_helper_loose(swizzle),_step;!(_step=_iterator()).done;){var ch=_step.value;var matched=false;for(var s=0;s<sets.length;s++){var idx=sets[s].indexOf(ch);if(idx===-1)continue;if(setIndex===-1)setIndex=s;else if(setIndex!==s)return'Invalid swizzle \".'+swizzle+'\": components must come from one set (xyzw, rgba, or stpq).';if(idx>=size)return'Invalid swizzle \".'+swizzle+\"\\\": component '\"+ch+\"' is out of range for a \"+size+\"-component vector.\";matched=true;break}if(!matched)return'Invalid swizzle \".'+swizzle+\"\\\": '\"+ch+\"' is not a vector component.\"}return null};ParserUtils.constNumericValue=function constNumericValue(node){var cur=node;while(true){if(_instanceof(cur,ASTNode.PrimaryExpression)){if(cur.children.length===3){var inner=cur.children[1];if(!_instanceof(inner,TreeNode))return undefined;cur=inner;continue}var leaf=cur.children[0];if(_instanceof(leaf,BaseToken)&&(leaf.type===ETokenType.INT_CONSTANT||leaf.type===ETokenType.FLOAT_CONSTANT)){var n=Number(leaf.lexeme);return Number.isNaN(n)?undefined:n}return undefined}if(_instanceof(cur,ASTNode.ExpressionAstNode)&&cur.children.length===1){var child=cur.children[0];if(!_instanceof(child,TreeNode))return undefined;cur=child;continue}return undefined}};ParserUtils.constIntegerValue=function constIntegerValue(node){return ParserUtils._constIntegerValue(node,new Set)};ParserUtils._constIntegerValue=function _constIntegerValue(node,resolving){if(_instanceof(node,ASTNode.PrimaryExpression)){if(node.children.length===3){var inner=node.children[1];return _instanceof(inner,TreeNode)?ParserUtils._constIntegerValue(inner,resolving):undefined}var leaf=node.children[0];if(_instanceof(leaf,BaseToken)&&leaf.type===ETokenType.INT_CONSTANT){var value=Number(leaf.lexeme.replace(/[uU]$/,\"\"));return Number.isSafeInteger(value)?ParserUtils._normalizeInteger(value,node.type):undefined}}var ident=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(ident){var child=ident.children[0];if(!_instanceof(child,BaseToken))return;var symbols=ident.resolvedSymbols();if(!symbols.length)return;var resolvedValue;for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;if(!_instanceof(symbol,VarSymbol)||!symbol.isConst||resolving.has(symbol))return;var initializer=ParserUtils._constInitializer(symbol);if(!initializer)return;resolving.add(symbol);var value1=ParserUtils._constIntegerValue(initializer,resolving);resolving.delete(symbol);if(value1===undefined||resolvedValue!==undefined&&resolvedValue!==value1)return;resolvedValue=value1}return resolvedValue}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var fn=node.children[0];if(fn.ident!==\"int\"&&fn.ident!==\"uint\")return;var params=node.children[2];if(!_instanceof(params,ASTNode.FunctionCallParameterList)||params.paramNodes.length!==1)return;var value2=ParserUtils._constIntegerValue(params.paramNodes[0],resolving);return value2===undefined?undefined:ParserUtils._normalizeInteger(value2,node.type)}var children=node.children;var nodeType=_instanceof(node,ASTNode.ExpressionAstNode)?node.type:undefined;if(children.length===1){var child1=children[0];return _instanceof(child1,TreeNode)?ParserUtils._constIntegerValue(child1,resolving):undefined}if(_instanceof(node,ASTNode.ConditionalExpression)&&children.length===5){var condition=children[0];var whenTrue=children[2];var whenFalse=children[4];if(!_instanceof(condition,TreeNode)||!_instanceof(whenTrue,TreeNode)||!_instanceof(whenFalse,TreeNode)){return}var conditionValue=ParserUtils._constIntegerValue(condition,resolving);return conditionValue===undefined?undefined:ParserUtils._constIntegerValue(conditionValue!==0?whenTrue:whenFalse,resolving)}if(children.length===2&&_instanceof(children[1],TreeNode)){var operator=ParserUtils._operatorLexeme(children[0]);var operand=ParserUtils._constIntegerValue(children[1],resolving);if(operator===undefined||operand===undefined)return;var value3;if(operator===\"+\")value3=operand;else if(operator===\"-\")value3=-operand;else if(operator===\"~\")value3=~operand;else if(operator===\"!\")value3=operand===0?1:0;else return;return ParserUtils._normalizeInteger(value3,nodeType)}if(children.length===3&&_instanceof(children[0],TreeNode)&&_instanceof(children[2],TreeNode)){if(_instanceof(node,ASTNode.AssignmentExpression))return;var operator1=ParserUtils._operatorLexeme(children[1]);var left=ParserUtils._constIntegerValue(children[0],resolving);var right=ParserUtils._constIntegerValue(children[2],resolving);if(operator1===undefined||left===undefined||right===undefined)return;var value4;switch(operator1){case\"+\":value4=left+right;break;case\"-\":value4=left-right;break;case\"*\":value4=left*right;break;case\"/\":if(right===0)return;value4=Math.trunc(left/right);break;case\"%\":if(right===0)return;value4=left%right;break;case\"<<\":value4=left<<right;break;case\">>\":value4=nodeType===Keyword.UINT?left>>>right:left>>right;break;case\"&\":value4=left&right;break;case\"^\":value4=left^right;break;case\"|\":value4=left|right;break;case\"&&\":value4=left!==0&&right!==0?1:0;break;case\"^^\":value4=left!==0!==(right!==0)?1:0;break;case\"||\":value4=left!==0||right!==0?1:0;break;case\"<\":value4=left<right?1:0;break;case\">\":value4=left>right?1:0;break;case\"<=\":value4=left<=right?1:0;break;case\">=\":value4=left>=right?1:0;break;case\"==\":value4=left===right?1:0;break;case\"!=\":value4=left!==right?1:0;break;default:return}return ParserUtils._normalizeInteger(value4,nodeType)}return};ParserUtils._constInitializer=function _constInitializer(symbol){var declaration=symbol.astNode;if(_instanceof(declaration,ASTNode.InitDeclaratorList)||_instanceof(declaration,ASTNode.VariableDeclaration)){var _declaration_declarator;return(_declaration_declarator=declaration.declarator)==null?void 0:_declaration_declarator.initializer}return _instanceof(declaration,TreeNode)?declaration:undefined};ParserUtils._operatorLexeme=function _operatorLexeme(node){if(_instanceof(node,BaseToken))return node.lexeme;if(!_instanceof(node,TreeNode))return;for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;var lexeme=ParserUtils._operatorLexeme(child);if(lexeme!==undefined)return lexeme}return};ParserUtils._normalizeInteger=function _normalizeInteger(value,type){return type===Keyword.UINT?value>>>0:value|0};ParserUtils.hasQualifier=function hasQualifier(node,keyword){for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,BaseToken)){if(child.type===keyword)return true}else if(_instanceof(child,TreeNode)&&ParserUtils.hasQualifier(child,keyword)){return true}}return false};ParserUtils.isConstExpr=function isConstExpr(node){if(ParserUtils.constNumericValue(node)!==undefined)return true;if(ParserUtils._isBooleanLiteral(node))return true;var ident=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(ident){var child=ident.children[0];if(_instanceof(child,ASTNode.MacroCallSymbol)||_instanceof(child,ASTNode.MacroCallFunction))return true;if(!_instanceof(child,BaseToken))return false;var symbols=ident.resolvedSymbols();return symbols.length>0&&symbols.every(function(symbol){return _instanceof(symbol,VarSymbol)&&symbol.isConst})}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var fnIdent=node.children[0];var isConstructor=fnIdent.isBuiltin;var isBuiltinFn=typeof fnIdent.ident===\"string\"&&BuiltinFunction.isExist(fnIdent.ident);if(!isConstructor&&!isBuiltinFn)return false;var list=node.children[2];if(!_instanceof(list,ASTNode.FunctionCallParameterList))return true;for(var _iterator=_create_for_of_iterator_helper_loose(list.paramNodes),_step;!(_step=_iterator()).done;){var arg=_step.value;if(_instanceof(arg,TreeNode)&&!ParserUtils.isConstExpr(arg))return false}return true}if(_instanceof(node,ASTNode.ExpressionAstNode)){var sawSubExpr=false;for(var _iterator1=_create_for_of_iterator_helper_loose(node.children),_step1;!(_step1=_iterator1()).done;){var c=_step1.value;if(_instanceof(c,ASTNode.ExpressionAstNode)){sawSubExpr=true;if(!ParserUtils.isConstExpr(c))return false}}return sawSubExpr}return false};ParserUtils._isBooleanLiteral=function _isBooleanLiteral(node){var current=node;while(true){if(_instanceof(current,ASTNode.PrimaryExpression)){if(current.children.length===3){var child=current.children[1];if(!_instanceof(child,TreeNode))return false;current=child;continue}var token=current.children[0];return _instanceof(token,BaseToken)&&(token.type===Keyword.True||token.type===Keyword.False)}if(_instanceof(current,ASTNode.ExpressionAstNode)&¤t.children.length===1){var child1=current.children[0];if(!_instanceof(child1,TreeNode))return false;current=child1;continue}return false}};ParserUtils.firstNonArithmeticOperand=function firstNonArithmeticOperand(a,b){for(var _i=0,_iter=[a,b];_i<_iter.length;_i++){var n=_iter[_i];if(_instanceof(n,ASTNode.ExpressionAstNode)&&TypeSystem.nonArithmeticOperand(n.type))return n}return undefined};ParserUtils.toString=function toString(sm){if(this.isTerminal(sm)){var _ETokenType_sm;return(_ETokenType_sm=ETokenType[sm])!=null?_ETokenType_sm:Keyword[sm]}return NoneTerminal[sm]};ParserUtils.isTerminal=function isTerminal(sm){return sm<NoneTerminal.START};return ParserUtils}();ParserUtils._swizzleSets=[\"xyzw\",\"rgba\",\"stpq\"];var SymbolType=function(SymbolDataType){_inherits(SymbolType,SymbolDataType);function SymbolType(){return SymbolDataType.apply(this,arguments)||this}return SymbolType}(SymbolDataType);var StructProp=function StructProp(typeInfo,ident,mrtIndex,isInMacroBranch,isFlat){if(isInMacroBranch===void 0)isInMacroBranch=false;if(isFlat===void 0)isFlat=false;this.typeInfo=typeInfo;this.ident=ident;this.mrtIndex=mrtIndex;this.isInMacroBranch=isInMacroBranch;this.isFlat=isFlat};var TEXTURE_SAMPLING_BUILTINS=new Set([\"texture\",\"texture2D\",\"texture2DLod\",\"texture2DLodEXT\",\"textureCube\",\"textureCubeLod\",\"textureCubeLodEXT\",\"textureLod\",\"textureOffset\",\"textureProj\",\"textureProjLod\",\"textureProjOffset\",\"textureSize\",\"texelFetch\"]);var EMPTY_FN_SYMBOLS=Object.freeze([]);var EMPTY_STRUCT_DECLARATIONS=Object.freeze([]);var EMPTY_VALUE_SYMBOLS=Object.freeze([]);function ASTNodeDecorator(nonTerminal){return function(ASTNode){ASTNode.prototype.nt=nonTerminal}}var TreeNode=function(){function TreeNode(){this._branch=EMPTY_BRANCH;this._inMacroDefinition=false}var _proto=TreeNode.prototype;_proto.set=function set(loc,children){this._location=loc;this._children=children;this._parent=undefined;var branch=EMPTY_BRANCH;var inheritedBranch=false;var inMacroDefinition=false;for(var _iterator=_create_for_of_iterator_helper_loose(children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,TreeNode)){child._parent=this;if(!inheritedBranch){branch=child._branch;inMacroDefinition=child._inMacroDefinition;inheritedBranch=true}}else if(!inheritedBranch&&_instanceof(child,BaseToken)){branch=child.branch;inMacroDefinition=child.inMacroDefinition;inheritedBranch=true}}this._branch=branch;this._inMacroDefinition=inMacroDefinition;this.init()};_proto.init=function init(){};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.defaultCodeGen(this.children))};_proto.semanticAnalyze=function semanticAnalyze(sa){};_create_class(TreeNode,[{key:\"parent\",get:function get(){return this._parent}},{key:\"children\",get:function get(){return this._children}},{key:\"location\",get:function get(){return this._location}}]);return TreeNode}();(function(ASTNodes){function mergeBranchSignatures(left,right){if(!left.length)return right;if(!right.length)return left;var merged=left.slice();for(var _iterator=_create_for_of_iterator_helper_loose(right),_step;!(_step=_iterator()).done;){var constraint=_step.value;if(merged.indexOf(constraint)===-1)merged.push(constraint)}return merged}function appendMacroReference(references,candidate){var duplicate=references.find(function(reference){return reference.name===candidate.name&&reference.formalParameterIndex===candidate.formalParameterIndex&&reference.unresolved===candidate.unresolved&&reference.branch.length===candidate.branch.length&&reference.branch.every(function(constraint,index){return constraint===candidate.branch[index]})&&reference.replacementMemberOwner===candidate.replacementMemberOwner&&reference.requiresRuntimeOwnerExpansion===candidate.requiresRuntimeOwnerExpansion});if(duplicate){if(candidate.isValueIdentity)duplicate.isValueIdentity=true}else{references.push(candidate)}}function appendSubstitutedValueIdentityReferences(node,template,references,names){var identity=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(!identity)return;var child=identity.children[0];if(_instanceof(child,BaseToken)){appendMacroReference(references,{name:child.lexeme,branch:mergeBranchSignatures(template.branch,identity._branch),isValueIdentity:true});if(names.indexOf(child.lexeme)===-1)names.push(child.lexeme);return}if(!(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)))return;var appendedIdentity=false;for(var _iterator=_create_for_of_iterator_helper_loose(child.referenceSymbols),_step;!(_step=_iterator()).done;){var actualReference=_step.value;if(!actualReference.isValueIdentity)continue;if(actualReference.unresolved){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(template.branch,actualReference.branch),isValueIdentity:true});appendedIdentity=true;continue}if(actualReference.name===undefined)continue;appendMacroReference(references,{name:actualReference.name,branch:mergeBranchSignatures(template.branch,actualReference.branch),isValueIdentity:true});if(names.indexOf(actualReference.name)===-1)names.push(actualReference.name);appendedIdentity=true}if(!appendedIdentity&&!child.visibleHasAstValue&&child.macroName){appendMacroReference(references,{name:child.macroName,branch:mergeBranchSignatures(template.branch,identity._branch),isValueIdentity:true});if(names.indexOf(child.macroName)===-1)names.push(child.macroName)}}function appendSubstitutedOwnerReferences(node,template,references,names){if(template.isValueIdentity){appendSubstitutedValueIdentityReferences(node,template,references,names);return}if(_instanceof(node,VariableIdentifier)){var child=node.children[0];if(_instanceof(child,BaseToken)){appendMacroReference(references,{name:child.lexeme,branch:mergeBranchSignatures(template.branch,node._branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(child.lexeme)===-1)names.push(child.lexeme)}else if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var actualReferences=child.referenceSymbols;for(var _iterator=_create_for_of_iterator_helper_loose(actualReferences),_step;!(_step=_iterator()).done;){var actualReference=_step.value;if(actualReference.unresolved){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(template.branch,actualReference.branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});continue}if(actualReference.name===undefined)continue;appendMacroReference(references,{name:actualReference.name,branch:mergeBranchSignatures(template.branch,actualReference.branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(actualReference.name)===-1)names.push(actualReference.name)}if(!actualReferences.length&&child.macroName){appendMacroReference(references,{name:child.macroName,branch:mergeBranchSignatures(template.branch,node._branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(child.macroName)===-1)names.push(child.macroName)}}return}for(var _iterator1=_create_for_of_iterator_helper_loose(node.children),_step1;!(_step1=_iterator1()).done;){var child1=_step1.value;if(_instanceof(child1,TreeNode))appendSubstitutedOwnerReferences(child1,template,references,names)}}function _unwrapToken(node){if(_instanceof(node,BaseToken)){return node}throw\"not token\"}ASTNodes._unwrapToken=_unwrapToken;function get(type,sa,loc,children){var node=sa.objectPool?sa.objectPool.createNode(type):new type;node.set(loc,children);if(!sa.diagnosticsEnabled){node.semanticAnalyze(sa);sa.semanticStack.push(node);return}var prev=sa.symbolTableStack._currentBranch;var previousMacroDefinition=sa.inMacroDefinition;sa.symbolTableStack._currentBranch=node._branch;sa.inMacroDefinition=node._inMacroDefinition;node.semanticAnalyze(sa);sa.symbolTableStack._currentBranch=prev;sa.inMacroDefinition=previousMacroDefinition;sa.semanticStack.push(node)}ASTNodes.get=get;var TrivialNode=function(TreeNode){_inherits(TrivialNode,TreeNode);function TrivialNode(){return TreeNode.apply(this,arguments)||this}return TrivialNode}(TreeNode);ASTNodes.TrivialNode=TrivialNode;TrivialNode=__decorate([ASTNodeDecorator(NoneTerminal._ignore)],TrivialNode);var ScopeBrace=function(TreeNode){_inherits(ScopeBrace,TreeNode);function ScopeBrace(){return TreeNode.apply(this,arguments)||this}var _proto=ScopeBrace.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.pushScope()};return ScopeBrace}(TreeNode);ASTNodes.ScopeBrace=ScopeBrace;ScopeBrace=__decorate([ASTNodeDecorator(NoneTerminal.scope_brace)],ScopeBrace);var ScopeEndBrace=function(TreeNode){_inherits(ScopeEndBrace,TreeNode);function ScopeEndBrace(){return TreeNode.apply(this,arguments)||this}var _proto=ScopeEndBrace.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.popScope()};return ScopeEndBrace}(TreeNode);ASTNodes.ScopeEndBrace=ScopeEndBrace;ScopeEndBrace=__decorate([ASTNodeDecorator(NoneTerminal.scope_end_brace)],ScopeEndBrace);var JumpStatement=function(TreeNode){_inherits(JumpStatement,TreeNode);function JumpStatement(){return TreeNode.apply(this,arguments)||this}var _proto=JumpStatement.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitJumpStatement(this))};return JumpStatement}(TreeNode);ASTNodes.JumpStatement=JumpStatement;JumpStatement=__decorate([ASTNodeDecorator(NoneTerminal.jump_statement)],JumpStatement);var ConditionOpt=function(TreeNode){_inherits(ConditionOpt,TreeNode);function ConditionOpt(){return TreeNode.apply(this,arguments)||this}return ConditionOpt}(TreeNode);ASTNodes.ConditionOpt=ConditionOpt;ConditionOpt=__decorate([ASTNodeDecorator(NoneTerminal.conditionopt)],ConditionOpt);var ForRestStatement=function(TreeNode){_inherits(ForRestStatement,TreeNode);function ForRestStatement(){return TreeNode.apply(this,arguments)||this}return ForRestStatement}(TreeNode);ASTNodes.ForRestStatement=ForRestStatement;ForRestStatement=__decorate([ASTNodeDecorator(NoneTerminal.for_rest_statement)],ForRestStatement);var Condition=function(TreeNode){_inherits(Condition,TreeNode);function Condition(){return TreeNode.apply(this,arguments)||this}return Condition}(TreeNode);ASTNodes.Condition=Condition;Condition=__decorate([ASTNodeDecorator(NoneTerminal.condition)],Condition);var ForInitStatement=function(TreeNode){_inherits(ForInitStatement,TreeNode);function ForInitStatement(){return TreeNode.apply(this,arguments)||this}return ForInitStatement}(TreeNode);ASTNodes.ForInitStatement=ForInitStatement;ForInitStatement=__decorate([ASTNodeDecorator(NoneTerminal.for_init_statement)],ForInitStatement);var IterationStatement=function(TreeNode){_inherits(IterationStatement,TreeNode);function IterationStatement(){return TreeNode.apply(this,arguments)||this}var _proto=IterationStatement.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(sa.diagnosticsEnabled)sa.popScope()};return IterationStatement}(TreeNode);ASTNodes.IterationStatement=IterationStatement;IterationStatement=__decorate([ASTNodeDecorator(NoneTerminal.iteration_statement)],IterationStatement);var SelectionStatement=function(TreeNode){_inherits(SelectionStatement,TreeNode);function SelectionStatement(){return TreeNode.apply(this,arguments)||this}return SelectionStatement}(TreeNode);ASTNodes.SelectionStatement=SelectionStatement;SelectionStatement=__decorate([ASTNodeDecorator(NoneTerminal.selection_statement)],SelectionStatement);var ExpressionStatement=function(TreeNode){_inherits(ExpressionStatement,TreeNode);function ExpressionStatement(){return TreeNode.apply(this,arguments)||this}return ExpressionStatement}(TreeNode);ASTNodes.ExpressionStatement=ExpressionStatement;ExpressionStatement=__decorate([ASTNodeDecorator(NoneTerminal.expression_statement)],ExpressionStatement);var ExpressionAstNode=function(TreeNode){_inherits(ExpressionAstNode,TreeNode);function ExpressionAstNode(){return TreeNode.apply(this,arguments)||this}var _proto=ExpressionAstNode.prototype;_proto.init=function init(){this._type=undefined};_create_class(ExpressionAstNode,[{key:\"type\",get:function get(){var _this__type;return(_this__type=this._type)!=null?_this__type:TypeAny},set:function set(t){this._type=t}}]);return ExpressionAstNode}(TreeNode);ASTNodes.ExpressionAstNode=ExpressionAstNode;var InitializerList=function(ExpressionAstNode){_inherits(InitializerList,ExpressionAstNode);function InitializerList(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=InitializerList.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var init=this.children[0];this.type=init.type};return InitializerList}(ExpressionAstNode);ASTNodes.InitializerList=InitializerList;InitializerList=__decorate([ASTNodeDecorator(NoneTerminal.initializer_list)],InitializerList);var Initializer=function(ExpressionAstNode){_inherits(Initializer,ExpressionAstNode);function Initializer(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=Initializer.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=this.children[1].type}};return Initializer}(ExpressionAstNode);ASTNodes.Initializer=Initializer;Initializer=__decorate([ASTNodeDecorator(NoneTerminal.initializer)],Initializer);var SingleDeclaration=function(TreeNode){_inherits(SingleDeclaration,TreeNode);function SingleDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=SingleDeclaration.prototype;_proto.init=function init(){this.typeSpecifier=undefined;this.arraySpecifier=undefined;this.isConst=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var childrenLen=children.length;var fullyType=children[0];var typeSpecifier=fullyType.typeSpecifier;this.typeSpecifier=typeSpecifier;this.arraySpecifier=typeSpecifier.arraySpecifier;var id=children[1];var isConst=fullyType.isConst;this.isConst=isConst;var symbolType;var initializer;if(childrenLen===2||childrenLen===4){symbolType=new SymbolType(fullyType.type,typeSpecifier.lexeme,this.arraySpecifier,typeSpecifier.structDeclarations);initializer=children[3]}else{var arraySpecifier=children[2];this.arraySpecifier=arraySpecifier;symbolType=new SymbolType(fullyType.type,typeSpecifier.lexeme,this.arraySpecifier,typeSpecifier.structDeclarations);initializer=children[4]}var sm=sa.assignSourceScope(new VarSymbol(id.lexeme,symbolType,false,initializer,isConst),id.location);this.declarator={identifier:id,typeInfo:symbolType,initializer:initializer,isConst:isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult=sa.symbolTableStack.insert(sm,id.branch);sa.reportRedefinition(id.location,sm,insertResult)};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitSingleDeclaration(this))};return SingleDeclaration}(TreeNode);ASTNodes.SingleDeclaration=SingleDeclaration;SingleDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.single_declaration)],SingleDeclaration);var FullySpecifiedType=function(TreeNode){_inherits(FullySpecifiedType,TreeNode);function FullySpecifiedType(){return TreeNode.apply(this,arguments)||this}var _proto=FullySpecifiedType.prototype;_proto.semanticAnalyze=function semanticAnalyze(_){var children=this.children;this.isConst=children.length===2&&ParserUtils.hasQualifier(children[0],Keyword.CONST);this.typeSpecifier=children.length===1?children[0]:children[1];this.type=this.typeSpecifier.type};return FullySpecifiedType}(TreeNode);ASTNodes.FullySpecifiedType=FullySpecifiedType;FullySpecifiedType=__decorate([ASTNodeDecorator(NoneTerminal.fully_specified_type)],FullySpecifiedType);var TypeQualifier=function(TreeNode){_inherits(TypeQualifier,TreeNode);function TypeQualifier(){return TreeNode.apply(this,arguments)||this}return TypeQualifier}(TreeNode);ASTNodes.TypeQualifier=TypeQualifier;TypeQualifier=__decorate([ASTNodeDecorator(NoneTerminal.type_qualifier)],TypeQualifier);var SingleTypeQualifier=function(TreeNode){_inherits(SingleTypeQualifier,TreeNode);function SingleTypeQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=SingleTypeQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var child=this.children[0];if(_instanceof(child,BaseToken)){this.qualifier=child.type;this.lexeme=child.lexeme}else{this.qualifier=child.qualifier;this.lexeme=child.lexeme}};return SingleTypeQualifier}(TreeNode);ASTNodes.SingleTypeQualifier=SingleTypeQualifier;SingleTypeQualifier=__decorate([ASTNodeDecorator(NoneTerminal.single_type_qualifier)],SingleTypeQualifier);var BasicTypeQualifier=function(TreeNode){_inherits(BasicTypeQualifier,TreeNode);function BasicTypeQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=BasicTypeQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var token=this.children[0];this.qualifier=token.type;this.lexeme=token.lexeme};return BasicTypeQualifier}(TreeNode);var StorageQualifier=function(BasicTypeQualifier){_inherits(StorageQualifier,BasicTypeQualifier);function StorageQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return StorageQualifier}(BasicTypeQualifier);ASTNodes.StorageQualifier=StorageQualifier;StorageQualifier=__decorate([ASTNodeDecorator(NoneTerminal.storage_qualifier)],StorageQualifier);var PrecisionQualifier=function(BasicTypeQualifier){_inherits(PrecisionQualifier,BasicTypeQualifier);function PrecisionQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return PrecisionQualifier}(BasicTypeQualifier);ASTNodes.PrecisionQualifier=PrecisionQualifier;PrecisionQualifier=__decorate([ASTNodeDecorator(NoneTerminal.precision_qualifier)],PrecisionQualifier);var InterpolationQualifier=function(BasicTypeQualifier){_inherits(InterpolationQualifier,BasicTypeQualifier);function InterpolationQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return InterpolationQualifier}(BasicTypeQualifier);ASTNodes.InterpolationQualifier=InterpolationQualifier;InterpolationQualifier=__decorate([ASTNodeDecorator(NoneTerminal.interpolation_qualifier)],InterpolationQualifier);var InvariantQualifier=function(BasicTypeQualifier){_inherits(InvariantQualifier,BasicTypeQualifier);function InvariantQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return InvariantQualifier}(BasicTypeQualifier);ASTNodes.InvariantQualifier=InvariantQualifier;InvariantQualifier=__decorate([ASTNodeDecorator(NoneTerminal.invariant_qualifier)],InvariantQualifier);var TypeSpecifier=function(TreeNode){_inherits(TypeSpecifier,TreeNode);function TypeSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=TypeSpecifier.prototype;_proto.init=function init(){this.arraySize=undefined;this.structDeclarations=EMPTY_STRUCT_DECLARATIONS;this.structDependencies=EMPTY_STRUCT_DECLARATIONS};_proto.semanticAnalyze=function semanticAnalyze(sa){var _children_;var children=this.children;var firstChild=children[0];this.type=firstChild.type;this.lexeme=firstChild.lexeme;this.arraySize=children==null?void 0:(_children_=children[1])==null?void 0:_children_.size;this.isCustom=typeof this.type===\"string\";if(this.isCustom){var lookup=sa.lookupSymbol;lookup.set(this.lexeme,ESymbolType.STRUCT);var structs=sa.symbolTableStack.lookupAll(lookup,true,sa.structScratch,this._branch);this.structDeclarations=structs.length?structs.map(function(symbol){return symbol.astNode}):EMPTY_STRUCT_DECLARATIONS;this.structDependencies=this.structDeclarations}else if(_instanceof(firstChild.children[0],MacroCallSymbol)){var dependencies=[];for(var _iterator=_create_for_of_iterator_helper_loose(firstChild.children[0].referenceSymbols),_step;!(_step=_iterator()).done;){var reference=_step.value;if(!reference.name)continue;sa.lookupSymbol.set(reference.name,ESymbolType.STRUCT);var symbols=sa.symbolTableStack.lookupAll(sa.lookupSymbol,true,sa.structScratch,reference.branch);for(var _iterator1=_create_for_of_iterator_helper_loose(symbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;var declaration=symbol.astNode;if(!dependencies.includes(declaration))dependencies.push(declaration)}}if(dependencies.length)this.structDependencies=dependencies}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitTypeSpecifier(this))};_create_class(TypeSpecifier,[{key:\"arraySpecifier\",get:function get(){return this.children[1]}}]);return TypeSpecifier}(TreeNode);ASTNodes.TypeSpecifier=TypeSpecifier;TypeSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.type_specifier)],TypeSpecifier);var ArraySpecifier=function(TreeNode){_inherits(ArraySpecifier,TreeNode);function ArraySpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=ArraySpecifier.prototype;_proto.init=function init(){this.size=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var integerConstantExpr=this.children[1];if(!_instanceof(integerConstantExpr,IntegerConstantExpression))return;this.size=integerConstantExpr.value;var exprChildren=integerConstantExpr.children;if(this.size===undefined&&exprChildren.length===1&&_instanceof(exprChildren[0],VariableIdentifier)){var bare=exprChildren[0].children[0];if(_instanceof(bare,BaseToken)&&!sa.macroDefineList[bare.lexeme]){var lookup=sa.lookupSymbol;lookup.set(bare.lexeme,ESymbolType.VAR);var symbols=sa.symbolTableStack.lookupAll(lookup,true,sa.arraySymbolScratch,this._branch);if(!symbols.length)return;var firstIsConst=symbols[0].isConst;var divergent=symbols.some(function(symbol){return symbol.isConst!==firstIsConst});if(divergent){sa.reportBranchAmbiguity(exprChildren[0].location,bare.lexeme,\"const-qualification\",bare.lexeme)}else if(!firstIsConst){sa.reportNonConstArraySize(exprChildren[0].location)}}}};return ArraySpecifier}(TreeNode);ASTNodes.ArraySpecifier=ArraySpecifier;ArraySpecifier=__decorate([ASTNodeDecorator(NoneTerminal.array_specifier)],ArraySpecifier);var IntegerConstantExpressionOperator=function(TreeNode){_inherits(IntegerConstantExpressionOperator,TreeNode);function IntegerConstantExpressionOperator(){return TreeNode.apply(this,arguments)||this}var _proto=IntegerConstantExpressionOperator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var operator=this.children[0];this.lexeme=operator.lexeme;switch(operator.type){case ETokenType.PLUS:this.compute=function(a,b){return a+b};break;case ETokenType.DASH:this.compute=function(a,b){return a-b};break;case ETokenType.STAR:this.compute=function(a,b){return a*b};break;case ETokenType.SLASH:this.compute=function(a,b){return a/b};break;case ETokenType.PERCENT:this.compute=function(a,b){return a%b};break}};return IntegerConstantExpressionOperator}(TreeNode);ASTNodes.IntegerConstantExpressionOperator=IntegerConstantExpressionOperator;IntegerConstantExpressionOperator=__decorate([ASTNodeDecorator(NoneTerminal.integer_constant_expression_operator)],IntegerConstantExpressionOperator);var IntegerConstantExpression=function(TreeNode){_inherits(IntegerConstantExpression,TreeNode);function IntegerConstantExpression(){return TreeNode.apply(this,arguments)||this}var _proto=IntegerConstantExpression.prototype;_proto.init=function init(){this.value=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var child=this.children[0];if(_instanceof(child,BaseToken)){this.value=Number(child.lexeme)}}};return IntegerConstantExpression}(TreeNode);ASTNodes.IntegerConstantExpression=IntegerConstantExpression;IntegerConstantExpression=__decorate([ASTNodeDecorator(NoneTerminal.integer_constant_expression)],IntegerConstantExpression);var TypeSpecifierNonArray=function(TreeNode){_inherits(TypeSpecifierNonArray,TreeNode);function TypeSpecifierNonArray(){return TreeNode.apply(this,arguments)||this}var _proto=TypeSpecifierNonArray.prototype;_proto.init=function init(){var tt=this.children[0];if(_instanceof(tt,BaseToken)){this.type=tt.lexeme;this.lexeme=tt.lexeme}else if(_instanceof(tt,MacroCallSymbol)){this.type=TypeAny;this.lexeme=tt.macroName}else{this.type=tt.type;this.lexeme=tt.lexeme}};return TypeSpecifierNonArray}(TreeNode);ASTNodes.TypeSpecifierNonArray=TypeSpecifierNonArray;TypeSpecifierNonArray=__decorate([ASTNodeDecorator(NoneTerminal.type_specifier_nonarray)],TypeSpecifierNonArray);var ExtBuiltinTypeSpecifierNonArray=function(TreeNode){_inherits(ExtBuiltinTypeSpecifierNonArray,TreeNode);function ExtBuiltinTypeSpecifierNonArray(){return TreeNode.apply(this,arguments)||this}var _proto=ExtBuiltinTypeSpecifierNonArray.prototype;_proto.init=function init(){var token=this.children[0];this.type=token.type;this.lexeme=token.lexeme};return ExtBuiltinTypeSpecifierNonArray}(TreeNode);ASTNodes.ExtBuiltinTypeSpecifierNonArray=ExtBuiltinTypeSpecifierNonArray;ExtBuiltinTypeSpecifierNonArray=__decorate([ASTNodeDecorator(NoneTerminal.ext_builtin_type_specifier_nonarray)],ExtBuiltinTypeSpecifierNonArray);var InitDeclaratorList=function(TreeNode){_inherits(InitDeclaratorList,TreeNode);function InitDeclaratorList(){return TreeNode.apply(this,arguments)||this}var _proto=InitDeclaratorList.prototype;_proto.init=function init(){this.isConst=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var sm;var children=this.children;var childrenLength=children.length;if(childrenLength===1){var _children_=children[0],typeSpecifier=_children_.typeSpecifier,arraySpecifier=_children_.arraySpecifier,isConst=_children_.isConst;this.typeInfo=new SymbolType(typeSpecifier.type,typeSpecifier.lexeme,arraySpecifier,typeSpecifier.structDeclarations);this.isConst=isConst}else{var initDeclList=children[0];this.typeInfo=initDeclList.typeInfo;this.isConst=initDeclList.isConst}if(childrenLength===3||childrenLength===5){var id=children[2];var initializer=childrenLength===5?children[4]:undefined;var typeInfo=new SymbolType(this.typeInfo.type,this.typeInfo.typeLexeme,undefined,this.typeInfo.structDeclarations);sm=sa.assignSourceScope(new VarSymbol(id.lexeme,typeInfo,false,this,this.isConst),id.location);this.declarator={identifier:id,typeInfo:typeInfo,initializer:initializer,isConst:this.isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult=sa.symbolTableStack.insert(sm,id.branch);sa.reportRedefinition(id.location,sm,insertResult)}else if(childrenLength===4||childrenLength===6){var typeInfo1=new SymbolType(this.typeInfo.type,this.typeInfo.typeLexeme,undefined,this.typeInfo.structDeclarations);var arraySpecifier1=this.children[3];typeInfo1.arraySpecifier=arraySpecifier1;var id1=children[2];var initializer1=childrenLength===6?children[5]:undefined;sm=sa.assignSourceScope(new VarSymbol(id1.lexeme,typeInfo1,false,this,this.isConst),id1.location);this.declarator={identifier:id1,typeInfo:typeInfo1,initializer:initializer1,isConst:this.isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult1=sa.symbolTableStack.insert(sm,id1.branch);sa.reportRedefinition(id1.location,sm,insertResult1)}};return InitDeclaratorList}(TreeNode);ASTNodes.InitDeclaratorList=InitDeclaratorList;InitDeclaratorList=__decorate([ASTNodeDecorator(NoneTerminal.init_declarator_list)],InitDeclaratorList);var IdentifierList=function(TreeNode){_inherits(IdentifierList,TreeNode);function IdentifierList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.idList=[];return _this}var _proto=IdentifierList.prototype;_proto.init=function init(){this.idList.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,curIdList=_this.idList;if(children.length===2){curIdList.push(children[1])}else{var list=children[0];var id=children[2];var listIdLength=list.idList.length;curIdList.length=listIdLength+1;for(var i=0;i<listIdLength;i++){curIdList[i]=list.idList[i]}curIdList[listIdLength]=id}};return IdentifierList}(TreeNode);ASTNodes.IdentifierList=IdentifierList;IdentifierList=__decorate([ASTNodeDecorator(NoneTerminal.identifier_list)],IdentifierList);var Declaration=function(TreeNode){_inherits(Declaration,TreeNode);function Declaration(){return TreeNode.apply(this,arguments)||this}var _proto=Declaration.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(_instanceof(this.children[0],FunctionProtoType)){sa.popScope();sa.endFunction()}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitDeclaration(this))};return Declaration}(TreeNode);ASTNodes.Declaration=Declaration;Declaration=__decorate([ASTNodeDecorator(NoneTerminal.declaration)],Declaration);var FunctionProtoType=function(TreeNode){_inherits(FunctionProtoType,TreeNode);function FunctionProtoType(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionProtoType.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var declarator=this.children[0];this.ident=declarator.ident;this.returnType=declarator.returnType;this.parameterList=declarator.parameterInfoList;this.paramSig=declarator.paramSig};return FunctionProtoType}(TreeNode);ASTNodes.FunctionProtoType=FunctionProtoType;FunctionProtoType=__decorate([ASTNodeDecorator(NoneTerminal.function_prototype)],FunctionProtoType);var FunctionDeclarator=function(TreeNode){_inherits(FunctionDeclarator,TreeNode);function FunctionDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionDeclarator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var header=children[0];var parameterList=children[1];this.ident=header.ident;this.returnType=header.returnType;this.parameterInfoList=parameterList==null?void 0:parameterList.parameterInfoList;this.paramSig=parameterList==null?void 0:parameterList.paramSig;sa.beginFunction(this)};return FunctionDeclarator}(TreeNode);ASTNodes.FunctionDeclarator=FunctionDeclarator;FunctionDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.function_declarator)],FunctionDeclarator);var FunctionHeader=function(TreeNode){_inherits(FunctionHeader,TreeNode);function FunctionHeader(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionHeader.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.pushScope();var children=this.children;this.ident=children[1];this.returnType=children[0]};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionHeader(this))};return FunctionHeader}(TreeNode);ASTNodes.FunctionHeader=FunctionHeader;FunctionHeader=__decorate([ASTNodeDecorator(NoneTerminal.function_header)],FunctionHeader);var FunctionParameterList=function(TreeNode){_inherits(FunctionParameterList,TreeNode);function FunctionParameterList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.parameterInfoList=[],_this.paramSig=[];return _this}var _proto=FunctionParameterList.prototype;_proto.init=function init(){this.parameterInfoList.length=0;this.paramSig.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var _this=this,parameterInfoList=_this.parameterInfoList,paramSig=_this.paramSig;if(_instanceof(children[0],ParameterDeclaration)){var _decl_typeInfo;var decl=children[0];parameterInfoList.push({ident:decl.ident,typeInfo:decl.typeInfo,astNode:decl});var _decl_typeInfo_type;paramSig.push((_decl_typeInfo_type=(_decl_typeInfo=decl.typeInfo)==null?void 0:_decl_typeInfo.type)!=null?_decl_typeInfo_type:TypeAny)}else if(_instanceof(children[2],ParameterDeclaration)){var _parameterInfoList,_paramSig;var _decl_typeInfo1;var list=children[0];var decl1=children[2];(_parameterInfoList=parameterInfoList).push.apply(_parameterInfoList,[].concat(list.parameterInfoList,[{ident:decl1.ident,typeInfo:decl1.typeInfo,astNode:decl1}]));var _decl_typeInfo_type1;(_paramSig=paramSig).push.apply(_paramSig,[].concat(list.paramSig,[(_decl_typeInfo_type1=(_decl_typeInfo1=decl1.typeInfo)==null?void 0:_decl_typeInfo1.type)!=null?_decl_typeInfo_type1:TypeAny]))}else if(_instanceof(children[0],FunctionParameterList)&&_instanceof(children[1],MacroParamBlock)){var _parameterInfoList1,_paramSig1;(_parameterInfoList1=parameterInfoList).push.apply(_parameterInfoList1,[].concat(children[0].parameterInfoList,[{astNode:children[1]}]));(_paramSig1=paramSig).push.apply(_paramSig1,[].concat(children[0].paramSig,[TypeAny]))}else if(_instanceof(children[0],MacroParamBlock)){parameterInfoList.push({astNode:children[0]});paramSig.push(TypeAny)}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionParameterList(this))};return FunctionParameterList}(TreeNode);ASTNodes.FunctionParameterList=FunctionParameterList;FunctionParameterList=__decorate([ASTNodeDecorator(NoneTerminal.function_parameter_list)],FunctionParameterList);var MacroParamCaseList=function(TreeNode){_inherits(MacroParamCaseList,TreeNode);function MacroParamCaseList(){return TreeNode.apply(this,arguments)||this}return MacroParamCaseList}(TreeNode);ASTNodes.MacroParamCaseList=MacroParamCaseList;MacroParamCaseList=__decorate([ASTNodeDecorator(NoneTerminal.macro_param_case_list)],MacroParamCaseList);var MacroParamBlock=function(TreeNode){_inherits(MacroParamBlock,TreeNode);function MacroParamBlock(){return TreeNode.apply(this,arguments)||this}return MacroParamBlock}(TreeNode);ASTNodes.MacroParamBlock=MacroParamBlock;MacroParamBlock=__decorate([ASTNodeDecorator(NoneTerminal.macro_param_block)],MacroParamBlock);var MacroParameterBranch=function(TreeNode){_inherits(MacroParameterBranch,TreeNode);function MacroParameterBranch(){return TreeNode.apply(this,arguments)||this}return MacroParameterBranch}(TreeNode);ASTNodes.MacroParameterBranch=MacroParameterBranch;MacroParameterBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_parameter_branch)],MacroParameterBranch);var ParameterDeclaration=function(TreeNode){_inherits(ParameterDeclaration,TreeNode);function ParameterDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=ParameterDeclaration.prototype;_proto.init=function init(){this.typeInfo=undefined;this.ident=undefined;this.symbol=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var parameterDeclarator;if(_instanceof(children[0],ParameterDeclarator)){parameterDeclarator=children[0]}else if(_instanceof(children[1],ParameterDeclarator)){parameterDeclarator=children[1]}if(parameterDeclarator){this.typeInfo=parameterDeclarator.typeInfo;this.ident=parameterDeclarator.ident;var varSymbol=new VarSymbol(parameterDeclarator.ident.lexeme,parameterDeclarator.typeInfo,false,parameterDeclarator);this.symbol=varSymbol;sa.symbolTableStack.insert(varSymbol,parameterDeclarator.ident.branch)}};return ParameterDeclaration}(TreeNode);ASTNodes.ParameterDeclaration=ParameterDeclaration;ParameterDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.parameter_declaration)],ParameterDeclaration);var ParameterDeclarator=function(TreeNode){_inherits(ParameterDeclarator,TreeNode);function ParameterDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=ParameterDeclarator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.ident=children[1];var typeSpecifier=children[0];var arraySpecifier=children[2];this.typeInfo=new SymbolType(typeSpecifier.type,typeSpecifier.lexeme,arraySpecifier,typeSpecifier.structDeclarations)};return ParameterDeclarator}(TreeNode);ASTNodes.ParameterDeclarator=ParameterDeclarator;ParameterDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.parameter_declarator)],ParameterDeclarator);var SimpleStatement=function(TreeNode){_inherits(SimpleStatement,TreeNode);function SimpleStatement(){return TreeNode.apply(this,arguments)||this}return SimpleStatement}(TreeNode);ASTNodes.SimpleStatement=SimpleStatement;SimpleStatement=__decorate([ASTNodeDecorator(NoneTerminal.simple_statement)],SimpleStatement);var CompoundStatement=function(TreeNode){_inherits(CompoundStatement,TreeNode);function CompoundStatement(){return TreeNode.apply(this,arguments)||this}return CompoundStatement}(TreeNode);ASTNodes.CompoundStatement=CompoundStatement;CompoundStatement=__decorate([ASTNodeDecorator(NoneTerminal.compound_statement)],CompoundStatement);var CompoundStatementNoScope=function(TreeNode){_inherits(CompoundStatementNoScope,TreeNode);function CompoundStatementNoScope(){return TreeNode.apply(this,arguments)||this}return CompoundStatementNoScope}(TreeNode);ASTNodes.CompoundStatementNoScope=CompoundStatementNoScope;CompoundStatementNoScope=__decorate([ASTNodeDecorator(NoneTerminal.compound_statement_no_scope)],CompoundStatementNoScope);var Statement=function(TreeNode){_inherits(Statement,TreeNode);function Statement(){return TreeNode.apply(this,arguments)||this}return Statement}(TreeNode);ASTNodes.Statement=Statement;Statement=__decorate([ASTNodeDecorator(NoneTerminal.statement)],Statement);var StatementList=function(TreeNode){_inherits(StatementList,TreeNode);function StatementList(){return TreeNode.apply(this,arguments)||this}var _proto=StatementList.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitStatementList(this))};return StatementList}(TreeNode);ASTNodes.StatementList=StatementList;StatementList=__decorate([ASTNodeDecorator(NoneTerminal.statement_list)],StatementList);var FunctionDefinition=function(TreeNode){_inherits(FunctionDefinition,TreeNode);function FunctionDefinition(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionDefinition.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.protoType=children[0];this.statements=children[1];sa.popScope();var capture=sa.endFunction();var sm=sa.assignSourceScope(new FnSymbol(this.protoType.ident.lexeme,this,capture.localVariables,capture.calledFunctions),this.protoType.ident.location);var existing=this.protoType.ident.branch.length===0?sa.symbolTableStack.lookup(sm):undefined;var unconditionalDuplicate=existing&&existing.sourceScope===sm.sourceScope;var conflict=unconditionalDuplicate?\"coexist\":sa.symbolTableStack.insert(sm,this.protoType.ident.branch);sa.reportRedefinition(this.protoType.ident.location,sm,conflict);this.isInMacroBranch=sa.symbolTableStack.isInMacroBranch};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionDefinition(this))};return FunctionDefinition}(TreeNode);ASTNodes.FunctionDefinition=FunctionDefinition;FunctionDefinition=__decorate([ASTNodeDecorator(NoneTerminal.function_definition)],FunctionDefinition);var FunctionCall=function(ExpressionAstNode){_inherits(FunctionCall,ExpressionAstNode);function FunctionCall(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=FunctionCall.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.type=this.children[0].type};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionCall(this))};return FunctionCall}(ExpressionAstNode);ASTNodes.FunctionCall=FunctionCall;FunctionCall=__decorate([ASTNodeDecorator(NoneTerminal.function_call)],FunctionCall);var FunctionCallGeneric=function(ExpressionAstNode){_inherits(FunctionCallGeneric,ExpressionAstNode);function FunctionCallGeneric(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=FunctionCallGeneric.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);this.fnSymbol=undefined;this.fnSymbols=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var functionIdentifier=this.children[0];if(functionIdentifier.isBuiltin){this.type=functionIdentifier.ident}else{var _fnSymbol_dataType;var fnIdent=functionIdentifier.ident;var paramSig;if(this.children.length===4){var paramList=this.children[2];if(_instanceof(paramList,FunctionCallParameterList)){paramSig=paramList.paramSig}}if(sa.diagnosticsEnabled){var _header_ident,_fnSymbol_dataType1;var header=sa.currentFunctionHeader;if((header==null?void 0:(_header_ident=header.ident)==null?void 0:_header_ident.lexeme)===fnIdent){var _header_paramSig;var hSig=(_header_paramSig=header.paramSig)!=null?_header_paramSig:[];var cSig=paramSig!=null?paramSig:[];if(hSig.length===cSig.length&&hSig.every(function(t,i){return t===cSig[i]})){return}}if(TEXTURE_SAMPLING_BUILTINS.has(fnIdent)){var arg0=paramSig==null?void 0:paramSig[0];if(arg0!==undefined&&arg0!==TypeAny&&!TypeSystem.isSamplerType(arg0)){sa.reportExpectedSampler(this.location,fnIdent,arg0);return}}var builtinFn=BuiltinFunction.resolveOverload(fnIdent,paramSig);if(builtinFn){this.type=builtinFn.realReturnType;return}var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(fnIdent,ESymbolType.FN,undefined,undefined,paramSig);var allMatches=sa.overloadScratch;sa.symbolTableStack.lookupAll(lookupSymbol,true,allMatches,this._branch);var branchCoverage=sa.getBranchCoverage(allMatches.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),this._branch);var branchCovered=branchCoverage===\"covered\"||FunctionCallGeneric._hasConflictingBranches(sa,allMatches);var fnSymbol=branchCovered?allMatches[0]:undefined;var overloadTypeAmbiguous=false;if(fnSymbol&&(paramSig==null?void 0:paramSig.some(function(t){return t===TypeAny}))){if(allMatches.length>1){var _allMatches__dataType;var firstType=(_allMatches__dataType=allMatches[0].dataType)==null?void 0:_allMatches__dataType.type;overloadTypeAmbiguous=allMatches.some(function(s){var _s_dataType;return((_s_dataType=s.dataType)==null?void 0:_s_dataType.type)!==firstType})}}if(!fnSymbol){var codegenFn=sa.symbolTableStack.lookup(lookupSymbol,true);if(codegenFn){this.fnSymbol=codegenFn;sa.recordFunctionCall(codegenFn)}if(allMatches.length){sa.reportBranchAvailability(this.location,\"Function\",fnIdent,branchCoverage);return}lookupSymbol.set(fnIdent,ESymbolType.FN);var nameDeclared=sa.symbolTableStack.lookupAll(lookupSymbol,true,allMatches,this._branch).length>0||BuiltinFunction.isExist(fnIdent);if(nameDeclared){sa.reportNoMatchingOverload(this.location,fnIdent)}return}this.type=overloadTypeAmbiguous?TypeAny:fnSymbol==null?void 0:(_fnSymbol_dataType1=fnSymbol.dataType)==null?void 0:_fnSymbol_dataType1.type;this.fnSymbol=fnSymbol;if(allMatches.length>1){var first=allMatches[0];this.fnSymbols=allMatches.every(function(candidate){return FunctionCallGeneric._hasSameParameterSignature(first,candidate)})?allMatches.slice():EMPTY_FN_SYMBOLS}if(this.fnSymbols!==undefined){for(var _iterator=_create_for_of_iterator_helper_loose(this.fnSymbols),_step;!(_step=_iterator()).done;){var candidate=_step.value;sa.recordFunctionCall(candidate)}}else if(_instanceof(fnSymbol,FnSymbol)){sa.recordFunctionCall(fnSymbol)}return}var lookupSymbol1=sa.lookupSymbol;lookupSymbol1.set(fnIdent,ESymbolType.FN,undefined,undefined,paramSig);var fnSymbol1=sa.symbolTableStack.lookup(lookupSymbol1,true);if(!fnSymbol1)return;this.type=(_fnSymbol_dataType=fnSymbol1.dataType)==null?void 0:_fnSymbol_dataType.type;this.fnSymbol=fnSymbol1;if(_instanceof(fnSymbol1,FnSymbol))sa.recordFunctionCall(fnSymbol1)}};FunctionCallGeneric._hasConflictingBranches=function _hasConflictingBranches(sa,symbols){for(var i=0,n=symbols.length;i<n;i++){for(var j=i+1;j<n;j++){var left=symbols[i];var right=symbols[j];var _left_branchSignature,_right_branchSignature;if(FunctionCallGeneric._hasSameParameterSignature(left,right)&&sa.canDeclarationsCoexist((_left_branchSignature=left.branchSignature)!=null?_left_branchSignature:EMPTY_BRANCH,(_right_branchSignature=right.branchSignature)!=null?_right_branchSignature:EMPTY_BRANCH)){return true}}}return false};FunctionCallGeneric._hasSameParameterSignature=function _hasSameParameterSignature(left,right){var _left_astNode_protoType_paramSig;var leftSignature=(_left_astNode_protoType_paramSig=left.astNode.protoType.paramSig)!=null?_left_astNode_protoType_paramSig:[];var _right_astNode_protoType_paramSig;var rightSignature=(_right_astNode_protoType_paramSig=right.astNode.protoType.paramSig)!=null?_right_astNode_protoType_paramSig:[];return leftSignature.length===rightSignature.length&&leftSignature.every(function(type,index){return type===rightSignature[index]})};return FunctionCallGeneric}(ExpressionAstNode);ASTNodes.FunctionCallGeneric=FunctionCallGeneric;FunctionCallGeneric=__decorate([ASTNodeDecorator(NoneTerminal.function_call_generic)],FunctionCallGeneric);var FunctionCallParameterList=function(TreeNode){_inherits(FunctionCallParameterList,TreeNode);function FunctionCallParameterList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.paramSig=[],_this.paramNodes=[];return _this}var _proto=FunctionCallParameterList.prototype;_proto.init=function init(){this.paramSig.length=0;this.paramNodes.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,paramSig=_this.paramSig,paramNodes=_this.paramNodes;if(_instanceof(children[0],AssignmentExpression)){var expr=children[0];paramSig.push(expr.type);paramNodes.push(expr)}else if(_instanceof(children[2],AssignmentExpression)){var _paramSig,_paramNodes;var list=children[0];var decl=children[2];(_paramSig=paramSig).push.apply(_paramSig,[].concat(list.paramSig,[decl.type]));(_paramNodes=paramNodes).push.apply(_paramNodes,[].concat(list.paramNodes,[decl]))}else if(_instanceof(children[0],FunctionCallParameterList)&&_instanceof(children[1],MacroCallArgBlock)){var _paramSig1,_paramNodes1;(_paramSig1=paramSig).push.apply(_paramSig1,[].concat(children[0].paramSig,[TypeAny]));(_paramNodes1=paramNodes).push.apply(_paramNodes1,[].concat(children[0].paramNodes,[children[1]]))}else if(_instanceof(children[0],MacroCallArgBlock)){paramSig.push(TypeAny);paramNodes.push(children[0])}};return FunctionCallParameterList}(TreeNode);ASTNodes.FunctionCallParameterList=FunctionCallParameterList;FunctionCallParameterList=__decorate([ASTNodeDecorator(NoneTerminal.function_call_parameter_list)],FunctionCallParameterList);var MacroCallArgCaseList=function(TreeNode){_inherits(MacroCallArgCaseList,TreeNode);function MacroCallArgCaseList(){return TreeNode.apply(this,arguments)||this}return MacroCallArgCaseList}(TreeNode);ASTNodes.MacroCallArgCaseList=MacroCallArgCaseList;MacroCallArgCaseList=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_case_list)],MacroCallArgCaseList);var MacroCallArgBlock=function(TreeNode){_inherits(MacroCallArgBlock,TreeNode);function MacroCallArgBlock(){return TreeNode.apply(this,arguments)||this}return MacroCallArgBlock}(TreeNode);ASTNodes.MacroCallArgBlock=MacroCallArgBlock;MacroCallArgBlock=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_block)],MacroCallArgBlock);var MacroCallArgBranch=function(TreeNode){_inherits(MacroCallArgBranch,TreeNode);function MacroCallArgBranch(){return TreeNode.apply(this,arguments)||this}return MacroCallArgBranch}(TreeNode);ASTNodes.MacroCallArgBranch=MacroCallArgBranch;MacroCallArgBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_branch)],MacroCallArgBranch);var PrecisionSpecifier=function(TreeNode){_inherits(PrecisionSpecifier,TreeNode);function PrecisionSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=PrecisionSpecifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(!sa.symbolTableStack.isInMacroBranch){sa.shaderData.globalPrecisions.push(this)}};return PrecisionSpecifier}(TreeNode);ASTNodes.PrecisionSpecifier=PrecisionSpecifier;PrecisionSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.precision_specifier)],PrecisionSpecifier);var FunctionIdentifier=function(TreeNode){_inherits(FunctionIdentifier,TreeNode);function FunctionIdentifier(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionIdentifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var typeSpecifier=this.children[0];this.ident=typeSpecifier.type;this.lexeme=typeSpecifier.lexeme;this.isBuiltin=typeof this.ident!==\"string\"};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionIdentifier(this))};return FunctionIdentifier}(TreeNode);ASTNodes.FunctionIdentifier=FunctionIdentifier;FunctionIdentifier=__decorate([ASTNodeDecorator(NoneTerminal.function_identifier)],FunctionIdentifier);var AssignmentExpression=function(ExpressionAstNode){_inherits(AssignmentExpression,ExpressionAstNode);function AssignmentExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AssignmentExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var expr=this.children[0];var _expr_type;this.type=(_expr_type=expr.type)!=null?_expr_type:TypeAny}else{var rhs=this.children[2];var _rhs_type;this.type=(_rhs_type=rhs.type)!=null?_rhs_type:TypeAny}};return AssignmentExpression}(ExpressionAstNode);ASTNodes.AssignmentExpression=AssignmentExpression;AssignmentExpression=__decorate([ASTNodeDecorator(NoneTerminal.assignment_expression)],AssignmentExpression);var AssignmentOperator=function(TreeNode){_inherits(AssignmentOperator,TreeNode);function AssignmentOperator(){return TreeNode.apply(this,arguments)||this}return AssignmentOperator}(TreeNode);ASTNodes.AssignmentOperator=AssignmentOperator;AssignmentOperator=__decorate([ASTNodeDecorator(NoneTerminal.assignment_operator)],AssignmentOperator);var Expression=function(ExpressionAstNode){_inherits(Expression,ExpressionAstNode);function Expression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=Expression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var expr=this.children[0];this.type=expr.type}else{var expr1=this.children[2];this.type=expr1.type}};return Expression}(ExpressionAstNode);ASTNodes.Expression=Expression;Expression=__decorate([ASTNodeDecorator(NoneTerminal.expression)],Expression);var PrimaryExpression=function(ExpressionAstNode){_inherits(PrimaryExpression,ExpressionAstNode);function PrimaryExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=PrimaryExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var id=this.children[0];if(_instanceof(id,VariableIdentifier)){var _id_typeInfo;this.type=(_id_typeInfo=id.typeInfo)!=null?_id_typeInfo:TypeAny}else{switch(id.type){case ETokenType.INT_CONSTANT:this._type=Keyword.INT;break;case ETokenType.FLOAT_CONSTANT:this.type=Keyword.FLOAT;break;case Keyword.True:case Keyword.False:this.type=Keyword.BOOL;break}}}else{var expression=this.children[1];this.type=expression.type}};return PrimaryExpression}(ExpressionAstNode);ASTNodes.PrimaryExpression=PrimaryExpression;PrimaryExpression=__decorate([ASTNodeDecorator(NoneTerminal.primary_expression)],PrimaryExpression);var PostfixExpression=function(ExpressionAstNode){_inherits(PostfixExpression,ExpressionAstNode);function PostfixExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=PostfixExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);if(this.children.length===1){var child=this.children[0];this.type=child.type}};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;if(children.length===3&&_instanceof(children[2],BaseToken)){var base=children[0];if(!this._inMacroDefinition){var reference=ParserUtils.unwrapBareIdentifier(base,{allowParens:true});if(reference)sa.shaderData.directMemberOwnerReferences.push(reference)}if(typeof base.type===\"string\"){PostfixExpression._checkStructField(sa,base.type,children[2],this._branch)}}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitPostfixExpression(this))};PostfixExpression._checkStructField=function _checkStructField(sa,structName,field,callsiteBranch){var lookup=sa.lookupSymbol;lookup.set(structName,ESymbolType.STRUCT);var structs=sa.symbolTableStack.lookupAll(lookup,true,sa.structScratch,callsiteBranch);if(!structs.length)return;var coverage=sa.getBranchCoverage(structs.map(function(struct){var _struct_branchSignature;return(_struct_branchSignature=struct.branchSignature)!=null?_struct_branchSignature:EMPTY_BRANCH}),callsiteBranch);if(coverage!==\"covered\"){sa.reportBranchAvailability(field.location,\"Struct\",structName,coverage);return}var firstProp=structs[0].astNode.propList.find(function(prop){return prop.ident.lexeme===field.lexeme});var memberPresenceDivergent=false;var memberTypeDivergent=false;for(var i=1;i<structs.length;i++){var prop=structs[i].astNode.propList.find(function(item){return item.ident.lexeme===field.lexeme});if(!!prop!==!!firstProp){memberPresenceDivergent=true;break}if(prop&&firstProp){var firstArray=firstProp.typeInfo.arraySpecifier;var array=prop.typeInfo.arraySpecifier;if(prop.typeInfo.type!==firstProp.typeInfo.type||!!array!==!!firstArray||(array==null?void 0:array.size)!==(firstArray==null?void 0:firstArray.size)){memberTypeDivergent=true;break}}}if(memberPresenceDivergent){sa.reportBranchAmbiguity(field.location,structName+\".\"+field.lexeme,\"struct-member-presence\",field.lexeme,structName);return}if(memberTypeDivergent){return}if(firstProp)return;sa.reportUndeclaredStructMember(field.location,structName,field.lexeme)};return PostfixExpression}(ExpressionAstNode);ASTNodes.PostfixExpression=PostfixExpression;PostfixExpression=__decorate([ASTNodeDecorator(NoneTerminal.postfix_expression)],PostfixExpression);var UnaryOperator=function(TreeNode){_inherits(UnaryOperator,TreeNode);function UnaryOperator(){return TreeNode.apply(this,arguments)||this}return UnaryOperator}(TreeNode);ASTNodes.UnaryOperator=UnaryOperator;UnaryOperator=__decorate([ASTNodeDecorator(NoneTerminal.unary_operator)],UnaryOperator);var UnaryExpression=function(ExpressionAstNode){_inherits(UnaryExpression,ExpressionAstNode);function UnaryExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=UnaryExpression.prototype;_proto.init=function init(){this.type=this.children[0].type};return UnaryExpression}(ExpressionAstNode);ASTNodes.UnaryExpression=UnaryExpression;UnaryExpression=__decorate([ASTNodeDecorator(NoneTerminal.unary_expression)],UnaryExpression);var MultiplicativeExpression=function(ExpressionAstNode){_inherits(MultiplicativeExpression,ExpressionAstNode);function MultiplicativeExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=MultiplicativeExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);if(this.children.length===1){this.type=this.children[0].type}else{this.type=TypeSystem.arithmeticResultType(this.children[0].type,this.children[2].type,this.children[1].lexeme)}};return MultiplicativeExpression}(ExpressionAstNode);ASTNodes.MultiplicativeExpression=MultiplicativeExpression;MultiplicativeExpression=__decorate([ASTNodeDecorator(NoneTerminal.multiplicative_expression)],MultiplicativeExpression);var AdditiveExpression=function(ExpressionAstNode){_inherits(AdditiveExpression,ExpressionAstNode);function AdditiveExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AdditiveExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);if(this.children.length===1){this.type=this.children[0].type}else{this.type=TypeSystem.arithmeticResultType(this.children[0].type,this.children[2].type,this.children[1].lexeme)}};return AdditiveExpression}(ExpressionAstNode);ASTNodes.AdditiveExpression=AdditiveExpression;AdditiveExpression=__decorate([ASTNodeDecorator(NoneTerminal.additive_expression)],AdditiveExpression);var ShiftExpression=function(ExpressionAstNode){_inherits(ShiftExpression,ExpressionAstNode);function ShiftExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ShiftExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var expr=this.children[0];this.type=expr.type};return ShiftExpression}(ExpressionAstNode);ASTNodes.ShiftExpression=ShiftExpression;ShiftExpression=__decorate([ASTNodeDecorator(NoneTerminal.shift_expression)],ShiftExpression);var RelationalExpression=function(ExpressionAstNode){_inherits(RelationalExpression,ExpressionAstNode);function RelationalExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=RelationalExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return RelationalExpression}(ExpressionAstNode);ASTNodes.RelationalExpression=RelationalExpression;RelationalExpression=__decorate([ASTNodeDecorator(NoneTerminal.relational_expression)],RelationalExpression);var EqualityExpression=function(ExpressionAstNode){_inherits(EqualityExpression,ExpressionAstNode);function EqualityExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=EqualityExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return EqualityExpression}(ExpressionAstNode);ASTNodes.EqualityExpression=EqualityExpression;EqualityExpression=__decorate([ASTNodeDecorator(NoneTerminal.equality_expression)],EqualityExpression);var AndExpression=function(ExpressionAstNode){_inherits(AndExpression,ExpressionAstNode);function AndExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AndExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return AndExpression}(ExpressionAstNode);ASTNodes.AndExpression=AndExpression;AndExpression=__decorate([ASTNodeDecorator(NoneTerminal.and_expression)],AndExpression);var ExclusiveOrExpression=function(ExpressionAstNode){_inherits(ExclusiveOrExpression,ExpressionAstNode);function ExclusiveOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ExclusiveOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return ExclusiveOrExpression}(ExpressionAstNode);ASTNodes.ExclusiveOrExpression=ExclusiveOrExpression;ExclusiveOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.exclusive_or_expression)],ExclusiveOrExpression);var InclusiveOrExpression=function(ExpressionAstNode){_inherits(InclusiveOrExpression,ExpressionAstNode);function InclusiveOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=InclusiveOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return InclusiveOrExpression}(ExpressionAstNode);ASTNodes.InclusiveOrExpression=InclusiveOrExpression;InclusiveOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.inclusive_or_expression)],InclusiveOrExpression);var LogicalAndExpression=function(ExpressionAstNode){_inherits(LogicalAndExpression,ExpressionAstNode);function LogicalAndExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalAndExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalAndExpression}(ExpressionAstNode);ASTNodes.LogicalAndExpression=LogicalAndExpression;LogicalAndExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_and_expression)],LogicalAndExpression);var LogicalXorExpression=function(ExpressionAstNode){_inherits(LogicalXorExpression,ExpressionAstNode);function LogicalXorExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalXorExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalXorExpression}(ExpressionAstNode);ASTNodes.LogicalXorExpression=LogicalXorExpression;LogicalXorExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_xor_expression)],LogicalXorExpression);var LogicalOrExpression=function(ExpressionAstNode){_inherits(LogicalOrExpression,ExpressionAstNode);function LogicalOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalOrExpression}(ExpressionAstNode);ASTNodes.LogicalOrExpression=LogicalOrExpression;LogicalOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_or_expression)],LogicalOrExpression);var ConditionalExpression=function(ExpressionAstNode){_inherits(ConditionalExpression,ExpressionAstNode);function ConditionalExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ConditionalExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}};return ConditionalExpression}(ExpressionAstNode);ASTNodes.ConditionalExpression=ConditionalExpression;ConditionalExpression=__decorate([ASTNodeDecorator(NoneTerminal.conditional_expression)],ConditionalExpression);var StructSpecifier=function(TreeNode){_inherits(StructSpecifier,TreeNode);function StructSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=StructSpecifier.prototype;_proto.init=function init(){this.ident=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.isInMacroBranch=sa.symbolTableStack.isInMacroBranch;if(children.length===6){this.ident=children[1];var symbol=sa.assignSourceScope(new StructSymbol(this.ident.lexeme,this),this.ident.location);var insertResult=sa.symbolTableStack.insert(symbol,this.ident.branch);sa.reportRedefinition(this.ident.location,symbol,insertResult);this.propList=children[3].propList;this.macroExpressions=children[3].macroExpressions}else{this.propList=children[2].propList;this.macroExpressions=children[2].macroExpressions}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitStructSpecifier(this))};return StructSpecifier}(TreeNode);ASTNodes.StructSpecifier=StructSpecifier;StructSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.struct_specifier)],StructSpecifier);var StructDeclarationList=function(TreeNode){_inherits(StructDeclarationList,TreeNode);function StructDeclarationList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.propList=[],_this.macroExpressions=[];return _this}var _proto=StructDeclarationList.prototype;_proto.init=function init(){this.propList.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,propList=_this.propList,macroExpressions=_this.macroExpressions;if(children.length===1){var _propList,_macroExpressions;(_propList=propList).push.apply(_propList,[].concat(children[0].props));(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[0].macroExpressions))}else{var _propList1,_propList2,_macroExpressions1,_macroExpressions2;(_propList1=propList).push.apply(_propList1,[].concat(children[0].propList));(_propList2=propList).push.apply(_propList2,[].concat(children[1].props));(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[0].macroExpressions));(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};return StructDeclarationList}(TreeNode);ASTNodes.StructDeclarationList=StructDeclarationList;StructDeclarationList=__decorate([ASTNodeDecorator(NoneTerminal.struct_declaration_list)],StructDeclarationList);var StructDeclaration=function(TreeNode){_inherits(StructDeclaration,TreeNode);function StructDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=StructDeclaration.prototype;_proto.init=function init(){this._typeSpecifier=undefined;this._declaratorList=undefined;this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,props=_this.props,macroExpressions=_this.macroExpressions;if(children.length===1){var _macroExpressions;var macroStructDeclaration=children[0];var macroProps=macroStructDeclaration.props;for(var i=0,length=macroProps.length;i<length;i++){macroProps[i].isInMacroBranch=true;props.push(macroProps[i])}(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(macroStructDeclaration.macroExpressions));return}if(children.length===3){this._typeSpecifier=children[0];this._declaratorList=children[1]}else{this._typeSpecifier=children[1];this._declaratorList=children[2]}var firstChild=children[0];var _this__typeSpecifier=this._typeSpecifier,type=_this__typeSpecifier.type,lexeme=_this__typeSpecifier.lexeme;var isInMacroBranch=sa.symbolTableStack.isInMacroBranch;if(_instanceof(firstChild,LayoutQualifier)){var declarator=children[2];var typeInfo=new SymbolType(type,lexeme,undefined,this._typeSpecifier.structDeclarations);var prop=new StructProp(typeInfo,declarator.ident,firstChild.index,isInMacroBranch);props.push(prop)}else{var isFlat=children.length===4&&ParserUtils.hasQualifier(children[0],Keyword.FLAT);var declaratorList=this._declaratorList.declaratorList;var declaratorListLength=declaratorList.length;props.length=declaratorListLength;for(var i1=0;i1<declaratorListLength;i1++){var declarator1=declaratorList[i1];var typeInfo1=new SymbolType(type,lexeme,declarator1.arraySpecifier,this._typeSpecifier.structDeclarations);var prop1=new StructProp(typeInfo1,declarator1.ident,undefined,isInMacroBranch,isFlat);props[i1]=prop1}}};return StructDeclaration}(TreeNode);ASTNodes.StructDeclaration=StructDeclaration;StructDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.struct_declaration)],StructDeclaration);var MacroStructDeclaration=function(TreeNode){_inherits(MacroStructDeclaration,TreeNode);function MacroStructDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=MacroStructDeclaration.prototype;_proto.init=function init(){this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(){var children=this.children;this.macroExpressions.push(children[0]);if(children.length===3){var _this_props,_this_props1,_this_macroExpressions,_this_macroExpressions1;(_this_props=this.props).push.apply(_this_props,[].concat(children[1].propList));(_this_props1=this.props).push.apply(_this_props1,[].concat(children[2].props));(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(children[1].macroExpressions));(_this_macroExpressions1=this.macroExpressions).push.apply(_this_macroExpressions1,[].concat(children[2].macroExpressions))}else{var _this_props2,_this_macroExpressions2;(_this_props2=this.props).push.apply(_this_props2,[].concat(children[1].props));(_this_macroExpressions2=this.macroExpressions).push.apply(_this_macroExpressions2,[].concat(children[1].macroExpressions))}};return MacroStructDeclaration}(TreeNode);ASTNodes.MacroStructDeclaration=MacroStructDeclaration;MacroStructDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.macro_struct_declaration)],MacroStructDeclaration);var MacroStructBranch=function(TreeNode){_inherits(MacroStructBranch,TreeNode);function MacroStructBranch(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=MacroStructBranch.prototype;_proto.init=function init(){this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(){var children=this.children;var lastNode=children[children.length-1];this.macroExpressions.push(children[0]);if(_instanceof(children[1],StructDeclarationList)){var _this_props,_this_macroExpressions;(_this_props=this.props).push.apply(_this_props,[].concat(children[1].propList));(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(children[1].macroExpressions))}if(_instanceof(lastNode,MacroStructBranch)){var _this_props1,_this_macroExpressions1;(_this_props1=this.props).push.apply(_this_props1,[].concat(lastNode.props));(_this_macroExpressions1=this.macroExpressions).push.apply(_this_macroExpressions1,[].concat(lastNode.macroExpressions))}if(children.length>1&&_instanceof(lastNode,MacroPopContext)){this.macroExpressions.push(lastNode)}};return MacroStructBranch}(TreeNode);ASTNodes.MacroStructBranch=MacroStructBranch;MacroStructBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_struct_branch)],MacroStructBranch);var LayoutQualifier=function(TreeNode){_inherits(LayoutQualifier,TreeNode);function LayoutQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=LayoutQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.index=Number(this.children[4].lexeme)};return LayoutQualifier}(TreeNode);ASTNodes.LayoutQualifier=LayoutQualifier;LayoutQualifier=__decorate([ASTNodeDecorator(NoneTerminal.layout_qualifier)],LayoutQualifier);var StructDeclaratorList=function(TreeNode){_inherits(StructDeclaratorList,TreeNode);function StructDeclaratorList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.declaratorList=[];return _this}var _proto=StructDeclaratorList.prototype;_proto.init=function init(){this.declaratorList.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,declaratorList=_this.declaratorList;if(children.length===1){declaratorList.push(children[0])}else{var list=children[0];var declarator=children[1];var listLength=list.declaratorList.length;declaratorList.length=listLength+1;for(var i=0;i<listLength;i++){declaratorList[i]=list.declaratorList[i]}declaratorList[listLength]=declarator}};return StructDeclaratorList}(TreeNode);ASTNodes.StructDeclaratorList=StructDeclaratorList;StructDeclaratorList=__decorate([ASTNodeDecorator(NoneTerminal.struct_declarator_list)],StructDeclaratorList);var StructDeclarator=function(TreeNode){_inherits(StructDeclarator,TreeNode);function StructDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=StructDeclarator.prototype;_proto.init=function init(){this.arraySpecifier=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.ident=children[0];this.arraySpecifier=children[1]};return StructDeclarator}(TreeNode);ASTNodes.StructDeclarator=StructDeclarator;StructDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.struct_declarator)],StructDeclarator);var VariableDeclaration=function(TreeNode){_inherits(VariableDeclaration,TreeNode);function VariableDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=VariableDeclaration.prototype;_proto.init=function init(){this.isStatic=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var type=children[0];var ident=children[1];this.type=type;var hasInitializer=children.length===4;var arraySpecifier=children.length===3?children[2]:undefined;var initializer=hasInitializer?children[3]:undefined;var typeInfo=new SymbolType(type.type,type.typeSpecifier.lexeme,arraySpecifier,type.typeSpecifier.structDeclarations);var sm=sa.assignSourceScope(new VarSymbol(ident.lexeme,typeInfo,true,this,type.isConst,!hasInitializer&&!type.isConst),ident.location);this.declarator={identifier:ident,typeInfo:typeInfo,initializer:initializer,isConst:type.isConst,isGlobal:true,symbol:sm};var insertResult=sa.symbolTableStack.insert(sm,ident.branch);sa.reportRedefinition(ident.location,sm,insertResult);if(children.length===4){this.isStatic=true}};_proto.codeGen=function codeGen(visitor){if(this.isStatic){return TreeNode.prototype.codeGen.call(this,visitor)}else{return visitor.cache(this,visitor.visitGlobalVariableDeclaration(this))}};return VariableDeclaration}(TreeNode);ASTNodes.VariableDeclaration=VariableDeclaration;VariableDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.variable_declaration)],VariableDeclaration);var VariableDeclarationList=function(TreeNode){_inherits(VariableDeclarationList,TreeNode);function VariableDeclarationList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.variableDeclarations=[];return _this}var _proto=VariableDeclarationList.prototype;_proto.init=function init(){this.variableDeclarations.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var length=children.length;var child=children[0];var type=child.type;this.type=type;if(_instanceof(child,VariableDeclaration)){this.variableDeclarations.push(child)}else{var _this_variableDeclarations;(_this_variableDeclarations=this.variableDeclarations).push.apply(_this_variableDeclarations,[].concat(child.variableDeclarations));var ident=children[2];var newVariable=sa.objectPool?sa.objectPool.createNode(VariableDeclaration):new VariableDeclaration;if(length===3){newVariable.set(ident.location,[type,ident])}else{newVariable.set(ident.location,[type,ident,children[3]])}newVariable.semanticAnalyze(sa);this.variableDeclarations.push(newVariable)}};return VariableDeclarationList}(TreeNode);ASTNodes.VariableDeclarationList=VariableDeclarationList;VariableDeclarationList=__decorate([ASTNodeDecorator(NoneTerminal.variable_declaration_list)],VariableDeclarationList);var VariableIdentifier=function(TreeNode){_inherits(VariableIdentifier,TreeNode);function VariableIdentifier(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.referenceGlobalSymbolNames=[],_this._symbols=[];return _this}var _proto=VariableIdentifier.prototype;_proto.resolvedSymbols=function resolvedSymbols(){return this._symbols};_proto.resolvedValueSymbols=function resolvedValueSymbols(){var child=this.children[0];if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var _this__valueSymbols;return(_this__valueSymbols=this._valueSymbols)!=null?_this__valueSymbols:EMPTY_VALUE_SYMBOLS}return this._symbols};_proto.init=function init(){this.typeInfo=TypeAny;this.builtinSemantic=undefined;this.isArray=false;this.arraySize=undefined;this.referenceGlobalSymbolNames.length=0;this._symbols.length=0;if(this._valueSymbols)this._valueSymbols.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){if(sa.diagnosticsEnabled){var child=this.children[0];var referenceGlobalSymbolNames=this.referenceGlobalSymbolNames;var symbols=this._symbols;var references=_instanceof(child,BaseToken)?[{name:child.lexeme,branch:this._branch}]:child.referenceSymbols;var needFindNames=[];var builtinAliasType;if(!_instanceof(child,BaseToken)){for(var _iterator=_create_for_of_iterator_helper_loose(references),_step;!(_step=_iterator()).done;){var reference=_step.value;var builtin=reference.name===undefined?undefined:BuiltinVariable.getVar(reference.name);if(!reference.isValueIdentity||reference.unresolved||!builtin||builtinAliasType!==undefined&&builtinAliasType!==builtin.type){builtinAliasType=undefined;break}builtinAliasType=builtin.type}}for(var i=0;i<references.length;i++){var _references_i=references[i],name=_references_i.name,branch=_references_i.branch,isValueIdentity=_references_i.isValueIdentity,replacementMemberOwner=_references_i.replacementMemberOwner,requiresRuntimeOwnerExpansion=_references_i.requiresRuntimeOwnerExpansion,unresolved=_references_i.unresolved;if(unresolved){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);continue}if(name===undefined)continue;needFindNames.push(name);if(sa.macroDefineList[name]){if(replacementMemberOwner||isValueIdentity){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}continue}if(!_instanceof(child,BaseToken)&&BuiltinFunction.isExist(name)){continue}var builtinVar=BuiltinVariable.getVar(name);if(builtinVar){this.typeInfo=_instanceof(child,BaseToken)?builtinVar.type:builtinAliasType!=null?builtinAliasType:TypeAny;if(_instanceof(child,BaseToken))this.builtinSemantic=builtinVar.semantic;continue}var hit=VariableIdentifier._lookupAndMarkGlobalReference(sa,name,symbols,referenceGlobalSymbolNames,this.location,branch,this,false,!_instanceof(child,BaseToken)&&(replacementMemberOwner!==undefined||isValueIdentity===true),replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);if(isValueIdentity)this._appendValueSymbols(symbols);if(hit&&(_instanceof(child,BaseToken)||!child.visibleHasAstValue)){var _first_dataType,_first_dataType1,_first_dataType_arraySpecifier,_first_dataType2;var first=symbols[0];var firstType=(_first_dataType=first.dataType)==null?void 0:_first_dataType.type;var firstIsArray=!!((_first_dataType1=first.dataType)==null?void 0:_first_dataType1.arraySpecifier);var firstArraySize=(_first_dataType2=first.dataType)==null?void 0:(_first_dataType_arraySpecifier=_first_dataType2.arraySpecifier)==null?void 0:_first_dataType_arraySpecifier.size;var divergent=false;var arraySizeDivergent=false;if(symbols.length>1){for(var s=1;s<symbols.length;s++){var _d_arraySpecifier;var d=symbols[s].dataType;if((d==null?void 0:d.type)!==firstType||!!(d==null?void 0:d.arraySpecifier)!==firstIsArray){divergent=true;break}if((d==null?void 0:(_d_arraySpecifier=d.arraySpecifier)==null?void 0:_d_arraySpecifier.size)!==firstArraySize)arraySizeDivergent=true}}if(divergent){this.typeInfo=TypeAny;this.isArray=false;this.arraySize=undefined}else{this.typeInfo=firstType;this.isArray=firstIsArray;this.arraySize=arraySizeDivergent?undefined:firstArraySize}}}if(!_instanceof(child,BaseToken)){VariableIdentifier._probeCrossArmShadowing(sa,child,needFindNames,symbols,referenceGlobalSymbolNames)}return}this._semanticAnalyzeForCodegen(sa)};_proto._semanticAnalyzeForCodegen=function _semanticAnalyzeForCodegen(sa){var _this=this;var child=this.children[0];if(_instanceof(child,BaseToken)){var name=child.lexeme;if(sa.macroDefineList[name])return;var builtinVar=BuiltinVariable.getVar(name);if(builtinVar){this.typeInfo=builtinVar.type;this.builtinSemantic=builtinVar.semantic;return}this._resolveCodegenReference(sa,name,true,this._branch);return}var references=child.referenceSymbols.length?child.referenceSymbols:child.referenceSymbolNames.map(function(name){return{name:name,branch:_this._branch}});for(var i=0;i<references.length;i++){var _references_i=references[i],name1=_references_i.name,branch=_references_i.branch,isValueIdentity=_references_i.isValueIdentity,replacementMemberOwner=_references_i.replacementMemberOwner,requiresRuntimeOwnerExpansion=_references_i.requiresRuntimeOwnerExpansion,unresolved=_references_i.unresolved;if(unresolved){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);continue}if(name1===undefined)continue;if(sa.macroDefineList[name1]){if(replacementMemberOwner||isValueIdentity){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}continue}if(BuiltinFunction.isExist(name1))continue;var builtinVar1=BuiltinVariable.getVar(name1);if(builtinVar1){this.typeInfo=builtinVar1.type;continue}this._resolveCodegenReference(sa,name1,!child.hasAstValue,branch,replacementMemberOwner!==undefined||isValueIdentity===true,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}var macroName=child.macroName;if(!macroName||BuiltinFunction.isExist(macroName)||BuiltinVariable.getVar(macroName))return;for(var i1=0;i1<references.length;i1++){if(references[i1].name===macroName)return}var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(macroName,ESymbolType.Any);sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,sa.runtimeLookupScratch,sa.runtimeFallbackScratch,this._branch);this._markCodegenReference(macroName,sa.runtimeLookupScratch);this._markCodegenReference(macroName,sa.runtimeFallbackScratch)};_proto._resolveCodegenReference=function _resolveCodegenReference(sa,name,inferType,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){if(captureResolution===void 0)captureResolution=false;var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(name,ESymbolType.Any);var symbols=this._symbols;var runtimeFallbacks=sa.runtimeFallbackScratch;sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,symbols,runtimeFallbacks,callSiteBranch);if(!symbols.length){if(captureResolution&&(replacementMemberOwner||isValueIdentity)){this._registerUnresolvedReferenceResolution(sa,callSiteBranch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}return}this._appendCodegenRuntimeFallbacks(sa,symbols,runtimeFallbacks,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);this._markCodegenReference(name,symbols);if(isValueIdentity)this._appendValueSymbols(symbols);if(!inferType)return;var first=symbols[0].dataType;var arraySizeDivergent=false;for(var i=1;i<symbols.length;i++){var _current_arraySpecifier,_first_arraySpecifier;var current=symbols[i].dataType;if((current==null?void 0:current.type)!==(first==null?void 0:first.type)||!!(current==null?void 0:current.arraySpecifier)!==!!(first==null?void 0:first.arraySpecifier))return;if((current==null?void 0:(_current_arraySpecifier=current.arraySpecifier)==null?void 0:_current_arraySpecifier.size)!==(first==null?void 0:(_first_arraySpecifier=first.arraySpecifier)==null?void 0:_first_arraySpecifier.size))arraySizeDivergent=true}this._setCodegenType(first,arraySizeDivergent)};_proto._appendCodegenRuntimeFallbacks=function _appendCodegenRuntimeFallbacks(sa,symbols,runtimeFallbacks,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){var fallbackStart=symbols.length;for(var i=0,n=runtimeFallbacks.length;i<n;i++){var fallback=runtimeFallbacks[i];if(!(_instanceof(fallback,VarSymbol)||_instanceof(fallback,FnSymbol)))continue;if(symbols.indexOf(fallback)===-1)symbols.push(fallback)}this._registerReferenceResolution(sa,fallbackStart,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)};_proto._appendValueSymbols=function _appendValueSymbols(symbols){if(!symbols.length)return;var _this__valueSymbols;var valueSymbols=(_this__valueSymbols=this._valueSymbols)!=null?_this__valueSymbols:this._valueSymbols=[];for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;if(valueSymbols.indexOf(symbol)===-1)valueSymbols.push(symbol)}};_proto._markCodegenReference=function _markCodegenReference(name,symbols){for(var i=0;i<symbols.length;i++){var symbol=symbols[i];if(_instanceof(symbol,FnSymbol)||_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable){if(this.referenceGlobalSymbolNames.indexOf(name)===-1){this.referenceGlobalSymbolNames.push(name)}return}}};_proto._setCodegenType=function _setCodegenType(dataType,arraySizeDivergent){if(arraySizeDivergent===void 0)arraySizeDivergent=false;var _dataType_arraySpecifier;this.typeInfo=dataType==null?void 0:dataType.type;this.isArray=!!(dataType==null?void 0:dataType.arraySpecifier);this.arraySize=arraySizeDivergent?undefined:dataType==null?void 0:(_dataType_arraySpecifier=dataType.arraySpecifier)==null?void 0:_dataType_arraySpecifier.size};_proto._registerReferenceResolution=function _registerReferenceResolution(sa,fallbackStart,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){var capturesEmptyResolution=captureResolution&&(replacementMemberOwner!==undefined||isValueIdentity===true);if(!this._symbols.length&&!capturesEmptyResolution||!captureResolution&&fallbackStart>=this._symbols.length){return}sa.shaderData.referenceResolutionSnapshots.push({reference:this,symbols:this._symbols.slice(),fallbackStart:fallbackStart,callSiteBranch:callSiteBranch,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:requiresRuntimeOwnerExpansion,isValueIdentity:isValueIdentity})};_proto._registerUnresolvedReferenceResolution=function _registerUnresolvedReferenceResolution(sa,callSiteBranch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){sa.shaderData.referenceResolutionSnapshots.push({reference:this,symbols:EMPTY_VALUE_SYMBOLS,fallbackStart:0,callSiteBranch:callSiteBranch,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:requiresRuntimeOwnerExpansion,isValueIdentity:isValueIdentity})};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitVariableIdentifier(this))};_proto.getLexeme=function getLexeme(visitor){var child=this.children[0];if(_instanceof(child,BaseToken)){return child.lexeme}else{return child.codeGen(visitor)}};VariableIdentifier._probeCrossArmShadowing=function _probeCrossArmShadowing(sa,child,needFindNames,symbols,referenceGlobalSymbolNames){var macroName=child.macroName;if(!macroName)return;if(needFindNames.indexOf(macroName)!==-1)return;if(BuiltinFunction.isExist(macroName)||BuiltinVariable.getVar(macroName))return;VariableIdentifier._lookupAndMarkGlobalReference(sa,macroName,symbols,referenceGlobalSymbolNames,null,EMPTY_BRANCH,undefined,true)};VariableIdentifier._lookupAndMarkGlobalReference=function _lookupAndMarkGlobalReference(sa,name,symbols,referenceGlobalSymbolNames,missErrorLoc,callsiteBranch,resolvedReference,retainPartialBranchCandidates,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){if(retainPartialBranchCandidates===void 0)retainPartialBranchCandidates=false;if(captureResolution===void 0)captureResolution=false;var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(name,ESymbolType.Any);var runtimeFallbacks=sa.runtimeFallbackScratch;sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,symbols,runtimeFallbacks,callsiteBranch);var directlyVisibleCount=0;for(var i=0,n=symbols.length;i<n;i++){var symbol=symbols[i];var _symbol_branchSignature;if(sa.isBranchVisibleFrom((_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH,callsiteBranch)){symbols[directlyVisibleCount++]=symbol}}if(directlyVisibleCount)symbols.length=directlyVisibleCount;var fallbackStart=symbols.length;for(var i1=0,n1=runtimeFallbacks.length;i1<n1;i1++){var fallback=runtimeFallbacks[i1];if(!(_instanceof(fallback,VarSymbol)||_instanceof(fallback,FnSymbol)))continue;if(symbols.indexOf(fallback)===-1)symbols.push(fallback)}resolvedReference==null?void 0:resolvedReference._registerReferenceResolution(sa,fallbackStart,callsiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);if(!symbols.length){if(missErrorLoc){if(sa.symbolTableStack.hasSymbol(lookupSymbol)){sa.symbolTableStack.lookupAll(lookupSymbol,true,symbols);sa.reportBranchAvailability(missErrorLoc,\"Identifier\",name,sa.getBranchCoverage(symbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),callsiteBranch));symbols.length=0;return false}}return false}var coverage=sa.getBranchCoverage(symbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),callsiteBranch);if((VariableIdentifier._containsGlobalSymbol(symbols)||VariableIdentifier._containsGlobalSymbol(runtimeFallbacks))&&referenceGlobalSymbolNames.indexOf(name)===-1){referenceGlobalSymbolNames.push(name)}if(!retainPartialBranchCandidates&&coverage!==\"covered\"&&!VariableIdentifier._hasConflictingGlobalBranches(sa,symbols)){if(missErrorLoc){sa.reportBranchAvailability(missErrorLoc,\"Identifier\",name,coverage)}return false}return true};VariableIdentifier._hasConflictingGlobalBranches=function _hasConflictingGlobalBranches(sa,symbols){for(var i=0,n=symbols.length;i<n;i++){var left=symbols[i];if(!_instanceof(left,FnSymbol)&&!left.isGlobalVariable)continue;for(var j=i+1;j<n;j++){var right=symbols[j];if(!_instanceof(right,FnSymbol)&&!right.isGlobalVariable)continue;var _left_branchSignature,_right_branchSignature;if(sa.canDeclarationsCoexist((_left_branchSignature=left.branchSignature)!=null?_left_branchSignature:EMPTY_BRANCH,(_right_branchSignature=right.branchSignature)!=null?_right_branchSignature:EMPTY_BRANCH))return true}}return false};VariableIdentifier._containsGlobalSymbol=function _containsGlobalSymbol(symbols){for(var i=0;i<symbols.length;i++){var symbol=symbols[i];if(_instanceof(symbol,FnSymbol)||_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable)return true}return false};return VariableIdentifier}(TreeNode);ASTNodes.VariableIdentifier=VariableIdentifier;VariableIdentifier=__decorate([ASTNodeDecorator(NoneTerminal.variable_identifier)],VariableIdentifier);var GLShaderProgram=function(TreeNode){_inherits(GLShaderProgram,TreeNode);function GLShaderProgram(){return TreeNode.apply(this,arguments)||this}var _proto=GLShaderProgram.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.shaderData=sa.shaderData;this.shaderData.symbolTable=sa.symbolTableStack.scope};return GLShaderProgram}(TreeNode);ASTNodes.GLShaderProgram=GLShaderProgram;GLShaderProgram=__decorate([ASTNodeDecorator(NoneTerminal.gs_shader_program)],GLShaderProgram);var GlobalDeclaration=function(TreeNode){_inherits(GlobalDeclaration,TreeNode);function GlobalDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalDeclaration.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var child=this.children[0];if(_instanceof(child,MacroUndef)||_instanceof(child,GlobalMacroIfStatement)||_instanceof(child,MacroDefine)||_instanceof(child,BaseToken)){sa.shaderData.globalMacroDeclarations.push(this);if(_instanceof(child,GlobalMacroIfStatement)){var _this_macroExpressions;(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(child.macroExpressions))}else{this.macroExpressions.push(child)}}};return GlobalDeclaration}(TreeNode);ASTNodes.GlobalDeclaration=GlobalDeclaration;GlobalDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.global_declaration)],GlobalDeclaration);var MacroUndef=function(TreeNode){_inherits(MacroUndef,TreeNode);function MacroUndef(){return TreeNode.apply(this,arguments)||this}var _proto=MacroUndef.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroUndef}(TreeNode);ASTNodes.MacroUndef=MacroUndef;MacroUndef=__decorate([ASTNodeDecorator(NoneTerminal.macro_undef)],MacroUndef);var MacroPushContext=function(TreeNode){_inherits(MacroPushContext,TreeNode);function MacroPushContext(){return TreeNode.apply(this,arguments)||this}var _proto=MacroPushContext.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.symbolTableStack._macroLevel++};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroPushContext}(TreeNode);ASTNodes.MacroPushContext=MacroPushContext;MacroPushContext=__decorate([ASTNodeDecorator(NoneTerminal.macro_push_context)],MacroPushContext);var MacroPopContext=function(TreeNode){_inherits(MacroPopContext,TreeNode);function MacroPopContext(){return TreeNode.apply(this,arguments)||this}var _proto=MacroPopContext.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.symbolTableStack._macroLevel--};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroPopContext}(TreeNode);ASTNodes.MacroPopContext=MacroPopContext;MacroPopContext=__decorate([ASTNodeDecorator(NoneTerminal.macro_pop_context)],MacroPopContext);var MacroElifExpression=function(TreeNode){_inherits(MacroElifExpression,TreeNode);function MacroElifExpression(){return TreeNode.apply(this,arguments)||this}var _proto=MacroElifExpression.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroElifExpression}(TreeNode);ASTNodes.MacroElifExpression=MacroElifExpression;MacroElifExpression=__decorate([ASTNodeDecorator(NoneTerminal.macro_elif_expression)],MacroElifExpression);var MacroElseExpression=function(TreeNode){_inherits(MacroElseExpression,TreeNode);function MacroElseExpression(){return TreeNode.apply(this,arguments)||this}var _proto=MacroElseExpression.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroElseExpression}(TreeNode);ASTNodes.MacroElseExpression=MacroElseExpression;MacroElseExpression=__decorate([ASTNodeDecorator(NoneTerminal.macro_else_expression)],MacroElseExpression);var GlobalMacroDeclaration=function(TreeNode){_inherits(GlobalMacroDeclaration,TreeNode);function GlobalMacroDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroDeclaration.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var macroExpressions=this.macroExpressions;if(children.length===1){var _macroExpressions;(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[0].macroExpressions))}else{var _macroExpressions1,_macroExpressions2;(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[0].macroExpressions));(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};_proto.codeGen=function codeGen(visitor){var children=this.children;if(children.length===1){return visitor.cache(this,children[0].codeGen(visitor))}else{return visitor.cache(this,children[0].codeGen(visitor)+\"\\n\"+children[1].codeGen(visitor))}};return GlobalMacroDeclaration}(TreeNode);ASTNodes.GlobalMacroDeclaration=GlobalMacroDeclaration;GlobalMacroDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_declaration)],GlobalMacroDeclaration);var GlobalMacroIfStatement=function(TreeNode){_inherits(GlobalMacroIfStatement,TreeNode);function GlobalMacroIfStatement(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroIfStatement.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var macroExpressions=this.macroExpressions;if(children.length===3){var _macroExpressions,_macroExpressions1;macroExpressions.push(children[0]);(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[1].macroExpressions));(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[2].macroExpressions))}else{var _macroExpressions2;macroExpressions.push(children[0]);(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};return GlobalMacroIfStatement}(TreeNode);ASTNodes.GlobalMacroIfStatement=GlobalMacroIfStatement;GlobalMacroIfStatement=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_if_statement)],GlobalMacroIfStatement);var GlobalMacroBranch=function(TreeNode){_inherits(GlobalMacroBranch,TreeNode);function GlobalMacroBranch(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroBranch.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var lastNode=children[children.length-1];var macroExpressions=this.macroExpressions;macroExpressions.push(children[0]);if(_instanceof(children[1],GlobalMacroDeclaration)){var _macroExpressions;(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[1].macroExpressions))}if(_instanceof(lastNode,GlobalMacroBranch)){var _macroExpressions1;(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(lastNode.macroExpressions))}if(children.length>1&&_instanceof(lastNode,MacroPopContext)){macroExpressions.push(lastNode)}};return GlobalMacroBranch}(TreeNode);ASTNodes.GlobalMacroBranch=GlobalMacroBranch;GlobalMacroBranch=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_branch)],GlobalMacroBranch);var MacroIfStatement=function(TreeNode){_inherits(MacroIfStatement,TreeNode);function MacroIfStatement(){return TreeNode.apply(this,arguments)||this}return MacroIfStatement}(TreeNode);ASTNodes.MacroIfStatement=MacroIfStatement;MacroIfStatement=__decorate([ASTNodeDecorator(NoneTerminal.macro_if_statement)],MacroIfStatement);var MacroBranch=function(TreeNode){_inherits(MacroBranch,TreeNode);function MacroBranch(){return TreeNode.apply(this,arguments)||this}return MacroBranch}(TreeNode);ASTNodes.MacroBranch=MacroBranch;MacroBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_branch)],MacroBranch);var MacroCallSymbol=function(TreeNode1){_inherits(MacroCallSymbol,TreeNode1);function MacroCallSymbol(){var _this;_this=TreeNode1.apply(this,arguments)||this,_this.referenceSymbolNames=[],_this.referenceSymbols=[],_this.hasAstValue=false,_this.visibleHasAstValue=false,_this.isFunctionLikeMacro=false,_this.aliasesNonBuiltinIdent=false;return _this}var _proto=MacroCallSymbol.prototype;_proto.init=function init(){this.expandedSyntax=undefined;this.referenceSymbolNames.length=0;this.referenceSymbols.length=0;this.hasAstValue=false;this.visibleHasAstValue=false;this.isFunctionLikeMacro=false;this.aliasesNonBuiltinIdent=false};_proto.semanticAnalyze=function semanticAnalyze(sa){var _sa_semanticDiagnostics_macroExpansion,_sa_semanticDiagnostics;var nameToken=this.children[0];var macroName=nameToken.lexeme;this.macroName=macroName;var defList=sa.macroDefineList[macroName];var refs=this.referenceSymbolNames;refs.length=0;this.referenceSymbols.length=0;this._analyzeForCodegen(defList,refs);var callSiteBranch=nameToken.branch;var referenceSymbols=this.referenceSymbols;var visibleCount=0;var allAst=true;if(defList){for(var i=0,n=defList.length;i<n;i++){var info=defList[i];if(!sa.canBranchesOverlap(info.branch,callSiteBranch))continue;visibleCount++;if(info.valueAst==null){allAst=false;appendMacroReference(referenceSymbols,{unresolved:true,branch:mergeBranchSignatures(callSiteBranch,info.branch),isValueIdentity:true})}else{MacroCallSymbol._collectIdentifierRefs(info.valueAst,info.params,refs,referenceSymbols,callSiteBranch,undefined,ParserUtils.unwrapBareIdentifier(info.valueAst,{allowParens:true}))}}}this.visibleHasAstValue=visibleCount>0&&allAst;if(sa.diagnosticsEnabled)this.expandedSyntax=(_sa_semanticDiagnostics=sa.semanticDiagnostics)==null?void 0:(_sa_semanticDiagnostics_macroExpansion=_sa_semanticDiagnostics.macroExpansion)==null?void 0:_sa_semanticDiagnostics_macroExpansion.call(_sa_semanticDiagnostics,this,sa)};_proto._analyzeForCodegen=function _analyzeForCodegen(defList,refs){var allAst=true;var isFunctionLike=false;var allAliasNonBuiltinIdent=true;var _defList_length;var count=(_defList_length=defList==null?void 0:defList.length)!=null?_defList_length:0;for(var i=0;i<count;i++){var info=defList[i];if(!info.valueAst)allAst=false;if(info.isFunction)isFunctionLike=true;if(info.valueAst)MacroCallSymbol._collectIdentifierRefs(info.valueAst,info.params,refs);if(info.isFunction||!info.valueAst){allAliasNonBuiltinIdent=false}else{var leadingIdent=ParserUtils.unwrapBareIdentifier(info.valueAst,{allowParens:false});var leadingChild=leadingIdent==null?void 0:leadingIdent.children[0];var leadingId=_instanceof(leadingChild,BaseToken)?leadingChild.lexeme:undefined;if(!leadingId||BuiltinFunction.isExist(leadingId))allAliasNonBuiltinIdent=false}}this.hasAstValue=count>0&&allAst;this.isFunctionLikeMacro=isFunctionLike;this.aliasesNonBuiltinIdent=count>0&&allAliasNonBuiltinIdent};MacroCallSymbol._collectIdentifierRefs=function _collectIdentifierRefs(node,params,out,references,callSiteBranch,projectedMemberOwner,valueIdentity){if(callSiteBranch===void 0)callSiteBranch=EMPTY_BRANCH;if(_instanceof(node,PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var base=node.children[0];if(_instanceof(base,TreeNode)){var directOwner=ParserUtils.unwrapBareIdentifier(base,{allowParens:true});if(directOwner){MacroCallSymbol._collectIdentifierRefs(base,params,out,references,callSiteBranch,directOwner,valueIdentity);return}}}if(_instanceof(node,VariableIdentifier)){var child=node.children[0];var isValueIdentity=valueIdentity===node;var replacementMemberOwner=projectedMemberOwner===node?node:undefined;var branch=mergeBranchSignatures(callSiteBranch,node._branch);if(_instanceof(child,BaseToken)){var name=child.lexeme;var formalParameterIndex=params.indexOf(name);if(formalParameterIndex===-1){if(out.indexOf(name)===-1)out.push(name);if(references){appendMacroReference(references,{name:name,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner})}}else if(references&&(replacementMemberOwner||isValueIdentity)){appendMacroReference(references,{formalParameterIndex:formalParameterIndex,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:replacementMemberOwner?true:undefined})}}else if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var nestedReferences=child.referenceSymbols;for(var _iterator=_create_for_of_iterator_helper_loose(nestedReferences),_step;!(_step=_iterator()).done;){var nestedReference=_step.value;if(nestedReference.unresolved){if(references&&(replacementMemberOwner||isValueIdentity)){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(branch,nestedReference.branch),isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:replacementMemberOwner?true:undefined})}continue}var name1=nestedReference.name;var formalParameterIndex1=nestedReference.formalParameterIndex;if(name1!==undefined){var outerFormalIndex=params.indexOf(name1);if(outerFormalIndex===-1){if(out.indexOf(name1)===-1)out.push(name1)}else{name1=undefined;formalParameterIndex1=outerFormalIndex}}if(!references)continue;var nestedBranch=mergeBranchSignatures(branch,nestedReference.branch);var nestedOwner=replacementMemberOwner!=null?replacementMemberOwner:nestedReference.replacementMemberOwner;var nestedIsValueIdentity=isValueIdentity&&nestedReference.isValueIdentity;var requiresRuntimeExpansion=replacementMemberOwner!==undefined||nestedReference.requiresRuntimeOwnerExpansion;if(name1!==undefined){appendMacroReference(references,{name:name1,branch:nestedBranch,isValueIdentity:nestedIsValueIdentity,replacementMemberOwner:nestedOwner,requiresRuntimeOwnerExpansion:requiresRuntimeExpansion})}else if(formalParameterIndex1!==undefined){appendMacroReference(references,{formalParameterIndex:formalParameterIndex1,branch:nestedBranch,isValueIdentity:nestedIsValueIdentity,replacementMemberOwner:nestedOwner,requiresRuntimeOwnerExpansion:requiresRuntimeExpansion})}}var hasNestedValueIdentity=nestedReferences.some(function(reference){return reference.isValueIdentity});if(references&&child.macroName&&(!nestedReferences.length&&replacementMemberOwner||isValueIdentity&&!hasNestedValueIdentity&&!child.visibleHasAstValue)){appendMacroReference(references,{name:child.macroName,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(out.indexOf(child.macroName)===-1)out.push(child.macroName)}}return}var children=node.children;if(!children)return;for(var i=0,n=children.length;i<n;i++){var c=children[i];if(_instanceof(c,TreeNode)){MacroCallSymbol._collectIdentifierRefs(c,params,out,references,callSiteBranch,projectedMemberOwner,valueIdentity)}}};return MacroCallSymbol}(TreeNode);ASTNodes.MacroCallSymbol=MacroCallSymbol;MacroCallSymbol=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_symbol)],MacroCallSymbol);var MacroCallFunction=function(TreeNode1){_inherits(MacroCallFunction,TreeNode1);function MacroCallFunction(){var _this;_this=TreeNode1.apply(this,arguments)||this,_this.referenceSymbolNames=[],_this.referenceSymbols=[],_this.macroName=\"\",_this.hasAstValue=false,_this.visibleHasAstValue=false,_this.isFunctionLikeMacro=false,_this.aliasesNonBuiltinIdent=false;return _this}var _proto=MacroCallFunction.prototype;_proto.init=function init(){this.expandedSyntax=undefined;this.referenceSymbolNames.length=0;this.referenceSymbols.length=0;this.macroName=\"\";this.hasAstValue=false;this.visibleHasAstValue=false;this.isFunctionLikeMacro=false;this.aliasesNonBuiltinIdent=false};_proto.semanticAnalyze=function semanticAnalyze(sa){var _sa_semanticDiagnostics_macroExpansion,_sa_semanticDiagnostics;var child=this.children[0];var paramList=this.children[2];var paramNodes=_instanceof(paramList,FunctionCallParameterList)?paramList.paramNodes:undefined;for(var _iterator=_create_for_of_iterator_helper_loose(child.referenceSymbols),_step;!(_step=_iterator()).done;){var reference=_step.value;var formalParameterIndex=reference.formalParameterIndex;if(formalParameterIndex===undefined){appendMacroReference(this.referenceSymbols,reference);if(reference.name!==undefined&&this.referenceSymbolNames.indexOf(reference.name)===-1){this.referenceSymbolNames.push(reference.name)}continue}var actual=paramNodes==null?void 0:paramNodes[formalParameterIndex];if(!_instanceof(actual,TreeNode))continue;appendSubstitutedOwnerReferences(actual,reference,this.referenceSymbols,this.referenceSymbolNames)}this.macroName=child.macroName;this.hasAstValue=child.hasAstValue;this.visibleHasAstValue=child.visibleHasAstValue;this.isFunctionLikeMacro=child.isFunctionLikeMacro;this.aliasesNonBuiltinIdent=child.aliasesNonBuiltinIdent;if(sa.diagnosticsEnabled)this.expandedSyntax=(_sa_semanticDiagnostics=sa.semanticDiagnostics)==null?void 0:(_sa_semanticDiagnostics_macroExpansion=_sa_semanticDiagnostics.macroExpansion)==null?void 0:_sa_semanticDiagnostics_macroExpansion.call(_sa_semanticDiagnostics,this,sa)};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitMacroCallFunction(this))};return MacroCallFunction}(TreeNode);ASTNodes.MacroCallFunction=MacroCallFunction;MacroCallFunction=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_function)],MacroCallFunction);var MacroDefine=function(TreeNode){_inherits(MacroDefine,TreeNode);function MacroDefine(){return TreeNode.apply(this,arguments)||this}var _proto=MacroDefine.prototype;_proto.init=function init(){this.macroName=\"\";this.isFunction=false;this.valueExpression=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this;var children=this.children;this.macroName=children[1].lexeme;var params=[];var valueIdx=2;if(_instanceof(children[2],BaseToken)&&children[2].type===Keyword.MACRO_DEFINE_PARAMS){this.isFunction=true;params=ParserUtils.parseMacroParamList(children[2].lexeme);valueIdx=3}if(_instanceof(children[valueIdx],Expression)){this.valueExpression=children[valueIdx]}var definingBranch=children[1].branch;var list=sa.macroDefineList;var entries=list[this.macroName];var sameArity=function(info){return info.isFunction===_this.isFunction&&info.params.length===params.length&&info.params.every(function(p,i){return p===params[i]})};var upgradable=entries==null?void 0:entries.find(function(info){return!info.valueAst&&sameArity(info)&&sameBranch(info.branch,definingBranch)});if(upgradable){upgradable.valueAst=this.valueExpression}else{var info={isFunction:this.isFunction,params:params,valueAst:this.valueExpression,dedupKey:this.macroName+\"#ast/\"+(this.isFunction?params.join(\",\"):\"\"),branch:definingBranch};if(entries)entries.push(info);else list[this.macroName]=[info]}if(this.isFunction){sa.popScope()}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitMacroDefine(this))};return MacroDefine}(TreeNode);ASTNodes.MacroDefine=MacroDefine;MacroDefine=__decorate([ASTNodeDecorator(NoneTerminal.macro_define)],MacroDefine)})(ASTNodes||(ASTNodes={}));var ASTNode=ASTNodes;var ASTNodes;var EAction=function(EAction){EAction[EAction[\"Shift\"]=0]=\"Shift\";EAction[EAction[\"Reduce\"]=1]=\"Reduce\";EAction[EAction[\"Accept\"]=2]=\"Accept\";return EAction}({});var GrammarUtils=function(){function GrammarUtils(){}GrammarUtils.isTerminal=function isTerminal(sm){return sm<NoneTerminal.START};GrammarUtils.toString=function toString(sm){if(this.isTerminal(sm)){var _ETokenType_sm;return(_ETokenType_sm=ETokenType[sm])!=null?_ETokenType_sm:Keyword[sm]}return NoneTerminal[sm]};GrammarUtils.createProductionWithOptions=function createProductionWithOptions(goal,options,astType){return this._createProductionWithOptions(goal,options,astType,astType)};GrammarUtils.createAnalyzerProductionWithOptions=function createAnalyzerProductionWithOptions(goal,options,analyzerType){return this._createProductionWithOptions(goal,options,undefined,analyzerType)};GrammarUtils._createProductionWithOptions=function _createProductionWithOptions(goal,options,runtimeType,analyzerType){var _loop=function(){var opt=_step.value;var runtimeCanElide=!runtimeType&&opt.length===1&&!GrammarUtils.isTerminal(opt[0]);var analyzerCanElide=!analyzerType&&opt.length===1&&!GrammarUtils.isTerminal(opt[0]);ret.push([[].concat([goal],opt),function(sa){for(var _len=arguments.length,children=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){children[_key-1]=arguments[_key]}if(!children[0])return;var analyzerMode=sa.diagnosticsEnabled;var canElide=analyzerMode?analyzerCanElide:runtimeCanElide;if(canElide){sa.semanticStack.push(children[0])}else{var start=children[0].location.start;var end=children[children.length-1].location.end;var location=sa.objectPool?sa.objectPool.createRange(start,end):ShaderCompilerUtils.createRange(start,end);ASTNode.get(analyzerMode?analyzerResolvedType:runtimeResolvedType,sa,location,children)}}])};var runtimeResolvedType=runtimeType!=null?runtimeType:ASTNode.TrivialNode;var analyzerResolvedType=analyzerType!=null?analyzerType:ASTNode.TrivialNode;var ret=[];for(var _iterator=_create_for_of_iterator_helper_loose(options),_step;!(_step=_iterator()).done;)_loop();return ret};GrammarUtils.addMapSetItem=function addMapSetItem(map,k,v){var _map_get;var set=(_map_get=map.get(k))!=null?_map_get:new Set;set.add(v);map.set(k,set)};GrammarUtils.isSubSet=function isSubSet(sa,sb){for(var _iterator=_create_for_of_iterator_helper_loose(sa),_step;!(_step=_iterator()).done;){var item=_step.value;if(!sb.has(item))return false}return true};GrammarUtils.isActionEqual=function isActionEqual(a,b){return a.action===b.action&&a.target===b.target};GrammarUtils.printAction=function printAction(actionInfo){var production=Production.pool.get(actionInfo.target);return\"<Action: \"+EAction[actionInfo.action]+\" -> \"+this.printProduction(production)+\">\"};GrammarUtils.printProduction=function printProduction(production){var deriv=production.derivation.map(function(gs){return GrammarUtils.toString(gs)}).join(\"|\");return NoneTerminal[production.goal]+\" :=> \"+deriv};return GrammarUtils}();var StateItem=function(){function StateItem(production,position,lookahead){this._needReInfer=true;this.production=production;this.position=position;this.lookaheadSet=new Set;for(var _iterator=_create_for_of_iterator_helper_loose(lookahead),_step;!(_step=_iterator()).done;){var la=_step.value;this.lookaheadSet.add(la)}this.id=StateItem._id++}var _proto=StateItem.prototype;_proto.addLookahead=function addLookahead(ts){for(var _iterator=_create_for_of_iterator_helper_loose(ts),_step;!(_step=_iterator()).done;){var t=_step.value;if(this.lookaheadSet.has(t))continue;this.lookaheadSet.add(t);this.needReInfer=true}};_proto.symbolByOffset=function symbolByOffset(offset){return this.production.derivation[this.position+offset]};_proto.canReduce=function canReduce(){if(this.position>this.production.derivation.length-1)return true;else{for(var i=this.position;i<this.production.derivation.length;i++){if(this.production.derivation[i]!==ETokenType.EPSILON)return false}return true}};_proto.advance=function advance(){if(this.canReduce())throw\"Error: advance reduce-able parsing state item\";return new StateItem(this.production,this.position+1,this.lookaheadSet)};_proto.toString=function toString(){var coreItem=this.production.derivation.map(function(item){return GrammarUtils.toString(item)});var _coreItem_this_position;coreItem[this.position]=\".\"+((_coreItem_this_position=coreItem[this.position])!=null?_coreItem_this_position:\"\");return NoneTerminal[this.production.goal]+\" :=> \"+coreItem.join(\"|\")+\" ;\"+Array.from(this.lookaheadSet).map(function(item){return GrammarUtils.toString(item)}).join(\"/\")};_create_class(StateItem,[{key:\"needReInfer\",get:function get(){return this._needReInfer},set:function set(v){this._needReInfer=v}},{key:\"curSymbol\",get:function get(){return this.production.derivation[this.position]}},{key:\"nextSymbol\",get:function get(){return this.production.derivation[this.position+1]}}]);return StateItem}();StateItem._id=0;var State=function(){function State(cores){this.closured=false;this._stateItemPool=new Map;this.id=State._id++;this._items=new Set([].concat(cores));this.cores=new Set([].concat(cores));for(var _iterator=_create_for_of_iterator_helper_loose(cores),_step;!(_step=_iterator()).done;){var it=_step.value;var itemMapKey=this.getStateItemMapKey(it.production,it.position);this._stateItemPool.set(itemMapKey,it)}State.pool.set(this.id,this)}var _proto=State.prototype;_proto.getStateItemMapKey=function getStateItemMapKey(production,position){return production.id+\",\"+position};_proto.createStateItem=function createStateItem(production,position,lookaheadSet){if(lookaheadSet===void 0)lookaheadSet=new Set;var mapId=this.getStateItemMapKey(production,position);var item=this._stateItemPool.get(mapId);if(item){for(var _iterator=_create_for_of_iterator_helper_loose(lookaheadSet),_step;!(_step=_iterator()).done;){var la=_step.value;if(item.lookaheadSet.has(la))continue;item.lookaheadSet.add(la);item.needReInfer=true}return item}var newItem=new StateItem(production,position,lookaheadSet);this._stateItemPool.set(mapId,newItem);return newItem};State.create=function create(cores){var cacheKey=this.getMapKey(cores);var state=this.closureMap.get(cacheKey);if(state){for(var _iterator=_create_for_of_iterator_helper_loose(cores),_step;!(_step=_iterator()).done;){var core=_step.value;state.createStateItem(core.production,core.position,core.lookaheadSet)}return state}var newState=new State(cores);this.closureMap.set(cacheKey,newState);return newState};State.getMapKey=function getMapKey(cores){return cores.map(function(item){return item.production.id+\",\"+item.position}).join(\";\")};_create_class(State,[{key:\"items\",get:function get(){return this._items}},{key:\"needReInfer\",get:function get(){for(var _iterator=_create_for_of_iterator_helper_loose(this.cores),_step;!(_step=_iterator()).done;){var core=_step.value;if(core.needReInfer)return true}return false}}]);return State}();State.closureMap=new Map;State.pool=new Map;State._id=0;var LALR1=function(){function LALR1(grammar){this.firstSetMap=new Map;this.followSetMap=new Map;this.actionTable=new Map;this.gotoTable=new Map;this._firstSetNTStack=[];this.grammar=grammar}var _proto=LALR1.prototype;_proto.generate=function generate(){this.computeFirstSet();this.buildStateTable()};_proto.buildStateTable=function buildStateTable(){var startStateItemCore=[new StateItem(this.grammar.productions[0],0,[ETokenType.EOF])];var startState=State.create(startStateItemCore);this._extendState(startState)};_proto._extendState=function _extendState(state){if(!state.needReInfer)return;this._closure(state);var newStates=this._inferNextState(state);for(var _iterator=_create_for_of_iterator_helper_loose(newStates),_step;!(_step=_iterator()).done;){var ns=_step.value;this._extendState(ns)}};_proto._closure=function _closure(state){for(var _iterator=_create_for_of_iterator_helper_loose(state.cores),_step;!(_step=_iterator()).done;){var core=_step.value;if(!core.canReduce()){this._extendStateItem(state,core)}}state.closured=true;return state};_proto._extendStateItem=function _extendStateItem(state,item){if(GrammarUtils.isTerminal(item.curSymbol))return;var productionList=this.grammar.getProductionList(item.curSymbol);if(item.nextSymbol!==undefined){var newLookaheadSet=new Set;var lastFirstSet;var terminalExist=false;for(var i=1,nextSymbol=item.symbolByOffset(1);nextSymbol!==undefined;nextSymbol=item.symbolByOffset(++i)){if(GrammarUtils.isTerminal(nextSymbol)){newLookaheadSet.add(nextSymbol);terminalExist=true;break}lastFirstSet=this.firstSetMap.get(nextSymbol);for(var _iterator=_create_for_of_iterator_helper_loose(lastFirstSet),_step;!(_step=_iterator()).done;){var t=_step.value;newLookaheadSet.add(t)}if(!lastFirstSet.has(ETokenType.EPSILON))break}if(!terminalExist&&(lastFirstSet==null?void 0:lastFirstSet.has(ETokenType.EPSILON))){for(var _iterator1=_create_for_of_iterator_helper_loose(item.lookaheadSet),_step1;!(_step1=_iterator1()).done;){var t1=_step1.value;newLookaheadSet.add(t1)}}for(var _iterator2=_create_for_of_iterator_helper_loose(productionList),_step2;!(_step2=_iterator2()).done;){var production=_step2.value;var newItem=state.createStateItem(production,0);if(!state.items.has(newItem)||!GrammarUtils.isSubSet(newLookaheadSet,newItem.lookaheadSet)){state.items.add(newItem);newItem.addLookahead(newLookaheadSet);this._extendStateItem(state,newItem)}}}else{for(var _iterator3=_create_for_of_iterator_helper_loose(productionList),_step3;!(_step3=_iterator3()).done;){var production1=_step3.value;var newItem1=state.createStateItem(production1,0);if(!state.items.has(newItem1)||!GrammarUtils.isSubSet(item.lookaheadSet,newItem1.lookaheadSet)){state.items.add(newItem1);newItem1.addLookahead(item.lookaheadSet);this._extendStateItem(state,newItem1)}}}};_proto._inferNextState=function _inferNextState(state){var coreMap=new Map;var _this_actionTable_get;var stateActionTable=(_this_actionTable_get=this.actionTable.get(state.id))!=null?_this_actionTable_get:new Map;var _this_gotoTable_get;var stateGotoTable=(_this_gotoTable_get=this.gotoTable.get(state.id))!=null?_this_gotoTable_get:new Map;this.actionTable.set(state.id,stateActionTable);this.gotoTable.set(state.id,stateGotoTable);for(var _iterator=_create_for_of_iterator_helper_loose(state.items),_step;!(_step=_iterator()).done;){var stateItem=_step.value;if(stateItem.canReduce()){var action=void 0;if(stateItem.production.goal!==NoneTerminal.START){action={action:EAction.Reduce,target:stateItem.production.id}}else{action={action:EAction.Accept}}for(var _iterator1=_create_for_of_iterator_helper_loose(stateItem.lookaheadSet),_step1;!(_step1=_iterator1()).done;){var t=_step1.value;this._addAction(stateActionTable,t,action)}}else{var nextItem=stateItem.advance();GrammarUtils.addMapSetItem(coreMap,stateItem.curSymbol,nextItem)}stateItem.needReInfer=false}var newStates=new Set;for(var _iterator2=_create_for_of_iterator_helper_loose(coreMap.entries()),_step2;!(_step2=_iterator2()).done;){var _step_value=_step2.value,gs=_step_value[0],cores=_step_value[1];var newState=State.create(Array.from(cores));if(GrammarUtils.isTerminal(gs)){this._addAction(stateActionTable,gs,{action:EAction.Shift,target:newState.id})}else{stateGotoTable.set(gs,newState.id)}newStates.add(newState)}return newStates};_proto._addAction=function _addAction(table,terminal,action){var exist=table.get(terminal);if(exist&&!GrammarUtils.isActionEqual(exist,action)){if(LALR1._isKnownShiftPreferred(terminal,exist,action)){if(exist.action===EAction.Shift&&action.action===EAction.Reduce)return}else{Logger.warn(\"conflict detect: <Terminal \"+GrammarUtils.toString(terminal)+\"> \\n\",GrammarUtils.printAction(exist),\"\\n\",GrammarUtils.printAction(action))}}table.set(terminal,action)};_proto.computeFirstSet=function computeFirstSet(){for(var _iterator=_create_for_of_iterator_helper_loose(this.grammar.productions.slice(1)),_step;!(_step=_iterator()).done;){var production=_step.value;this._computeFirstSetForNT(production.goal)}};_proto._computeFirstSetForNT=function _computeFirstSetForNT(NT){var idx=this._firstSetNTStack.findIndex(function(item){return item===NT});if(idx!==-1){var computingFS=this.firstSetMap.get(NT);var len=this._firstSetNTStack.length;for(var i=len-1;i>idx;i--){var curNT=this._firstSetNTStack[i];this.firstSetMap.set(curNT,computingFS)}return computingFS}this._firstSetNTStack.push(NT);var productionList=this.grammar.getProductionList(NT);var firstSet=new Set;this.firstSetMap.set(NT,firstSet);if(this.grammar.isNullableNT(NT))firstSet.add(ETokenType.EPSILON);for(var _iterator=_create_for_of_iterator_helper_loose(productionList),_step;!(_step=_iterator()).done;){var production=_step.value;var i1=0;for(;i1<production.derivation.length;i1++){var gs=production.derivation[i1];if(GrammarUtils.isTerminal(gs)){firstSet.add(gs);break}var succeedFirstSet=this._computeFirstSetForNT(gs);for(var _iterator1=_create_for_of_iterator_helper_loose(succeedFirstSet),_step1;!(_step1=_iterator1()).done;){var item=_step1.value;if(item!==ETokenType.EPSILON)firstSet.add(item)}if(!this.grammar.isNullableNT(gs))break}if(i1===production.derivation.length)firstSet.add(ETokenType.EPSILON)}this._firstSetNTStack.pop();return firstSet};LALR1._isKnownShiftPreferred=function _isKnownShiftPreferred(terminal,exist,action){if(terminal===Keyword.ELSE)return true;if(terminal!==ETokenType.LEFT_PAREN)return false;var reduce=exist.action===EAction.Reduce?exist:action.action===EAction.Reduce?action:null;if(!reduce)return false;var prod=Production.pool.get(reduce.target);return!!prod&&prod.goal===NoneTerminal.type_specifier_nonarray&&prod.derivation.length===1&&prod.derivation[0]===NoneTerminal.macro_call_symbol};return LALR1}();var Grammar=function(){function Grammar(start,productions){this.startSymbol=start;productions.unshift(new Production(NoneTerminal.START,[start]));this.productions=productions}var _proto=Grammar.prototype;_proto.getProductionList=function getProductionList(nonTerminal){return this.productions.filter(function(item){return item.goal===nonTerminal})};_proto.isNullableNT=function isNullableNT(NT){return this.productions.find(function(item){return item.goal===NT&&item.derivation[0]===ETokenType.EPSILON})};_proto.getProductionByID=function getProductionByID(pid){return Production.pool.get(pid)};Grammar.create=function create(start,productions){var _ps=productions.map(function(gsl){return new Production(gsl[0],gsl.slice(1))});return new Grammar(start,_ps)};return Grammar}();var productionAndRules=[].concat(GrammarUtils.createProductionWithOptions(NoneTerminal.gs_shader_program,[[NoneTerminal.global_declaration],[NoneTerminal.gs_shader_program,NoneTerminal.global_declaration]],ASTNode.GLShaderProgram),GrammarUtils.createProductionWithOptions(NoneTerminal.global_declaration,[[NoneTerminal.precision_specifier],[NoneTerminal.variable_declaration_statement],[NoneTerminal.struct_specifier],[NoneTerminal.function_definition],[NoneTerminal.global_macro_if_statement],[NoneTerminal.macro_undef],[NoneTerminal.macro_define],[Keyword.MACRO_DEFINE_EXPRESSION]],ASTNode.GlobalDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_define,[[Keyword.MACRO_DEFINE,ETokenType.ID,NoneTerminal.expression,Keyword.MACRO_DEFINE_END],[Keyword.MACRO_DEFINE,ETokenType.ID,Keyword.MACRO_DEFINE_PARAMS,NoneTerminal.expression,Keyword.MACRO_DEFINE_END]],ASTNode.MacroDefine),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_symbol,[[Keyword.MACRO_CALL]],ASTNode.MacroCallSymbol),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_function,[[NoneTerminal.macro_call_symbol,ETokenType.LEFT_PAREN,ETokenType.RIGHT_PAREN],[NoneTerminal.macro_call_symbol,ETokenType.LEFT_PAREN,NoneTerminal.function_call_parameter_list,ETokenType.RIGHT_PAREN]],ASTNode.MacroCallFunction),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_undef,[[Keyword.MACRO_UNDEF,ETokenType.ID],[Keyword.MACRO_UNDEF,Keyword.MACRO_CALL]],ASTNode.MacroUndef),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_push_context,[[Keyword.MACRO_IF,Keyword.MACRO_CONDITIONAL_EXPRESSION],[Keyword.MACRO_IFDEF,ETokenType.ID],[Keyword.MACRO_IFNDEF,ETokenType.ID],[Keyword.MACRO_IFDEF,NoneTerminal.macro_call_symbol],[Keyword.MACRO_IFNDEF,NoneTerminal.macro_call_symbol]],ASTNode.MacroPushContext),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_pop_context,[[Keyword.MACRO_ENDIF]],ASTNode.MacroPopContext),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_elif_expression,[[Keyword.MACRO_ELIF,Keyword.MACRO_CONDITIONAL_EXPRESSION]],ASTNode.MacroElifExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_else_expression,[[Keyword.MACRO_ELSE]],ASTNode.MacroElseExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_declaration,[[NoneTerminal.global_declaration],[NoneTerminal.global_macro_declaration,NoneTerminal.global_declaration]],ASTNode.GlobalMacroDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_if_statement,[[NoneTerminal.macro_push_context,NoneTerminal.global_macro_declaration,NoneTerminal.global_macro_branch],[NoneTerminal.macro_push_context,NoneTerminal.global_macro_branch]],ASTNode.GlobalMacroIfStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.global_macro_declaration,NoneTerminal.global_macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.global_macro_declaration,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.global_macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.GlobalMacroBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration,[[NoneTerminal.fully_specified_type,ETokenType.ID],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.VariableDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration_list,[[NoneTerminal.variable_declaration],[NoneTerminal.variable_declaration_list,ETokenType.COMMA,ETokenType.ID],[NoneTerminal.variable_declaration_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.VariableDeclarationList),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration_statement,[[NoneTerminal.variable_declaration_list,ETokenType.SEMICOLON]]),GrammarUtils.createProductionWithOptions(NoneTerminal.ext_builtin_type_specifier_nonarray,[[Keyword.VOID],[Keyword.FLOAT],[Keyword.BOOL],[Keyword.INT],[Keyword.UINT],[Keyword.VEC2],[Keyword.VEC3],[Keyword.VEC4],[Keyword.BVEC2],[Keyword.BVEC3],[Keyword.BVEC4],[Keyword.IVEC2],[Keyword.IVEC3],[Keyword.IVEC4],[Keyword.UVEC2],[Keyword.UVEC3],[Keyword.UVEC4],[Keyword.MAT2],[Keyword.MAT3],[Keyword.MAT4],[Keyword.MAT2X3],[Keyword.MAT2X4],[Keyword.MAT3X2],[Keyword.MAT3X4],[Keyword.MAT4X2],[Keyword.MAT4X3],[Keyword.SAMPLER2D],[Keyword.SAMPLER3D],[Keyword.SAMPLER_CUBE],[Keyword.SAMPLER2D_SHADOW],[Keyword.SAMPLER_CUBE_SHADOW],[Keyword.SAMPLER2D_ARRAY],[Keyword.SAMPLER2D_ARRAY_SHADOW],[Keyword.I_SAMPLER2D],[Keyword.I_SAMPLER3D],[Keyword.I_SAMPLER_CUBE],[Keyword.I_SAMPLER2D_ARRAY],[Keyword.U_SAMPLER2D],[Keyword.U_SAMPLER3D],[Keyword.U_SAMPLER_CUBE],[Keyword.U_SAMPLER2D_ARRAY]],ASTNode.ExtBuiltinTypeSpecifierNonArray),GrammarUtils.createProductionWithOptions(NoneTerminal.type_specifier_nonarray,[[ETokenType.ID],[NoneTerminal.ext_builtin_type_specifier_nonarray],[NoneTerminal.macro_call_symbol]],ASTNode.TypeSpecifierNonArray),GrammarUtils.createProductionWithOptions(NoneTerminal.fully_specified_type,[[NoneTerminal.type_specifier],[NoneTerminal.type_qualifier,NoneTerminal.type_specifier]],ASTNode.FullySpecifiedType),GrammarUtils.createProductionWithOptions(NoneTerminal.type_specifier,[[NoneTerminal.type_specifier_nonarray],[NoneTerminal.ext_builtin_type_specifier_nonarray,NoneTerminal.array_specifier]],ASTNode.TypeSpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.type_qualifier,[[NoneTerminal.single_type_qualifier],[NoneTerminal.type_qualifier,NoneTerminal.single_type_qualifier]],ASTNode.TypeQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.single_type_qualifier,[[NoneTerminal.storage_qualifier],[NoneTerminal.precision_qualifier],[NoneTerminal.interpolation_qualifier],[NoneTerminal.invariant_qualifier],[Keyword.PRECISE]],ASTNode.SingleTypeQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.storage_qualifier,[[Keyword.CONST],[Keyword.IN],[Keyword.INOUT],[Keyword.OUT],[Keyword.CENTROID]],ASTNode.StorageQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.interpolation_qualifier,[[Keyword.SMOOTH],[Keyword.FLAT]],ASTNode.InterpolationQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.invariant_qualifier,[[Keyword.INVARIANT]],ASTNode.InvariantQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.precision_qualifier,[[Keyword.HIGHP],[Keyword.MEDIUMP],[Keyword.LOWP]],ASTNode.PrecisionQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_specifier,[[Keyword.STRUCT,ETokenType.ID,ETokenType.LEFT_BRACE,NoneTerminal.struct_declaration_list,ETokenType.RIGHT_BRACE,ETokenType.SEMICOLON],[Keyword.STRUCT,ETokenType.LEFT_BRACE,NoneTerminal.struct_declaration_list,ETokenType.RIGHT_BRACE,ETokenType.SEMICOLON]],ASTNode.StructSpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declaration_list,[[NoneTerminal.struct_declaration],[NoneTerminal.struct_declaration_list,NoneTerminal.struct_declaration]],ASTNode.StructDeclarationList),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declaration,[[NoneTerminal.type_specifier,NoneTerminal.struct_declarator_list,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,NoneTerminal.type_specifier,NoneTerminal.struct_declarator_list,ETokenType.SEMICOLON],[NoneTerminal.layout_qualifier,NoneTerminal.type_specifier,NoneTerminal.struct_declarator,ETokenType.SEMICOLON],[NoneTerminal.macro_struct_declaration]],ASTNode.StructDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_struct_declaration,[[NoneTerminal.macro_push_context,NoneTerminal.struct_declaration_list,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_struct_branch]],ASTNode.MacroStructDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_struct_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.struct_declaration_list,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_else_expression,NoneTerminal.struct_declaration_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroStructBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.layout_qualifier,[[Keyword.LAYOUT,ETokenType.LEFT_PAREN,Keyword.LOCATION,ETokenType.EQUAL,ETokenType.INT_CONSTANT,ETokenType.RIGHT_PAREN]],ASTNode.LayoutQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declarator_list,[[NoneTerminal.struct_declarator],[NoneTerminal.struct_declarator_list,ETokenType.COMMA,NoneTerminal.struct_declarator]],ASTNode.StructDeclaratorList),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declarator,[[ETokenType.ID],[ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.StructDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.array_specifier,[[ETokenType.LEFT_BRACKET,ETokenType.RIGHT_BRACKET],[ETokenType.LEFT_BRACKET,NoneTerminal.integer_constant_expression,ETokenType.RIGHT_BRACKET]],ASTNode.ArraySpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.integer_constant_expression_operator,[[ETokenType.PLUS],[ETokenType.DASH],[ETokenType.STAR],[ETokenType.SLASH],[ETokenType.PERCENT]],ASTNode.IntegerConstantExpressionOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.integer_constant_expression,[[NoneTerminal.variable_identifier],[ETokenType.INT_CONSTANT],[NoneTerminal.integer_constant_expression,NoneTerminal.integer_constant_expression_operator,ETokenType.INT_CONSTANT],[NoneTerminal.integer_constant_expression,NoneTerminal.integer_constant_expression_operator,NoneTerminal.variable_identifier]],ASTNode.IntegerConstantExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.conditional_expression,[[NoneTerminal.logical_or_expression],[NoneTerminal.logical_or_expression,ETokenType.QUESTION,NoneTerminal.expression,ETokenType.COLON,NoneTerminal.assignment_expression]],ASTNode.ConditionalExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_or_expression,[[NoneTerminal.logical_xor_expression],[NoneTerminal.logical_or_expression,ETokenType.OR_OP,NoneTerminal.logical_xor_expression]],ASTNode.LogicalOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_xor_expression,[[NoneTerminal.logical_and_expression],[NoneTerminal.logical_xor_expression,ETokenType.XOR_OP,NoneTerminal.logical_and_expression]],ASTNode.LogicalXorExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_and_expression,[[NoneTerminal.inclusive_or_expression],[NoneTerminal.logical_and_expression,ETokenType.AND_OP,NoneTerminal.inclusive_or_expression]],ASTNode.LogicalAndExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.inclusive_or_expression,[[NoneTerminal.exclusive_or_expression],[NoneTerminal.inclusive_or_expression,ETokenType.VERTICAL_BAR,NoneTerminal.exclusive_or_expression]],ASTNode.InclusiveOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.exclusive_or_expression,[[NoneTerminal.and_expression],[NoneTerminal.exclusive_or_expression,ETokenType.CARET,NoneTerminal.and_expression]],ASTNode.ExclusiveOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.and_expression,[[NoneTerminal.equality_expression],[NoneTerminal.and_expression,ETokenType.AMPERSAND,NoneTerminal.equality_expression]],ASTNode.AndExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.equality_expression,[[NoneTerminal.relational_expression],[NoneTerminal.equality_expression,ETokenType.EQ_OP,NoneTerminal.relational_expression],[NoneTerminal.equality_expression,ETokenType.NE_OP,NoneTerminal.relational_expression]],ASTNode.EqualityExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.relational_expression,[[NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.LEFT_ANGLE,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.RIGHT_ANGLE,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.LE_OP,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.GE_OP,NoneTerminal.shift_expression]],ASTNode.RelationalExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.shift_expression,[[NoneTerminal.additive_expression],[NoneTerminal.shift_expression,ETokenType.LEFT_OP,NoneTerminal.additive_expression],[NoneTerminal.shift_expression,ETokenType.RIGHT_OP,NoneTerminal.additive_expression]],ASTNode.ShiftExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.additive_expression,[[NoneTerminal.multiplicative_expression],[NoneTerminal.additive_expression,ETokenType.PLUS,NoneTerminal.multiplicative_expression],[NoneTerminal.additive_expression,ETokenType.DASH,NoneTerminal.multiplicative_expression]],ASTNode.AdditiveExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.multiplicative_expression,[[NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.STAR,NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.SLASH,NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.PERCENT,NoneTerminal.unary_expression]],ASTNode.MultiplicativeExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.unary_expression,[[NoneTerminal.postfix_expression],[ETokenType.INC_OP,NoneTerminal.unary_expression],[ETokenType.DEC_OP,NoneTerminal.unary_expression],[NoneTerminal.unary_operator,NoneTerminal.unary_expression]],ASTNode.UnaryExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.unary_operator,[[ETokenType.PLUS],[ETokenType.DASH],[ETokenType.BANG],[ETokenType.TILDE]],ASTNode.UnaryOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.postfix_expression,[[NoneTerminal.primary_expression],[NoneTerminal.postfix_expression,ETokenType.LEFT_BRACKET,NoneTerminal.expression,ETokenType.RIGHT_BRACKET],[NoneTerminal.function_call],[NoneTerminal.postfix_expression,ETokenType.DOT,ETokenType.ID],[NoneTerminal.postfix_expression,ETokenType.DOT,NoneTerminal.function_call],[NoneTerminal.postfix_expression,ETokenType.INC_OP],[NoneTerminal.postfix_expression,ETokenType.DEC_OP]],ASTNode.PostfixExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.primary_expression,[[NoneTerminal.variable_identifier],[ETokenType.INT_CONSTANT],[ETokenType.FLOAT_CONSTANT],[Keyword.True],[Keyword.False],[ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN]],ASTNode.PrimaryExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.expression,[[NoneTerminal.assignment_expression],[NoneTerminal.expression,ETokenType.COMMA,NoneTerminal.assignment_expression]],ASTNode.Expression),GrammarUtils.createProductionWithOptions(NoneTerminal.assignment_expression,[[NoneTerminal.conditional_expression],[NoneTerminal.unary_expression,NoneTerminal.assignment_operator,NoneTerminal.assignment_expression]],ASTNode.AssignmentExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.assignment_operator,[[ETokenType.EQUAL],[ETokenType.MUL_ASSIGN],[ETokenType.DIV_ASSIGN],[ETokenType.MOD_ASSIGN],[ETokenType.ADD_ASSIGN],[ETokenType.SUB_ASSIGN],[ETokenType.LEFT_ASSIGN],[ETokenType.RIGHT_ASSIGN],[ETokenType.AND_ASSIGN],[ETokenType.XOR_ASSIGN],[ETokenType.OR_ASSIGN]],ASTNode.AssignmentOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call,[[NoneTerminal.function_call_generic]],ASTNode.FunctionCall),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call_generic,[[NoneTerminal.function_identifier,ETokenType.LEFT_PAREN,NoneTerminal.function_call_parameter_list,ETokenType.RIGHT_PAREN],[NoneTerminal.function_identifier,ETokenType.LEFT_PAREN,ETokenType.RIGHT_PAREN],[NoneTerminal.function_identifier,Keyword.VOID,ETokenType.RIGHT_PAREN]],ASTNode.FunctionCallGeneric),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call_parameter_list,[[NoneTerminal.assignment_expression],[NoneTerminal.function_call_parameter_list,ETokenType.COMMA,NoneTerminal.assignment_expression],[NoneTerminal.macro_call_arg_block],[NoneTerminal.function_call_parameter_list,NoneTerminal.macro_call_arg_block]],ASTNode.FunctionCallParameterList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_case_list,[[NoneTerminal.assignment_expression],[ETokenType.COMMA,NoneTerminal.assignment_expression],[NoneTerminal.macro_call_arg_block],[NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_block],[NoneTerminal.macro_call_arg_case_list,ETokenType.COMMA,NoneTerminal.assignment_expression]],ASTNode.MacroCallArgCaseList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_block,[[NoneTerminal.macro_push_context,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_branch]],ASTNode.MacroCallArgBlock),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroCallArgBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.function_identifier,[[NoneTerminal.type_specifier]],ASTNode.FunctionIdentifier),GrammarUtils.createProductionWithOptions(NoneTerminal.function_definition,[[NoneTerminal.function_prototype,NoneTerminal.compound_statement_no_scope]],ASTNode.FunctionDefinition),GrammarUtils.createProductionWithOptions(NoneTerminal.function_prototype,[[NoneTerminal.function_declarator,ETokenType.RIGHT_PAREN]],ASTNode.FunctionProtoType),GrammarUtils.createProductionWithOptions(NoneTerminal.function_declarator,[[NoneTerminal.function_header],[NoneTerminal.function_header,NoneTerminal.function_parameter_list]],ASTNode.FunctionDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.function_header,[[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.LEFT_PAREN]],ASTNode.FunctionHeader),GrammarUtils.createProductionWithOptions(NoneTerminal.function_parameter_list,[[NoneTerminal.parameter_declaration],[NoneTerminal.function_parameter_list,ETokenType.COMMA,NoneTerminal.parameter_declaration],[NoneTerminal.macro_param_block],[NoneTerminal.function_parameter_list,NoneTerminal.macro_param_block]],ASTNode.FunctionParameterList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_param_case_list,[[NoneTerminal.parameter_declaration],[ETokenType.COMMA,NoneTerminal.parameter_declaration],[NoneTerminal.macro_param_block],[NoneTerminal.macro_param_case_list,NoneTerminal.macro_param_block],[NoneTerminal.macro_param_case_list,ETokenType.COMMA,NoneTerminal.parameter_declaration]],ASTNode.MacroParamCaseList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_param_block,[[NoneTerminal.macro_push_context,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_param_case_list,NoneTerminal.macro_parameter_branch]],ASTNode.MacroParamBlock),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_parameter_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_param_case_list,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_param_case_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroParameterBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.parameter_declaration,[[NoneTerminal.type_qualifier,NoneTerminal.parameter_declarator],[NoneTerminal.parameter_declarator],[NoneTerminal.macro_call_symbol],[NoneTerminal.macro_call_function]],ASTNode.ParameterDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.parameter_declarator,[[NoneTerminal.type_specifier,ETokenType.ID],[NoneTerminal.type_specifier,ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.ParameterDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.statement_list,[[NoneTerminal.statement],[NoneTerminal.statement_list,NoneTerminal.statement]],ASTNode.StatementList),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.statement,[[NoneTerminal.compound_statement],[NoneTerminal.simple_statement]],ASTNode.Statement),GrammarUtils.createProductionWithOptions(NoneTerminal.compound_statement_no_scope,[[ETokenType.LEFT_BRACE,ETokenType.RIGHT_BRACE],[ETokenType.LEFT_BRACE,NoneTerminal.statement_list,ETokenType.RIGHT_BRACE]],ASTNode.CompoundStatementNoScope),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.compound_statement,[[ETokenType.LEFT_BRACE,ETokenType.RIGHT_BRACE],[NoneTerminal.scope_brace,NoneTerminal.statement_list,NoneTerminal.scope_end_brace]],ASTNode.CompoundStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.simple_statement,[[NoneTerminal.declaration],[NoneTerminal.expression_statement],[NoneTerminal.selection_statement],[NoneTerminal.iteration_statement],[NoneTerminal.jump_statement],[NoneTerminal.macro_if_statement],[NoneTerminal.macro_undef],[NoneTerminal.macro_define],[Keyword.MACRO_DEFINE_EXPRESSION]],ASTNode.SimpleStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.declaration,[[NoneTerminal.function_prototype,ETokenType.SEMICOLON],[NoneTerminal.init_declarator_list,ETokenType.SEMICOLON],[Keyword.PRECISION,NoneTerminal.precision_qualifier,NoneTerminal.ext_builtin_type_specifier_nonarray,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,ETokenType.ID,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,ETokenType.ID,NoneTerminal.identifier_list,ETokenType.SEMICOLON]],ASTNode.Declaration),GrammarUtils.createProductionWithOptions(NoneTerminal.identifier_list,[[ETokenType.COMMA,ETokenType.ID],[NoneTerminal.identifier_list,ETokenType.COMMA,ETokenType.ID]],ASTNode.IdentifierList),GrammarUtils.createProductionWithOptions(NoneTerminal.init_declarator_list,[[NoneTerminal.single_declaration],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.InitDeclaratorList),GrammarUtils.createProductionWithOptions(NoneTerminal.single_declaration,[[NoneTerminal.fully_specified_type,ETokenType.ID],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.fully_specified_type,Keyword.MACRO_CALL],[NoneTerminal.fully_specified_type,Keyword.MACRO_CALL,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.SingleDeclaration),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.initializer,[[NoneTerminal.assignment_expression],[ETokenType.LEFT_BRACE,NoneTerminal.initializer_list,ETokenType.RIGHT_BRACE]],ASTNode.Initializer),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.initializer_list,[[NoneTerminal.initializer],[NoneTerminal.initializer_list,ETokenType.COMMA,NoneTerminal.initializer]],ASTNode.InitializerList),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.expression_statement,[[ETokenType.SEMICOLON],[NoneTerminal.expression,ETokenType.SEMICOLON]],ASTNode.ExpressionStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.selection_statement,[[Keyword.IF,ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN,NoneTerminal.statement],[Keyword.IF,ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN,NoneTerminal.statement,Keyword.ELSE,NoneTerminal.statement]],ASTNode.SelectionStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.iteration_statement,[[Keyword.WHILE,ETokenType.LEFT_PAREN,NoneTerminal.condition,ETokenType.RIGHT_PAREN,NoneTerminal.statement],[Keyword.FOR,ETokenType.LEFT_PAREN,NoneTerminal.for_init_statement,NoneTerminal.for_rest_statement,ETokenType.RIGHT_PAREN,NoneTerminal.statement]],ASTNode.IterationStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.precision_specifier,[[Keyword.PRECISION,NoneTerminal.precision_qualifier,NoneTerminal.ext_builtin_type_specifier_nonarray,ETokenType.SEMICOLON]],ASTNode.PrecisionSpecifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.for_init_statement,[[NoneTerminal.expression_statement],[NoneTerminal.declaration]],ASTNode.ForInitStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.condition,[[NoneTerminal.expression],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.Condition),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.for_rest_statement,[[NoneTerminal.conditionopt,ETokenType.SEMICOLON],[NoneTerminal.conditionopt,ETokenType.SEMICOLON,NoneTerminal.expression]],ASTNode.ForRestStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.conditionopt,[[ETokenType.EPSILON],[NoneTerminal.condition]],ASTNode.ConditionOpt),GrammarUtils.createProductionWithOptions(NoneTerminal.jump_statement,[[Keyword.CONTINUE,ETokenType.SEMICOLON],[Keyword.BREAK,ETokenType.SEMICOLON],[Keyword.RETURN,ETokenType.SEMICOLON],[Keyword.RETURN,NoneTerminal.expression,ETokenType.SEMICOLON],[Keyword.DISCARD,ETokenType.SEMICOLON]],ASTNode.JumpStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.scope_brace,[[ETokenType.LEFT_BRACE]],ASTNode.ScopeBrace),GrammarUtils.createProductionWithOptions(NoneTerminal.scope_end_brace,[[ETokenType.RIGHT_BRACE]],ASTNode.ScopeEndBrace),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_identifier,[[ETokenType.ID],[NoneTerminal.macro_call_symbol],[NoneTerminal.macro_call_function]],ASTNode.VariableIdentifier),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_if_statement,[[NoneTerminal.macro_push_context,NoneTerminal.statement_list,NoneTerminal.macro_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_branch]],ASTNode.MacroIfStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.statement_list,NoneTerminal.macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.statement_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroBranch));var createGrammar=function(){return Grammar.create(NoneTerminal.gs_shader_program,productionAndRules.map(function(item){return item[0]}))};var translationRules=productionAndRules.map(function(item){return item[1]});var addTranslationRule=function(sa){sa.setTranslationRules(translationRules)};var ShaderData=function(){function ShaderData(){this.globalPrecisions=[];this.globalMacroDeclarations=[];this.directMemberOwnerReferences=[];this.referenceResolutionSnapshots=[]}var _proto=ShaderData.prototype;_proto.getOuterGlobalMacroDeclarations=function getOuterGlobalMacroDeclarations(){return this.globalMacroDeclarations.filter(function(node){return _instanceof(node.parent,ASTNode.GLShaderProgram)})};return ShaderData}();function createShaderDeclarationOwnership(symbolTable){var groups=new Map;var names=new Map;var keys=new Map;symbolTable.forEach(function(symbol){if(!symbol.astNode)return;var name=JSON.stringify([symbol.type,symbol.ident]);var _names_get;var candidates=(_names_get=names.get(name))!=null?_names_get:[];candidates.push(symbol);names.set(name,candidates);var key=declarationKey(symbol);keys.set(symbol,key);if(key===undefined)return;var _groups_get;var group=(_groups_get=groups.get(key))!=null?_groups_get:[];group.push(symbol);groups.set(key,group)});var declarations=new Map;var coverage=new Map;var unsupported=new Set;var groupId=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups.values()),_step;!(_step=_iterator()).done;){var _loop=function(){var earlier=_step1.value;var narrower=group.filter(function(candidate){return candidate.sourceScope>earlier.sourceScope});if(!narrower.length)return\"continue\";var proof=proveInheritanceBranchesCover(narrower.map(function(candidate){return candidate.branchSignature}),earlier.branchSignature);coverage.set(earlier,proof);deferred||(deferred=proof===undefined)};var group=_step.value;var deferred=false;for(var _iterator1=_create_for_of_iterator_helper_loose(group),_step1;!(_step1=_iterator1()).done;)_loop();if(!deferred)continue;groupId++;for(var _iterator2=_create_for_of_iterator_helper_loose(group),_step2;!(_step2=_iterator2()).done;){var symbol=_step2.value;declarations.set(symbol,{id:declarations.size+1,group:groupId,sourceScope:symbol.sourceScope});if(coverage.get(symbol)!==false)continue;for(var _iterator3=_create_for_of_iterator_helper_loose(group),_step3;!(_step3=_iterator3()).done;){var narrower=_step3.value;if(narrower.sourceScope<=symbol.sourceScope)continue;if(proveInheritanceBranchesCover([],symbol.branchSignature.concat(narrower.branchSignature))===false){unsupported.add(symbol);unsupported.add(narrower)}}}}for(var _iterator4=_create_for_of_iterator_helper_loose(names.values()),_step4;!(_step4=_iterator4()).done;){var _loop1=function(){var earlier=_step5.value;var narrower=candidates.filter(function(candidate){return candidate.sourceScope>earlier.sourceScope&&candidate.equal(earlier)});if(!narrower.length||keys.get(earlier)!==undefined&&narrower.every(function(candidate){return keys.get(candidate)}))return\"continue\";if(proveInheritanceBranchesCover(narrower.map(function(candidate){return candidate.branchSignature}),earlier.branchSignature)===undefined){unsupported.add(earlier);for(var _iterator=_create_for_of_iterator_helper_loose(narrower),_step;!(_step=_iterator()).done;){var candidate=_step.value;unsupported.add(candidate)}}};var candidates=_step4.value;if(!candidates.some(function(candidate){return keys.get(candidate)===undefined}))continue;for(var _iterator5=_create_for_of_iterator_helper_loose(candidates),_step5;!(_step5=_iterator5()).done;)_loop1()}return{declarations:declarations,unsupported:Array.from(unsupported),coverage:coverage}}function isDeferredDeclarationPair(facts,left,right){var _facts_declarations_get,_facts_declarations_get1;if(left.sourceScope===right.sourceScope)return false;var group=(_facts_declarations_get=facts.declarations.get(left))==null?void 0:_facts_declarations_get.group;if(group===undefined||((_facts_declarations_get1=facts.declarations.get(right))==null?void 0:_facts_declarations_get1.group)!==group)return false;var earlier=left.sourceScope<right.sourceScope?left:right;return facts.coverage.has(earlier)&&facts.coverage.get(earlier)===undefined}function declarationKey(symbol){if(symbol.type!==ESymbolType.FN)return JSON.stringify([symbol.type,symbol.ident]);if(!_instanceof(symbol,FnSymbol))return;var _symbol_astNode_protoType_parameterList;var parameters=(_symbol_astNode_protoType_parameterList=symbol.astNode.protoType.parameterList)!=null?_symbol_astNode_protoType_parameterList:[];var signature=[];for(var _iterator=_create_for_of_iterator_helper_loose(parameters),_step;!(_step=_iterator()).done;){var parameter=_step.value;var type=parameter.typeInfo;if(!type||type.type===TypeAny)return;if(type.type===Keyword.VOID&¶meters.length===1&&!type.arraySpecifier)continue;var array=type.arraySpecifier;var shape=null;if(array){if(array.children.some(function(child){return _instanceof(child,ASTNode.ArraySpecifier)}))return;if(array.children.length===2)shape=\"unsized\";else if(array.size!==undefined)shape=array.size;else return}signature.push([type.type,shape])}return JSON.stringify([symbol.type,symbol.ident,signature])}var SemanticAnalyzer=function(){function SemanticAnalyzer(branchSemantics,semanticDiagnostics,objectPool,diagnosticsEnabled){if(diagnosticsEnabled===void 0)diagnosticsEnabled=semanticDiagnostics!==undefined;this.branchSemantics=branchSemantics;this.semanticDiagnostics=semanticDiagnostics;this.objectPool=objectPool;this.lookupSymbol=new SymbolInfo(\"\",null);this.arraySymbolScratch=[];this.overloadScratch=[];this.structScratch=[];this.runtimeLookupScratch=[];this.runtimeFallbackScratch=[];this.semanticStack=[];this.acceptRule=undefined;this.symbolTableStack=new SymbolTableStack;this._functionCaptures=[];this._shaderData=new ShaderData;this._translationRules=[];this._sourceScopes=[];this._inheritedDeclarations=[];this.errors=[];this.inMacroDefinition=false;this._ambiguousReported=new Set;this.diagnosticsEnabled=diagnosticsEnabled;this.symbolTableStack.branchSemantics=branchSemantics;this.pushScope()}var _proto=SemanticAnalyzer.prototype;_proto.reset=function reset(macroDefineList){this._macroDefineList=macroDefineList;this.semanticStack.length=0;this._shaderData=new ShaderData;this.symbolTableStack.clear();this.pushScope();this.errors.length=0;this.inMacroDefinition=false;this._ambiguousReported.clear();this._inheritedDeclarations.length=0;this._functionCaptures.length=0;this.runtimeLookupScratch.length=0;this.runtimeFallbackScratch.length=0};_proto.pushScope=function pushScope(){this.symbolTableStack.pushScope(new SymbolTable)};_proto.popScope=function popScope(){return this.symbolTableStack.popScope()};_proto.setTranslationRules=function setTranslationRules(rules){this._translationRules=rules};_proto.setSourceScopes=function setSourceScopes(sourceScopes){this._sourceScopes=sourceScopes};_proto.assignSourceScope=function assignSourceScope(symbol,location){var offset=location.start.index;var segments=this._sourceScopes;var low=0;var high=segments.length-1;while(low<=high){var mid=low+high>>>1;var segment=segments[mid];if(offset<segment.generatedStart){high=mid-1}else if(offset>=segment.generatedEnd){low=mid+1}else{var _segment_sourceScope;symbol.sourceScope=(_segment_sourceScope=segment.sourceScope)!=null?_segment_sourceScope:0;return symbol}}symbol.sourceScope=0;return symbol};_proto.getTranslationRule=function getTranslationRule(pid){return this._translationRules[pid]};_proto.beginFunction=function beginFunction(header){this._functionCaptures.push({header:header,localVariables:[],calledFunctions:[]})};_proto.endFunction=function endFunction(){return this._functionCaptures.pop()};_proto.recordFunctionVariable=function recordFunctionVariable(variable){var _this__functionCaptures_;(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.localVariables.push(variable)};_proto.recordFunctionCall=function recordFunctionCall(fn){var _this__functionCaptures_;(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.calledFunctions.push(fn)};_proto.reportRedefinition=function reportRedefinition(loc,symbol,conflict){var _this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.redefinition(loc,symbol.ident,conflict,symbol.branchSignature));if(this.semanticDiagnostics&&symbol.sourceScope>0&&this.symbolTableStack.stack.length===1&&!this.inMacroDefinition&&this._isCurrentBranchReachable()){this._inheritedDeclarations.push({symbol:symbol,location:loc})}};_proto.finalizeInheritance=function finalizeInheritance(){var ownership=this._shaderData.declarationOwnership=createShaderDeclarationOwnership(this.symbolTableStack.scope);if(!this.branchSemantics||!this.semanticDiagnostics)return;for(var _iterator=_create_for_of_iterator_helper_loose(this._inheritedDeclarations),_step;!(_step=_iterator()).done;){var _step_value=_step.value,symbol=_step_value.symbol,location=_step_value.location;var conflict=this.symbolTableStack.scope.getInheritedConflict(symbol,this.branchSemantics,function(left,right){return isDeferredDeclarationPair(ownership,left,right)});var error=this.semanticDiagnostics.redefinition(location,symbol.ident,conflict,symbol.branchSignature);if(error)this.errors.push(error)}this._inheritedDeclarations.length=0};_proto.reportBranchAvailability=function reportBranchAvailability(loc,subjectKind,name,coverage){var _this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.branchAvailability(loc,subjectKind,name,coverage))};_proto.reportBranchAmbiguity=function reportBranchAmbiguity(loc,key,kind,name,owner){var _this_semanticDiagnostics;var createDiagnostic=(_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.branchAmbiguity;if(!createDiagnostic)return;var dedupKey=kind+\":\"+key;if(this._ambiguousReported.has(dedupKey))return;var error=createDiagnostic.call(this.semanticDiagnostics,loc,kind,name,owner);if(!error)return;this._ambiguousReported.add(dedupKey);this._report(error)};_proto.reportNonConstArraySize=function reportNonConstArraySize(loc){var _this_semanticDiagnostics_nonConstArraySize,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_nonConstArraySize=_this_semanticDiagnostics.nonConstArraySize)==null?void 0:_this_semanticDiagnostics_nonConstArraySize.call(_this_semanticDiagnostics,loc))};_proto.reportExpectedSampler=function reportExpectedSampler(loc,functionName,actualType){var _this_semanticDiagnostics_expectedSampler,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_expectedSampler=_this_semanticDiagnostics.expectedSampler)==null?void 0:_this_semanticDiagnostics_expectedSampler.call(_this_semanticDiagnostics,loc,functionName,actualType))};_proto.reportNoMatchingOverload=function reportNoMatchingOverload(loc,functionName){var _this_semanticDiagnostics_noMatchingOverload,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_noMatchingOverload=_this_semanticDiagnostics.noMatchingOverload)==null?void 0:_this_semanticDiagnostics_noMatchingOverload.call(_this_semanticDiagnostics,loc,functionName))};_proto.reportUndeclaredStructMember=function reportUndeclaredStructMember(loc,structName,memberName){var _this_semanticDiagnostics_undeclaredStructMember,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_undeclaredStructMember=_this_semanticDiagnostics.undeclaredStructMember)==null?void 0:_this_semanticDiagnostics_undeclaredStructMember.call(_this_semanticDiagnostics,loc,structName,memberName))};_proto.canBranchesOverlap=function canBranchesOverlap(left,right){var _this_branchSemantics;var _this_branchSemantics_canBranchesOverlap;return(_this_branchSemantics_canBranchesOverlap=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.canBranchesOverlap(left,right))!=null?_this_branchSemantics_canBranchesOverlap:getLexicalDeclarationCoexistence(left,right)!==\"exclusive\"};_proto.canDeclarationsCoexist=function canDeclarationsCoexist(earlier,later){var _this_branchSemantics;var _this_branchSemantics_canDeclarationsCoexist;return(_this_branchSemantics_canDeclarationsCoexist=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.canDeclarationsCoexist(earlier,later))!=null?_this_branchSemantics_canDeclarationsCoexist:true};_proto.getBranchCoverage=function getBranchCoverage(candidates,callSiteBranch){var _this_branchSemantics;var _this_branchSemantics_getBranchCoverage;return(_this_branchSemantics_getBranchCoverage=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.getBranchCoverage(candidates,callSiteBranch))!=null?_this_branchSemantics_getBranchCoverage:\"covered\"};_proto.isBranchVisibleFrom=function isBranchVisibleFrom(defBranch,callSiteBranch){var _this_branchSemantics;var _this_branchSemantics_isBranchVisibleFrom;return(_this_branchSemantics_isBranchVisibleFrom=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.isBranchVisibleFrom(defBranch,callSiteBranch))!=null?_this_branchSemantics_isBranchVisibleFrom:true};_proto._report=function _report(error){if(!error||this.inMacroDefinition||!this._isCurrentBranchReachable())return;this.errors.push(error)};_proto._isCurrentBranchReachable=function _isCurrentBranchReachable(){var _this_branchSemantics;var _this_branchSemantics_isBranchReachable;return(_this_branchSemantics_isBranchReachable=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.isBranchReachable(this.symbolTableStack._currentBranch))!=null?_this_branchSemantics_isBranchReachable:true};_create_class(SemanticAnalyzer,[{key:\"shaderData\",get:function get(){return this._shaderData}},{key:\"macroDefineList\",get:function get(){return this._macroDefineList}},{key:\"currentFunctionHeader\",get:function get(){var _this__functionCaptures_;return(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.header}}]);return SemanticAnalyzer}();var ShaderTargetParser=function(){function ShaderTargetParser(actionTable,gotoTable,grammar,branchSemantics,semanticDiagnostics,_source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled){if(semanticErrorsBlockCodegen===void 0)semanticErrorsBlockCodegen=false;if(authoringAnalysisEnabled===void 0)authoringAnalysisEnabled=semanticDiagnostics!==undefined;this._source=_source;this.semanticErrorsBlockCodegen=semanticErrorsBlockCodegen;this.blockingErrors=[];this._traceBackStack=[];this.actionTable=actionTable;this.gotoTable=gotoTable;this.grammar=grammar;this.semanticAnalyzer=new SemanticAnalyzer(branchSemantics,semanticDiagnostics,objectPool,authoringAnalysisEnabled)}var _proto=ShaderTargetParser.prototype;_proto.setSource=function setSource(source){var _this_semanticAnalyzer_semanticDiagnostics_setSource,_this_semanticAnalyzer_semanticDiagnostics;this._source=source;(_this_semanticAnalyzer_semanticDiagnostics=this.semanticAnalyzer.semanticDiagnostics)==null?void 0:(_this_semanticAnalyzer_semanticDiagnostics_setSource=_this_semanticAnalyzer_semanticDiagnostics.setSource)==null?void 0:_this_semanticAnalyzer_semanticDiagnostics_setSource.call(_this_semanticAnalyzer_semanticDiagnostics,source)};_proto.setSourceScopes=function setSourceScopes(sourceScopes){this.semanticAnalyzer.setSourceScopes(sourceScopes)};_proto.parse=function parse(tokens,macroDefineList){this.semanticAnalyzer.reset(macroDefineList);this.blockingErrors.length=0;var _this=this,traceBackStack=_this._traceBackStack,semanticAnalyzer=_this.semanticAnalyzer;traceBackStack.length=0;traceBackStack.push(0);try{var nextToken=tokens.next();while(true){var token=nextToken.value;var actionInfo=this.stateActionTable.get(token.type);if((actionInfo==null?void 0:actionInfo.action)===EAction.Shift){traceBackStack.push(token,actionInfo.target);if(token.type===Keyword.MACRO_DEFINE_PARAMS){semanticAnalyzer.pushScope();for(var _iterator=_create_for_of_iterator_helper_loose(ParserUtils.parseMacroParamList(token.lexeme)),_step;!(_step=_iterator()).done;){var p=_step.value;semanticAnalyzer.symbolTableStack.insert(new SymbolInfo(p,ESymbolType.VAR))}}if(semanticAnalyzer.semanticDiagnostics&&(token.type===Keyword.FOR||token.type===Keyword.WHILE)){semanticAnalyzer.pushScope()}nextToken=tokens.next()}else if((actionInfo==null?void 0:actionInfo.action)===EAction.Accept){semanticAnalyzer.acceptRule==null?void 0:semanticAnalyzer.acceptRule.call(semanticAnalyzer,semanticAnalyzer);semanticAnalyzer.finalizeInheritance();var program=semanticAnalyzer.semanticStack.pop();return program}else if((actionInfo==null?void 0:actionInfo.action)===EAction.Reduce){var target=actionInfo.target;var reduceProduction=this.grammar.getProductionByID(target);var translationRule=semanticAnalyzer.getTranslationRule(reduceProduction.id);var values=[];for(var i=reduceProduction.derivation.length-1;i>=0;i--){if(reduceProduction.derivation[i]===ETokenType.EPSILON)continue;traceBackStack.pop();var token1=traceBackStack.pop();if(_instanceof(token1,BaseToken)){values.unshift(token1)}else{var astNode=semanticAnalyzer.semanticStack.pop();values.unshift(astNode)}}translationRule==null?void 0:translationRule.apply(void 0,[].concat([semanticAnalyzer],values));if(semanticAnalyzer.semanticDiagnostics&&!semanticAnalyzer.diagnosticsEnabled&&reduceProduction.goal===NoneTerminal.iteration_statement){semanticAnalyzer.popScope()}var gotoTable=this.stateGotoTable;traceBackStack.push(reduceProduction.goal);var nextState=gotoTable.get(reduceProduction.goal);traceBackStack.push(nextState);continue}else{var _$error=ShaderCompilerUtils.createGSError(\"Unexpected token \"+token.lexeme,GSErrorName.CompilationError,this._source,token.location);this.semanticAnalyzer.errors.push(_$error);this.blockingErrors.push(_$error);return null}}}catch(error){if(!_instanceof(error,GSError)||error.name!==GSErrorName.ScannerError)throw error;this.semanticAnalyzer.errors.push(error);this.blockingErrors.push(error);return null}};ShaderTargetParser.create=function create(branchSemantics,semanticDiagnostics,source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled){if(semanticErrorsBlockCodegen===void 0)semanticErrorsBlockCodegen=false;if(authoringAnalysisEnabled===void 0)authoringAnalysisEnabled=semanticDiagnostics!==undefined;var tables=this._tables;if(!tables){var grammar=createGrammar();var generator=new LALR1(grammar);generator.generate();tables=this._tables={actionTable:generator.actionTable,gotoTable:generator.gotoTable,grammar:grammar}}var parser=new ShaderTargetParser(tables.actionTable,tables.gotoTable,tables.grammar,branchSemantics,semanticDiagnostics,source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled);addTranslationRule(parser.semanticAnalyzer);return parser};_create_class(ShaderTargetParser,[{key:\"curState\",get:function get(){return this._traceBackStack[this._traceBackStack.length-1]}},{key:\"stateActionTable\",get:function get(){return this.actionTable.get(this.curState)}},{key:\"stateGotoTable\",get:function get(){return this.gotoTable.get(this.curState)}},{key:\"errors\",get:function get(){return this.semanticAnalyzer.errors}}]);return ShaderTargetParser}();var parsedShaderPassPayloads=new WeakMap;function createParsedShaderPass(data,vertexEntry,fragmentEntry,coreInfo){var pass=Object.freeze({});parsedShaderPassPayloads.set(pass,Object.freeze({data:data,vertexEntry:vertexEntry,fragmentEntry:fragmentEntry,coreInfo:coreInfo}));return pass}function getParsedShaderPassPayload(pass){var payload=parsedShaderPassPayloads.get(pass);if(!payload)throw new TypeError(\"Invalid parsed shader pass handle.\");return payload}var SHADER_ROOT_URL=\"shaders://root/\";var ABSOLUTE_URL_PATTERN$1=/^[A-Za-z][A-Za-z\\d+.-]*:/;function normalizeShaderSourceFile(sourceFile){if(!sourceFile)return undefined;var normalized=sourceFile.trim().replace(/\\\\/g,\"/\");if(!normalized)return undefined;if(normalized.startsWith(SHADER_ROOT_URL)){return normalized===SHADER_ROOT_URL?undefined:normalizeShaderIncludeKey(normalized)}if(!ABSOLUTE_URL_PATTERN$1.test(normalized)){return normalizeShaderIncludeKey(normalized)}return new URL(normalized).href}function normalizeShaderIncludeMap(includeMap){if(!includeMap)return Object.create(null);var inputKeysByCanonicalKey=Object.create(null);for(var _iterator=_create_for_of_iterator_helper_loose(Object.keys(includeMap)),_step;!(_step=_iterator()).done;){var inputKey=_step.value;var canonicalKey=normalizeShaderIncludeKey(inputKey);if(Object.prototype.hasOwnProperty.call(inputKeysByCanonicalKey,canonicalKey)){throw new Error('Shader include key collision after normalization: \"'+inputKey+'\" resolves to \"'+canonicalKey+'\".')}inputKeysByCanonicalKey[canonicalKey]=inputKey}return new Proxy(Object.create(null),{get:function get(_target,property){if(typeof property!==\"string\")return undefined;var inputKey=inputKeysByCanonicalKey[property];if(inputKey!==undefined){var source=includeMap[inputKey];return typeof source===\"string\"?source:undefined}var source1=includeMap[property];return typeof source1===\"string\"?source1:undefined}})}function shaderSourceBaseURL(sourceFile){if(!sourceFile)return\"\";if(!ABSOLUTE_URL_PATTERN$1.test(sourceFile)){return new URL(sourceFile,SHADER_ROOT_URL).href}return new URL(sourceFile).href}var PreprocessorMacroState=function(){function PreprocessorMacroState(){this._states=Object.create(null);this._versions=Object.create(null);this._frames=[];this._expressionContext={resolveIdentifier:function(){return{}},isDefined:function(){return undefined}};this.reachable=true}var _proto=PreprocessorMacroState.prototype;_proto.processDirective=function processDirective(directive,body){switch(directive){case\"if\":{var condition=this.reachable?this._evaluate(body):{value:undefined};return{keep:this._openConditional(condition),arm:this._arm(condition.value,[],condition),error:condition.error,errorStart:condition.errorStart,errorEnd:condition.errorEnd}}case\"ifdef\":{var condition1=this._definedCondition(body,true);return{keep:this._openConditional(condition1),arm:this._arm(condition1.value,[],condition1),error:condition1.error}}case\"ifndef\":{var condition2=this._definedCondition(body,false);return{keep:this._openConditional(condition2),arm:this._arm(condition2.value,[],condition2),error:condition2.error}}case\"elif\":return this._advanceConditional(body);case\"else\":return this._advanceElse();case\"endif\":return{keep:this._closeConditional()};case\"define\":{var keep=this.reachable;if(keep)this._define(body);return{keep:keep}}case\"undef\":{var keep1=this.reachable;if(keep1)this._undef(body);return{keep:keep1}}default:return{keep:this.reachable}}};_proto.captureSnapshot=function captureSnapshot(){return{states:PreprocessorMacroState._cloneStates(this._states),versions:Object.assign(Object.create(null),this._versions)}};_proto.createCachedState=function createCachedState(before){var names=new Set([].concat(Object.keys(before.states),Object.keys(this._states)));var mutatedNames=[];for(var _iterator=_create_for_of_iterator_helper_loose(names),_step;!(_step=_iterator()).done;){var name=_step.value;var _before_versions_name,_this__versions_name;if(((_before_versions_name=before.versions[name])!=null?_before_versions_name:0)!==((_this__versions_name=this._versions[name])!=null?_this__versions_name:0)){mutatedNames.push(name)}}return{snapshot:this.captureSnapshot(),mutatedNames:mutatedNames}};_proto.applyCachedState=function applyCachedState(cached){for(var _iterator=_create_for_of_iterator_helper_loose(cached.mutatedNames),_step;!(_step=_iterator()).done;){var name=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(this._frames),_step1;!(_step1=_iterator1()).done;){var frame=_step1.value;frame.mutatedNames.add(name)}}this._states=PreprocessorMacroState._cloneStates(cached.snapshot.states);this._versions=Object.assign(Object.create(null),cached.snapshot.versions);this._versionKey=undefined};_proto.cacheKey=function cacheKey(){var names=Object.keys(this._states).sort();var key=\"\";for(var i=0,n=names.length;i<n;i++){var name=names[i];var state=this._states[name];var defined=state.defined===undefined?\"?\":state.defined?\"1\":\"0\";var replacement=state.replacementKey;var _replacement_length;key+=name.length+\":\"+name+defined+(state.functionParams?\"f\":\"v\")+((_replacement_length=replacement==null?void 0:replacement.length)!=null?_replacement_length:\"?\")+\":\"+(replacement!=null?replacement:\"\")}return key+\"\\0\"+this._macroVersionKey()};_proto._openConditional=function _openConditional(condition){var parentReachable=this.reachable;var entryState=PreprocessorMacroState._cloneStates(this._states);var remainderState=PreprocessorMacroState._cloneStates(entryState);if(parentReachable&&condition.value===undefined){this._applyAssumption(this._states,condition.trueAssumption);this._applyAssumption(remainderState,condition.falseAssumption)}this._frames.push({parentReachable:parentReachable,remainderReachable:parentReachable&&condition.value!==true,remainderValue:condition.value===undefined?undefined:!condition.value,remainderConditions:this._appendCondition([],condition,true),hasElse:false,entryState:entryState,remainderState:remainderState,armStates:[],mutatedNames:new Set});this.reachable=parentReachable&&condition.value!==false;return parentReachable};_proto._advanceConditional=function _advanceConditional(body){var frame=this._frames[this._frames.length-1];if(!frame)return{keep:this.reachable};this._finishCurrentArm(frame);this._states=PreprocessorMacroState._cloneStates(frame.remainderState);if(frame.hasElse){this.reachable=false;return{keep:frame.parentReachable}}var keep=frame.remainderReachable;if(!keep){this.reachable=false;return{keep:false}}var condition=this._evaluate(body);var armValue=PreprocessorMacroState._and(frame.remainderValue,condition.value);var arm=this._arm(armValue,frame.remainderConditions,condition);frame.remainderConditions=this._appendCondition(frame.remainderConditions,condition,true);frame.remainderValue=PreprocessorMacroState._and(frame.remainderValue,condition.value===undefined?undefined:!condition.value);frame.remainderState=PreprocessorMacroState._cloneStates(this._states);if(condition.value===undefined){this._applyAssumption(this._states,condition.trueAssumption);this._applyAssumption(frame.remainderState,condition.falseAssumption)}this.reachable=condition.value!==false;if(condition.value===true)frame.remainderReachable=false;return{keep:true,arm:arm,error:condition.error,errorStart:condition.errorStart,errorEnd:condition.errorEnd}};_proto._advanceElse=function _advanceElse(){var frame=this._frames[this._frames.length-1];if(!frame)return{keep:this.reachable};this._finishCurrentArm(frame);this._states=PreprocessorMacroState._cloneStates(frame.remainderState);var keep=!frame.hasElse&&frame.remainderReachable;var armValue=frame.hasElse?false:frame.remainderValue;this.reachable=keep;frame.remainderReachable=false;frame.remainderValue=false;frame.hasElse=true;return{keep:keep,arm:{value:armValue,predicates:frame.remainderConditions}}};_proto._closeConditional=function _closeConditional(){var frame=this._frames.pop();if(!frame)return this.reachable;this._finishCurrentArm(frame);if(!frame.hasElse&&frame.remainderReachable){frame.armStates.push(PreprocessorMacroState._cloneStates(frame.remainderState))}this._states=this._mergeStates(frame);this.reachable=frame.parentReachable;return frame.parentReachable};_proto._finishCurrentArm=function _finishCurrentArm(frame){if(this.reachable)frame.armStates.push(PreprocessorMacroState._cloneStates(this._states))};_proto._mergeStates=function _mergeStates(frame){var _this,_loop=function(){var name=_step.value;var candidates=frame.armStates.map(function(state){return _this1._stateFrom(state,name)});var _candidates_;var first=(_candidates_=candidates[0])!=null?_candidates_:_this._stateFrom(frame.entryState,name);if(candidates.every(function(candidate){return PreprocessorMacroState._sameState(first,candidate)})){merged[name]=first;return\"continue\"}var defined=candidates.every(function(candidate){return candidate.defined===true})?true:candidates.every(function(candidate){return candidate.defined===false})?false:undefined;merged[name]={defined:defined}};var _this1=this;var merged=PreprocessorMacroState._cloneStates(frame.entryState);for(var _iterator=_create_for_of_iterator_helper_loose(frame.mutatedNames),_step;!(_step=_iterator()).done;)_this=this,_loop();return merged};_proto._define=function _define(body){var match=/^[ \\t]*([A-Za-z_]\\w*)([\\s\\S]*)$/.exec(body);if(!match)return;var name=match[1];var suffix=match[2];this._markMutation(name);var replacementKey=suffix.trim();if(suffix[0]===\"(\"){var closeParen=suffix.indexOf(\")\");if(closeParen<0){this._states[name]={defined:true,replacementKey:replacementKey};return}var params=suffix.slice(1,closeParen).split(\",\").map(function(param){return param.trim()}).filter(Boolean);this._states[name]={defined:true,replacementKey:replacementKey,functionParams:params,functionBody:suffix.slice(closeParen+1).trim()};return}this._states[name]={defined:true,replacementKey:replacementKey}};_proto._undef=function _undef(body){var _exec;var name=(_exec=/^[ \\t]*([A-Za-z_]\\w*)/.exec(body))==null?void 0:_exec[1];if(!name)return;this._markMutation(name);this._states[name]={defined:false}};_proto._markMutation=function _markMutation(name){var _this__versions_name;this._versions[name]=((_this__versions_name=this._versions[name])!=null?_this__versions_name:0)+1;this._versionKey=undefined;for(var i=0,n=this._frames.length;i<n;i++)this._frames[i].mutatedNames.add(name)};_proto._evaluate=function _evaluate(expression){var _this=this;var trimmedExpression=expression.trim();var unexpanded=parsePreprocessorExpression(trimmedExpression);var withDefinedValues=resolvePreprocessorDefinedOperators(trimmedExpression,function(name){return _this._state(name).defined});var expansion=expandPreprocessorExpressionMacros(withDefinedValues,function(name){return _this._state(name).defined===false?{body:\"0\"}:_this._macro(name)});if(expansion.error){return{value:undefined,error:expansion.error,errorStart:0,errorEnd:trimmedExpression.length}}var expandedExpression=resolvePreprocessorDefinedOperators(expansion.expression,function(name){return _this._state(name).defined});var parsed=parsePreprocessorExpression(expandedExpression);if(\"error\"in parsed){if(\"error\"in unexpanded&&unexpanded.error.certain){return{value:undefined,error:unexpanded.error.message,errorStart:unexpanded.error.start,errorEnd:unexpanded.error.end}}var error=parsed.error.certain||!parsed.hasExpandableIdentifier?expandedExpression===withDefinedValues?parsed.error.message:\"Invalid preprocessor expression after expanding source macros: \"+parsed.error.message:undefined;return{value:undefined,error:error,errorStart:0,errorEnd:trimmedExpression.length}}var evaluated=parsed.hasExpandableIdentifier?{value:undefined,error:undefined}:evaluatePartiallyKnownPreprocessorConditionResult(parsed.condition,this._expressionContext);var value=evaluated.value!==undefined&&!getPreprocessorConditionRange(parsed.condition)?undefined:evaluated.value;var assumptions=PreprocessorMacroState._conditionAssumptions(parsed.condition);return{value:value===undefined?undefined:value!==0,condition:value!==undefined?undefined:parsed.hasExpandableIdentifier?{kind:\"opaque\",identity:JSON.stringify([expandedExpression,this._macroVersionKey()])}:capturePreprocessorCondition(parsed.condition,this._versions),error:evaluated.error,errorStart:evaluated.error?0:undefined,errorEnd:evaluated.error?trimmedExpression.length:undefined,trueAssumption:assumptions==null?void 0:assumptions.trueAssumption,falseAssumption:assumptions==null?void 0:assumptions.falseAssumption}};_proto._definedCondition=function _definedCondition(body,whenDefined){var _exec;var name=(_exec=/^[ \\t]*([A-Za-z_]\\w*)/.exec(body))==null?void 0:_exec[1];if(!name||!this.reachable)return{value:undefined};var defined=this._state(name).defined;return{value:defined===undefined?undefined:defined===whenDefined,condition:capturePreprocessorCondition({t:whenDefined?\"def\":\"ndef\",m:name},this._versions),trueAssumption:{name:name,defined:whenDefined},falseAssumption:{name:name,defined:!whenDefined}}};_proto._arm=function _arm(value,preceding,condition){return{value:value,predicates:value===true?[]:this._appendCondition(preceding,condition)}};_proto._appendCondition=function _appendCondition(preceding,condition,negate){if(negate===void 0)negate=false;if(!preceding)return;if(condition.value!==undefined)return condition.value!==negate?preceding:undefined;if(!condition.condition)return;return[].concat(preceding,[{condition:condition.condition,negated:negate}])};_proto._macroVersionKey=function _macroVersionKey(){var _this=this;var _this__versionKey;return(_this__versionKey=this._versionKey)!=null?_this__versionKey:this._versionKey=JSON.stringify(Object.keys(this._versions).sort().map(function(name){return[name,_this._versions[name]]}))};_proto._applyAssumption=function _applyAssumption(states,assumption){if(!assumption)return;var current=this._stateFrom(states,assumption.name);states[assumption.name]=assumption.defined?_extends({},current,{defined:true}):{defined:false}};_proto._macro=function _macro(name){var state=this._state(name);if(state.defined!==true||state.replacementKey===undefined)return;var _state_functionBody;return state.functionParams?{body:(_state_functionBody=state.functionBody)!=null?_state_functionBody:\"\",parameters:state.functionParams}:{body:state.replacementKey}};_proto._state=function _state(name){return this._stateFrom(this._states,name)};_proto._stateFrom=function _stateFrom(states,name){var _states_name;return(_states_name=states[name])!=null?_states_name:{defined:undefined}};PreprocessorMacroState._cloneStates=function _cloneStates(states){var clone=Object.create(null);for(var name in states)clone[name]=states[name];return clone};PreprocessorMacroState._sameState=function _sameState(left,right){return left.defined===right.defined&&left.replacementKey===right.replacementKey&&!!left.functionParams===!!right.functionParams};PreprocessorMacroState._and=function _and(left,right){return left===false||right===false?false:left===true&&right===true?true:undefined};PreprocessorMacroState._conditionAssumptions=function _conditionAssumptions(condition){if(condition.t===\"def\"){return{trueAssumption:{name:condition.m,defined:true},falseAssumption:{name:condition.m,defined:false}}}if(condition.t===\"ndef\"){return{trueAssumption:{name:condition.m,defined:false},falseAssumption:{name:condition.m,defined:true}}}if(condition.t!==\"not\")return;var nested=this._conditionAssumptions(condition.c);return nested?{trueAssumption:nested.falseAssumption,falseAssumption:nested.trueAssumption}:undefined};return PreprocessorMacroState}();var SHADER_ROOT_PATH=\"shaders://root/\";var ABSOLUTE_URL_PATTERN=/^[A-Za-z][A-Za-z\\d+.-]*:/;var cachedMacroStates=new WeakMap;var expandedSegmentCounts=new WeakMap;var MAX_INCLUDE_DEPTH=128;var MAX_EXPANDED_SOURCE_LENGTH=8*1024*1024;var MAX_EXPANDED_SOURCE_SEGMENTS=65536;var Preprocessor=function(){function Preprocessor(){}Preprocessor.parse=function parse(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,sourceScopeStarts){var result=this.parseWithErrors(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,true,sourceScopeStarts);for(var _iterator=_create_for_of_iterator_helper_loose(result.errors),_step;!(_step=_iterator()).done;){var error=_step.value;Logger.error(error.toString())}return result.content};Preprocessor.parseWithErrors=function parseWithErrors(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,trackSourceMap,sourceScopeStarts){if(trackSourceMap===void 0)trackSourceMap=true;try{return this._expand(source,basePathForIncludeKey,includeMap,chunkOutputCache,new Set,sourceFile,trackSourceMap,new PreprocessorMacroState,sourceScopeStarts,0)}catch(error){if(!_instanceof(error,GSError)||error.name!==GSErrorName.PreprocessorError)throw error;return{content:\"\",errors:[error],sourceMap:[],sourceScopes:[],conditionalArms:new Map}}};Preprocessor._expand=function _expand(source,basePathForIncludeKey,includeMap,chunkOutputCache,activeIncludePaths,sourceFile,trackSourceMap,macroState,sourceScopeStarts,inheritedSourceScope){var _this=this;var splices=[];var removed=0;var logicalSource=source.replace(/\\\\(?:\\r\\n|\\n|\\r)/g,function(text,offset){splices.push({offset:offset-removed,length:text.length,removed:removed+text.length});removed+=text.length;return\"\"});if(splices.length){var logicalScopeStarts=sourceScopeStarts==null?void 0:sourceScopeStarts.map(function(start){var removedBefore=0;for(var _iterator=_create_for_of_iterator_helper_loose(splices),_step;!(_step=_iterator()).done;){var splice=_step.value;removedBefore+=Math.min(splice.length,Math.max(0,start-splice.offset-removedBefore))}return start-removedBefore});sourceScopeStarts=logicalScopeStarts}var originalSource=source;source=logicalSource;var errors=[];var sourceMap=[];var sourceScopes=[];var conditionalArms=new Map;var parts=[];var sourceOffset=0;var generatedOffset=0;var segmentCount=0;var match;var directiveSource=this._maskDirectiveTrivia(source);var directiveReg=new RegExp(this._directiveReg.source,this._directiveReg.flags);var failExpansion=function(offset,message){throw _this._createPreprocessorError(originalSource,_this._physicalOffset(offset,splices),message,sourceFile)};var reserveExpansion=function(length,segments,offset){if(generatedOffset+length>MAX_EXPANDED_SOURCE_LENGTH){failExpansion(offset,\"Expanded shader source exceeds \"+MAX_EXPANDED_SOURCE_LENGTH+\" characters.\")}if(segmentCount+segments>MAX_EXPANDED_SOURCE_SEGMENTS){failExpansion(offset,\"Shader include expansion exceeds \"+MAX_EXPANDED_SOURCE_SEGMENTS+\" source segments.\")}segmentCount+=segments};reserveExpansion(0,splices.length,0);var currentScope;var appendScope=function(length,sourceScope){if(!(sourceScopeStarts==null?void 0:sourceScopeStarts.length)||!length)return;if((currentScope==null?void 0:currentScope.sourceScope)===sourceScope){currentScope.generatedEnd=generatedOffset+length}else{currentScope={generatedStart:generatedOffset,generatedEnd:generatedOffset+length,sourceScope:sourceScope};sourceScopes.push(currentScope)}};var appendSource=function(start,end,keep){while(start<end){var nextBoundary=_this._nextSourceScopeStart(start,end,sourceScopeStarts);var segmentEnd=nextBoundary!=null?nextBoundary:end;var originalText=source.slice(start,segmentEnd);var text=keep?originalText:_this._maskText(originalText);var sourceScope=_this._sourceScopeAt(start,sourceScopeStarts,inheritedSourceScope);reserveExpansion(text.length,1,start);parts.push(text);appendScope(text.length,sourceScope);if(trackSourceMap){sourceMap.push({generatedStart:generatedOffset,generatedEnd:generatedOffset+text.length,sourceStart:start,source:source,sourceFile:sourceFile,sourceScope:sourceScope})}generatedOffset+=text.length;start=segmentEnd}};while(match=directiveReg.exec(directiveSource)){var _errors;var _this__includePathReg_exec;appendSource(sourceOffset,match.index,macroState.reachable);var directive=match[1];var _match_;var directiveBody=(_match_=match[2])!=null?_match_:\"\";if(directive!==\"include\"){var result=macroState.processDirective(directive,this._stripLineComment(directiveBody));if(result.keep&&result.arm){var hashOffset=directiveSource.indexOf(\"#\",match.index)-match.index;conditionalArms.set(generatedOffset+hashOffset,result.arm)}if(result.error){var leadingWhitespace=directiveBody.length-directiveBody.trimStart().length;var expressionLength=directiveBody.trim().length;var expressionOffset=directiveReg.lastIndex-directiveBody.length+leadingWhitespace;var _result_errorStart;var expressionStart=expressionOffset+Math.min((_result_errorStart=result.errorStart)!=null?_result_errorStart:0,expressionLength);var _result_errorEnd;var expressionEnd=expressionOffset+Math.min((_result_errorEnd=result.errorEnd)!=null?_result_errorEnd:expressionLength,expressionLength);errors.push(this._createPreprocessorError(source,expressionStart,result.error,sourceFile,expressionEnd))}appendSource(match.index,directiveReg.lastIndex,result.keep);sourceOffset=directiveReg.lastIndex;continue}if(!macroState.reachable){appendSource(match.index,directiveReg.lastIndex,false);sourceOffset=directiveReg.lastIndex;continue}var includeName=(_this__includePathReg_exec=this._includePathReg.exec(directiveBody))==null?void 0:_this__includePathReg_exec[1];if(!includeName){errors.push(this._createPreprocessorError(source,match.index,\"Invalid shader include directive.\",sourceFile));sourceOffset=directiveReg.lastIndex;continue}var path=this._resolveIncludePath(includeName,basePathForIncludeKey);if(!path){errors.push(this._createPreprocessorError(source,match.index,'Invalid shader include path \"'+includeName+'\".',sourceFile));sourceOffset=directiveReg.lastIndex;continue}var chunk=includeMap[path];if(chunk===undefined){errors.push(this._createPreprocessorError(source,match.index,'Shader include \"'+path+'\" was not found.',sourceFile));sourceOffset=directiveReg.lastIndex;continue}if(activeIncludePaths.has(path)){errors.push(this._createPreprocessorError(source,match.index,'Shader include cycle detected at \"'+path+'\".',sourceFile));sourceOffset=directiveReg.lastIndex;continue}if(activeIncludePaths.size>=MAX_INCLUDE_DEPTH){failExpansion(match.index,\"Shader include nesting exceeds \"+MAX_INCLUDE_DEPTH+\" levels.\")}var inputMacroState=macroState.captureSnapshot();var includeSourceScope=this._sourceScopeAt(match.index,sourceScopeStarts,inheritedSourceScope);var cacheKey=(trackSourceMap?1:0)+\"\\0\"+path+\"\\0\"+macroState.cacheKey();var expanded=chunkOutputCache.get(cacheKey);var cachedState=expanded&&cachedMacroStates.get(expanded);if(!expanded||!cachedState){activeIncludePaths.add(path);expanded=this._expand(chunk,this._canonicalIncludeURL(path),includeMap,chunkOutputCache,activeIncludePaths,path,trackSourceMap,macroState,undefined,includeSourceScope);activeIncludePaths.delete(path);cachedMacroStates.set(expanded,macroState.createCachedState(inputMacroState));chunkOutputCache.set(cacheKey,expanded)}else{macroState.applyCachedState(cachedState)}var _expandedSegmentCounts_get;reserveExpansion(expanded.content.length,(_expandedSegmentCounts_get=expandedSegmentCounts.get(expanded))!=null?_expandedSegmentCounts_get:1,match.index);for(var _iterator=_create_for_of_iterator_helper_loose(expanded.conditionalArms),_step;!(_step=_iterator()).done;){var _step_value=_step.value,offset=_step_value[0],value=_step_value[1];conditionalArms.set(generatedOffset+offset,value)}parts.push(expanded.content);appendScope(expanded.content.length,includeSourceScope);if(trackSourceMap){for(var _iterator1=_create_for_of_iterator_helper_loose(expanded.sourceMap),_step1;!(_step1=_iterator1()).done;){var segment=_step1.value;sourceMap.push({generatedStart:generatedOffset+segment.generatedStart,generatedEnd:generatedOffset+segment.generatedEnd,sourceStart:segment.sourceStart,source:segment.source,sourceFile:segment.sourceFile,sourceScope:includeSourceScope})}}generatedOffset+=expanded.content.length;(_errors=errors).push.apply(_errors,[].concat(expanded.errors));sourceOffset=directiveReg.lastIndex}appendSource(sourceOffset,source.length,macroState.reachable);var result1={content:parts.join(\"\"),errors:errors,sourceMap:sourceMap,sourceScopes:sourceScopes,conditionalArms:conditionalArms};if(splices.length)this._restoreSplicedSource(result1,source,originalSource,sourceFile,splices);expandedSegmentCounts.set(result1,segmentCount);return result1};Preprocessor._restoreSplicedSource=function _restoreSplicedSource(result,source,originalSource,sourceFile,splices){var _loop=function(){var segment=_step.value;if(segment.source!==source||segment.sourceFile!==sourceFile){mappedSegments.push(segment);return\"continue\"}var start=segment.sourceStart;var end=start+segment.generatedEnd-segment.generatedStart;var append=function(partEnd){if(partEnd<=start)return;mappedSegments.push(_extends({},segment,{generatedStart:segment.generatedStart+start-segment.sourceStart,generatedEnd:segment.generatedStart+partEnd-segment.sourceStart,sourceStart:_this._physicalOffset(start,splices),source:originalSource}));start=partEnd};while(spliceIndex<splices.length&&splices[spliceIndex].offset<=start)spliceIndex++;while(spliceIndex<splices.length&&splices[spliceIndex].offset<end)append(splices[spliceIndex++].offset);append(end)};var _this=this;var mappedSegments=[];var spliceIndex=0;for(var _iterator=_create_for_of_iterator_helper_loose(result.sourceMap),_step;!(_step=_iterator()).done;)_loop();result.sourceMap=mappedSegments;result.errors=result.errors.map(function(error){if(error.source!==source||error.file!==sourceFile)return error;var location=error.location;var start=\"start\"in location?location.start.index:location.index;var end=\"end\"in location?location.end.index:start;return _this._createPreprocessorError(originalSource,_this._physicalOffset(start,splices),error.message,sourceFile,_this._physicalOffset(end,splices,end>start))});return result};Preprocessor._physicalOffset=function _physicalOffset(offset,splices,isEnd){if(isEnd===void 0)isEnd=false;var low=0;var high=splices.length;while(low<high){var middle=low+high>>>1;var seam=splices[middle].offset;if(seam<offset||!isEnd&&seam===offset)low=middle+1;else high=middle}return offset+(low?splices[low-1].removed:0)};Preprocessor._sourceScopeAt=function _sourceScopeAt(offset,scopeStarts,inheritedScope){if(!(scopeStarts==null?void 0:scopeStarts.length))return inheritedScope;var scope=0;for(var index=1;index<scopeStarts.length&&scopeStarts[index]<=offset;index++)scope=index;return scope};Preprocessor._nextSourceScopeStart=function _nextSourceScopeStart(offset,end,scopeStarts){if(!scopeStarts)return;for(var _iterator=_create_for_of_iterator_helper_loose(scopeStarts),_step;!(_step=_iterator()).done;){var start=_step.value;if(start>offset&&start<end)return start}};Preprocessor._maskDirectiveTrivia=function _maskDirectiveTrivia(source){return source.replace(/\\/\\/[^\\r\\n]*|\"[^\"\\r\\n]*\"|\\/\\*[\\s\\S]*?\\*\\//g,function(trivia){return trivia.startsWith(\"/*\")?trivia.replace(/[^\\r\\n]/g,\" \"):trivia})};Preprocessor._stripLineComment=function _stripLineComment(source){return source.replace(/\\/\\/.*$/,\"\")};Preprocessor._maskText=function _maskText(source){return source.replace(/[^\\r\\n]/g,\" \")};Preprocessor._resolveIncludePath=function _resolveIncludePath(includeName,basePathForIncludeKey){var basePath=includeName[0]===\".\"?basePathForIncludeKey||SHADER_ROOT_PATH:SHADER_ROOT_PATH;if(!ABSOLUTE_URL_PATTERN.test(includeName)&&basePath.startsWith(SHADER_ROOT_PATH)){return normalizeShaderIncludeKey(new URL(includeName,basePath).href)}try{var url=new URL(includeName,basePath);return normalizeShaderIncludeKey(url.href)}catch(e){return}};Preprocessor._canonicalIncludeURL=function _canonicalIncludeURL(path){return ABSOLUTE_URL_PATTERN.test(path)?new URL(path).href:new URL(path,SHADER_ROOT_PATH).href};Preprocessor._createPreprocessorError=function _createPreprocessorError(source,offset,message,file,endOffset){if(endOffset===void 0)endOffset=offset;var start=this._positionAt(source,offset);if(endOffset<=offset)return new GSError(GSErrorName.PreprocessorError,message,start,source,file);var range=new ShaderRange;range.set(start,this._positionAt(source,endOffset));return new GSError(GSErrorName.PreprocessorError,message,range,source,file)};Preprocessor._positionAt=function _positionAt(source,offset){var line=0;var lastBreak=-1;for(var i=0;i<offset;i++){var char=source.charCodeAt(i);if(char===10){line++;lastBreak=i}else if(char===13){lastBreak=i}}var position=new ShaderPosition;position.set(offset,line,offset-lastBreak-1);return position};return Preprocessor}();Preprocessor._includePathReg=/^[ \\t]*\"([^\"\\r\\n]+)\"[ \\t]*(?:(?:\\/\\/.*)|(?:\\/\\*.*\\*\\/[ \\t]*))?$/;Preprocessor._directiveReg=/^[ \\t]*#[ \\t]*(include|define|undef|if|ifdef|ifndef|elif|else|endif)\\b([^\\r\\n]*)/gm;var ShaderClueIR=function ShaderClueIR(program,source,sourceMap){if(sourceMap===void 0)sourceMap=[];this.program=program;this.source=source;this.sourceMap=sourceMap;this.shaderData=program.shaderData};function findUnsupportedStructOwnership(ownership,entries,roles,snapshots){var _loop=function(){var _loop=function(){var _loop=function(){var _loop=function(){var member=_step1.value;if(proveInheritanceBranchesCover([],selected.branchSignature.concat(member.branch))===true)return\"continue\";var declarations=member.declarations.filter(function(type){return structs.has(type)});if(!declarations.length)return\"continue\";members.push({declarations:declarations,field:member.field,branch:member.branch});if(targetRole&&declarations.some(function(type){return roles.get(type)===targetRole})&&target.propList.some(function(prop){return prop.ident.lexeme===member.field.lexeme}))referenced=true};var consumer=pending.pop();if(visited.has(consumer)||!consumer.astNode)return\"continue\";visited.add(consumer);var context=selected.branchSignature.concat(consumer.branchSignature);if(proveInheritanceBranchesCover([],context)===true)return\"continue\";var owner=ownership.declarations.get(consumer);var alternatives=owner?families.get(owner.group):[consumer];var replacements=alternatives.filter(function(candidate){return candidate.sourceScope>consumer.sourceScope});if(replacements.length&&proveInheritanceBranchesCover(replacements.map(function(candidate){return candidate.branchSignature}),context)===true)return\"continue\";var facts=references(consumer);for(var _iterator=_create_for_of_iterator_helper_loose(facts.symbols),_step;!(_step=_iterator()).done;){var dependency=_step.value;var _pending;var dependencyOwner=ownership.declarations.get(dependency);(_pending=pending).push.apply(_pending,[].concat(dependencyOwner?families.get(dependencyOwner.group):[dependency]))}if(facts.types.some(function(type){return structs.has(type)&&!roles.has(type)}))referenced=true;for(var _iterator1=_create_for_of_iterator_helper_loose(facts.members),_step1;!(_step1=_iterator1()).done;)_loop()},_loop1=function(){var _step_value=_step1.value,declarations=_step_value.declarations,field=_step_value.field,branch=_step_value.branch;for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var _loop=function(){var prop=_step2.value;var compatible=target.propList.filter(function(candidate){return compatibleProperty(prop,candidate)});if(roles.get(source)!==targetRole||proveInheritanceBranchesCover(compatible.map(function(candidate){return candidate.ident.branch}),selected.branchSignature.concat(branch,prop.ident.branch))!==true)unsupported.add(selected)};var source=_step.value;if(source===target)continue;var sourceProps=source.propList.filter(function(prop){return prop.ident.lexeme===field.lexeme});for(var _iterator1=_create_for_of_iterator_helper_loose(sourceProps),_step2;!(_step2=_iterator1()).done;)_loop()}};var selected=_step.value;var target=selected.astNode;var targetRole=roles.get(target);var visited=new Set;var pending=entries.slice();var members=[];var referenced=false;while(pending.length)_loop();if(!referenced)return\"continue\";for(var _iterator=_create_for_of_iterator_helper_loose(members),_step1;!(_step1=_iterator()).done;)_loop1()};var family=_step2.value;if(!_instanceof(family[0],StructSymbol))return\"continue\";var structs=new Set(family.map(function(symbol){return symbol.astNode}));for(var _iterator=_create_for_of_iterator_helper_loose(family),_step;!(_step=_iterator()).done;)_loop()};var families=new Map;var hasStructFamily=false;ownership.declarations.forEach(function(owner,symbol){if(_instanceof(symbol,StructSymbol))hasStructFamily=true;var _families_get;var family=(_families_get=families.get(owner.group))!=null?_families_get:[];family.push(symbol);families.set(owner.group,family)});if(!hasStructFamily)return[];var projectedMembers=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(snapshots),_step;!(_step=_iterator()).done;){var snapshot=_step.value;var _declarations;var _symbol_dataType;var node=snapshot.replacementMemberOwner;if(!node)continue;while(node&&!(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3))node=node.parent;var field=node==null?void 0:node.children[2];if(!_instanceof(field,BaseToken))continue;var declarations=[];var _symbol_dataType_structDeclarations;for(var _iterator1=_create_for_of_iterator_helper_loose(snapshot.symbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;(_declarations=declarations).push.apply(_declarations,[].concat((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]))}var _projectedMembers_get;var members=(_projectedMembers_get=projectedMembers.get(snapshot.reference))!=null?_projectedMembers_get:[];members.push({declarations:declarations,field:field,branch:snapshot.callSiteBranch});projectedMembers.set(snapshot.reference,members)}var unsupported=new Set;var referenceCache=new Map;var references=function(symbol){var facts=referenceCache.get(symbol);if(!facts){facts=collectReferences(symbol,projectedMembers);referenceCache.set(symbol,facts)}return facts};for(var _iterator2=_create_for_of_iterator_helper_loose(families.values()),_step2;!(_step2=_iterator2()).done;)_loop();return Array.from(unsupported)}function collectReferences(symbol,projectedMembers){var symbols=new Set(_instanceof(symbol,FnSymbol)?symbol.calledFunctions:[]);var types=new Set;var members=[];var pending=[symbol.astNode];var visited=new Set;while(pending.length){var node=pending.pop();if(visited.has(node))continue;visited.add(node);if(_instanceof(node,ASTNode.TypeSpecifier)){for(var _iterator=_create_for_of_iterator_helper_loose(node.structDeclarations),_step;!(_step=_iterator()).done;){var type=_step.value;types.add(type);pending.push(type)}}else if(_instanceof(node,ASTNode.VariableIdentifier)){var _members;var _projectedMembers_get;(_members=members).push.apply(_members,[].concat((_projectedMembers_get=projectedMembers.get(node))!=null?_projectedMembers_get:[]));for(var _iterator1=_create_for_of_iterator_helper_loose(node.resolvedSymbols()),_step1;!(_step1=_iterator1()).done;){var reference=_step1.value;if(_instanceof(reference,FnSymbol)||reference.isGlobalVariable)symbols.add(reference)}}else if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var declarations=expressionStructs(node.children[0]);if(declarations.length)members.push({declarations:declarations,field:node.children[2],branch:node._branch})}for(var _iterator2=_create_for_of_iterator_helper_loose(node.children),_step2;!(_step2=_iterator2()).done;){var child=_step2.value;if(_instanceof(child,TreeNode))pending.push(child)}}return{symbols:Array.from(symbols),types:Array.from(types),members:members}}function expressionStructs(node){if(_instanceof(node,ASTNode.VariableIdentifier)){var _result;var _symbol_dataType;var result=[];var _symbol_dataType_structDeclarations;for(var _iterator=_create_for_of_iterator_helper_loose(node.resolvedValueSymbols()),_step;!(_step=_iterator()).done;){var symbol=_step.value;(_result=result).push.apply(_result,[].concat((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]))}return result}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var result1=[];var _node_fnSymbols;for(var _iterator1=_create_for_of_iterator_helper_loose((_node_fnSymbols=node.fnSymbols)!=null?_node_fnSymbols:node.fnSymbol?[node.fnSymbol]:[]),_step1;!(_step1=_iterator1()).done;){var symbol1=_step1.value;var _result1;var _symbol_dataType1;var _symbol_dataType_structDeclarations1;(_result1=result1).push.apply(_result1,[].concat((_symbol_dataType_structDeclarations1=(_symbol_dataType1=symbol1.dataType)==null?void 0:_symbol_dataType1.structDeclarations)!=null?_symbol_dataType_structDeclarations1:[]))}return result1}if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var result2=[];for(var _iterator2=_create_for_of_iterator_helper_loose(expressionStructs(node.children[0])),_step2;!(_step2=_iterator2()).done;){var type=_step2.value;for(var _iterator3=_create_for_of_iterator_helper_loose(type.propList),_step3;!(_step3=_iterator3()).done;){var prop=_step3.value;var _result2;if(prop.ident.lexeme===node.children[2].lexeme)(_result2=result2).push.apply(_result2,[].concat(prop.typeInfo.structDeclarations))}}return result2}var child=node.children[_instanceof(node.children[0],BaseToken)?1:0];return _instanceof(child,TreeNode)?expressionStructs(child):[]}function compatibleProperty(source,target){if(source.ident.lexeme!==target.ident.lexeme||source.typeInfo.type!==target.typeInfo.type||source.isFlat!==target.isFlat||source.mrtIndex!==target.mrtIndex)return false;var left=source.typeInfo.arraySpecifier;var right=target.typeInfo.arraySpecifier;if(!left||!right)return left===right;return left===right||left.size!==undefined&&left.size===right.size}var ShaderStructRole=function(ShaderStructRole){ShaderStructRole[\"Varying\"]=\"varying\";ShaderStructRole[\"Attribute\"]=\"attribute\";ShaderStructRole[\"Mrt\"]=\"mrt\";return ShaderStructRole}({});var ShaderCoreInfo=function(){function ShaderCoreInfo(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage){this.getDeclarationCoexistence=getDeclarationCoexistence;this.getBranchCoverage=getBranchCoverage;var symbolTable=ir.shaderData.symbolTable;var ownership=ir.shaderData.declarationOwnership;this.deferredDeclarationOwnership=ownership.declarations;var vertexFunctions=findFunctions(symbolTable,vertexEntry);var fragmentFunctions=findFunctions(symbolTable,fragmentEntry);this.vertexEntry=createEntryPointInfo(EShaderStage.VERTEX,vertexEntry,vertexFunctions,getDeclarationCoexistence,ownership);this.fragmentEntry=createEntryPointInfo(EShaderStage.FRAGMENT,fragmentEntry,fragmentFunctions,getDeclarationCoexistence,ownership);var mutableIO=createIOInfo();collectEntryIO(vertexFunctions,fragmentFunctions,mutableIO);this.roleConflicts=removeRoleConflicts(mutableIO);var roles=new Map;registerStructRoles(roles,mutableIO.attributeStructs,\"attribute\");registerStructRoles(roles,mutableIO.varyingStructs,\"varying\");registerStructRoles(roles,mutableIO.mrtStructs,\"mrt\");this.unsupportedDeferredDeclarations=ownership.unsupported.concat(findUnsupportedStructOwnership(ownership,vertexFunctions.concat(fragmentFunctions),roles,ir.shaderData.referenceResolutionSnapshots));deriveStructVariableRoles(symbolTable,vertexFunctions,fragmentFunctions,mutableIO,roles);this.io=mutableIO;this.outerGlobalMacroDeclarations=ir.shaderData.getOuterGlobalMacroDeclarations()}ShaderCoreInfo.create=function create(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage){if(getDeclarationCoexistence===void 0)getDeclarationCoexistence=getLexicalDeclarationCoexistence;if(getBranchCoverage===void 0)getBranchCoverage=getLexicalBranchCoverage;return new ShaderCoreInfo(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage)};return ShaderCoreInfo}();function createIOInfo(){return{attributeStructs:[],attributeList:[],varyingStructs:[],varyingList:[],mrtStructs:[],mrtList:[],structVariableRoles:new Map,vertexStructVariableRoles:new Map,fragmentStructVariableRoles:new Map}}function findFunctions(symbolTable,entry){var lookupSymbol=new SymbolInfo(\"\",null);lookupSymbol.set(entry,ESymbolType.FN);var functions=symbolTable.getSymbols(lookupSymbol,true,[]);functions.sort(function(left,right){return left.astNode.location.start.index-right.astNode.location.start.index});return functions}function createEntryPointInfo(stage,name,functions,getDeclarationCoexistence,ownership){var hasDefiniteAmbiguity=false;for(var i=0,n=functions.length;i<n&&!hasDefiniteAmbiguity;i++){for(var j=i+1;j<n;j++){if(isDeferredDeclarationPair(ownership,functions[i],functions[j]))continue;if(getDeclarationCoexistence(functions[i].branchSignature,functions[j].branchSignature)===\"coexist\"){hasDefiniteAmbiguity=true;break}}}return{stage:stage,name:name,functions:functions,hasDefiniteAmbiguity:hasDefiniteAmbiguity}}function appendStructs(declarations,structs,props,seen){for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var node=_step.value;var _props;if(seen.has(node))continue;seen.add(node);structs.push(node);(_props=props).push.apply(_props,[].concat(node.propList))}}function collectEntryIO(vertexFunctions,fragmentFunctions,io){var attributeStructs=new Set;var varyingStructs=new Set;var mrtStructs=new Set;for(var _iterator=_create_for_of_iterator_helper_loose(vertexFunctions),_step;!(_step=_iterator()).done;){var fn=_step.value;var _proto_parameterList_,_proto_parameterList;var proto=fn.astNode.protoType;if(typeof proto.returnType.type===\"string\"){appendStructs(proto.returnType.typeSpecifier.structDeclarations,io.varyingStructs,io.varyingList,varyingStructs)}var attributeType=(_proto_parameterList=proto.parameterList)==null?void 0:(_proto_parameterList_=_proto_parameterList[0])==null?void 0:_proto_parameterList_.typeInfo.type;if(typeof attributeType===\"string\"){appendStructs(proto.parameterList[0].typeInfo.structDeclarations,io.attributeStructs,io.attributeList,attributeStructs)}}for(var _iterator1=_create_for_of_iterator_helper_loose(fragmentFunctions),_step1;!(_step1=_iterator1()).done;){var fn1=_step1.value;var returnType=fn1.astNode.protoType.returnType.type;if(typeof returnType===\"string\"){appendStructs(fn1.astNode.protoType.returnType.typeSpecifier.structDeclarations,io.mrtStructs,io.mrtList,mrtStructs)}}}function removeRoleConflicts(io){var roles=new Map;var register=function(nodes,role){for(var _iterator=_create_for_of_iterator_helper_loose(nodes),_step;!(_step=_iterator()).done;){var node=_step.value;var _roles_get;var nodeRoles=(_roles_get=roles.get(node))!=null?_roles_get:[];if(nodeRoles.indexOf(role)===-1)nodeRoles.push(role);roles.set(node,nodeRoles)}};register(io.attributeStructs,\"attribute\");register(io.varyingStructs,\"varying\");register(io.mrtStructs,\"mrt\");var conflicts=[];var conflictingStructs=new Set;roles.forEach(function(structRoles,struct){if(structRoles.length>1){conflicts.push({struct:struct,roles:structRoles});conflictingStructs.add(struct)}});if(!conflictingStructs.size)return conflicts;var droppedProps=new Set;var filterStructs=function(structs){for(var index=structs.length-1;index>=0;index--){if(conflictingStructs.has(structs[index])){for(var _iterator=_create_for_of_iterator_helper_loose(structs[index].propList),_step;!(_step=_iterator()).done;){var prop=_step.value;droppedProps.add(prop)}structs.splice(index,1)}}};filterStructs(io.attributeStructs);filterStructs(io.varyingStructs);filterStructs(io.mrtStructs);var filterProps=function(props){for(var index=props.length-1;index>=0;index--){if(droppedProps.has(props[index]))props.splice(index,1)}};filterProps(io.attributeList);filterProps(io.varyingList);filterProps(io.mrtList);return conflicts}function deriveStructVariableRoles(symbolTable,vertexFunctions,fragmentFunctions,io,structRoles){var functionFacts=new Map;symbolTable.forEach(function(symbol){if(_instanceof(symbol,FnSymbol)){functionFacts.set(symbol,collectFunctionRoleFacts(symbol,structRoles,io.structVariableRoles))}else if(_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable){registerVariableRole(io.structVariableRoles,symbol,structRoles);registerVariableRole(io.vertexStructVariableRoles,symbol,structRoles);registerVariableRole(io.fragmentStructVariableRoles,symbol,structRoles)}});populateReachableFunctionVariables(io.vertexStructVariableRoles,vertexFunctions,functionFacts);populateReachableFunctionVariables(io.fragmentStructVariableRoles,fragmentFunctions,functionFacts)}function populateReachableFunctionVariables(target,entries,functionFacts){var visited=new Set;var pending=entries.slice();while(pending.length){var _pending;var fn=pending.pop();if(visited.has(fn))continue;visited.add(fn);var facts=functionFacts.get(fn);if(!facts)continue;for(var _iterator=_create_for_of_iterator_helper_loose(facts.variables),_step;!(_step=_iterator()).done;){var _step_value=_step.value,variable=_step_value.variable,role=_step_value.role;target.set(variable,role)}(_pending=pending).push.apply(_pending,[].concat(facts.callees))}}function collectFunctionRoleFacts(fn,roles,allVariableRoles){var _callees;var variables=[];var callees=[];var register=function(variable){var role=resolveVariableRole(variable,roles);if(!role)return;variables.push({variable:variable,role:role});allVariableRoles.set(variable,role)};var parameters=fn.astNode.protoType.parameterList;if(parameters){for(var _iterator=_create_for_of_iterator_helper_loose(parameters),_step;!(_step=_iterator()).done;){var parameter=_step.value;var parameterNode=parameter.astNode;if(_instanceof(parameterNode,ASTNode.ParameterDeclaration)&¶meterNode.symbol){register(parameterNode.symbol)}}}for(var _iterator1=_create_for_of_iterator_helper_loose(fn.localVariables),_step1;!(_step1=_iterator1()).done;){var variable=_step1.value;register(variable)}(_callees=callees).push.apply(_callees,[].concat(fn.calledFunctions));return{variables:variables,callees:callees}}function registerStructRoles(roles,structs,role){for(var _iterator=_create_for_of_iterator_helper_loose(structs),_step;!(_step=_iterator()).done;){var struct=_step.value;roles.set(struct,role)}}function registerVariableRole(target,variable,roles){var role=resolveVariableRole(variable,roles);if(role)target.set(variable,role)}function resolveVariableRole(variable,roles){var _variable_dataType;var resolvedRole;var _variable_dataType_structDeclarations;for(var _iterator=_create_for_of_iterator_helper_loose((_variable_dataType_structDeclarations=(_variable_dataType=variable.dataType)==null?void 0:_variable_dataType.structDeclarations)!=null?_variable_dataType_structDeclarations:[]),_step;!(_step=_iterator()).done;){var declaration=_step.value;var role=roles.get(declaration);if(!role||resolvedRole&&resolvedRole!==role)return;resolvedRole=role}return resolvedRole}var SIGNED_INT32_MIN=-0x80000000;var SIGNED_INT32_MAX=0x7fffffff;var MAX_BRANCH_PROOF_STATES=256;function areConditionsComplementary(left,right){if(!left||!right)return false;if(left.kind===\"constant\"||right.kind===\"constant\"){return left.kind===\"constant\"&&right.kind===\"constant\"&&left.value!==right.value}if(left.kind===\"expression\"||right.kind===\"expression\"){return left.kind===\"expression\"&&right.kind===\"expression\"&&sameExpression(left,right)&&left.negated!==right.negated}if(left.kind!==right.kind||left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"&&right.kind===\"defined\")return left.defined!==right.defined;if(left.kind!==\"comparison\"||right.kind!==\"comparison\")return false;if(hasExactIntegerValue(left)&&hasExactIntegerValue(right)){return complementaryConditionKey(left)===simpleConditionKey(right)}if(left.value!==right.value)return false;return left.operator===\"==\"&&right.operator===\"!=\"||left.operator===\"!=\"&&right.operator===\"==\"||left.operator===\">\"&&right.operator===\"<=\"||left.operator===\">=\"&&right.operator===\"<\"||left.operator===\"<\"&&right.operator===\">=\"||left.operator===\"<=\"&&right.operator===\">\"}function isConditionalChainExhaustive(constraints){for(var i=0,n=constraints.length;i<n;i++){var condition=constraints[i].condition;if((condition==null?void 0:condition.kind)===\"constant\"&&condition.value)return true;var _constraints_i_precedingConditions;if(condition&&isConditionImplied(condition,(_constraints_i_precedingConditions=constraints[i].precedingConditions)!=null?_constraints_i_precedingConditions:[]))return true;for(var j=0;j<i;j++){if(areConditionsComplementary(constraints[j].condition,condition))return true}}return false}function isBranchVisibleFrom(defBranch,callSiteBranch){var _loop=function(i,n){var constraint=defBranch[i];if(constraint.conditionalGroup!==undefined){var matchingArm=callSiteBranch.find(function(candidate){return candidate.conditionalGroup===constraint.conditionalGroup&&candidate.conditionalArm===constraint.conditionalArm});var otherArm=callSiteBranch.find(function(candidate){return candidate.conditionalGroup===constraint.conditionalGroup&&candidate.conditionalArm!==constraint.conditionalArm});if(otherArm)return{v:false};if(matchingArm)return\"continue\"}var required=getConstraintConditions(constraint);if(!constraint.condition&&required.length===0)return{v:false};for(var j=0,m=required.length;j<m;j++){if(!isConditionImplied(required[j],callConditions))return{v:false}}};if(!isBranchReachable(callSiteBranch)||!canBranchesOverlap(defBranch,callSiteBranch))return false;var callConditions=getConditions(callSiteBranch);for(var i=0,n=defBranch.length;i<n;i++){var _ret=_loop(i);if(_type_of(_ret)===\"object\")return _ret.v}return true}function canDeclarationsCoexist(earlier,later){return getDeclarationCoexistence(earlier,later)!==\"exclusive\"}function getDeclarationCoexistence(earlier,later){if(!canBranchesOverlap(earlier,later))return\"exclusive\";for(var i=0,n=earlier.length;i<n;i++){var left=earlier[i];if(left.defined||!left.selfGuarding)continue;for(var j=0,m=later.length;j<m;j++){var right=later[j];if(!right.defined&&right.name===left.name&&left.conditionalGroup!==undefined&&right.conditionalGroup!==undefined&&right.conditionalGroup>left.conditionalGroup){if(!hasCompatibleGuardUndef(earlier,left,later,right))return\"exclusive\"}}}if(hasUnresolvedCondition(earlier)||hasUnresolvedCondition(later))return\"unknown\";var conditions=getConditions(earlier);appendConditions(later,conditions);var satisfiability=getConditionConjunctionSatisfiability(conditions);return satisfiability===\"satisfiable\"?\"coexist\":satisfiability===\"unsatisfiable\"?\"exclusive\":\"unknown\"}function hasUnresolvedCondition(branch){return branch.some(function(constraint){var _constraint_precedingConditions;var _constraint_precedingConditions_length;return!constraint.condition&&((_constraint_precedingConditions_length=(_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.length)!=null?_constraint_precedingConditions_length:0)===0})}function isBranchReachable(branch){return getBranchReachability(branch)!==\"unreachable\"}function getBranchReachability(branch){for(var i=0,n=branch.length;i<n;i++){var left=branch[i];if(left.conditionalGroup===undefined)continue;for(var j=i+1;j<n;j++){var right=branch[j];if(right.conditionalGroup===left.conditionalGroup&&right.conditionalArm!==left.conditionalArm){return\"unreachable\"}}}if(hasUnresolvedCondition(branch))return\"unknown\";var satisfiability=getConditionConjunctionSatisfiability(getConditions(branch));return satisfiability===\"satisfiable\"?\"reachable\":satisfiability===\"unsatisfiable\"?\"unreachable\":\"unknown\"}function areConditionsReachable(conditions){for(var i=0,n=conditions.length;i<n;i++){var condition=conditions[i];if(condition.kind===\"constant\"&&!condition.value)return false;for(var j=i+1;j<n;j++){if(areConditionsMutuallyExclusive(conditions[i],conditions[j]))return false}}return getConditionConjunctionSatisfiability(conditions)!==\"unsatisfiable\"}function getConditionConjunctionSatisfiability(conditions,budget){if(budget===void 0)budget={remaining:MAX_BRANCH_PROOF_STATES};if(--budget.remaining<0)return\"unknown\";var expressionIndex=conditions.findIndex(function(condition){return condition.kind===\"expression\"});if(expressionIndex<0){return conditions.every(hasExactIntegerValue)?isAtomicConjunctionSatisfiable(conditions)?\"satisfiable\":\"unsatisfiable\":\"unknown\"}var expression=conditions[expressionIndex];if(expression.opaque)return\"unknown\";var remaining=conditions.slice();remaining.splice(expressionIndex,1);var operands=expression.negated?expression.operands.map(negateCondition):expression.operands;var operator=expression.negated?expression.operator===\"&&\"?\"||\":\"&&\":expression.operator;if(operator===\"&&\")return getConditionConjunctionSatisfiability([].concat(remaining,operands),budget);var sawUnknown=false;for(var i=0,n=operands.length;i<n;i++){var result=getConditionConjunctionSatisfiability([].concat(remaining,[operands[i]]),budget);if(result===\"satisfiable\")return result;if(result===\"unknown\")sawUnknown=true}return sawUnknown?\"unknown\":\"unsatisfiable\"}function canBranchesOverlap(left,right){for(var i=0,n=left.length;i<n;i++){var leftConstraint=left[i];for(var j=0,m=right.length;j<m;j++){var rightConstraint=right[j];if(leftConstraint.conditionalGroup!==undefined&&leftConstraint.conditionalGroup===rightConstraint.conditionalGroup&&leftConstraint.conditionalArm!==rightConstraint.conditionalArm){return false}}}var conditions=getConditions(left);appendConditions(right,conditions);return areConditionsReachable(conditions)}function canBranchesCoverCallsite(candidates,callSiteBranch){return getBranchCoverage(candidates,callSiteBranch)===\"covered\"}function getBranchCoverage(candidates,callSiteBranch){var _loop=function(i,n){var candidate=normalizedCandidates[i];if(!uniqueCandidates.some(function(existing){return sameBranch(existing,candidate)}))uniqueCandidates.push(candidate)};var normalizedCandidates=candidates.map(removeSelfGuardingConstraints);var normalizedCallsite=removeSelfGuardingConstraints(callSiteBranch);if(canCandidateSetCoverCallsite(normalizedCandidates,normalizedCallsite))return\"covered\";var uniqueCandidates=[];for(var i=0,n=normalizedCandidates.length;i<n;i++)_loop(i);uniqueCandidates.sort(compareBranchSourceOrder);return hasAtomicCoverageCounterexample(uniqueCandidates,normalizedCallsite)?\"uncovered\":\"unknown\"}function compareBranchSourceOrder(left,right){var length=Math.min(left.length,right.length);for(var i=0;i<length;i++){var _left_i_conditionalGroup;var leftGroup=(_left_i_conditionalGroup=left[i].conditionalGroup)!=null?_left_i_conditionalGroup:Number.MAX_SAFE_INTEGER;var _right_i_conditionalGroup;var rightGroup=(_right_i_conditionalGroup=right[i].conditionalGroup)!=null?_right_i_conditionalGroup:Number.MAX_SAFE_INTEGER;if(leftGroup!==rightGroup)return leftGroup-rightGroup;var _left_i_conditionalArm;var leftArm=(_left_i_conditionalArm=left[i].conditionalArm)!=null?_left_i_conditionalArm:Number.MAX_SAFE_INTEGER;var _right_i_conditionalArm;var rightArm=(_right_i_conditionalArm=right[i].conditionalArm)!=null?_right_i_conditionalArm:Number.MAX_SAFE_INTEGER;if(leftArm!==rightArm)return leftArm-rightArm}return left.length-right.length}function hasAtomicCoverageCounterexample(candidates,callSiteBranch){if(candidates.length===0)return false;if(candidates.every(function(candidate){return!canBranchesOverlap(candidate,callSiteBranch)}))return true;if(!hasOnlyAtomicConditions(callSiteBranch)||candidates.some(function(candidate){return!hasOnlyAtomicConditions(candidate)})){return false}var counterexampleFacts=getConditions(callSiteBranch);if(!isAtomicConjunctionSatisfiable(counterexampleFacts))return false;for(var i=0,n=candidates.length;i<n;i++){var candidateConditions=getConditions(candidates[i]);if(!isAtomicConjunctionSatisfiable([].concat(counterexampleFacts,candidateConditions)))continue;var excluded=false;for(var j=0,m=candidateConditions.length;j<m;j++){var negated=negateCondition(candidateConditions[j]);if(isAtomicConjunctionSatisfiable([].concat(counterexampleFacts,[negated]))){counterexampleFacts.push(negated);excluded=true;break}}if(!excluded)return false}return true}function hasOnlyAtomicConditions(branch){for(var i=0,n=branch.length;i<n;i++){var _constraint_condition;var constraint=branch[i];var preceding=constraint.precedingConditions;if(!constraint.condition&&!(preceding==null?void 0:preceding.length))return false;if(((_constraint_condition=constraint.condition)==null?void 0:_constraint_condition.kind)===\"expression\")return false;if(constraint.condition&&!hasExactIntegerValue(constraint.condition))return false;if(preceding==null?void 0:preceding.some(function(condition){return condition.kind===\"expression\"}))return false;if(preceding==null?void 0:preceding.some(function(condition){return!hasExactIntegerValue(condition)}))return false}return true}function hasExactIntegerValue(condition){return condition.kind!==\"comparison\"||Number.isInteger(condition.value)&&condition.value>=SIGNED_INT32_MIN&&condition.value<=SIGNED_INT32_MAX}function isAtomicConjunctionSatisfiable(conditions){var _loop=function(){var state=_step.value;if(state.defined===false){if(state.comparisons.some(function(comparison){return!matchesComparison(0,comparison)}))return{v:false};return\"continue\"}var exact=void 0;var minimum=SIGNED_INT32_MIN;var maximum=SIGNED_INT32_MAX;var excluded=new Set;for(var i=0,n=state.comparisons.length;i<n;i++){var comparison=state.comparisons[i];if(comparison.operator===\"==\"){if(exact!==undefined&&exact!==comparison.value)return{v:false};exact=comparison.value}else if(comparison.operator===\"!=\"){excluded.add(comparison.value)}else{var candidateLower=lowerBound(comparison);if(candidateLower){minimum=Math.max(minimum,candidateLower.value+(candidateLower.inclusive?0:1))}var candidateUpper=upperBound(comparison);if(candidateUpper){maximum=Math.min(maximum,candidateUpper.value-(candidateUpper.inclusive?0:1))}}}if(exact!==undefined){if(excluded.has(exact))return{v:false};if(state.comparisons.some(function(comparison){return!matchesComparison(exact,comparison)}))return{v:false};return\"continue\"}if(minimum>maximum)return{v:false};if(Number.isFinite(minimum)&&Number.isFinite(maximum)){var excludedInRange=0;for(var _iterator=_create_for_of_iterator_helper_loose(excluded),_step1;!(_step1=_iterator()).done;){var value=_step1.value;if(value>=minimum&&value<=maximum)excludedInRange++}if(maximum-minimum+1<=excludedInRange)return{v:false}}};var states=new Map;for(var i=0,n=conditions.length;i<n;i++){var condition=conditions[i];if(condition.kind===\"constant\"){if(!condition.value)return false;continue}if(condition.kind===\"expression\")return false;var key=condition.name+\":\"+condition.version;var _states_get;var state=(_states_get=states.get(key))!=null?_states_get:{comparisons:[]};states.set(key,state);if(condition.kind===\"defined\"){if(state.defined!==undefined&&state.defined!==condition.defined)return false;state.defined=condition.defined}else{state.comparisons.push(condition)}}for(var _iterator=_create_for_of_iterator_helper_loose(states.values()),_step;!(_step=_iterator()).done;){var _ret=_loop();if(_type_of(_ret)===\"object\")return _ret.v}return true}function removeSelfGuardingConstraints(branch){return branch.some(function(constraint){return constraint.selfGuarding})?branch.filter(function(constraint){return!constraint.selfGuarding}):branch}function canCandidateSetCoverCallsite(candidates,callSiteBranch,memo){var _loop=function(){var _loop=function(arm){var _representative_conditionalReachableArms;var _representative_conditionalReachableArms_arm;var armReachable=(_representative_conditionalReachableArms_arm=representative==null?void 0:(_representative_conditionalReachableArms=representative.conditionalReachableArms)==null?void 0:_representative_conditionalReachableArms[arm])!=null?_representative_conditionalReachableArms_arm:true;if(!armReachable)return\"continue\";var armCandidates=compatible.filter(function(candidate){var _candidate_find;return((_candidate_find=candidate.find(function(constraint){return constraint.conditionalGroup===group}))==null?void 0:_candidate_find.conditionalArm)===arm}).map(function(candidate){return removeConditionalGroup(candidate,group)});if(!armCandidates.length){everyArmHasCandidates=false;return\"break\"}candidatesByArm.push(armCandidates)};var group=_step.value;var callSiteConstraint=callSiteBranch.find(function(constraint){return constraint.conditionalGroup===group});if((callSiteConstraint==null?void 0:callSiteConstraint.conditionalArm)!==undefined){var inCurrentArm=compatible.filter(function(candidate){var _candidate_find;return((_candidate_find=candidate.find(function(constraint){return constraint.conditionalGroup===group}))==null?void 0:_candidate_find.conditionalArm)===callSiteConstraint.conditionalArm}).map(function(candidate){return removeConditionalGroup(candidate,group)});if(inCurrentArm.length&&canCandidateSetCoverCallsite(inCurrentArm,removeConditionalGroup(callSiteBranch,group),memo)){memo.results.set(key,true);return{v:true}}return\"continue\"}var representative=compatible.map(function(candidate){return candidate.find(function(constraint){return constraint.conditionalGroup===group})}).find(function(constraint){return(constraint==null?void 0:constraint.conditionalArmCount)!==undefined});var armCount=representative==null?void 0:representative.conditionalArmCount;if(armCount===undefined)return\"continue\";var candidatesByArm=[];var everyArmHasCandidates=true;for(var arm=0;arm<armCount;arm++){var _ret=_loop(arm);if(_ret===\"break\")break}if(everyArmHasCandidates&&candidatesByArm.every(function(armCandidates){return canCandidateSetCoverCallsite(armCandidates,callSiteBranch,memo)})){memo.results.set(key,true);return{v:true}}};if(!isBranchReachable(callSiteBranch))return true;var compatible=candidates.filter(function(candidate){return canBranchesOverlap(candidate,callSiteBranch)});for(var i=0,n=compatible.length;i<n;i++){if(isBranchVisibleFrom(compatible[i],callSiteBranch))return true}var groups=new Set;for(var i1=0,n1=compatible.length;i1<n1;i1++){var candidate=compatible[i1];for(var j=0,m=candidate.length;j<m;j++){var constraint=candidate[j];if(constraint.conditionalComplete&&constraint.conditionalGroup!==undefined&&constraint.conditionalArmCount!==undefined){groups.add(constraint.conditionalGroup)}}}if(!groups.size)return canComplementarySimpleCandidatesCoverCallsite(compatible,callSiteBranch);memo!=null?memo:memo={constraints:new Map,results:new Map};var key=coverageStateKey(compatible,callSiteBranch,memo.constraints);var cached=memo.results.get(key);if(cached!==undefined)return cached;var commonGroup=findIndependentCommonGroup(compatible,callSiteBranch);for(var _iterator=_create_for_of_iterator_helper_loose(commonGroup===undefined?groups:[commonGroup]),_step;!(_step=_iterator()).done;){var _ret=_loop();if(_type_of(_ret)===\"object\")return _ret.v}var covered=canComplementarySimpleCandidatesCoverCallsite(compatible,callSiteBranch);memo.results.set(key,covered);return covered}function coverageStateKey(candidates,callSiteBranch,constraints){return[].concat([callSiteBranch],candidates).map(function(branch){return branch.map(function(constraint){var id=constraints.get(constraint);if(id===undefined)constraints.set(constraint,id=constraints.size);return id}).join(\",\")}).join(\";\")}function findIndependentCommonGroup(candidates,callSiteBranch){var _candidates__find,_candidates_;if(callSiteBranch.length)return;var groups=new Map;var macros=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(candidates),_step;!(_step=_iterator()).done;){var candidate=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(candidate),_step1;!(_step1=_iterator1()).done;){var constraint=_step1.value;var _constraint_conditionalReachableArms;var group=constraint.conditionalGroup;var conditions=getConstraintConditions(constraint);var condition=conditions[0];if(group===undefined||!constraint.conditionalComplete||constraint.conditionalArmCount!==2||constraint.conditionalArm!==0&&constraint.conditionalArm!==1||((_constraint_conditionalReachableArms=constraint.conditionalReachableArms)==null?void 0:_constraint_conditionalReachableArms.some(function(reachable){return!reachable}))||conditions.length!==1||condition.kind!==\"defined\"&&condition.kind!==\"comparison\"||!hasExactIntegerValue(condition)){return}var macro=condition.name+\":\"+condition.version;var arm0Condition=constraint.conditionalArm===0?condition:negateCondition(condition);var existing=groups.get(group);if(existing&&(existing.macro!==macro||!sameCondition(existing.condition,arm0Condition))||macros.has(macro)&¯os.get(macro)!==group){return}groups.set(group,{macro:macro,condition:arm0Condition});macros.set(macro,group)}}return(_candidates_=candidates[0])==null?void 0:(_candidates__find=_candidates_.find(function(constraint){return candidates.every(function(candidate){return candidate.some(function(arm){return arm.conditionalGroup===constraint.conditionalGroup})})}))==null?void 0:_candidates__find.conditionalGroup}function canComplementarySimpleCandidatesCoverCallsite(candidates,callSiteBranch){var seen=new Set;for(var i=0,n=candidates.length;i<n;i++){var candidate=candidates[i];for(var j=0,m=candidate.length;j<m;j++){var _constraint_precedingConditions;var constraint=candidate[j];var condition=constraint.condition;if(!condition||((_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.length))continue;var remaining=[].concat(candidate.slice(0,j),candidate.slice(j+1));if(!isBranchVisibleFrom(remaining,callSiteBranch))continue;var remainderKey=branchKey(remaining);var conditionKey=simpleConditionKey(condition);var complementKey=complementaryConditionKey(condition);if(complementKey&&seen.has(remainderKey+\"|\"+complementKey))return true;seen.add(remainderKey+\"|\"+conditionKey)}}return false}function removeConditionalGroup(branch,group){return branch.filter(function(constraint){return constraint.conditionalGroup!==group})}function branchKey(branch){return branch.map(function(constraint){var _constraint_precedingConditions;return[constraint.name,constraint.defined,simpleConditionKey(constraint.condition),(_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.map(simpleConditionKey).join(\",\")]}).join(\"|\")}function simpleConditionKey(condition){if(!condition)return\"\";if(condition.kind===\"constant\")return\"constant:\"+condition.value;if(condition.kind===\"defined\")return\"defined:\"+condition.name+\":\"+condition.version+\":\"+condition.defined;if(condition.kind===\"expression\"){return\"expression:\"+condition.expression+\":\"+condition.names.map(function(name,i){return name+\":\"+condition.versions[i]}).join(\",\")+\":\"+condition.negated}var normalized=normalizeIntegerComparison(condition);return\"comparison:\"+normalized.name+\":\"+normalized.version+\":\"+normalized.operator+\":\"+normalized.value}function complementaryConditionKey(condition){if(condition.kind===\"constant\")return\"constant:\"+!condition.value;if(condition.kind===\"defined\")return\"defined:\"+condition.name+\":\"+condition.version+\":\"+!condition.defined;if(condition.kind===\"expression\"){return\"expression:\"+condition.expression+\":\"+condition.names.map(function(name,i){return name+\":\"+condition.versions[i]}).join(\",\")+\":\"+!condition.negated}if(!hasExactIntegerValue(condition)){var operator=condition.operator===\"==\"?\"!=\":condition.operator===\"!=\"?\"==\":condition.operator===\">\"?\"<=\":condition.operator===\">=\"?\"<\":condition.operator===\"<\"?\">=\":\">\";return\"comparison:\"+condition.name+\":\"+condition.version+\":\"+operator+\":\"+condition.value}var normalized=normalizeIntegerComparison(condition);var operator1=normalized.operator===\"==\"?\"!=\":normalized.operator===\"!=\"?\"==\":normalized.operator===\">=\"?\"<=\":\">=\";var value=normalized.operator===\">=\"?normalized.value-1:normalized.operator===\"<=\"?normalized.value+1:normalized.value;return\"comparison:\"+normalized.name+\":\"+normalized.version+\":\"+operator1+\":\"+value}function normalizeIntegerComparison(condition){if(!hasExactIntegerValue(condition))return condition;if(condition.operator===\">\")return _extends({},condition,{operator:\">=\",value:condition.value+1});if(condition.operator===\"<\")return _extends({},condition,{operator:\"<=\",value:condition.value-1});return condition}function hasCompatibleGuardUndef(earlier,earlierGuard,later,laterGuard){var events=laterGuard.guardUndefBranches;if(!events)return false;var _earlierGuard_guardUndefStart;var start=(_earlierGuard_guardUndefStart=earlierGuard.guardUndefStart)!=null?_earlierGuard_guardUndefStart:0;var _laterGuard_guardUndefStart;var end=(_laterGuard_guardUndefStart=laterGuard.guardUndefStart)!=null?_laterGuard_guardUndefStart:0;for(var i=start;i<end;i++){var event=events[i];if(canBranchesOverlap(earlier,event)&&canBranchesOverlap(event,later))return true}return false}function getConditions(branch){var conditions=[];appendConditions(branch,conditions);return conditions}function appendConditions(branch,conditions){for(var i=0,n=branch.length;i<n;i++){var constraint=branch[i];var preceding=constraint.precedingConditions;if(preceding){for(var j=0,m=preceding.length;j<m;j++)conditions.push(preceding[j])}if(constraint.condition)conditions.push(constraint.condition)}}function getConstraintConditions(constraint){var conditions=constraint.precedingConditions?[].concat(constraint.precedingConditions):[];if(constraint.condition)conditions.push(constraint.condition);return conditions}function isConditionImplied(required,facts){if(required.kind===\"constant\")return required.value;if(facts.some(function(fact){return sameCondition(fact,required)}))return true;if(required.kind===\"expression\"){if(required.opaque)return false;if(!required.negated&&required.operator===\"&&\"){if(required.operands.every(function(operand){return isConditionImplied(operand,facts)}))return true}if(!required.negated&&required.operator===\"||\"){if(required.operands.some(function(operand){return isConditionImplied(operand,facts)}))return true}if(required.negated&&required.operator===\"||\"){if(required.operands.every(function(operand){return isConditionImplied(negateCondition(operand),facts)}))return true}if(required.negated&&required.operator===\"&&\"){if(required.operands.some(function(operand){return isConditionImplied(negateCondition(operand),facts)}))return true}return facts.length>1&&doDefinedBooleanFactsImply(required,facts)}for(var i=0,n=facts.length;i<n;i++){var fact=facts[i];if(fact.kind===\"constant\")continue;if(fact.kind===\"expression\"){if(expressionImpliesCondition(fact,required))return true;continue}if(fact.name!==required.name||fact.version!==required.version)continue;if(conditionImplies(fact,required))return true}return facts.length>1&&doDefinedBooleanFactsImply(required,facts)}function doDefinedBooleanFactsImply(required,facts){var known=[];var changed=true;while(changed){changed=false;for(var i=0,n=facts.length;i<n;i++){var simplified=simplifyDefinedBooleanCondition(facts[i],known);if(simplified.kind===\"constant\"&&!simplified.value)return true;changed=collectGuaranteedDefinedFacts(simplified,known)||changed}}var simplifiedRequired=simplifyDefinedBooleanCondition(required,known);return simplifiedRequired.kind===\"constant\"&&simplifiedRequired.value}function collectGuaranteedDefinedFacts(condition,known){if(condition.kind===\"constant\"||condition.kind===\"comparison\")return false;if(condition.kind===\"defined\"){if(known.some(function(candidate){return sameCondition(candidate,condition)}))return false;known.push(condition);return true}if(condition.opaque)return false;if(!condition.negated&&condition.operator===\"&&\"){return condition.operands.reduce(function(changed,operand){return collectGuaranteedDefinedFacts(operand,known)||changed},false)}if(condition.negated&&condition.operator===\"||\"){return condition.operands.reduce(function(changed,operand){return collectGuaranteedDefinedFacts(negateCondition(operand),known)||changed},false)}return false}function simplifyDefinedBooleanCondition(condition,known){if(condition.kind===\"constant\"||condition.kind===\"comparison\")return condition;if(condition.kind===\"defined\"){if(known.some(function(candidate){return sameCondition(candidate,condition)}))return{kind:\"constant\",value:true};if(known.some(function(candidate){return areConditionsComplementary(candidate,condition)})){return{kind:\"constant\",value:false}}return condition}if(condition.opaque)return condition;var operands=condition.operands.map(function(operand){return simplifyDefinedBooleanCondition(operand,known)});var hasTrue=operands.some(function(operand){return operand.kind===\"constant\"&&operand.value});var hasFalse=operands.some(function(operand){return operand.kind===\"constant\"&&!operand.value});var remaining=operands.filter(function(operand){return operand.kind!==\"constant\"});var innerValue=condition.operator===\"&&\"?hasFalse?false:remaining.length===0?true:undefined:hasTrue?true:remaining.length===0?false:undefined;if(innerValue!==undefined)return{kind:\"constant\",value:condition.negated?!innerValue:innerValue};if(!condition.negated&&remaining.length===1)return remaining[0];return _extends({},condition,{operands:remaining})}function expressionImpliesCondition(fact,required){if(fact.opaque)return false;if(!fact.negated&&fact.operator===\"&&\"){return fact.operands.some(function(operand){return isConditionImplied(required,[operand])})}if(!fact.negated&&fact.operator===\"||\"){return fact.operands.every(function(operand){return isConditionImplied(required,[operand])})}if(fact.negated&&fact.operator===\"||\"){return fact.operands.some(function(operand){return isConditionImplied(required,[negateCondition(operand)])})}if(fact.negated&&fact.operator===\"&&\"){return fact.operands.every(function(operand){return isConditionImplied(required,[negateCondition(operand)])})}return false}function negateCondition(condition){if(condition.kind===\"constant\")return{kind:\"constant\",value:!condition.value};if(condition.kind===\"defined\")return _extends({},condition,{defined:!condition.defined});if(condition.kind===\"expression\")return _extends({},condition,{negated:!condition.negated});switch(condition.operator){case\"==\":return _extends({},condition,{operator:\"!=\"});case\"!=\":return _extends({},condition,{operator:\"==\"});case\">\":return _extends({},condition,{operator:\"<=\"});case\">=\":return _extends({},condition,{operator:\"<\"});case\"<\":return _extends({},condition,{operator:\">=\"});case\"<=\":return _extends({},condition,{operator:\">\"})}}function conditionImplies(fact,required){if(fact.kind===\"expression\"||required.kind===\"expression\")return sameCondition(fact,required);if(fact.kind===\"defined\"){if(required.kind===\"defined\")return fact.defined===required.defined;return!fact.defined&&matchesComparison(0,required)}if(required.kind===\"defined\"){return required.defined&&!matchesComparison(0,fact)}if(fact.operator===\"==\")return matchesComparison(fact.value,required);if(required.operator===\"!=\")return!matchesComparison(required.value,fact);var factLower=lowerBound(fact);var factUpper=upperBound(fact);var requiredLower=lowerBound(required);var requiredUpper=upperBound(required);if(requiredLower&&(!factLower||!isLowerBoundAtLeast(factLower,requiredLower)))return false;if(requiredUpper&&(!factUpper||!isUpperBoundAtMost(factUpper,requiredUpper)))return false;return!!(requiredLower||requiredUpper)}function areConditionsMutuallyExclusive(left,right){if(!left||!right)return false;if(left.kind===\"constant\"||right.kind===\"constant\"){return left.kind===\"constant\"&&!left.value||right.kind===\"constant\"&&!right.value}if(left.kind===\"expression\"||right.kind===\"expression\"){return left.kind===\"expression\"&&right.kind===\"expression\"&&sameExpression(left,right)&&left.negated!==right.negated}if(left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"){if(right.kind===\"defined\")return left.defined!==right.defined;return!left.defined&&!matchesComparison(0,right)}if(right.kind===\"defined\")return!right.defined&&!matchesComparison(0,left);if(left.operator===\"==\")return!matchesComparison(left.value,right);if(right.operator===\"==\")return!matchesComparison(right.value,left);var leftLower=lowerBound(left);var rightLower=lowerBound(right);var leftUpper=upperBound(left);var rightUpper=upperBound(right);return leftLower!==undefined&&rightUpper!==undefined&&isEmptyInterval(leftLower,rightUpper)||rightLower!==undefined&&leftUpper!==undefined&&isEmptyInterval(rightLower,leftUpper)}function isLowerBoundAtLeast(actual,required){return actual.value>required.value||actual.value===required.value&&(required.inclusive||!actual.inclusive)}function isUpperBoundAtMost(actual,required){return actual.value<required.value||actual.value===required.value&&(required.inclusive||!actual.inclusive)}function matchesComparison(value,comparison){switch(comparison.operator){case\"==\":return value===comparison.value;case\"!=\":return value!==comparison.value;case\">\":return value>comparison.value;case\">=\":return value>=comparison.value;case\"<\":return value<comparison.value;case\"<=\":return value<=comparison.value}}function lowerBound(comparison){switch(comparison.operator){case\">\":return{value:comparison.value,inclusive:false};case\">=\":return{value:comparison.value,inclusive:true};default:return undefined}}function upperBound(comparison){switch(comparison.operator){case\"<\":return{value:comparison.value,inclusive:false};case\"<=\":return{value:comparison.value,inclusive:true};default:return undefined}}function isEmptyInterval(lower,upper){return lower.value>upper.value||lower.value===upper.value&&(!lower.inclusive||!upper.inclusive)}var branchAnalysis={canBranchesOverlap:canBranchesOverlap,canDeclarationsCoexist:canDeclarationsCoexist,getBranchCoverage:getBranchCoverage,getDeclarationCoexistence:getDeclarationCoexistence,isBranchReachable:isBranchReachable,isBranchVisibleFrom:isBranchVisibleFrom};var ParserSemanticValidation=function(){function ParserSemanticValidation(){}ParserSemanticValidation.collect=function collect(root){var issues=[];var pending=[root];while(pending.length){var node=pending.pop();if(!isBranchReachable(node._branch)||_instanceof(node,ASTNode.MacroDefine))continue;if(_instanceof(node,ASTNode.AssignmentExpression)){var targetIssue=this.assignmentTargetIssue(node);var typeIssue=this.assignmentTypeIssue(node);if(targetIssue)issues.push(targetIssue);if(typeIssue)issues.push(typeIssue)}else if(_instanceof(node,ASTNode.UnaryExpression)||_instanceof(node,ASTNode.PostfixExpression)){var issue=this.incrementTargetIssue(node);if(issue)issues.push(issue)}else if(_instanceof(node,ASTNode.SelectionStatement)){var issue1=this.selectionConditionIssue(node);if(issue1)issues.push(issue1)}else if(_instanceof(node,ASTNode.IterationStatement)){var issue2=this.iterationConditionIssue(node);if(issue2)issues.push(issue2)}else if(_instanceof(node,ASTNode.ConditionalExpression)){var issue3=this.ternaryConditionIssue(node);if(issue3)issues.push(issue3)}else if(_instanceof(node,ASTNode.FunctionCallGeneric)){var _issues;var issue4=this.constructorIssue(node);if(issue4)issues.push(issue4);(_issues=issues).push.apply(_issues,[].concat(this.outputArgumentIssues(node)))}else if(_instanceof(node,ASTNode.FunctionDeclarator)){var issue5=this.functionReturnTypeIssue(node);if(issue5)issues.push(issue5)}for(var index=node.children.length-1;index>=0;index--){var child=node.children[index];if(_instanceof(child,TreeNode))pending.push(child)}}return issues};ParserSemanticValidation.nonAssignableReason=function nonAssignableReason(node){if(_instanceof(node,ASTNode.ConditionalExpression)&&node.children.length>1){return\"a ternary expression result\"}if((_instanceof(node,ASTNode.LogicalOrExpression)||_instanceof(node,ASTNode.LogicalXorExpression)||_instanceof(node,ASTNode.LogicalAndExpression)||_instanceof(node,ASTNode.InclusiveOrExpression)||_instanceof(node,ASTNode.ExclusiveOrExpression)||_instanceof(node,ASTNode.AndExpression)||_instanceof(node,ASTNode.EqualityExpression)||_instanceof(node,ASTNode.RelationalExpression)||_instanceof(node,ASTNode.ShiftExpression)||_instanceof(node,ASTNode.AdditiveExpression)||_instanceof(node,ASTNode.MultiplicativeExpression))&&node.children.length>1){return\"a compound expression\"}if(_instanceof(node,ASTNode.UnaryExpression)&&node.children.length>1){return\"a unary-operator result\"}if(_instanceof(node,ASTNode.FunctionCallGeneric)){return\"a function call result\"}if(_instanceof(node,ASTNode.PostfixExpression)){var base=node.children[0];var field=node.children[2];if(node.children.length===3&&_instanceof(base,ASTNode.ExpressionAstNode)&&_instanceof(field,BaseToken)){var size=this._vectorComponentCount(base);if(size){if(ParserUtils.swizzleError(base.type,field.lexeme,size))return\"an invalid swizzle '.\"+field.lexeme+\"'\";if(new Set(field.lexeme).size!==field.lexeme.length){return\"a swizzle with repeated components '.\"+field.lexeme+\"'\"}}}return _instanceof(base,TreeNode)?ParserSemanticValidation.nonAssignableReason(base):\"an unassignable postfix expression\"}if(_instanceof(node,ASTNode.PrimaryExpression)){if(node.children.length===1){var child=node.children[0];if(_instanceof(child,ASTNode.VariableIdentifier))return ParserSemanticValidation.nonAssignableReason(child);if(_instanceof(child,BaseToken)){if(child.type===ETokenType.INT_CONSTANT||child.type===ETokenType.FLOAT_CONSTANT){return\"a numeric literal\"}if(child.type===Keyword.True||child.type===Keyword.False)return\"a boolean literal\"}return}var inner=node.children[1];return _instanceof(inner,TreeNode)?ParserSemanticValidation.nonAssignableReason(inner):undefined}if(_instanceof(node,ASTNode.VariableIdentifier)){var child1=node.children[0];if(_instanceof(child1,ASTNode.MacroCallSymbol)||_instanceof(child1,ASTNode.MacroCallFunction))return;var symbols=node.resolvedValueSymbols();if(!symbols.length)return;var sharedReason;for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;var _symbol_dataType;if(!_instanceof(symbol,VarSymbol))return;var reason=symbol.isConst?\"a const-qualified variable\":TypeSystem.isSamplerType((_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.type)?\"a sampler\":symbol.isUniform?\"a uniform variable\":undefined;if(!reason)return;if(sharedReason&&sharedReason!==reason)return\"a non-modifiable variable\";sharedReason=reason}return sharedReason}if(node.children.length===1){var child2=node.children[0];if(_instanceof(child2,TreeNode))return ParserSemanticValidation.nonAssignableReason(child2)}return};ParserSemanticValidation._vectorComponentCount=function _vectorComponentCount(node){var size=TypeSystem.vectorComponentCount(node.type);if(size)return size;if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3){var base=node.children[0];var field=node.children[2];if(_instanceof(base,ASTNode.ExpressionAstNode)&&_instanceof(field,BaseToken)){var baseSize=this._vectorComponentCount(base);if(baseSize&&!ParserUtils.swizzleError(base.type,field.lexeme,baseSize)){return field.lexeme.length>1?field.lexeme.length:0}}}var child=node.children[_instanceof(node,ASTNode.PrimaryExpression)&&node.children.length===3?1:0];if((node.children.length===1||_instanceof(node,ASTNode.PrimaryExpression))&&_instanceof(child,ASTNode.ExpressionAstNode)){return this._vectorComponentCount(child)}return 0};ParserSemanticValidation.outputArgumentIssues=function outputArgumentIssues(node){var argumentsNode=node.children[2];if(!_instanceof(argumentsNode,ASTNode.FunctionCallParameterList))return[];var _node_fnSymbols;var candidates=(_node_fnSymbols=node.fnSymbols)!=null?_node_fnSymbols:_instanceof(node.fnSymbol,FnSymbol)?[node.fnSymbol]:[];if(!candidates.length)return[];var issues=[];for(var _iterator=_create_for_of_iterator_helper_loose(candidates),_step;!(_step=_iterator()).done;){var candidate=_step.value;var branch=node._branch.concat(candidate.branchSignature);if(getBranchReachability(branch)!==\"reachable\")continue;for(var index=0;index<argumentsNode.paramNodes.length;index++){var _candidate_astNode_protoType_parameterList_index,_candidate_astNode_protoType_parameterList;var argument=argumentsNode.paramNodes[index];if(!_instanceof(argument,TreeNode))continue;var parameter=(_candidate_astNode_protoType_parameterList=candidate.astNode.protoType.parameterList)==null?void 0:(_candidate_astNode_protoType_parameterList_index=_candidate_astNode_protoType_parameterList[index])==null?void 0:_candidate_astNode_protoType_parameterList_index.astNode;if(!_instanceof(parameter,ASTNode.ParameterDeclaration)||!(ParserUtils.hasQualifier(parameter,Keyword.OUT)||ParserUtils.hasQualifier(parameter,Keyword.INOUT)))continue;var reason=this.nonAssignableReason(argument);if(reason){issues.push({code:\"InvalidAssignmentTarget\",message:\"Cannot pass \"+reason+\" to an out or inout parameter — the argument must be a modifiable l-value.\",location:argument.location,branch:branch})}}}return issues};ParserSemanticValidation.assignmentTargetIssue=function assignmentTargetIssue(node){if(node.children.length!==3)return;var lhs=node.children[0];if(!_instanceof(lhs,ASTNode.ExpressionAstNode))return;var reason=this.nonAssignableReason(lhs);return reason?{code:\"InvalidAssignmentTarget\",message:\"Cannot assign to \"+reason+\" — the left operand of '=' must be a modifiable l-value.\",location:lhs.location}:undefined};ParserSemanticValidation.incrementTargetIssue=function incrementTargetIssue(node){if(node.children.length!==2)return;var prefix=_instanceof(node,ASTNode.UnaryExpression);var operator=node.children[prefix?0:1];var operand=node.children[prefix?1:0];if(!_instanceof(operator,BaseToken)||operator.type!==ETokenType.INC_OP&&operator.type!==ETokenType.DEC_OP||!_instanceof(operand,TreeNode)){return}var reason=this.nonAssignableReason(operand);return reason?{code:\"InvalidAssignmentTarget\",message:\"Cannot apply '\"+operator.lexeme+\"' to \"+reason+\" — the operand of '\"+operator.lexeme+\"' must be a modifiable l-value.\",location:operand.location}:undefined};ParserSemanticValidation.assignmentTypeIssue=function assignmentTypeIssue(node){var _operator_children_;if(node.children.length!==3)return;var lhs=node.children[0];var operator=node.children[1];var rhs=node.children[2];if(!_instanceof(lhs,ASTNode.ExpressionAstNode)||!_instanceof(operator,ASTNode.AssignmentOperator)||!_instanceof(rhs,ASTNode.AssignmentExpression)){return}var operatorType=(_operator_children_=operator.children[0])==null?void 0:_operator_children_.type;var compoundOperator=operatorType===ETokenType.MUL_ASSIGN?\"*\":operatorType===ETokenType.DIV_ASSIGN?\"/\":operatorType===ETokenType.MOD_ASSIGN?\"%\":operatorType===ETokenType.ADD_ASSIGN?\"+\":operatorType===ETokenType.SUB_ASSIGN?\"-\":undefined;var arithmetic=compoundOperator?TypeSystem.arithmeticOperation(lhs.type,rhs.type,compoundOperator):undefined;if((arithmetic==null?void 0:arithmetic.valid)===false){return{code:\"InvalidBinaryOperands\",message:\"Operator '\"+compoundOperator+\"=' cannot combine '\"+TypeSystem.typeName(lhs.type)+\"' and '\"+TypeSystem.typeName(rhs.type)+\"'.\",location:node.location}}var _arithmetic_resultType;var assignedType=(_arithmetic_resultType=arithmetic==null?void 0:arithmetic.resultType)!=null?_arithmetic_resultType:rhs.type;if(!TypeSystem.isAssignable(lhs.type,assignedType)){return{code:\"AssignTypeMismatch\",message:\"Cannot assign a value of type '\"+TypeSystem.typeName(rhs.type)+\"' to '\"+TypeSystem.typeName(lhs.type)+\"'.\",location:node.location}}return};ParserSemanticValidation.nonBoolConditionIssue=function nonBoolConditionIssue(condition,label){var type=condition.type;if(type===TypeAny||type===Keyword.BOOL)return;return{code:\"NonBoolCondition\",message:\"\"+label[0].toUpperCase()+label.slice(1)+\" must be a bool, got '\"+TypeSystem.typeName(type)+\"'.\",location:condition.location}};ParserSemanticValidation.selectionConditionIssue=function selectionConditionIssue(node){var condition=node.children.find(function(child){return _instanceof(child,ASTNode.ExpressionAstNode)});return _instanceof(condition,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(condition,\"'if' condition\"):undefined};ParserSemanticValidation.iterationConditionIssue=function iterationConditionIssue(node){var keyword=node.children[0];if(!_instanceof(keyword,BaseToken))return;var condition;var label;if(keyword.type===Keyword.WHILE){var candidate=node.children[2];if(_instanceof(candidate,ASTNode.Condition))condition=candidate;label=\"'while' condition\"}else if(keyword.type===Keyword.FOR){var rest=node.children[3];var optionalCondition=_instanceof(rest,ASTNode.ForRestStatement)?rest.children[0]:undefined;var candidate1=_instanceof(optionalCondition,ASTNode.ConditionOpt)&&optionalCondition.children.length===1?optionalCondition.children[0]:undefined;if(_instanceof(candidate1,ASTNode.Condition))condition=candidate1;label=\"'for' condition\"}else{return}if(!condition)return;var children=condition.children;var expression=children.length===1&&_instanceof(children[0],ASTNode.ExpressionAstNode)?children[0]:children.length===4&&_instanceof(children[3],ASTNode.ExpressionAstNode)?children[3]:undefined;return _instanceof(expression,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(expression,label):undefined};ParserSemanticValidation.ternaryConditionIssue=function ternaryConditionIssue(node){var condition=node.children.length===5?node.children[0]:undefined;return _instanceof(condition,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(condition,\"ternary condition\"):undefined};ParserSemanticValidation.constructorIssue=function constructorIssue(node){var functionIdentifier=node.children[0];if(!functionIdentifier.isBuiltin)return;var list=node.children.length===4?node.children[2]:undefined;if(!_instanceof(list,ASTNode.FunctionCallParameterList))return;var badIndex=list.paramSig.findIndex(function(type){return TypeSystem.isSamplerType(type)||typeof type===\"string\"});if(badIndex>=0){var argument=list.paramNodes[badIndex];return{code:\"ConstructorArgType\",message:\"Cannot construct '\"+TypeSystem.typeName(functionIdentifier.ident)+\"' from a '\"+TypeSystem.typeName(list.paramSig[badIndex])+\"' argument.\",location:_instanceof(argument,TreeNode)?argument.location:list.location}}var matrixComponents=TypeSystem.matrixComponentCount(functionIdentifier.ident);var requiredComponents=TypeSystem.vectorComponentCount(functionIdentifier.ident)||matrixComponents;if(requiredComponents<=0)return;if(matrixComponents>0&&list.paramSig.length===1&&TypeSystem.matrixComponentCount(list.paramSig[0])>0){return}if(matrixComponents===0&&list.paramSig.length===1&&TypeSystem.vectorComponentCount(list.paramSig[0])>=requiredComponents){return}var providedComponents=0;var countable=list.paramSig.length>0;for(var _iterator=_create_for_of_iterator_helper_loose(list.paramSig),_step;!(_step=_iterator()).done;){var type=_step.value;var components=TypeSystem.isScalarType(type)?1:TypeSystem.vectorComponentCount(type)||TypeSystem.matrixComponentCount(type);if(components===0){countable=false;break}providedComponents+=components}var singleScalar=list.paramSig.length===1&&TypeSystem.isScalarType(list.paramSig[0]);return countable&&!singleScalar&&providedComponents!==requiredComponents?{code:\"ConstructorArgCount\",message:\"Constructor '\"+TypeSystem.typeName(functionIdentifier.ident)+\"' needs \"+requiredComponents+\" components but the arguments provide \"+providedComponents+\".\",location:list.location}:undefined};ParserSemanticValidation.functionReturnTypeIssue=function functionReturnTypeIssue(node){var _this=this;var returnType=node.returnType;var type=returnType.type;if(TypeSystem.isSamplerType(type)){return{code:\"NonConstructibleReturnType\",message:\"Function return type '\"+TypeSystem.typeName(type)+\"' is not constructible; samplers cannot be returned.\",location:returnType.location}}if(typeof type===\"string\"&&returnType.typeSpecifier.structDeclarations.some(function(declaration){return _this._structContainsSampler(declaration,new Set)})){return{code:\"NonConstructibleReturnType\",message:\"Function return type '\"+type+\"' is not constructible; structs containing samplers cannot be returned.\",location:returnType.location}}return};ParserSemanticValidation._structContainsSampler=function _structContainsSampler(declaration,visited){if(visited.has(declaration))return false;visited.add(declaration);for(var _iterator=_create_for_of_iterator_helper_loose(declaration.propList),_step;!(_step=_iterator()).done;){var property=_step.value;if(TypeSystem.isSamplerType(property.typeInfo.type))return true;for(var _iterator1=_create_for_of_iterator_helper_loose(property.typeInfo.structDeclarations),_step1;!(_step1=_iterator1()).done;){var nestedDeclaration=_step1.value;if(this._structContainsSampler(nestedDeclaration,visited))return true}}return false};return ParserSemanticValidation}();var EMPTY_ERRORS$1=Object.freeze([]);var EMPTY_PREPROCESSOR_EXPRESSIONS$1=new Map;function mapExpandedShaderRange(startOffset,endOffset,segments){var startSegment=findSourceMapSegment(startOffset,segments,false);if(!startSegment)return undefined;var endSegment=findSourceMapSegment(endOffset,segments,true);var mappedStartOffset=startSegment.sourceStart+startOffset-startSegment.generatedStart;var mappedEndOffset=(endSegment==null?void 0:endSegment.source)===startSegment.source&&endSegment.sourceFile===startSegment.sourceFile?endSegment.sourceStart+endOffset-endSegment.generatedStart:mappedStartOffset;return{source:startSegment.source,sourceFile:startSegment.sourceFile,start:shaderPositionAt(startSegment.source,mappedStartOffset),end:shaderPositionAt(startSegment.source,mappedEndOffset)}}function mapExpandedShaderError(error,expandedSource,segments){if(!_instanceof(error,GSError)||error.source!==expandedSource)return error;var location=error.location;var range=\"start\"in location?location:{start:location,end:location};var mapped=mapExpandedShaderRange(range.start.index,range.end.index,segments);if(!mapped)return error;var mappedLocation=new ShaderRange;mappedLocation.set(mapped.start,mapped.end);var _mapped_sourceFile;return new GSError(error.name,error.message,mappedLocation,mapped.source,(_mapped_sourceFile=mapped.sourceFile)!=null?_mapped_sourceFile:error.file,error.code)}function findSourceMapSegment(offset,segments,isEnd){for(var _iterator=_create_for_of_iterator_helper_loose(segments),_step;!(_step=_iterator()).done;){var segment=_step.value;if(offset>=segment.generatedStart&&(isEnd?offset<=segment.generatedEnd&&offset>segment.generatedStart:offset<segment.generatedEnd)){return segment}}var last=segments[segments.length-1];return last&&offset===last.generatedEnd?last:undefined}function shaderPositionAt(source,offset){var line=0;var column=0;for(var index=0;index<offset;index++){if(source.charCodeAt(index)===10){line++;column=0}else{column++}}var position=new ShaderPosition;position.set(offset,line,column);return position}function parseShaderPassWith(source,includeMap,cache,basePathForIncludeKey,createLexer,createParser,sourceFile,objectPool,trackSourceMap,sourceScopeStarts){if(trackSourceMap===void 0)trackSourceMap=true;objectPool==null?void 0:objectPool.reset();var macroDefineList={};var _Preprocessor_parseWithErrors=Preprocessor.parseWithErrors(source,basePathForIncludeKey,includeMap,cache,sourceFile,trackSourceMap,sourceScopeStarts),expandedSource=_Preprocessor_parseWithErrors.content,preprocessErrors=_Preprocessor_parseWithErrors.errors,sourceMap=_Preprocessor_parseWithErrors.sourceMap,conditionalArms=_Preprocessor_parseWithErrors.conditionalArms;for(var _iterator=_create_for_of_iterator_helper_loose(sourceMap),_step;!(_step=_iterator()).done;){var segment=_step.value;Object.freeze(segment)}var frozenSourceMap=Object.freeze(sourceMap);if(preprocessErrors.length){var errors=Object.freeze([].concat(preprocessErrors));return Object.freeze({ir:null,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:EMPTY_PREPROCESSOR_EXPRESSIONS$1,errors:errors,blockingErrors:errors})}var lexer=createLexer(expandedSource,macroDefineList,objectPool,conditionalArms);var tokens=lexer.tokenize();var parser=createParser(expandedSource,objectPool);parser.setSourceScopes(frozenSourceMap);var program=parser.parse(tokens,macroDefineList);var mappedParserErrors=parser.errors.map(function(error){return mapExpandedShaderError(error,expandedSource,frozenSourceMap)});var errors1=mappedParserErrors.length?Object.freeze(mappedParserErrors):EMPTY_ERRORS$1;var parserBlockingErrors=parser.semanticErrorsBlockCodegen?parser.errors:parser.blockingErrors;var blockingErrors=parser.errors.length===parserBlockingErrors.length?errors1:Object.freeze(parserBlockingErrors.map(function(error){return mapExpandedShaderError(error,expandedSource,frozenSourceMap)}));var ir=program?Object.freeze(new ShaderClueIR(program,expandedSource,frozenSourceMap)):null;if(ir){var semanticIssues=ParserSemanticValidation.collect(ir.program);if(semanticIssues.length){var semanticErrors=semanticIssues.map(function(issue){return mapExpandedShaderError(ShaderCompilerUtils.createGSError(issue.message,GSErrorName.CompilationError,expandedSource,issue.location,issue.code),expandedSource,frozenSourceMap)});return Object.freeze({ir:ir,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:lexer.preprocessorExpressions,errors:Object.freeze([].concat(errors1,semanticErrors)),blockingErrors:Object.freeze([].concat(blockingErrors,semanticErrors))})}}return Object.freeze({ir:ir,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:lexer.preprocessorExpressions,errors:errors1,blockingErrors:blockingErrors})}var EMPTY_ERRORS=Object.freeze([]);var EMPTY_SOURCE_MAP=Object.freeze([]);var EMPTY_PREPROCESSOR_EXPRESSIONS=new Map;function createRuntimeShaderTargetParser(objectPool){return ShaderTargetParser.create(undefined,undefined,undefined,objectPool)}function parseRuntimeShaderPass(source,includeMap,cache,sourceFile,objectPool,runtimeParser,sourceScopeStarts){objectPool==null?void 0:objectPool.reset();if(!(sourceScopeStarts==null?void 0:sourceScopeStarts.some(function(offset){return offset>0})))sourceScopeStarts=undefined;var normalizedSourceFile=normalizeShaderSourceFile(sourceFile);var preprocessResult=Preprocessor.parseWithErrors(source,shaderSourceBaseURL(normalizedSourceFile),includeMap,cache,normalizedSourceFile,false,sourceScopeStarts);var expandedSource=preprocessResult.content;if(preprocessResult.errors.length){var errors=freezeErrors(preprocessResult.errors);return Object.freeze({ir:null,expandedSource:expandedSource,sourceMap:EMPTY_SOURCE_MAP,preprocessorExpressions:EMPTY_PREPROCESSOR_EXPRESSIONS,errors:errors,blockingErrors:errors})}var macroDefineList={};var lexer=new Lexer(expandedSource,macroDefineList,objectPool,preprocessResult.conditionalArms);var parser=runtimeParser!=null?runtimeParser:createRuntimeShaderTargetParser(objectPool);parser.setSource(expandedSource);parser.setSourceScopes(preprocessResult.sourceScopes);var program=parser.parse(lexer.tokenize(),macroDefineList);var errors1=freezeErrors(parser.errors);var blockingErrors=freezeErrors(parser.blockingErrors);return Object.freeze({ir:program?Object.freeze(new ShaderClueIR(program,expandedSource,EMPTY_SOURCE_MAP)):null,expandedSource:expandedSource,sourceMap:EMPTY_SOURCE_MAP,preprocessorExpressions:lexer.preprocessorExpressions,errors:errors1,blockingErrors:blockingErrors})}function freezeErrors(){for(var _len=arguments.length,groups=new Array(_len),_key=0;_key<_len;_key++){groups[_key]=arguments[_key]}var _errors;var count=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups),_step;!(_step=_iterator()).done;){var group=_step.value;count+=group.length}if(count===0)return EMPTY_ERRORS;var errors=[];for(var _iterator1=_create_for_of_iterator_helper_loose(groups),_step1;!(_step1=_iterator1()).done;){var group1=_step1.value;(_errors=errors).push.apply(_errors,[].concat(group1))}return Object.freeze(errors)}var ShaderSourceFactory=function(){function ShaderSourceFactory(){}ShaderSourceFactory.createRenderStates=function createRenderStates(){return{constantMap:{},variableMap:{}}};ShaderSourceFactory.createShaderSource=function createShaderSource(name){return{name:name,subShaders:[],pendingContents:[],renderStates:this.createRenderStates()}};ShaderSourceFactory.createSubShaderSource=function createSubShaderSource(name){return{name:name,passes:[],pendingContents:[],tags:{},renderStates:this.createRenderStates()}};ShaderSourceFactory.createShaderPassSource=function createShaderPassSource(name){return{name:name,pendingContents:[],contentScopeStarts:[],isUsePass:false,tags:{},renderStates:this.createRenderStates(),contents:\"\",vertexEntry:\"\",fragmentEntry:\"\"}};ShaderSourceFactory.createUsePass=function createUsePass(name){return{name:name,pendingContents:[],contentScopeStarts:[],isUsePass:true,tags:{},renderStates:this.createRenderStates(),contents:\"\",vertexEntry:\"\",fragmentEntry:\"\"}};return ShaderSourceFactory}();var ShaderSourceSymbol=function(){function ShaderSourceSymbol(ident,type,value){this.ident=ident;this.type=type;this.value=value;this.isInMacroBranch=false;this.branchSignature=EMPTY_BRANCH}var _proto=ShaderSourceSymbol.prototype;_proto.set=function set(ident,type,value){this.ident=ident;this.type=type;this.value=value};_proto.equal=function equal(other){return this.type===other.type};return ShaderSourceSymbol}();var SourceLexer=function(BaseLexer1){_inherits(SourceLexer,BaseLexer1);function SourceLexer(){var _this;_this=BaseLexer1.apply(this,arguments)||this,_this.hasPendingContent=false;return _this}var _proto=SourceLexer.prototype;_proto.setSource=function setSource(source){BaseLexer1.prototype.setSource.call(this,source);this.hasPendingContent=false};_proto.scanNumber=function scanNumber(){this.skipCommentsAndSpace();var start=this._currentIndex;var source=this._source;var index=this._currentIndex;index=SourceLexer._scanDigits(source,index);if(source[index]===\".\"){index=SourceLexer._scanDigits(source,index+1)}this.advance(index-this._currentIndex);return Number(source.substring(start,index))};_proto.scanColor=function scanColor(){this.scanLexeme(\"(\");var r=this.scanNumber();var g=0;var b=0;var a=1;this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");g=this.scanNumber();this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");b=this.scanNumber();this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");a=this.scanNumber();this.skipCommentsAndSpace()}}}this.scanLexeme(\")\");return new Color(r,g,b,a)};_proto.scanToken=function scanToken(){while(true){this.skipCommentsAndSpace();if(this.isEnd()){return this._createEOFToken()}var start=this.getShaderPosition(0);if(BaseLexer.isAlpha(this.getCurCharCode())){var wordToken=this._scanWord(start);if(wordToken!==null){return wordToken}this.hasPendingContent=true;continue}var currentChar=this.getCurChar();var symbolKeyword=SourceLexer._symbolLexemeTable[currentChar];if(symbolKeyword!==undefined){this.advance(1);var token=this._createToken();token.set(symbolKeyword,currentChar,start);return token}this.advance(1)}};_proto.scanToCharacter=function scanToCharacter(char){while(this.getCurChar()!==char&&this.getCurChar()!==\"}\"&&!this.isEnd()){this.advance(1)}if(this.getCurChar()!==char)return false;this.advance(1);return true};_proto.createCompileError=function createCompileError(message,location,code){return ShaderCompilerUtils.createGSError(message,GSErrorName.CompilationError,this.source,location!=null?location:this.getShaderPosition(0),code)};_proto._scanWord=function _scanWord(start){while(BaseLexer.isAlnum(this.getCurCharCode())&&!this.isEnd()){this.advance(1)}var end=this.getShaderPosition(0);if(!this._validateWordBoundaries(start.index,end.index)){return null}var lexeme=this._source.substring(start.index,end.index);var _SourceLexer__keywordLexemeTable_lexeme;var tokenType=(_SourceLexer__keywordLexemeTable_lexeme=SourceLexer._keywordLexemeTable[lexeme])!=null?_SourceLexer__keywordLexemeTable_lexeme:ETokenType.ID;var range=this._createRange(start,end);var token=this._createToken();token.set(tokenType,lexeme,range);return token};_proto._validateWordBoundaries=function _validateWordBoundaries(startIndex,endIndex){var source=this._source;if(startIndex>0){var prevCharCode=source.charCodeAt(startIndex-1);if(!this._isValidWordBoundary(prevCharCode)){return false}}if(endIndex<source.length){var nextCharCode=source.charCodeAt(endIndex);if(!this._isValidWordBoundary(nextCharCode)){return false}}return true};_proto._isValidWordBoundary=function _isValidWordBoundary(charCode){return BaseLexer.isWhiteSpaceChar(charCode,true)||SourceLexer._isWordSeparatorChar(charCode)};SourceLexer._isWordSeparatorChar=function _isWordSeparatorChar(charCode){return charCode===123||charCode===125||charCode===61||charCode===59||charCode===46||charCode===91||charCode===40||charCode===124};SourceLexer._scanDigits=function _scanDigits(source,startIndex){var currentIndex=startIndex;while(currentIndex<source.length){var charCode=source.charCodeAt(currentIndex);if(BaseLexer.isDigit(charCode)){currentIndex++}else{break}}return currentIndex};return SourceLexer}(BaseLexer);SourceLexer._keywordLexemeTable={RenderQueueType:Keyword.GSRenderQueueType,BlendState:Keyword.GSBlendState,DepthState:Keyword.GSDepthState,StencilState:Keyword.GSStencilState,RasterState:Keyword.GSRasterState,EditorProperties:Keyword.GSEditorProperties,EditorMacros:Keyword.GSEditorMacros,Editor:Keyword.GSEditor,Tags:Keyword.GSTags,VertexShader:Keyword.GSVertexShader,FragmentShader:Keyword.GSFragmentShader,SubShader:Keyword.GSSubShader,Pass:Keyword.GSPass,BlendFactor:Keyword.GSBlendFactor,BlendOperation:Keyword.GSBlendOperation,Bool:Keyword.GSBool,Number:Keyword.GSNumber,Color:Keyword.GSColor,CompareFunction:Keyword.GSCompareFunction,StencilOperation:Keyword.GSStencilOperation,CullMode:Keyword.GSCullMode,ColorWriteMask:Keyword.GSColorWriteMask,UsePass:Keyword.GSUsePass,true:Keyword.True,false:Keyword.False};SourceLexer._symbolLexemeTable={\"{\":Keyword.LeftBrace,\"}\":Keyword.RightBrace,\"=\":Keyword.Equal,\"|\":Keyword.BitwiseOr};var renderStateConstMap={RenderQueueType:RenderQueueType,CompareFunction:CompareFunction,StencilOperation:StencilOperation,BlendOperation:BlendOperation,BlendFactor:BlendFactor,CullMode:CullMode,ColorWriteMask:ColorWriteMask};var ShaderSourceParser=function(){function ShaderSourceParser(){}ShaderSourceParser.parse=function parse(sourceCode){return new ShaderSourceParserSession().parse(sourceCode).shaderSource};ShaderSourceParser.parseStrict=function parseStrict(sourceCode,objectPool){return new ShaderSourceParserSession(objectPool).parse(sourceCode)};ShaderSourceParser.parseWithErrors=function parseWithErrors(sourceCode){return new ShaderSourceParserSession().parseWithErrors(sourceCode)};return ShaderSourceParser}();var ShaderSourceParserSession=function(){function ShaderSourceParserSession(_objectPool){this._objectPool=_objectPool;this._errors=[];this._symbolTableStack=new SymbolTableStack;this._lookupSymbol=new ShaderSourceSymbol(\"\",null);this._shaderSource=ShaderSourceFactory.createShaderSource(\"\");this._reportedUnexpectedEnd=false;this._lexer=new SourceLexer(undefined,this._objectPool)}var _proto=ShaderSourceParserSession.prototype;_proto.parseWithErrors=function parseWithErrors(sourceCode){try{return this.parse(sourceCode)}catch(error){if(!_instanceof(error,GSError))throw error;this._errors.push(error);return{shaderSource:this._shaderSource,errors:Object.freeze(this._errors.slice())}}};_proto.parse=function parse(sourceCode){var _this__objectPool;(_this__objectPool=this._objectPool)==null?void 0:_this__objectPool.reset();this._pushScope();var lexer=this._lexer;lexer.setSource(sourceCode);var shaderSource=this._parseShader(lexer);var shaderPendingContents=shaderSource.pendingContents;var shaderRenderStates=shaderSource.renderStates;for(var i=0,n=shaderSource.subShaders.length;i<n;i++){var subShader=shaderSource.subShaders[i];var globalSubShaderStates={constantMap:_extends({},shaderRenderStates.constantMap),variableMap:_extends({},shaderRenderStates.variableMap)};this._mergeRenderStates(globalSubShaderStates,subShader.renderStates);for(var j=0,m=subShader.passes.length;j<m;j++){var pass=subShader.passes[j];var globalPassRenderStates={constantMap:_extends({},globalSubShaderStates.constantMap),variableMap:_extends({},globalSubShaderStates.variableMap)};this._mergeRenderStates(globalPassRenderStates,pass.renderStates);pass.renderStates=globalPassRenderStates;if(pass.isUsePass)continue;var composed=this._composePassContents([shaderPendingContents,subShader.pendingContents,pass.pendingContents]);pass.contents=composed.contents;pass.contentScopeStarts=composed.scopeStarts}}return{shaderSource:shaderSource,errors:Object.freeze(this._errors.slice())}};_proto._composePassContents=function _composePassContents(groups){var parts=[];var scopeStarts=[];var length=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups),_step;!(_step=_iterator()).done;){var group=_step.value;scopeStarts.push(length);for(var _iterator1=_create_for_of_iterator_helper_loose(group),_step1;!(_step1=_iterator1()).done;){var statement=_step1.value;if(parts.length)length++;parts.push(statement.content);length+=statement.content.length}}return{contents:parts.join(\"\\n\"),scopeStarts:Object.freeze(scopeStarts)}};_proto._parseShader=function _parseShader(lexer){lexer.scanLexeme(\"Shader\");var name=lexer.scanPairedChar('\"','\"',false,false);var shaderSource=ShaderSourceFactory.createShaderSource(name);this._shaderSource=shaderSource;lexer.scanLexeme(\"{\");var braceLevel=1;lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);var pendingContents=shaderSource.pendingContents;while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,pendingContents);this._reportUnexpectedEnd(token,\"Shader\");this._popScope();return shaderSource;case Keyword.GSSubShader:{this._addPendingContents(start,token.lexeme.length,pendingContents);var subShader=this._parseSubShader();shaderSource.subShaders.push(subShader);start=lexer.getShaderPosition(0);break}case Keyword.GSEditorProperties:case Keyword.GSEditorMacros:case Keyword.GSEditor:this._addPendingContents(start,token.lexeme.length,pendingContents);lexer.scanPairedChar(\"{\",\"}\",true,false);start=lexer.getShaderPosition(0);break;case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,pendingContents);this._popScope();return shaderSource}break;default:start=this._parseRenderState(token,start,pendingContents,shaderSource.renderStates)}}};_proto._parseRenderStateDeclarationOrAssignment=function _parseRenderStateDeclarationOrAssignment(outRenderStates,stateToken){var lexer=this._lexer;var token=lexer.scanToken();if(token.type===ETokenType.ID){lexer.scanLexeme(\"{\");var renderState=this._parseRenderStateProperties(stateToken.lexeme);var symbol=new ShaderSourceSymbol(token.lexeme,stateToken.type,renderState);this._symbolTableStack.insert(symbol)}else if(token.lexeme===\"=\"){var nextToken=lexer.scanToken();if(nextToken.type===ETokenType.EOF)return;var renderState1;if(nextToken.lexeme===\"{\"){renderState1=this._parseRenderStateProperties(stateToken.lexeme)}else{lexer.scanLexeme(\";\");var lookupSymbol=this._lookupSymbol;lookupSymbol.set(nextToken.lexeme,stateToken.type);var sm=this._symbolTableStack.lookup(lookupSymbol);if(!(sm==null?void 0:sm.value)){this._createCompileError('Invalid \"'+stateToken.lexeme+'\" variable: '+nextToken.lexeme+\" — property will not be applied.\",nextToken.location,\"InvalidRenderStateVariable\");return}renderState1=sm.value}this._mergeRenderStates(outRenderStates,renderState1)}};_proto._mergeRenderStates=function _mergeRenderStates(outTarget,source){var targetConstantMap=outTarget.constantMap,targetVariableMap=outTarget.variableMap;var sourceConstantMap=source.constantMap,sourceVariableMap=source.variableMap;for(var key in sourceConstantMap){delete targetVariableMap[key];targetConstantMap[key]=sourceConstantMap[key]}for(var key1 in sourceVariableMap){delete targetConstantMap[key1];targetVariableMap[key1]=sourceVariableMap[key1]}};_proto._parseVariableDeclaration=function _parseVariableDeclaration(){var lexer=this._lexer;var token=lexer.scanToken();lexer.scanLexeme(\";\");var symbol=new ShaderSourceSymbol(token.lexeme,token.type);this._symbolTableStack.insert(symbol)};_proto._pushScope=function _pushScope(){var symbolTable=new SymbolTable;this._symbolTableStack.pushScope(symbolTable)};_proto._popScope=function _popScope(){this._symbolTableStack.popScope()};_proto._parseRenderStateProperties=function _parseRenderStateProperties(state){var lexer=this._lexer;var renderStates=ShaderSourceFactory.createRenderStates();while(lexer.getCurChar()!==\"}\"&&!lexer.isEnd()){this._parseRenderStateProperty(state,renderStates);lexer.skipCommentsAndSpace()}if(lexer.getCurChar()===\"}\")lexer.advance(1);return renderStates};_proto._createCompileError=function _createCompileError(message,location,code){var error=this._lexer.createCompileError(message,location,code);this._errors.push(error)};_proto._scanEnumConstValue=function _scanEnumConstValue(enumName){var _renderStateConstMap_enumName;var lexer=this._lexer;lexer.advance(1);var constValueToken=lexer.scanToken();var value=(_renderStateConstMap_enumName=renderStateConstMap[enumName])==null?void 0:_renderStateConstMap_enumName[constValueToken.lexeme];if(value==undefined){this._createCompileError(\"Invalid engine constant: \"+enumName+\".\"+constValueToken.lexeme+\" — property will not be applied.\",constValueToken.location,\"InvalidEnumValue\");lexer.scanToCharacter(\";\")}return value};_proto._parseRenderStateProperty=function _parseRenderStateProperty(stateLexeme,out){var lexer=this._lexer;var propertyToken=lexer.scanToken();var propertyLexeme=propertyToken.lexeme;var stateElementKey=propertyLexeme;if(stateLexeme===\"BlendState\"&&propertyLexeme!==\"BlendColor\"&&propertyLexeme!==\"AlphaToCoverage\"){var keyIndex=0;var scannedLexeme=lexer.scanTwoExpectedLexemes(\"[\",\"=\");if(scannedLexeme===\"[\"){keyIndex=lexer.scanNumber();lexer.scanLexeme(\"]\");lexer.scanLexeme(\"=\")}else if(scannedLexeme!==\"=\"){this._createCompileError(\"Invalid syntax, expect '[' or '=', but got unexpected token\",undefined,\"SyntaxError\");lexer.scanToCharacter(\";\");return}stateElementKey+=keyIndex}else{lexer.scanLexeme(\"=\")}var renderStateElementKey=RenderStateElementKey[stateLexeme+stateElementKey];if(renderStateElementKey===undefined){this._createCompileError(\"Invalid render state property \"+propertyLexeme+\" — property will not be applied.\",propertyToken.location,\"InvalidRenderStateProperty\");lexer.scanToCharacter(\";\");return}lexer.skipCommentsAndSpace();var propertyValue;var curCharCode=lexer.getCurCharCode();if(BaseLexer.isDigit(curCharCode)||curCharCode===46){propertyValue=lexer.scanNumber()}else{var valueToken=lexer.scanToken();var valueTokenType=valueToken.type;if(valueTokenType===ETokenType.EOF)return;if(valueTokenType===Keyword.True){propertyValue=true}else if(valueTokenType===Keyword.False){propertyValue=false}else if(valueTokenType===Keyword.GSColor){propertyValue=lexer.scanColor()}else if(lexer.getCurChar()===\".\"){propertyValue=this._scanEnumConstValue(valueToken.lexeme);if(propertyValue==undefined)return;lexer.skipCommentsAndSpace();if(lexer.getCurChar()===\"|\"){if(valueToken.lexeme!==\"ColorWriteMask\"){this._createCompileError(\"Bitwise OR '|' is not supported for '\"+valueToken.lexeme+\"', only bitmask enums like 'ColorWriteMask' support this — property will not be applied.\",valueToken.location,\"BitwiseOrOnNonBitmask\");lexer.scanToCharacter(\";\");return}while(lexer.getCurChar()===\"|\"){lexer.advance(1);var nextEnumToken=lexer.scanToken();if(nextEnumToken==undefined||lexer.getCurChar()!==\".\"){this._createCompileError(\"Invalid syntax after '|', expect 'EnumType.Value'\",nextEnumToken==null?void 0:nextEnumToken.location,\"SyntaxError\");lexer.scanToCharacter(\";\");return}if(nextEnumToken.lexeme!==valueToken.lexeme){this._createCompileError(\"Cannot mix enum types in bitwise OR: expected '\"+valueToken.lexeme+\"' but got '\"+nextEnumToken.lexeme+\"' — property will not be applied.\",nextEnumToken.location,\"MixedEnumTypes\");lexer.scanToCharacter(\";\");return}var nextValue=this._scanEnumConstValue(nextEnumToken.lexeme);if(nextValue==undefined)return;propertyValue=propertyValue|nextValue;lexer.skipCommentsAndSpace()}}}else{propertyValue=valueToken.lexeme;var lookupSymbol=this._lookupSymbol;lookupSymbol.set(valueToken.lexeme,ETokenType.ID);if(!this._symbolTableStack.lookup(lookupSymbol)){this._createCompileError(\"Invalid \"+stateLexeme+\" variable: \"+valueToken.lexeme+\" — property will not be applied.\",valueToken.location,\"InvalidRenderStateVariable\");lexer.scanToCharacter(\";\");return}}}lexer.scanLexeme(\";\");if(typeof propertyValue===\"string\"){out.variableMap[renderStateElementKey]=propertyValue}else{out.constantMap[renderStateElementKey]=propertyValue}};_proto._parseRenderQueueDeclarationOrAssignment=function _parseRenderQueueDeclarationOrAssignment(renderStates){var lexer=this._lexer;var token=lexer.scanToken();if(token.type===ETokenType.ID){lexer.scanLexeme(\";\");var symbol=new ShaderSourceSymbol(token.lexeme,Keyword.GSRenderQueueType);this._symbolTableStack.insert(symbol);return}if(token.lexeme!==\"=\"){this._createCompileError(\"Invalid syntax, expect character '=', but got \"+token.lexeme,token.location,\"SyntaxError\");return}var word=lexer.scanToken();lexer.scanLexeme(\";\");var value=renderStateConstMap.RenderQueueType[word.lexeme];var key=RenderStateElementKey.RenderQueueType;if(value==undefined){var lookupSymbol=this._lookupSymbol;lookupSymbol.set(word.lexeme,Keyword.GSRenderQueueType);var sm=this._symbolTableStack.lookup(lookupSymbol);if(!sm){this._createCompileError(\"Invalid RenderQueueType variable: \"+word.lexeme+\" — property will not be applied at runtime.\",word.location,\"InvalidRenderQueueVariable\");return}renderStates.variableMap[key]=word.lexeme}else{renderStates.constantMap[key]=value}};_proto._addPendingContents=function _addPendingContents(start,backOffset,outPendingContents){var lexer=this._lexer;if(lexer.hasPendingContent){var endIndex=lexer.currentIndex-backOffset;outPendingContents.push({range:{start:start,end:_extends({},lexer.getShaderPosition(0),{index:endIndex-1})},content:lexer.source.substring(start.index,endIndex-1)});lexer.hasPendingContent=false}};_proto._parseSubShader=function _parseSubShader(){var lexer=this._lexer;this._pushScope();var braceLevel=1;var name=lexer.scanPairedChar('\"','\"',false,false);var subShaderSource=ShaderSourceFactory.createSubShaderSource(name);lexer.scanLexeme(\"{\");lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,subShaderSource.pendingContents);this._reportUnexpectedEnd(token,\"SubShader\");this._popScope();return subShaderSource;case Keyword.GSPass:{this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);var pass=this._parsePass(this._retainRange(token.location));subShaderSource.passes.push(pass);start=lexer.getShaderPosition(0);break}case Keyword.GSUsePass:{this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);var name1=lexer.scanPairedChar('\"','\"',false,false);subShaderSource.passes.push(ShaderSourceFactory.createUsePass(name1));start=lexer.getShaderPosition(0);break}case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);this._popScope();return subShaderSource}break;default:start=this._parseRenderStateAndTags(token,start,subShaderSource.pendingContents,subShaderSource.renderStates,subShaderSource.tags)}}};_proto._parseTags=function _parseTags(tags){var lexer=this._lexer;lexer.scanLexeme(\"{\");while(true){var ident=lexer.scanToken();lexer.scanLexeme(\"=\");var value=lexer.scanPairedChar('\"','\"',false,false);lexer.skipCommentsAndSpace();tags[ident.lexeme]=value;if(lexer.peek(1)===\"}\"){lexer.advance(1);return}lexer.scanLexeme(\",\")}};_proto._parsePass=function _parsePass(passLocation){this._pushScope();var lexer=this._lexer;var name=lexer.scanPairedChar('\"','\"',false,false);var passSource=ShaderSourceFactory.createShaderPassSource(name);lexer.scanLexeme(\"{\");var braceLevel=1;lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,passSource.pendingContents);this._reportUnexpectedEnd(token,\"Pass\");this._popScope();return passSource;case Keyword.GSVertexShader:case Keyword.GSFragmentShader:{this._addPendingContents(start,token.lexeme.length,passSource.pendingContents);lexer.scanLexeme(\"=\");var entry=lexer.scanToken();var isVertex=token.type===Keyword.GSVertexShader;var key=isVertex?\"vertexEntry\":\"fragmentEntry\";if(passSource[key]){this._createCompileError(\"Reassignment of \"+(isVertex?\"VertexShader\":\"FragmentShader\")+\" entry — the first binding is kept.\",entry.location,\"DuplicateEntryAssignment\");lexer.scanLexeme(\";\");start=lexer.getShaderPosition(0);break}passSource[key]=entry.lexeme;passSource[isVertex?\"vertexEntryLocation\":\"fragmentEntryLocation\"]=this._retainRange(entry.location);lexer.scanLexeme(\";\");start=lexer.getShaderPosition(0);break}case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,passSource.pendingContents);if(!passSource.vertexEntry||!passSource.fragmentEntry){this._createCompileError(\"Pass must bind both VertexShader and FragmentShader entries.\",passLocation,\"MissingEntry\")}this._popScope();return passSource}break;default:start=this._parseRenderStateAndTags(token,start,passSource.pendingContents,passSource.renderStates,passSource.tags)}}};_proto._reportUnexpectedEnd=function _reportUnexpectedEnd(token,construct){if(this._reportedUnexpectedEnd)return;this._reportedUnexpectedEnd=true;this._createCompileError(\"Unexpected end of source while parsing \"+construct+\".\",token.location,\"SyntaxError\")};_proto._retainRange=function _retainRange(range){if(!this._objectPool)return range;var start=new ShaderPosition;start.set(range.start.index,range.start.line,range.start.column);var end=new ShaderPosition;end.set(range.end.index,range.end.line,range.end.column);var retained=new ShaderRange;retained.set(start,end);return retained};_proto._parseRenderStateAndTags=function _parseRenderStateAndTags(token,start,outGlobalContents,outRenderStates,outTags){switch(token.type){case Keyword.GSTags:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseTags(outTags);start=this._lexer.getShaderPosition(0);break;default:start=this._parseRenderState(token,start,outGlobalContents,outRenderStates)}return start};_proto._parseRenderState=function _parseRenderState(token,start,outGlobalContents,outRenderStates){switch(token.type){case Keyword.GSBlendState:case Keyword.GSDepthState:case Keyword.GSRasterState:case Keyword.GSStencilState:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseRenderStateDeclarationOrAssignment(outRenderStates,token);start=this._lexer.getShaderPosition(0);break;case Keyword.GSBlendFactor:case Keyword.GSBlendOperation:case Keyword.GSBool:case Keyword.GSNumber:case Keyword.GSColor:case Keyword.GSCompareFunction:case Keyword.GSStencilOperation:case Keyword.GSCullMode:case Keyword.GSColorWriteMask:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseVariableDeclaration();start=this._lexer.getShaderPosition(0);break;case Keyword.GSRenderQueueType:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseRenderQueueDeclarationOrAssignment(outRenderStates);start=this._lexer.getShaderPosition(0);break;default:this._lexer.hasPendingContent=true}return start};return ShaderSourceParserSession}();var nextNodePoolId=0;var ParserObjectPool=function(){function ParserObjectPool(){this._tokens={values:[],used:0};this._positions={values:[],used:0};this._ranges={values:[],used:0};this._nodes=[]}var _proto=ParserObjectPool.prototype;_proto.reset=function reset(){this._tokens.used=0;this._positions.used=0;this._ranges.used=0;for(var _iterator=_create_for_of_iterator_helper_loose(this._nodes),_step;!(_step=_iterator()).done;){var list=_step.value;if(list)list.used=0}};_proto.createToken=function createToken(){var list=this._tokens;var index=list.used++;var _list_values_index;return(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new BaseToken(this)};_proto.createPosition=function createPosition(index,line,column){var list=this._positions;var itemIndex=list.used++;var _list_values_itemIndex;var position=(_list_values_itemIndex=list.values[itemIndex])!=null?_list_values_itemIndex:list.values[itemIndex]=new ShaderPosition;position.set(index,line,column);return position};_proto.createRange=function createRange(start,end){var list=this._ranges;var index=list.used++;var _list_values_index;var range=(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new ShaderRange;range.set(start,end);return range};_proto.createNode=function createNode(type){var pooledType=type;var _pooledType___parserObjectPoolId;var poolId=(_pooledType___parserObjectPoolId=pooledType.__parserObjectPoolId)!=null?_pooledType___parserObjectPoolId:pooledType.__parserObjectPoolId=nextNodePoolId++;var list=this._nodes[poolId];if(!list){list={values:[],used:0};this._nodes[poolId]=list}var index=list.used++;var _list_values_index;return(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new type};return ParserObjectPool}();var GLESShaderInfo=function GLESShaderInfo(ir,coreInfo){var io=coreInfo.io,vertexEntry=coreInfo.vertexEntry,fragmentEntry=coreInfo.fragmentEntry,getDeclarationCoexistence=coreInfo.getDeclarationCoexistence,getBranchCoverage=coreInfo.getBranchCoverage;this.mrtOutputIssues=collectMrtOutputIssues(io.mrtList,getDeclarationCoexistence);this.invalidMrtReturnLocations=collectInvalidEntryReturns(fragmentEntry.functions,io.mrtStructs,false);this.invalidVaryingReturnLocations=collectInvalidEntryReturns(vertexEntry.functions,io.varyingStructs,true);this.structMemberOwnerIssues=collectStructMemberOwnerIssues([].concat(vertexEntry.functions,fragmentEntry.functions),ir.shaderData.directMemberOwnerReferences,ir.shaderData.referenceResolutionSnapshots,io.structVariableRoles,getBranchCoverage)};function collectStructMemberOwnerIssues(entries,directMemberReferences,snapshots,variableRoles,getBranchCoverage){var _loop=function(){var reference=_step1.value;var _snapshotsByReference_get;if(!isReferenceReachable(reference,reachableFunctions))return\"continue\";var child=reference.children[0];var referenceSnapshots=(_snapshotsByReference_get=snapshotsByReference.get(reference))==null?void 0:_snapshotsByReference_get.filter(function(snapshot){return snapshot.replacementMemberOwner===undefined&&(_instanceof(child,BaseToken)||snapshot.isValueIdentity)});var resolutions=void 0;if(_instanceof(child,BaseToken)){var symbols=reference.resolvedValueSymbols();resolutions=(referenceSnapshots==null?void 0:referenceSnapshots.length)?referenceSnapshots:[{symbols:symbols,fallbackStart:symbols.length,callSiteBranch:reference._branch}]}else if(_instanceof(child,ASTNode.MacroCallSymbol)||_instanceof(child,ASTNode.MacroCallFunction)){resolutions=referenceSnapshots}if(resolutions==null?void 0:resolutions.length){var hasUnresolvedMacroOwner=!_instanceof(child,BaseToken)&&resolutions.some(function(resolution){return resolution.symbols.length===0});if(hasUnresolvedMacroOwner){recordOwnerIssue(issues,reference,\"unresolved-owner\",\"unknown\")}var member=_instanceof(child,BaseToken)||hasUnresolvedMacroOwner?undefined:findDirectMember(reference);if(member){recordOwnerIssue(issues,reference,\"incompatible-io-member\",classifyIOMemberAvailability(member,resolutions,variableRoles,getBranchCoverage))}recordOwnerIssue(issues,reference,\"mixed-owner-roles\",classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage))}};var visitedFunctions=new Set;var reachableFunctions=new Set;var pending=entries.slice();while(pending.length){var _pending;var fn=pending.pop();if(visitedFunctions.has(fn))continue;visitedFunctions.add(fn);reachableFunctions.add(fn.astNode);(_pending=pending).push.apply(_pending,[].concat(fn.calledFunctions))}var snapshotsByReference=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(snapshots),_step;!(_step=_iterator()).done;){var snapshot=_step.value;var referenceSnapshots=snapshotsByReference.get(snapshot.reference);if(!referenceSnapshots)snapshotsByReference.set(snapshot.reference,referenceSnapshots=[]);referenceSnapshots.push(snapshot)}var issues=new Map;for(var _iterator1=_create_for_of_iterator_helper_loose(directMemberReferences),_step1;!(_step1=_iterator1()).done;)_loop();var replacementOwnerGroups=new Map;for(var _iterator2=_create_for_of_iterator_helper_loose(snapshots),_step2;!(_step2=_iterator2()).done;){var snapshot1=_step2.value;var owner=snapshot1.replacementMemberOwner;if(owner===undefined||!isReferenceReachable(snapshot1.reference,reachableFunctions))continue;var ownerGroups=replacementOwnerGroups.get(snapshot1.reference);if(!ownerGroups)replacementOwnerGroups.set(snapshot1.reference,ownerGroups=new Map);var group=ownerGroups.get(owner);if(!group)ownerGroups.set(owner,group=[]);group.push(snapshot1)}for(var _iterator3=_create_for_of_iterator_helper_loose(replacementOwnerGroups),_step3;!(_step3=_iterator3()).done;){var _step_value=_step3.value,reference=_step_value[0],ownerGroups1=_step_value[1];for(var _iterator4=_create_for_of_iterator_helper_loose(ownerGroups1.values()),_step4;!(_step4=_iterator4()).done;){var resolutions=_step4.value;if(resolutions.some(function(resolution){return resolution.symbols.length===0})){recordOwnerIssue(issues,reference,\"unresolved-owner\",\"unknown\")}if(resolutions.some(function(resolution){return resolution.requiresRuntimeOwnerExpansion})){recordOwnerIssue(issues,reference,\"runtime-expanded-io-owner\",classifyRuntimeExpandedOwner(resolutions,variableRoles,getBranchCoverage))}recordOwnerIssue(issues,reference,\"mixed-owner-roles\",classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage))}}return Array.from(issues,function(param){var reference=param[0],issue=param[1];return _extends({location:reference.location},issue)})}function isReferenceReachable(reference,reachableFunctions){var current=reference.parent;while(current){if(_instanceof(current,ASTNode.FunctionDefinition))return reachableFunctions.has(current);current=current.parent}return false}function findDirectMember(reference){var current=reference.parent;while(current){if(_instanceof(current,ASTNode.PostfixExpression)&¤t.children.length===3){var base=current.children[0];var member=current.children[2];if(_instanceof(base,TreeNode)&&_instanceof(member,BaseToken)&&ParserUtils.unwrapBareIdentifier(base,{allowParens:true})===reference){return member}}current=current.parent}return undefined}function classifyIOMemberAvailability(member,resolutions,variableRoles,getBranchCoverage){var certainty;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primarySymbols=resolution.symbols.slice(0,resolution.fallbackStart);var primaryCoverage=getBranchCoverage(primarySymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);var retainedSymbols=primaryCoverage===\"covered\"?primarySymbols:resolution.symbols;for(var _iterator1=_create_for_of_iterator_helper_loose(retainedSymbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;var _symbol_dataType;if(!_instanceof(symbol,VarSymbol)||!variableRoles.has(symbol))continue;var _symbol_branchSignature;var ownerBranch=mergeBranchSignatures(resolution.callSiteBranch,(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH);var memberBranches=[];var _symbol_dataType_structDeclarations;for(var _iterator2=_create_for_of_iterator_helper_loose((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]),_step2;!(_step2=_iterator2()).done;){var struct=_step2.value;for(var _iterator3=_create_for_of_iterator_helper_loose(struct.propList),_step3;!(_step3=_iterator3()).done;){var prop=_step3.value;if(prop.ident.lexeme!==member.lexeme)continue;memberBranches.push(mergeBranchSignatures(ownerBranch,struct._branch,prop.ident.branch))}}var memberCoverage=getBranchCoverage(memberBranches,ownerBranch);if(!memberBranches.length||memberCoverage===\"uncovered\")return\"definite\";if(memberCoverage===\"unknown\")certainty=\"unknown\"}}return certainty}function mergeBranchSignatures(){for(var _len=arguments.length,branches=new Array(_len),_key=0;_key<_len;_key++){branches[_key]=arguments[_key]}var merged=[];for(var _iterator=_create_for_of_iterator_helper_loose(branches),_step;!(_step=_iterator()).done;){var branch=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(branch),_step1;!(_step1=_iterator1()).done;){var constraint=_step1.value;if(merged.indexOf(constraint)===-1)merged.push(constraint)}}return merged}function classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage){var resolutionKinds=[];var hasUnknownConflict=false;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primaryBranches=[];for(var i=0;i<resolution.fallbackStart;i++){var _resolution_symbols_i_branchSignature;primaryBranches.push((_resolution_symbols_i_branchSignature=resolution.symbols[i].branchSignature)!=null?_resolution_symbols_i_branchSignature:EMPTY_BRANCH)}var primaryCoverage=getBranchCoverage(primaryBranches,resolution.callSiteBranch);var primaryKinds=collectOwnerKinds(resolution.symbols,variableRoles,resolution.fallbackStart);var retainedKinds=primaryCoverage===\"covered\"?primaryKinds:collectOwnerKinds(resolution.symbols,variableRoles);if(retainedKinds.size>1){if(primaryKinds.size>1&&primaryCoverage===\"covered\"||primaryKinds.size<=1&&primaryCoverage===\"uncovered\"){return\"definite\"}hasUnknownConflict=true}for(var _iterator1=_create_for_of_iterator_helper_loose(retainedKinds),_step1;!(_step1=_iterator1()).done;){var kind=_step1.value;if(resolutionKinds.indexOf(kind)===-1)resolutionKinds.push(kind)}}if(hasUnknownConflict)return\"unknown\";if(resolutionKinds.length<=1)return undefined;var replacementCoverage=getBranchCoverage(resolutions.map(function(resolution){return resolution.callSiteBranch}),reference._branch);return replacementCoverage===\"covered\"?\"definite\":\"unknown\"}function classifyRuntimeExpandedOwner(resolutions,variableRoles,getBranchCoverage){var hasUnknownIOOwner=false;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primarySymbols=resolution.symbols.slice(0,resolution.fallbackStart);var primaryCoverage=getBranchCoverage(primarySymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);var retainedSymbols=primaryCoverage===\"covered\"?primarySymbols:resolution.symbols;if(!containsStructIORole(retainedSymbols,variableRoles))continue;var retainedCoverage=primaryCoverage===\"covered\"?primaryCoverage:getBranchCoverage(retainedSymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);if(retainedCoverage===\"covered\")return\"definite\";hasUnknownIOOwner=true}return hasUnknownIOOwner?\"unknown\":undefined}function containsStructIORole(symbols,variableRoles){return symbols.some(function(symbol){return _instanceof(symbol,VarSymbol)&&variableRoles.has(symbol)})}function collectOwnerKinds(symbols,variableRoles,end){if(end===void 0)end=symbols.length;var kinds=new Set;for(var i=0;i<end;i++){var symbol=symbols[i];var _variableRoles_get;if(_instanceof(symbol,VarSymbol))kinds.add((_variableRoles_get=variableRoles.get(symbol))!=null?_variableRoles_get:\"ordinary\")}return kinds}function recordOwnerIssue(issues,reference,kind,certainty){if(!certainty)return;var existing=issues.get(reference);if(!existing||existing.certainty===\"unknown\"&&certainty===\"definite\"){issues.set(reference,{kind:kind,certainty:certainty})}}function collectInvalidEntryReturns(functions,ioStructs,allowFunctionResult){var locations=[];for(var _iterator=_create_for_of_iterator_helper_loose(functions),_step;!(_step=_iterator()).done;){var fn=_step.value;var returnStructs=fn.astNode.protoType.returnType.typeSpecifier.structDeclarations;if(!returnStructs.some(function(struct){return ioStructs.includes(struct)}))continue;collectInvalidReturnsInNode(fn.astNode.statements,returnStructs,allowFunctionResult,locations)}return locations}function collectInvalidReturnsInNode(node,returnStructs,allowFunctionResult,out){if(_instanceof(node,ASTNode.JumpStatement)&&node.children.length===3){var expression=node.children[1];if(!_instanceof(expression,TreeNode)||!isEntryReturnExpression(expression,returnStructs,allowFunctionResult)){out.push(node.location)}return}for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,TreeNode))collectInvalidReturnsInNode(child,returnStructs,allowFunctionResult,out)}}function isEntryReturnExpression(expression,returnStructs,allowFunctionResult){var _generic_fnSymbol_dataType;var variable=ParserUtils.unwrapBareIdentifier(expression,{allowParens:true});var _variable_resolvedValueSymbols;var symbols=(_variable_resolvedValueSymbols=variable==null?void 0:variable.resolvedValueSymbols())!=null?_variable_resolvedValueSymbols:[];if(symbols.length>0&&symbols.every(function(symbol){var _symbol_dataType;return _instanceof(symbol,VarSymbol)&&((_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations.some(function(struct){return returnStructs.includes(struct)}))}))return true;if(!allowFunctionResult)return false;var call=ParserUtils.unwrapNodeByType(expression,NoneTerminal.function_call);var generic=call==null?void 0:call.children[0];return _instanceof(generic==null?void 0:generic.fnSymbol,FnSymbol)&&((_generic_fnSymbol_dataType=generic.fnSymbol.dataType)==null?void 0:_generic_fnSymbol_dataType.structDeclarations.some(function(struct){return returnStructs.includes(struct)}))===true}function collectMrtOutputIssues(props,getDeclarationCoexistence){var _loop=function(){var prop=_step.value;var _occupiedLocations_get;if(prop.typeInfo.type!==Keyword.VEC4){issues.push({prop:prop,kind:\"invalid-type\"})}var location=prop.mrtIndex;if(location===undefined){issues.push({prop:prop,kind:\"missing-location\"})}else if(!Number.isInteger(location)||location<0){issues.push({prop:prop,kind:\"invalid-location\"})}else if((_occupiedLocations_get=occupiedLocations.get(location))==null?void 0:_occupiedLocations_get.some(function(existing){return getDeclarationCoexistence(existing.ident.branch,prop.ident.branch)===\"coexist\"})){issues.push({prop:prop,kind:\"duplicate-location\"})}else{var _occupiedLocations_get1;var occupants=(_occupiedLocations_get1=occupiedLocations.get(location))!=null?_occupiedLocations_get1:[];occupants.push(prop);occupiedLocations.set(location,occupants)}};var issues=[];var occupiedLocations=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(props),_step;!(_step=_iterator()).done;)_loop();return issues}export{GSError as $,ASTNode as A,BaseToken as B,ShaderData as C,StructSymbol as D,EMPTY_BRANCH as E,FnSymbol as F,Grammar as G,SymbolDataType as H,ESymbolType as I,SymbolInfo as J,Keyword as K,Lexer as L,ShaderClueIR as M,NoneTerminal as N,ShaderStructRole as O,ShaderCoreInfo as P,ShaderBuiltinSemantic as Q,createShaderDeclarationOwnership as R,ShaderTargetParser as S,TypeAny as T,isDeferredDeclarationPair as U,VarSymbol as V,ShaderSourceParser as W,ShaderSourceFactory as X,Preprocessor as Y,ParserObjectPool as Z,ParserUtils as _,EOF as a,GSErrorName as a0,ShaderCompilerUtils as a1,GLESShaderInfo as a2,_instanceof as a3,canBranchesOverlap as a4,getBranchCoverage as a5,_create_for_of_iterator_helper_loose as a6,BuiltinVariable as a7,BuiltinFunction as a8,_inherits as a9,__generator as aa,_extends as ab,isConditionalChainExhaustive as ac,isBranchReachable as ad,TypeSystem as ae,branchAnalysis as af,normalizeShaderSourceFile as ag,parseShaderPassWith as ah,shaderSourceBaseURL as ai,areConditionsComplementary as aj,isBranchVisibleFrom as ak,canDeclarationsCoexist as al,getDeclarationCoexistence as am,getBranchReachability as an,canBranchesCoverCallsite as ao,mapExpandedShaderRange as ap,createParsedShaderPass as aq,GenericType as ar,BuiltinVariableTable as as,ParserSemanticValidation as at,formatDiagnosticSource as au,getParsedShaderPassPayload as b,canInheritanceBranchesCover as c,ShaderRange as d,ShaderPosition as e,ETokenType as f,getLexicalDeclarationCoexistence as g,BaseLexer as h,parsePreprocessorCondition as i,toPreprocessorCondition as j,SymbolTable as k,SymbolTableStack as l,mapExpandedShaderError as m,normalizeShaderIncludeMap as n,EShaderStage as o,proveInheritanceBranchesCover as p,LALR1 as q,addTranslationRule as r,sameBranch as s,tryParsePreprocessorCondition as t,createGrammar as u,createRuntimeShaderTargetParser as v,parseRuntimeShaderPass as w,TreeNode as x,SymbolType as y,StructProp as z};\n//# sourceMappingURL=GLESShaderInfo.module.js.map\n","function _type_of(obj) {\n \"@swc/helpers - typeof\";\n\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nexport { _type_of as _ };\n","function _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {\n o.__proto__ = p;\n\n return o;\n };\n\n return _set_prototype_of(o, p);\n}\nexport { _set_prototype_of as _ };\n","import { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });\n\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nexport { _inherits as _ };\n","function _is_native_reflect_construct() {\n // Since Reflect.construct can't be properly polyfilled, some\n // implementations (e.g. core-js@2) don't set the correct internal slots.\n // Those polyfills don't allow us to subclass built-ins, so we need to\n // use our fallback implementation.\n try {\n // If the internal slots aren't set, this throws an error similar to\n // TypeError: this is not a Boolean object.\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));\n } catch (_) {}\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\n\nexport { _is_native_reflect_construct as _ };\n","import { _ as _is_native_reflect_construct } from \"./_is_native_reflect_construct.js\";\nimport { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) _construct = Reflect.construct;\n else {\n _construct = function construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n\n if (Class) _set_prototype_of(instance, Class.prototype);\n\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\nexport { _construct as _ };\n","function _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n\n return _get_prototype_of(o);\n}\nexport { _get_prototype_of as _ };\n","import { _ as _construct } from \"./_construct.js\";\nimport { _ as _get_prototype_of } from \"./_get_prototype_of.js\";\nimport { _ as _is_native_function } from \"./_is_native_function.js\";\nimport { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\n\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n _wrap_native_super = function(Class) {\n if (Class === null || !_is_native_function(Class)) return Class;\n if (typeof Class !== \"function\") throw new TypeError(\"Super expression must either be null or a function\");\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Class);\n _cache.set(Class, Wrapper);\n }\n\n function Wrapper() {\n return _construct(Class, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });\n\n return _set_prototype_of(Wrapper, Class);\n };\n\n return _wrap_native_super(Class);\n}\nexport { _wrap_native_super as _ };\n","function _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nexport { _is_native_function as _ };\n","function _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\nexport { _array_like_to_array as _ };\n","import { _ as _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _create_for_of_iterator_helper_loose as _ };\n","import { _ as _array_like_to_array } from \"./_array_like_to_array.js\";\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\nexport { _unsupported_iterable_to_array as _ };\n","import { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { SymbolTable } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType, SymbolInfo, VarSymbol } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole, StructProp } from \"@galacean/engine-shader-parser/internal\";\n\n/** @internal */\nexport class VisitorContext {\n private readonly _lookupSymbol = new SymbolInfo(\"\", null);\n private readonly _structRoles = new Map<ASTNode.StructSpecifier, ShaderStructRole>();\n private readonly _vertexUnresolvedVariableRoles = new Map<string, ShaderStructRole>();\n private readonly _fragmentUnresolvedVariableRoles = new Map<string, ShaderStructRole>();\n private readonly _vertexAmbiguousVariableNames = new Set<string>();\n private readonly _fragmentAmbiguousVariableNames = new Set<string>();\n\n attributeStructs: ASTNode.StructSpecifier[] = [];\n attributeList: StructProp[] = [];\n varyingStructs: ASTNode.StructSpecifier[] = [];\n varyingList: StructProp[] = [];\n mrtStructs: ASTNode.StructSpecifier[] = [];\n mrtList: StructProp[] = [];\n\n stage: EShaderStage;\n stageEntry: string;\n\n _referencedAttributeList: Record<string, StructProp[]>;\n _referencedVaryingList: Record<string, StructProp[]>;\n _referencedMRTList: Record<string, StructProp[]>;\n _referencedGlobals: Record<string, SymbolInfo[]>;\n readonly _referencedGlobalSymbols = new Set<SymbolInfo>();\n private _globalSymbolQueries: Record<string, Partial<Record<ESymbolType, SymbolInfo[]>>>;\n _referencedGlobalMacroASTs: TreeNode[] = [];\n private readonly _structVariableRoles = new Map<VarSymbol, ShaderStructRole>();\n\n _passSymbolTable?: SymbolTable<SymbolInfo>;\n /** Receives every global use, including uses of declarations already discovered. */\n onReferenceGlobal?: (symbols: readonly SymbolInfo[]) => void;\n /** Receives interface uses so generated fields retain their declaration dependencies. */\n onReferenceStructProps?: (props: readonly StructProp[]) => void;\n readonly codeCache = new Map<TreeNode, string>();\n private readonly fragmentReturnModes = new Map<ASTNode.JumpStatement, FragmentReturnMode>();\n private readonly terminalInterfaceReturns = new Set<ASTNode.JumpStatement>();\n\n constructor() {\n this.reset();\n }\n\n reset(resetAll = true) {\n this.codeCache.clear();\n this.fragmentReturnModes.clear();\n this.terminalInterfaceReturns.clear();\n if (resetAll) {\n this.attributeStructs.length = 0;\n this.attributeList.length = 0;\n this.varyingStructs.length = 0;\n this.varyingList.length = 0;\n this.mrtStructs.length = 0;\n this.mrtList.length = 0;\n this._structRoles.clear();\n this._vertexUnresolvedVariableRoles.clear();\n this._fragmentUnresolvedVariableRoles.clear();\n this._vertexAmbiguousVariableNames.clear();\n this._fragmentAmbiguousVariableNames.clear();\n }\n\n this._referencedAttributeList = Object.create(null);\n this._referencedVaryingList = Object.create(null);\n this._referencedMRTList = Object.create(null);\n this._referencedGlobals = Object.create(null);\n this._referencedGlobalSymbols.clear();\n this._globalSymbolQueries = Object.create(null);\n this._referencedGlobalMacroASTs.length = 0;\n if (resetAll) {\n this._structVariableRoles.clear();\n this._passSymbolTable = undefined;\n }\n }\n\n /**\n * Finds the shared interface role of custom-struct declaration candidates.\n * @param declarations - Exact parser struct identities resolved at one type occurrence.\n * @returns Interface role, or `undefined` when the type is not an unambiguous interface struct.\n */\n getStructRole(declarations: readonly ASTNode.StructSpecifier[]): ShaderStructRole | undefined {\n let resolvedRole: ShaderStructRole | undefined;\n for (const declaration of declarations) {\n const role = this._structRoles.get(declaration);\n if (!role || (resolvedRole && resolvedRole !== role)) return;\n resolvedRole = role;\n }\n return resolvedRole;\n }\n\n /**\n * Tests the exact interface role of one struct declaration.\n * @param declaration - Parser struct identity.\n * @param role - Expected interface role.\n * @returns Whether the declaration owns that role.\n */\n hasStructRole(declaration: ASTNode.StructSpecifier, role: ShaderStructRole): boolean {\n return this._structRoles.get(declaration) === role;\n }\n\n /**\n * Registers stage-interface struct types for constant-time role lookup.\n * @param role - Interface role shared by the supplied structs.\n * @param structs - Struct declarations derived from parser IR.\n * @internal\n */\n registerStructTypes(role: ShaderStructRole, structs: readonly ASTNode.StructSpecifier[]): void {\n for (const struct of structs) {\n this._structRoles.set(struct, role);\n }\n }\n\n /**\n * Registers a resolved variable that holds an interface struct.\n * @param variable - Parser symbol identity for the declaration.\n * @param role - Struct interface role.\n * @param stage - Optional stage from whose entry the variable is reachable. Omit when only exact\n * symbol lookup is required.\n */\n registerStructVar(variable: VarSymbol, role: ShaderStructRole, stage?: EShaderStage): void {\n this._structVariableRoles.set(variable, role);\n if (stage === undefined) return;\n const roles =\n stage === EShaderStage.VERTEX ? this._vertexUnresolvedVariableRoles : this._fragmentUnresolvedVariableRoles;\n const ambiguous =\n stage === EShaderStage.VERTEX ? this._vertexAmbiguousVariableNames : this._fragmentAmbiguousVariableNames;\n const name = variable.ident;\n if (ambiguous.has(name)) return;\n const existing = roles.get(name);\n if (existing && existing !== role) {\n roles.delete(name);\n ambiguous.add(name);\n } else {\n roles.set(name, role);\n }\n }\n\n /**\n * Finds an interface role for a global macro value that has no lexical symbol identity.\n * @param variableName - Bare variable name in the macro replacement AST.\n * @returns A role only when every stage-reachable declaration with that name agrees.\n */\n getUnresolvedStructVarRole(variableName: string): ShaderStructRole | undefined {\n const roles =\n this.stage === EShaderStage.VERTEX ? this._vertexUnresolvedVariableRoles : this._fragmentUnresolvedVariableRoles;\n const ambiguous =\n this.stage === EShaderStage.VERTEX ? this._vertexAmbiguousVariableNames : this._fragmentAmbiguousVariableNames;\n return ambiguous.has(variableName) ? undefined : roles.get(variableName);\n }\n\n /**\n * Finds the shared interface role of branch-visible variable candidates.\n * @param symbols - Exact parser symbols resolved at one reference.\n * @returns Interface role, or `undefined` when the reference is not an unambiguous interface value.\n */\n getStructVarRole(symbols: readonly SymbolInfo[]): ShaderStructRole | undefined {\n let resolvedRole: ShaderStructRole | undefined;\n for (const symbol of symbols) {\n if (!(symbol instanceof VarSymbol)) return;\n const role = this._structVariableRoles.get(symbol);\n if (!role || (resolvedRole && resolvedRole !== role)) return;\n resolvedRole = role;\n }\n return resolvedRole;\n }\n\n /**\n * Marks a value-return belonging to a fragment entry for backend lowering.\n * @param statement - Exact return statement identity.\n * @param mode - Fragment output contract of the containing entry declaration.\n */\n registerFragmentReturn(statement: ASTNode.JumpStatement, mode: FragmentReturnMode): void {\n this.fragmentReturnModes.set(statement, mode);\n }\n\n /**\n * Finds the output contract for a fragment-entry return statement.\n * @param statement - Return statement identity.\n * @returns Output mode, or `undefined` for ordinary helper/vertex returns.\n */\n getFragmentReturnMode(statement: ASTNode.JumpStatement): FragmentReturnMode | undefined {\n return this.fragmentReturnModes.get(statement);\n }\n\n /** Marks a syntactically final interface return whose control-flow exit can be omitted. */\n registerTerminalInterfaceReturn(statement: ASTNode.JumpStatement): void {\n this.terminalInterfaceReturns.add(statement);\n }\n\n /**\n * Tests whether an interface return is the final syntactic statement in its function.\n * @param statement - Return statement identity.\n * @returns Whether backend lowering may omit a trailing `return;`.\n */\n isTerminalInterfaceReturn(statement: ASTNode.JumpStatement): boolean {\n return this.terminalInterfaceReturns.has(statement);\n }\n\n referenceAttribute(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.attributeList, this._referencedAttributeList);\n }\n\n referenceVarying(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.varyingList, this._referencedVaryingList);\n }\n\n referenceMRTProp(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.mrtList, this._referencedMRTList);\n }\n\n referenceGlobal(ident: string, type: ESymbolType): void {\n const queries = (this._globalSymbolQueries[ident] ??= Object.create(null));\n let symbols = queries[type];\n if (!symbols) {\n this._lookupSymbol.set(ident, type);\n symbols = queries[type] = this._passSymbolTable!.getSymbols(this._lookupSymbol, true, []);\n const namedSymbols = (this._referencedGlobals[ident] ??= []);\n for (const symbol of symbols) {\n if (!this._referencedGlobalSymbols.has(symbol)) {\n this._referencedGlobalSymbols.add(symbol);\n namedSymbols.push(symbol);\n }\n }\n }\n // Repeated uses still establish edges from each declaration's owner.\n this.onReferenceGlobal?.(symbols);\n }\n\n // Track which IO props are actually referenced (drives in/out emission). A missing member is no\n // longer flagged here — that's the parser's struct-field check (UndeclaredStructMember).\n private _referenceProp(name: string, list: StructProp[], refList: Record<string, StructProp[]>): void {\n if (!refList[name]) refList[name] = list.filter((item) => item.ident.lexeme === name);\n this.onReferenceStructProps?.(refList[name]);\n }\n}\n\n/** @internal */\nexport type FragmentReturnMode = \"color\" | \"mrt\";\n","import type { IPoolElement } from \"@galacean/engine-core\";\n\nexport class TempArray<T> implements IPoolElement {\n array: Array<T> = new Array();\n\n dispose(): void {\n this.array.length = 0;\n }\n}\n","import { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { NoneTerminal } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType, FnSymbol } from \"@galacean/engine-shader-parser/internal\";\nimport { NodeChild, StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport type { BranchSignature, ICodeGenVisitor } from \"@galacean/engine-shader-parser/internal\";\nimport { VisitorContext } from \"./VisitorContext\";\nimport { ReturnableObjectPool } from \"@galacean/engine-core\";\nimport { Keyword } from \"@galacean/engine-shader-parser/internal\";\nimport { TempArray } from \"../TempArray\";\nimport { ICodeSegment } from \"./types\";\n\n/**\n * @internal\n * The code generator\n */\nexport abstract class CodeGenVisitor implements ICodeGenVisitor {\n abstract getAttributeProp(prop: StructProp): string;\n abstract getVaryingProp(prop: StructProp): string;\n abstract getMRTProp(prop: StructProp): string | null;\n\n protected static _tmpArrayPool = new ReturnableObjectPool(TempArray<string>, 10);\n protected readonly context = new VisitorContext();\n\n cache(node: TreeNode, code: string): string {\n this.context.codeCache.set(node, code);\n return code;\n }\n\n getCachedCode(node: TreeNode): string | undefined {\n return this.context.codeCache.get(node);\n }\n\n defaultCodeGen(children: NodeChild[]) {\n const pool = CodeGenVisitor._tmpArrayPool;\n const ret = pool.get();\n ret.dispose();\n for (const child of children) {\n if (child instanceof BaseToken) {\n // Legacy opaque `#define` lexemes carry the directive verbatim; expression-style defines use the AST path\n ret.array.push(child.lexeme);\n } else {\n ret.array.push(child.codeGen(this));\n }\n }\n const result = ret.array.join(\" \");\n ret.dispose();\n pool.return(ret);\n return result;\n }\n\n visitPostfixExpression(node: ASTNode.PostfixExpression): string {\n const children = node.children;\n const derivationLength = children.length;\n const context = this.context;\n\n if (derivationLength === 3) {\n const postExpr = children[0] as ASTNode.PostfixExpression;\n const prop = children[2];\n\n if (prop instanceof BaseToken) {\n // Direct variables use parser symbol identity so lexical shadowing cannot inherit an IO role\n // from a same-named declaration. Macro-expanded identifiers can lack a resolved symbol, so\n // only that zero-symbol path consults the current stage's unambiguous name-to-role map.\n let role: ShaderStructRole | undefined;\n const directRoot = ParserUtils.unwrapBareIdentifier(postExpr, { allowParens: true });\n if (directRoot) {\n const symbols = directRoot.resolvedValueSymbols();\n const unresolvedName = ParserUtils.extractDirectIdentLexeme(postExpr);\n role = symbols.length\n ? context.getStructVarRole(symbols)\n : unresolvedName\n ? context.getUnresolvedStructVarRole(unresolvedName)\n : undefined;\n }\n\n if (role) {\n if (role === ShaderStructRole.Attribute) context.referenceAttribute(prop);\n else if (role === ShaderStructRole.Varying) context.referenceVarying(prop);\n else context.referenceMRTProp(prop);\n return prop.lexeme;\n }\n\n return `${postExpr.codeGen(this)}.${prop.lexeme}`;\n } else {\n return `${postExpr.codeGen(this)}.${prop.codeGen(this)}`;\n }\n } else if (derivationLength === 4) {\n const identNode = children[0] as ASTNode.PostfixExpression;\n const indexNode = children[2] as ASTNode.Expression;\n return `${identNode.codeGen(this)}[${indexNode.codeGen(this)}]`;\n }\n\n return this.defaultCodeGen(node.children);\n }\n\n visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n for (const name of node.referenceGlobalSymbolNames) {\n this.context.referenceGlobal(name, ESymbolType.Any);\n }\n for (const symbol of node.resolvedSymbols()) {\n if (symbol instanceof FnSymbol) this.referenceFunction(symbol, node.location.start.index, node._branch);\n }\n\n return node.getLexeme(this);\n }\n\n protected referenceFunction(symbol: FnSymbol, referenceIndex: number, branch: BranchSignature): void {\n void referenceIndex;\n void branch;\n this.context.referenceGlobal(symbol.ident, ESymbolType.FN);\n }\n\n visitFunctionCall(node: ASTNode.FunctionCall): string {\n const call = node.children[0] as ASTNode.FunctionCallGeneric;\n if (call.fnSymbol instanceof FnSymbol) {\n for (const symbol of call.fnSymbols?.length ? call.fnSymbols : [call.fnSymbol]) {\n this.referenceFunction(symbol, node.location.start.index, node._branch);\n }\n\n const paramList = call.children[2];\n if (paramList instanceof ASTNode.FunctionCallParameterList) {\n const astNodes = paramList.paramNodes;\n const finalSymbol = this.context._referencedGlobals[call.fnSymbol.ident].find(\n (candidate) => candidate instanceof FnSymbol && candidate.equal(call.fnSymbol!)\n ) as FnSymbol | undefined;\n const paramInfoList = (finalSymbol ?? call.fnSymbol).astNode.protoType.parameterList;\n\n const context = this.context;\n const params = astNodes.filter((_, i) => {\n const parameter = paramInfoList?.[i]?.astNode;\n // Drop struct-IO parameters (attribute/varying/mrt) — they're flattened\n // into top-level declarations and no longer exist as function-call args.\n return (\n !(parameter instanceof ASTNode.ParameterDeclaration) ||\n !parameter.symbol ||\n !context.getStructVarRole([parameter.symbol])\n );\n });\n\n let paramsCode = \"\";\n\n for (let i = 0, length = params.length; i < length; i++) {\n const astNode = params[i];\n const code = astNode.codeGen(this);\n if (astNode instanceof ASTNode.MacroCallArgBlock || i === 0) {\n paramsCode += code;\n } else {\n paramsCode += `, ${code}`;\n }\n }\n\n return `${call.fnSymbol.ident}(${paramsCode})`;\n }\n }\n\n return this.defaultCodeGen(node.children);\n }\n\n visitMacroCallFunction(node: ASTNode.MacroCallFunction): string {\n const children = node.children;\n const paramList = children[2];\n if (paramList instanceof ASTNode.FunctionCallParameterList) {\n const astNodes = paramList.paramNodes;\n const context = this.context;\n\n // Drop bare IO-struct args only when the macro aliases a user fn (whose\n // formal was flattened). All other shapes preserve args verbatim.\n let params: typeof astNodes;\n if (node.isFunctionLikeMacro || !node.aliasesNonBuiltinIdent) {\n params = astNodes;\n } else {\n params = astNodes.filter((arg) => {\n if (arg instanceof ASTNode.AssignmentExpression) {\n const variableParam = ParserUtils.unwrapBareIdentifier(arg, { allowParens: false });\n if (variableParam && context.getStructVarRole(variableParam.resolvedValueSymbols())) {\n return false;\n }\n }\n return true;\n });\n }\n\n let paramsCode = \"\";\n for (let i = 0, length = params.length; i < length; i++) {\n const argNode = params[i];\n const code = argNode.codeGen(this);\n\n if (argNode instanceof ASTNode.MacroCallArgBlock || i === 0) {\n paramsCode += code;\n } else {\n paramsCode += `, ${code}`;\n }\n }\n\n return `${node.macroName}(${paramsCode})`;\n } else {\n return this.defaultCodeGen(node.children);\n }\n }\n\n visitStatementList(node: ASTNode.StatementList): string {\n const children = node.children as TreeNode[];\n if (children.length === 1) {\n return children[0].codeGen(this);\n } else {\n return `${children[0].codeGen(this)}\\n${children[1].codeGen(this)}`;\n }\n }\n\n /**\n * Code-generate a `#define` macro parsed as expression AST. Produces a `#define`\n * directive whose value is the AST-rewritten string — so varying flattening\n * happens naturally via `visitPostfixExpression` inside the AST walk.\n */\n visitMacroDefine(node: ASTNode.MacroDefine): string {\n // For function-like macros, preserve the original `(params)` lexeme verbatim —\n // the parameter list is user-authored text that shouldn't be canonicalized.\n let paramsLexeme = \"\";\n if (node.isFunction) {\n const paramsToken = node.children[2];\n if (paramsToken instanceof BaseToken) paramsLexeme = paramsToken.lexeme;\n }\n const valueCode = node.valueExpression ? node.valueExpression.codeGen(this) : \"\";\n // Newlines around the directive keep `#` at the start of its physical line per\n // GLSL ES 3.0 §3.4, regardless of how surrounding tokens are joined.\n return `\\n#define ${node.macroName}${paramsLexeme}${valueCode ? \" \" + valueCode : \"\"}\\n`;\n }\n\n visitSingleDeclaration(node: ASTNode.SingleDeclaration): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitGlobalVariableDeclaration(node: ASTNode.VariableDeclaration): string {\n const children = node.children;\n const fullType = children[0];\n if (fullType instanceof ASTNode.FullySpecifiedType && fullType.typeSpecifier.isCustom) {\n const context = this.context;\n // Global interface variables are flattened and therefore are not emitted as uniforms.\n if (context.getStructVarRole([node.declarator.symbol])) {\n return \"\";\n }\n context.referenceGlobal(<string>fullType.type, ESymbolType.STRUCT);\n }\n return `uniform ${this.defaultCodeGen(children)}`;\n }\n\n visitDeclaration(node: ASTNode.Declaration): string {\n const context = this.context;\n const children = node.children;\n const child = children[0];\n\n if (child instanceof ASTNode.InitDeclaratorList) {\n const first = child.children[0];\n const declarator =\n child.declarator ?? (first instanceof ASTNode.SingleDeclaration ? first.declarator : undefined);\n const role = declarator && context.getStructVarRole([declarator.symbol]);\n if (role === ShaderStructRole.Varying || role === ShaderStructRole.Mrt) return \"\";\n }\n return this.defaultCodeGen(children);\n }\n\n visitFunctionParameterList(node: ASTNode.FunctionParameterList): string {\n const context = this.context;\n const params = node.parameterInfoList.filter((item) => {\n const parameter = item.astNode;\n return (\n !(parameter instanceof ASTNode.ParameterDeclaration) ||\n !parameter.symbol ||\n !context.getStructVarRole([parameter.symbol])\n );\n });\n\n let out = \"\";\n for (let i = 0, length = params.length; i < length; i++) {\n const item = params[i];\n const astNode = item.astNode!;\n const code = astNode.codeGen(this);\n if (astNode instanceof ASTNode.MacroParamBlock || i === 0) {\n out += code;\n } else {\n out += `, ${code}`;\n }\n }\n\n return out;\n }\n\n visitFunctionHeader(node: ASTNode.FunctionHeader): string {\n const returnType = node.returnType.typeSpecifier;\n if (this.context.getStructRole(returnType.structDeclarations) === ShaderStructRole.Varying) {\n return `void ${node.ident.lexeme}(`;\n }\n return this.defaultCodeGen(node.children);\n }\n\n visitJumpStatement(node: ASTNode.JumpStatement): string {\n const children = node.children;\n const cmd = children[0] as BaseToken;\n if (cmd.type === Keyword.RETURN) {\n const expr = children[1];\n if (expr instanceof ASTNode.Expression) {\n const returnVar = ParserUtils.unwrapNodeByType<ASTNode.VariableIdentifier>(\n expr,\n NoneTerminal.variable_identifier\n );\n if (returnVar && this.context.getStructVarRole(returnVar.resolvedValueSymbols()) === ShaderStructRole.Varying) {\n return this.context.isTerminalInterfaceReturn(node) ? \"\" : \"return;\";\n }\n const returnFnCall = ParserUtils.unwrapNodeByType<ASTNode.FunctionCall>(expr, NoneTerminal.function_call);\n const calledFunction = returnFnCall?.children[0] as ASTNode.FunctionCallGeneric | undefined;\n const returnDeclarations =\n calledFunction?.fnSymbol instanceof FnSymbol\n ? calledFunction.fnSymbol.astNode.protoType.returnType.typeSpecifier.structDeclarations\n : [];\n if (this.context.getStructRole(returnDeclarations) === ShaderStructRole.Varying) {\n const call = `${expr.codeGen(this)};`;\n return this.context.isTerminalInterfaceReturn(node) ? call : `{ ${call} return; }`;\n }\n }\n }\n return this.defaultCodeGen(children);\n }\n\n visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitTypeSpecifier(node: ASTNode.TypeSpecifier): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitStructSpecifier(node: ASTNode.StructSpecifier): string {\n const context = this.context;\n const { varyingStructs, attributeStructs, mrtStructs } = context;\n const isVaryingStruct = varyingStructs.indexOf(node) !== -1;\n const isAttributeStruct = attributeStructs.indexOf(node) !== -1;\n const isMRTStruct = mrtStructs.indexOf(node) !== -1;\n\n if (isVaryingStruct || isAttributeStruct || isMRTStruct) {\n const result: ICodeSegment[] = [];\n\n result.push(\n ...node.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }))\n );\n\n for (const prop of node.propList) {\n const name = prop.ident.lexeme;\n if (isVaryingStruct && context._referencedVaryingList[name]?.indexOf(prop) >= 0) {\n result.push({\n text: `${this.getVaryingProp(prop)}\\n`,\n index: prop.ident.location.start.index\n });\n } else if (isAttributeStruct && context._referencedAttributeList[name]?.indexOf(prop) >= 0) {\n result.push({\n text: `${this.getAttributeProp(prop)}\\n`,\n index: prop.ident.location.start.index\n });\n } else if (isMRTStruct && context._referencedMRTList[name]?.indexOf(prop) >= 0) {\n result.push({\n text: `${this.getMRTProp(prop)}\\n`,\n index: prop.ident.location.start.index\n });\n }\n }\n\n const text = result\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\");\n\n return text;\n } else {\n return this.defaultCodeGen(node.children);\n }\n }\n\n visitFunctionDefinition(fnNode: ASTNode.FunctionDefinition): string {\n const fnName = fnNode.protoType.ident.lexeme;\n const context = this.context;\n const terminal = ParserUtils.lastStatement(fnNode.statements);\n if (terminal instanceof ASTNode.JumpStatement) context.registerTerminalInterfaceReturn(terminal);\n\n if (fnName == context.stageEntry) {\n const statements = fnNode.statements.codeGen(this);\n return `void main() ${statements}`;\n } else {\n return this.defaultCodeGen(fnNode.children);\n }\n }\n}\n","import type { Condition, PreprocessorExpressionParseResult, ShaderInstruction } from \"@galacean/engine-design\";\nimport { ShaderPreprocessorDirective } from \"@galacean/engine-core\";\nimport { parsePreprocessorExpression, toPreprocessorCondition } from \"@galacean/engine-shader-parser/internal\";\nimport type { DeferredDeclarationOwnership } from \"@galacean/engine-shader-parser/internal\";\n\nexport type { ShaderInstruction } from \"@galacean/engine-design\";\n\n/**\n * @internal\n */\nexport class ShaderInstructionEncoder {\n private static _DIRECTIVE_RE = /^[ \\t]*#[ \\t]*(if|ifdef|ifndef|elif|else|endif|define|undef)\\b(.*)/;\n private static _FUNC_MACRO_RE = /^(\\w+)\\(([^)]*)\\)\\s*(.*)/;\n\n /**\n * Marks compiler-owned text without placing parser objects in the instruction stream.\n * @param text - Declaration or derived declaration text.\n * @param owner - Neutral declaration identity, if runtime selection is required.\n * @param activate - Whether this is the declaration's original source position.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static declaration(text: string, owner?: DeferredDeclarationOwnership, activate = true): string {\n if (!owner) return text;\n const activation = activate ? `\\0D${owner.id},${owner.group},${owner.sourceScope}\\0\\n` : \"\";\n return text ? `${activation}\\0T${owner.id}\\0\\n${text}\\n\\0E\\0\\n` : activation;\n }\n\n /**\n * Marks derived text shared by any selected, reachable declaration without activating an owner.\n * @param text - Shared derived declaration text.\n * @param owners - Declarations that require the text; an empty list never retains it.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static sharedDeclaration(text: string, owners: readonly DeferredDeclarationOwnership[]): string {\n return text ? `\\0T${owners.map((owner) => owner.id).join(\",\")}\\0\\n${text}\\n\\0E\\0\\n` : \"\";\n }\n\n /**\n * Records a declaration dependency for variant-time reachability after ownership selection.\n * @param from - Referencing declaration identity, or zero for a stage root.\n * @param to - Referenced declaration identity.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static reference(from: number, to: number): string {\n return `\\0R${from},${to}\\0\\n`;\n }\n\n /**\n * Removes private emission markers from the public source view after instruction encoding.\n * @param source - Encoded intermediate stage source.\n * @returns GLSL source without compiler metadata.\n * @internal\n */\n static source(source: string): string {\n return source.indexOf(\"\\0\") < 0 ? source : source.replace(/\\0[^\\0]*\\0\\n?/g, \"\");\n }\n\n /**\n * Encodes generated GLSL directives into runtime-selectable instructions.\n * @param glsl - Generated stage source.\n * @param preprocessorExpressions - Parser-owned expression trees keyed by logical directive text.\n * @returns Runtime shader instruction stream.\n * @throws Error when a conditional directive is malformed or has a deterministic evaluation failure.\n * @internal\n */\n static parse(\n glsl: string,\n preprocessorExpressions?: ReadonlyMap<string, PreprocessorExpressionParseResult>\n ): ShaderInstruction[] {\n const instructions: ShaderInstruction[] = [];\n const length = glsl.length;\n let pos = 0;\n let owners: number[] | undefined;\n const backfillStack: number[][] = [];\n\n while (pos < length) {\n const directiveStart = ShaderInstructionEncoder._findDirectiveStart(glsl, pos, length);\n\n if (directiveStart === -1) {\n ShaderInstructionEncoder._pushText(instructions, glsl, pos, length, owners);\n break;\n }\n\n if (directiveStart > pos) {\n ShaderInstructionEncoder._pushText(instructions, glsl, pos, directiveStart, owners);\n }\n\n const lineEnd = ShaderInstructionEncoder._findLogicalLineEnd(glsl, directiveStart, length);\n const line = glsl.substring(directiveStart, lineEnd).replace(/\\\\(?:\\r\\n|\\n|\\r)/g, \"\");\n pos = lineEnd < length ? lineEnd + 1 : length;\n\n if (line.charCodeAt(0) === 0) {\n const kind = line.charAt(1);\n if (kind === \"D\") {\n const fields = line.slice(2, -1).split(\",\").map(Number);\n instructions.push([ShaderPreprocessorDirective.Declaration, fields[0], fields[1], fields[2]]);\n } else if (kind === \"R\") {\n const fields = line.slice(2, -1).split(\",\").map(Number);\n instructions.push([ShaderPreprocessorDirective.Reference, fields[0], fields[1]]);\n } else {\n const ids = line.slice(2, -1);\n owners = kind === \"T\" ? (ids ? ids.split(\",\").map(Number) : []) : undefined;\n }\n continue;\n }\n\n const match = ShaderInstructionEncoder._DIRECTIVE_RE.exec(line);\n if (!match) {\n const text = lineEnd < length ? line + \"\\n\" : line;\n ShaderInstructionEncoder._pushText(instructions, text, 0, text.length, owners);\n continue;\n }\n\n const keyword = match[1];\n const rest = match[2].trim();\n\n switch (keyword) {\n case \"ifdef\": {\n const idx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.IfDef, rest, -1]);\n backfillStack.push([idx]);\n break;\n }\n case \"ifndef\": {\n const idx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.IfNdef, rest, -1]);\n backfillStack.push([idx]);\n break;\n }\n case \"if\": {\n const cond = ShaderInstructionEncoder._parseCondition(rest, preprocessorExpressions);\n const idx = instructions.length;\n ShaderInstructionEncoder._pushConditionInstruction(instructions, cond);\n backfillStack.push([idx]);\n break;\n }\n case \"elif\": {\n const stack = backfillStack[backfillStack.length - 1];\n const prevIdx = stack[stack.length - 1];\n const elseIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Else, -1]);\n stack.push(elseIdx);\n ShaderInstructionEncoder._backfillJump(instructions[prevIdx], instructions.length);\n\n const cond = ShaderInstructionEncoder._parseCondition(rest, preprocessorExpressions);\n const idx = instructions.length;\n ShaderInstructionEncoder._pushConditionInstruction(instructions, cond);\n stack.push(idx);\n break;\n }\n case \"else\": {\n const stack = backfillStack[backfillStack.length - 1];\n const prevIdx = stack[stack.length - 1];\n const elseIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Else, -1]);\n stack.push(elseIdx);\n ShaderInstructionEncoder._backfillJump(instructions[prevIdx], instructions.length);\n break;\n }\n case \"endif\": {\n const endifIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Endif]);\n const stack = backfillStack.pop();\n if (stack) {\n const afterEndif = endifIdx + 1;\n for (let j = 0; j < stack.length; j++) {\n const inst = instructions[stack[j]];\n if (inst[0] === ShaderPreprocessorDirective.Else) {\n (inst as [number, number])[1] = afterEndif;\n } else {\n ShaderInstructionEncoder._backfillJump(inst, afterEndif, true);\n }\n }\n }\n break;\n }\n case \"define\": {\n const funcMatch = ShaderInstructionEncoder._FUNC_MACRO_RE.exec(rest);\n if (funcMatch) {\n const params = funcMatch[2]\n .split(\",\")\n .map((p) => p.trim())\n .filter((p) => p.length > 0);\n instructions.push([\n ShaderPreprocessorDirective.DefineFunc,\n funcMatch[1],\n params,\n ShaderInstructionEncoder._stripLineComment(funcMatch[3].trim())\n ]);\n } else {\n const separator = ShaderInstructionEncoder._findInlineWhitespace(rest);\n if (separator === rest.length) {\n instructions.push([ShaderPreprocessorDirective.Define, rest]);\n } else {\n instructions.push([\n ShaderPreprocessorDirective.DefineVal,\n rest.substring(0, separator),\n ShaderInstructionEncoder._stripLineComment(rest.substring(separator + 1).trim())\n ]);\n }\n }\n break;\n }\n case \"undef\": {\n instructions.push([ShaderPreprocessorDirective.Undef, rest]);\n break;\n }\n }\n }\n\n return instructions;\n }\n\n private static _pushConditionInstruction(instructions: ShaderInstruction[], cond: Condition): void {\n if (cond.t === \"def\") {\n instructions.push([ShaderPreprocessorDirective.IfDef, cond.m, -1]);\n } else if (cond.t === \"ndef\") {\n instructions.push([ShaderPreprocessorDirective.IfNdef, cond.m, -1]);\n } else if (cond.t === \"cmp\") {\n instructions.push([ShaderPreprocessorDirective.IfCmp, cond.m, cond.op, cond.v, -1]);\n } else {\n instructions.push([ShaderPreprocessorDirective.IfExpr, cond, -1]);\n }\n }\n\n private static _parseCondition(\n expression: string,\n preprocessorExpressions?: ReadonlyMap<string, PreprocessorExpressionParseResult>\n ): Condition {\n const result = preprocessorExpressions?.get(expression) ?? parsePreprocessorExpression(expression);\n if (\"error\" in result) {\n if (!result.error.certain && result.hasExpandableIdentifier) return { t: \"deferred\", e: expression };\n throw new Error(result.error.message);\n }\n if (result.evaluationError) throw new Error(result.evaluationError);\n const compact = toPreprocessorCondition(result.condition);\n if (compact && !result.hasExpandableIdentifier) return compact;\n return result.hasExpandableIdentifier ? { t: \"deferred\", e: expression } : result.condition;\n }\n\n private static _findDirectiveStart(source: string, from: number, length: number): number {\n let i = from;\n while (i < length) {\n let j = i;\n while (j < length) {\n const c = source.charCodeAt(j);\n if (c === 32 /* space */ || c === 9 /* tab */) {\n j++;\n } else {\n break;\n }\n }\n if (j < length && (source.charCodeAt(j) === 35 /* '#' */ || source.charCodeAt(j) === 0)) return i;\n\n const nl = source.indexOf(\"\\n\", i);\n if (nl === -1) break;\n i = nl + 1;\n }\n return -1;\n }\n\n private static _findLogicalLineEnd(source: string, start: number, length: number): number {\n let lineEnd = source.indexOf(\"\\n\", start);\n while (lineEnd !== -1) {\n const beforeBreak = source.charCodeAt(lineEnd - 1) === 13 ? lineEnd - 2 : lineEnd - 1;\n if (beforeBreak < start || source.charCodeAt(beforeBreak) !== 92) return lineEnd;\n lineEnd = source.indexOf(\"\\n\", lineEnd + 1);\n }\n return length;\n }\n\n private static _findInlineWhitespace(source: string): number {\n let index = 0;\n while (index < source.length) {\n const charCode = source.charCodeAt(index);\n if (charCode === 32 /* space */ || charCode === 9 /* tab */) break;\n index++;\n }\n return index;\n }\n\n private static _pushText(\n instructions: ShaderInstruction[],\n source: string,\n from: number,\n to: number,\n owners?: readonly number[]\n ): void {\n if (from >= to) return;\n const last = instructions.length > 0 ? instructions[instructions.length - 1] : null;\n const directive = owners === undefined ? ShaderPreprocessorDirective.Text : ShaderPreprocessorDirective.OwnedText;\n if (\n last &&\n last[0] === directive &&\n (owners === undefined ||\n (last.length === owners.length + 2 && owners.every((owner, index) => last[index + 2] === owner)))\n ) {\n (last as [number, string])[1] += source.substring(from, to);\n } else {\n instructions.push(\n owners === undefined\n ? [directive, source.substring(from, to)]\n : [directive, source.substring(from, to), ...owners]\n );\n }\n }\n\n /**\n * Backfill jump offset of an IF/ELIF instruction.\n * When onlyPlaceholder is true, only backfill if the current value is still -1\n */\n private static _backfillJump(inst: ShaderInstruction, target: number, onlyPlaceholder = false): void {\n const directive = inst[0];\n if (directive === ShaderPreprocessorDirective.IfDef || directive === ShaderPreprocessorDirective.IfNdef) {\n if (!onlyPlaceholder || inst[2] === -1) (inst as [number, string, number])[2] = target;\n } else if (directive === ShaderPreprocessorDirective.IfCmp) {\n if (!onlyPlaceholder || inst[4] === -1) (inst as [number, string, string, number, number])[4] = target;\n } else if (directive === ShaderPreprocessorDirective.IfExpr) {\n if (!onlyPlaceholder || inst[2] === -1) (inst as [number, Condition, number])[2] = target;\n }\n }\n\n private static _stripLineComment(s: string): string {\n const idx = s.indexOf(\"//\");\n return idx >= 0 ? s.substring(0, idx).trimEnd() : s;\n }\n}\n","import type { IShaderInfo } from \"@galacean/engine-design\";\nimport type { IPoolElement } from \"@galacean/engine-core\";\nimport { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { Keyword } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { NodeChild } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderData } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType } from \"@galacean/engine-shader-parser/internal\";\nimport {\n FnSymbol,\n VarSymbol,\n canInheritanceBranchesCover,\n getLexicalDeclarationCoexistence\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GSError, GSErrorName, mapExpandedShaderError } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils } from \"@galacean/engine-shader-parser/internal\";\nimport type {\n BranchSignature,\n ShaderClueIR,\n ShaderCoreInfo,\n ShaderEntryPointInfo,\n DeferredDeclarationOwnership\n} from \"@galacean/engine-shader-parser/internal\";\nimport { CodeGenVisitor } from \"./CodeGenVisitor\";\nimport { ICodeSegment } from \"./types\";\nimport type { ShaderBackend } from \"../ShaderBackend\";\nimport { ShaderInstructionEncoder } from \"../ShaderInstructionEncoder\";\n\n/**\n * @internal\n */\nexport abstract class GLESVisitor extends CodeGenVisitor implements ShaderBackend, IPoolElement {\n private _globalCodeArray: ICodeSegment[] = [];\n private readonly _forwardFunctionDeclarations = new Map<ASTNode.FunctionDefinition, string>();\n private readonly _forwardStructIndices = new Map<ASTNode.StructSpecifier, number>();\n private readonly _structCodeSegments = new Map<ASTNode.StructSpecifier, ICodeSegment>();\n private readonly _forwardVariableIndices = new Map<ASTNode.VariableDeclaration, number>();\n private readonly _variableCodeSegments = new Map<ASTNode.VariableDeclaration, ICodeSegment>();\n private readonly _declarationOwners = new Map<TreeNode, DeferredDeclarationOwnership>();\n private readonly _deferredPrototypes = new Map<ASTNode.FunctionDefinition, ICodeSegment>();\n private readonly _declarationReferences = new Map<number, Set<number>>();\n private _currentDeclaration?: TreeNode;\n private _sourceIR?: ShaderClueIR;\n private _outerMacroDeclarations: readonly ASTNode.GlobalDeclaration[] = [];\n\n /**\n * Clears pass-local output retained by the pooled visitor.\n */\n reset(): void {\n const { _globalCodeArray: globalCodeArray } = this;\n globalCodeArray.length = 0;\n this._forwardFunctionDeclarations.clear();\n this._forwardStructIndices.clear();\n this._structCodeSegments.clear();\n this._forwardVariableIndices.clear();\n this._variableCodeSegments.clear();\n this._deferredPrototypes.clear();\n this._declarationReferences.clear();\n this._currentDeclaration = undefined;\n }\n\n /**\n * Releases references retained by an idle visitor when its pool is collected.\n * @internal\n */\n dispose(): void {\n this.context.reset();\n this.reset();\n }\n\n /**\n * Emits target-specific declarations that precede generated global code.\n * @param data - Parser-owned shader facts.\n * @param out - Destination code segments.\n */\n getOtherGlobal(data: ShaderData, out: ICodeSegment[]): void {\n for (const precision of data.globalPrecisions) {\n out.push({ text: precision.codeGen(this), index: precision.location.start.index });\n }\n }\n\n /**\n * Generates vertex and fragment source from neutral parser facts.\n * @param ir - Request-owned neutral shader IR.\n * @param coreInfo - Entry and stage-interface facts derived from the same IR.\n * @returns Generated vertex and fragment source.\n */\n generate(ir: ShaderClueIR, coreInfo: ShaderCoreInfo): IShaderInfo {\n this.context.reset();\n this.reset();\n\n const node = ir.program;\n const shaderData = node.shaderData;\n const context = this.context;\n context._passSymbolTable = shaderData.symbolTable;\n\n const outerGlobalMacroDeclarations = coreInfo.outerGlobalMacroDeclarations;\n const { io } = coreInfo;\n context.attributeStructs.push(...io.attributeStructs);\n context.attributeList.push(...io.attributeList);\n context.varyingStructs.push(...io.varyingStructs);\n context.varyingList.push(...io.varyingList);\n context.mrtStructs.push(...io.mrtStructs);\n context.mrtList.push(...io.mrtList);\n context.registerStructTypes(ShaderStructRole.Attribute, io.attributeStructs);\n context.registerStructTypes(ShaderStructRole.Varying, io.varyingStructs);\n context.registerStructTypes(ShaderStructRole.Mrt, io.mrtStructs);\n io.structVariableRoles.forEach((role, variable) => context.registerStructVar(variable, role));\n io.vertexStructVariableRoles.forEach((role, variable) => {\n context.registerStructVar(variable, role, EShaderStage.VERTEX);\n });\n io.fragmentStructVariableRoles.forEach((role, variable) => {\n context.registerStructVar(variable, role, EShaderStage.FRAGMENT);\n });\n\n this._sourceIR = ir;\n this._outerMacroDeclarations = outerGlobalMacroDeclarations;\n try {\n coreInfo.deferredDeclarationOwnership.forEach((owner, symbol) =>\n this._declarationOwners.set(symbol.astNode!, owner)\n );\n if (this._declarationOwners.size) {\n let nextId = 0;\n let nextGroup = 0;\n this._declarationOwners.forEach((owner) => {\n nextId = Math.max(nextId, owner.id);\n nextGroup = Math.max(nextGroup, owner.group);\n });\n // Reachability follows the selected declaration, including dependencies without an override.\n shaderData.symbolTable.forEach((symbol) => {\n if (symbol.astNode && !this._declarationOwners.has(symbol.astNode)) {\n this._declarationOwners.set(symbol.astNode, {\n id: ++nextId,\n group: ++nextGroup,\n sourceScope: symbol.sourceScope\n });\n }\n });\n context.onReferenceGlobal = (symbols) => {\n const from = this.currentDeclarationOwner?.id ?? 0;\n for (const symbol of symbols) this._referenceDeclaration(from, symbol.astNode!);\n };\n const propDeclarations = new Map();\n for (const struct of [...io.attributeStructs, ...io.varyingStructs, ...io.mrtStructs]) {\n for (const prop of struct.propList) propDeclarations.set(prop, struct);\n }\n context.onReferenceStructProps = (props) => {\n const from = this.currentDeclarationOwner?.id ?? 0;\n for (const prop of props) this._referenceDeclaration(from, propDeclarations.get(prop));\n };\n }\n if (coreInfo.unsupportedDeferredDeclarations.length) {\n throw mapExpandedShaderError(\n new GSError(\n GSErrorName.CompilationError,\n \"Deferred inheritance requires exact signatures and cannot resolve a known partial-coverage conflict.\",\n coreInfo.unsupportedDeferredDeclarations[0].astNode!.location,\n ir.source,\n undefined,\n \"UnsupportedDeferredDeclaration\"\n ),\n ir.source,\n ir.sourceMap\n );\n }\n return {\n vertex: this._vertexMain(coreInfo.vertexEntry, shaderData, outerGlobalMacroDeclarations),\n fragment: this._fragmentMain(coreInfo.fragmentEntry, shaderData, outerGlobalMacroDeclarations)\n };\n } finally {\n this._sourceIR = undefined;\n this._outerMacroDeclarations = [];\n this._declarationOwners.clear();\n context.onReferenceGlobal = undefined;\n context.onReferenceStructProps = undefined;\n }\n }\n\n private _vertexMain(\n entryInfo: ShaderEntryPointInfo,\n data: ShaderData,\n outerGlobalMacroDeclarations: readonly ASTNode.GlobalDeclaration[]\n ): string {\n const context = this.context;\n context.stage = EShaderStage.VERTEX;\n context.stageEntry = entryInfo.name;\n\n // Attribute/varying structs were collected in ShaderCoreInfo\n\n // Pre-walk global `#define` values so referenced struct properties emit `attribute`/`varying` declarations.\n this._preRegisterGlobalMacroRefs(outerGlobalMacroDeclarations);\n\n const globalCodeArray = this._globalCodeArray;\n context.referenceGlobal(entryInfo.name, ESymbolType.FN);\n\n this._getGlobalSymbol(globalCodeArray);\n this._getCustomStruct(context.attributeStructs, globalCodeArray);\n this._getCustomStruct(context.varyingStructs, globalCodeArray);\n this._getGlobalMacroDeclarations(outerGlobalMacroDeclarations, globalCodeArray);\n this.getOtherGlobal(data, globalCodeArray);\n this._emitDeclarationReferences(globalCodeArray);\n\n const globalCode = globalCodeArray\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n\n context.reset(false);\n this.reset();\n\n return globalCode;\n }\n\n private _fragmentMain(\n entryInfo: ShaderEntryPointInfo,\n data: ShaderData,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): string {\n const context = this.context;\n context.stage = EShaderStage.FRAGMENT;\n context.stageEntry = entryInfo.name;\n this.prepareFragment(entryInfo, outerGlobalMacroStatements);\n\n // Every value-return must preserve early-exit control flow after entry return values are\n // lowered into fragment outputs.\n entryInfo.functions.forEach((fnSymbol) => {\n const returnType = fnSymbol.astNode.protoType.returnType;\n const mode =\n returnType.type === Keyword.VEC4\n ? \"color\"\n : returnType.typeSpecifier.structDeclarations.some((struct) =>\n context.hasStructRole(struct, ShaderStructRole.Mrt)\n )\n ? \"mrt\"\n : undefined;\n if (mode) {\n const statements = fnSymbol.astNode.statements;\n this._registerFragmentReturns(statements, mode, ParserUtils.lastStatement(statements));\n }\n });\n\n // Struct-variable identities are already populated from ShaderCoreInfo; just pre-walk macro\n // refs so struct codegen sees the references.\n this._preRegisterGlobalMacroRefs(outerGlobalMacroStatements);\n\n const globalCodeArray = this._globalCodeArray;\n context.referenceGlobal(entryInfo.name, ESymbolType.FN);\n\n this._getGlobalSymbol(globalCodeArray);\n this._getCustomStruct(context.varyingStructs, globalCodeArray);\n this._getCustomStruct(context.mrtStructs, globalCodeArray);\n this._getGlobalMacroDeclarations(outerGlobalMacroStatements, globalCodeArray);\n this.getOtherGlobal(data, globalCodeArray);\n this._emitDeclarationReferences(globalCodeArray);\n\n const globalCode = globalCodeArray\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n\n context.reset();\n this.reset();\n\n return globalCode;\n }\n\n protected prepareFragment(\n entryInfo: ShaderEntryPointInfo,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): void {\n void entryInfo;\n void outerGlobalMacroStatements;\n }\n\n /**\n * Pre-walk `#define` values in global macro declarations and register any\n * `structVar.prop` member accesses as referenced struct props. This must run before\n * struct codegen emits the declaration lists (`attribute …`, `varying …`, `MRT …`),\n * otherwise properties used only from macros would be missing from the output.\n */\n private _preRegisterGlobalMacroRefs(macros: readonly ASTNode.GlobalDeclaration[]): void {\n for (const macro of macros) {\n this._walkMacroDefineTokens(macro.children);\n }\n }\n\n private _walkMacroDefineTokens(children: NodeChild[]): void {\n for (const child of children) {\n if (child instanceof ASTNode.MacroDefine) {\n // Codegen the value once so the enclosed `visitPostfixExpression` calls\n // register their struct-prop references. The returned string is discarded\n // — the real emit happens later in `_getGlobalMacroDeclarations`.\n if (child.valueExpression) child.valueExpression.codeGen(this);\n } else if (child instanceof TreeNode) {\n const previous = this._currentDeclaration;\n if (child instanceof ASTNode.FunctionDefinition) this._currentDeclaration = child;\n this._walkMacroDefineTokens(child.children);\n this._currentDeclaration = previous;\n }\n }\n }\n\n private _registerFragmentReturns(node: TreeNode, mode: \"color\" | \"mrt\", terminal?: TreeNode): void {\n if (node instanceof ASTNode.JumpStatement && node.children.length === 3) {\n this.context.registerFragmentReturn(node, mode);\n if (node === terminal) this.context.registerTerminalInterfaceReturn(node);\n return;\n }\n for (const child of node.children) {\n if (child instanceof TreeNode) this._registerFragmentReturns(child, mode, terminal);\n }\n }\n\n private _getGlobalSymbol(out: ICodeSegment[]): void {\n const context = this.context;\n // Set iteration includes dependencies discovered while generating earlier declarations.\n for (const sm of context._referencedGlobalSymbols) {\n this._currentDeclaration = sm.astNode;\n const codeGenResult = sm.astNode!.codeGen(this);\n this._currentDeclaration = undefined;\n if (!codeGenResult) continue;\n const text = codeGenResult + (sm.type === ESymbolType.VAR ? \";\" : \"\");\n if (!sm.isInMacroBranch) {\n const segment = {\n text: this._declaration(text, sm.astNode!),\n index: sm.astNode!.location.start.index\n };\n out.push(segment);\n if (sm.astNode instanceof ASTNode.StructSpecifier) this._structCodeSegments.set(sm.astNode, segment);\n if (sm.astNode instanceof ASTNode.VariableDeclaration) this._variableCodeSegments.set(sm.astNode, segment);\n }\n }\n this._getForwardDeclarations(out);\n for (const segment of this._deferredPrototypes.values()) out.push(segment);\n for (const [definition, text] of this._forwardFunctionDeclarations) {\n if (!definition.isInMacroBranch) out.push({ text, index: definition.location.start.index });\n }\n }\n\n protected override referenceFunction(symbol: FnSymbol, referenceIndex: number, branch: BranchSignature): void {\n super.referenceFunction(symbol, referenceIndex, branch);\n const definition = symbol.astNode;\n const declarations = this._forwardFunctionDeclarations;\n if (symbol.ident === this.context.stageEntry) return;\n const candidates = this.context._referencedGlobals[symbol.ident].filter(\n (candidate): candidate is FnSymbol => candidate instanceof FnSymbol && candidate.equal(symbol)\n );\n const owner = this._declarationOwners.get(definition);\n if (owner) {\n for (const candidate of candidates) {\n const replacement = candidate.astNode;\n const nextOwner = this._declarationOwners.get(replacement);\n if (\n !nextOwner ||\n nextOwner.group !== owner.group ||\n nextOwner.sourceScope <= owner.sourceScope ||\n replacement.location.start.index <= referenceIndex\n )\n continue;\n const prototype = replacement.protoType;\n const anchor = definition.location.start.index;\n const previous = this._deferredPrototypes.get(replacement);\n if (previous && previous.index <= anchor) continue;\n if (\n !this._isContextIndependent(prototype) ||\n this._hasDeclarationContextBarrier(anchor, prototype.location.start.index, false)\n ) {\n this._unsupportedForwardDeclaration(prototype);\n }\n const outer = this._outerMacroDeclarations.find(\n (macro) => macro.location.start.index <= anchor && macro.location.end.index >= definition.location.end.index\n );\n const typeAnchor = outer?.location.start.index ?? anchor;\n this._prepareForwardTypes(prototype.returnType.typeSpecifier.structDeclarations, anchor, typeAnchor);\n for (const parameter of prototype.parameterList ?? []) {\n this._prepareForwardTypes(parameter.typeInfo?.structDeclarations ?? [], anchor, typeAnchor);\n }\n // Selection is determined at the later definition, so the prototype must not replay its guard here.\n this._deferredPrototypes.set(replacement, {\n text: this._declaration(`${prototype.codeGen(this)};`, replacement, false),\n index: typeAnchor\n });\n }\n return;\n }\n if (candidates.some((candidate) => candidate.astNode === definition)) return;\n const compatible = candidates.filter((candidate) => this._canBranchesOverlap(candidate.branchSignature, branch));\n const preceding = compatible.filter((candidate) => candidate.astNode.location.start.index < referenceIndex);\n if (\n canInheritanceBranchesCover(\n preceding.map((candidate) => candidate.branchSignature),\n branch\n )\n )\n return;\n const replacement = compatible.find((candidate) => candidate.astNode.location.start.index > referenceIndex);\n if (replacement) {\n // An inherited helper can call a declaration whose overriding body occurs later. Keep the\n // original declaration's macro/type context and emit only the final backend signature there.\n const prototype = replacement.astNode.protoType;\n const anchor = definition.location.start.index;\n const text = `${prototype.codeGen(this)};`;\n const signature = this._getForwardSignature(prototype);\n for (const candidate of candidates) {\n if (\n this._canBranchesOverlap(candidate.branchSignature, symbol.branchSignature) &&\n this._getForwardSignature(candidate.astNode.protoType) !== signature\n ) {\n this._unsupportedForwardDeclaration(candidate.astNode.protoType);\n }\n }\n if (declarations.has(definition)) return;\n if (\n !this._isContextIndependent(prototype) ||\n this._hasDeclarationContextBarrier(anchor, prototype.location.start.index, false)\n ) {\n this._unsupportedForwardDeclaration(prototype);\n }\n const outerMacro = this._outerMacroDeclarations.find(\n (macro) => macro.location.start.index <= anchor && macro.location.end.index >= definition.location.end.index\n );\n const typeAnchor = outerMacro?.location.start.index ?? anchor;\n this._prepareForwardTypes(prototype.returnType.typeSpecifier.structDeclarations, anchor, typeAnchor);\n for (const parameter of prototype.parameterList ?? []) {\n if (\n parameter.astNode instanceof ASTNode.ParameterDeclaration &&\n parameter.astNode.symbol &&\n this.context.getStructVarRole([parameter.astNode.symbol])\n ) {\n continue;\n }\n this._prepareForwardTypes(parameter.typeInfo?.structDeclarations ?? [], anchor, typeAnchor);\n }\n declarations.set(definition, text);\n }\n }\n\n private _getForwardSignature(prototype: ASTNode.FunctionProtoType): string {\n const parameters: string[] = [];\n for (const parameter of prototype.parameterList ?? []) {\n const declaration = parameter.astNode!;\n if (\n declaration instanceof ASTNode.ParameterDeclaration &&\n declaration.symbol &&\n this.context.getStructVarRole([declaration.symbol])\n )\n continue;\n const tokens: string[] = [];\n const visit = (node: NodeChild) => {\n if (node instanceof BaseToken) {\n if (node !== parameter.ident && node.type !== Keyword.IN) tokens.push(node.lexeme);\n } else {\n node.children.forEach(visit);\n }\n };\n visit(declaration);\n const text = tokens.join(\" \");\n if (text !== \"void\") parameters.push(text);\n }\n return `${prototype.returnType.codeGen(this)}(${parameters.join(\",\")})`;\n }\n\n private _canBranchesOverlap(left: BranchSignature, right: BranchSignature): boolean {\n return (\n getLexicalDeclarationCoexistence(left, right) !== \"exclusive\" &&\n !canInheritanceBranchesCover([], [...left, ...right])\n );\n }\n\n override visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n const code = super.visitVariableIdentifier(node);\n for (const symbol of node.resolvedSymbols()) {\n if (!(symbol instanceof VarSymbol) || !symbol.isUniform) continue;\n const candidates = this.context._referencedGlobals[symbol.ident]?.filter(\n (candidate): candidate is VarSymbol => candidate instanceof VarSymbol\n );\n const owner = this._declarationOwners.get(symbol.astNode);\n if (!candidates || (!owner && candidates.includes(symbol))) continue;\n const preceding = candidates.filter(\n (candidate) => candidate.astNode!.location.start.index < node.location.start.index\n );\n if (\n !owner &&\n canInheritanceBranchesCover(\n preceding.map((candidate) => candidate.branchSignature),\n node._branch\n )\n )\n continue;\n const oldMacro = this._outerMacroDeclarations.find(\n (macro) =>\n macro.location.start.index <= symbol.astNode.location.start.index &&\n macro.location.end.index >= symbol.astNode.location.end.index\n );\n const anchor = oldMacro?.location.start.index ?? symbol.astNode.location.start.index;\n for (const candidate of candidates) {\n if (candidate.astNode!.location.start.index <= node.location.start.index) continue;\n if (owner) {\n const nextOwner = this._declarationOwners.get(candidate.astNode!);\n if (!nextOwner || nextOwner.group !== owner.group || nextOwner.sourceScope <= owner.sourceScope) continue;\n }\n const declaration = candidate.astNode!;\n if (\n !(candidate instanceof VarSymbol) ||\n !candidate.isUniform ||\n !(declaration instanceof ASTNode.VariableDeclaration)\n ) {\n this._unsupportedForwardDeclaration(declaration);\n }\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= declaration.location.start.index &&\n item.location.end.index >= declaration.location.end.index\n );\n if (\n !this._isContextIndependent(declaration) ||\n this._hasDeclarationContextBarrier(anchor, macro?.location.end.index ?? declaration.location.end.index, true)\n ) {\n this._unsupportedForwardDeclaration(declaration);\n }\n this._prepareForwardTypes(candidate.dataType!.structDeclarations, anchor);\n this._forwardVariableIndices.set(\n declaration,\n Math.min(this._forwardVariableIndices.get(declaration) ?? Infinity, anchor)\n );\n }\n }\n return code;\n }\n\n private _getForwardDeclarations(out: ICodeSegment[]): void {\n type Declaration = ASTNode.StructSpecifier | ASTNode.VariableDeclaration;\n const guarded = new Map<ASTNode.GlobalDeclaration, { index: number; declarations: Declaration[] }>();\n const declarations: [Declaration, number][] = Array.from(this._forwardStructIndices);\n for (const entry of this._forwardVariableIndices) declarations.push(entry);\n const code = (declaration: Declaration) =>\n this._declaration(\n declaration.codeGen(this) + (declaration instanceof ASTNode.VariableDeclaration ? \";\" : \"\"),\n declaration,\n false\n );\n for (const [declaration, index] of declarations) {\n const owner = this._declarationOwners.get(declaration);\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= declaration.location.start.index &&\n item.location.end.index >= declaration.location.end.index\n );\n if (!macro) {\n const previous =\n declaration instanceof ASTNode.StructSpecifier\n ? this._structCodeSegments.get(declaration)\n : this._variableCodeSegments.get(declaration);\n if (previous) {\n if (owner) previous.text = this._declaration(\"\", declaration);\n else out.splice(out.indexOf(previous), 1);\n }\n out.push({ text: code(declaration), index });\n } else if (owner) {\n out.push({ text: code(declaration), index });\n } else {\n let group = guarded.get(macro);\n if (!group) guarded.set(macro, (group = { index, declarations: [] }));\n group.index = Math.min(group.index, index);\n group.declarations.push(declaration);\n }\n }\n for (const [macro, group] of guarded) {\n const segments: ICodeSegment[] = macro.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }));\n for (const declaration of group.declarations) {\n segments.push({ text: code(declaration), index: declaration.location.start.index });\n }\n out.push({\n text: segments\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\"),\n index: group.index\n });\n }\n }\n\n override visitTypeSpecifier(node: ASTNode.TypeSpecifier): string {\n const call = node.parent instanceof ASTNode.FunctionIdentifier ? node.parent.parent : undefined;\n if (call instanceof ASTNode.FunctionCallGeneric && call.fnSymbol instanceof FnSymbol) {\n return super.visitTypeSpecifier(node);\n }\n for (const type of node.structDependencies) {\n if (!type.ident || this.context.getStructRole([type])) continue;\n // A function-local struct can shadow a global name without participating in inheritance.\n let parent = type.parent;\n while (\n parent &&\n !(parent instanceof ASTNode.GlobalDeclaration) &&\n !(parent instanceof ASTNode.FunctionDefinition)\n ) {\n parent = parent.parent;\n }\n if (parent instanceof ASTNode.FunctionDefinition) continue;\n this.context.referenceGlobal(type.ident.lexeme, ESymbolType.STRUCT);\n const final = this.context._referencedGlobals[type.ident.lexeme];\n const owner = this._declarationOwners.get(type);\n if (!owner && final.some((symbol) => symbol.astNode === type)) continue;\n const oldMacro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= type.location.start.index && item.location.end.index >= type.location.end.index\n );\n this._prepareForwardTypes(\n final\n .filter((symbol) => {\n if (!owner) return true;\n const nextOwner = this._declarationOwners.get(symbol.astNode!);\n return nextOwner?.group === owner.group && nextOwner.sourceScope > owner.sourceScope;\n })\n .map((symbol) => symbol.astNode)\n .filter((item): item is ASTNode.StructSpecifier => item instanceof ASTNode.StructSpecifier),\n oldMacro?.location.start.index ?? type.location.start.index\n );\n }\n return super.visitTypeSpecifier(node);\n }\n\n private _prepareForwardTypes(types: readonly ASTNode.StructSpecifier[], anchor: number, hoistAnchor = anchor): void {\n if (this.context.getStructRole(types)) return;\n for (const type of types) {\n if ((this._forwardStructIndices.get(type) ?? Infinity) <= anchor) continue;\n if (type.ident) {\n this.context.referenceGlobal(type.ident.lexeme, ESymbolType.STRUCT);\n const final = this.context._referencedGlobals[type.ident.lexeme];\n if (!final.some((symbol) => symbol.astNode === type)) {\n this._prepareForwardTypes(\n final\n .map((symbol) => symbol.astNode)\n .filter((item): item is ASTNode.StructSpecifier => item instanceof ASTNode.StructSpecifier),\n anchor,\n hoistAnchor\n );\n continue;\n }\n }\n const needsHoist = type.location.start.index > anchor;\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= type.location.start.index && item.location.end.index >= type.location.end.index\n );\n if (\n needsHoist &&\n (!this._isContextIndependent(type) ||\n this._hasDeclarationContextBarrier(hoistAnchor, macro?.location.end.index ?? type.location.end.index, true))\n ) {\n this._unsupportedForwardDeclaration(type);\n }\n const dependencyAnchor = needsHoist ? hoistAnchor : type.location.start.index;\n for (const property of type.propList) {\n this._prepareForwardTypes(property.typeInfo.structDeclarations, dependencyAnchor);\n }\n if (needsHoist) this._forwardStructIndices.set(type, hoistAnchor);\n }\n }\n\n private _isContextIndependent(node: TreeNode): boolean {\n if (\n node instanceof ASTNode.VariableIdentifier ||\n node instanceof ASTNode.MacroCallSymbol ||\n node instanceof ASTNode.MacroCallFunction\n )\n return false;\n if (node instanceof ASTNode.TypeSpecifier && node.isCustom && !node.structDeclarations.length) return false;\n return node.children.every((child) =>\n child instanceof TreeNode\n ? this._isContextIndependent(child)\n : child.type < Keyword.MACRO_IF || child.type > Keyword.MACRO_DEFINE_PARAMS\n );\n }\n\n private _hasDeclarationContextBarrier(start: number, end: number, includeMacros: boolean): boolean {\n const visit = (node: TreeNode, inFunction = false): boolean => {\n if (node.location.end.index <= start || node.location.start.index >= end) return false;\n if (node instanceof ASTNode.PrecisionSpecifier && !inFunction) return true;\n if (includeMacros && node instanceof ASTNode.MacroDefine) return true;\n inFunction ||= node instanceof ASTNode.FunctionDefinition;\n return node.children.some((child) =>\n child instanceof TreeNode\n ? visit(child, inFunction)\n : includeMacros &&\n child.location.start.index > start &&\n child.location.start.index < end &&\n (child.type === Keyword.MACRO_UNDEF || child.type === Keyword.MACRO_DEFINE_EXPRESSION)\n );\n };\n return visit(this._sourceIR!.program);\n }\n\n private _unsupportedForwardDeclaration(node: TreeNode): never {\n const ir = this._sourceIR!;\n throw mapExpandedShaderError(\n new GSError(\n GSErrorName.CompilationError,\n \"Inherited declarations require incompatible forward signatures or depend on a later macro or precision context.\",\n node.location,\n ir.source,\n undefined,\n \"UnsupportedForwardDeclaration\"\n ),\n ir.source,\n ir.sourceMap\n );\n }\n\n private _getCustomStruct(structNodes: ASTNode.StructSpecifier[], out: ICodeSegment[]): void {\n for (const node of structNodes) {\n const text = node.codeGen(this);\n\n if (!node.isInMacroBranch) {\n out.push({ text: this._declaration(text, node), index: node.location.start.index });\n }\n }\n }\n\n private _getGlobalMacroDeclarations(macros: readonly ASTNode.GlobalDeclaration[], out: ICodeSegment[]): void {\n const context = this.context;\n const referencedGlobalMacroASTs = context._referencedGlobalMacroASTs;\n referencedGlobalMacroASTs.length = 0;\n\n for (const symbol of context._referencedGlobalSymbols) {\n if (symbol.isInMacroBranch) referencedGlobalMacroASTs.push(symbol.astNode!);\n }\n\n for (const macro of macros) {\n let text: string;\n const child = macro.children[0];\n\n if (child instanceof ASTNode.GlobalMacroIfStatement) {\n const result: ICodeSegment[] = [];\n result.push(\n ...macro.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }))\n );\n\n this._visitGlobalMacroIfStatement(child, result);\n\n text = result\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n } else if (child instanceof BaseToken && child.type === Keyword.MACRO_DEFINE_EXPRESSION) {\n // Legacy opaque `#define` — its lexeme is the complete directive text,\n // newlines included; emit verbatim.\n text = child.lexeme;\n } else {\n text = macro.codeGen(this);\n }\n\n out.push({\n text,\n index: macro.location.start.index\n });\n }\n }\n\n private _visitGlobalMacroIfStatement(node: TreeNode, out: ICodeSegment[]): void {\n const children = node.children;\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child instanceof ASTNode.PrecisionSpecifier) {\n out.push({\n text: child.codeGen(this),\n index: child.location.start.index\n });\n } else if (child instanceof ASTNode.FunctionDefinition) {\n const text =\n this.context._referencedGlobalMacroASTs.indexOf(child) !== -1\n ? this.getCachedCode(child)\n : this._forwardFunctionDeclarations.get(child);\n if (text !== undefined) {\n out.push({\n text: this._declaration(text, child),\n index: child.location.start.index\n });\n }\n } else if (child instanceof ASTNode.StructSpecifier) {\n if (this._forwardStructIndices.has(child)) {\n const text = this._declaration(\"\", child);\n if (text) out.push({ text, index: child.location.start.index });\n continue;\n }\n const context = this.context;\n const stage = context.stage;\n if (\n context._referencedGlobalMacroASTs.indexOf(child) !== -1 ||\n (stage === EShaderStage.VERTEX\n ? context.hasStructRole(child, ShaderStructRole.Attribute) ||\n context.hasStructRole(child, ShaderStructRole.Varying)\n : context.hasStructRole(child, ShaderStructRole.Varying) ||\n context.hasStructRole(child, ShaderStructRole.Mrt))\n ) {\n out.push({\n text: this._declaration(this.getCachedCode(child) ?? \"\", child),\n index: child.location.start.index\n });\n }\n } else if (child instanceof ASTNode.VariableDeclarationList) {\n const variableDeclarations = child.variableDeclarations;\n for (let i = 0; i < variableDeclarations.length; i++) {\n const variableDeclaration = variableDeclarations[i];\n if (this.context._referencedGlobalMacroASTs.indexOf(variableDeclaration) !== -1) {\n out.push({\n text: this._declaration(\n this._forwardVariableIndices.has(variableDeclaration)\n ? \"\"\n : `${this.getCachedCode(variableDeclaration) ?? \"\"};`,\n variableDeclaration\n ),\n index: variableDeclaration.location.start.index\n });\n }\n }\n }\n\n if (child instanceof TreeNode) {\n this._visitGlobalMacroIfStatement(child, out);\n }\n }\n }\n\n /** Ownership of the declaration currently generating dependencies. @internal */\n protected get currentDeclarationOwner(): DeferredDeclarationOwnership | undefined {\n return this._currentDeclaration && this._declarationOwners.get(this._currentDeclaration);\n }\n\n private _referenceDeclaration(from: number, node: TreeNode): void {\n const owner = this._declarationOwners.get(node);\n if (!owner) return;\n let targets = this._declarationReferences.get(from);\n if (!targets) this._declarationReferences.set(from, (targets = new Set()));\n targets.add(owner.id);\n }\n\n private _emitDeclarationReferences(out: ICodeSegment[]): void {\n for (const [from, targets] of this._declarationReferences) {\n for (const to of targets) out.push({ text: ShaderInstructionEncoder.reference(from, to), index: -1 });\n }\n }\n\n private _declaration(text: string, node: TreeNode, activate = true): string {\n return ShaderInstructionEncoder.declaration(text, this._declarationOwners.get(node), activate);\n }\n}\n","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n\n if (\"value\" in descriptor) descriptor.writable = true;\n\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n\n return Constructor;\n}\nexport { _create_class as _ };\n","import { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils, ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport { StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { GLESVisitor } from \"./GLESVisitor\";\n\nexport class GLES100Visitor extends GLESVisitor {\n override getAttributeProp(prop: StructProp): string {\n return `attribute ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getVaryingProp(prop: StructProp): string {\n return `varying ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getMRTProp(): string {\n return \"\";\n }\n\n override visitPostfixExpression(node: ASTNode.PostfixExpression): string {\n const { children } = node;\n const postExpr = children[0];\n const context = this.context;\n const directRoot =\n postExpr instanceof ASTNode.PostfixExpression\n ? ParserUtils.unwrapBareIdentifier(postExpr, { allowParens: true })\n : undefined;\n const directSymbols = directRoot?.resolvedValueSymbols() ?? [];\n const unresolvedName =\n postExpr instanceof ASTNode.PostfixExpression ? ParserUtils.extractDirectIdentLexeme(postExpr) : null;\n const directRole = directRoot\n ? directSymbols.length\n ? context.getStructVarRole(directSymbols)\n : unresolvedName\n ? context.getUnresolvedStructVarRole(unresolvedName)\n : undefined\n : undefined;\n if (directRole === ShaderStructRole.Mrt) {\n const propReferenced = children[2] as BaseToken;\n const prop = context.mrtList.find((item) => item.ident.lexeme === propReferenced.lexeme);\n // The parser already validated struct fields (UndeclaredStructMember); a miss here is an\n // already-errored shader, so emit nothing rather than re-report.\n if (!prop) return \"\";\n return `gl_FragData[${prop.mrtIndex!}]`;\n }\n return super.visitPostfixExpression(node);\n }\n\n override visitJumpStatement(node: ASTNode.JumpStatement): string {\n const mode = this.context.getFragmentReturnMode(node);\n const terminal = this.context.isTerminalInterfaceReturn(node);\n if (mode === \"mrt\") return terminal ? \"\" : \"return;\";\n if (mode === \"color\") {\n const expression = node.children[1] as ASTNode.Expression;\n const assignment = `gl_FragColor = ${expression.codeGen(this)};`;\n return terminal ? assignment : `{ ${assignment} return; }`;\n }\n return super.visitJumpStatement(node);\n }\n}\n","import { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderData } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderBuiltinSemantic } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderEntryPointInfo } from \"@galacean/engine-shader-parser/internal\";\nimport { TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { GLESVisitor } from \"./GLESVisitor\";\nimport { ICodeSegment } from \"./types\";\nimport type { DeferredDeclarationOwnership } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderInstructionEncoder } from \"../ShaderInstructionEncoder\";\n\nconst V3_GL_FragColor = \"GS_glFragColor\";\nconst V3_GL_FragData = \"GS_glFragData\";\n\nexport class GLES300Visitor extends GLESVisitor {\n private readonly _outputDeclarations = new Map<\n string,\n { text: string; owners: Map<number, DeferredDeclarationOwnership>; unconditional: boolean }\n >();\n private _fragDataArrayRequired = false;\n private readonly _fragDataIndices = new Map<ASTNode.PostfixExpression, number>();\n private readonly _scannedFragmentFunctions = new Set<ShaderEntryPointInfo[\"functions\"][number]>();\n\n override reset(): void {\n super.reset();\n\n this._outputDeclarations.clear();\n this._fragDataArrayRequired = false;\n this._fragDataIndices.clear();\n this._scannedFragmentFunctions.clear();\n }\n\n override getOtherGlobal(data: ShaderData, out: ICodeSegment[]): void {\n super.getOtherGlobal(data, out);\n\n for (const output of this._outputDeclarations.values()) {\n out.push({\n text: output.unconditional\n ? output.text\n : ShaderInstructionEncoder.sharedDeclaration(output.text, Array.from(output.owners.values())),\n // A source macro block can start at zero and contain the first output use.\n index: -1\n });\n }\n }\n\n override getAttributeProp(prop: StructProp): string {\n return `in ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getVaryingProp(prop: StructProp): string {\n const qualifier = this.context.stage === EShaderStage.FRAGMENT ? \"in\" : \"out\";\n return `${qualifier} ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getMRTProp(prop: StructProp): string {\n return `layout(location = ${prop.mrtIndex}) out vec4 ${prop.ident.lexeme};`;\n }\n\n override visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string {\n const children = node.children;\n const typeSpecifier = children[0] as ASTNode.TypeSpecifier;\n if (typeSpecifier.children.length !== 1 || typeSpecifier.structDependencies.length) {\n // Struct constructors still need the shared type-dependency visitor.\n return super.visitFunctionIdentifier(node);\n }\n let ident = node.lexeme;\n switch (node.ident) {\n case \"texture2D\":\n case \"textureCube\":\n ident = \"texture\";\n break;\n case \"texture2DProj\":\n ident = \"textureProj\";\n break;\n case \"texture2DLodEXT\":\n case \"textureCubeLodEXT\":\n ident = \"textureLod\";\n break;\n case \"texture2DGradEXT\":\n case \"textureCubeGradEXT\":\n ident = \"textureGrad\";\n break;\n case \"texture2DProjLodEXT\":\n ident = \"textureProjLod\";\n break;\n case \"texture2DProjGradEXT\":\n ident = \"textureProjGrad\";\n break;\n }\n return ident;\n }\n\n override visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n const context = this.context;\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutput0) {\n this._registerFragColorVariable();\n return V3_GL_FragColor;\n }\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentDepth) {\n return \"gl_FragDepth\";\n }\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray) {\n this._registerFragDataArray();\n return V3_GL_FragData;\n }\n return super.visitVariableIdentifier(node);\n }\n\n override visitPostfixExpression(node: ASTNode.PostfixExpression): string {\n if (!this._fragDataArrayRequired) {\n const index = this._fragDataIndices.get(node);\n if (index !== undefined) return this._registerFragDataVariable(index);\n }\n return super.visitPostfixExpression(node);\n }\n\n override visitJumpStatement(node: ASTNode.JumpStatement): string {\n const mode = this.context.getFragmentReturnMode(node);\n const terminal = this.context.isTerminalInterfaceReturn(node);\n if (mode === \"mrt\") return terminal ? \"\" : \"return;\";\n if (mode === \"color\") {\n this._registerFragColorVariable();\n\n const expression = node.children[1] as ASTNode.Expression;\n const assignment = `${V3_GL_FragColor} = ${expression.codeGen(this)};`;\n return terminal ? assignment : `{ ${assignment} return; }`;\n }\n return super.visitJumpStatement(node);\n }\n\n private _registerFragColorVariable(): void {\n this._registerOutput(V3_GL_FragColor, `out vec4 ${V3_GL_FragColor};`);\n }\n\n private _registerOutput(name: string, text: string): void {\n let output = this._outputDeclarations.get(name);\n if (!output) this._outputDeclarations.set(name, (output = { text, owners: new Map(), unconditional: false }));\n const owner = this.currentDeclarationOwner;\n if (owner) output.owners.set(owner.id, owner);\n else output.unconditional = true;\n }\n\n protected override prepareFragment(\n entryInfo: ShaderEntryPointInfo,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): void {\n const pending = entryInfo.functions.slice();\n while (pending.length) {\n const fn = pending.pop()!;\n if (this._scannedFragmentFunctions.has(fn)) continue;\n this._scannedFragmentFunctions.add(fn);\n this._scanFragmentOutputs(fn.astNode);\n pending.push(...fn.calledFunctions);\n }\n for (const macro of outerGlobalMacroStatements) this._scanFragmentOutputs(macro);\n }\n\n private _scanFragmentOutputs(node: TreeNode): void {\n if (node instanceof ASTNode.PostfixExpression && node.children.length === 4) {\n const base = node.children[0];\n const index = node.children[2];\n if (\n base instanceof TreeNode &&\n index instanceof TreeNode &&\n ParserUtils.unwrapBareIdentifier(base, { allowParens: true })?.builtinSemantic ===\n ShaderBuiltinSemantic.FragmentOutputArray\n ) {\n const value = ParserUtils.constIntegerValue(index);\n if (value === undefined || value < 0) this._fragDataArrayRequired = true;\n else this._fragDataIndices.set(node, value);\n this._scanFragmentOutputs(index);\n return;\n }\n }\n if (\n node instanceof ASTNode.VariableIdentifier &&\n node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray\n ) {\n this._fragDataArrayRequired = true;\n return;\n }\n for (const child of node.children) {\n if (child instanceof TreeNode) this._scanFragmentOutputs(child);\n }\n }\n\n private _registerFragDataArray(): void {\n this._registerOutput(V3_GL_FragData, `layout(location = 0) out vec4 ${V3_GL_FragData}[gl_MaxDrawBuffers];`);\n }\n\n private _registerFragDataVariable(index: number): string {\n const name = `${V3_GL_FragData}${index}`;\n this._registerOutput(name, `layout(location = ${index}) out vec4 ${name};`);\n return name;\n }\n}\n","import type { IShaderInfo } from \"@galacean/engine-design\";\nimport { Logger, ReturnableObjectPool, ShaderLanguage } from \"@galacean/engine-core\";\nimport {\n GSError,\n GLESShaderInfo,\n type ShaderClueIR,\n type ShaderCoreInfo\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GLES100Visitor, GLES300Visitor } from \"./codeGen\";\nimport type { GLESVisitor } from \"./codeGen/GLESVisitor\";\n\n/**\n * Static internal facade for GLES source generation.\n * @internal\n */\nexport class GLESBackend {\n private static readonly _gles100VisitorPool = new ReturnableObjectPool(GLES100Visitor);\n private static readonly _gles300VisitorPool = new ReturnableObjectPool(GLES300Visitor);\n\n private constructor() {}\n\n /**\n * Generates one GLES program with request-owned visitor state.\n * @param ir - Request-owned neutral parser IR consumed read-only.\n * @param coreInfo - Entry and stage-interface facts derived from the same IR.\n * @param target - GLES language version to emit.\n * @returns Generated vertex and fragment source.\n * @internal\n */\n static generate(ir: ShaderClueIR, coreInfo: ShaderCoreInfo, target: ShaderLanguage): IShaderInfo | undefined {\n const glesInfo = new GLESShaderInfo(ir, coreInfo);\n if (glesInfo.mrtOutputIssues.length || glesInfo.invalidMrtReturnLocations.length) {\n Logger.error(\n \"MRT outputs require unique non-negative locations, vec4 members, and returns through an assigned struct variable.\"\n );\n return undefined;\n }\n if (glesInfo.invalidVaryingReturnLocations.length) {\n Logger.error(\"Varying vertex entries must return a struct variable or same-type function result.\");\n return undefined;\n }\n if (glesInfo.structMemberOwnerIssues.length) {\n Logger.error(\"A struct member reference cannot be lowered safely across runtime macro expansion.\");\n return undefined;\n }\n\n return target === ShaderLanguage.GLSLES100\n ? GLESBackend._generateWithPool(GLESBackend._gles100VisitorPool, ir, coreInfo)\n : GLESBackend._generateWithPool(GLESBackend._gles300VisitorPool, ir, coreInfo);\n }\n\n private static _generateWithPool<T extends GLESVisitor>(\n pool: ReturnableObjectPool<T>,\n ir: ShaderClueIR,\n coreInfo: ShaderCoreInfo\n ): IShaderInfo | undefined {\n const visitor = pool.get();\n try {\n return visitor.generate(ir, coreInfo);\n } catch (error) {\n visitor.dispose();\n if (!(error instanceof GSError)) throw error;\n Logger.error(`${error.file ? `${error.file}: ` : \"\"}${error.code ? `${error.code}: ` : \"\"}${error.toString()}`);\n return undefined;\n } finally {\n pool.return(visitor);\n }\n }\n}\n","import { Logger, ShaderLanguage } from \"@galacean/engine-core\";\nimport type { IRenderStates, IShaderSource } from \"@galacean/engine-design\";\nimport type { IShaderProgramSource } from \"@galacean/engine-design/types/shader-compiler/IShaderProgramSource\";\nimport { Color } from \"@galacean/engine-math\";\nimport {\n GSError,\n ShaderCoreInfo,\n type ParsedShaderPassData,\n type ShaderClueIR,\n type ShaderSourceParseResult\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GLESBackend } from \"./GLESBackend\";\nimport { ShaderInstructionEncoder } from \"./ShaderInstructionEncoder\";\n\nclass ShaderSourceParseError extends Error {\n constructor(readonly errors: readonly Error[]) {\n super(errors.map((error) => error.toString()).join(\"\\n\"));\n this.name = \"ShaderSourceParseError\";\n }\n}\n\n/**\n * Rejects a partial ShaderLab structure when source parsing produced errors.\n * @param result - ShaderLab source-parser result.\n * @returns Complete parsed ShaderLab structure.\n * @throws ShaderSourceParseError when structural source diagnostics exist.\n * @internal\n */\nexport function requireValidShaderSource(result: ShaderSourceParseResult): IShaderSource {\n if (result.errors.length) throw new ShaderSourceParseError(result.errors);\n return result.shaderSource;\n}\n\n/**\n * Generates one backend program from a parser-owned pass without reparsing it.\n * @param parsed - Neutral parser output.\n * @param vertexEntry - Vertex entry name.\n * @param fragmentEntry - Fragment entry name.\n * @param backend - Target GLES language.\n * @param coreInfo - Optional stage facts already derived from this exact parser result.\n * @returns Generated program, or `undefined` when parser or entry admission fails.\n * @internal\n */\nexport function generateParsedShaderPassData(\n parsed: ParsedShaderPassData,\n vertexEntry: string,\n fragmentEntry: string,\n backend: ShaderLanguage,\n coreInfo?: ShaderCoreInfo\n): IShaderProgramSource | undefined {\n if (parsed.blockingErrors.length) {\n for (const error of parsed.blockingErrors) Logger.error(error.toString());\n return undefined;\n }\n if (!parsed.ir) return undefined;\n const resolvedCoreInfo = coreInfo ?? ShaderCoreInfo.create(parsed.ir, vertexEntry, fragmentEntry);\n return generateShaderProgram(parsed.ir, resolvedCoreInfo, backend, parsed.preprocessorExpressions);\n}\n\nfunction generateShaderProgram(\n ir: ShaderClueIR,\n coreInfo: ShaderCoreInfo,\n backend: ShaderLanguage,\n preprocessorExpressions: ParsedShaderPassData[\"preprocessorExpressions\"]\n): IShaderProgramSource | undefined {\n if (!coreInfo.vertexEntry.functions.length) {\n Logger.error(`Vertex entry function '${coreInfo.vertexEntry.name}' not found.`);\n return undefined;\n }\n if (!coreInfo.fragmentEntry.functions.length) {\n Logger.error(`Fragment entry function '${coreInfo.fragmentEntry.name}' not found.`);\n return undefined;\n }\n if (coreInfo.vertexEntry.hasDefiniteAmbiguity) {\n Logger.error(`Vertex entry function '${coreInfo.vertexEntry.name}' resolves to multiple declarations.`);\n return undefined;\n }\n if (coreInfo.fragmentEntry.hasDefiniteAmbiguity) {\n Logger.error(`Fragment entry function '${coreInfo.fragmentEntry.name}' resolves to multiple declarations.`);\n return undefined;\n }\n if (coreInfo.roleConflicts.length) {\n Logger.error(\"A shader IO struct cannot serve multiple stage-interface roles.\");\n return undefined;\n }\n const result = GLESBackend.generate(ir, coreInfo, backend);\n if (result) {\n result.vertexShaderInstructions = ShaderInstructionEncoder.parse(result.vertex, preprocessorExpressions);\n result.fragmentShaderInstructions = ShaderInstructionEncoder.parse(result.fragment, preprocessorExpressions);\n result.vertex = ShaderInstructionEncoder.source(result.vertex);\n result.fragment = ShaderInstructionEncoder.source(result.fragment);\n }\n return result;\n}\n\n/**\n * Converts parser-owned render states into JSON-safe precompile data.\n * @param renderStates - Parsed render-state maps.\n * @returns Serializable constant and variable maps.\n * @internal\n */\nexport function serializeRenderStates(renderStates: IRenderStates): {\n constantMap: Record<string, number | string | boolean | number[]>;\n variableMap: Record<string, string>;\n} {\n const constantMap: Record<string, number | string | boolean | number[]> = {};\n for (const key in renderStates.constantMap) {\n const value = renderStates.constantMap[key];\n if (value instanceof Color) {\n constantMap[key] = [value.r, value.g, value.b, value.a];\n } else {\n constantMap[key] = value as number | string | boolean;\n }\n }\n return { constantMap, variableMap: renderStates.variableMap };\n}\n\n/**\n * Formats a parser failure with include-source attribution.\n * @param error - Parser failure.\n * @returns User-facing error text.\n * @internal\n */\nexport function formatShaderError(error: Error): string {\n const text = error.toString();\n return error instanceof GSError && error.file ? `${error.file}: ${text}` : text;\n}\n","import { ShaderLanguage } from \"@galacean/engine-core\";\nimport type { IShaderSource } from \"@galacean/engine-design\";\nimport type { IShaderProgramSource } from \"@galacean/engine-design/types/shader-compiler/IShaderProgramSource\";\nimport {\n getParsedShaderPassPayload,\n normalizeShaderIncludeMap,\n ParserObjectPool,\n createRuntimeShaderTargetParser,\n parseRuntimeShaderPass,\n type IncludeMap,\n type ChunkOutputCache,\n ShaderSourceParser\n} from \"@galacean/engine-shader-parser/internal\";\nimport type { ParsedShaderPass } from \"@galacean/engine-shader-parser/shared\";\nimport { generateParsedShaderPassData, requireValidShaderSource } from \"./ShaderCompilation\";\n\n/**\n * Compiles ShaderLab sources into runtime GLES programs.\n *\n * Source parsing and backend generation remain independent of authoring diagnostics; structural\n * source errors reject compilation before partial runtime programs can be created. Offline `.shaderc`\n * validation lives in the bundler-only precompiler entry and is excluded from this runtime package surface.\n */\nexport class ShaderCompiler {\n private _includeMap: IncludeMap = {};\n private readonly _chunkOutputCache: ChunkOutputCache = new Map();\n private readonly _sourceParserObjectPool = new ParserObjectPool();\n private readonly _parserObjectPool = new ParserObjectPool();\n private readonly _runtimeParser = createRuntimeShaderTargetParser(this._parserObjectPool);\n\n /**\n * Replaces the `#include` lookup table and clears the derived chunk cache.\n * @param includeMap - Canonical include paths mapped to shader chunks.\n * @internal\n */\n _setIncludeMap(includeMap: IncludeMap): void {\n this._includeMap = normalizeShaderIncludeMap(includeMap);\n this._chunkOutputCache.clear();\n }\n\n /**\n * Parses one ShaderLab document into its source structure.\n * @param sourceCode - Complete ShaderLab source.\n * @returns Parsed subshaders, passes, entries, and render states.\n * @throws ShaderSourceParseError when source-structure diagnostics were produced.\n * @internal\n */\n _parseShaderSource(sourceCode: string): IShaderSource {\n this._chunkOutputCache.clear();\n return requireValidShaderSource(ShaderSourceParser.parseStrict(sourceCode, this._sourceParserObjectPool));\n }\n\n /**\n * Parses and generates one runtime ShaderLab pass.\n * @param source - GLSL source contained by the pass.\n * @param vertexEntry - Vertex entry function name.\n * @param fragmentEntry - Fragment entry function name.\n * @param backend - Target GLES language version.\n * @param sourceFile - Optional logical source location used for relative includes and attribution.\n * @param sourceScopeStarts - Inherited ShaderLab content boundaries from source parsing.\n * @returns Generated stage program, or `undefined` after a blocking parser or backend error.\n * @internal\n */\n _parseShaderPass(\n source: string,\n vertexEntry: string,\n fragmentEntry: string,\n backend: ShaderLanguage,\n sourceFile?: string,\n sourceScopeStarts?: readonly number[]\n ): IShaderProgramSource | undefined {\n const parsed = parseRuntimeShaderPass(\n source,\n this._includeMap,\n this._chunkOutputCache,\n sourceFile,\n this._parserObjectPool,\n this._runtimeParser,\n sourceScopeStarts\n );\n return generateParsedShaderPassData(parsed, vertexEntry, fragmentEntry, backend);\n }\n\n /**\n * Generates backend source from a pass returned by `ShaderAnalyzer.analyze()` without parsing it again.\n * @param pass - Opaque parsed-pass handle from the analyzer result.\n * @param backend - Target GLES language version.\n * @returns Variant-selectable instructions and unselected text for inspection, or `undefined` on validation failure.\n * @throws TypeError when `pass` was not created by the compatible shader-parser package instance.\n */\n generate(pass: ParsedShaderPass, backend: ShaderLanguage): IShaderProgramSource | undefined {\n const { data, vertexEntry, fragmentEntry, coreInfo } = getParsedShaderPassPayload(pass);\n return generateParsedShaderPassData(data, vertexEntry, fragmentEntry, backend, coreInfo);\n }\n}\n","import { Logger } from \"@galacean/engine-core\";\n\nexport { ShaderCompiler } from \"./ShaderCompiler\";\n\nexport { GSError, GSErrorName } from \"@galacean/engine-shader-parser/internal\";\n\n/**\n * Version of the shader compiler package, replaced with the package version during builds.\n */\nexport const version = `__buildVersion`;\n\nLogger.info(`Galacean Engine Shader Compiler Version: ${version}`);\n"],"names":["_instanceof","left","right","Symbol","hasInstance","_extends","Object","assign","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","ShaderRange","set","start","end","obj","constructor","_set_prototype_of","o","p","setPrototypeOf","__proto__","_inherits","subClass","superClass","TypeError","create","value","writable","configurable","_is_native_reflect_construct","result","Boolean","valueOf","Reflect","construct","_","_construct","Parent","args","Class","a","push","instance","Function","bind","_get_prototype_of","getPrototypeOf","_wrap_native_super","_cache","Map","undefined","toString","indexOf","has","get","Wrapper","enumerable","_array_like_to_array","arr","len","arr2","Array","_create_for_of_iterator_helper_loose","allowArrayLike","it","iterator","next","isArray","_unsupported_iterable_to_array","minLen","n","slice","name","from","test","done","VisitorContext","_lookupSymbol","SymbolInfo","_structRoles","_vertexUnresolvedVariableRoles","_fragmentUnresolvedVariableRoles","_vertexAmbiguousVariableNames","Set","_fragmentAmbiguousVariableNames","attributeStructs","attributeList","varyingStructs","varyingList","mrtStructs","mrtList","_referencedGlobalSymbols","_referencedGlobalMacroASTs","_structVariableRoles","codeCache","fragmentReturnModes","terminalInterfaceReturns","reset","resetAll","clear","_referencedAttributeList","_referencedVaryingList","_referencedMRTList","_referencedGlobals","_globalSymbolQueries","_passSymbolTable","getStructRole","declarations","resolvedRole","_step","_iterator","declaration","role","hasStructRole","registerStructTypes","structs","struct","registerStructVar","variable","stage","roles","EShaderStage","VERTEX","ambiguous","ident","existing","delete","add","getUnresolvedStructVarRole","variableName","getStructVarRole","symbols","symbol","VarSymbol","registerFragmentReturn","statement","mode","getFragmentReturnMode","registerTerminalInterfaceReturn","isTerminalInterfaceReturn","referenceAttribute","_referenceProp","lexeme","referenceVarying","referenceMRTProp","referenceGlobal","type","queries","_this__globalSymbolQueries","getSymbols","_this__referencedGlobals","namedSymbols","_1","onReferenceGlobal","_proto","list","refList","filter","item","onReferenceStructProps","TempArray","array","dispose","CodeGenVisitor","context","cache","node","code","getCachedCode","defaultCodeGen","children","pool","_tmpArrayPool","ret","child","BaseToken","codeGen","join","return","visitPostfixExpression","derivationLength","postExpr","prop","directRoot","ParserUtils","unwrapBareIdentifier","allowParens","resolvedValueSymbols","unresolvedName","extractDirectIdentLexeme","ShaderStructRole","Attribute","Varying","identNode","indexNode","visitVariableIdentifier","referenceGlobalSymbolNames","ESymbolType","Any","_step1","resolvedSymbols","_iterator1","FnSymbol","referenceFunction","location","index","_branch","getLexeme","referenceIndex","branch","FN","visitFunctionCall","fnSymbol","fnSymbols","paramList","ASTNode","FunctionCallParameterList","astNodes","paramNodes","finalSymbol","find","candidate","equal","paramInfoList","astNode","protoType","parameterList","params","parameter","ParameterDeclaration","paramsCode","MacroCallArgBlock","visitMacroCallFunction","isFunctionLikeMacro","aliasesNonBuiltinIdent","arg","AssignmentExpression","variableParam","argNode","macroName","visitStatementList","visitMacroDefine","paramsLexeme","isFunction","paramsToken","valueCode","valueExpression","visitSingleDeclaration","visitGlobalVariableDeclaration","fullType","FullySpecifiedType","typeSpecifier","isCustom","declarator","STRUCT","visitDeclaration","InitDeclaratorList","first","SingleDeclaration","Mrt","visitFunctionParameterList","parameterInfoList","out","MacroParamBlock","visitFunctionHeader","returnType","structDeclarations","visitJumpStatement","cmd","Keyword","RETURN","expr","Expression","returnVar","unwrapNodeByType","NoneTerminal","variable_identifier","returnFnCall","function_call","calledFunction","returnDeclarations","visitFunctionIdentifier","visitTypeSpecifier","visitStructSpecifier","isVaryingStruct","isAttributeStruct","isMRTStruct","macroExpressions","map","text","_this","propList","getVaryingProp","getAttributeProp","getMRTProp","sort","b","visitFunctionDefinition","fnNode","fnName","terminal","lastStatement","statements","JumpStatement","stageEntry","ReturnableObjectPool","ShaderInstructionEncoder","owner","activate","activation","id","group","sourceScope","sharedDeclaration","owners","reference","to","replace","parse","glsl","preprocessorExpressions","instructions","pos","backfillStack","directiveStart","_findDirectiveStart","_pushText","lineEnd","_findLogicalLineEnd","line","substring","charCodeAt","kind","charAt","fields","split","Number","ShaderPreprocessorDirective","Declaration","Reference","ids","match","_DIRECTIVE_RE","exec","keyword","rest","trim","idx","IfDef","IfNdef","cond","_parseCondition","_pushConditionInstruction","stack","prevIdx","elseIdx","Else","_backfillJump","endifIdx","Endif","pop","afterEndif","j","inst","funcMatch","_FUNC_MACRO_RE","DefineFunc","_stripLineComment","separator","_findInlineWhitespace","Define","DefineVal","Undef","t","m","IfCmp","op","v","IfExpr","expression","parsePreprocessorExpression","error","certain","hasExpandableIdentifier","e","Error","message","evaluationError","compact","toPreprocessorCondition","condition","c","nl","beforeBreak","charCode","last","directive","Text","OwnedText","every","concat","onlyPlaceholder","s","trimEnd","GLESVisitor","_globalCodeArray","_forwardFunctionDeclarations","_forwardStructIndices","_structCodeSegments","_forwardVariableIndices","_variableCodeSegments","_declarationOwners","_deferredPrototypes","_declarationReferences","_outerMacroDeclarations","protoProps","globalCodeArray","_currentDeclaration","getOtherGlobal","data","globalPrecisions","precision","generate","ir","coreInfo","shaderData","program","symbolTable","outerGlobalMacroDeclarations","io","structVariableRoles","forEach","vertexStructVariableRoles","fragmentStructVariableRoles","FRAGMENT","_sourceIR","deferredDeclarationOwnership","size","nextId","nextGroup","Math","max","_this_currentDeclarationOwner","_this_currentDeclarationOwner_id","currentDeclarationOwner","_referenceDeclaration","propDeclarations","props","unsupportedDeferredDeclarations","mapExpandedShaderError","GSError","GSErrorName","CompilationError","sourceMap","vertex","_vertexMain","vertexEntry","fragment","_fragmentMain","fragmentEntry","entryInfo","_preRegisterGlobalMacroRefs","_getGlobalSymbol","_getCustomStruct","_getGlobalMacroDeclarations","_emitDeclarationReferences","globalCode","outerGlobalMacroStatements","prepareFragment","functions","VEC4","some","_registerFragmentReturns","macros","macro","_walkMacroDefineTokens","MacroDefine","TreeNode","previous","FunctionDefinition","sm","codeGenResult","VAR","isInMacroBranch","segment","_declaration","StructSpecifier","VariableDeclaration","_getForwardDeclarations","values","_step2","_iterator2","definition","candidates","replacement","nextOwner","_this1","anchor","_isContextIndependent","_hasDeclarationContextBarrier","_unsupportedForwardDeclaration","outer","typeAnchor","_prepareForwardTypes","typeInfo","compatible","_canBranchesOverlap","branchSignature","canInheritanceBranchesCover","preceding","signature","_getForwardSignature","outerMacro","parameters","_loop","tokens","visit","IN","getLexicalDeclarationCoexistence","isUniform","_this_context__referencedGlobals_symbol_ident","includes","oldMacro","_this__forwardVariableIndices_get","dataType","min","Infinity","guarded","entry","splice","_step3","segments","_iterator3","parent","FunctionIdentifier","FunctionCallGeneric","structDependencies","GlobalDeclaration","final","types","hoistAnchor","_this__forwardStructIndices_get","needsHoist","dependencyAnchor","property","VariableIdentifier","MacroCallSymbol","MacroCallFunction","TypeSpecifier","MACRO_IF","MACRO_DEFINE_PARAMS","includeMacros","inFunction","PrecisionSpecifier","MACRO_UNDEF","MACRO_DEFINE_EXPRESSION","structNodes","referencedGlobalMacroASTs","GlobalMacroIfStatement","_visitGlobalMacroIfStatement","_this_getCachedCode","VariableDeclarationList","variableDeclarations","_this_getCachedCode1","variableDeclaration","targets","_defineProperties","descriptor","defineProperty","Constructor","GLES100Visitor","typeLexeme","PostfixExpression","directSymbols","directRole","propReferenced","mrtIndex","assignment","V3_GL_FragColor","V3_GL_FragData","GLES300Visitor","_outputDeclarations","_fragDataArrayRequired","_fragDataIndices","_scannedFragmentFunctions","output","unconditional","qualifier","builtinSemantic","ShaderBuiltinSemantic","FragmentOutput0","_registerFragColorVariable","FragmentDepth","FragmentOutputArray","_registerFragDataArray","_registerFragDataVariable","_registerOutput","pending","fn","_scanFragmentOutputs","calledFunctions","base","constIntegerValue","GLESBackend","glesInfo","GLESShaderInfo","mrtOutputIssues","invalidMrtReturnLocations","Logger","invalidVaryingReturnLocations","structMemberOwnerIssues","ShaderLanguage","GLSLES100","_generateWithPool","_gles100VisitorPool","_gles300VisitorPool","visitor","file","ShaderSourceParseError","Error1","errors","generateParsedShaderPassData","parsed","backend","blockingErrors","resolvedCoreInfo","ShaderCoreInfo","generateShaderProgram","hasDefiniteAmbiguity","roleConflicts","vertexShaderInstructions","fragmentShaderInstructions","ShaderCompiler","_includeMap","_chunkOutputCache","_sourceParserObjectPool","ParserObjectPool","_parserObjectPool","_runtimeParser","createRuntimeShaderTargetParser","_setIncludeMap","includeMap","normalizeShaderIncludeMap","_parseShaderSource","sourceCode","requireValidShaderSource","shaderSource","ShaderSourceParser","parseStrict","_parseShaderPass","sourceFile","sourceScopeStarts","parseRuntimeShaderPass","pass","getParsedShaderPassPayload","version","info"],"mappings":"saAAA,SAASA,EAAYC,CAAI,CAAEC,CAAK,SAC5B,AAAIA,AAAS,MAATA,GAAiB,AAAkB,aAAlB,OAAOC,QAA0BD,CAAK,CAACC,OAAOC,WAAW,CAAC,CACpE,CAAC,CAACF,CAAK,CAACC,OAAOC,WAAW,CAAC,CAACH,GACzBA,aAAgBC,CAClC,CCJA,SAASG,IAUL,MAAOA,AATPA,CAAAA,EAAWC,OAAOC,MAAM,EAAI,SAAgBC,CAAM,EAC9C,IAAK,IAAIC,EAAI,EAAGA,EAAIC,UAAUC,MAAM,CAAEF,IAAK,CACvC,IAAIG,EAASF,SAAS,CAACD,EAAE,CACzB,IAAK,IAAII,KAAOD,EAAYN,OAAOQ,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,EAAQC,IAAML,CAAAA,CAAM,CAACK,EAAI,CAAGD,CAAM,CAACC,EAAI,AAAD,CAC1G,CAED,OAAOL,CACf,CAAA,EAEoBS,KAAK,CAAC,IAAI,CAAEP,UAChC,ggUCLO,IAAMQ,EAAN,WAAMA,SAAAA,IAAAA,CAAAA,OAYXC,AAZWD,EAAAA,S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a,GAE0CnM,EAAaG,EAAeoK,EAC1E,EASAzM,EAAAA,QAGC,CAHDA,SAASuO,CAAsB,CAAE9B,CAAuB,EACtD,IAAuD+B,EAAAA,kGAA2BD,GAClF,OAAOhC,GADgDiC,EAA/C3O,IAAAA,CAA+C2O,EAAzCtM,WAAaG,CAA4BmM,EAA5BnM,aAAAA,CAC2CoK,EADf+B,EAAbtO,QAAAA,CAE5C,EAtEWgN,CAuEZ,ICrFYuB,GAAW,iBAExB/C,EAAAA,MAAOgD,CAAAA,IAAI,CAAE,4CAA2CD"}
|
|
1
|
+
{"version":3,"file":"browser.min.js","sources":["../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_instanceof.js","../../design/dist/module.js","../../shader-parser/dist/shared/GLESShaderInfo.module.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_type_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_set_prototype_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_inherits.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_is_native_reflect_construct.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_construct.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_get_prototype_of.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_wrap_native_super.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_is_native_function.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_array_like_to_array.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_for_of_iterator_helper_loose.js","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_unsupported_iterable_to_array.js","../src/codeGen/NameAllocator.ts","../src/codeGen/VisitorContext.ts","../src/TempArray.ts","../src/codeGen/CodeGenVisitor.ts","../src/ShaderInstructionEncoder.ts","../src/codeGen/GLESVisitor.ts","../../../node_modules/.pnpm/@swc+helpers@0.5.15/node_modules/@swc/helpers/esm/_create_class.js","../src/codeGen/GLES100.ts","../src/codeGen/GLES300.ts","../src/GLESBackend.ts","../src/ShaderCompilation.ts","../src/ShaderCompiler.ts","../src/index.ts"],"sourcesContent":["function _instanceof(left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return !!right[Symbol.hasInstance](left);\n } else return left instanceof right;\n}\nexport { _instanceof as _ };\n","function _extends() {\n _extends = Object.assign || function assign(target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) if (Object.prototype.hasOwnProperty.call(source, key)) target[key] = source[key];\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction _type_of(obj) {\n \"@swc/helpers - typeof\";\n\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\n\nfunction _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\n\nvar binaryPrecedence = {\n \"||\": 1,\n \"&&\": 2,\n \"|\": 3,\n \"^\": 4,\n \"&\": 5,\n \"==\": 6,\n \"!=\": 6,\n \"<\": 7,\n \"<=\": 7,\n \">\": 7,\n \">=\": 7,\n \"<<\": 8,\n \">>\": 8,\n \"+\": 9,\n \"-\": 9,\n \"*\": 10,\n \"/\": 10,\n \"%\": 10\n};\nvar MAX_EXPRESSION_NESTING = 256;\nvar MAX_MACRO_EXPANSION_DEPTH = 256;\nvar MAX_MACRO_EXPANSION_TOKENS = 65536;\n/**\n * Parses the complete integer-expression grammar used by `#if` and `#elif`.\n * @param expression - Text after the preprocessor directive.\n * @returns A serializable tree or a structured parse failure.\n */ function parsePreprocessorExpression(expression) {\n return new ExpressionParser(expression).parse();\n}\n/**\n * Resolves `defined` operators and removes comments with the expression parser's tokenization rules.\n * @param expression - Expression before ordinary macro replacement.\n * @param isDefined - Resolves whether one macro name is defined, or returns `undefined` when external state decides.\n * @returns Token-normalized expression with every known `defined` operator replaced by `0` or `1`.\n */ function resolvePreprocessorDefinedOperators(expression, isDefined) {\n var tokens = tokenize(expression);\n var parts = [];\n for(var index = 0; index < tokens.length - 1; index++){\n var token = tokens[index];\n if (token.kind !== \"identifier\" || token.text !== \"defined\") {\n parts.push(token.text);\n continue;\n }\n var next = tokens[index + 1];\n var parenthesized = (next == null ? void 0 : next.text) === \"(\";\n var name = tokens[index + (parenthesized ? 2 : 1)];\n var close = parenthesized ? tokens[index + 3] : name;\n if ((name == null ? void 0 : name.kind) !== \"identifier\" || name.text === \"defined\" || parenthesized && (close == null ? void 0 : close.text) !== \")\") {\n parts.push(token.text);\n continue;\n }\n var defined = isDefined(name.text);\n if (defined === undefined) {\n parts.push(\"defined\");\n if (parenthesized) parts.push(\"(\");\n parts.push(name.text);\n if (parenthesized) parts.push(\")\");\n } else {\n parts.push(defined ? \"1\" : \"0\");\n }\n index += parenthesized ? 3 : 1;\n }\n return parts.join(\" \");\n}\n/**\n * Expands object-like and function-like macros with the expression parser's tokenization rules.\n * @param expression - Expression after any caller-owned `defined` resolution.\n * @param resolveMacro - Resolves source or runtime macro definitions by name.\n * @returns Token-normalized expansion or a deterministic depth error.\n */ function expandPreprocessorExpressionMacros(expression, resolveMacro) {\n var expanded = expandMacroTokens(tokenize(expression).slice(0, -1), resolveMacro, tokenize, true, 0, {\n remaining: MAX_MACRO_EXPANSION_TOKENS\n });\n return typeof expanded === \"string\" ? {\n expression: \"\",\n error: expanded\n } : {\n expression: expanded.map(function(token) {\n return token.text;\n }).join(\" \")\n };\n}\n/**\n * Expands shader macros using the same argument prescan and rescan rules as conditional expressions.\n * @param source - Shader text without macro definition or conditional directives.\n * @param resolveMacro - Resolves the macro state active at this source location.\n * @returns Expanded shader source, or a deterministic expansion-limit error.\n */ function expandShaderMacros(source, resolveMacro) {\n var expanded = expandMacroTokens(tokenizeShader(source).slice(0, -1), resolveMacro, tokenizeShaderReplacement, false, 0, {\n remaining: MAX_MACRO_EXPANSION_TOKENS\n });\n return typeof expanded === \"string\" ? {\n source: \"\",\n error: expanded\n } : {\n source: serializeShaderTokens(expanded)\n };\n}\nfunction expandMacroTokens(input, resolveMacro, tokenizeReplacement, protectDefined, depth, budget) {\n var tokens = input.slice();\n var output = [];\n var index = 0;\n while(index < tokens.length){\n var // Rescan in place so an object alias can form a call with the following original tokens\n _tokens;\n var _token_disabledMacros, _tokens_openParen;\n var token = tokens[index];\n if (protectDefined && token.text === \"defined\") {\n var _tokens_index;\n output.push(token);\n index++;\n var count = ((_tokens_index = tokens[index]) == null ? void 0 : _tokens_index.text) === \"(\" ? 3 : 1;\n for(var i = 0; i < count && index < tokens.length; i++)output.push(tokens[index++]);\n continue;\n }\n var macro = token.kind === \"identifier\" && !((_token_disabledMacros = token.disabledMacros) == null ? void 0 : _token_disabledMacros.has(token.text)) ? resolveMacro(token.text) : undefined;\n var openParen = index + 1;\n if (macro == null ? void 0 : macro.parameters) {\n var _tokens_openParen1;\n while(((_tokens_openParen1 = tokens[openParen]) == null ? void 0 : _tokens_openParen1.kind) === \"trivia\")openParen++;\n }\n if (!macro || macro.parameters && ((_tokens_openParen = tokens[openParen]) == null ? void 0 : _tokens_openParen.text) !== \"(\") {\n output.push(token);\n index++;\n continue;\n }\n var _token_expansionDepth;\n var expansionDepth = Math.max(depth, (_token_expansionDepth = token.expansionDepth) != null ? _token_expansionDepth : 0) + 1;\n if (expansionDepth > MAX_MACRO_EXPANSION_DEPTH) {\n return \"Preprocessor macro expansion exceeds \" + MAX_MACRO_EXPANSION_DEPTH + \" nested replacements.\";\n }\n var invocationEnd = index;\n var args = [];\n var disabledMacros = new Set(token.disabledMacros);\n if (macro.parameters) {\n var invocation = parseMacroInvocation(tokens, openParen);\n if (!invocation) {\n output.push(token);\n index++;\n continue;\n }\n args = invocation.arguments;\n if (macro.parameters.length === 0 && args.length === 1 && args[0].every(function(token) {\n return token.kind === \"trivia\";\n })) {\n args = [];\n }\n if (args.length !== macro.parameters.length) {\n output.push(token);\n index++;\n continue;\n }\n invocationEnd = invocation.end;\n // A function invocation inherits only exclusions present at both invocation boundaries\n var closingExclusions = tokens[invocationEnd].disabledMacros;\n for(var _iterator = _create_for_of_iterator_helper_loose(disabledMacros), _step; !(_step = _iterator()).done;){\n var name = _step.value;\n if (!(closingExclusions == null ? void 0 : closingExclusions.has(name))) disabledMacros.delete(name);\n }\n }\n disabledMacros.add(token.text);\n var replacement = [];\n var expandedArguments = new Map();\n for(var _iterator1 = _create_for_of_iterator_helper_loose(tokenizeReplacement(macro.body).slice(0, -1)), _step1; !(_step1 = _iterator1()).done;){\n var _loop = function() {\n var part = _step2.value;\n var _part_disabledMacros;\n if (--budget.remaining < 0) return {\n v: \"Preprocessor macro expansion exceeds \" + MAX_MACRO_EXPANSION_TOKENS + \" replacement tokens.\"\n };\n // Only macro names and invocation closing boundaries carry exclusions into later rescans.\n if (part.kind !== \"identifier\" && part.text !== \")\") {\n replacement.push(part);\n return \"continue\";\n }\n var exclusions = disabledMacros;\n if ((_part_disabledMacros = part.disabledMacros) == null ? void 0 : _part_disabledMacros.size) {\n exclusions = new Set(disabledMacros);\n part.disabledMacros.forEach(function(name) {\n return exclusions.add(name);\n });\n }\n var _part_expansionDepth;\n replacement.push(_extends({}, part, {\n disabledMacros: exclusions,\n expansionDepth: Math.max(expansionDepth, (_part_expansionDepth = part.expansionDepth) != null ? _part_expansionDepth : 0)\n }));\n };\n var bodyToken = _step1.value;\n var _macro_parameters;\n var _macro_parameters_indexOf;\n var parameter = bodyToken.kind === \"identifier\" ? (_macro_parameters_indexOf = (_macro_parameters = macro.parameters) == null ? void 0 : _macro_parameters.indexOf(bodyToken.text)) != null ? _macro_parameters_indexOf : -1 : -1;\n var substituted = [\n bodyToken\n ];\n if (parameter >= 0) {\n var argument = expandedArguments.get(parameter);\n if (!argument) {\n // Arguments expand before this invocation disables its own name, including ID(ID(1))\n var expanded = expandMacroTokens(args[parameter], resolveMacro, tokenizeReplacement, protectDefined, expansionDepth, budget);\n if (typeof expanded === \"string\") return expanded;\n expandedArguments.set(parameter, argument = expanded);\n }\n substituted = argument;\n }\n for(var _iterator2 = _create_for_of_iterator_helper_loose(substituted), _step2; !(_step2 = _iterator2()).done;){\n var _ret = _loop();\n if (_type_of(_ret) === \"object\") return _ret.v;\n }\n }\n (_tokens = tokens).splice.apply(_tokens, [].concat([\n index,\n invocationEnd - index + 1\n ], replacement));\n }\n return output;\n}\nvar shaderMultiOperators = new Set([\n \"<<=\",\n \">>=\",\n \"++\",\n \"--\",\n \"<<\",\n \">>\",\n \"<=\",\n \">=\",\n \"==\",\n \"!=\",\n \"&&\",\n \"||\",\n \"^^\",\n \"+=\",\n \"-=\",\n \"*=\",\n \"/=\",\n \"%=\",\n \"&=\",\n \"^=\",\n \"|=\",\n \"##\"\n]);\n// Shader replacement lists use preprocessing numbers, not the integer-only #if grammar.\nfunction tokenizeShader(source, removeComments) {\n if (removeComments === void 0) removeComments = false;\n var tokens = [];\n var index = 0;\n while(index < source.length){\n var start = index;\n var char = source.charCodeAt(index++);\n var kind = void 0;\n var comment = false;\n var _source_index;\n if (isWhitespace(char)) {\n kind = \"trivia\";\n while(isWhitespace(source.charCodeAt(index)))index++;\n } else if (char === 47 && source[index] === \"/\") {\n kind = \"trivia\";\n comment = true;\n while(index < source.length && source[index] !== \"\\n\" && source[index] !== \"\\r\")index++;\n } else if (char === 47 && source[index] === \"*\") {\n kind = \"trivia\";\n comment = true;\n var close = source.indexOf(\"*/\", index + 1);\n index = close < 0 ? source.length : close + 2;\n } else if (char === 34 || char === 39) {\n kind = \"invalid\";\n while(index < source.length){\n var next = source.charCodeAt(index++);\n if (next === 92) index = Math.min(index + 1, source.length);\n else if (next === char) break;\n }\n } else if (isIdentifierStart(char)) {\n kind = \"identifier\";\n while(isIdentifierPart(source.charCodeAt(index)))index++;\n } else if (char >= 48 && char <= 57 || char === 46 && /[0-9]/.test((_source_index = source[index]) != null ? _source_index : \"\")) {\n kind = \"number\";\n while(index < source.length){\n var next1 = source.charCodeAt(index);\n if (isIdentifierPart(next1) || next1 === 46) index++;\n else if ((next1 === 43 || next1 === 45) && /[eEpP]/.test(source[index - 1])) index++;\n else break;\n }\n } else {\n kind = \"operator\";\n if (char === 60 || char === 62) {\n if (shaderMultiOperators.has(source.slice(start, start + 3))) index = start + 3;\n else if (shaderMultiOperators.has(source.slice(start, start + 2))) index = start + 2;\n } else if (\"+-*/%&|^!=#\".includes(source[start]) && shaderMultiOperators.has(source.slice(start, start + 2))) {\n index = start + 2;\n }\n }\n var text = source.slice(start, index);\n tokens.push({\n kind: kind,\n text: removeComments && comment ? text.replace(/[^\\r\\n]/g, \"\") || \" \" : text,\n start: start,\n end: index\n });\n }\n tokens.push({\n kind: \"end\",\n text: \"\",\n start: index,\n end: index\n });\n return tokens;\n}\nfunction tokenizeShaderReplacement(source) {\n // A comment in a replacement list is whitespace; a trailing // must not swallow the caller's suffix.\n return tokenizeShader(source, true);\n}\nfunction serializeShaderTokens(tokens) {\n var parts = [];\n var previous;\n for(var _iterator = _create_for_of_iterator_helper_loose(tokens), _step; !(_step = _iterator()).done;){\n var token = _step.value;\n if (previous && previous.kind !== \"trivia\" && token.kind !== \"trivia\") {\n var word = previous.kind === \"identifier\" || previous.kind === \"number\";\n var nextWord = token.kind === \"identifier\" || token.kind === \"number\";\n var joined = previous.kind === \"operator\" && token.kind === \"operator\" ? previous.text + token.text : \"\";\n // Replacement must not join two preprocessing tokens into a new number, operator or comment.\n if (word && nextWord || previous.kind === \"number\" && (token.text === \".\" || /[eEpP]$/.test(previous.text) && /^[+-]/.test(token.text)) || previous.text === \".\" && token.kind === \"number\" || joined && previous.text.length < 2 && shaderMultiOperators.has(joined.slice(0, 2)) || joined && previous.text.length < 3 && shaderMultiOperators.has(joined.slice(0, 3)) || joined.startsWith(\"//\") || joined.startsWith(\"/*\")) parts.push(\" \");\n }\n parts.push(token.text);\n previous = token;\n }\n return parts.join(\"\");\n}\nfunction parseMacroInvocation(tokens, openParen) {\n var args = [\n []\n ];\n var depth = 1;\n for(var index = openParen + 1; index < tokens.length; index++){\n var token = tokens[index];\n if (token.text === \"(\") {\n depth++;\n args[args.length - 1].push(token);\n } else if (token.text === \")\") {\n if (--depth === 0) {\n for(var _iterator = _create_for_of_iterator_helper_loose(args), _step; !(_step = _iterator()).done;){\n var argument = _step.value;\n trimMacroArgument(argument);\n }\n return {\n arguments: args,\n end: index\n };\n }\n args[args.length - 1].push(token);\n } else if (token.text === \",\" && depth === 1) {\n args.push([]);\n } else {\n args[args.length - 1].push(token);\n }\n }\n}\nfunction trimMacroArgument(tokens) {\n // Call-site padding is not part of the replacement. Keep comments and line breaks intact.\n for(var _i = 0, _iter = [\n false,\n true\n ]; _i < _iter.length; _i++){\n var trailing = _iter[_i];\n while(tokens.length){\n var index = trailing ? tokens.length - 1 : 0;\n var token = tokens[index];\n if (token.kind !== \"trivia\") break;\n var text = token.text.replace(trailing ? /[ \\t\\v\\f]+$/ : /^[ \\t\\v\\f]+/, \"\");\n if (text === token.text) break;\n if (text) {\n tokens[index] = _extends({}, token, {\n text: text\n });\n break;\n }\n if (trailing) tokens.pop();\n else tokens.shift();\n }\n }\n}\n/**\n * Evaluates an expression whose result is independent of macro state.\n * @param expression - Complete preprocessor expression text.\n * @returns 32-bit result, or `undefined` when the expression is invalid, state-dependent, or unevaluable.\n */ function evaluateContextFreePreprocessorExpression(expression) {\n var parsed = parsePreprocessorExpression(expression);\n return parsed.ok ? evaluateContextFreePreprocessorCondition(parsed.condition) : undefined;\n}\n/**\n * Evaluates a parsed condition whose result is independent of macro state.\n * @param condition - Parsed preprocessor expression tree.\n * @returns 32-bit result, or `undefined` when macro state or an invalid operation affects the result.\n */ function evaluateContextFreePreprocessorCondition(condition) {\n var evaluated = evaluateStaticallyKnownPreprocessorCondition(condition);\n return typeof evaluated === \"number\" ? evaluated : undefined;\n}\n/**\n * Evaluates the part of a preprocessor expression determined by known source macro state.\n * @param condition - Parsed preprocessor expression tree.\n * @param context - Partially known macro values and definition states.\n * @returns 32-bit result, or `undefined` when any reachable input remains unknown.\n */ function evaluatePartiallyKnownPreprocessorCondition(condition, context) {\n return evaluatePartiallyKnownPreprocessorConditionResult(condition, context).value;\n}\n/**\n * Evaluates the known portion of an expression while preserving definite evaluation failures.\n * @param condition - Parsed preprocessor expression tree.\n * @param context - Partially known macro values and definition states.\n * @returns Known value, definite error, or an empty result when external state still matters.\n */ function evaluatePartiallyKnownPreprocessorConditionResult(condition, context) {\n var evaluated = evaluateStaticallyKnownPreprocessorCondition(condition, context);\n return typeof evaluated === \"number\" ? {\n value: evaluated\n } : typeof evaluated === \"string\" ? {\n error: evaluated\n } : {};\n}\n/**\n * Evaluates a parsed preprocessor expression with signed 32-bit arithmetic matching ANGLE's preprocessor.\n * @param condition - Serializable expression tree.\n * @param context - Active macro value and definition resolver.\n * @returns Signed 32-bit result; nonzero values are true.\n * @throws Error when an active expression divides by zero or contains a deferred node.\n */ function evaluatePreprocessorExpression(condition, context) {\n var evaluated = evaluatePreprocessorExpressionInternal(condition, context);\n if (typeof evaluated === \"string\") throw new Error(evaluated);\n return evaluated;\n}\nvar DIVISION_BY_ZERO_ERROR = \"Division by zero in active preprocessor expression.\";\nvar MODULO_BY_ZERO_ERROR = \"Modulo by zero in active preprocessor expression.\";\nvar INVALID_SHIFT_COUNT_ERROR = \"Shift count must be between 0 and 31 in active preprocessor expression.\";\nfunction evaluatePreprocessorExpressionInternal(condition, context) {\n switch(condition.t){\n case \"def\":\n return context.isDefined(condition.m) ? 1 : 0;\n case \"ndef\":\n return context.isDefined(condition.m) ? 0 : 1;\n case \"cmp\":\n return evaluateBinaryExpression(context.resolveIdentifier(condition.m), condition.op, condition.v);\n case \"and\":\n {\n var left = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left === \"string\" || left === 0) return left;\n var right = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right === \"string\" ? right : right !== 0 ? 1 : 0;\n }\n case \"or\":\n {\n var left1 = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left1 === \"string\") return left1;\n if (left1 !== 0) return 1;\n var right1 = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right1 === \"string\" ? right1 : right1 !== 0 ? 1 : 0;\n }\n case \"not\":\n {\n var value = evaluatePreprocessorExpressionInternal(condition.c, context);\n return typeof value === \"string\" ? value : value === 0 ? 1 : 0;\n }\n case \"bool\":\n return condition.v ? 1 : 0;\n case \"num\":\n return condition.v;\n case \"id\":\n return context.resolveIdentifier(condition.m);\n case \"unary\":\n {\n var value1 = evaluatePreprocessorExpressionInternal(condition.c, context);\n if (typeof value1 === \"string\") return value1;\n return condition.op === \"+\" ? value1 | 0 : condition.op === \"-\" ? -value1 | 0 : ~value1;\n }\n case \"binary\":\n {\n var left2 = evaluatePreprocessorExpressionInternal(condition.l, context);\n if (typeof left2 === \"string\") return left2;\n var right2 = evaluatePreprocessorExpressionInternal(condition.r, context);\n return typeof right2 === \"string\" ? right2 : evaluateBinaryExpression(left2, condition.op, right2);\n }\n case \"deferred\":\n return \"Deferred preprocessor expressions must be expanded before evaluation.\";\n }\n}\nvar ExpressionParser = /*#__PURE__*/ function() {\n function ExpressionParser(expression) {\n this._index = 0;\n this._sawExpandableIdentifier = false;\n this._rightEdgeExpandable = false;\n this._nestingDepth = 0;\n this._tokens = tokenize(expression);\n }\n var _proto = ExpressionParser.prototype;\n _proto.parse = function parse() {\n var condition = this._parseRoot();\n var invalid = this._invalidResult();\n if (invalid) return invalid;\n var evaluated = this._sawExpandableIdentifier ? undefined : evaluateStaticallyKnownPreprocessorCondition(condition);\n return _extends({\n ok: true,\n condition: condition,\n hasExpandableIdentifier: this._sawExpandableIdentifier\n }, typeof evaluated === \"string\" ? {\n evaluationError: evaluated\n } : undefined);\n };\n _proto._parseRoot = function _parseRoot() {\n var condition = this._parseBinary(1);\n if (!this._failure) {\n var token = this._current();\n if (token.kind !== \"end\") {\n var unexpectedExpandableIdentifier = token.kind === \"identifier\" && token.text !== \"defined\";\n this._sawExpandableIdentifier || (this._sawExpandableIdentifier = unexpectedExpandableIdentifier);\n var unsupportedConditionalOperator = token.text === \"?\" || token.text === \":\";\n var certain = unsupportedConditionalOperator || !this._rightEdgeExpandable && !unexpectedExpandableIdentifier && !(token.text === \")\" && this._sawExpandableIdentifier);\n this._fail(\"Unexpected token '\" + token.text + \"' in preprocessor expression.\", token, certain);\n }\n }\n return condition;\n };\n _proto._invalidResult = function _invalidResult() {\n if (this._failure) {\n // A macro supplying a closing delimiter may be the token where parsing stopped.\n for(var i = this._index; i < this._tokens.length; i++){\n var token = this._tokens[i];\n if (token.kind === \"identifier\" && token.text !== \"defined\") {\n this._sawExpandableIdentifier = true;\n break;\n }\n }\n }\n return this._failure ? {\n ok: false,\n error: this._failure,\n hasExpandableIdentifier: this._sawExpandableIdentifier\n } : undefined;\n };\n _proto._parseBinary = function _parseBinary(minPrecedence) {\n var left = this._parseUnary();\n if (this._failure || !left) return undefined;\n while(true){\n var token = this._current();\n var precedence = binaryPrecedence[token.text];\n if (precedence === undefined || precedence < minPrecedence) return left;\n this._index++;\n var right = this._parseBinary(precedence + 1);\n if (this._failure || !right) return undefined;\n if (token.text === \"&&\") left = {\n t: \"and\",\n l: left,\n r: right\n };\n else if (token.text === \"||\") left = {\n t: \"or\",\n l: left,\n r: right\n };\n else left = {\n t: \"binary\",\n op: token.text,\n l: left,\n r: right\n };\n }\n };\n _proto._parseUnary = function _parseUnary() {\n var token = this._current();\n if (token.kind === \"operator\" && (token.text === \"+\" || token.text === \"-\" || token.text === \"!\" || token.text === \"~\")) {\n if (!this._enterNesting(token)) return;\n this._index++;\n var condition = this._parseUnary();\n this._nestingDepth--;\n if (!condition) return undefined;\n return token.text === \"!\" ? {\n t: \"not\",\n c: condition\n } : {\n t: \"unary\",\n op: token.text,\n c: condition\n };\n }\n return this._parsePrimary();\n };\n _proto._parsePrimary = function _parsePrimary() {\n var token = this._current();\n if (token.kind === \"number\") {\n this._index++;\n this._rightEdgeExpandable = false;\n var value = parseIntegerLiteral(token.text);\n if (value === undefined) {\n this._fail(\"Integer literal exceeds 32 bits in preprocessor expression.\", token, true);\n return undefined;\n }\n return {\n t: \"num\",\n v: value\n };\n }\n if (token.kind === \"identifier\") {\n if (token.text === \"defined\") return this._parseDefined();\n this._sawExpandableIdentifier = true;\n this._rightEdgeExpandable = true;\n this._index++;\n return {\n t: \"id\",\n m: token.text\n };\n }\n if (this._consume(\"(\")) {\n if (!this._enterNesting(token)) return;\n var condition = this._parseBinary(1);\n if (!this._failure && !this._consume(\")\")) {\n this._fail(\"Expected ')' in preprocessor expression.\", this._current(), false);\n }\n if (!this._failure) this._rightEdgeExpandable = false;\n this._nestingDepth--;\n return condition;\n }\n if (token.kind === \"end\") {\n this._fail(\"Expected an operand before the end of the preprocessor expression.\", token, true);\n } else {\n this._fail(\"Expected an operand, found '\" + token.text + \"'.\", token, true);\n }\n return undefined;\n };\n _proto._parseDefined = function _parseDefined() {\n this._index++;\n this._rightEdgeExpandable = false;\n var parenthesized = this._consume(\"(\");\n var name = this._current();\n if (name.kind !== \"identifier\" || name.text === \"defined\") {\n this._fail(\"Expected a macro name after 'defined'.\", name, true);\n return undefined;\n }\n this._index++;\n if (parenthesized && !this._consume(\")\")) {\n this._fail(\"Expected ')' after the macro name in 'defined(...)'.\", this._current(), true);\n return undefined;\n }\n return {\n t: \"def\",\n m: name.text\n };\n };\n _proto._consume = function _consume(text) {\n if (this._current().text !== text) return false;\n this._index++;\n return true;\n };\n _proto._enterNesting = function _enterNesting(token) {\n if (this._nestingDepth >= MAX_EXPRESSION_NESTING) {\n this._fail(\"Preprocessor expression nesting exceeds the supported depth of \" + MAX_EXPRESSION_NESTING + \".\", token, true);\n return false;\n }\n this._nestingDepth++;\n return true;\n };\n _proto._current = function _current() {\n return this._tokens[this._index];\n };\n _proto._fail = function _fail(message, token, certain) {\n var _this__failure;\n (_this__failure = this._failure) != null ? _this__failure : this._failure = {\n message: message,\n start: token.start,\n end: Math.max(token.end, token.start + 1),\n certain: certain\n };\n };\n return ExpressionParser;\n}();\nfunction tokenize(expression) {\n var tokens = [];\n var index = 0;\n while(index < expression.length){\n var charCode = expression.charCodeAt(index);\n if (isWhitespace(charCode)) {\n index++;\n continue;\n }\n if (charCode === 47 && expression.charCodeAt(index + 1) === 47) break;\n if (charCode === 47 && expression.charCodeAt(index + 1) === 42) {\n var end = expression.indexOf(\"*/\", index + 2);\n if (end < 0) {\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(index),\n start: index,\n end: expression.length\n });\n index = expression.length;\n } else {\n index = end + 2;\n }\n continue;\n }\n if (isIdentifierStart(charCode)) {\n var start = index++;\n while(index < expression.length && isIdentifierPart(expression.charCodeAt(index)))index++;\n tokens.push({\n kind: \"identifier\",\n text: expression.slice(start, index),\n start: start,\n end: index\n });\n continue;\n }\n if (charCode >= 48 && charCode <= 57) {\n var start1 = index;\n if (charCode === 48 && (expression.charCodeAt(index + 1) === 88 || expression.charCodeAt(index + 1) === 120)) {\n index += 2;\n var digitStart = index;\n while(index < expression.length && isHexDigit(expression.charCodeAt(index)))index++;\n if (index === digitStart) {\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n } else if (charCode === 48) {\n index++;\n while(index < expression.length && expression.charCodeAt(index) >= 48 && expression.charCodeAt(index) <= 55)index++;\n } else {\n index++;\n while(index < expression.length && expression.charCodeAt(index) >= 48 && expression.charCodeAt(index) <= 57)index++;\n }\n var suffixStart = index;\n while(isIntegerSuffix(expression.charCodeAt(index)))index++;\n var suffix = expression.slice(suffixStart, index);\n if (!isValidIntegerSuffix(suffix) || isIdentifierStart(expression.charCodeAt(index))) {\n while(isIdentifierPart(expression.charCodeAt(index)))index++;\n tokens.push({\n kind: \"invalid\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n tokens.push({\n kind: \"number\",\n text: expression.slice(start1, index),\n start: start1,\n end: index\n });\n continue;\n }\n var nextCharCode = expression.charCodeAt(index + 1);\n if (isDoubleOperator(charCode, nextCharCode)) {\n tokens.push({\n kind: \"operator\",\n text: expression.slice(index, index + 2),\n start: index,\n end: index + 2\n });\n index += 2;\n continue;\n }\n if (isSingleOperator(charCode)) {\n tokens.push({\n kind: \"operator\",\n text: expression[index],\n start: index,\n end: index + 1\n });\n index++;\n continue;\n }\n tokens.push({\n kind: \"invalid\",\n text: expression[index],\n start: index,\n end: index + 1\n });\n index++;\n }\n tokens.push({\n kind: \"end\",\n text: \"\",\n start: index,\n end: index\n });\n return tokens;\n}\nfunction parseIntegerLiteral(literal) {\n var end = literal.length;\n while(end > 0 && isIntegerSuffix(literal.charCodeAt(end - 1)))end--;\n var value;\n if (literal.charCodeAt(0) === 48) {\n var prefix = literal.charCodeAt(1);\n if (prefix === 88 || prefix === 120) value = parseInt(literal.slice(2, end), 16);\n else if (end > 1) value = parseInt(literal.slice(0, end), 8);\n else value = 0;\n } else {\n value = Number(literal.slice(0, end));\n }\n return value <= 0xffffffff ? value | 0 : undefined;\n}\nfunction evaluateBinaryExpression(left, operator, right) {\n switch(operator){\n case \"||\":\n return left !== 0 || right !== 0 ? 1 : 0;\n case \"&&\":\n return left !== 0 && right !== 0 ? 1 : 0;\n case \"|\":\n return left | right;\n case \"^\":\n return left ^ right;\n case \"&\":\n return left & right;\n case \"==\":\n return left === right ? 1 : 0;\n case \"!=\":\n return left !== right ? 1 : 0;\n case \"<\":\n return left < right ? 1 : 0;\n case \"<=\":\n return left <= right ? 1 : 0;\n case \">\":\n return left > right ? 1 : 0;\n case \">=\":\n return left >= right ? 1 : 0;\n case \"<<\":\n {\n if (right < 0 || right > 31) return INVALID_SHIFT_COUNT_ERROR;\n return left << right;\n }\n case \">>\":\n {\n if (right < 0 || right > 31) return INVALID_SHIFT_COUNT_ERROR;\n return left >>> right | 0;\n }\n case \"+\":\n return left + right | 0;\n case \"-\":\n return left - right | 0;\n case \"*\":\n return Math.imul(left, right);\n case \"/\":\n if (right === 0) return DIVISION_BY_ZERO_ERROR;\n if (left === -0x80000000 && right === -1) return 0x7fffffff;\n return Math.trunc(left / right) | 0;\n case \"%\":\n if (right === 0) return MODULO_BY_ZERO_ERROR;\n return left % right | 0;\n default:\n throw new Error(\"Unsupported preprocessor operator '\" + operator + \"'.\");\n }\n}\nfunction validateBinaryRightOperand(operator, right) {\n if ((operator === \"/\" || operator === \"%\") && right === 0) {\n return operator === \"/\" ? DIVISION_BY_ZERO_ERROR : MODULO_BY_ZERO_ERROR;\n }\n if ((operator === \"<<\" || operator === \">>\") && right !== undefined && (right < 0 || right > 31)) {\n return INVALID_SHIFT_COUNT_ERROR;\n }\n}\nfunction evaluateStaticallyKnownPreprocessorCondition(condition, context) {\n switch(condition.t){\n case \"and\":\n {\n var left = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n if (typeof left === \"string\") return left;\n if (left === 0) return 0;\n var right = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof right === \"string\") return left === undefined ? undefined : right;\n if (right === 0) return 0;\n return left === undefined || right === undefined ? undefined : 1;\n }\n case \"or\":\n {\n var left1 = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n if (typeof left1 === \"string\") return left1;\n if (left1 !== undefined && left1 !== 0) return 1;\n var right1 = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof right1 === \"string\") return left1 === undefined ? undefined : right1;\n if (right1 !== undefined && right1 !== 0) return 1;\n return left1 === undefined || right1 === undefined ? undefined : 0;\n }\n case \"binary\":\n {\n var left2 = evaluateStaticallyKnownPreprocessorCondition(condition.l, context);\n var right2 = evaluateStaticallyKnownPreprocessorCondition(condition.r, context);\n if (typeof left2 === \"string\") return left2;\n if (typeof right2 === \"string\") return right2;\n var rightOperandError = validateBinaryRightOperand(condition.op, right2);\n if (rightOperandError) return rightOperandError;\n if (left2 === undefined || right2 === undefined) {\n return context ? evaluateBoundedIdentifierComparison(condition, left2, right2) : undefined;\n }\n var value = evaluateBinaryExpression(left2, condition.op, right2);\n return value;\n }\n case \"not\":\n {\n var value1 = evaluateStaticallyKnownPreprocessorCondition(condition.c, context);\n if (typeof value1 === \"string\") return value1;\n return value1 === undefined ? undefined : value1 === 0 ? 1 : 0;\n }\n case \"unary\":\n {\n var value2 = evaluateStaticallyKnownPreprocessorCondition(condition.c, context);\n if (typeof value2 === \"string\") return value2;\n if (value2 === undefined) return undefined;\n return condition.op === \"+\" ? value2 | 0 : condition.op === \"-\" ? -value2 | 0 : ~value2;\n }\n case \"bool\":\n return condition.v ? 1 : 0;\n case \"num\":\n return condition.v;\n case \"def\":\n {\n var defined = context == null ? void 0 : context.isDefined(condition.m);\n return defined === undefined ? undefined : defined ? 1 : 0;\n }\n case \"ndef\":\n {\n var defined1 = context == null ? void 0 : context.isDefined(condition.m);\n return defined1 === undefined ? undefined : defined1 ? 0 : 1;\n }\n case \"cmp\":\n {\n var resolved = context == null ? void 0 : context.resolveIdentifier(condition.m);\n if (resolved == null ? void 0 : resolved.error) return resolved.error;\n var value3 = resolved == null ? void 0 : resolved.value;\n if (value3 === undefined) return context ? evaluateUnknownSignedComparison(condition.op, condition.v) : undefined;\n var result = evaluateBinaryExpression(value3, condition.op, condition.v);\n return typeof result === \"string\" ? undefined : result;\n }\n case \"id\":\n {\n var resolved1 = context == null ? void 0 : context.resolveIdentifier(condition.m);\n return (resolved1 == null ? void 0 : resolved1.error) ? resolved1.error : resolved1 == null ? void 0 : resolved1.value;\n }\n case \"deferred\":\n return undefined;\n }\n}\nfunction evaluateBoundedIdentifierComparison(condition, left, right) {\n if (!isComparisonOperator(condition.op)) return undefined;\n if (condition.l.t === \"id\" && left === undefined && right !== undefined) {\n return evaluateUnknownSignedComparison(condition.op, right);\n }\n if (condition.r.t === \"id\" && right === undefined && left !== undefined) {\n return evaluateUnknownSignedComparison(reverseComparison(condition.op), left);\n }\n return undefined;\n}\nfunction evaluateUnknownSignedComparison(operator, value) {\n if (!isComparisonOperator(operator) || operator === \"==\" || operator === \"!=\") return undefined;\n var atMinimum = evaluateBinaryExpression(-0x80000000, operator, value);\n var atMaximum = evaluateBinaryExpression(0x7fffffff, operator, value);\n return typeof atMinimum === \"number\" && atMinimum === atMaximum ? atMinimum : undefined;\n}\nfunction isComparisonOperator(operator) {\n return operator === \"==\" || operator === \"!=\" || operator === \"<\" || operator === \"<=\" || operator === \">\" || operator === \">=\";\n}\nfunction reverseComparison(operator) {\n switch(operator){\n case \"<\":\n return \">\";\n case \"<=\":\n return \">=\";\n case \">\":\n return \"<\";\n case \">=\":\n return \"<=\";\n default:\n return operator;\n }\n}\nfunction isWhitespace(charCode) {\n return charCode === 32 || charCode >= 9 && charCode <= 13;\n}\nfunction isIdentifierStart(charCode) {\n return charCode >= 65 && charCode <= 90 || charCode >= 97 && charCode <= 122 || charCode === 95;\n}\nfunction isIdentifierPart(charCode) {\n return isIdentifierStart(charCode) || charCode >= 48 && charCode <= 57;\n}\nfunction isHexDigit(charCode) {\n return charCode >= 48 && charCode <= 57 || charCode >= 65 && charCode <= 70 || charCode >= 97 && charCode <= 102;\n}\nfunction isIntegerSuffix(charCode) {\n return charCode === 85 || charCode === 117;\n}\nfunction isValidIntegerSuffix(suffix) {\n return suffix === \"\" || suffix === \"u\" || suffix === \"U\";\n}\nfunction isDoubleOperator(charCode, nextCharCode) {\n return charCode === 124 && nextCharCode === 124 || charCode === 38 && nextCharCode === 38 || (charCode === 33 || charCode === 61) && nextCharCode === 61 || (charCode === 60 || charCode === 62) && (nextCharCode === 61 || nextCharCode === charCode);\n}\nfunction isSingleOperator(charCode) {\n return charCode === 33 || charCode === 37 || charCode === 38 || charCode === 40 || charCode === 41 || charCode === 42 || charCode === 43 || charCode === 45 || charCode === 47 || charCode === 58 || charCode === 60 || charCode === 62 || charCode === 63 || charCode === 94 || charCode === 124 || charCode === 126;\n}\n\nvar SHADER_ROOT_URL = \"shaders://root/\";\nvar ABSOLUTE_URL_PATTERN = /^[A-Za-z][A-Za-z\\d+.-]*:/;\n/**\n * Converts a registered shader-include key to its canonical lookup form.\n * @param includeKey - Logical project path, project-root path, or absolute URL.\n * @returns Canonical registry key without the virtual shader-root prefix.\n * @throws Error when the key is empty or an absolute URL is malformed.\n */ function normalizeShaderIncludeKey(includeKey) {\n var normalized = includeKey.trim().replace(/\\\\/g, \"/\");\n if (!normalized) throw new Error(\"Shader include key cannot be empty.\");\n if (normalized.startsWith(SHADER_ROOT_URL)) {\n var key = new URL(normalized).href.slice(SHADER_ROOT_URL.length);\n if (!key) throw new Error(\"Shader include key cannot be the virtual shader root.\");\n return key;\n }\n if (ABSOLUTE_URL_PATTERN.test(normalized)) {\n return new URL(normalized).href;\n }\n return new URL(normalized.replace(/^\\/+/, \"\"), SHADER_ROOT_URL).href.slice(SHADER_ROOT_URL.length);\n}\n\nexport { evaluateContextFreePreprocessorCondition, evaluateContextFreePreprocessorExpression, evaluatePartiallyKnownPreprocessorCondition, evaluatePartiallyKnownPreprocessorConditionResult, evaluatePreprocessorExpression, expandPreprocessorExpressionMacros, expandShaderMacros, normalizeShaderIncludeKey, parsePreprocessorExpression, resolvePreprocessorDefinedOperators };\n//# sourceMappingURL=module.js.map\n","import{parsePreprocessorExpression,evaluateContextFreePreprocessorCondition,normalizeShaderIncludeKey,resolvePreprocessorDefinedOperators,expandPreprocessorExpressionMacros,evaluatePartiallyKnownPreprocessorConditionResult}from\"@galacean/engine-design\";import{Logger,RenderStateElementKey,RenderQueueType,CompareFunction,StencilOperation,BlendOperation,BlendFactor,CullMode,ColorWriteMask}from\"@galacean/engine-core\";import{Color}from\"@galacean/engine-math\";var ShaderRange=function(){function ShaderRange(){}var _proto=ShaderRange.prototype;_proto.set=function set(start,end){this.start=start;this.end=end};return ShaderRange}();var ShaderPosition=function(){function ShaderPosition(){}var _proto=ShaderPosition.prototype;_proto.set=function set(index,line,column){this.index=index;this.line=line;this.column=column};return ShaderPosition}();var ETokenType=function(ETokenType){ETokenType[ETokenType[\"ID\"]=1e3]=\"ID\";ETokenType[ETokenType[\"FLOAT_CONSTANT\"]=1001]=\"FLOAT_CONSTANT\";ETokenType[ETokenType[\"INT_CONSTANT\"]=1002]=\"INT_CONSTANT\";ETokenType[ETokenType[\"STRING_CONST\"]=1003]=\"STRING_CONST\";ETokenType[ETokenType[\"LEFT_OP\"]=1004]=\"LEFT_OP\";ETokenType[ETokenType[\"RIGHT_OP\"]=1005]=\"RIGHT_OP\";ETokenType[ETokenType[\"INC_OP\"]=1006]=\"INC_OP\";ETokenType[ETokenType[\"DEC_OP\"]=1007]=\"DEC_OP\";ETokenType[ETokenType[\"LE_OP\"]=1008]=\"LE_OP\";ETokenType[ETokenType[\"GE_OP\"]=1009]=\"GE_OP\";ETokenType[ETokenType[\"EQ_OP\"]=1010]=\"EQ_OP\";ETokenType[ETokenType[\"NE_OP\"]=1011]=\"NE_OP\";ETokenType[ETokenType[\"AND_OP\"]=1012]=\"AND_OP\";ETokenType[ETokenType[\"OR_OP\"]=1013]=\"OR_OP\";ETokenType[ETokenType[\"XOR_OP\"]=1014]=\"XOR_OP\";ETokenType[ETokenType[\"MUL_ASSIGN\"]=1015]=\"MUL_ASSIGN\";ETokenType[ETokenType[\"DIV_ASSIGN\"]=1016]=\"DIV_ASSIGN\";ETokenType[ETokenType[\"ADD_ASSIGN\"]=1017]=\"ADD_ASSIGN\";ETokenType[ETokenType[\"SUB_ASSIGN\"]=1018]=\"SUB_ASSIGN\";ETokenType[ETokenType[\"MOD_ASSIGN\"]=1019]=\"MOD_ASSIGN\";ETokenType[ETokenType[\"LEFT_ASSIGN\"]=1020]=\"LEFT_ASSIGN\";ETokenType[ETokenType[\"RIGHT_ASSIGN\"]=1021]=\"RIGHT_ASSIGN\";ETokenType[ETokenType[\"AND_ASSIGN\"]=1022]=\"AND_ASSIGN\";ETokenType[ETokenType[\"XOR_ASSIGN\"]=1023]=\"XOR_ASSIGN\";ETokenType[ETokenType[\"OR_ASSIGN\"]=1024]=\"OR_ASSIGN\";ETokenType[ETokenType[\"LEFT_PAREN\"]=1025]=\"LEFT_PAREN\";ETokenType[ETokenType[\"RIGHT_PAREN\"]=1026]=\"RIGHT_PAREN\";ETokenType[ETokenType[\"LEFT_BRACKET\"]=1027]=\"LEFT_BRACKET\";ETokenType[ETokenType[\"RIGHT_BRACKET\"]=1028]=\"RIGHT_BRACKET\";ETokenType[ETokenType[\"LEFT_BRACE\"]=1029]=\"LEFT_BRACE\";ETokenType[ETokenType[\"RIGHT_BRACE\"]=1030]=\"RIGHT_BRACE\";ETokenType[ETokenType[\"DOT\"]=1031]=\"DOT\";ETokenType[ETokenType[\"COMMA\"]=1032]=\"COMMA\";ETokenType[ETokenType[\"COLON\"]=1033]=\"COLON\";ETokenType[ETokenType[\"EQUAL\"]=1034]=\"EQUAL\";ETokenType[ETokenType[\"SEMICOLON\"]=1035]=\"SEMICOLON\";ETokenType[ETokenType[\"BANG\"]=1036]=\"BANG\";ETokenType[ETokenType[\"DASH\"]=1037]=\"DASH\";ETokenType[ETokenType[\"TILDE\"]=1038]=\"TILDE\";ETokenType[ETokenType[\"PLUS\"]=1039]=\"PLUS\";ETokenType[ETokenType[\"STAR\"]=1040]=\"STAR\";ETokenType[ETokenType[\"SLASH\"]=1041]=\"SLASH\";ETokenType[ETokenType[\"PERCENT\"]=1042]=\"PERCENT\";ETokenType[ETokenType[\"LEFT_ANGLE\"]=1043]=\"LEFT_ANGLE\";ETokenType[ETokenType[\"RIGHT_ANGLE\"]=1044]=\"RIGHT_ANGLE\";ETokenType[ETokenType[\"VERTICAL_BAR\"]=1045]=\"VERTICAL_BAR\";ETokenType[ETokenType[\"CARET\"]=1046]=\"CARET\";ETokenType[ETokenType[\"AMPERSAND\"]=1047]=\"AMPERSAND\";ETokenType[ETokenType[\"QUESTION\"]=1048]=\"QUESTION\";ETokenType[ETokenType[\"NotWord\"]=1049]=\"NotWord\";ETokenType[ETokenType[\"EPSILON\"]=1998]=\"EPSILON\";ETokenType[ETokenType[\"EOF\"]=1999]=\"EOF\";return ETokenType}({});var TypeAny=3e3;var Keyword=function(Keyword){Keyword[Keyword[\"CONST\"]=0]=\"CONST\";Keyword[Keyword[\"BOOL\"]=1]=\"BOOL\";Keyword[Keyword[\"FLOAT\"]=2]=\"FLOAT\";Keyword[Keyword[\"DOUBLE\"]=3]=\"DOUBLE\";Keyword[Keyword[\"INT\"]=4]=\"INT\";Keyword[Keyword[\"UINT\"]=5]=\"UINT\";Keyword[Keyword[\"BREAK\"]=6]=\"BREAK\";Keyword[Keyword[\"CONTINUE\"]=7]=\"CONTINUE\";Keyword[Keyword[\"DO\"]=8]=\"DO\";Keyword[Keyword[\"ELSE\"]=9]=\"ELSE\";Keyword[Keyword[\"FOR\"]=10]=\"FOR\";Keyword[Keyword[\"IF\"]=11]=\"IF\";Keyword[Keyword[\"WHILE\"]=12]=\"WHILE\";Keyword[Keyword[\"DISCARD\"]=13]=\"DISCARD\";Keyword[Keyword[\"RETURN\"]=14]=\"RETURN\";Keyword[Keyword[\"BVEC2\"]=15]=\"BVEC2\";Keyword[Keyword[\"BVEC3\"]=16]=\"BVEC3\";Keyword[Keyword[\"BVEC4\"]=17]=\"BVEC4\";Keyword[Keyword[\"IVEC2\"]=18]=\"IVEC2\";Keyword[Keyword[\"IVEC3\"]=19]=\"IVEC3\";Keyword[Keyword[\"IVEC4\"]=20]=\"IVEC4\";Keyword[Keyword[\"UVEC2\"]=21]=\"UVEC2\";Keyword[Keyword[\"UVEC3\"]=22]=\"UVEC3\";Keyword[Keyword[\"UVEC4\"]=23]=\"UVEC4\";Keyword[Keyword[\"VEC2\"]=24]=\"VEC2\";Keyword[Keyword[\"VEC3\"]=25]=\"VEC3\";Keyword[Keyword[\"VEC4\"]=26]=\"VEC4\";Keyword[Keyword[\"VEC4_ARRAY\"]=27]=\"VEC4_ARRAY\";Keyword[Keyword[\"MAT2\"]=28]=\"MAT2\";Keyword[Keyword[\"MAT3\"]=29]=\"MAT3\";Keyword[Keyword[\"MAT4\"]=30]=\"MAT4\";Keyword[Keyword[\"MAT2X3\"]=31]=\"MAT2X3\";Keyword[Keyword[\"MAT2X4\"]=32]=\"MAT2X4\";Keyword[Keyword[\"MAT3X2\"]=33]=\"MAT3X2\";Keyword[Keyword[\"MAT3X4\"]=34]=\"MAT3X4\";Keyword[Keyword[\"MAT4X2\"]=35]=\"MAT4X2\";Keyword[Keyword[\"MAT4X3\"]=36]=\"MAT4X3\";Keyword[Keyword[\"IN\"]=37]=\"IN\";Keyword[Keyword[\"OUT\"]=38]=\"OUT\";Keyword[Keyword[\"INOUT\"]=39]=\"INOUT\";Keyword[Keyword[\"CENTROID\"]=40]=\"CENTROID\";Keyword[Keyword[\"SAMPLER2D\"]=41]=\"SAMPLER2D\";Keyword[Keyword[\"SAMPLER3D\"]=42]=\"SAMPLER3D\";Keyword[Keyword[\"SAMPLER_CUBE\"]=43]=\"SAMPLER_CUBE\";Keyword[Keyword[\"SAMPLER2D_SHADOW\"]=44]=\"SAMPLER2D_SHADOW\";Keyword[Keyword[\"SAMPLER_CUBE_SHADOW\"]=45]=\"SAMPLER_CUBE_SHADOW\";Keyword[Keyword[\"SAMPLER2D_ARRAY\"]=46]=\"SAMPLER2D_ARRAY\";Keyword[Keyword[\"SAMPLER2D_ARRAY_SHADOW\"]=47]=\"SAMPLER2D_ARRAY_SHADOW\";Keyword[Keyword[\"I_SAMPLER2D\"]=48]=\"I_SAMPLER2D\";Keyword[Keyword[\"I_SAMPLER3D\"]=49]=\"I_SAMPLER3D\";Keyword[Keyword[\"I_SAMPLER_CUBE\"]=50]=\"I_SAMPLER_CUBE\";Keyword[Keyword[\"I_SAMPLER2D_ARRAY\"]=51]=\"I_SAMPLER2D_ARRAY\";Keyword[Keyword[\"U_SAMPLER2D\"]=52]=\"U_SAMPLER2D\";Keyword[Keyword[\"U_SAMPLER3D\"]=53]=\"U_SAMPLER3D\";Keyword[Keyword[\"U_SAMPLER_CUBE\"]=54]=\"U_SAMPLER_CUBE\";Keyword[Keyword[\"U_SAMPLER2D_ARRAY\"]=55]=\"U_SAMPLER2D_ARRAY\";Keyword[Keyword[\"STRUCT\"]=56]=\"STRUCT\";Keyword[Keyword[\"LAYOUT\"]=57]=\"LAYOUT\";Keyword[Keyword[\"LOCATION\"]=58]=\"LOCATION\";Keyword[Keyword[\"VOID\"]=59]=\"VOID\";Keyword[Keyword[\"PRECISION\"]=60]=\"PRECISION\";Keyword[Keyword[\"PRECISE\"]=61]=\"PRECISE\";Keyword[Keyword[\"HIGHP\"]=62]=\"HIGHP\";Keyword[Keyword[\"MEDIUMP\"]=63]=\"MEDIUMP\";Keyword[Keyword[\"LOWP\"]=64]=\"LOWP\";Keyword[Keyword[\"INVARIANT\"]=65]=\"INVARIANT\";Keyword[Keyword[\"SMOOTH\"]=66]=\"SMOOTH\";Keyword[Keyword[\"FLAT\"]=67]=\"FLAT\";Keyword[Keyword[\"NOPERSPECTIVE\"]=68]=\"NOPERSPECTIVE\";Keyword[Keyword[\"True\"]=69]=\"True\";Keyword[Keyword[\"False\"]=70]=\"False\";Keyword[Keyword[\"LeftBrace\"]=71]=\"LeftBrace\";Keyword[Keyword[\"RightBrace\"]=72]=\"RightBrace\";Keyword[Keyword[\"Equal\"]=73]=\"Equal\";Keyword[Keyword[\"BitwiseOr\"]=74]=\"BitwiseOr\";Keyword[Keyword[\"GSRenderQueueType\"]=75]=\"GSRenderQueueType\";Keyword[Keyword[\"GSBlendState\"]=76]=\"GSBlendState\";Keyword[Keyword[\"GSDepthState\"]=77]=\"GSDepthState\";Keyword[Keyword[\"GSStencilState\"]=78]=\"GSStencilState\";Keyword[Keyword[\"GSRasterState\"]=79]=\"GSRasterState\";Keyword[Keyword[\"GSEditorProperties\"]=80]=\"GSEditorProperties\";Keyword[Keyword[\"GSEditorMacros\"]=81]=\"GSEditorMacros\";Keyword[Keyword[\"GSEditor\"]=82]=\"GSEditor\";Keyword[Keyword[\"GSTags\"]=83]=\"GSTags\";Keyword[Keyword[\"GSVertexShader\"]=84]=\"GSVertexShader\";Keyword[Keyword[\"GSFragmentShader\"]=85]=\"GSFragmentShader\";Keyword[Keyword[\"GSSubShader\"]=86]=\"GSSubShader\";Keyword[Keyword[\"GSPass\"]=87]=\"GSPass\";Keyword[Keyword[\"GSBlendFactor\"]=88]=\"GSBlendFactor\";Keyword[Keyword[\"GSBlendOperation\"]=89]=\"GSBlendOperation\";Keyword[Keyword[\"GSBool\"]=90]=\"GSBool\";Keyword[Keyword[\"GSNumber\"]=91]=\"GSNumber\";Keyword[Keyword[\"GSColor\"]=92]=\"GSColor\";Keyword[Keyword[\"GSCompareFunction\"]=93]=\"GSCompareFunction\";Keyword[Keyword[\"GSStencilOperation\"]=94]=\"GSStencilOperation\";Keyword[Keyword[\"GSCullMode\"]=95]=\"GSCullMode\";Keyword[Keyword[\"GSColorWriteMask\"]=96]=\"GSColorWriteMask\";Keyword[Keyword[\"GSUsePass\"]=97]=\"GSUsePass\";Keyword[Keyword[\"MACRO_IF\"]=98]=\"MACRO_IF\";Keyword[Keyword[\"MACRO_IFDEF\"]=99]=\"MACRO_IFDEF\";Keyword[Keyword[\"MACRO_IFNDEF\"]=100]=\"MACRO_IFNDEF\";Keyword[Keyword[\"MACRO_ELSE\"]=101]=\"MACRO_ELSE\";Keyword[Keyword[\"MACRO_ELIF\"]=102]=\"MACRO_ELIF\";Keyword[Keyword[\"MACRO_ENDIF\"]=103]=\"MACRO_ENDIF\";Keyword[Keyword[\"MACRO_UNDEF\"]=104]=\"MACRO_UNDEF\";Keyword[Keyword[\"MACRO_DEFINE_EXPRESSION\"]=105]=\"MACRO_DEFINE_EXPRESSION\";Keyword[Keyword[\"MACRO_CONDITIONAL_EXPRESSION\"]=106]=\"MACRO_CONDITIONAL_EXPRESSION\";Keyword[Keyword[\"MACRO_CALL\"]=107]=\"MACRO_CALL\";Keyword[Keyword[\"MACRO_DEFINE\"]=108]=\"MACRO_DEFINE\";Keyword[Keyword[\"MACRO_DEFINE_END\"]=109]=\"MACRO_DEFINE_END\";Keyword[Keyword[\"MACRO_DEFINE_PARAMS\"]=110]=\"MACRO_DEFINE_PARAMS\";return Keyword}({});function _instanceof(left,right){if(right!=null&&typeof Symbol!==\"undefined\"&&right[Symbol.hasInstance]){return!!right[Symbol.hasInstance](left)}else return left instanceof right}function _type_of(obj){\"@swc/helpers - typeof\";return obj&&typeof Symbol!==\"undefined\"&&obj.constructor===Symbol?\"symbol\":typeof obj}function _array_like_to_array(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}function _unsupported_iterable_to_array(o,minLen){if(!o)return;if(typeof o===\"string\")return _array_like_to_array(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n===\"Object\"&&o.constructor)n=o.constructor.name;if(n===\"Map\"||n===\"Set\")return Array.from(n);if(n===\"Arguments\"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _array_like_to_array(o,minLen)}function _create_for_of_iterator_helper_loose(o,allowArrayLike){var it=typeof Symbol!==\"undefined\"&&o[Symbol.iterator]||o[\"@@iterator\"];if(it)return(it=it.call(o)).next.bind(it);if(Array.isArray(o)||(it=_unsupported_iterable_to_array(o))||allowArrayLike&&o&&typeof o.length===\"number\"){if(it)o=it;var i=0;return function(){if(i>=o.length)return{done:true};return{done:false,value:o[i++]}}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}function sameBranch(a,b){if(a.length!==b.length)return false;for(var i=0,n=a.length;i<n;i++){var left=a[i];var right=b[i];if(left.name!==right.name||left.defined!==right.defined)return false;if(!sameCondition(left.condition,right.condition))return false;var leftPreceding=left.precedingConditions;var rightPreceding=right.precedingConditions;var _leftPreceding_length,_rightPreceding_length;if(((_leftPreceding_length=leftPreceding==null?void 0:leftPreceding.length)!=null?_leftPreceding_length:0)!==((_rightPreceding_length=rightPreceding==null?void 0:rightPreceding.length)!=null?_rightPreceding_length:0))return false;var _leftPreceding_length1;for(var j=0,m=(_leftPreceding_length1=leftPreceding==null?void 0:leftPreceding.length)!=null?_leftPreceding_length1:0;j<m;j++){if(!sameCondition(leftPreceding[j],rightPreceding[j]))return false}}return true}function isLexicalBranchVisibleFrom(declaration,reference){for(var i=0;i<declaration.length;i++){var _declarationConstraint_sourceArm;var declarationConstraint=declaration[i];if(((_declarationConstraint_sourceArm=declarationConstraint.sourceArm)==null?void 0:_declarationConstraint_sourceArm.value)===true)continue;var group=declarationConstraint.conditionalGroup;if(group===undefined)return false;var matched=false;for(var j=0;j<reference.length;j++){var referenceConstraint=reference[j];if(referenceConstraint.conditionalGroup!==group)continue;if(referenceConstraint.conditionalArm!==declarationConstraint.conditionalArm)return false;matched=true;break}if(!matched)return false}return true}function getLexicalBranchCoverage(candidates,reference){return coverLexicalArms(candidates,reference,{remaining:256})?\"covered\":\"unknown\"}function coverLexicalArms(candidates,reference,budget){var _loop=function(arm){var _completeArm_conditionalReachableArms;if(referenceArm!==undefined&&arm!==referenceArm)return\"continue\";if(((_completeArm_conditionalReachableArms=completeArm.conditionalReachableArms)==null?void 0:_completeArm_conditionalReachableArms[arm])===false)return\"continue\";var armCandidates=compatible.filter(function(candidate){return candidate.every(function(constraint){return constraint.conditionalGroup!==group||constraint.conditionalArm===arm})}).map(function(candidate){return candidate.filter(function(constraint){return constraint.conditionalGroup!==group})});if(!coverLexicalArms(armCandidates,remainingReference,budget))return{v:false}};var _reference_find;if(candidates.some(function(candidate){return isLexicalBranchVisibleFrom(candidate,reference)}))return true;if(--budget.remaining<0)return false;var compatible=candidates.filter(function(candidate){return getLexicalDeclarationCoexistence(candidate,reference)!==\"exclusive\"});var completeArm;for(var _iterator=_create_for_of_iterator_helper_loose(compatible),_step;!(_step=_iterator()).done;){var candidate=_step.value;completeArm=candidate.find(function(arm){return arm.conditionalComplete&&arm.conditionalGroup!==undefined&&arm.conditionalArmCount});if(completeArm)break}if(!completeArm)return false;var group=completeArm.conditionalGroup;var referenceArm=(_reference_find=reference.find(function(arm){return arm.conditionalGroup===group}))==null?void 0:_reference_find.conditionalArm;var remainingReference=reference.filter(function(arm){return arm.conditionalGroup!==group});for(var arm=0;arm<completeArm.conditionalArmCount;arm++){var _ret=_loop(arm);if(_type_of(_ret)===\"object\")return _ret.v}return true}function getLexicalDeclarationCoexistence(earlier,later){for(var _iterator=_create_for_of_iterator_helper_loose(earlier),_step;!(_step=_iterator()).done;){var left=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(later),_step1;!(_step1=_iterator1()).done;){var right=_step1.value;if(left.conditionalGroup!==undefined&&left.conditionalGroup===right.conditionalGroup&&left.conditionalArm!==right.conditionalArm){return\"exclusive\"}}}for(var _iterator2=_create_for_of_iterator_helper_loose(earlier),_step2;!(_step2=_iterator2()).done;){var constraint=_step2.value;if(constraint.condition!==undefined)return\"unknown\"}for(var _iterator3=_create_for_of_iterator_helper_loose(later),_step3;!(_step3=_iterator3()).done;){var constraint1=_step3.value;if(constraint1.condition!==undefined)return\"unknown\"}return\"coexist\"}function sameCondition(left,right){if(!left||!right)return left===right;if(left.kind!==right.kind)return false;if(left.kind===\"constant\")return right.kind===\"constant\"&&left.value===right.value;if(right.kind===\"constant\")return false;if(left.kind===\"expression\")return right.kind===\"expression\"&&sameExpression(left,right)&&left.negated===right.negated;if(right.kind===\"expression\")return false;if(left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"&&right.kind===\"defined\")return left.defined===right.defined;return left.kind===\"comparison\"&&right.kind===\"comparison\"&&left.operator===right.operator&&left.value===right.value}function sameExpression(left,right){if(left.expression!==right.expression||left.opaque!==right.opaque||left.names.length!==right.names.length){return false}for(var i=0,n=left.names.length;i<n;i++){if(left.names[i]!==right.names[i]||left.versions[i]!==right.versions[i])return false}return true}var EMPTY_BRANCH=Object.freeze([]);var BaseToken=function(){function BaseToken(_objectPool){this._objectPool=_objectPool;this.branch=EMPTY_BRANCH;this.inMacroDefinition=false}var _proto=BaseToken.prototype;_proto.set=function set(type,lexeme,arg){this.type=type;this.lexeme=lexeme;this.branch=EMPTY_BRANCH;this.inMacroDefinition=false;if(_instanceof(arg,ShaderRange)){this.location=arg}else{var end=this._objectPool?this._objectPool.createPosition(arg.index+lexeme.length,arg.line,arg.column+lexeme.length):createPosition(arg.index+lexeme.length,arg.line,arg.column+lexeme.length);this.location=this._objectPool?this._objectPool.createRange(arg,end):createRange(arg,end)}};return BaseToken}();function createPosition(index,line,column){var position=new ShaderPosition;position.set(index,line,column);return position}function createRange(start,end){var range=new ShaderRange;range.set(start,end);return range}var EOF=new BaseToken;var EOF_POSITION=createPosition(0,0,0);EOF.set(ETokenType.EOF,\"/EOF\",createRange(EOF_POSITION,EOF_POSITION));function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if(\"value\"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor)}}function _create_class(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor}function _set_prototype_of(o,p){_set_prototype_of=Object.setPrototypeOf||function setPrototypeOf(o,p){o.__proto__=p;return o};return _set_prototype_of(o,p)}function _inherits(subClass,superClass){if(typeof superClass!==\"function\"&&superClass!==null){throw new TypeError(\"Super expression must either be null or a function\")}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,writable:true,configurable:true}});if(superClass)_set_prototype_of(subClass,superClass)}function _is_native_reflect_construct(){try{var result=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(_){}return(_is_native_reflect_construct=function(){return!!result})()}function _construct(Parent,args,Class){if(_is_native_reflect_construct())_construct=Reflect.construct;else{_construct=function construct(Parent,args,Class){var a=[null];a.push.apply(a,args);var Constructor=Function.bind.apply(Parent,a);var instance=new Constructor;if(Class)_set_prototype_of(instance,Class.prototype);return instance}}return _construct.apply(null,arguments)}function _get_prototype_of(o){_get_prototype_of=Object.setPrototypeOf?Object.getPrototypeOf:function getPrototypeOf(o){return o.__proto__||Object.getPrototypeOf(o)};return _get_prototype_of(o)}function _is_native_function(fn){return Function.toString.call(fn).indexOf(\"[native code]\")!==-1}function _wrap_native_super(Class){var _cache=typeof Map===\"function\"?new Map:undefined;_wrap_native_super=function(Class){if(Class===null||!_is_native_function(Class))return Class;if(typeof Class!==\"function\")throw new TypeError(\"Super expression must either be null or a function\");if(typeof _cache!==\"undefined\"){if(_cache.has(Class))return _cache.get(Class);_cache.set(Class,Wrapper)}function Wrapper(){return _construct(Class,arguments,_get_prototype_of(this).constructor)}Wrapper.prototype=Object.create(Class.prototype,{constructor:{value:Wrapper,enumerable:false,writable:true,configurable:true}});return _set_prototype_of(Wrapper,Class)};return _wrap_native_super(Class)}function formatDiagnosticSource(source,range,header,contextLines){if(contextLines===void 0)contextLines=5;if(!source)return header;var lines=source.split(\"\\n\");var start=range.start,end=range.end;var from=Math.max(0,start.line-contextLines);var to=Math.min(lines.length-1,end.line+contextLines);var gutterWidth=String(to+1).length;var gutterPad=\" \".repeat(gutterWidth);var out=header+\"\\n\";for(var i=from;i<=to;i++){out+=String(i+1).padStart(gutterWidth)+\" | \"+lines[i]+\"\\n\";if(start.line<=i&&i<=end.line){var cs=i===start.line?start.column:0;var ce=i===end.line?end.column:lines[i].length;out+=gutterPad+\" | \"+\" \".repeat(cs)+\"^\".repeat(Math.max(ce-cs,1))+\"\\n\"}}return out}var GSError=function(Error1){_inherits(GSError,Error1);function GSError(name,message,location,source,file,code){var _this;_this=Error1.call(this,message)||this,_this.location=location,_this.source=source,_this.file=file,_this.code=code;_this.name=name;return _this}var _proto=GSError.prototype;_proto.toString=function toString(){var location=this.location;var range=\"start\"in location?location:{start:location,end:location};return formatDiagnosticSource(this.source||undefined,range,this.name+\": \"+this.message)};return GSError}(_wrap_native_super(Error));var GSErrorName=function(GSErrorName){GSErrorName[\"PreprocessorError\"]=\"PreprocessorError\";GSErrorName[\"CompilationError\"]=\"CompilationError\";GSErrorName[\"ScannerError\"]=\"ScannerError\";GSErrorName[\"CompilationWarn\"]=\"CompilationWarning\";return GSErrorName}({});var ShaderCompilerUtils=function(){function ShaderCompilerUtils(){}ShaderCompilerUtils.createPosition=function createPosition(index,line,column){if(line===void 0)line=0;if(column===void 0)column=0;var position=new ShaderPosition;position.set(index,line,column);return position};ShaderCompilerUtils.createRange=function createRange(start,end){var range=new ShaderRange;range.set(start,end);return range};ShaderCompilerUtils.createGSError=function createGSError(message,errorName,source,location,code,file){return new GSError(errorName,message,location,source,file,code)};return ShaderCompilerUtils}();var BaseLexer=function(){function BaseLexer(source,_objectPool){this._objectPool=_objectPool;this._currentIndex=0;this._column=0;this._line=0;this.setSource(source!=null?source:\"\")}var _proto=BaseLexer.prototype;_proto.setSource=function setSource(source){this._source=source;this._currentIndex=0;this._line=this._column=0};_proto.getShaderPosition=function getShaderPosition(backOffset){if(backOffset===void 0)backOffset=0;var index=this._currentIndex-backOffset;return this._createPosition(index,this._line,this._column-backOffset)};_proto._createPosition=function _createPosition(index,line,column){return this._objectPool?this._objectPool.createPosition(index,line,column):ShaderCompilerUtils.createPosition(index,line,column)};_proto._createToken=function _createToken(){return this._objectPool?this._objectPool.createToken():new BaseToken};_proto._createEOFToken=function _createEOFToken(){var position=this.getShaderPosition();var token=this._createToken();token.set(ETokenType.EOF,\"/EOF\",this._createRange(position,position));return token};_proto._createRange=function _createRange(start,end){return this._objectPool?this._objectPool.createRange(start,end):ShaderCompilerUtils.createRange(start,end)};_proto.isEnd=function isEnd(){return this._currentIndex>=this._source.length};_proto.getCurChar=function getCurChar(){return this._source[this._currentIndex]};_proto.getCurCharCode=function getCurCharCode(){return this._source.charCodeAt(this._currentIndex)};_proto.advance=function advance(count){var source=this._source;var startIndex=this._currentIndex;for(var i=0;i<count;i++){if(source.charCodeAt(startIndex+i)===10){this._line+=1;this._column=0}else{this._column+=1}}this._currentIndex+=count};_proto.skipSpace=function skipSpace(includeLineBreak){while(BaseLexer.isWhiteSpaceChar(this.getCurCharCode(),includeLineBreak)){this.advance(1)}};_proto.skipCommentsAndSpace=function skipCommentsAndSpace(){var source=this._source;var length=source.length;var index=this._currentIndex;while(index<length){while(index<length&&BaseLexer.isWhiteSpaceChar(source.charCodeAt(index),true)){index++}var afterBlock=BaseLexer._skipBlockComment(source,index,length);if(afterBlock!==index){index=afterBlock;continue}var afterLine=BaseLexer._skipLineComment(source,index,length);if(afterLine!==index){index=afterLine;continue}break}this.advance(index-this._currentIndex)};_proto.peek=function peek(to){var offset=this._currentIndex;return this._source.substring(offset,offset+to)};_proto.scanLexeme=function scanLexeme(lexeme){this.skipCommentsAndSpace();var length=lexeme.length;var peek=this.peek(length);if(peek!==lexeme){this.throwError(this.getShaderPosition(0),'Expect lexeme \"'+lexeme+'\", but got \"'+peek+'\"')}this.advance(length)};_proto.scanTwoExpectedLexemes=function scanTwoExpectedLexemes(lexeme1,lexeme2){this.skipCommentsAndSpace();if(this.peek(lexeme1.length)===lexeme1){this.advance(lexeme1.length);return lexeme1}if(this.peek(lexeme2.length)===lexeme2){this.advance(lexeme2.length);return lexeme2}return null};_proto.throwError=function throwError(pos){for(var _len=arguments.length,msgs=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){msgs[_key-1]=arguments[_key]}var error=ShaderCompilerUtils.createGSError(msgs.join(\" \"),GSErrorName.ScannerError,this._source,pos);throw error};_proto.scanPairedChar=function scanPairedChar(left,right,balanced,skipLeading){if(!skipLeading){this.scanLexeme(left)}var start=this._currentIndex;var source=this._source;var sourceLength=source.length;var currentIndex=this._currentIndex;if(balanced){var level=1;while(currentIndex<sourceLength){var currentChar=source[currentIndex];if(currentChar===right&&--level===0){break}else if(currentChar===left){level++}currentIndex++}}else{while(currentIndex<sourceLength){if(source[currentIndex]===right){break}currentIndex++}}if(currentIndex===sourceLength){this.throwError(this.getShaderPosition(),'Expect closing character \"'+right+'\" before end of source.')}this.advance(currentIndex+1-this._currentIndex);return source.substring(start,currentIndex)};BaseLexer.isDigit=function isDigit(charCode){return charCode>=48&&charCode<=57};BaseLexer.isHexDigit=function isHexDigit(charCode){return charCode>=48&&charCode<=57||charCode>=65&&charCode<=70||charCode>=97&&charCode<=102};BaseLexer.isAlpha=function isAlpha(charCode){return charCode===95||charCode>=65&&charCode<=90||charCode>=97&&charCode<=122};BaseLexer.isAlnum=function isAlnum(charCode){return BaseLexer.isAlpha(charCode)||BaseLexer.isDigit(charCode)};BaseLexer.isPreprocessorStartChar=function isPreprocessorStartChar(charCode){return charCode===35};BaseLexer._skipBlockComment=function _skipBlockComment(src,i,len){if(src.charCodeAt(i)!==47||i+1>=len||src.charCodeAt(i+1)!==42)return i;var j=i+2;while(j+1<len){if(src.charCodeAt(j)===42&&src.charCodeAt(j+1)===47)return j+2;j++}return len};BaseLexer._skipLineComment=function _skipLineComment(src,i,len){if(src.charCodeAt(i)!==47||i+1>=len||src.charCodeAt(i+1)!==47)return i;var j=i+2;while(j<len){var c=src.charCodeAt(j);if(c===10||c===13)break;j++}return j};BaseLexer.isWhiteSpaceChar=function isWhiteSpaceChar(charCode,includeBreak){if(charCode===32||charCode===9){return true}return includeBreak&&(charCode===10||charCode===13)};_create_class(BaseLexer,[{key:\"currentIndex\",get:function get(){return this._currentIndex}},{key:\"source\",get:function get(){return this._source}},{key:\"line\",get:function get(){return this._line}},{key:\"column\",get:function get(){return this._column}}]);return BaseLexer}();function parsePreprocessorCondition(expression){var condition=tryParsePreprocessorCondition(expression);if(!condition)throw new Error(\"Unsupported or malformed preprocessor condition '\"+expression+\"'.\");return condition}function tryParsePreprocessorCondition(expression,parsedExpression){if(parsedExpression===void 0)parsedExpression=parsePreprocessorExpression(expression);var result=parsedExpression;if(!result.ok||result.evaluationError)return undefined;var constantValue=evaluateContextFreePreprocessorCondition(result.condition);if(constantValue!==undefined){return result.hasExpandableIdentifier?undefined:{t:\"bool\",v:constantValue!==0}}return toPreprocessorCondition(result.condition)}function toPreprocessorCondition(condition){switch(condition.t){case\"def\":return condition;case\"and\":{var left=toPreprocessorCondition(condition.l);var right=toPreprocessorCondition(condition.r);return left&&right?{t:\"and\",l:left,r:right}:undefined}case\"or\":{var left1=toPreprocessorCondition(condition.l);var right1=toPreprocessorCondition(condition.r);return left1&&right1?{t:\"or\",l:left1,r:right1}:undefined}case\"not\":{var child=toPreprocessorCondition(condition.c);return child?{t:\"not\",c:child}:undefined}case\"id\":return{t:\"cmp\",m:condition.m,op:\"!=\",v:0};case\"binary\":return toComparisonCondition(condition);case\"num\":return{t:\"bool\",v:condition.v!==0};case\"bool\":case\"cmp\":return condition;case\"ndef\":return{t:\"not\",c:{t:\"def\",m:condition.m}};case\"unary\":return undefined;case\"deferred\":return undefined}}function toComparisonCondition(condition){if(!isComparisonOperator(condition.op))return undefined;var right=evaluateContextFreePreprocessorCondition(condition.r);if(condition.l.t===\"id\"&&right!==undefined){return{t:\"cmp\",m:condition.l.m,op:condition.op,v:right}}var left=evaluateContextFreePreprocessorCondition(condition.l);if(condition.r.t===\"id\"&&left!==undefined){return{t:\"cmp\",m:condition.r.m,op:reverseComparison(condition.op),v:left}}return evaluateStaticCondition(condition)}function isComparisonOperator(operator){return operator===\"==\"||operator===\"!=\"||operator===\">\"||operator===\">=\"||operator===\"<\"||operator===\"<=\"}function reverseComparison(operator){switch(operator){case\"<\":return\">\";case\"<=\":return\">=\";case\">\":return\"<\";case\">=\":return\"<=\";default:return operator}}function evaluateStaticCondition(condition){var value=evaluateContextFreePreprocessorCondition(condition);return value===undefined?undefined:{t:\"bool\",v:value!==0}}function _extends(){_extends=Object.assign||function assign(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source)if(Object.prototype.hasOwnProperty.call(source,key))target[key]=source[key]}return target};return _extends.apply(this,arguments)}var INT_MIN=-0x80000000;var INT_MAX=0x7fffffff;var INTEGER_RANGE=[INT_MIN,INT_MAX];var BOOLEAN_RANGE=[0,1];function normalizePreprocessorCondition(condition){return normalize(condition,new WeakMap)}function getPreprocessorConditionRange(condition,cache){if(cache===void 0)cache=new WeakMap;return getRange(condition,cache)}function getRange(condition,cache){if(cache.has(condition))return cache.get(condition);var result=computeRange(condition,cache);cache.set(condition,result);return result}function computeRange(condition,cache){switch(condition.t){case\"num\":return[condition.v,condition.v];case\"bool\":return[Number(condition.v),Number(condition.v)];case\"def\":case\"ndef\":return BOOLEAN_RANGE;case\"not\":{var child=getRange(condition.c,cache);return child&&(excludesZero(child)?[0,0]:child[0]===child[1]?[1,1]:BOOLEAN_RANGE)}case\"and\":case\"or\":{var left=getRange(condition.l,cache);if(!left)return;var conjunction=condition.t===\"and\";if(conjunction&&left[0]===0&&left[1]===0)return[0,0];if(!conjunction&&excludesZero(left))return[1,1];var right=getRange(condition.r,cache);if(!right)return;if(conjunction&&right[0]===0&&right[1]===0)return[0,0];if(!conjunction&&excludesZero(right))return[1,1];if(excludesZero(left)&&excludesZero(right))return[1,1];if(left[0]===0&&left[1]===0&&right[0]===0&&right[1]===0)return[0,0];return BOOLEAN_RANGE}case\"unary\":{var child1=getRange(condition.c,cache);if(!child1)return;if(child1[0]===child1[1])return constantRange(_extends({},condition,{c:numeric(child1[0])}));if(condition.op===\"+\")return child1;if(condition.op===\"~\")return[~child1[1],~child1[0]];return child1[0]===INT_MIN?INTEGER_RANGE:[-child1[1],-child1[0]]}case\"binary\":{var left1=getRange(condition.l,cache);var right1=getRange(condition.r,cache);if(!left1||!right1)return;if(left1[0]===left1[1]&&right1[0]===right1[1]){return constantRange(_extends({},condition,{l:numeric(left1[0]),r:numeric(right1[0])}))}if(isComparison(condition.op))return BOOLEAN_RANGE;switch(condition.op){case\"+\":return boundedRange(left1[0]+right1[0],left1[1]+right1[1]);case\"-\":return boundedRange(left1[0]-right1[1],left1[1]-right1[0]);case\"*\":{var _Math,_Math1;var products=[left1[0]*right1[0],left1[0]*right1[1],left1[1]*right1[0],left1[1]*right1[1]];return boundedRange((_Math=Math).min.apply(_Math,[].concat(products)),(_Math1=Math).max.apply(_Math1,[].concat(products)))}case\"/\":case\"%\":return excludesZero(right1)?INTEGER_RANGE:undefined;case\"<<\":case\">>\":return right1[0]>=0&&right1[1]<=31?INTEGER_RANGE:undefined;default:return left1[0]>=0&&left1[1]<=1&&right1[0]>=0&&right1[1]<=1?BOOLEAN_RANGE:INTEGER_RANGE}}default:return}}function normalize(condition,cache){var range=getRange(condition,cache);if(!range)return condition;if(excludesZero(range))return boolean(true);if(range[0]===0&&range[1]===0)return boolean(false);switch(condition.t){case\"not\":return negate(normalize(condition.c,cache));case\"and\":case\"or\":return combine(condition.t,normalize(condition.l,cache),normalize(condition.r,cache));case\"binary\":if(isComparison(condition.op)){var left=getRange(condition.l,cache);var right=getRange(condition.r,cache);if(right[0]===right[1])return compare(condition.l,condition.op,right[0],cache);if(left[0]===left[1])return compare(condition.r,reverse(condition.op),left[0],cache)}break}var _arithmeticTruth;return(_arithmeticTruth=arithmeticTruth(condition,cache))!=null?_arithmeticTruth:condition}function arithmeticTruth(condition,cache){if(condition.t===\"def\"||condition.t===\"ndef\")return condition;if(condition.t===\"unary\"&&condition.op!==\"~\")return normalize(condition.c,cache);if(condition.t!==\"binary\")return;var left=getRange(condition.l,cache);var right=getRange(condition.r,cache);if(condition.op===\"+\"&&unwrappedSum(left,right)){if(left[0]>=0&&right[0]>=0||left[1]<=0&&right[1]<=0){return combine(\"or\",normalize(condition.l,cache),normalize(condition.r,cache))}}if(condition.op===\"|\"){return combine(\"or\",normalize(condition.l,cache),normalize(condition.r,cache))}if(condition.op===\"&\"&&left[0]>=0&&left[1]<=1&&right[0]>=0&&right[1]<=1){return combine(\"and\",normalize(condition.l,cache),normalize(condition.r,cache))}}function compare(expression,operator,value,cache){switch(operator){case\"<\":return lessThan(expression,value,cache);case\"<=\":return lessThan(expression,value+1,cache);case\">\":return negate(lessThan(expression,value+1,cache));case\">=\":return negate(lessThan(expression,value,cache));case\"==\":return combine(\"and\",negate(lessThan(expression,value,cache)),lessThan(expression,value+1,cache));case\"!=\":return combine(\"or\",lessThan(expression,value,cache),negate(lessThan(expression,value+1,cache)))}}function lessThan(expression,value,cache){var range=getRange(expression,cache);if(range[1]<value)return boolean(true);if(range[0]>=value)return boolean(false);if(range[0]===0&&value===1||range[1]===0&&value===0){var truth=arithmeticTruth(expression,cache);if(truth)return range[0]===0?negate(truth):truth}if(value===range[0]+1||value===range[1]){var maximum=value===range[1];var endpoint=sumEndpoint(expression,maximum,cache);if(endpoint)return maximum?negate(endpoint):endpoint}return{t:\"binary\",op:\"<\",l:expression,r:numeric(value)}}function sumEndpoint(expression,maximum,cache){if(expression.t!==\"binary\"||expression.op!==\"+\")return;var left=getRange(expression.l,cache);var right=getRange(expression.r,cache);if(!unwrappedSum(left,right))return;var bound=maximum?1:0;return combine(\"and\",compare(expression.l,\"==\",left[bound],cache),compare(expression.r,\"==\",right[bound],cache))}function combine(operator,left,right){if(left.t===\"bool\")return left.v===(operator===\"and\")?right:left;if(right.t===\"bool\")return right.v===(operator===\"and\")?left:right;return{t:operator,l:left,r:right}}function negate(condition){switch(condition.t){case\"bool\":return boolean(!condition.v);case\"def\":return{t:\"ndef\",m:condition.m};case\"ndef\":return{t:\"def\",m:condition.m};case\"not\":return condition.c;case\"and\":case\"or\":return combine(condition.t===\"and\"?\"or\":\"and\",negate(condition.l),negate(condition.r));default:return{t:\"not\",c:condition}}}function unwrappedSum(left,right){return left[0]+right[0]>=INT_MIN&&left[1]+right[1]<=INT_MAX}function boundedRange(minimum,maximum){return minimum>=INT_MIN&&maximum<=INT_MAX?[minimum,maximum]:INTEGER_RANGE}function constantRange(condition){var value=evaluateContextFreePreprocessorCondition(condition);return value===undefined?undefined:[value,value]}function excludesZero(range){return range[0]>0||range[1]<0}function numeric(value){return{t:\"num\",v:value}}function boolean(value){return{t:\"bool\",v:value}}function isComparison(operator){return[\"<\",\"<=\",\">\",\">=\",\"==\",\"!=\"].includes(operator)}function reverse(operator){switch(operator){case\"<\":return\">\";case\"<=\":return\">=\";case\">\":return\"<\";case\">=\":return\"<=\";default:return operator}}var MAX_DIAGRAM_WORK=16384;var EXHAUSTED=Symbol(\"condition diagram budget\");function provePreprocessorConditionCoverage(declarations,reference){var diagram=new ConditionDiagram;try{var source=diagram.predicates(reference);var target=diagram.constant(0);for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var declaration=_step.value;target=diagram.apply(\"or\",target,diagram.predicates(declaration))}return diagram.coverage(diagram.apply(\"or\",diagram.apply(\"not\",source),target))}catch(error){if(error!==EXHAUSTED)throw error;return undefined}}var ConditionDiagram=function(){function ConditionDiagram(){this._nodes=[];this._constants=new Map;this._variables=new Map;this._opaqueVariables=new Set;this._branches=new Map;this._operations=new Map;this._expressions=new Map;this._remaining=MAX_DIAGRAM_WORK}var _proto=ConditionDiagram.prototype;_proto.coverage=function coverage(root){var pending=[{id:root,opaque:false}];var visited=[new Set,new Set];var unknown=false;while(pending.length){var _pending_pop=pending.pop(),id=_pending_pop.id,opaque=_pending_pop.opaque;var seen=visited[Number(opaque)];if(seen.has(id))continue;seen.add(id);this._spend();var node=this._nodes[id];if(node.variable!==Infinity){var uncertain=opaque||this._opaqueVariables.has(node.variable);pending.push({id:node.low,opaque:uncertain},{id:node.high,opaque:uncertain})}else if(node.value===0){if(!opaque)return false;unknown=true}else if(node.value===undefined)unknown=true}return unknown?undefined:true};_proto.constant=function constant(value){var id=this._constants.get(value);if(id===undefined){this._spend();id=this._nodes.length;this._nodes.push({variable:Infinity,low:0,high:0,value:value});this._constants.set(value,id)}return id};_proto.predicates=function predicates(predicates){if(typeof predicates===\"boolean\")return this.constant(Number(predicates));var value=this.constant(1);for(var _iterator=_create_for_of_iterator_helper_loose(predicates),_step;!(_step=_iterator()).done;){var _step_value=_step.value,condition=_step_value.condition,negated=_step_value.negated;var expression=condition.kind===\"opaque\"?this._variable(\"opaque:\"+condition.identity,true):this._expression(condition.expression,condition);value=this.apply(\"and\",value,this.apply(negated?\"not\":\"truth\",expression))}return value};_proto.apply=function apply(operator,left,right){if(right===void 0)right=left;var key=operator+\":\"+left+\":\"+right;var cached=this._operations.get(key);if(cached!==undefined)return cached;this._spend();var a=this._nodes[left];var b=this._nodes[right];var result;if(a.variable===Infinity&&a.value===undefined){result=left}else if(a.variable===Infinity&&operator===\"and\"&&a.value===0){result=this.constant(0)}else if(a.variable===Infinity&&operator===\"or\"&&a.value!==0){result=this.constant(1)}else if(a.variable===Infinity&&b.variable===Infinity){result=this._evaluate(operator,a.value,b.value)}else{var variable=Math.min(a.variable,b.variable);result=this._branch(variable,this.apply(operator,a.variable===variable?a.low:left,b.variable===variable?b.low:right),this.apply(operator,a.variable===variable?a.high:left,b.variable===variable?b.high:right))}this._operations.set(key,result);return result};_proto._expression=function _expression(expression,owner){var cache=this._expressions.get(owner);if(!cache)this._expressions.set(owner,cache=new Map);var cached=cache.get(expression);if(cached!==undefined)return cached;var result;switch(expression.t){case\"bool\":result=this.constant(Number(expression.v));break;case\"num\":result=this.constant(expression.v);break;case\"def\":case\"ndef\":result=this._variable(\"defined:\"+expression.m+\":\"+owner.versions[expression.m]);if(expression.t===\"ndef\")result=this.apply(\"not\",result);break;case\"not\":result=this.apply(\"not\",this._expression(expression.c,owner));break;case\"unary\":result=this.apply(expression.op===\"+\"?\"positive\":expression.op===\"-\"?\"negative\":\"complement\",this._expression(expression.c,owner));break;case\"and\":case\"or\":case\"binary\":{var operator=expression.t===\"binary\"?expression.op:expression.t;result=[\"and\",\"or\",\"+\",\"*\",\"&\",\"|\",\"^\"].includes(operator)?this._associativeExpression(expression,owner,operator):this.apply(operator,this._expression(expression.l,owner),this._expression(expression.r,owner));break}default:result=this.constant();break}cache.set(expression,result);return result};_proto._associativeExpression=function _associativeExpression(expression,owner,operator){var pending=[expression];var operands=[];while(pending.length){var node=pending.pop();if(node.t===\"binary\"&&node.op===operator||(node.t===\"and\"||node.t===\"or\")&&node.t===operator){pending.push(node.r,node.l)}else{operands.push(this._expression(node,owner))}}while(operands.length>1){var count=0;for(var index=0;index<operands.length;index+=2){operands[count++]=index+1<operands.length?this.apply(operator,operands[index],operands[index+1]):operands[index]}operands.length=count}return operands[0]};_proto._variable=function _variable(identity,opaque){if(opaque===void 0)opaque=false;var variable=this._variables.get(identity);if(variable===undefined)this._variables.set(identity,variable=this._variables.size);if(opaque)this._opaqueVariables.add(variable);return this._branch(variable,this.constant(0),this.constant(1))};_proto._branch=function _branch(variable,low,high){if(low===high)return low;var key=variable+\":\"+low+\":\"+high;var id=this._branches.get(key);if(id===undefined){this._spend();id=this._nodes.length;this._nodes.push({variable:variable,low:low,high:high});this._branches.set(key,id)}return id};_proto._evaluate=function _evaluate(operator,left,right){if(operator===\"truth\")return this.constant(Number(left!==0));if(operator===\"not\")return this.constant(Number(left===0));var l={t:\"num\",v:left};var expression;if(operator===\"positive\"||operator===\"negative\"||operator===\"complement\"){expression={t:\"unary\",op:operator===\"positive\"?\"+\":operator===\"negative\"?\"-\":\"~\",c:l}}else{if(right===undefined)return this.constant();var r={t:\"num\",v:right};expression=operator===\"and\"||operator===\"or\"?{t:operator,l:l,r:r}:{t:\"binary\",op:operator,l:l,r:r}}var value;try{value=evaluateContextFreePreprocessorCondition(expression)}catch(e){value=undefined}return this.constant(value)};_proto._spend=function _spend(){if(--this._remaining<0)throw EXHAUSTED};return ConditionDiagram}();function capturePreprocessorCondition(expression,versions){var dependencies=Object.create(null);var pending=[expression];while(pending.length){var condition=pending.pop();switch(condition.t){case\"def\":case\"ndef\":var _versions_condition_m;dependencies[condition.m]=(_versions_condition_m=versions[condition.m])!=null?_versions_condition_m:0;break;case\"not\":case\"unary\":pending.push(condition.c);break;case\"and\":case\"or\":case\"binary\":pending.push(condition.l,condition.r);break}}return{kind:\"expression\",expression:expression,versions:dependencies}}function canInheritanceBranchesCover(declarations,reference){return proveInheritanceBranchesCover(declarations,reference)===true}function proveInheritanceBranchesCover(declarations,reference){var facts=getPredicates(reference);var alternatives=declarations.map(getPredicates);if(alternatives.includes(true)||facts===false)return true;if(facts===undefined)return undefined;var required=alternatives.filter(function(predicates){return predicates!==undefined});var normalized=new Map;function normalize(predicates){if(typeof predicates===\"boolean\")return predicates;return predicates.map(function(param){var condition=param.condition,negated=param.negated;var canonical=normalized.get(condition);if(!canonical){canonical=condition.kind===\"opaque\"?condition:_extends({},condition,{expression:normalizePreprocessorCondition(condition.expression)});normalized.set(condition,canonical)}return{condition:canonical,negated:negated}})}required=required.map(normalize);facts=normalize(facts);var rangeCache=new WeakMap;if(required.some(function(alternative){return proveCanonicalCoverage(alternative,facts,rangeCache)}))return true;var proof=provePreprocessorConditionCoverage(required,facts);return proof===false&&alternatives.includes(undefined)?undefined:proof}function getPredicates(branch){var predicates=[];for(var _iterator=_create_for_of_iterator_helper_loose(branch),_step;!(_step=_iterator()).done;){var sourceArm=_step.value.sourceArm;var _predicates;if((sourceArm==null?void 0:sourceArm.value)===true)continue;if((sourceArm==null?void 0:sourceArm.value)===false)return false;if(!(sourceArm==null?void 0:sourceArm.predicates))return;(_predicates=predicates).push.apply(_predicates,[].concat(sourceArm.predicates))}return predicates.length?predicates:true}function proveCanonicalCoverage(required,facts,rangeCache){var known=new Set;var ranges=new Map;var keys=new Map;var identities=new Map;var rangeOf=function(expression){return getPreprocessorConditionRange(expression,rangeCache)};var impossible=facts===false;function intern(signature){var identity=identities.get(signature);if(identity===undefined)identities.set(signature,identity=identities.size+1);return identity}function key(expression,owner){var cache=keys.get(owner);if(!cache)keys.set(owner,cache=new Map);var result=cache.get(expression);if(result===undefined){result=canonicalExpressionKey(expression,owner.kind===\"expression\"?owner.versions:{},function(child){return key(child,owner)},rangeOf,intern);cache.set(expression,result)}return result}function interval(expression,negated,owner){var numeric=expression;var allowed;if(expression.t===\"binary\"&&expression.op===\"<\"&&expression.r.t===\"num\"){numeric=expression.l;allowed=negated?[expression.r.v,0x7fffffff]:[-0x80000000,expression.r.v-1]}else if(negated){allowed=[0,0]}else{var domain=rangeOf(numeric);if(!domain||domain[0]<0&&domain[1]>0)return;allowed=domain[0]>=0?[1,0x7fffffff]:[-0x80000000,-1]}var domain1=rangeOf(numeric);if(!domain1)return;return{key:key(numeric,owner),domain:domain1,allowed:[Math.max(domain1[0],allowed[0]),Math.min(domain1[1],allowed[1])]}}function visit(owner,expression,negated,record){if(owner.kind===\"opaque\"){var identity=(negated?-1:1)*intern(opaqueKey(owner.identity));if(record)known.add(identity);return known.has(identity)}if(!expression)return false;if(expression.t===\"not\")return visit(owner,expression.c,!negated,record);if(expression.t===\"bool\"||expression.t===\"num\"){var value=Boolean(expression.v)!==negated;if(record&&!value)impossible=true;return value}var identity1=(negated?-1:1)*key(expression,owner);if(record)known.add(identity1);else if(known.has(identity1))return true;if(expression.t===\"and\"||expression.t===\"or\"){if(!rangeOf(expression))return false;var conjunction=expression.t===\"and\"!==negated;if(record&&!conjunction)return false;var left=visit(owner,expression.l,negated,record);var right=visit(owner,expression.r,negated,record);return conjunction?left&&right:left||right}var constraint=interval(expression,negated,owner);if(!constraint)return false;var _ranges_get;var previous=(_ranges_get=ranges.get(constraint.key))!=null?_ranges_get:constraint.domain;var allowed=constraint.allowed;if(record){var narrowed=[Math.max(previous[0],allowed[0]),Math.min(previous[1],allowed[1])];if(narrowed[0]>narrowed[1])impossible=true;ranges.set(constraint.key,narrowed);return true}return previous[0]>=allowed[0]&&previous[1]<=allowed[1]}if(typeof facts!==\"boolean\"){for(var _iterator=_create_for_of_iterator_helper_loose(facts),_step;!(_step=_iterator()).done;){var _step_value=_step.value,condition=_step_value.condition,negated=_step_value.negated;visit(condition,condition.kind===\"expression\"?condition.expression:undefined,negated,true)}}return impossible||(typeof required===\"boolean\"?required:required.every(function(param){var condition=param.condition,negated=param.negated;return visit(condition,condition.kind===\"expression\"?condition.expression:undefined,negated,false)}))}function canonicalExpressionKey(expression,versions,key,rangeOf,intern){var range=rangeOf(expression);if(range&&range[0]===range[1])return intern(\"num:\"+range[0]);switch(expression.t){case\"def\":case\"ndef\":return intern(expression.t+\":\"+definedKey(expression.m,versions[expression.m]));case\"not\":return intern(\"not(\"+key(expression.c)+\")\");case\"unary\":return intern(expression.op+\"(\"+key(expression.c)+\")\");case\"and\":case\"or\":case\"binary\":{var operator=expression.t===\"binary\"?expression.op:expression.t;var numeric=[\"+\",\"*\",\"&\",\"|\",\"^\"].includes(operator);if(numeric||(operator===\"and\"||operator===\"or\")&&range){var terms=[];var constant;var collect=function(node){if(node.t===\"binary\"&&node.op===operator||(node.t===\"and\"||node.t===\"or\")&&node.t===operator){collect(node.l);collect(node.r)}else{var value=rangeOf(node);if(numeric&&value&&value[0]===value[1]){constant=constant===undefined?value[0]:evaluateContextFreePreprocessorCondition({t:\"binary\",op:operator,l:{t:\"num\",v:constant},r:{t:\"num\",v:value[0]}})}else terms.push(key(node))}};collect(expression);var identity=operator===\"*\"?1:operator===\"&\"?-1:0;if(numeric&&constant!==undefined&&(constant!==identity||!terms.length)){terms.push(intern(\"num:\"+constant))}terms.sort(function(left,right){return left-right});return terms.length===1?terms[0]:intern(operator+\"(\"+terms.join(\",\")+\")\")}return intern(operator+\"(\"+key(expression.l)+\",\"+key(expression.r)+\")\")}default:return intern(JSON.stringify(expression))}}function definedKey(name,version){return\"defined:\"+name+\":\"+version}function opaqueKey(identity){return\"opaque:\"+identity}var SymbolTable=function(){function SymbolTable(){this._table=new Map}var _proto=SymbolTable.prototype;_proto.insert=function insert(symbol,isInMacroBranch,branchSignature,branchSemantics){if(isInMacroBranch===void 0)isInMacroBranch=false;if(branchSignature===void 0)branchSignature=EMPTY_BRANCH;symbol.isInMacroBranch=isInMacroBranch;symbol.branchSignature=branchSignature;var _this__table_get;var entry=(_this__table_get=this._table.get(symbol.ident))!=null?_this__table_get:[];var _symbol_sourceScope;var sourceScope=(_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0;if(sourceScope>0){for(var i=entry.length-1;i>=0;i--){var existing=entry[i];var _existing_sourceScope;var inheritedScope=(_existing_sourceScope=existing.sourceScope)!=null?_existing_sourceScope:0;if(!existing.equal(symbol)||inheritedScope>=sourceScope)continue;var alternatives=[branchSignature];for(var _iterator=_create_for_of_iterator_helper_loose(entry),_step;!(_step=_iterator()).done;){var candidate=_step.value;var _candidate_sourceScope;if(((_candidate_sourceScope=candidate.sourceScope)!=null?_candidate_sourceScope:0)>inheritedScope&&candidate.equal(symbol)){var _candidate_branchSignature;alternatives.push((_candidate_branchSignature=candidate.branchSignature)!=null?_candidate_branchSignature:EMPTY_BRANCH)}}var _existing_branchSignature;if(canInheritanceBranchesCover(alternatives,(_existing_branchSignature=existing.branchSignature)!=null?_existing_branchSignature:EMPTY_BRANCH)){entry.splice(i,1)}}}if(!branchSemantics){return this._insertWithoutBranchAnalysis(entry,symbol)}var conflict=\"none\";for(var i1=0,n=entry.length;i1<n;i1++){var existing1=entry[i1];if(!existing1.equal(symbol))continue;var _existing_sourceScope1;if(((_existing_sourceScope1=existing1.sourceScope)!=null?_existing_sourceScope1:0)<sourceScope)continue;var _existing_branchSignature1;var existingBranch=(_existing_branchSignature1=existing1.branchSignature)!=null?_existing_branchSignature1:EMPTY_BRANCH;if(existingBranch.length===0&&branchSignature.length===0){entry[i1]=symbol;return\"coexist\"}var coexistence=branchSemantics.getDeclarationCoexistence(existingBranch,branchSignature);if(coexistence===\"coexist\")conflict=\"coexist\";else if(coexistence===\"unknown\"&&conflict===\"none\")conflict=\"unknown\"}entry.push(symbol);this._table.set(symbol.ident,entry);return conflict};_proto._insertWithoutBranchAnalysis=function _insertWithoutBranchAnalysis(entry,symbol){for(var i=0,n=entry.length;i<n;i++){var _entry_i_sourceScope,_symbol_sourceScope;if(entry[i].isInMacroBranch||((_entry_i_sourceScope=entry[i].sourceScope)!=null?_entry_i_sourceScope:0)!==((_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0)||!entry[i].equal(symbol))continue;entry[i]=symbol;return\"coexist\"}entry.push(symbol);this._table.set(symbol.ident,entry);return\"none\"};_proto.getInheritedConflict=function getInheritedConflict(symbol,branchSemantics,isDeferred){var entry=this._table.get(symbol.ident);if(!(entry==null?void 0:entry.includes(symbol)))return\"none\";var conflict=\"none\";for(var _iterator=_create_for_of_iterator_helper_loose(entry),_step;!(_step=_iterator()).done;){var existing=_step.value;var _existing_sourceScope,_symbol_sourceScope;if(((_existing_sourceScope=existing.sourceScope)!=null?_existing_sourceScope:0)>=((_symbol_sourceScope=symbol.sourceScope)!=null?_symbol_sourceScope:0)||!existing.equal(symbol))continue;if(isDeferred==null?void 0:isDeferred(existing,symbol))continue;var _existing_branchSignature,_symbol_branchSignature;var coexistence=branchSemantics.getDeclarationCoexistence((_existing_branchSignature=existing.branchSignature)!=null?_existing_branchSignature:EMPTY_BRANCH,(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH);if(coexistence===\"coexist\")return\"coexist\";if(coexistence===\"unknown\")conflict=\"unknown\"}return conflict};_proto.getSymbol=function getSymbol(symbol,includeMacro,callsiteBranch,branchSemantics){if(includeMacro===void 0)includeMacro=false;var entry=this._table.get(symbol.ident);if(entry){for(var i=entry.length-1;i>=0;i--){var item=entry[i];var visible=includeMacro||!item.isInMacroBranch;if(branchSemantics&&callsiteBranch!==undefined){var _item_branchSignature;visible=branchSemantics.isBranchVisibleFrom((_item_branchSignature=item.branchSignature)!=null?_item_branchSignature:EMPTY_BRANCH,callsiteBranch)}if(!visible)continue;if(item.equal(symbol))return item}}};_proto.getSymbols=function getSymbols(symbol,includeMacro,out){if(includeMacro===void 0)includeMacro=false;out.length=0;this._getSymbols(symbol,includeMacro,out);return out};_proto.hasSymbol=function hasSymbol(symbol){var entry=this._table.get(symbol.ident);if(!entry)return false;for(var i=0,n=entry.length;i<n;i++){if(entry[i].equal(symbol))return true}return false};_proto._getSymbols=function _getSymbols(symbol,includeMacro,out,callsiteBranch,branchSemantics){if(includeMacro===void 0)includeMacro=false;var entry=this._table.get(symbol.ident);if(entry){for(var i=entry.length-1;i>=0;i--){var item=entry[i];var visible=includeMacro||!item.isInMacroBranch;if(callsiteBranch!==undefined){var _item_branchSignature,_item_branchSignature1;visible=branchSemantics?branchSemantics.canBranchesOverlap((_item_branchSignature=item.branchSignature)!=null?_item_branchSignature:EMPTY_BRANCH,callsiteBranch):getLexicalDeclarationCoexistence((_item_branchSignature1=item.branchSignature)!=null?_item_branchSignature1:EMPTY_BRANCH,callsiteBranch)!==\"exclusive\"}if(!visible)continue;if(item.equal(symbol))out.push(item)}}return out};_proto.forEach=function forEach(callback){for(var _iterator=_create_for_of_iterator_helper_loose(this._table.values()),_step;!(_step=_iterator()).done;){var entries=_step.value;for(var i=0,n=entries.length;i<n;i++){callback(entries[i])}}};return SymbolTable}();var SymbolTableStack=function(){function SymbolTableStack(){this.stack=[];this._macroLevel=0;this._currentBranch=EMPTY_BRANCH}var _proto=SymbolTableStack.prototype;_proto.pushScope=function pushScope(scope){this.stack.push(scope)};_proto.clear=function clear(){this.stack.length=0;this._macroLevel=0;this._currentBranch=EMPTY_BRANCH};_proto.popScope=function popScope(){return this.stack.pop()};_proto.insert=function insert(symbol,branchSignature){if(branchSignature===void 0)branchSignature=this._currentBranch;return this.scope.insert(symbol,this.isInMacroBranch,branchSignature,this.branchSemantics)};_proto.lookup=function lookup(symbol,includeMacro,callsiteBranch){if(includeMacro===void 0)includeMacro=false;for(var i=this.stack.length-1;i>=0;i--){var symbolTable=this.stack[i];var result=symbolTable.getSymbol(symbol,includeMacro,callsiteBranch,this.branchSemantics);if(result)return result}return undefined};_proto.hasSymbol=function hasSymbol(symbol){for(var i=this.stack.length-1;i>=0;i--){if(this.stack[i].hasSymbol(symbol))return true}return false};_proto.lookupAll=function lookupAll(symbol,includeMacro,out,callsiteBranch){if(includeMacro===void 0)includeMacro=false;out.length=0;for(var i=this.stack.length-1;i>=0;i--){var symbolTable=this.stack[i];symbolTable._getSymbols(symbol,includeMacro,out,callsiteBranch,this.branchSemantics);if(out.length>0)break}return out};_proto.lookupAllWithRuntimeFallbacks=function lookupAllWithRuntimeFallbacks(symbol,includeMacro,out,runtimeFallbacks,callsiteBranch){out.length=0;runtimeFallbacks.length=0;for(var i=this.stack.length-1;i>=0;i--){if(!out.length){this.stack[i]._getSymbols(symbol,includeMacro,out,callsiteBranch,this.branchSemantics);if(!out.length)continue;if(this._runtimeCandidatesCoverCallsite(out,callsiteBranch))break}else{var fallbackStart=runtimeFallbacks.length;this.stack[i]._getSymbols(symbol,includeMacro,runtimeFallbacks,callsiteBranch,this.branchSemantics);if(runtimeFallbacks.length>fallbackStart&&this._runtimeCandidatesCoverCallsite(runtimeFallbacks,callsiteBranch)){break}}}return out};_proto._runtimeCandidatesCoverCallsite=function _runtimeCandidatesCoverCallsite(candidates,callsiteBranch){for(var i=0;i<candidates.length;i++){var candidate=candidates[i];var _candidate_branchSignature;if(!candidate.isInMacroBranch||callsiteBranch&&isLexicalBranchVisibleFrom((_candidate_branchSignature=candidate.branchSignature)!=null?_candidate_branchSignature:EMPTY_BRANCH,callsiteBranch)){return true}}return false};_create_class(SymbolTableStack,[{key:\"scope\",get:function get(){return this.stack[this.stack.length-1]}},{key:\"isInMacroBranch\",get:function get(){return this._macroLevel>0}}]);return SymbolTableStack}();var EShaderStage=function(EShaderStage){EShaderStage[EShaderStage[\"VERTEX\"]=0]=\"VERTEX\";EShaderStage[EShaderStage[\"FRAGMENT\"]=1]=\"FRAGMENT\";EShaderStage[EShaderStage[\"ALL\"]=2]=\"ALL\";return EShaderStage}({});function __decorate(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect===\"object\"&&typeof Reflect.decorate===\"function\")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r}function __generator(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},f,y,t,g=Object.create((typeof Iterator===\"function\"?Iterator:Object).prototype);return g.next=verb(0),g[\"throw\"]=verb(1),g[\"return\"]=verb(2),typeof Symbol===\"function\"&&(g[Symbol.iterator]=function(){return this}),g;function verb(n){return function(v){return step([n,v])}}function step(op){if(f)throw new TypeError(\"Generator is already executing.\");while(g&&(g=0,op[0]&&(_=0)),_)try{if(f=1,y&&(t=op[0]&2?y[\"return\"]:op[0]?y[\"throw\"]||((t=y[\"return\"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue}if(op[0]===3&&(!t||op[1]>t[0]&&op[1]<t[3])){_.label=op[1];break}if(op[0]===6&&_.label<t[1]){_.label=t[1];t=op;break}if(t&&_.label<t[2]){_.label=t[2];_.ops.push(op);break}if(t[2])_.ops.pop();_.trys.pop();continue}op=body.call(thisArg,_)}catch(e){op=[6,e];y=0}finally{f=t=0}if(op[0]&5)throw op[1];return{value:op[0]?op[1]:void 0,done:true}}}function __values(o){var s=typeof Symbol===\"function\"&&Symbol.iterator,m=s&&o[s],i=0;if(m)return m.call(o);if(o&&typeof o.length===\"number\")return{next:function(){if(o&&i>=o.length)o=void 0;return{value:o&&o[i++],done:!o}}};throw new TypeError(s?\"Object is not iterable.\":\"Symbol.iterator is not defined.\")}typeof SuppressedError===\"function\"?SuppressedError:function(error,suppressed,message){var e=new Error(message);return e.name=\"SuppressedError\",e.error=error,e.suppressed=suppressed,e};var Lexer=function(BaseLexer1){_inherits(Lexer,BaseLexer1);function Lexer(source,macroDefineList,objectPool,_conditionalArms){var _this;_this=BaseLexer1.call(this,source,objectPool)||this,_this.macroDefineList=macroDefineList,_this._conditionalArms=_conditionalArms,_this.preprocessorExpressions=new Map,_this._needScanMacroConditionExpression=false,_this._inMacroDefineValue=false,_this._macroDefineExpectsNameToken=false,_this._macroDefineExpectsParamsToken=false,_this._currentMacroName=\"\",_this._currentMacroParamsLexeme=undefined,_this._currentMacroValueStart=-1,_this._branchStack=[],_this._branchSnapshot=EMPTY_BRANCH,_this._conditionalGroup=0,_this._pendingBranchPushDefined=null,_this._pendingCodegenConditional=null,_this._codegenConditionalFrames=[];return _this}var _proto=Lexer.prototype;_proto.tokenize=function tokenize(){return __generator(this,function(_state){switch(_state.label){case 0:return[5,__values(this._tokenizeForCodegen())];case 1:_state.sent();return[2,this._createEOFToken()]}})};_proto._tokenizeForCodegen=function _tokenizeForCodegen(){var tok,parsedCondition,conditionalGroup,arm,index,previous,frame,definitelyMatched,condition,_previous_conditionalArm,isMacroName,conditionalGroup1,arm1,_this__conditionalArms,_this__conditionalArms1,_this__conditionalArms2,_this__conditionalArms3,index1,previous1,_this__conditionalArms4,frame1,condition1,_previous_conditionalArm1,frame2,reachableArms,_iterator,_step,arm2;return __generator(this,function(_state){switch(_state.label){case 0:if(!!this.isEnd())return[3,2];tok=this.scanToken();if(this._pendingCodegenConditional&&tok.type===Keyword.MACRO_CONDITIONAL_EXPRESSION){parsedCondition=this._parseCodegenConstantCondition(tok.lexeme);if(this._pendingCodegenConditional===\"push\"){conditionalGroup=++this._conditionalGroup;arm={name:\"__if_\"+conditionalGroup,defined:true,sourceArm:this._pendingCodegenArm,conditionalGroup:conditionalGroup,conditionalArm:0,condition:parsedCondition};this._branchStack.push(arm);this._codegenConditionalFrames.push({arms:[arm],definitelyMatched:(parsedCondition==null?void 0:parsedCondition.kind)===\"constant\"&&parsedCondition.value})}else{index=this._branchStack.length-1;previous=this._branchStack[index];if(previous){frame=this._codegenConditionalFrames[index];definitelyMatched=frame.definitelyMatched;condition=definitelyMatched?{kind:\"constant\",value:false}:parsedCondition;this._branchStack[index]={name:previous.name,defined:true,conditionalGroup:previous.conditionalGroup,conditionalArm:((_previous_conditionalArm=previous.conditionalArm)!=null?_previous_conditionalArm:0)+1,sourceArm:this._pendingCodegenArm,condition:condition};frame.arms.push(this._branchStack[index]);if(!definitelyMatched&&(parsedCondition==null?void 0:parsedCondition.kind)===\"constant\"&&parsedCondition.value){frame.definitelyMatched=true}}}this._pendingCodegenConditional=null}isMacroName=tok.type===ETokenType.ID||tok.type===Keyword.MACRO_CALL;if(this._pendingBranchPushDefined!==null&&isMacroName){conditionalGroup1=++this._conditionalGroup;arm1={name:tok.lexeme,defined:this._pendingBranchPushDefined,sourceArm:this._pendingCodegenArm,conditionalGroup:conditionalGroup1,conditionalArm:0};this._branchStack.push(arm1);this._codegenConditionalFrames.push({arms:[arm1],definitelyMatched:false});this._pendingBranchPushDefined=null}if(this._branchStack.length>0)tok.branch=this._captureBranchSignature();switch(tok.type){case Keyword.MACRO_IFDEF:this._pendingCodegenArm=(_this__conditionalArms=this._conditionalArms)==null?void 0:_this__conditionalArms.get(tok.location.start.index);this._pendingBranchPushDefined=true;break;case Keyword.MACRO_IFNDEF:this._pendingCodegenArm=(_this__conditionalArms1=this._conditionalArms)==null?void 0:_this__conditionalArms1.get(tok.location.start.index);this._pendingBranchPushDefined=false;break;case Keyword.MACRO_IF:this._pendingCodegenArm=(_this__conditionalArms2=this._conditionalArms)==null?void 0:_this__conditionalArms2.get(tok.location.start.index);this._pendingCodegenConditional=\"push\";break;case Keyword.MACRO_ELIF:this._pendingCodegenArm=(_this__conditionalArms3=this._conditionalArms)==null?void 0:_this__conditionalArms3.get(tok.location.start.index);this._pendingCodegenConditional=\"advance\";break;case Keyword.MACRO_ELSE:{index1=this._branchStack.length-1;previous1=this._branchStack[index1];if(previous1){frame1=this._codegenConditionalFrames[index1];condition1=frame1.definitelyMatched?{kind:\"constant\",value:false}:undefined;this._branchStack[index1]={name:previous1.name,defined:!previous1.defined,sourceArm:(_this__conditionalArms4=this._conditionalArms)==null?void 0:_this__conditionalArms4.get(tok.location.start.index),conditionalGroup:previous1.conditionalGroup,conditionalArm:((_previous_conditionalArm1=previous1.conditionalArm)!=null?_previous_conditionalArm1:0)+1,condition:condition1};frame1.arms.push(this._branchStack[index1]);frame1.definitelyMatched=true}break}case Keyword.MACRO_ENDIF:{this._branchStack.pop();frame2=this._codegenConditionalFrames.pop();if(frame2==null?void 0:frame2.definitelyMatched){reachableArms=frame2.arms.map(function(arm){var _arm_condition;return((_arm_condition=arm.condition)==null?void 0:_arm_condition.kind)!==\"constant\"||arm.condition.value});for(_iterator=_create_for_of_iterator_helper_loose(frame2.arms);!(_step=_iterator()).done;){arm2=_step.value;arm2.conditionalComplete=true;arm2.conditionalArmCount=frame2.arms.length;arm2.conditionalReachableArms=reachableArms}}break}}return[4,tok];case 1:_state.sent();return[3,0];case 2:return[2,this._createEOFToken()]}})};_proto._parseCodegenConstantCondition=function _parseCodegenConstantCondition(expression){var parsed=this.preprocessorExpressions.get(expression.trim());var value=(parsed==null?void 0:parsed.ok)&&!parsed.hasExpandableIdentifier?evaluateContextFreePreprocessorCondition(parsed.condition):undefined;return value===undefined?undefined:{kind:\"constant\",value:value!==0}};_proto._isBranchReachable=function _isBranchReachable(branch){return Lexer._isCodegenBranchReachable(branch)};_proto._sameDefinitionBranch=function _sameDefinitionBranch(left,right){return Lexer._sameCodegenBranch(left,right)};_proto._branchesOverlap=function _branchesOverlap(left,right){return getLexicalDeclarationCoexistence(left,right)!==\"exclusive\"};_proto.scanToken=function scanToken(){if(this._inMacroDefineValue){this._skipInlineSpaceAndComments();if(this.isEnd()||this._isAtLineBreak()){return this._emitMacroDefineEnd()}if(this._macroDefineExpectsParamsToken){this._macroDefineExpectsParamsToken=false;if(this.getCurChar()===\"(\"){return this._scanMacroDefineParams()}}}else{this.skipCommentsAndSpace();if(this.isEnd()){return this._createEOFToken()}}if(this._needScanMacroConditionExpression){this._needScanMacroConditionExpression=false;return this._scanMacroConditionExpression()}var curCharCode=this.getCurCharCode();if(BaseLexer.isPreprocessorStartChar(curCharCode)){return this._scanDirectives()}if(BaseLexer.isAlpha(curCharCode)){return this._scanWord()}if(BaseLexer.isDigit(curCharCode)){return this._scanNum()}var start=this.getShaderPosition();var token=this._createToken();var curChar;switch(this.getCurChar()){case\"<\":this.advance(1);curChar=this.getCurChar();if(curChar===\"<\"){this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.LEFT_ASSIGN,\"<<=\",start);break}token.set(ETokenType.LEFT_OP,\"<<\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.LE_OP,\"<=\",start);break}token.set(ETokenType.LEFT_ANGLE,\"<\",start);break;case\">\":this.advance(1);curChar=this.getCurChar();if(curChar===\">\"){this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.RIGHT_ASSIGN,\">>=\",start);break}token.set(ETokenType.RIGHT_OP,\">>\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.GE_OP,\">=\",start);break}token.set(ETokenType.RIGHT_ANGLE,\">\",start);break;case\"+\":this.advance(1);curChar=this.getCurChar();if(curChar===\"+\"){this.advance(1);token.set(ETokenType.INC_OP,\"++\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.ADD_ASSIGN,\"+=\",start);break}token.set(ETokenType.PLUS,\"+\",start);break;case\"-\":this.advance(1);curChar=this.getCurChar();if(curChar===\"-\"){this.advance(1);token.set(ETokenType.DEC_OP,\"--\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.SUB_ASSIGN,\"-=\",start);break}token.set(ETokenType.DASH,\"-\",start);break;case\"=\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.EQ_OP,\"==\",start);break}token.set(ETokenType.EQUAL,\"=\",start);break;case\"!\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.NE_OP,\"!=\",start);break}token.set(ETokenType.BANG,\"!\",start);break;case\"&\":this.advance(1);curChar=this.getCurChar();if(curChar===\"&\"){this.advance(1);token.set(ETokenType.AND_OP,\"&&\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.AND_ASSIGN,\"&=\",start);break}token.set(ETokenType.AMPERSAND,\"&\",start);break;case\"|\":this.advance(1);curChar=this.getCurChar();if(curChar===\"|\"){this.advance(1);token.set(ETokenType.OR_OP,\"||\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.OR_ASSIGN,\"|=\",start);break}token.set(ETokenType.VERTICAL_BAR,\"|\",start);break;case\"^\":this.advance(1);curChar=this.getCurChar();if(curChar===\"^\"){this.advance(1);token.set(ETokenType.XOR_OP,\"^^\",start);break}else if(curChar===\"=\"){this.advance(1);token.set(ETokenType.XOR_ASSIGN,\"^=\",start);break}token.set(ETokenType.CARET,\"^\",start);break;case\"*\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.MUL_ASSIGN,\"*=\",start);break}token.set(ETokenType.STAR,\"*\",start);break;case\"/\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.DIV_ASSIGN,\"/=\",start);break}token.set(ETokenType.SLASH,\"/\",start);break;case\"%\":this.advance(1);if(this.getCurChar()===\"=\"){this.advance(1);token.set(ETokenType.MOD_ASSIGN,\"%=\",start);break}token.set(ETokenType.PERCENT,\"%\",start);break;case\"(\":this.advance(1);token.set(ETokenType.LEFT_PAREN,\"(\",start);break;case\")\":this.advance(1);token.set(ETokenType.RIGHT_PAREN,\")\",start);break;case\"{\":this.advance(1);token.set(ETokenType.LEFT_BRACE,\"{\",start);break;case\"}\":this.advance(1);token.set(ETokenType.RIGHT_BRACE,\"}\",start);break;case\"[\":this.advance(1);token.set(ETokenType.LEFT_BRACKET,\"[\",start);break;case\"]\":this.advance(1);token.set(ETokenType.RIGHT_BRACKET,\"]\",start);break;case\".\":this.advance(1);if(BaseLexer.isDigit(this.getCurCharCode())){return this._scanNumAfterDot()}token.set(ETokenType.DOT,\".\",start);break;case\",\":this.advance(1);token.set(ETokenType.COMMA,\",\",start);break;case\":\":this.advance(1);token.set(ETokenType.COLON,\":\",start);return token;case\";\":this.advance(1);token.set(ETokenType.SEMICOLON,\";\",start);break;case\"~\":this.advance(1);token.set(ETokenType.TILDE,\"~\",start);break;case\"?\":this.advance(1);token.set(ETokenType.QUESTION,\"?\",start);break;case'\"':this.advance(1);return this._scanStringConst();default:this.throwError(this.getShaderPosition(0),\"Unexpected character \"+this.getCurChar())}return token};_proto._scanStringConst=function _scanStringConst(){var start=this.getShaderPosition();var buffer=[];while(this.getCurChar()!=='\"'){if(this.isEnd()){var quote=this._createPosition(start.index-1,start.line,start.column-1);this.throwError(this._createRange(quote,start),\"Unterminated string literal.\")}buffer.push(this.getCurChar());this.advance(1)}this.advance(1);var range=this._createRange(start,this.getShaderPosition());var token=this._createToken();token.set(ETokenType.STRING_CONST,buffer.join(\"\"),range);return token};_proto._scanNumAfterDot=function _scanNumAfterDot(){var buffer=[\".\"];while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}this._scanFloatSuffix(buffer);var token=this._createToken();token.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token};_proto._scanUtilBreakLine=function _scanUtilBreakLine(outBuffer){var src=this._source;var len=src.length;while(!this.isEnd()){var afterContinuation=Lexer._skipLineContinuation(src,this._currentIndex,len);if(afterContinuation!==this._currentIndex){this.advance(afterContinuation-this._currentIndex);continue}var c=src.charCodeAt(this._currentIndex);if(c===10)break;outBuffer.push(src[this._currentIndex]);this.advance(1)}};_proto._scanDirectives=function _scanDirectives(){var buffer=[this.getCurChar()];var start=this.getShaderPosition();this.advance(1);this.skipSpace(false);while(BaseLexer.isAlpha(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var token=this._createToken();var word=buffer.join(\"\");if(word===\"#define\"){var branchReachable=this._isBranchReachable(this._branchStack);if(!branchReachable){this._scanUtilBreakLine(buffer);token.set(Keyword.MACRO_DEFINE_EXPRESSION,\"\\n\"+buffer.join(\"\")+\"\\n\",start);return token}var peek=this._peekMacroDefine();if(peek&&peek.isExpression){this._inMacroDefineValue=true;this._macroDefineExpectsNameToken=true;token.set(Keyword.MACRO_DEFINE,\"#define\",start)}else{this._scanUtilBreakLine(buffer);var lexeme=\"\\n\"+buffer.join(\"\")+\"\\n\";if(peek){this._registerMacroDefine(peek.name,peek.paramsLexeme,peek.valueStart,peek.valueEnd)}token.set(Keyword.MACRO_DEFINE_EXPRESSION,lexeme,start)}}else{var kt=Lexer._lexemeTable[word];token.set(kt!=null?kt:ETokenType.ID,word,start);if(word===\"#if\"||word===\"#elif\"){this._needScanMacroConditionExpression=true}}return token};_proto._isAtLineBreak=function _isAtLineBreak(){var c=this.getCurChar();return c===\"\\n\"||c===\"\\r\"};_proto._peekMacroDefine=function _peekMacroDefine(){var src=this._source;var len=src.length;var i=Lexer._skipNonSemantic(src,this._currentIndex,len);if(!(i<len&&BaseLexer.isAlpha(src.charCodeAt(i))))return null;var nameStart=i;while(i<len&&BaseLexer.isAlnum(src.charCodeAt(i)))i++;var name=src.slice(nameStart,i);var paramsLexeme;if(i<len&&src.charCodeAt(i)===40){var paramsStart=i;var depth=1;i++;while(i<len&&depth>0){i=Lexer._skipNonSemantic(src,i,len);if(i>=len)break;var c=src.charCodeAt(i);if(c===10||c===13){return{name:name,paramsLexeme:undefined,valueStart:i,valueEnd:i,isExpression:false}}if(c===40)depth++;else if(c===41)depth--;i++}paramsLexeme=src.slice(paramsStart,i)}var valueStart=i;var parenDepth=0;var bracketDepth=0;var firstStart=-1;var firstEnd=-1;var firstFollowedByParen=false;var topLevelLast=-1;while(i<len){var skipped=Lexer._skipNonSemantic(src,i,len);if(skipped!==i){i=skipped;continue}var c1=src.charCodeAt(i);if(c1===10||c1===13)break;if(firstStart===-1){firstStart=i;if(BaseLexer.isAlpha(c1)){while(i<len&&BaseLexer.isAlnum(src.charCodeAt(i)))i++;firstEnd=i;var after=Lexer._skipNonSemantic(src,i,len);firstFollowedByParen=after<len&&src.charCodeAt(after)===40;topLevelLast=firstEnd-1;continue}}if(c1===40)parenDepth++;else if(c1===41)parenDepth--;else if(c1===91)bracketDepth++;else if(c1===93)bracketDepth--;if(parenDepth===0&&bracketDepth===0)topLevelLast=i;i++}var result={name:name,paramsLexeme:paramsLexeme,valueStart:valueStart,valueEnd:i,isExpression:false};if(firstStart===-1)return result;if(firstEnd!==-1&&!firstFollowedByParen&&Lexer._isNonExpressionLeadingKeyword(src.slice(firstStart,firstEnd))){return result}var head=src.charCodeAt(firstStart);var tail=topLevelLast>=0?src.charCodeAt(topLevelLast):0;var headIllegal=!BaseLexer.isAlnum(head)&&head!==40&&head!==46&&head!==45&&head!==43&&head!==33&&head!==126;var tailIllegal=!BaseLexer.isAlnum(tail)&&tail!==41&&tail!==93;if(parenDepth!==0||bracketDepth!==0||headIllegal||tailIllegal)return result;result.isExpression=true;return result};_proto._skipInlineSpaceAndComments=function _skipInlineSpaceAndComments(){var next=Lexer._skipNonSemantic(this._source,this._currentIndex,this._source.length);if(next>this._currentIndex)this.advance(next-this._currentIndex)};_proto._scanMacroDefineParams=function _scanMacroDefineParams(){var start=this.getShaderPosition();var src=this._source;var len=src.length;var buffer=[];var depth=0;while(this._currentIndex<len){var afterContinuation=Lexer._skipLineContinuation(src,this._currentIndex,len);if(afterContinuation!==this._currentIndex){this.advance(afterContinuation-this._currentIndex);continue}var ch=src[this._currentIndex];buffer.push(ch);if(ch===\"(\")depth++;else if(ch===\")\"){depth--;this.advance(1);if(depth===0)break;continue}this.advance(1)}var token=this._createToken();var lexeme=buffer.join(\"\");this._currentMacroParamsLexeme=lexeme;this._currentMacroValueStart=this._currentIndex;token.set(Keyword.MACRO_DEFINE_PARAMS,lexeme,start);return token};_proto._emitMacroDefineEnd=function _emitMacroDefineEnd(){var start=this.getShaderPosition();var valueEnd=this._currentIndex;var source=this._source;if(this._currentIndex<source.length){var c=source.charCodeAt(this._currentIndex);if(c===13&&source.charCodeAt(this._currentIndex+1)===10){this.advance(2)}else if(c===10||c===13){this.advance(1)}}this._registerMacroDefine(this._currentMacroName,this._currentMacroParamsLexeme,this._currentMacroValueStart,valueEnd);this._inMacroDefineValue=false;var token=this._createToken();token.set(Keyword.MACRO_DEFINE_END,\"\\n\",start);return token};_proto._registerMacroDefine=function _registerMacroDefine(name,paramsLexeme,valueStart,valueEnd){var params=paramsLexeme?paramsLexeme.slice(1,-1).split(\",\").map(function(p){return p.trim()}).filter(Boolean):[];var dedupKey=(paramsLexeme!=null?paramsLexeme:\"\")+\"=\"+Lexer._normalizeValueText(this._source,valueStart,valueEnd);var info={isFunction:paramsLexeme!==undefined,params:params,dedupKey:dedupKey,branch:this._captureBranchSignature()};var arr=this.macroDefineList[name];if(!arr){this.macroDefineList[name]=[info]}else{var duplicate=false;for(var i=0,n=arr.length;i<n;i++){var e=arr[i];if(e.dedupKey===dedupKey&&this._sameDefinitionBranch(e.branch,info.branch)){duplicate=true;break}}if(!duplicate)arr.push(info)}};_proto._captureBranchSignature=function _captureBranchSignature(){var stack=this._branchStack;var snapshot=this._branchSnapshot;if(stack.length===snapshot.length){var unchanged=true;for(var i=0;i<stack.length;i++){if(stack[i]!==snapshot[i]){unchanged=false;break}}if(unchanged)return snapshot}return this._branchSnapshot=stack.length===0?EMPTY_BRANCH:stack.slice()};_proto._scanMacroConditionExpression=function _scanMacroConditionExpression(){var buffer=new Array;var start=this.getShaderPosition();var source=this._source;while(!this.isEnd()){var afterContinuation=Lexer._skipLineContinuation(source,this._currentIndex,source.length);if(afterContinuation!==this._currentIndex){while(this._currentIndex<afterContinuation){var character=source[this._currentIndex];buffer.push(character===\"\\\\\"?\" \":character);this.advance(1)}continue}if(source.charCodeAt(this._currentIndex)===10)break;buffer.push(source[this._currentIndex]);this.advance(1)}var word=buffer.join(\"\");var result=parsePreprocessorExpression(word);var emittedWord=word.replace(/[\\r\\n]/g,\" \");this.preprocessorExpressions.set(emittedWord.trim(),result);var token=this._createToken();token.set(Keyword.MACRO_CONDITIONAL_EXPRESSION,emittedWord,start);return token};_proto._scanWord=function _scanWord(){var buffer=[this.getCurChar()];var start=this.getShaderPosition();this.advance(1);while(BaseLexer.isAlnum(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var token=this._createToken();var word=buffer.join(\"\");var kt=Lexer._lexemeTable[word];if(this._macroDefineExpectsNameToken){this._macroDefineExpectsNameToken=false;this._currentMacroName=word;this._currentMacroParamsLexeme=undefined;if(this._inMacroDefineValue){this._macroDefineExpectsParamsToken=this.getCurChar()===\"(\";this._currentMacroValueStart=this._currentIndex}token.set(ETokenType.ID,word,start)}else if(this._isVisibleMacro(word)){token.set(Keyword.MACRO_CALL,word,start)}else{token.set(kt!=null?kt:ETokenType.ID,word,start)}return token};_proto._isVisibleMacro=function _isVisibleMacro(word){var defs=this.macroDefineList[word];if(!defs||defs.length===0)return false;var callSiteBranch=this._branchStack;for(var i=0,n=defs.length;i<n;i++){if(this._branchesOverlap(defs[i].branch,callSiteBranch)){return true}}return false};_proto._scanNum=function _scanNum(){var buffer=[];if(this.getCurChar()===\"0\"){var nextCode=this._source.charCodeAt(this._currentIndex+1);if(nextCode===120||nextCode===88){buffer.push(this.getCurChar());this.advance(1);buffer.push(this.getCurChar());this.advance(1);while(BaseLexer.isHexDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}if(buffer.length===2){this.throwError(this.getShaderPosition(0),\"lexing error, hex literal needs at least one digit.\")}this._scanIntegerSuffix(buffer);var token=this._createToken();token.set(ETokenType.INT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token}}while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}var curChar=this.getCurChar();if(curChar===\".\"){buffer.push(curChar);this.advance(1);while(BaseLexer.isDigit(this.getCurCharCode())){buffer.push(this.getCurChar());this.advance(1)}this._scanFloatSuffix(buffer);var token1=this._createToken();token1.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token1}else if(curChar===\"e\"||curChar===\"E\"){this._scanFloatSuffix(buffer);var token2=this._createToken();token2.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token2}else if(curChar===\"f\"||curChar===\"F\"){buffer.push(curChar);this.advance(1);var token3=this._createToken();token3.set(ETokenType.FLOAT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token3}else{this._scanIntegerSuffix(buffer);var token4=this._createToken();token4.set(ETokenType.INT_CONSTANT,buffer.join(\"\"),this.getShaderPosition(buffer.length));return token4}};_proto._scanFloatSuffix=function _scanFloatSuffix(buffer){var curChar=this.getCurChar();if(curChar===\"e\"||curChar===\"E\"){buffer.push(curChar);this.advance(1);curChar=this.getCurChar();if(curChar===\"+\"||curChar===\"-\"){buffer.push(curChar);this.advance(1);curChar=this.getCurChar()}if(!BaseLexer.isDigit(this.getCurCharCode()))this.throwError(this.getShaderPosition(0),\"lexing error, invalid exponent suffix.\");do{buffer.push(curChar);this.advance(1);curChar=this.getCurChar()}while(BaseLexer.isDigit(this.getCurCharCode()))}if(curChar===\"f\"||curChar===\"F\"){buffer.push(curChar);this.advance(1)}};_proto._scanIntegerSuffix=function _scanIntegerSuffix(buffer){var curChar=this.getCurChar();if(curChar===\"u\"||curChar===\"U\"){buffer.push(curChar);this.advance(1)}};Lexer._isCodegenBranchReachable=function _isCodegenBranchReachable(branch){for(var i=0;i<branch.length;i++){var condition=branch[i].condition;if((condition==null?void 0:condition.kind)===\"constant\"&&!condition.value)return false}return true};Lexer._isNonExpressionLeadingKeyword=function _isNonExpressionLeadingKeyword(lexeme){var kw=Lexer._lexemeTable[lexeme];return kw!==undefined&&kw!==Keyword.True&&kw!==Keyword.False&&!lexeme.startsWith(\"#\")};Lexer._skipLineContinuation=function _skipLineContinuation(src,i,len){if(src.charCodeAt(i)!==92||i+1>=len)return i;var n=src.charCodeAt(i+1);if(n===10)return i+2;if(n===13)return i+2<len&&src.charCodeAt(i+2)===10?i+3:i+2;return i};Lexer._skipNonSemantic=function _skipNonSemantic(src,from,len){var i=from;while(i<len){var c=src.charCodeAt(i);if(c===32||c===9){i++;continue}var afterContinuation=Lexer._skipLineContinuation(src,i,len);if(afterContinuation!==i){i=afterContinuation;continue}var afterBlock=Lexer._skipBlockComment(src,i,len);if(afterBlock!==i){i=afterBlock;continue}var afterLine=Lexer._skipLineComment(src,i,len);if(afterLine!==i){i=afterLine;continue}break}return i};Lexer._normalizeValueText=function _normalizeValueText(src,start,end){var out=\"\";var i=start;var pendingSpace=false;while(i<end){var skipped=Lexer._skipNonSemantic(src,i,end);if(skipped!==i){pendingSpace=out.length>0;i=skipped;continue}var c=src.charCodeAt(i);if(c===32||c===9){pendingSpace=out.length>0;i++;continue}if(pendingSpace){out+=\" \";pendingSpace=false}out+=src[i];i++}return out};Lexer._sameCodegenBranch=function _sameCodegenBranch(left,right){if(left.length!==right.length)return false;for(var i=0;i<left.length;i++){if(left[i].conditionalGroup!==right[i].conditionalGroup||left[i].conditionalArm!==right[i].conditionalArm){return false}}return true};return Lexer}(BaseLexer);Lexer._lexemeTable={const:Keyword.CONST,bool:Keyword.BOOL,float:Keyword.FLOAT,double:Keyword.DOUBLE,int:Keyword.INT,uint:Keyword.UINT,break:Keyword.BREAK,continue:Keyword.CONTINUE,do:Keyword.DO,else:Keyword.ELSE,for:Keyword.FOR,if:Keyword.IF,while:Keyword.WHILE,discard:Keyword.DISCARD,return:Keyword.RETURN,bvec2:Keyword.BVEC2,bvec3:Keyword.BVEC3,bvec4:Keyword.BVEC4,ivec2:Keyword.IVEC2,ivec3:Keyword.IVEC3,ivec4:Keyword.IVEC4,uvec2:Keyword.UVEC2,uvec3:Keyword.UVEC3,uvec4:Keyword.UVEC4,vec2:Keyword.VEC2,vec3:Keyword.VEC3,vec4:Keyword.VEC4,mat2:Keyword.MAT2,mat3:Keyword.MAT3,mat4:Keyword.MAT4,mat2x3:Keyword.MAT2X3,mat2x4:Keyword.MAT2X4,mat3x2:Keyword.MAT3X2,mat3x4:Keyword.MAT3X4,mat4x2:Keyword.MAT4X2,mat4x3:Keyword.MAT4X3,in:Keyword.IN,out:Keyword.OUT,inout:Keyword.INOUT,sampler2D:Keyword.SAMPLER2D,samplerCube:Keyword.SAMPLER_CUBE,sampler3D:Keyword.SAMPLER3D,sampler2DShadow:Keyword.SAMPLER2D_SHADOW,samplerCubeShadow:Keyword.SAMPLER_CUBE_SHADOW,sampler2DArray:Keyword.SAMPLER2D_ARRAY,sampler2DArrayShadow:Keyword.SAMPLER2D_ARRAY_SHADOW,isampler2D:Keyword.I_SAMPLER2D,isampler3D:Keyword.I_SAMPLER3D,isamplerCube:Keyword.I_SAMPLER_CUBE,isampler2DArray:Keyword.I_SAMPLER2D_ARRAY,usampler2D:Keyword.U_SAMPLER2D,usampler3D:Keyword.U_SAMPLER3D,usamplerCube:Keyword.U_SAMPLER_CUBE,usampler2DArray:Keyword.U_SAMPLER2D_ARRAY,struct:Keyword.STRUCT,void:Keyword.VOID,true:Keyword.True,false:Keyword.False,precision:Keyword.PRECISION,precise:Keyword.PRECISE,highp:Keyword.HIGHP,mediump:Keyword.MEDIUMP,lowp:Keyword.LOWP,invariant:Keyword.INVARIANT,flat:Keyword.FLAT,smooth:Keyword.SMOOTH,noperspective:Keyword.NOPERSPECTIVE,centroid:Keyword.CENTROID,layout:Keyword.LAYOUT,location:Keyword.LOCATION,\"#if\":Keyword.MACRO_IF,\"#ifdef\":Keyword.MACRO_IFDEF,\"#ifndef\":Keyword.MACRO_IFNDEF,\"#else\":Keyword.MACRO_ELSE,\"#elif\":Keyword.MACRO_ELIF,\"#endif\":Keyword.MACRO_ENDIF,\"#undef\":Keyword.MACRO_UNDEF};var NoneTerminal=function(NoneTerminal){NoneTerminal[NoneTerminal[\"START\"]=2e3]=\"START\";NoneTerminal[NoneTerminal[\"gs_shader_program\"]=2001]=\"gs_shader_program\";NoneTerminal[NoneTerminal[\"global_declaration\"]=2002]=\"global_declaration\";NoneTerminal[NoneTerminal[\"variable_declaration\"]=2003]=\"variable_declaration\";NoneTerminal[NoneTerminal[\"variable_declaration_list\"]=2004]=\"variable_declaration_list\";NoneTerminal[NoneTerminal[\"variable_declaration_statement\"]=2005]=\"variable_declaration_statement\";NoneTerminal[NoneTerminal[\"array_specifier_list\"]=2006]=\"array_specifier_list\";NoneTerminal[NoneTerminal[\"array_specifier\"]=2007]=\"array_specifier\";NoneTerminal[NoneTerminal[\"ext_builtin_type_specifier_nonarray\"]=2008]=\"ext_builtin_type_specifier_nonarray\";NoneTerminal[NoneTerminal[\"precision_specifier\"]=2009]=\"precision_specifier\";NoneTerminal[NoneTerminal[\"variable_identifier\"]=2010]=\"variable_identifier\";NoneTerminal[NoneTerminal[\"variable_identifier_node\"]=2011]=\"variable_identifier_node\";NoneTerminal[NoneTerminal[\"primary_expression\"]=2012]=\"primary_expression\";NoneTerminal[NoneTerminal[\"postfix_expression\"]=2013]=\"postfix_expression\";NoneTerminal[NoneTerminal[\"integer_expression\"]=2014]=\"integer_expression\";NoneTerminal[NoneTerminal[\"function_call\"]=2015]=\"function_call\";NoneTerminal[NoneTerminal[\"function_call_generic\"]=2016]=\"function_call_generic\";NoneTerminal[NoneTerminal[\"function_call_header_no_parameters\"]=2017]=\"function_call_header_no_parameters\";NoneTerminal[NoneTerminal[\"function_call_header_with_parameters\"]=2018]=\"function_call_header_with_parameters\";NoneTerminal[NoneTerminal[\"function_call_parameter_list\"]=2019]=\"function_call_parameter_list\";NoneTerminal[NoneTerminal[\"function_call_header\"]=2020]=\"function_call_header\";NoneTerminal[NoneTerminal[\"function_identifier\"]=2021]=\"function_identifier\";NoneTerminal[NoneTerminal[\"constructor_identifier\"]=2022]=\"constructor_identifier\";NoneTerminal[NoneTerminal[\"unary_expression\"]=2023]=\"unary_expression\";NoneTerminal[NoneTerminal[\"unary_operator\"]=2024]=\"unary_operator\";NoneTerminal[NoneTerminal[\"multiplicative_expression\"]=2025]=\"multiplicative_expression\";NoneTerminal[NoneTerminal[\"additive_expression\"]=2026]=\"additive_expression\";NoneTerminal[NoneTerminal[\"shift_expression\"]=2027]=\"shift_expression\";NoneTerminal[NoneTerminal[\"relational_expression\"]=2028]=\"relational_expression\";NoneTerminal[NoneTerminal[\"equality_expression\"]=2029]=\"equality_expression\";NoneTerminal[NoneTerminal[\"and_expression\"]=2030]=\"and_expression\";NoneTerminal[NoneTerminal[\"inclusive_or_expression\"]=2031]=\"inclusive_or_expression\";NoneTerminal[NoneTerminal[\"exclusive_or_expression\"]=2032]=\"exclusive_or_expression\";NoneTerminal[NoneTerminal[\"logical_and_expression\"]=2033]=\"logical_and_expression\";NoneTerminal[NoneTerminal[\"logical_xor_expression\"]=2034]=\"logical_xor_expression\";NoneTerminal[NoneTerminal[\"logical_or_expression\"]=2035]=\"logical_or_expression\";NoneTerminal[NoneTerminal[\"conditional_expression\"]=2036]=\"conditional_expression\";NoneTerminal[NoneTerminal[\"assignment_expression\"]=2037]=\"assignment_expression\";NoneTerminal[NoneTerminal[\"assignment_operator\"]=2038]=\"assignment_operator\";NoneTerminal[NoneTerminal[\"expression\"]=2039]=\"expression\";NoneTerminal[NoneTerminal[\"integer_constant_expression\"]=2040]=\"integer_constant_expression\";NoneTerminal[NoneTerminal[\"integer_constant_expression_operator\"]=2041]=\"integer_constant_expression_operator\";NoneTerminal[NoneTerminal[\"declaration\"]=2042]=\"declaration\";NoneTerminal[NoneTerminal[\"function_prototype\"]=2043]=\"function_prototype\";NoneTerminal[NoneTerminal[\"function_declarator\"]=2044]=\"function_declarator\";NoneTerminal[NoneTerminal[\"function_header_with_parameters\"]=2045]=\"function_header_with_parameters\";NoneTerminal[NoneTerminal[\"function_header\"]=2046]=\"function_header\";NoneTerminal[NoneTerminal[\"function_parameter_list\"]=2047]=\"function_parameter_list\";NoneTerminal[NoneTerminal[\"parameter_declarator\"]=2048]=\"parameter_declarator\";NoneTerminal[NoneTerminal[\"parameter_declaration\"]=2049]=\"parameter_declaration\";NoneTerminal[NoneTerminal[\"parameter_qualifier\"]=2050]=\"parameter_qualifier\";NoneTerminal[NoneTerminal[\"parameter_type_specifier\"]=2051]=\"parameter_type_specifier\";NoneTerminal[NoneTerminal[\"init_declarator_list\"]=2052]=\"init_declarator_list\";NoneTerminal[NoneTerminal[\"single_declaration\"]=2053]=\"single_declaration\";NoneTerminal[NoneTerminal[\"fully_specified_type\"]=2054]=\"fully_specified_type\";NoneTerminal[NoneTerminal[\"type_qualifier\"]=2055]=\"type_qualifier\";NoneTerminal[NoneTerminal[\"single_type_qualifier\"]=2056]=\"single_type_qualifier\";NoneTerminal[NoneTerminal[\"storage_qualifier\"]=2057]=\"storage_qualifier\";NoneTerminal[NoneTerminal[\"precision_qualifier\"]=2058]=\"precision_qualifier\";NoneTerminal[NoneTerminal[\"interpolation_qualifier\"]=2059]=\"interpolation_qualifier\";NoneTerminal[NoneTerminal[\"invariant_qualifier\"]=2060]=\"invariant_qualifier\";NoneTerminal[NoneTerminal[\"type_specifier\"]=2061]=\"type_specifier\";NoneTerminal[NoneTerminal[\"type_specifier_nonarray\"]=2062]=\"type_specifier_nonarray\";NoneTerminal[NoneTerminal[\"type_specifier_no_prec\"]=2063]=\"type_specifier_no_prec\";NoneTerminal[NoneTerminal[\"basic_type\"]=2064]=\"basic_type\";NoneTerminal[NoneTerminal[\"struct_specifier\"]=2065]=\"struct_specifier\";NoneTerminal[NoneTerminal[\"struct_declaration_list\"]=2066]=\"struct_declaration_list\";NoneTerminal[NoneTerminal[\"struct_declaration\"]=2067]=\"struct_declaration\";NoneTerminal[NoneTerminal[\"layout_qualifier\"]=2068]=\"layout_qualifier\";NoneTerminal[NoneTerminal[\"struct_declarator_list\"]=2069]=\"struct_declarator_list\";NoneTerminal[NoneTerminal[\"struct_declarator\"]=2070]=\"struct_declarator\";NoneTerminal[NoneTerminal[\"identifier_list\"]=2071]=\"identifier_list\";NoneTerminal[NoneTerminal[\"decl_identifier\"]=2072]=\"decl_identifier\";NoneTerminal[NoneTerminal[\"initializer\"]=2073]=\"initializer\";NoneTerminal[NoneTerminal[\"initializer_list\"]=2074]=\"initializer_list\";NoneTerminal[NoneTerminal[\"declaration_statement\"]=2075]=\"declaration_statement\";NoneTerminal[NoneTerminal[\"simple_statement\"]=2076]=\"simple_statement\";NoneTerminal[NoneTerminal[\"compound_statement_no_scope\"]=2077]=\"compound_statement_no_scope\";NoneTerminal[NoneTerminal[\"statement_with_scope\"]=2078]=\"statement_with_scope\";NoneTerminal[NoneTerminal[\"compound_statement\"]=2079]=\"compound_statement\";NoneTerminal[NoneTerminal[\"statement\"]=2080]=\"statement\";NoneTerminal[NoneTerminal[\"statement_list\"]=2081]=\"statement_list\";NoneTerminal[NoneTerminal[\"iteration_statement_no_new_scope\"]=2082]=\"iteration_statement_no_new_scope\";NoneTerminal[NoneTerminal[\"expression_statement\"]=2083]=\"expression_statement\";NoneTerminal[NoneTerminal[\"selection_statement\"]=2084]=\"selection_statement\";NoneTerminal[NoneTerminal[\"selection_rest_statement\"]=2085]=\"selection_rest_statement\";NoneTerminal[NoneTerminal[\"condition\"]=2086]=\"condition\";NoneTerminal[NoneTerminal[\"conditionopt\"]=2087]=\"conditionopt\";NoneTerminal[NoneTerminal[\"iteration_statement\"]=2088]=\"iteration_statement\";NoneTerminal[NoneTerminal[\"for_init_statement\"]=2089]=\"for_init_statement\";NoneTerminal[NoneTerminal[\"for_rest_statement\"]=2090]=\"for_rest_statement\";NoneTerminal[NoneTerminal[\"jump_statement\"]=2091]=\"jump_statement\";NoneTerminal[NoneTerminal[\"external_declaration\"]=2092]=\"external_declaration\";NoneTerminal[NoneTerminal[\"function_definition\"]=2093]=\"function_definition\";NoneTerminal[NoneTerminal[\"field_selection\"]=2094]=\"field_selection\";NoneTerminal[NoneTerminal[\"bool_constant\"]=2095]=\"bool_constant\";NoneTerminal[NoneTerminal[\"function_identifier_node\"]=2096]=\"function_identifier_node\";NoneTerminal[NoneTerminal[\"typename_identifier_node\"]=2097]=\"typename_identifier_node\";NoneTerminal[NoneTerminal[\"scope_brace\"]=2098]=\"scope_brace\";NoneTerminal[NoneTerminal[\"scope_end_brace\"]=2099]=\"scope_end_brace\";NoneTerminal[NoneTerminal[\"macro_undef\"]=2100]=\"macro_undef\";NoneTerminal[NoneTerminal[\"macro_push_context\"]=2101]=\"macro_push_context\";NoneTerminal[NoneTerminal[\"macro_pop_context\"]=2102]=\"macro_pop_context\";NoneTerminal[NoneTerminal[\"macro_elif_expression\"]=2103]=\"macro_elif_expression\";NoneTerminal[NoneTerminal[\"macro_else_expression\"]=2104]=\"macro_else_expression\";NoneTerminal[NoneTerminal[\"global_macro_if_statement\"]=2105]=\"global_macro_if_statement\";NoneTerminal[NoneTerminal[\"global_macro_declaration\"]=2106]=\"global_macro_declaration\";NoneTerminal[NoneTerminal[\"global_macro_branch\"]=2107]=\"global_macro_branch\";NoneTerminal[NoneTerminal[\"macro_struct_declaration\"]=2108]=\"macro_struct_declaration\";NoneTerminal[NoneTerminal[\"macro_struct_branch\"]=2109]=\"macro_struct_branch\";NoneTerminal[NoneTerminal[\"macro_if_statement\"]=2110]=\"macro_if_statement\";NoneTerminal[NoneTerminal[\"macro_branch\"]=2111]=\"macro_branch\";NoneTerminal[NoneTerminal[\"macro_param_case_list\"]=2112]=\"macro_param_case_list\";NoneTerminal[NoneTerminal[\"macro_param_block\"]=2113]=\"macro_param_block\";NoneTerminal[NoneTerminal[\"macro_parameter_branch\"]=2114]=\"macro_parameter_branch\";NoneTerminal[NoneTerminal[\"macro_call_arg_case_list\"]=2115]=\"macro_call_arg_case_list\";NoneTerminal[NoneTerminal[\"macro_call_arg_block\"]=2116]=\"macro_call_arg_block\";NoneTerminal[NoneTerminal[\"macro_call_arg_branch\"]=2117]=\"macro_call_arg_branch\";NoneTerminal[NoneTerminal[\"macro_call_symbol\"]=2118]=\"macro_call_symbol\";NoneTerminal[NoneTerminal[\"macro_call_function\"]=2119]=\"macro_call_function\";NoneTerminal[NoneTerminal[\"macro_define\"]=2120]=\"macro_define\";NoneTerminal[NoneTerminal[\"_ignore\"]=2121]=\"_ignore\";return NoneTerminal}({});var Production=function Production(goal,derivation){this.goal=goal;this.derivation=derivation;this.id=Production._id++;Production.pool.set(this.id,this)};Production._id=0;Production.pool=new Map;var GenericType=function(GenericType){GenericType[GenericType[\"GenType\"]=200]=\"GenType\";GenericType[GenericType[\"GenIntType\"]=201]=\"GenIntType\";GenericType[GenericType[\"GenUintType\"]=202]=\"GenUintType\";GenericType[GenericType[\"GenBoolType\"]=203]=\"GenBoolType\";GenericType[GenericType[\"Mat\"]=204]=\"Mat\";GenericType[GenericType[\"BoolVec\"]=205]=\"BoolVec\";GenericType[GenericType[\"IntVec\"]=206]=\"IntVec\";GenericType[GenericType[\"UintVec\"]=207]=\"UintVec\";GenericType[GenericType[\"Vec\"]=208]=\"Vec\";GenericType[GenericType[\"GVec4\"]=209]=\"GVec4\";GenericType[GenericType[\"GSampler2D\"]=210]=\"GSampler2D\";GenericType[GenericType[\"GSampler3D\"]=211]=\"GSampler3D\";GenericType[GenericType[\"GSamplerCube\"]=212]=\"GSamplerCube\";GenericType[GenericType[\"GSampler2DArray\"]=213]=\"GSampler2DArray\";return GenericType}({});var _obj;var FamilyMembers=(_obj={},_obj[200]={dimension:0,members:[Keyword.FLOAT,Keyword.VEC2,Keyword.VEC3,Keyword.VEC4]},_obj[201]={dimension:0,members:[Keyword.INT,Keyword.IVEC2,Keyword.IVEC3,Keyword.IVEC4]},_obj[202]={dimension:0,members:[Keyword.UINT,Keyword.UVEC2,Keyword.UVEC3,Keyword.UVEC4]},_obj[203]={dimension:0,members:[Keyword.BOOL,Keyword.BVEC2,Keyword.BVEC3,Keyword.BVEC4]},_obj[208]={dimension:0,members:[Keyword.VEC2,Keyword.VEC3,Keyword.VEC4]},_obj[206]={dimension:0,members:[Keyword.IVEC2,Keyword.IVEC3,Keyword.IVEC4]},_obj[207]={dimension:0,members:[Keyword.UVEC2,Keyword.UVEC3,Keyword.UVEC4]},_obj[205]={dimension:0,members:[Keyword.BVEC2,Keyword.BVEC3,Keyword.BVEC4]},_obj[204]={dimension:0,members:[Keyword.MAT2,Keyword.MAT3,Keyword.MAT4]},_obj[210]={dimension:1,members:[Keyword.SAMPLER2D,Keyword.I_SAMPLER2D,Keyword.U_SAMPLER2D]},_obj[211]={dimension:1,members:[Keyword.SAMPLER3D,Keyword.I_SAMPLER3D,Keyword.U_SAMPLER3D]},_obj[212]={dimension:1,members:[Keyword.SAMPLER_CUBE,Keyword.I_SAMPLER_CUBE,Keyword.U_SAMPLER_CUBE]},_obj[213]={dimension:1,members:[Keyword.SAMPLER2D_ARRAY,Keyword.I_SAMPLER2D_ARRAY,Keyword.U_SAMPLER2D_ARRAY]},_obj[209]={dimension:1,members:[Keyword.VEC4,Keyword.IVEC4,Keyword.UVEC4]},_obj);var BuiltinFunctionTable=new Map;var BuiltinFunction=function(){function BuiltinFunction(ident,returnType,scope){for(var _len=arguments.length,args=new Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){args[_key-3]=arguments[_key]}this.ident=ident;this._returnType=returnType;this.args=args;this.scope=scope}BuiltinFunction._create=function _create(ident,returnType){for(var _len=arguments.length,args=new Array(_len>2?_len-2:0),_key=2;_key<_len;_key++){args[_key-2]=arguments[_key]}var fn=_construct(BuiltinFunction,[].concat([ident,returnType,EShaderStage.ALL],args));var _BuiltinFunctionTable_get;var list=(_BuiltinFunctionTable_get=BuiltinFunctionTable.get(ident))!=null?_BuiltinFunctionTable_get:[];list.push(fn);BuiltinFunctionTable.set(ident,list)};BuiltinFunction._createWithScope=function _createWithScope(ident,returnType,scope){for(var _len=arguments.length,args=new Array(_len>3?_len-3:0),_key=3;_key<_len;_key++){args[_key-3]=arguments[_key]}var fn=_construct(BuiltinFunction,[].concat([ident,returnType,scope],args));var _BuiltinFunctionTable_get;var list=(_BuiltinFunctionTable_get=BuiltinFunctionTable.get(ident))!=null?_BuiltinFunctionTable_get:[];list.push(fn);BuiltinFunctionTable.set(ident,list)};BuiltinFunction.resolveOverload=function resolveOverload(funcName,callArgTypes){var overloads=BuiltinFunctionTable.get(funcName);if(!overloads)return undefined;var _callArgTypes_length;var n=(_callArgTypes_length=callArgTypes==null?void 0:callArgTypes.length)!=null?_callArgTypes_length:0;for(var i=0,m=overloads.length;i<m;i++){var candidate=overloads[i];var declaredArgs=candidate.args;if(declaredArgs.length!==n)continue;var sizeLock=-1;var scalarTypeLock=-1;var matched=true;var sizeAmbiguous=false;var scalarTypeAmbiguous=false;for(var j=0;j<n;j++){var declaredType=declaredArgs[j];var actualType=callArgTypes[j];var paramFamily=FamilyMembers[declaredType];if(actualType===TypeAny){if(paramFamily){if(paramFamily.dimension===0)sizeAmbiguous=true;else scalarTypeAmbiguous=true}continue}if(paramFamily){var memberIdx=paramFamily.members.indexOf(actualType);if(memberIdx===-1){matched=false;break}if(paramFamily.dimension===0){if(sizeLock===-1)sizeLock=memberIdx;else if(sizeLock!==memberIdx){matched=false;break}}else{if(scalarTypeLock===-1)scalarTypeLock=memberIdx;else if(scalarTypeLock!==memberIdx){matched=false;break}}}else if(declaredType!==actualType){matched=false;break}}if(!matched)continue;var returnFamily=FamilyMembers[candidate._returnType];if(!returnFamily){candidate._realReturnType=candidate._returnType;return candidate}var returnIsSize=returnFamily.dimension===0;var ambiguous=returnIsSize?sizeAmbiguous:scalarTypeAmbiguous;var returnIdx=returnIsSize?sizeLock:scalarTypeLock;candidate._realReturnType=returnIdx===-1||ambiguous?TypeAny:returnFamily.members[returnIdx];return candidate}return undefined};BuiltinFunction.isExist=function isExist(ident){return BuiltinFunctionTable.has(ident)};_create_class(BuiltinFunction,[{key:\"realReturnType\",get:function get(){return this._realReturnType}}]);return BuiltinFunction}();BuiltinFunction._create(\"radians\",200,200);BuiltinFunction._create(\"degrees\",200,200);BuiltinFunction._create(\"sin\",200,200);BuiltinFunction._create(\"cos\",200,200);BuiltinFunction._create(\"tan\",200,200);BuiltinFunction._create(\"asin\",200,200);BuiltinFunction._create(\"acos\",200,200);BuiltinFunction._create(\"atan\",200,200,200);BuiltinFunction._create(\"atan\",200,200);BuiltinFunction._create(\"sinh\",200,200);BuiltinFunction._create(\"cosh\",200,200);BuiltinFunction._create(\"tanh\",200,200);BuiltinFunction._create(\"asinh\",200,200);BuiltinFunction._create(\"acosh\",200,200);BuiltinFunction._create(\"atanh\",200,200);BuiltinFunction._create(\"pow\",200,200,200);BuiltinFunction._create(\"exp\",200,200);BuiltinFunction._create(\"log\",200,200);BuiltinFunction._create(\"exp2\",200,200);BuiltinFunction._create(\"log2\",200,200);BuiltinFunction._create(\"sqrt\",200,200);BuiltinFunction._create(\"inversesqrt\",200,200);BuiltinFunction._create(\"abs\",200,200);BuiltinFunction._create(\"abs\",201,201);BuiltinFunction._create(\"sign\",200,200);BuiltinFunction._create(\"sign\",201,201);BuiltinFunction._create(\"floor\",200,200);BuiltinFunction._create(\"trunc\",200,200);BuiltinFunction._create(\"round\",200,200);BuiltinFunction._create(\"roundEven\",200,200);BuiltinFunction._create(\"ceil\",200,200);BuiltinFunction._create(\"fract\",200,200);BuiltinFunction._create(\"mod\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"mod\",200,200,200);BuiltinFunction._create(\"min\",200,200,200);BuiltinFunction._create(\"min\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"min\",201,201,201);BuiltinFunction._create(\"min\",201,201,Keyword.INT);BuiltinFunction._create(\"min\",202,202,202);BuiltinFunction._create(\"min\",202,202,Keyword.UINT);BuiltinFunction._create(\"max\",200,200,200);BuiltinFunction._create(\"max\",200,200,Keyword.FLOAT);BuiltinFunction._create(\"max\",201,201,201);BuiltinFunction._create(\"max\",201,201,Keyword.INT);BuiltinFunction._create(\"clamp\",200,200,200,200);BuiltinFunction._create(\"clamp\",200,200,Keyword.FLOAT,Keyword.FLOAT);BuiltinFunction._create(\"clamp\",201,201,201,201);BuiltinFunction._create(\"clamp\",201,201,Keyword.INT,Keyword.INT);BuiltinFunction._create(\"clamp\",202,202,202,202);BuiltinFunction._create(\"clamp\",202,202,Keyword.UINT,Keyword.UINT);BuiltinFunction._create(\"mix\",200,200,200,200);BuiltinFunction._create(\"mix\",200,200,200,Keyword.FLOAT);BuiltinFunction._create(\"mix\",200,200,200,203);BuiltinFunction._create(\"step\",200,200,200);BuiltinFunction._create(\"step\",200,Keyword.FLOAT,200);BuiltinFunction._create(\"smoothstep\",200,200,200,200);BuiltinFunction._create(\"smoothstep\",200,Keyword.FLOAT,Keyword.FLOAT,200);BuiltinFunction._create(\"isnan\",203,200);BuiltinFunction._create(\"isinf\",203,200);BuiltinFunction._create(\"floatBitsToInt\",200,200);BuiltinFunction._create(\"floatBitsToUint\",202,200);BuiltinFunction._create(\"intBitsToFloat\",200,201);BuiltinFunction._create(\"uintBitsToFloat\",200,202);BuiltinFunction._create(\"packSnorm2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackSnorm2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"packUnorm2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackUnorm2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"packHalf2x16\",Keyword.UINT,Keyword.VEC2);BuiltinFunction._create(\"unpackHalf2x16\",Keyword.VEC2,Keyword.UINT);BuiltinFunction._create(\"length\",Keyword.FLOAT,200);BuiltinFunction._create(\"distance\",Keyword.FLOAT,200,200);BuiltinFunction._create(\"dot\",Keyword.FLOAT,200,200);BuiltinFunction._create(\"cross\",Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"normalize\",200,200);BuiltinFunction._create(\"faceforward\",200,200,200,200);BuiltinFunction._create(\"reflect\",200,200,200);BuiltinFunction._create(\"refract\",200,200,200,Keyword.FLOAT);BuiltinFunction._create(\"matrixCompMult\",204,204,204);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4,Keyword.VEC4,Keyword.VEC4);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2X3,Keyword.VEC3,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3X2,Keyword.VEC2,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT2X4,Keyword.VEC4,Keyword.VEC2);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4X2,Keyword.VEC2,Keyword.VEC4);BuiltinFunction._create(\"outerProduct\",Keyword.MAT3X4,Keyword.VEC4,Keyword.VEC3);BuiltinFunction._create(\"outerProduct\",Keyword.MAT4X3,Keyword.VEC3,Keyword.VEC4);BuiltinFunction._create(\"transpose\",Keyword.MAT2,Keyword.MAT2);BuiltinFunction._create(\"transpose\",Keyword.MAT3,Keyword.MAT3);BuiltinFunction._create(\"transpose\",Keyword.MAT4,Keyword.MAT4);BuiltinFunction._create(\"transpose\",Keyword.MAT2X3,Keyword.MAT3X2);BuiltinFunction._create(\"transpose\",Keyword.MAT3X2,Keyword.MAT2X3);BuiltinFunction._create(\"transpose\",Keyword.MAT4X2,Keyword.MAT2X4);BuiltinFunction._create(\"transpose\",Keyword.MAT2X4,Keyword.MAT4X2);BuiltinFunction._create(\"transpose\",Keyword.MAT3X4,Keyword.MAT4X3);BuiltinFunction._create(\"transpose\",Keyword.MAT4X3,Keyword.MAT3X4);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT2);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT3);BuiltinFunction._create(\"determinant\",Keyword.FLOAT,Keyword.MAT4);BuiltinFunction._create(\"inverse\",Keyword.MAT2,Keyword.MAT2);BuiltinFunction._create(\"inverse\",Keyword.MAT3,Keyword.MAT3);BuiltinFunction._create(\"inverse\",Keyword.MAT4,Keyword.MAT4);BuiltinFunction._create(\"lessThan\",205,208,208);BuiltinFunction._create(\"lessThan\",205,206,206);BuiltinFunction._create(\"lessThan\",205,207,207);BuiltinFunction._create(\"lessThanEqual\",205,208,208);BuiltinFunction._create(\"lessThanEqual\",205,206,206);BuiltinFunction._create(\"lessThanEqual\",205,207,207);BuiltinFunction._create(\"greaterThan\",205,208,208);BuiltinFunction._create(\"greaterThan\",205,206,206);BuiltinFunction._create(\"greaterThan\",205,207,207);BuiltinFunction._create(\"greaterThanEqual\",205,208,208);BuiltinFunction._create(\"greaterThanEqual\",205,206,206);BuiltinFunction._create(\"greaterThanEqual\",205,207,207);BuiltinFunction._create(\"equal\",205,208,208);BuiltinFunction._create(\"equal\",205,206,206);BuiltinFunction._create(\"equal\",205,207,207);BuiltinFunction._create(\"equal\",205,205,205);BuiltinFunction._create(\"notEqual\",205,208,208);BuiltinFunction._create(\"notEqual\",205,206,206);BuiltinFunction._create(\"notEqual\",205,207,207);BuiltinFunction._create(\"notEqual\",205,205,205);BuiltinFunction._create(\"any\",Keyword.BOOL,205);BuiltinFunction._create(\"all\",Keyword.BOOL,205);BuiltinFunction._create(\"not\",205,205);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,210,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,211,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,212,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,Keyword.SAMPLER2D_SHADOW,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC2,Keyword.SAMPLER_CUBE_SHADOW,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,213,Keyword.INT);BuiltinFunction._create(\"textureSize\",Keyword.IVEC3,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.INT);BuiltinFunction._create(\"texture2D\",209,210,Keyword.VEC2);BuiltinFunction._create(\"texture2D\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,210,Keyword.VEC2);BuiltinFunction._create(\"texture\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,211,Keyword.VEC3);BuiltinFunction._create(\"texture\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,212,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"texture\",209,Keyword.SAMPLER2D_ARRAY,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture\",209,Keyword.SAMPLER2D_ARRAY,Keyword.VEC3);BuiltinFunction._create(\"texture\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC3);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,210,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",209,211,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",209,211,Keyword.VEC4);BuiltinFunction._create(\"textureProj\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProj\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4);BuiltinFunction._create(\"textureLod\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureLod\",209,213,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLod\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLodEXT\",209,210,Keyword.VEC2,Keyword.FLOAT);BuiltinFunction._create(\"texture2DLodEXT\",209,211,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCube\",209,212,Keyword.VEC3);BuiltinFunction._create(\"textureCube\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCubeLod\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureCubeLodEXT\",209,212,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,210,Keyword.VEC2,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,210,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureOffset\",209,211,Keyword.VEC3,Keyword.IVEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,211,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"textureOffset\",209,213,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureOffset\",209,213,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"texelFetch\",209,210,Keyword.IVEC2,Keyword.INT);BuiltinFunction._create(\"texelFetch\",209,211,Keyword.IVEC3,Keyword.INT);BuiltinFunction._create(\"texelFetch\",209,213,Keyword.IVEC3,Keyword.INT);BuiltinFunction._create(\"texelFetchOffset\",209,210,Keyword.IVEC2,Keyword.INT,Keyword.IVEC2);BuiltinFunction._create(\"texelFetchOffset\",209,211,Keyword.IVEC3,Keyword.INT,Keyword.IVEC3);BuiltinFunction._create(\"texelFetchOffset\",209,213,Keyword.IVEC3,Keyword.INT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC3,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC3,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC4,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,210,Keyword.VEC4,Keyword.IVEC2);BuiltinFunction._create(\"textureProjOffset\",209,211,Keyword.VEC4,Keyword.IVEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",209,211,Keyword.VEC4,Keyword.IVEC3);BuiltinFunction._create(\"textureProjOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.IVEC2,Keyword.FLOAT);BuiltinFunction._create(\"textureProjOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,210,Keyword.VEC2,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,211,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC3);BuiltinFunction._create(\"textureLodOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureLodOffset\",209,213,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLod\",209,210,Keyword.VEC3,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",209,210,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",209,211,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLod\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT);BuiltinFunction._create(\"textureProjLodOffset\",209,210,Keyword.VEC3,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLodOffset\",209,210,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureProjLodOffset\",209,211,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC3);BuiltinFunction._create(\"textureProjLodOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.FLOAT,Keyword.IVEC2);BuiltinFunction._create(\"textureGrad\",209,210,Keyword.VEC2,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",209,211,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",209,212,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER_CUBE_SHADOW,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureGrad\",209,213,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureGradOffset\",209,210,Keyword.VEC2,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",209,211,Keyword.VEC3,Keyword.VEC3,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",209,213,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_ARRAY_SHADOW,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGrad\",209,210,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGrad\",209,210,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGrad\",209,211,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3);BuiltinFunction._create(\"textureProjGrad\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,210,Keyword.VEC3,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,210,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._create(\"textureProjGradOffset\",209,211,Keyword.VEC4,Keyword.VEC3,Keyword.VEC3,Keyword.IVEC3);BuiltinFunction._create(\"textureProjGradOffset\",Keyword.FLOAT,Keyword.SAMPLER2D_SHADOW,Keyword.VEC4,Keyword.VEC2,Keyword.VEC2,Keyword.IVEC2);BuiltinFunction._createWithScope(\"dFdx\",200,EShaderStage.FRAGMENT,200);BuiltinFunction._createWithScope(\"dFdy\",200,EShaderStage.FRAGMENT,200);BuiltinFunction._createWithScope(\"fwidth\",200,EShaderStage.FRAGMENT,200);var ShaderBuiltinSemantic=function(ShaderBuiltinSemantic){ShaderBuiltinSemantic[\"VertexPosition\"]=\"vertex-position\";ShaderBuiltinSemantic[\"FragmentOutput0\"]=\"fragment-output-0\";ShaderBuiltinSemantic[\"FragmentOutputArray\"]=\"fragment-output-array\";ShaderBuiltinSemantic[\"FragmentDepth\"]=\"fragment-depth\";return ShaderBuiltinSemantic}({});var BuiltinVariableTable=new Map;var BuiltinVariable=function(){function BuiltinVariable(type,lexeme,scope,semantic){this.type=type;this.lexeme=lexeme;this.scope=scope;this.semantic=semantic}BuiltinVariable.createVariable=function createVariable(lexeme,type,scope,semantic){if(scope===void 0)scope=EShaderStage.ALL;var item=new BuiltinVariable(type,lexeme,scope,semantic);BuiltinVariableTable.set(lexeme,item)};BuiltinVariable.getVar=function getVar(ident){return BuiltinVariableTable.get(ident)};return BuiltinVariable}();BuiltinVariable.createVariable(\"gl_VertexID\",Keyword.INT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_InstanceID\",Keyword.INT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_Position\",Keyword.VEC4,EShaderStage.VERTEX,ShaderBuiltinSemantic.VertexPosition);BuiltinVariable.createVariable(\"gl_PointSize\",Keyword.FLOAT,EShaderStage.VERTEX);BuiltinVariable.createVariable(\"gl_FragCoord\",Keyword.VEC4,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FrontFacing\",Keyword.BOOL,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FragDepth\",Keyword.FLOAT,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentDepth);BuiltinVariable.createVariable(\"gl_FragDepthEXT\",Keyword.FLOAT,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentDepth);BuiltinVariable.createVariable(\"gl_PointCoord\",Keyword.VEC2,EShaderStage.FRAGMENT);BuiltinVariable.createVariable(\"gl_FragColor\",Keyword.VEC4,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentOutput0);BuiltinVariable.createVariable(\"gl_FragData\",Keyword.VEC4_ARRAY,EShaderStage.FRAGMENT,ShaderBuiltinSemantic.FragmentOutputArray);BuiltinVariable.createVariable(\"gl_MaxVertexAttribs\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexUniformVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexOutputVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxFragmentInputVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxVertexTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxCombinedTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxTextureImageUnits\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxFragmentUniformVectors\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxDrawBuffers\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MinProgramTexelOffset\",Keyword.INT);BuiltinVariable.createVariable(\"gl_MaxProgramTexelOffset\",Keyword.INT);var SymbolDataType=function SymbolDataType(type,typeLexeme,arraySpecifier,structDeclarations){if(structDeclarations===void 0)structDeclarations=[];this.type=type;this.typeLexeme=typeLexeme;this.arraySpecifier=arraySpecifier;this.structDeclarations=structDeclarations};var ESymbolType=function(ESymbolType){ESymbolType[ESymbolType[\"VAR\"]=0]=\"VAR\";ESymbolType[ESymbolType[\"FN\"]=1]=\"FN\";ESymbolType[ESymbolType[\"STRUCT\"]=2]=\"STRUCT\";ESymbolType[ESymbolType[\"Any\"]=3]=\"Any\";return ESymbolType}({});var SymbolInfo=function(){function SymbolInfo(ident,type,astNode,dataType,paramSignature,isInMacroBranch){if(isInMacroBranch===void 0)isInMacroBranch=false;this.ident=ident;this.type=type;this.astNode=astNode;this.dataType=dataType;this.paramSignature=paramSignature;this.isInMacroBranch=isInMacroBranch;this.sourceScope=0;this.branchSignature=EMPTY_BRANCH}var _proto=SymbolInfo.prototype;_proto.set=function set(ident,symbolType,astNode,dataType,paramSignature){this.ident=ident;this.type=symbolType;this.astNode=astNode;this.dataType=dataType;this.paramSignature=paramSignature};_proto.equal=function equal(symbol){if(symbol.type!==3&&this.type!==symbol.type)return false;if(this.type===1){if(!symbol.astNode&&!symbol.paramSignature)return true;var params=this.astNode.protoType.paramSig;var _symbol_paramSignature;var comparedParams=(_symbol_paramSignature=symbol.paramSignature)!=null?_symbol_paramSignature:symbol.astNode.protoType.paramSig;var length=params==null?void 0:params.length;if(length!==(comparedParams==null?void 0:comparedParams.length))return false;for(var i=0;i<length;i++){var t1=params[i],t2=comparedParams[i];if(t1===TypeAny||t2===TypeAny)continue;if(t1!==t2)return false}return true}return true};return SymbolInfo}();var FnSymbol=function(SymbolInfo){_inherits(FnSymbol,SymbolInfo);function FnSymbol(lexeme,astNode,localVariables,calledFunctions){if(localVariables===void 0)localVariables=[];if(calledFunctions===void 0)calledFunctions=[];var _this;var type=new SymbolDataType(astNode.protoType.returnType.type,astNode.protoType.returnType.typeSpecifier.lexeme,undefined,astNode.protoType.returnType.typeSpecifier.structDeclarations);_this=SymbolInfo.call(this,lexeme,ESymbolType.FN,astNode,type)||this;_this.localVariables=localVariables.slice();_this.calledFunctions=calledFunctions.slice();return _this}return FnSymbol}(SymbolInfo);var StructSymbol=function(SymbolInfo){_inherits(StructSymbol,SymbolInfo);function StructSymbol(lexeme,astNode){return SymbolInfo.call(this,lexeme,ESymbolType.STRUCT,astNode)||this}return StructSymbol}(SymbolInfo);var VarSymbol=function(SymbolInfo){_inherits(VarSymbol,SymbolInfo);function VarSymbol(ident,dataType,isGlobalVariable,initAst,isConst,isUniform){if(isConst===void 0)isConst=false;if(isUniform===void 0)isUniform=false;var _this;_this=SymbolInfo.call(this,ident,ESymbolType.VAR,initAst,dataType)||this;_this.isGlobalVariable=isGlobalVariable;_this.isConst=isConst;_this.isUniform=isUniform;return _this}return VarSymbol}(SymbolInfo);var TypeSystem=function(){function TypeSystem(){}TypeSystem.isAssignable=function isAssignable(target,source){if(target==undefined||source==undefined||target===TypeAny||source===TypeAny)return true;return target===source};TypeSystem.typeName=function typeName(type){if(typeof type===\"string\")return type;if(type==undefined)return\"unknown\";var _Keyword_type;return((_Keyword_type=Keyword[type])!=null?_Keyword_type:String(type)).toLowerCase()};TypeSystem.isSamplerType=function isSamplerType(type){switch(type){case Keyword.SAMPLER2D:case Keyword.SAMPLER3D:case Keyword.SAMPLER_CUBE:case Keyword.SAMPLER2D_SHADOW:case Keyword.SAMPLER_CUBE_SHADOW:case Keyword.SAMPLER2D_ARRAY:case Keyword.SAMPLER2D_ARRAY_SHADOW:case Keyword.I_SAMPLER2D:case Keyword.I_SAMPLER3D:case Keyword.I_SAMPLER_CUBE:case Keyword.I_SAMPLER2D_ARRAY:case Keyword.U_SAMPLER2D:case Keyword.U_SAMPLER3D:case Keyword.U_SAMPLER_CUBE:case Keyword.U_SAMPLER2D_ARRAY:return true;default:return false}};TypeSystem.isBoolType=function isBoolType(type){return type===Keyword.BOOL||type===Keyword.BVEC2||type===Keyword.BVEC3||type===Keyword.BVEC4};TypeSystem.isIntegerType=function isIntegerType(type){switch(type){case Keyword.INT:case Keyword.UINT:case Keyword.IVEC2:case Keyword.IVEC3:case Keyword.IVEC4:case Keyword.UVEC2:case Keyword.UVEC3:case Keyword.UVEC4:return true;default:return false}};TypeSystem.nonArithmeticOperand=function nonArithmeticOperand(type){return type!=undefined&&type!==TypeAny&&(this.isBoolType(type)||this.isSamplerType(type)||typeof type===\"string\")};TypeSystem.isScalarType=function isScalarType(type){return type===Keyword.FLOAT||type===Keyword.INT||type===Keyword.UINT||type===Keyword.BOOL};TypeSystem.arithmeticOperation=function arithmeticOperation(left,right,operator){if(left==undefined||right==undefined||left===TypeAny||right===TypeAny){return{resultType:TypeAny,valid:undefined}}var leftFamily=this._arithmeticFamily(left);var rightFamily=this._arithmeticFamily(right);if(!leftFamily||!rightFamily){return{resultType:TypeAny,valid:false,reason:\"non-arithmetic\"}}if(leftFamily!==rightFamily){return{resultType:TypeAny,valid:false,reason:\"family-mismatch\"}}if(operator===\"%\"&&leftFamily===\"float\"){return{resultType:TypeAny,valid:false,reason:\"integer-required\"}}var leftScalar=this.isScalarType(left);var rightScalar=this.isScalarType(right);if(leftScalar||rightScalar){return{resultType:leftScalar?right:left,valid:true}}var leftVectorSize=this.vectorComponentCount(left);var rightVectorSize=this.vectorComponentCount(right);var leftMatrix=this.matrixDimensions(left);var rightMatrix=this.matrixDimensions(right);if(leftVectorSize&&rightVectorSize){return leftVectorSize===rightVectorSize?{resultType:left,valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(leftMatrix&&rightMatrix){if(operator===\"*\"){return leftMatrix.columns===rightMatrix.rows?{resultType:this._matrixType(rightMatrix.columns,leftMatrix.rows),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}return leftMatrix.columns===rightMatrix.columns&&leftMatrix.rows===rightMatrix.rows?{resultType:left,valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(operator===\"*\"&&leftMatrix&&rightVectorSize){return leftMatrix.columns===rightVectorSize?{resultType:this._vectorType(leftMatrix.rows),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}if(operator===\"*\"&&leftVectorSize&&rightMatrix){return leftVectorSize===rightMatrix.rows?{resultType:this._vectorType(rightMatrix.columns),valid:true}:{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}}return{resultType:TypeAny,valid:false,reason:\"shape-mismatch\"}};TypeSystem.arithmeticResultType=function arithmeticResultType(a,b,operator){if(operator===void 0)operator=\"+\";return this.arithmeticOperation(a,b,operator).resultType};TypeSystem._arithmeticFamily=function _arithmeticFamily(type){if(typeof type===\"string\"||this.isBoolType(type)||this.isSamplerType(type))return undefined;if(this.matrixDimensions(type))return\"float\";switch(type){case Keyword.FLOAT:case Keyword.VEC2:case Keyword.VEC3:case Keyword.VEC4:return\"float\";case Keyword.INT:case Keyword.IVEC2:case Keyword.IVEC3:case Keyword.IVEC4:return\"int\";case Keyword.UINT:case Keyword.UVEC2:case Keyword.UVEC3:case Keyword.UVEC4:return\"uint\";default:return undefined}};TypeSystem._vectorType=function _vectorType(size){return size===2?Keyword.VEC2:size===3?Keyword.VEC3:size===4?Keyword.VEC4:TypeAny};TypeSystem._matrixType=function _matrixType(columns,rows){var key=\"MAT\"+columns+(columns===rows?\"\":\"X\"+rows);var _Keyword_key;return(_Keyword_key=Keyword[key])!=null?_Keyword_key:TypeAny};TypeSystem.vectorComponentCount=function vectorComponentCount(type){switch(type){case Keyword.VEC2:case Keyword.IVEC2:case Keyword.UVEC2:case Keyword.BVEC2:return 2;case Keyword.VEC3:case Keyword.IVEC3:case Keyword.UVEC3:case Keyword.BVEC3:return 3;case Keyword.VEC4:case Keyword.IVEC4:case Keyword.UVEC4:case Keyword.BVEC4:return 4;default:return 0}};TypeSystem.matrixComponentCount=function matrixComponentCount(type){var dimensions=this.matrixDimensions(type);return dimensions?dimensions.columns*dimensions.rows:0};TypeSystem.matrixDimensions=function matrixDimensions(type){switch(type){case Keyword.MAT2:return{columns:2,rows:2};case Keyword.MAT3:return{columns:3,rows:3};case Keyword.MAT4:return{columns:4,rows:4};case Keyword.MAT2X3:return{columns:2,rows:3};case Keyword.MAT3X2:return{columns:3,rows:2};case Keyword.MAT2X4:return{columns:2,rows:4};case Keyword.MAT4X2:return{columns:4,rows:2};case Keyword.MAT3X4:return{columns:3,rows:4};case Keyword.MAT4X3:return{columns:4,rows:3};default:return undefined}};return TypeSystem}();var ParserUtils=function(){function ParserUtils(){}ParserUtils.unwrapNodeByType=function unwrapNodeByType(node,type){var child=node.children[0];if(_instanceof(child,BaseToken))return;if(child.nt===type)return child;return ParserUtils.unwrapNodeByType(child,type)};ParserUtils.parseMacroParamList=function parseMacroParamList(lexeme){var inner=lexeme.replace(/^\\s*\\(\\s*|\\s*\\)\\s*$/g,\"\");if(!inner)return[];return inner.split(\",\").map(function(s){return s.trim()}).filter(Boolean)};ParserUtils.unwrapBareIdentifier=function unwrapBareIdentifier(node,options){var cur=node;while(true){if(_instanceof(cur,ASTNode.VariableIdentifier))return cur;if(options.allowParens&&_instanceof(cur,ASTNode.PrimaryExpression)&&cur.children.length===3){var inner=cur.children[1];if(!_instanceof(inner,TreeNode))return undefined;cur=inner;continue}if(_instanceof(cur,ASTNode.ExpressionAstNode)&&cur.children.length===1){var child=cur.children[0];if(!_instanceof(child,TreeNode))return undefined;cur=child;continue}return undefined}};ParserUtils.extractDirectIdentLexeme=function extractDirectIdentLexeme(expr){var ident=ParserUtils.unwrapBareIdentifier(expr,{allowParens:true});if(!ident)return null;var child=ident.children[0];return _instanceof(child,BaseToken)?child.lexeme:null};ParserUtils.lastStatement=function lastStatement(node){if(_instanceof(node,ASTNode.Statement)||_instanceof(node,ASTNode.SimpleStatement)||_instanceof(node,ASTNode.CompoundStatement)||_instanceof(node,ASTNode.CompoundStatementNoScope)){if(node.children.length===2)return;for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(!_instanceof(child,TreeNode))continue;var statement=ParserUtils.lastStatement(child);if(statement)return statement}return}if(_instanceof(node,ASTNode.StatementList)){for(var i=node.children.length-1;i>=0;i--){var child1=node.children[i];if(!_instanceof(child1,TreeNode))continue;var statement1=ParserUtils.lastStatement(child1);if(statement1)return statement1}return}return node};ParserUtils.swizzleError=function swizzleError(baseType,swizzle,size){if(size===void 0)size=TypeSystem.vectorComponentCount(baseType);if(size===0)return null;if(swizzle.length<1||swizzle.length>4){return'Invalid swizzle \".'+swizzle+'\": a vector swizzle selects 1-4 components.'}var sets=ParserUtils._swizzleSets;var setIndex=-1;for(var _iterator=_create_for_of_iterator_helper_loose(swizzle),_step;!(_step=_iterator()).done;){var ch=_step.value;var matched=false;for(var s=0;s<sets.length;s++){var idx=sets[s].indexOf(ch);if(idx===-1)continue;if(setIndex===-1)setIndex=s;else if(setIndex!==s)return'Invalid swizzle \".'+swizzle+'\": components must come from one set (xyzw, rgba, or stpq).';if(idx>=size)return'Invalid swizzle \".'+swizzle+\"\\\": component '\"+ch+\"' is out of range for a \"+size+\"-component vector.\";matched=true;break}if(!matched)return'Invalid swizzle \".'+swizzle+\"\\\": '\"+ch+\"' is not a vector component.\"}return null};ParserUtils.constNumericValue=function constNumericValue(node){var cur=node;while(true){if(_instanceof(cur,ASTNode.PrimaryExpression)){if(cur.children.length===3){var inner=cur.children[1];if(!_instanceof(inner,TreeNode))return undefined;cur=inner;continue}var leaf=cur.children[0];if(_instanceof(leaf,BaseToken)&&(leaf.type===ETokenType.INT_CONSTANT||leaf.type===ETokenType.FLOAT_CONSTANT)){var n=Number(leaf.lexeme);return Number.isNaN(n)?undefined:n}return undefined}if(_instanceof(cur,ASTNode.ExpressionAstNode)&&cur.children.length===1){var child=cur.children[0];if(!_instanceof(child,TreeNode))return undefined;cur=child;continue}return undefined}};ParserUtils.constIntegerValue=function constIntegerValue(node){return ParserUtils._constIntegerValue(node,new Set)};ParserUtils._constIntegerValue=function _constIntegerValue(node,resolving){if(_instanceof(node,ASTNode.PrimaryExpression)){if(node.children.length===3){var inner=node.children[1];return _instanceof(inner,TreeNode)?ParserUtils._constIntegerValue(inner,resolving):undefined}var leaf=node.children[0];if(_instanceof(leaf,BaseToken)&&leaf.type===ETokenType.INT_CONSTANT){var value=Number(leaf.lexeme.replace(/[uU]$/,\"\"));return Number.isSafeInteger(value)?ParserUtils._normalizeInteger(value,node.type):undefined}}var ident=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(ident){var child=ident.children[0];if(!_instanceof(child,BaseToken))return;var symbols=ident.resolvedSymbols();if(!symbols.length)return;var resolvedValue;for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;if(!_instanceof(symbol,VarSymbol)||!symbol.isConst||resolving.has(symbol))return;var initializer=ParserUtils._constInitializer(symbol);if(!initializer)return;resolving.add(symbol);var value1=ParserUtils._constIntegerValue(initializer,resolving);resolving.delete(symbol);if(value1===undefined||resolvedValue!==undefined&&resolvedValue!==value1)return;resolvedValue=value1}return resolvedValue}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var fn=node.children[0];if(fn.ident!==\"int\"&&fn.ident!==\"uint\")return;var params=node.children[2];if(!_instanceof(params,ASTNode.FunctionCallParameterList)||params.paramNodes.length!==1)return;var value2=ParserUtils._constIntegerValue(params.paramNodes[0],resolving);return value2===undefined?undefined:ParserUtils._normalizeInteger(value2,node.type)}var children=node.children;var nodeType=_instanceof(node,ASTNode.ExpressionAstNode)?node.type:undefined;if(children.length===1){var child1=children[0];return _instanceof(child1,TreeNode)?ParserUtils._constIntegerValue(child1,resolving):undefined}if(_instanceof(node,ASTNode.ConditionalExpression)&&children.length===5){var condition=children[0];var whenTrue=children[2];var whenFalse=children[4];if(!_instanceof(condition,TreeNode)||!_instanceof(whenTrue,TreeNode)||!_instanceof(whenFalse,TreeNode)){return}var conditionValue=ParserUtils._constIntegerValue(condition,resolving);return conditionValue===undefined?undefined:ParserUtils._constIntegerValue(conditionValue!==0?whenTrue:whenFalse,resolving)}if(children.length===2&&_instanceof(children[1],TreeNode)){var operator=ParserUtils._operatorLexeme(children[0]);var operand=ParserUtils._constIntegerValue(children[1],resolving);if(operator===undefined||operand===undefined)return;var value3;if(operator===\"+\")value3=operand;else if(operator===\"-\")value3=-operand;else if(operator===\"~\")value3=~operand;else if(operator===\"!\")value3=operand===0?1:0;else return;return ParserUtils._normalizeInteger(value3,nodeType)}if(children.length===3&&_instanceof(children[0],TreeNode)&&_instanceof(children[2],TreeNode)){if(_instanceof(node,ASTNode.AssignmentExpression))return;var operator1=ParserUtils._operatorLexeme(children[1]);var left=ParserUtils._constIntegerValue(children[0],resolving);var right=ParserUtils._constIntegerValue(children[2],resolving);if(operator1===undefined||left===undefined||right===undefined)return;var value4;switch(operator1){case\"+\":value4=left+right;break;case\"-\":value4=left-right;break;case\"*\":value4=left*right;break;case\"/\":if(right===0)return;value4=Math.trunc(left/right);break;case\"%\":if(right===0)return;value4=left%right;break;case\"<<\":value4=left<<right;break;case\">>\":value4=nodeType===Keyword.UINT?left>>>right:left>>right;break;case\"&\":value4=left&right;break;case\"^\":value4=left^right;break;case\"|\":value4=left|right;break;case\"&&\":value4=left!==0&&right!==0?1:0;break;case\"^^\":value4=left!==0!==(right!==0)?1:0;break;case\"||\":value4=left!==0||right!==0?1:0;break;case\"<\":value4=left<right?1:0;break;case\">\":value4=left>right?1:0;break;case\"<=\":value4=left<=right?1:0;break;case\">=\":value4=left>=right?1:0;break;case\"==\":value4=left===right?1:0;break;case\"!=\":value4=left!==right?1:0;break;default:return}return ParserUtils._normalizeInteger(value4,nodeType)}return};ParserUtils._constInitializer=function _constInitializer(symbol){var declaration=symbol.astNode;if(_instanceof(declaration,ASTNode.InitDeclaratorList)||_instanceof(declaration,ASTNode.VariableDeclaration)){var _declaration_declarator;return(_declaration_declarator=declaration.declarator)==null?void 0:_declaration_declarator.initializer}return _instanceof(declaration,TreeNode)?declaration:undefined};ParserUtils._operatorLexeme=function _operatorLexeme(node){if(_instanceof(node,BaseToken))return node.lexeme;if(!_instanceof(node,TreeNode))return;for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;var lexeme=ParserUtils._operatorLexeme(child);if(lexeme!==undefined)return lexeme}return};ParserUtils._normalizeInteger=function _normalizeInteger(value,type){return type===Keyword.UINT?value>>>0:value|0};ParserUtils.hasQualifier=function hasQualifier(node,keyword){for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,BaseToken)){if(child.type===keyword)return true}else if(_instanceof(child,TreeNode)&&ParserUtils.hasQualifier(child,keyword)){return true}}return false};ParserUtils.isConstExpr=function isConstExpr(node){if(ParserUtils.constNumericValue(node)!==undefined)return true;if(ParserUtils._isBooleanLiteral(node))return true;var ident=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(ident){var child=ident.children[0];if(_instanceof(child,ASTNode.MacroCallSymbol)||_instanceof(child,ASTNode.MacroCallFunction))return true;if(!_instanceof(child,BaseToken))return false;var symbols=ident.resolvedSymbols();return symbols.length>0&&symbols.every(function(symbol){return _instanceof(symbol,VarSymbol)&&symbol.isConst})}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var fnIdent=node.children[0];var isConstructor=fnIdent.isBuiltin;var isBuiltinFn=typeof fnIdent.ident===\"string\"&&BuiltinFunction.isExist(fnIdent.ident);if(!isConstructor&&!isBuiltinFn)return false;var list=node.children[2];if(!_instanceof(list,ASTNode.FunctionCallParameterList))return true;for(var _iterator=_create_for_of_iterator_helper_loose(list.paramNodes),_step;!(_step=_iterator()).done;){var arg=_step.value;if(_instanceof(arg,TreeNode)&&!ParserUtils.isConstExpr(arg))return false}return true}if(_instanceof(node,ASTNode.ExpressionAstNode)){var sawSubExpr=false;for(var _iterator1=_create_for_of_iterator_helper_loose(node.children),_step1;!(_step1=_iterator1()).done;){var c=_step1.value;if(_instanceof(c,ASTNode.ExpressionAstNode)){sawSubExpr=true;if(!ParserUtils.isConstExpr(c))return false}}return sawSubExpr}return false};ParserUtils._isBooleanLiteral=function _isBooleanLiteral(node){var current=node;while(true){if(_instanceof(current,ASTNode.PrimaryExpression)){if(current.children.length===3){var child=current.children[1];if(!_instanceof(child,TreeNode))return false;current=child;continue}var token=current.children[0];return _instanceof(token,BaseToken)&&(token.type===Keyword.True||token.type===Keyword.False)}if(_instanceof(current,ASTNode.ExpressionAstNode)&¤t.children.length===1){var child1=current.children[0];if(!_instanceof(child1,TreeNode))return false;current=child1;continue}return false}};ParserUtils.firstNonArithmeticOperand=function firstNonArithmeticOperand(a,b){for(var _i=0,_iter=[a,b];_i<_iter.length;_i++){var n=_iter[_i];if(_instanceof(n,ASTNode.ExpressionAstNode)&&TypeSystem.nonArithmeticOperand(n.type))return n}return undefined};ParserUtils.toString=function toString(sm){if(this.isTerminal(sm)){var _ETokenType_sm;return(_ETokenType_sm=ETokenType[sm])!=null?_ETokenType_sm:Keyword[sm]}return NoneTerminal[sm]};ParserUtils.isTerminal=function isTerminal(sm){return sm<NoneTerminal.START};return ParserUtils}();ParserUtils._swizzleSets=[\"xyzw\",\"rgba\",\"stpq\"];var SymbolType=function(SymbolDataType){_inherits(SymbolType,SymbolDataType);function SymbolType(){return SymbolDataType.apply(this,arguments)||this}return SymbolType}(SymbolDataType);var StructProp=function StructProp(typeInfo,ident,mrtIndex,isInMacroBranch,isFlat){if(isInMacroBranch===void 0)isInMacroBranch=false;if(isFlat===void 0)isFlat=false;this.typeInfo=typeInfo;this.ident=ident;this.mrtIndex=mrtIndex;this.isInMacroBranch=isInMacroBranch;this.isFlat=isFlat};var TEXTURE_SAMPLING_BUILTINS=new Set([\"texture\",\"texture2D\",\"texture2DLod\",\"texture2DLodEXT\",\"textureCube\",\"textureCubeLod\",\"textureCubeLodEXT\",\"textureLod\",\"textureOffset\",\"textureProj\",\"textureProjLod\",\"textureProjOffset\",\"textureSize\",\"texelFetch\"]);var EMPTY_FN_SYMBOLS=Object.freeze([]);var EMPTY_STRUCT_DECLARATIONS=Object.freeze([]);var EMPTY_VALUE_SYMBOLS=Object.freeze([]);function ASTNodeDecorator(nonTerminal){return function(ASTNode){ASTNode.prototype.nt=nonTerminal}}var TreeNode=function(){function TreeNode(){this._branch=EMPTY_BRANCH;this._inMacroDefinition=false}var _proto=TreeNode.prototype;_proto.set=function set(loc,children){this._location=loc;this._children=children;this._parent=undefined;var branch=EMPTY_BRANCH;var inheritedBranch=false;var inMacroDefinition=false;for(var _iterator=_create_for_of_iterator_helper_loose(children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,TreeNode)){child._parent=this;if(!inheritedBranch){branch=child._branch;inMacroDefinition=child._inMacroDefinition;inheritedBranch=true}}else if(!inheritedBranch&&_instanceof(child,BaseToken)){branch=child.branch;inMacroDefinition=child.inMacroDefinition;inheritedBranch=true}}this._branch=branch;this._inMacroDefinition=inMacroDefinition;this.init()};_proto.init=function init(){};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.defaultCodeGen(this.children))};_proto.semanticAnalyze=function semanticAnalyze(sa){};_create_class(TreeNode,[{key:\"parent\",get:function get(){return this._parent}},{key:\"children\",get:function get(){return this._children}},{key:\"location\",get:function get(){return this._location}}]);return TreeNode}();(function(ASTNodes){function mergeBranchSignatures(left,right){if(!left.length)return right;if(!right.length)return left;var merged=left.slice();for(var _iterator=_create_for_of_iterator_helper_loose(right),_step;!(_step=_iterator()).done;){var constraint=_step.value;if(merged.indexOf(constraint)===-1)merged.push(constraint)}return merged}function appendMacroReference(references,candidate){var duplicate=references.find(function(reference){return reference.name===candidate.name&&reference.formalParameterIndex===candidate.formalParameterIndex&&reference.unresolved===candidate.unresolved&&reference.branch.length===candidate.branch.length&&reference.branch.every(function(constraint,index){return constraint===candidate.branch[index]})&&reference.replacementMemberOwner===candidate.replacementMemberOwner&&reference.requiresRuntimeOwnerExpansion===candidate.requiresRuntimeOwnerExpansion});if(duplicate){if(candidate.isValueIdentity)duplicate.isValueIdentity=true}else{references.push(candidate)}}function appendSubstitutedValueIdentityReferences(node,template,references,names){var identity=ParserUtils.unwrapBareIdentifier(node,{allowParens:true});if(!identity)return;var child=identity.children[0];if(_instanceof(child,BaseToken)){appendMacroReference(references,{name:child.lexeme,branch:mergeBranchSignatures(template.branch,identity._branch),isValueIdentity:true});if(names.indexOf(child.lexeme)===-1)names.push(child.lexeme);return}if(!(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)))return;var appendedIdentity=false;for(var _iterator=_create_for_of_iterator_helper_loose(child.referenceSymbols),_step;!(_step=_iterator()).done;){var actualReference=_step.value;if(!actualReference.isValueIdentity)continue;if(actualReference.unresolved){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(template.branch,actualReference.branch),isValueIdentity:true});appendedIdentity=true;continue}if(actualReference.name===undefined)continue;appendMacroReference(references,{name:actualReference.name,branch:mergeBranchSignatures(template.branch,actualReference.branch),isValueIdentity:true});if(names.indexOf(actualReference.name)===-1)names.push(actualReference.name);appendedIdentity=true}if(!appendedIdentity&&!child.visibleHasAstValue&&child.macroName){appendMacroReference(references,{name:child.macroName,branch:mergeBranchSignatures(template.branch,identity._branch),isValueIdentity:true});if(names.indexOf(child.macroName)===-1)names.push(child.macroName)}}function appendSubstitutedOwnerReferences(node,template,references,names){if(template.isValueIdentity){appendSubstitutedValueIdentityReferences(node,template,references,names);return}if(_instanceof(node,VariableIdentifier)){var child=node.children[0];if(_instanceof(child,BaseToken)){appendMacroReference(references,{name:child.lexeme,branch:mergeBranchSignatures(template.branch,node._branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(child.lexeme)===-1)names.push(child.lexeme)}else if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var actualReferences=child.referenceSymbols;for(var _iterator=_create_for_of_iterator_helper_loose(actualReferences),_step;!(_step=_iterator()).done;){var actualReference=_step.value;if(actualReference.unresolved){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(template.branch,actualReference.branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});continue}if(actualReference.name===undefined)continue;appendMacroReference(references,{name:actualReference.name,branch:mergeBranchSignatures(template.branch,actualReference.branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(actualReference.name)===-1)names.push(actualReference.name)}if(!actualReferences.length&&child.macroName){appendMacroReference(references,{name:child.macroName,branch:mergeBranchSignatures(template.branch,node._branch),replacementMemberOwner:template.replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(names.indexOf(child.macroName)===-1)names.push(child.macroName)}}return}for(var _iterator1=_create_for_of_iterator_helper_loose(node.children),_step1;!(_step1=_iterator1()).done;){var child1=_step1.value;if(_instanceof(child1,TreeNode))appendSubstitutedOwnerReferences(child1,template,references,names)}}function _unwrapToken(node){if(_instanceof(node,BaseToken)){return node}throw\"not token\"}ASTNodes._unwrapToken=_unwrapToken;function get(type,sa,loc,children){var node=sa.objectPool?sa.objectPool.createNode(type):new type;node.set(loc,children);if(!sa.diagnosticsEnabled){node.semanticAnalyze(sa);sa.semanticStack.push(node);return}var prev=sa.symbolTableStack._currentBranch;var previousMacroDefinition=sa.inMacroDefinition;sa.symbolTableStack._currentBranch=node._branch;sa.inMacroDefinition=node._inMacroDefinition;node.semanticAnalyze(sa);sa.symbolTableStack._currentBranch=prev;sa.inMacroDefinition=previousMacroDefinition;sa.semanticStack.push(node)}ASTNodes.get=get;var TrivialNode=function(TreeNode){_inherits(TrivialNode,TreeNode);function TrivialNode(){return TreeNode.apply(this,arguments)||this}return TrivialNode}(TreeNode);ASTNodes.TrivialNode=TrivialNode;TrivialNode=__decorate([ASTNodeDecorator(NoneTerminal._ignore)],TrivialNode);var ScopeBrace=function(TreeNode){_inherits(ScopeBrace,TreeNode);function ScopeBrace(){return TreeNode.apply(this,arguments)||this}var _proto=ScopeBrace.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.pushScope()};return ScopeBrace}(TreeNode);ASTNodes.ScopeBrace=ScopeBrace;ScopeBrace=__decorate([ASTNodeDecorator(NoneTerminal.scope_brace)],ScopeBrace);var ScopeEndBrace=function(TreeNode){_inherits(ScopeEndBrace,TreeNode);function ScopeEndBrace(){return TreeNode.apply(this,arguments)||this}var _proto=ScopeEndBrace.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.popScope()};return ScopeEndBrace}(TreeNode);ASTNodes.ScopeEndBrace=ScopeEndBrace;ScopeEndBrace=__decorate([ASTNodeDecorator(NoneTerminal.scope_end_brace)],ScopeEndBrace);var JumpStatement=function(TreeNode){_inherits(JumpStatement,TreeNode);function JumpStatement(){return TreeNode.apply(this,arguments)||this}var _proto=JumpStatement.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitJumpStatement(this))};return JumpStatement}(TreeNode);ASTNodes.JumpStatement=JumpStatement;JumpStatement=__decorate([ASTNodeDecorator(NoneTerminal.jump_statement)],JumpStatement);var ConditionOpt=function(TreeNode){_inherits(ConditionOpt,TreeNode);function ConditionOpt(){return TreeNode.apply(this,arguments)||this}return ConditionOpt}(TreeNode);ASTNodes.ConditionOpt=ConditionOpt;ConditionOpt=__decorate([ASTNodeDecorator(NoneTerminal.conditionopt)],ConditionOpt);var ForRestStatement=function(TreeNode){_inherits(ForRestStatement,TreeNode);function ForRestStatement(){return TreeNode.apply(this,arguments)||this}return ForRestStatement}(TreeNode);ASTNodes.ForRestStatement=ForRestStatement;ForRestStatement=__decorate([ASTNodeDecorator(NoneTerminal.for_rest_statement)],ForRestStatement);var Condition=function(TreeNode){_inherits(Condition,TreeNode);function Condition(){return TreeNode.apply(this,arguments)||this}return Condition}(TreeNode);ASTNodes.Condition=Condition;Condition=__decorate([ASTNodeDecorator(NoneTerminal.condition)],Condition);var ForInitStatement=function(TreeNode){_inherits(ForInitStatement,TreeNode);function ForInitStatement(){return TreeNode.apply(this,arguments)||this}return ForInitStatement}(TreeNode);ASTNodes.ForInitStatement=ForInitStatement;ForInitStatement=__decorate([ASTNodeDecorator(NoneTerminal.for_init_statement)],ForInitStatement);var IterationStatement=function(TreeNode){_inherits(IterationStatement,TreeNode);function IterationStatement(){return TreeNode.apply(this,arguments)||this}var _proto=IterationStatement.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(sa.diagnosticsEnabled)sa.popScope()};return IterationStatement}(TreeNode);ASTNodes.IterationStatement=IterationStatement;IterationStatement=__decorate([ASTNodeDecorator(NoneTerminal.iteration_statement)],IterationStatement);var SelectionStatement=function(TreeNode){_inherits(SelectionStatement,TreeNode);function SelectionStatement(){return TreeNode.apply(this,arguments)||this}return SelectionStatement}(TreeNode);ASTNodes.SelectionStatement=SelectionStatement;SelectionStatement=__decorate([ASTNodeDecorator(NoneTerminal.selection_statement)],SelectionStatement);var ExpressionStatement=function(TreeNode){_inherits(ExpressionStatement,TreeNode);function ExpressionStatement(){return TreeNode.apply(this,arguments)||this}return ExpressionStatement}(TreeNode);ASTNodes.ExpressionStatement=ExpressionStatement;ExpressionStatement=__decorate([ASTNodeDecorator(NoneTerminal.expression_statement)],ExpressionStatement);var ExpressionAstNode=function(TreeNode){_inherits(ExpressionAstNode,TreeNode);function ExpressionAstNode(){return TreeNode.apply(this,arguments)||this}var _proto=ExpressionAstNode.prototype;_proto.init=function init(){this._type=undefined};_create_class(ExpressionAstNode,[{key:\"type\",get:function get(){var _this__type;return(_this__type=this._type)!=null?_this__type:TypeAny},set:function set(t){this._type=t}}]);return ExpressionAstNode}(TreeNode);ASTNodes.ExpressionAstNode=ExpressionAstNode;var InitializerList=function(ExpressionAstNode){_inherits(InitializerList,ExpressionAstNode);function InitializerList(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=InitializerList.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var init=this.children[0];this.type=init.type};return InitializerList}(ExpressionAstNode);ASTNodes.InitializerList=InitializerList;InitializerList=__decorate([ASTNodeDecorator(NoneTerminal.initializer_list)],InitializerList);var Initializer=function(ExpressionAstNode){_inherits(Initializer,ExpressionAstNode);function Initializer(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=Initializer.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=this.children[1].type}};return Initializer}(ExpressionAstNode);ASTNodes.Initializer=Initializer;Initializer=__decorate([ASTNodeDecorator(NoneTerminal.initializer)],Initializer);var SingleDeclaration=function(TreeNode){_inherits(SingleDeclaration,TreeNode);function SingleDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=SingleDeclaration.prototype;_proto.init=function init(){this.typeSpecifier=undefined;this.arraySpecifier=undefined;this.isConst=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var childrenLen=children.length;var fullyType=children[0];var typeSpecifier=fullyType.typeSpecifier;this.typeSpecifier=typeSpecifier;this.arraySpecifier=typeSpecifier.arraySpecifier;var id=children[1];var isConst=fullyType.isConst;this.isConst=isConst;var symbolType;var initializer;if(childrenLen===2||childrenLen===4){symbolType=new SymbolType(fullyType.type,typeSpecifier.lexeme,this.arraySpecifier,typeSpecifier.structDeclarations);initializer=children[3]}else{var arraySpecifier=children[2];this.arraySpecifier=arraySpecifier;symbolType=new SymbolType(fullyType.type,typeSpecifier.lexeme,this.arraySpecifier,typeSpecifier.structDeclarations);initializer=children[4]}var sm=sa.assignSourceScope(new VarSymbol(id.lexeme,symbolType,false,initializer,isConst),id.location);this.declarator={identifier:id,typeInfo:symbolType,initializer:initializer,isConst:isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult=sa.symbolTableStack.insert(sm,id.branch);sa.reportRedefinition(id.location,sm,insertResult)};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitSingleDeclaration(this))};return SingleDeclaration}(TreeNode);ASTNodes.SingleDeclaration=SingleDeclaration;SingleDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.single_declaration)],SingleDeclaration);var FullySpecifiedType=function(TreeNode){_inherits(FullySpecifiedType,TreeNode);function FullySpecifiedType(){return TreeNode.apply(this,arguments)||this}var _proto=FullySpecifiedType.prototype;_proto.semanticAnalyze=function semanticAnalyze(_){var children=this.children;this.isConst=children.length===2&&ParserUtils.hasQualifier(children[0],Keyword.CONST);this.typeSpecifier=children.length===1?children[0]:children[1];this.type=this.typeSpecifier.type};return FullySpecifiedType}(TreeNode);ASTNodes.FullySpecifiedType=FullySpecifiedType;FullySpecifiedType=__decorate([ASTNodeDecorator(NoneTerminal.fully_specified_type)],FullySpecifiedType);var TypeQualifier=function(TreeNode){_inherits(TypeQualifier,TreeNode);function TypeQualifier(){return TreeNode.apply(this,arguments)||this}return TypeQualifier}(TreeNode);ASTNodes.TypeQualifier=TypeQualifier;TypeQualifier=__decorate([ASTNodeDecorator(NoneTerminal.type_qualifier)],TypeQualifier);var SingleTypeQualifier=function(TreeNode){_inherits(SingleTypeQualifier,TreeNode);function SingleTypeQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=SingleTypeQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var child=this.children[0];if(_instanceof(child,BaseToken)){this.qualifier=child.type;this.lexeme=child.lexeme}else{this.qualifier=child.qualifier;this.lexeme=child.lexeme}};return SingleTypeQualifier}(TreeNode);ASTNodes.SingleTypeQualifier=SingleTypeQualifier;SingleTypeQualifier=__decorate([ASTNodeDecorator(NoneTerminal.single_type_qualifier)],SingleTypeQualifier);var BasicTypeQualifier=function(TreeNode){_inherits(BasicTypeQualifier,TreeNode);function BasicTypeQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=BasicTypeQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var token=this.children[0];this.qualifier=token.type;this.lexeme=token.lexeme};return BasicTypeQualifier}(TreeNode);var StorageQualifier=function(BasicTypeQualifier){_inherits(StorageQualifier,BasicTypeQualifier);function StorageQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return StorageQualifier}(BasicTypeQualifier);ASTNodes.StorageQualifier=StorageQualifier;StorageQualifier=__decorate([ASTNodeDecorator(NoneTerminal.storage_qualifier)],StorageQualifier);var PrecisionQualifier=function(BasicTypeQualifier){_inherits(PrecisionQualifier,BasicTypeQualifier);function PrecisionQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return PrecisionQualifier}(BasicTypeQualifier);ASTNodes.PrecisionQualifier=PrecisionQualifier;PrecisionQualifier=__decorate([ASTNodeDecorator(NoneTerminal.precision_qualifier)],PrecisionQualifier);var InterpolationQualifier=function(BasicTypeQualifier){_inherits(InterpolationQualifier,BasicTypeQualifier);function InterpolationQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return InterpolationQualifier}(BasicTypeQualifier);ASTNodes.InterpolationQualifier=InterpolationQualifier;InterpolationQualifier=__decorate([ASTNodeDecorator(NoneTerminal.interpolation_qualifier)],InterpolationQualifier);var InvariantQualifier=function(BasicTypeQualifier){_inherits(InvariantQualifier,BasicTypeQualifier);function InvariantQualifier(){return BasicTypeQualifier.apply(this,arguments)||this}return InvariantQualifier}(BasicTypeQualifier);ASTNodes.InvariantQualifier=InvariantQualifier;InvariantQualifier=__decorate([ASTNodeDecorator(NoneTerminal.invariant_qualifier)],InvariantQualifier);var TypeSpecifier=function(TreeNode){_inherits(TypeSpecifier,TreeNode);function TypeSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=TypeSpecifier.prototype;_proto.init=function init(){this.arraySize=undefined;this.structDeclarations=EMPTY_STRUCT_DECLARATIONS;this.structDependencies=EMPTY_STRUCT_DECLARATIONS};_proto.semanticAnalyze=function semanticAnalyze(sa){var _children_;var children=this.children;var firstChild=children[0];this.type=firstChild.type;this.lexeme=firstChild.lexeme;this.arraySize=children==null?void 0:(_children_=children[1])==null?void 0:_children_.size;this.isCustom=typeof this.type===\"string\";if(this.isCustom){var lookup=sa.lookupSymbol;lookup.set(this.lexeme,ESymbolType.STRUCT);var structs=sa.symbolTableStack.lookupAll(lookup,true,sa.structScratch,this._branch);this.structDeclarations=structs.length?structs.map(function(symbol){return symbol.astNode}):EMPTY_STRUCT_DECLARATIONS;this.structDependencies=this.structDeclarations}else if(_instanceof(firstChild.children[0],MacroCallSymbol)){var dependencies=[];for(var _iterator=_create_for_of_iterator_helper_loose(firstChild.children[0].referenceSymbols),_step;!(_step=_iterator()).done;){var reference=_step.value;if(!reference.name)continue;sa.lookupSymbol.set(reference.name,ESymbolType.STRUCT);var symbols=sa.symbolTableStack.lookupAll(sa.lookupSymbol,true,sa.structScratch,reference.branch);for(var _iterator1=_create_for_of_iterator_helper_loose(symbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;var declaration=symbol.astNode;if(!dependencies.includes(declaration))dependencies.push(declaration)}}if(dependencies.length)this.structDependencies=dependencies}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitTypeSpecifier(this))};_create_class(TypeSpecifier,[{key:\"arraySpecifier\",get:function get(){return this.children[1]}}]);return TypeSpecifier}(TreeNode);ASTNodes.TypeSpecifier=TypeSpecifier;TypeSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.type_specifier)],TypeSpecifier);var ArraySpecifier=function(TreeNode){_inherits(ArraySpecifier,TreeNode);function ArraySpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=ArraySpecifier.prototype;_proto.init=function init(){this.size=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var integerConstantExpr=this.children[1];if(!_instanceof(integerConstantExpr,IntegerConstantExpression))return;this.size=integerConstantExpr.value;var exprChildren=integerConstantExpr.children;if(this.size===undefined&&exprChildren.length===1&&_instanceof(exprChildren[0],VariableIdentifier)){var bare=exprChildren[0].children[0];if(_instanceof(bare,BaseToken)&&!sa.macroDefineList[bare.lexeme]){var lookup=sa.lookupSymbol;lookup.set(bare.lexeme,ESymbolType.VAR);var symbols=sa.symbolTableStack.lookupAll(lookup,true,sa.arraySymbolScratch,this._branch);if(!symbols.length)return;var firstIsConst=symbols[0].isConst;var divergent=symbols.some(function(symbol){return symbol.isConst!==firstIsConst});if(divergent){sa.reportBranchAmbiguity(exprChildren[0].location,bare.lexeme,\"const-qualification\",bare.lexeme)}else if(!firstIsConst){sa.reportNonConstArraySize(exprChildren[0].location)}}}};return ArraySpecifier}(TreeNode);ASTNodes.ArraySpecifier=ArraySpecifier;ArraySpecifier=__decorate([ASTNodeDecorator(NoneTerminal.array_specifier)],ArraySpecifier);var IntegerConstantExpressionOperator=function(TreeNode){_inherits(IntegerConstantExpressionOperator,TreeNode);function IntegerConstantExpressionOperator(){return TreeNode.apply(this,arguments)||this}var _proto=IntegerConstantExpressionOperator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var operator=this.children[0];this.lexeme=operator.lexeme;switch(operator.type){case ETokenType.PLUS:this.compute=function(a,b){return a+b};break;case ETokenType.DASH:this.compute=function(a,b){return a-b};break;case ETokenType.STAR:this.compute=function(a,b){return a*b};break;case ETokenType.SLASH:this.compute=function(a,b){return a/b};break;case ETokenType.PERCENT:this.compute=function(a,b){return a%b};break}};return IntegerConstantExpressionOperator}(TreeNode);ASTNodes.IntegerConstantExpressionOperator=IntegerConstantExpressionOperator;IntegerConstantExpressionOperator=__decorate([ASTNodeDecorator(NoneTerminal.integer_constant_expression_operator)],IntegerConstantExpressionOperator);var IntegerConstantExpression=function(TreeNode){_inherits(IntegerConstantExpression,TreeNode);function IntegerConstantExpression(){return TreeNode.apply(this,arguments)||this}var _proto=IntegerConstantExpression.prototype;_proto.init=function init(){this.value=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var child=this.children[0];if(_instanceof(child,BaseToken)){this.value=Number(child.lexeme)}}};return IntegerConstantExpression}(TreeNode);ASTNodes.IntegerConstantExpression=IntegerConstantExpression;IntegerConstantExpression=__decorate([ASTNodeDecorator(NoneTerminal.integer_constant_expression)],IntegerConstantExpression);var TypeSpecifierNonArray=function(TreeNode){_inherits(TypeSpecifierNonArray,TreeNode);function TypeSpecifierNonArray(){return TreeNode.apply(this,arguments)||this}var _proto=TypeSpecifierNonArray.prototype;_proto.init=function init(){var tt=this.children[0];if(_instanceof(tt,BaseToken)){this.type=tt.lexeme;this.lexeme=tt.lexeme}else if(_instanceof(tt,MacroCallSymbol)){this.type=TypeAny;this.lexeme=tt.macroName}else{this.type=tt.type;this.lexeme=tt.lexeme}};return TypeSpecifierNonArray}(TreeNode);ASTNodes.TypeSpecifierNonArray=TypeSpecifierNonArray;TypeSpecifierNonArray=__decorate([ASTNodeDecorator(NoneTerminal.type_specifier_nonarray)],TypeSpecifierNonArray);var ExtBuiltinTypeSpecifierNonArray=function(TreeNode){_inherits(ExtBuiltinTypeSpecifierNonArray,TreeNode);function ExtBuiltinTypeSpecifierNonArray(){return TreeNode.apply(this,arguments)||this}var _proto=ExtBuiltinTypeSpecifierNonArray.prototype;_proto.init=function init(){var token=this.children[0];this.type=token.type;this.lexeme=token.lexeme};return ExtBuiltinTypeSpecifierNonArray}(TreeNode);ASTNodes.ExtBuiltinTypeSpecifierNonArray=ExtBuiltinTypeSpecifierNonArray;ExtBuiltinTypeSpecifierNonArray=__decorate([ASTNodeDecorator(NoneTerminal.ext_builtin_type_specifier_nonarray)],ExtBuiltinTypeSpecifierNonArray);var InitDeclaratorList=function(TreeNode){_inherits(InitDeclaratorList,TreeNode);function InitDeclaratorList(){return TreeNode.apply(this,arguments)||this}var _proto=InitDeclaratorList.prototype;_proto.init=function init(){this.isConst=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var sm;var children=this.children;var childrenLength=children.length;if(childrenLength===1){var _children_=children[0],typeSpecifier=_children_.typeSpecifier,arraySpecifier=_children_.arraySpecifier,isConst=_children_.isConst;this.typeInfo=new SymbolType(typeSpecifier.type,typeSpecifier.lexeme,arraySpecifier,typeSpecifier.structDeclarations);this.isConst=isConst}else{var initDeclList=children[0];this.typeInfo=initDeclList.typeInfo;this.isConst=initDeclList.isConst}if(childrenLength===3||childrenLength===5){var id=children[2];var initializer=childrenLength===5?children[4]:undefined;var typeInfo=new SymbolType(this.typeInfo.type,this.typeInfo.typeLexeme,undefined,this.typeInfo.structDeclarations);sm=sa.assignSourceScope(new VarSymbol(id.lexeme,typeInfo,false,this,this.isConst),id.location);this.declarator={identifier:id,typeInfo:typeInfo,initializer:initializer,isConst:this.isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult=sa.symbolTableStack.insert(sm,id.branch);sa.reportRedefinition(id.location,sm,insertResult)}else if(childrenLength===4||childrenLength===6){var typeInfo1=new SymbolType(this.typeInfo.type,this.typeInfo.typeLexeme,undefined,this.typeInfo.structDeclarations);var arraySpecifier1=this.children[3];typeInfo1.arraySpecifier=arraySpecifier1;var id1=children[2];var initializer1=childrenLength===6?children[5]:undefined;sm=sa.assignSourceScope(new VarSymbol(id1.lexeme,typeInfo1,false,this,this.isConst),id1.location);this.declarator={identifier:id1,typeInfo:typeInfo1,initializer:initializer1,isConst:this.isConst,isGlobal:false,symbol:sm};sa.recordFunctionVariable(sm);var insertResult1=sa.symbolTableStack.insert(sm,id1.branch);sa.reportRedefinition(id1.location,sm,insertResult1)}};return InitDeclaratorList}(TreeNode);ASTNodes.InitDeclaratorList=InitDeclaratorList;InitDeclaratorList=__decorate([ASTNodeDecorator(NoneTerminal.init_declarator_list)],InitDeclaratorList);var IdentifierList=function(TreeNode){_inherits(IdentifierList,TreeNode);function IdentifierList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.idList=[];return _this}var _proto=IdentifierList.prototype;_proto.init=function init(){this.idList.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,curIdList=_this.idList;if(children.length===2){curIdList.push(children[1])}else{var list=children[0];var id=children[2];var listIdLength=list.idList.length;curIdList.length=listIdLength+1;for(var i=0;i<listIdLength;i++){curIdList[i]=list.idList[i]}curIdList[listIdLength]=id}};return IdentifierList}(TreeNode);ASTNodes.IdentifierList=IdentifierList;IdentifierList=__decorate([ASTNodeDecorator(NoneTerminal.identifier_list)],IdentifierList);var Declaration=function(TreeNode){_inherits(Declaration,TreeNode);function Declaration(){return TreeNode.apply(this,arguments)||this}var _proto=Declaration.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(_instanceof(this.children[0],FunctionProtoType)){sa.popScope();sa.endFunction()}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitDeclaration(this))};return Declaration}(TreeNode);ASTNodes.Declaration=Declaration;Declaration=__decorate([ASTNodeDecorator(NoneTerminal.declaration)],Declaration);var FunctionProtoType=function(TreeNode){_inherits(FunctionProtoType,TreeNode);function FunctionProtoType(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionProtoType.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var declarator=this.children[0];this.ident=declarator.ident;this.returnType=declarator.returnType;this.parameterList=declarator.parameterInfoList;this.paramSig=declarator.paramSig};return FunctionProtoType}(TreeNode);ASTNodes.FunctionProtoType=FunctionProtoType;FunctionProtoType=__decorate([ASTNodeDecorator(NoneTerminal.function_prototype)],FunctionProtoType);var FunctionDeclarator=function(TreeNode){_inherits(FunctionDeclarator,TreeNode);function FunctionDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionDeclarator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var header=children[0];var parameterList=children[1];this.ident=header.ident;this.returnType=header.returnType;this.parameterInfoList=parameterList==null?void 0:parameterList.parameterInfoList;this.paramSig=parameterList==null?void 0:parameterList.paramSig;sa.beginFunction(this)};return FunctionDeclarator}(TreeNode);ASTNodes.FunctionDeclarator=FunctionDeclarator;FunctionDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.function_declarator)],FunctionDeclarator);var FunctionHeader=function(TreeNode){_inherits(FunctionHeader,TreeNode);function FunctionHeader(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionHeader.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.pushScope();var children=this.children;this.ident=children[1];this.returnType=children[0]};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionHeader(this))};return FunctionHeader}(TreeNode);ASTNodes.FunctionHeader=FunctionHeader;FunctionHeader=__decorate([ASTNodeDecorator(NoneTerminal.function_header)],FunctionHeader);var FunctionParameterList=function(TreeNode){_inherits(FunctionParameterList,TreeNode);function FunctionParameterList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.parameterInfoList=[],_this.paramSig=[];return _this}var _proto=FunctionParameterList.prototype;_proto.init=function init(){this.parameterInfoList.length=0;this.paramSig.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var _this=this,parameterInfoList=_this.parameterInfoList,paramSig=_this.paramSig;if(_instanceof(children[0],ParameterDeclaration)){var _decl_typeInfo;var decl=children[0];parameterInfoList.push({ident:decl.ident,typeInfo:decl.typeInfo,astNode:decl});var _decl_typeInfo_type;paramSig.push((_decl_typeInfo_type=(_decl_typeInfo=decl.typeInfo)==null?void 0:_decl_typeInfo.type)!=null?_decl_typeInfo_type:TypeAny)}else if(_instanceof(children[2],ParameterDeclaration)){var _parameterInfoList,_paramSig;var _decl_typeInfo1;var list=children[0];var decl1=children[2];(_parameterInfoList=parameterInfoList).push.apply(_parameterInfoList,[].concat(list.parameterInfoList,[{ident:decl1.ident,typeInfo:decl1.typeInfo,astNode:decl1}]));var _decl_typeInfo_type1;(_paramSig=paramSig).push.apply(_paramSig,[].concat(list.paramSig,[(_decl_typeInfo_type1=(_decl_typeInfo1=decl1.typeInfo)==null?void 0:_decl_typeInfo1.type)!=null?_decl_typeInfo_type1:TypeAny]))}else if(_instanceof(children[0],FunctionParameterList)&&_instanceof(children[1],MacroParamBlock)){var _parameterInfoList1,_paramSig1;(_parameterInfoList1=parameterInfoList).push.apply(_parameterInfoList1,[].concat(children[0].parameterInfoList,[{astNode:children[1]}]));(_paramSig1=paramSig).push.apply(_paramSig1,[].concat(children[0].paramSig,[TypeAny]))}else if(_instanceof(children[0],MacroParamBlock)){parameterInfoList.push({astNode:children[0]});paramSig.push(TypeAny)}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionParameterList(this))};return FunctionParameterList}(TreeNode);ASTNodes.FunctionParameterList=FunctionParameterList;FunctionParameterList=__decorate([ASTNodeDecorator(NoneTerminal.function_parameter_list)],FunctionParameterList);var MacroParamCaseList=function(TreeNode){_inherits(MacroParamCaseList,TreeNode);function MacroParamCaseList(){return TreeNode.apply(this,arguments)||this}return MacroParamCaseList}(TreeNode);ASTNodes.MacroParamCaseList=MacroParamCaseList;MacroParamCaseList=__decorate([ASTNodeDecorator(NoneTerminal.macro_param_case_list)],MacroParamCaseList);var MacroParamBlock=function(TreeNode){_inherits(MacroParamBlock,TreeNode);function MacroParamBlock(){return TreeNode.apply(this,arguments)||this}return MacroParamBlock}(TreeNode);ASTNodes.MacroParamBlock=MacroParamBlock;MacroParamBlock=__decorate([ASTNodeDecorator(NoneTerminal.macro_param_block)],MacroParamBlock);var MacroParameterBranch=function(TreeNode){_inherits(MacroParameterBranch,TreeNode);function MacroParameterBranch(){return TreeNode.apply(this,arguments)||this}return MacroParameterBranch}(TreeNode);ASTNodes.MacroParameterBranch=MacroParameterBranch;MacroParameterBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_parameter_branch)],MacroParameterBranch);var ParameterDeclaration=function(TreeNode){_inherits(ParameterDeclaration,TreeNode);function ParameterDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=ParameterDeclaration.prototype;_proto.init=function init(){this.typeInfo=undefined;this.ident=undefined;this.symbol=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var parameterDeclarator;if(_instanceof(children[0],ParameterDeclarator)){parameterDeclarator=children[0]}else if(_instanceof(children[1],ParameterDeclarator)){parameterDeclarator=children[1]}if(parameterDeclarator){this.typeInfo=parameterDeclarator.typeInfo;this.ident=parameterDeclarator.ident;var varSymbol=new VarSymbol(parameterDeclarator.ident.lexeme,parameterDeclarator.typeInfo,false,parameterDeclarator);this.symbol=varSymbol;sa.symbolTableStack.insert(varSymbol,parameterDeclarator.ident.branch)}};return ParameterDeclaration}(TreeNode);ASTNodes.ParameterDeclaration=ParameterDeclaration;ParameterDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.parameter_declaration)],ParameterDeclaration);var ParameterDeclarator=function(TreeNode){_inherits(ParameterDeclarator,TreeNode);function ParameterDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=ParameterDeclarator.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.ident=children[1];var typeSpecifier=children[0];var arraySpecifier=children[2];this.typeInfo=new SymbolType(typeSpecifier.type,typeSpecifier.lexeme,arraySpecifier,typeSpecifier.structDeclarations)};return ParameterDeclarator}(TreeNode);ASTNodes.ParameterDeclarator=ParameterDeclarator;ParameterDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.parameter_declarator)],ParameterDeclarator);var SimpleStatement=function(TreeNode){_inherits(SimpleStatement,TreeNode);function SimpleStatement(){return TreeNode.apply(this,arguments)||this}return SimpleStatement}(TreeNode);ASTNodes.SimpleStatement=SimpleStatement;SimpleStatement=__decorate([ASTNodeDecorator(NoneTerminal.simple_statement)],SimpleStatement);var CompoundStatement=function(TreeNode){_inherits(CompoundStatement,TreeNode);function CompoundStatement(){return TreeNode.apply(this,arguments)||this}return CompoundStatement}(TreeNode);ASTNodes.CompoundStatement=CompoundStatement;CompoundStatement=__decorate([ASTNodeDecorator(NoneTerminal.compound_statement)],CompoundStatement);var CompoundStatementNoScope=function(TreeNode){_inherits(CompoundStatementNoScope,TreeNode);function CompoundStatementNoScope(){return TreeNode.apply(this,arguments)||this}return CompoundStatementNoScope}(TreeNode);ASTNodes.CompoundStatementNoScope=CompoundStatementNoScope;CompoundStatementNoScope=__decorate([ASTNodeDecorator(NoneTerminal.compound_statement_no_scope)],CompoundStatementNoScope);var Statement=function(TreeNode){_inherits(Statement,TreeNode);function Statement(){return TreeNode.apply(this,arguments)||this}return Statement}(TreeNode);ASTNodes.Statement=Statement;Statement=__decorate([ASTNodeDecorator(NoneTerminal.statement)],Statement);var StatementList=function(TreeNode){_inherits(StatementList,TreeNode);function StatementList(){return TreeNode.apply(this,arguments)||this}var _proto=StatementList.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitStatementList(this))};return StatementList}(TreeNode);ASTNodes.StatementList=StatementList;StatementList=__decorate([ASTNodeDecorator(NoneTerminal.statement_list)],StatementList);var FunctionDefinition=function(TreeNode){_inherits(FunctionDefinition,TreeNode);function FunctionDefinition(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionDefinition.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.protoType=children[0];this.statements=children[1];sa.popScope();var capture=sa.endFunction();var sm=sa.assignSourceScope(new FnSymbol(this.protoType.ident.lexeme,this,capture.localVariables,capture.calledFunctions),this.protoType.ident.location);var existing=this.protoType.ident.branch.length===0?sa.symbolTableStack.lookup(sm):undefined;var unconditionalDuplicate=existing&&existing.sourceScope===sm.sourceScope;var conflict=unconditionalDuplicate?\"coexist\":sa.symbolTableStack.insert(sm,this.protoType.ident.branch);sa.reportRedefinition(this.protoType.ident.location,sm,conflict);this.isInMacroBranch=sa.symbolTableStack.isInMacroBranch};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionDefinition(this))};return FunctionDefinition}(TreeNode);ASTNodes.FunctionDefinition=FunctionDefinition;FunctionDefinition=__decorate([ASTNodeDecorator(NoneTerminal.function_definition)],FunctionDefinition);var FunctionCall=function(ExpressionAstNode){_inherits(FunctionCall,ExpressionAstNode);function FunctionCall(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=FunctionCall.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.type=this.children[0].type};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionCall(this))};return FunctionCall}(ExpressionAstNode);ASTNodes.FunctionCall=FunctionCall;FunctionCall=__decorate([ASTNodeDecorator(NoneTerminal.function_call)],FunctionCall);var FunctionCallGeneric=function(ExpressionAstNode){_inherits(FunctionCallGeneric,ExpressionAstNode);function FunctionCallGeneric(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=FunctionCallGeneric.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);this.fnSymbol=undefined;this.fnSymbols=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var functionIdentifier=this.children[0];if(functionIdentifier.isBuiltin){this.type=functionIdentifier.ident}else{var _fnSymbol_dataType;var fnIdent=functionIdentifier.ident;var paramSig;if(this.children.length===4){var paramList=this.children[2];if(_instanceof(paramList,FunctionCallParameterList)){paramSig=paramList.paramSig}}if(sa.diagnosticsEnabled){var _header_ident,_fnSymbol_dataType1;var header=sa.currentFunctionHeader;if((header==null?void 0:(_header_ident=header.ident)==null?void 0:_header_ident.lexeme)===fnIdent){var _header_paramSig;var hSig=(_header_paramSig=header.paramSig)!=null?_header_paramSig:[];var cSig=paramSig!=null?paramSig:[];if(hSig.length===cSig.length&&hSig.every(function(t,i){return t===cSig[i]})){return}}if(TEXTURE_SAMPLING_BUILTINS.has(fnIdent)){var arg0=paramSig==null?void 0:paramSig[0];if(arg0!==undefined&&arg0!==TypeAny&&!TypeSystem.isSamplerType(arg0)){sa.reportExpectedSampler(this.location,fnIdent,arg0);return}}var builtinFn=BuiltinFunction.resolveOverload(fnIdent,paramSig);if(builtinFn){this.type=builtinFn.realReturnType;return}var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(fnIdent,ESymbolType.FN,undefined,undefined,paramSig);var allMatches=sa.overloadScratch;sa.symbolTableStack.lookupAll(lookupSymbol,true,allMatches,this._branch);var branchCoverage=sa.getBranchCoverage(allMatches.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),this._branch);var branchCovered=branchCoverage===\"covered\"||FunctionCallGeneric._hasConflictingBranches(sa,allMatches);var fnSymbol=branchCovered?allMatches[0]:undefined;var overloadTypeAmbiguous=false;if(fnSymbol&&(paramSig==null?void 0:paramSig.some(function(t){return t===TypeAny}))){if(allMatches.length>1){var _allMatches__dataType;var firstType=(_allMatches__dataType=allMatches[0].dataType)==null?void 0:_allMatches__dataType.type;overloadTypeAmbiguous=allMatches.some(function(s){var _s_dataType;return((_s_dataType=s.dataType)==null?void 0:_s_dataType.type)!==firstType})}}if(!fnSymbol){var codegenFn=sa.symbolTableStack.lookup(lookupSymbol,true);if(codegenFn){this.fnSymbol=codegenFn;sa.recordFunctionCall(codegenFn)}if(allMatches.length){sa.reportBranchAvailability(this.location,\"Function\",fnIdent,branchCoverage);return}lookupSymbol.set(fnIdent,ESymbolType.FN);var nameDeclared=sa.symbolTableStack.lookupAll(lookupSymbol,true,allMatches,this._branch).length>0||BuiltinFunction.isExist(fnIdent);if(nameDeclared){sa.reportNoMatchingOverload(this.location,fnIdent)}return}this.type=overloadTypeAmbiguous?TypeAny:fnSymbol==null?void 0:(_fnSymbol_dataType1=fnSymbol.dataType)==null?void 0:_fnSymbol_dataType1.type;this.fnSymbol=fnSymbol;if(allMatches.length>1){var first=allMatches[0];this.fnSymbols=allMatches.every(function(candidate){return FunctionCallGeneric._hasSameParameterSignature(first,candidate)})?allMatches.slice():EMPTY_FN_SYMBOLS}if(this.fnSymbols!==undefined){for(var _iterator=_create_for_of_iterator_helper_loose(this.fnSymbols),_step;!(_step=_iterator()).done;){var candidate=_step.value;sa.recordFunctionCall(candidate)}}else if(_instanceof(fnSymbol,FnSymbol)){sa.recordFunctionCall(fnSymbol)}return}var lookupSymbol1=sa.lookupSymbol;lookupSymbol1.set(fnIdent,ESymbolType.FN,undefined,undefined,paramSig);var fnSymbol1=sa.symbolTableStack.lookup(lookupSymbol1,true);if(!fnSymbol1)return;this.type=(_fnSymbol_dataType=fnSymbol1.dataType)==null?void 0:_fnSymbol_dataType.type;this.fnSymbol=fnSymbol1;if(_instanceof(fnSymbol1,FnSymbol))sa.recordFunctionCall(fnSymbol1)}};FunctionCallGeneric._hasConflictingBranches=function _hasConflictingBranches(sa,symbols){for(var i=0,n=symbols.length;i<n;i++){for(var j=i+1;j<n;j++){var left=symbols[i];var right=symbols[j];var _left_branchSignature,_right_branchSignature;if(FunctionCallGeneric._hasSameParameterSignature(left,right)&&sa.canDeclarationsCoexist((_left_branchSignature=left.branchSignature)!=null?_left_branchSignature:EMPTY_BRANCH,(_right_branchSignature=right.branchSignature)!=null?_right_branchSignature:EMPTY_BRANCH)){return true}}}return false};FunctionCallGeneric._hasSameParameterSignature=function _hasSameParameterSignature(left,right){var _left_astNode_protoType_paramSig;var leftSignature=(_left_astNode_protoType_paramSig=left.astNode.protoType.paramSig)!=null?_left_astNode_protoType_paramSig:[];var _right_astNode_protoType_paramSig;var rightSignature=(_right_astNode_protoType_paramSig=right.astNode.protoType.paramSig)!=null?_right_astNode_protoType_paramSig:[];return leftSignature.length===rightSignature.length&&leftSignature.every(function(type,index){return type===rightSignature[index]})};return FunctionCallGeneric}(ExpressionAstNode);ASTNodes.FunctionCallGeneric=FunctionCallGeneric;FunctionCallGeneric=__decorate([ASTNodeDecorator(NoneTerminal.function_call_generic)],FunctionCallGeneric);var FunctionCallParameterList=function(TreeNode){_inherits(FunctionCallParameterList,TreeNode);function FunctionCallParameterList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.paramSig=[],_this.paramNodes=[];return _this}var _proto=FunctionCallParameterList.prototype;_proto.init=function init(){this.paramSig.length=0;this.paramNodes.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,paramSig=_this.paramSig,paramNodes=_this.paramNodes;if(_instanceof(children[0],AssignmentExpression)){var expr=children[0];paramSig.push(expr.type);paramNodes.push(expr)}else if(_instanceof(children[2],AssignmentExpression)){var _paramSig,_paramNodes;var list=children[0];var decl=children[2];(_paramSig=paramSig).push.apply(_paramSig,[].concat(list.paramSig,[decl.type]));(_paramNodes=paramNodes).push.apply(_paramNodes,[].concat(list.paramNodes,[decl]))}else if(_instanceof(children[0],FunctionCallParameterList)&&_instanceof(children[1],MacroCallArgBlock)){var _paramSig1,_paramNodes1;(_paramSig1=paramSig).push.apply(_paramSig1,[].concat(children[0].paramSig,[TypeAny]));(_paramNodes1=paramNodes).push.apply(_paramNodes1,[].concat(children[0].paramNodes,[children[1]]))}else if(_instanceof(children[0],MacroCallArgBlock)){paramSig.push(TypeAny);paramNodes.push(children[0])}};return FunctionCallParameterList}(TreeNode);ASTNodes.FunctionCallParameterList=FunctionCallParameterList;FunctionCallParameterList=__decorate([ASTNodeDecorator(NoneTerminal.function_call_parameter_list)],FunctionCallParameterList);var MacroCallArgCaseList=function(TreeNode){_inherits(MacroCallArgCaseList,TreeNode);function MacroCallArgCaseList(){return TreeNode.apply(this,arguments)||this}return MacroCallArgCaseList}(TreeNode);ASTNodes.MacroCallArgCaseList=MacroCallArgCaseList;MacroCallArgCaseList=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_case_list)],MacroCallArgCaseList);var MacroCallArgBlock=function(TreeNode){_inherits(MacroCallArgBlock,TreeNode);function MacroCallArgBlock(){return TreeNode.apply(this,arguments)||this}return MacroCallArgBlock}(TreeNode);ASTNodes.MacroCallArgBlock=MacroCallArgBlock;MacroCallArgBlock=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_block)],MacroCallArgBlock);var MacroCallArgBranch=function(TreeNode){_inherits(MacroCallArgBranch,TreeNode);function MacroCallArgBranch(){return TreeNode.apply(this,arguments)||this}return MacroCallArgBranch}(TreeNode);ASTNodes.MacroCallArgBranch=MacroCallArgBranch;MacroCallArgBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_arg_branch)],MacroCallArgBranch);var PrecisionSpecifier=function(TreeNode){_inherits(PrecisionSpecifier,TreeNode);function PrecisionSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=PrecisionSpecifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(!sa.symbolTableStack.isInMacroBranch){sa.shaderData.globalPrecisions.push(this)}};return PrecisionSpecifier}(TreeNode);ASTNodes.PrecisionSpecifier=PrecisionSpecifier;PrecisionSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.precision_specifier)],PrecisionSpecifier);var FunctionIdentifier=function(TreeNode){_inherits(FunctionIdentifier,TreeNode);function FunctionIdentifier(){return TreeNode.apply(this,arguments)||this}var _proto=FunctionIdentifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var typeSpecifier=this.children[0];this.ident=typeSpecifier.type;this.lexeme=typeSpecifier.lexeme;this.isBuiltin=typeof this.ident!==\"string\"};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitFunctionIdentifier(this))};return FunctionIdentifier}(TreeNode);ASTNodes.FunctionIdentifier=FunctionIdentifier;FunctionIdentifier=__decorate([ASTNodeDecorator(NoneTerminal.function_identifier)],FunctionIdentifier);var AssignmentExpression=function(ExpressionAstNode){_inherits(AssignmentExpression,ExpressionAstNode);function AssignmentExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AssignmentExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var expr=this.children[0];var _expr_type;this.type=(_expr_type=expr.type)!=null?_expr_type:TypeAny}else{var rhs=this.children[2];var _rhs_type;this.type=(_rhs_type=rhs.type)!=null?_rhs_type:TypeAny}};return AssignmentExpression}(ExpressionAstNode);ASTNodes.AssignmentExpression=AssignmentExpression;AssignmentExpression=__decorate([ASTNodeDecorator(NoneTerminal.assignment_expression)],AssignmentExpression);var AssignmentOperator=function(TreeNode){_inherits(AssignmentOperator,TreeNode);function AssignmentOperator(){return TreeNode.apply(this,arguments)||this}return AssignmentOperator}(TreeNode);ASTNodes.AssignmentOperator=AssignmentOperator;AssignmentOperator=__decorate([ASTNodeDecorator(NoneTerminal.assignment_operator)],AssignmentOperator);var Expression=function(ExpressionAstNode){_inherits(Expression,ExpressionAstNode);function Expression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=Expression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var expr=this.children[0];this.type=expr.type}else{var expr1=this.children[2];this.type=expr1.type}};return Expression}(ExpressionAstNode);ASTNodes.Expression=Expression;Expression=__decorate([ASTNodeDecorator(NoneTerminal.expression)],Expression);var PrimaryExpression=function(ExpressionAstNode){_inherits(PrimaryExpression,ExpressionAstNode);function PrimaryExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=PrimaryExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){var id=this.children[0];if(_instanceof(id,VariableIdentifier)){var _id_typeInfo;this.type=(_id_typeInfo=id.typeInfo)!=null?_id_typeInfo:TypeAny}else{switch(id.type){case ETokenType.INT_CONSTANT:this._type=Keyword.INT;break;case ETokenType.FLOAT_CONSTANT:this.type=Keyword.FLOAT;break;case Keyword.True:case Keyword.False:this.type=Keyword.BOOL;break}}}else{var expression=this.children[1];this.type=expression.type}};return PrimaryExpression}(ExpressionAstNode);ASTNodes.PrimaryExpression=PrimaryExpression;PrimaryExpression=__decorate([ASTNodeDecorator(NoneTerminal.primary_expression)],PrimaryExpression);var PostfixExpression=function(ExpressionAstNode){_inherits(PostfixExpression,ExpressionAstNode);function PostfixExpression(){var _this;_this=ExpressionAstNode.apply(this,arguments)||this,_this.resolvedMemberOwners=EMPTY_STRUCT_DECLARATIONS;return _this}var _proto=PostfixExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);this.resolvedMemberOwners=EMPTY_STRUCT_DECLARATIONS;if(this.children.length===1){var child=this.children[0];this.type=child.type}};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;if(children.length===3&&_instanceof(children[2],BaseToken)){var base=children[0];if(!this._inMacroDefinition){var reference=ParserUtils.unwrapBareIdentifier(base,{allowParens:true});if(reference)sa.shaderData.directMemberOwnerReferences.push(reference)}if(typeof base.type===\"string\"){var _PostfixExpression__checkStructField;this.resolvedMemberOwners=(_PostfixExpression__checkStructField=PostfixExpression._checkStructField(sa,base.type,children[2],this._branch))!=null?_PostfixExpression__checkStructField:EMPTY_STRUCT_DECLARATIONS}}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitPostfixExpression(this))};PostfixExpression._checkStructField=function _checkStructField(sa,structName,field,callsiteBranch){var lookup=sa.lookupSymbol;lookup.set(structName,ESymbolType.STRUCT);var structs=sa.symbolTableStack.lookupAll(lookup,true,sa.structScratch,callsiteBranch);if(!structs.length)return;var coverage=sa.getBranchCoverage(structs.map(function(struct){var _struct_branchSignature;return(_struct_branchSignature=struct.branchSignature)!=null?_struct_branchSignature:EMPTY_BRANCH}),callsiteBranch);if(coverage!==\"covered\"){sa.reportBranchAvailability(field.location,\"Struct\",structName,coverage);return}var firstProp=structs[0].astNode.propList.find(function(prop){return prop.ident.lexeme===field.lexeme});var memberPresenceDivergent=false;var memberTypeDivergent=false;for(var i=1;i<structs.length;i++){var prop=structs[i].astNode.propList.find(function(item){return item.ident.lexeme===field.lexeme});if(!!prop!==!!firstProp){memberPresenceDivergent=true;break}if(prop&&firstProp){var firstArray=firstProp.typeInfo.arraySpecifier;var array=prop.typeInfo.arraySpecifier;if(prop.typeInfo.type!==firstProp.typeInfo.type||!!array!==!!firstArray||(array==null?void 0:array.size)!==(firstArray==null?void 0:firstArray.size)){memberTypeDivergent=true;break}}}if(memberPresenceDivergent){sa.reportBranchAmbiguity(field.location,structName+\".\"+field.lexeme,\"struct-member-presence\",field.lexeme,structName);return}if(memberTypeDivergent||firstProp)return structs.map(function(symbol){return symbol.astNode});sa.reportUndeclaredStructMember(field.location,structName,field.lexeme)};return PostfixExpression}(ExpressionAstNode);ASTNodes.PostfixExpression=PostfixExpression;PostfixExpression=__decorate([ASTNodeDecorator(NoneTerminal.postfix_expression)],PostfixExpression);var UnaryOperator=function(TreeNode){_inherits(UnaryOperator,TreeNode);function UnaryOperator(){return TreeNode.apply(this,arguments)||this}return UnaryOperator}(TreeNode);ASTNodes.UnaryOperator=UnaryOperator;UnaryOperator=__decorate([ASTNodeDecorator(NoneTerminal.unary_operator)],UnaryOperator);var UnaryExpression=function(ExpressionAstNode){_inherits(UnaryExpression,ExpressionAstNode);function UnaryExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=UnaryExpression.prototype;_proto.init=function init(){this.type=this.children[0].type};return UnaryExpression}(ExpressionAstNode);ASTNodes.UnaryExpression=UnaryExpression;UnaryExpression=__decorate([ASTNodeDecorator(NoneTerminal.unary_expression)],UnaryExpression);var MultiplicativeExpression=function(ExpressionAstNode){_inherits(MultiplicativeExpression,ExpressionAstNode);function MultiplicativeExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=MultiplicativeExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);if(this.children.length===1){this.type=this.children[0].type}else{this.type=TypeSystem.arithmeticResultType(this.children[0].type,this.children[2].type,this.children[1].lexeme)}};return MultiplicativeExpression}(ExpressionAstNode);ASTNodes.MultiplicativeExpression=MultiplicativeExpression;MultiplicativeExpression=__decorate([ASTNodeDecorator(NoneTerminal.multiplicative_expression)],MultiplicativeExpression);var AdditiveExpression=function(ExpressionAstNode){_inherits(AdditiveExpression,ExpressionAstNode);function AdditiveExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AdditiveExpression.prototype;_proto.init=function init(){ExpressionAstNode.prototype.init.call(this);if(this.children.length===1){this.type=this.children[0].type}else{this.type=TypeSystem.arithmeticResultType(this.children[0].type,this.children[2].type,this.children[1].lexeme)}};return AdditiveExpression}(ExpressionAstNode);ASTNodes.AdditiveExpression=AdditiveExpression;AdditiveExpression=__decorate([ASTNodeDecorator(NoneTerminal.additive_expression)],AdditiveExpression);var ShiftExpression=function(ExpressionAstNode){_inherits(ShiftExpression,ExpressionAstNode);function ShiftExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ShiftExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){var expr=this.children[0];this.type=expr.type};return ShiftExpression}(ExpressionAstNode);ASTNodes.ShiftExpression=ShiftExpression;ShiftExpression=__decorate([ASTNodeDecorator(NoneTerminal.shift_expression)],ShiftExpression);var RelationalExpression=function(ExpressionAstNode){_inherits(RelationalExpression,ExpressionAstNode);function RelationalExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=RelationalExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return RelationalExpression}(ExpressionAstNode);ASTNodes.RelationalExpression=RelationalExpression;RelationalExpression=__decorate([ASTNodeDecorator(NoneTerminal.relational_expression)],RelationalExpression);var EqualityExpression=function(ExpressionAstNode){_inherits(EqualityExpression,ExpressionAstNode);function EqualityExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=EqualityExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return EqualityExpression}(ExpressionAstNode);ASTNodes.EqualityExpression=EqualityExpression;EqualityExpression=__decorate([ASTNodeDecorator(NoneTerminal.equality_expression)],EqualityExpression);var AndExpression=function(ExpressionAstNode){_inherits(AndExpression,ExpressionAstNode);function AndExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=AndExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return AndExpression}(ExpressionAstNode);ASTNodes.AndExpression=AndExpression;AndExpression=__decorate([ASTNodeDecorator(NoneTerminal.and_expression)],AndExpression);var ExclusiveOrExpression=function(ExpressionAstNode){_inherits(ExclusiveOrExpression,ExpressionAstNode);function ExclusiveOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ExclusiveOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return ExclusiveOrExpression}(ExpressionAstNode);ASTNodes.ExclusiveOrExpression=ExclusiveOrExpression;ExclusiveOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.exclusive_or_expression)],ExclusiveOrExpression);var InclusiveOrExpression=function(ExpressionAstNode){_inherits(InclusiveOrExpression,ExpressionAstNode);function InclusiveOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=InclusiveOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.UINT}};return InclusiveOrExpression}(ExpressionAstNode);ASTNodes.InclusiveOrExpression=InclusiveOrExpression;InclusiveOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.inclusive_or_expression)],InclusiveOrExpression);var LogicalAndExpression=function(ExpressionAstNode){_inherits(LogicalAndExpression,ExpressionAstNode);function LogicalAndExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalAndExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalAndExpression}(ExpressionAstNode);ASTNodes.LogicalAndExpression=LogicalAndExpression;LogicalAndExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_and_expression)],LogicalAndExpression);var LogicalXorExpression=function(ExpressionAstNode){_inherits(LogicalXorExpression,ExpressionAstNode);function LogicalXorExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalXorExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalXorExpression}(ExpressionAstNode);ASTNodes.LogicalXorExpression=LogicalXorExpression;LogicalXorExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_xor_expression)],LogicalXorExpression);var LogicalOrExpression=function(ExpressionAstNode){_inherits(LogicalOrExpression,ExpressionAstNode);function LogicalOrExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=LogicalOrExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}else{this.type=Keyword.BOOL}};return LogicalOrExpression}(ExpressionAstNode);ASTNodes.LogicalOrExpression=LogicalOrExpression;LogicalOrExpression=__decorate([ASTNodeDecorator(NoneTerminal.logical_or_expression)],LogicalOrExpression);var ConditionalExpression=function(ExpressionAstNode){_inherits(ConditionalExpression,ExpressionAstNode);function ConditionalExpression(){return ExpressionAstNode.apply(this,arguments)||this}var _proto=ConditionalExpression.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){if(this.children.length===1){this.type=this.children[0].type}};return ConditionalExpression}(ExpressionAstNode);ASTNodes.ConditionalExpression=ConditionalExpression;ConditionalExpression=__decorate([ASTNodeDecorator(NoneTerminal.conditional_expression)],ConditionalExpression);var StructSpecifier=function(TreeNode){_inherits(StructSpecifier,TreeNode);function StructSpecifier(){return TreeNode.apply(this,arguments)||this}var _proto=StructSpecifier.prototype;_proto.init=function init(){this.ident=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.isInMacroBranch=sa.symbolTableStack.isInMacroBranch;if(children.length===6){this.ident=children[1];var symbol=sa.assignSourceScope(new StructSymbol(this.ident.lexeme,this),this.ident.location);var insertResult=sa.symbolTableStack.insert(symbol,this.ident.branch);sa.reportRedefinition(this.ident.location,symbol,insertResult);this.propList=children[3].propList;this.macroExpressions=children[3].macroExpressions}else{this.propList=children[2].propList;this.macroExpressions=children[2].macroExpressions}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitStructSpecifier(this))};return StructSpecifier}(TreeNode);ASTNodes.StructSpecifier=StructSpecifier;StructSpecifier=__decorate([ASTNodeDecorator(NoneTerminal.struct_specifier)],StructSpecifier);var StructDeclarationList=function(TreeNode){_inherits(StructDeclarationList,TreeNode);function StructDeclarationList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.propList=[],_this.macroExpressions=[];return _this}var _proto=StructDeclarationList.prototype;_proto.init=function init(){this.propList.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,propList=_this.propList,macroExpressions=_this.macroExpressions;if(children.length===1){var _propList,_macroExpressions;(_propList=propList).push.apply(_propList,[].concat(children[0].props));(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[0].macroExpressions))}else{var _propList1,_propList2,_macroExpressions1,_macroExpressions2;(_propList1=propList).push.apply(_propList1,[].concat(children[0].propList));(_propList2=propList).push.apply(_propList2,[].concat(children[1].props));(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[0].macroExpressions));(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};return StructDeclarationList}(TreeNode);ASTNodes.StructDeclarationList=StructDeclarationList;StructDeclarationList=__decorate([ASTNodeDecorator(NoneTerminal.struct_declaration_list)],StructDeclarationList);var StructDeclaration=function(TreeNode){_inherits(StructDeclaration,TreeNode);function StructDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=StructDeclaration.prototype;_proto.init=function init(){this._typeSpecifier=undefined;this._declaratorList=undefined;this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,props=_this.props,macroExpressions=_this.macroExpressions;if(children.length===1){var _macroExpressions;var macroStructDeclaration=children[0];var macroProps=macroStructDeclaration.props;for(var i=0,length=macroProps.length;i<length;i++){macroProps[i].isInMacroBranch=true;props.push(macroProps[i])}(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(macroStructDeclaration.macroExpressions));return}if(children.length===3){this._typeSpecifier=children[0];this._declaratorList=children[1]}else{this._typeSpecifier=children[1];this._declaratorList=children[2]}var firstChild=children[0];var _this__typeSpecifier=this._typeSpecifier,type=_this__typeSpecifier.type,lexeme=_this__typeSpecifier.lexeme;var isInMacroBranch=sa.symbolTableStack.isInMacroBranch;if(_instanceof(firstChild,LayoutQualifier)){var declarator=children[2];var typeInfo=new SymbolType(type,lexeme,undefined,this._typeSpecifier.structDeclarations);var prop=new StructProp(typeInfo,declarator.ident,firstChild.index,isInMacroBranch);props.push(prop)}else{var isFlat=children.length===4&&ParserUtils.hasQualifier(children[0],Keyword.FLAT);var declaratorList=this._declaratorList.declaratorList;var declaratorListLength=declaratorList.length;props.length=declaratorListLength;for(var i1=0;i1<declaratorListLength;i1++){var declarator1=declaratorList[i1];var typeInfo1=new SymbolType(type,lexeme,declarator1.arraySpecifier,this._typeSpecifier.structDeclarations);var prop1=new StructProp(typeInfo1,declarator1.ident,undefined,isInMacroBranch,isFlat);props[i1]=prop1}}};return StructDeclaration}(TreeNode);ASTNodes.StructDeclaration=StructDeclaration;StructDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.struct_declaration)],StructDeclaration);var MacroStructDeclaration=function(TreeNode){_inherits(MacroStructDeclaration,TreeNode);function MacroStructDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=MacroStructDeclaration.prototype;_proto.init=function init(){this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(){var children=this.children;this.macroExpressions.push(children[0]);if(children.length===3){var _this_props,_this_props1,_this_macroExpressions,_this_macroExpressions1;(_this_props=this.props).push.apply(_this_props,[].concat(children[1].propList));(_this_props1=this.props).push.apply(_this_props1,[].concat(children[2].props));(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(children[1].macroExpressions));(_this_macroExpressions1=this.macroExpressions).push.apply(_this_macroExpressions1,[].concat(children[2].macroExpressions))}else{var _this_props2,_this_macroExpressions2;(_this_props2=this.props).push.apply(_this_props2,[].concat(children[1].props));(_this_macroExpressions2=this.macroExpressions).push.apply(_this_macroExpressions2,[].concat(children[1].macroExpressions))}};return MacroStructDeclaration}(TreeNode);ASTNodes.MacroStructDeclaration=MacroStructDeclaration;MacroStructDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.macro_struct_declaration)],MacroStructDeclaration);var MacroStructBranch=function(TreeNode){_inherits(MacroStructBranch,TreeNode);function MacroStructBranch(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.props=[],_this.macroExpressions=[];return _this}var _proto=MacroStructBranch.prototype;_proto.init=function init(){this.props.length=0;this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(){var children=this.children;var lastNode=children[children.length-1];this.macroExpressions.push(children[0]);if(_instanceof(children[1],StructDeclarationList)){var _this_props,_this_macroExpressions;(_this_props=this.props).push.apply(_this_props,[].concat(children[1].propList));(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(children[1].macroExpressions))}if(_instanceof(lastNode,MacroStructBranch)){var _this_props1,_this_macroExpressions1;(_this_props1=this.props).push.apply(_this_props1,[].concat(lastNode.props));(_this_macroExpressions1=this.macroExpressions).push.apply(_this_macroExpressions1,[].concat(lastNode.macroExpressions))}if(children.length>1&&_instanceof(lastNode,MacroPopContext)){this.macroExpressions.push(lastNode)}};return MacroStructBranch}(TreeNode);ASTNodes.MacroStructBranch=MacroStructBranch;MacroStructBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_struct_branch)],MacroStructBranch);var LayoutQualifier=function(TreeNode){_inherits(LayoutQualifier,TreeNode);function LayoutQualifier(){return TreeNode.apply(this,arguments)||this}var _proto=LayoutQualifier.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.index=Number(this.children[4].lexeme)};return LayoutQualifier}(TreeNode);ASTNodes.LayoutQualifier=LayoutQualifier;LayoutQualifier=__decorate([ASTNodeDecorator(NoneTerminal.layout_qualifier)],LayoutQualifier);var StructDeclaratorList=function(TreeNode){_inherits(StructDeclaratorList,TreeNode);function StructDeclaratorList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.declaratorList=[];return _this}var _proto=StructDeclaratorList.prototype;_proto.init=function init(){this.declaratorList.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this,children=_this.children,declaratorList=_this.declaratorList;if(children.length===1){declaratorList.push(children[0])}else{var list=children[0];var declarator=children[1];var listLength=list.declaratorList.length;declaratorList.length=listLength+1;for(var i=0;i<listLength;i++){declaratorList[i]=list.declaratorList[i]}declaratorList[listLength]=declarator}};return StructDeclaratorList}(TreeNode);ASTNodes.StructDeclaratorList=StructDeclaratorList;StructDeclaratorList=__decorate([ASTNodeDecorator(NoneTerminal.struct_declarator_list)],StructDeclaratorList);var StructDeclarator=function(TreeNode){_inherits(StructDeclarator,TreeNode);function StructDeclarator(){return TreeNode.apply(this,arguments)||this}var _proto=StructDeclarator.prototype;_proto.init=function init(){this.arraySpecifier=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;this.ident=children[0];this.arraySpecifier=children[1]};return StructDeclarator}(TreeNode);ASTNodes.StructDeclarator=StructDeclarator;StructDeclarator=__decorate([ASTNodeDecorator(NoneTerminal.struct_declarator)],StructDeclarator);var VariableDeclaration=function(TreeNode){_inherits(VariableDeclaration,TreeNode);function VariableDeclaration(){return TreeNode.apply(this,arguments)||this}var _proto=VariableDeclaration.prototype;_proto.init=function init(){this.isStatic=false;this.declarator=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var type=children[0];var ident=children[1];this.type=type;var hasInitializer=children.length===4;var arraySpecifier=children.length===3?children[2]:undefined;var initializer=hasInitializer?children[3]:undefined;var typeInfo=new SymbolType(type.type,type.typeSpecifier.lexeme,arraySpecifier,type.typeSpecifier.structDeclarations);var sm=sa.assignSourceScope(new VarSymbol(ident.lexeme,typeInfo,true,this,type.isConst,!hasInitializer&&!type.isConst),ident.location);this.declarator={identifier:ident,typeInfo:typeInfo,initializer:initializer,isConst:type.isConst,isGlobal:true,symbol:sm};var insertResult=sa.symbolTableStack.insert(sm,ident.branch);sa.reportRedefinition(ident.location,sm,insertResult);if(children.length===4){this.isStatic=true}};_proto.codeGen=function codeGen(visitor){if(this.isStatic){return TreeNode.prototype.codeGen.call(this,visitor)}else{return visitor.cache(this,visitor.visitGlobalVariableDeclaration(this))}};return VariableDeclaration}(TreeNode);ASTNodes.VariableDeclaration=VariableDeclaration;VariableDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.variable_declaration)],VariableDeclaration);var VariableDeclarationList=function(TreeNode){_inherits(VariableDeclarationList,TreeNode);function VariableDeclarationList(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.variableDeclarations=[];return _this}var _proto=VariableDeclarationList.prototype;_proto.init=function init(){this.variableDeclarations.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var length=children.length;var child=children[0];var type=child.type;this.type=type;if(_instanceof(child,VariableDeclaration)){this.variableDeclarations.push(child)}else{var _this_variableDeclarations;(_this_variableDeclarations=this.variableDeclarations).push.apply(_this_variableDeclarations,[].concat(child.variableDeclarations));var ident=children[2];var newVariable=sa.objectPool?sa.objectPool.createNode(VariableDeclaration):new VariableDeclaration;if(length===3){newVariable.set(ident.location,[type,ident])}else{newVariable.set(ident.location,[type,ident,children[3]])}newVariable.semanticAnalyze(sa);this.variableDeclarations.push(newVariable)}};return VariableDeclarationList}(TreeNode);ASTNodes.VariableDeclarationList=VariableDeclarationList;VariableDeclarationList=__decorate([ASTNodeDecorator(NoneTerminal.variable_declaration_list)],VariableDeclarationList);var VariableIdentifier=function(TreeNode){_inherits(VariableIdentifier,TreeNode);function VariableIdentifier(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.referenceGlobalSymbolNames=[],_this._symbols=[];return _this}var _proto=VariableIdentifier.prototype;_proto.resolvedSymbols=function resolvedSymbols(){return this._symbols};_proto.resolvedValueSymbols=function resolvedValueSymbols(){var child=this.children[0];if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var _this__valueSymbols;return(_this__valueSymbols=this._valueSymbols)!=null?_this__valueSymbols:EMPTY_VALUE_SYMBOLS}return this._symbols};_proto.init=function init(){this.typeInfo=TypeAny;this.builtinSemantic=undefined;this.isArray=false;this.arraySize=undefined;this.referenceGlobalSymbolNames.length=0;this._symbols.length=0;if(this._valueSymbols)this._valueSymbols.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){if(sa.diagnosticsEnabled){var child=this.children[0];var referenceGlobalSymbolNames=this.referenceGlobalSymbolNames;var symbols=this._symbols;var references=_instanceof(child,BaseToken)?[{name:child.lexeme,branch:this._branch}]:child.referenceSymbols;var needFindNames=[];var builtinAliasType;if(!_instanceof(child,BaseToken)){for(var _iterator=_create_for_of_iterator_helper_loose(references),_step;!(_step=_iterator()).done;){var reference=_step.value;var builtin=reference.name===undefined?undefined:BuiltinVariable.getVar(reference.name);if(!reference.isValueIdentity||reference.unresolved||!builtin||builtinAliasType!==undefined&&builtinAliasType!==builtin.type){builtinAliasType=undefined;break}builtinAliasType=builtin.type}}for(var i=0;i<references.length;i++){var _references_i=references[i],name=_references_i.name,branch=_references_i.branch,isValueIdentity=_references_i.isValueIdentity,replacementMemberOwner=_references_i.replacementMemberOwner,requiresRuntimeOwnerExpansion=_references_i.requiresRuntimeOwnerExpansion,unresolved=_references_i.unresolved;if(unresolved){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);continue}if(name===undefined)continue;needFindNames.push(name);if(sa.macroDefineList[name]){if(replacementMemberOwner||isValueIdentity){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}continue}if(!_instanceof(child,BaseToken)&&BuiltinFunction.isExist(name)){continue}var builtinVar=BuiltinVariable.getVar(name);if(builtinVar){this.typeInfo=_instanceof(child,BaseToken)?builtinVar.type:builtinAliasType!=null?builtinAliasType:TypeAny;if(_instanceof(child,BaseToken))this.builtinSemantic=builtinVar.semantic;continue}var hit=VariableIdentifier._lookupAndMarkGlobalReference(sa,name,symbols,referenceGlobalSymbolNames,this.location,branch,this,false,!_instanceof(child,BaseToken)&&(replacementMemberOwner!==undefined||isValueIdentity===true),replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);if(isValueIdentity)this._appendValueSymbols(symbols);if(hit&&(_instanceof(child,BaseToken)||!child.visibleHasAstValue)){var _first_dataType,_first_dataType1,_first_dataType_arraySpecifier,_first_dataType2;var first=symbols[0];var firstType=(_first_dataType=first.dataType)==null?void 0:_first_dataType.type;var firstIsArray=!!((_first_dataType1=first.dataType)==null?void 0:_first_dataType1.arraySpecifier);var firstArraySize=(_first_dataType2=first.dataType)==null?void 0:(_first_dataType_arraySpecifier=_first_dataType2.arraySpecifier)==null?void 0:_first_dataType_arraySpecifier.size;var divergent=false;var arraySizeDivergent=false;if(symbols.length>1){for(var s=1;s<symbols.length;s++){var _d_arraySpecifier;var d=symbols[s].dataType;if((d==null?void 0:d.type)!==firstType||!!(d==null?void 0:d.arraySpecifier)!==firstIsArray){divergent=true;break}if((d==null?void 0:(_d_arraySpecifier=d.arraySpecifier)==null?void 0:_d_arraySpecifier.size)!==firstArraySize)arraySizeDivergent=true}}if(divergent){this.typeInfo=TypeAny;this.isArray=false;this.arraySize=undefined}else{this.typeInfo=firstType;this.isArray=firstIsArray;this.arraySize=arraySizeDivergent?undefined:firstArraySize}}}if(!_instanceof(child,BaseToken)){VariableIdentifier._probeCrossArmShadowing(sa,child,needFindNames,symbols,referenceGlobalSymbolNames)}return}this._semanticAnalyzeForCodegen(sa)};_proto._semanticAnalyzeForCodegen=function _semanticAnalyzeForCodegen(sa){var _this=this;var child=this.children[0];if(_instanceof(child,BaseToken)){var name=child.lexeme;if(sa.macroDefineList[name])return;var builtinVar=BuiltinVariable.getVar(name);if(builtinVar){this.typeInfo=builtinVar.type;this.builtinSemantic=builtinVar.semantic;return}this._resolveCodegenReference(sa,name,true,this._branch);return}var references=child.referenceSymbols.length?child.referenceSymbols:child.referenceSymbolNames.map(function(name){return{name:name,branch:_this._branch}});for(var i=0;i<references.length;i++){var _references_i=references[i],name1=_references_i.name,branch=_references_i.branch,isValueIdentity=_references_i.isValueIdentity,replacementMemberOwner=_references_i.replacementMemberOwner,requiresRuntimeOwnerExpansion=_references_i.requiresRuntimeOwnerExpansion,unresolved=_references_i.unresolved;if(unresolved){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);continue}if(name1===undefined)continue;if(sa.macroDefineList[name1]){if(replacementMemberOwner||isValueIdentity){this._registerUnresolvedReferenceResolution(sa,branch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}continue}if(BuiltinFunction.isExist(name1))continue;var builtinVar1=BuiltinVariable.getVar(name1);if(builtinVar1){this.typeInfo=builtinVar1.type;continue}this._resolveCodegenReference(sa,name1,!child.hasAstValue,branch,replacementMemberOwner!==undefined||isValueIdentity===true,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}var macroName=child.macroName;if(!macroName||BuiltinFunction.isExist(macroName)||BuiltinVariable.getVar(macroName))return;for(var i1=0;i1<references.length;i1++){if(references[i1].name===macroName)return}var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(macroName,ESymbolType.Any);sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,sa.runtimeLookupScratch,sa.runtimeFallbackScratch,this._branch);this._markCodegenReference(macroName,sa.runtimeLookupScratch);this._markCodegenReference(macroName,sa.runtimeFallbackScratch)};_proto._resolveCodegenReference=function _resolveCodegenReference(sa,name,inferType,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){if(captureResolution===void 0)captureResolution=false;var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(name,ESymbolType.Any);var symbols=this._symbols;var runtimeFallbacks=sa.runtimeFallbackScratch;sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,symbols,runtimeFallbacks,callSiteBranch);if(!symbols.length){if(captureResolution&&(replacementMemberOwner||isValueIdentity)){this._registerUnresolvedReferenceResolution(sa,callSiteBranch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)}return}this._appendCodegenRuntimeFallbacks(sa,symbols,runtimeFallbacks,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);this._markCodegenReference(name,symbols);if(isValueIdentity)this._appendValueSymbols(symbols);if(!inferType)return;var first=symbols[0].dataType;var arraySizeDivergent=false;for(var i=1;i<symbols.length;i++){var _current_arraySpecifier,_first_arraySpecifier;var current=symbols[i].dataType;if((current==null?void 0:current.type)!==(first==null?void 0:first.type)||!!(current==null?void 0:current.arraySpecifier)!==!!(first==null?void 0:first.arraySpecifier))return;if((current==null?void 0:(_current_arraySpecifier=current.arraySpecifier)==null?void 0:_current_arraySpecifier.size)!==(first==null?void 0:(_first_arraySpecifier=first.arraySpecifier)==null?void 0:_first_arraySpecifier.size))arraySizeDivergent=true}this._setCodegenType(first,arraySizeDivergent)};_proto._appendCodegenRuntimeFallbacks=function _appendCodegenRuntimeFallbacks(sa,symbols,runtimeFallbacks,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){var fallbackStart=symbols.length;for(var i=0,n=runtimeFallbacks.length;i<n;i++){var fallback=runtimeFallbacks[i];if(!(_instanceof(fallback,VarSymbol)||_instanceof(fallback,FnSymbol)))continue;if(symbols.indexOf(fallback)===-1)symbols.push(fallback)}this._registerReferenceResolution(sa,fallbackStart,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity)};_proto._appendValueSymbols=function _appendValueSymbols(symbols){if(!symbols.length)return;var _this__valueSymbols;var valueSymbols=(_this__valueSymbols=this._valueSymbols)!=null?_this__valueSymbols:this._valueSymbols=[];for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;if(valueSymbols.indexOf(symbol)===-1)valueSymbols.push(symbol)}};_proto._markCodegenReference=function _markCodegenReference(name,symbols){for(var i=0;i<symbols.length;i++){var symbol=symbols[i];if(_instanceof(symbol,FnSymbol)||_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable){if(this.referenceGlobalSymbolNames.indexOf(name)===-1){this.referenceGlobalSymbolNames.push(name)}return}}};_proto._setCodegenType=function _setCodegenType(dataType,arraySizeDivergent){if(arraySizeDivergent===void 0)arraySizeDivergent=false;var _dataType_arraySpecifier;this.typeInfo=dataType==null?void 0:dataType.type;this.isArray=!!(dataType==null?void 0:dataType.arraySpecifier);this.arraySize=arraySizeDivergent?undefined:dataType==null?void 0:(_dataType_arraySpecifier=dataType.arraySpecifier)==null?void 0:_dataType_arraySpecifier.size};_proto._registerReferenceResolution=function _registerReferenceResolution(sa,fallbackStart,callSiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){var capturesEmptyResolution=captureResolution&&(replacementMemberOwner!==undefined||isValueIdentity===true);if(!this._symbols.length&&!capturesEmptyResolution||!captureResolution&&fallbackStart>=this._symbols.length){return}sa.shaderData.referenceResolutionSnapshots.push({reference:this,symbols:this._symbols.slice(),fallbackStart:fallbackStart,callSiteBranch:callSiteBranch,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:requiresRuntimeOwnerExpansion,isValueIdentity:isValueIdentity})};_proto._registerUnresolvedReferenceResolution=function _registerUnresolvedReferenceResolution(sa,callSiteBranch,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){sa.shaderData.referenceResolutionSnapshots.push({reference:this,symbols:EMPTY_VALUE_SYMBOLS,fallbackStart:0,callSiteBranch:callSiteBranch,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:requiresRuntimeOwnerExpansion,isValueIdentity:isValueIdentity})};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitVariableIdentifier(this))};_proto.getLexeme=function getLexeme(visitor){var child=this.children[0];if(_instanceof(child,BaseToken)){return child.lexeme}else{return child.codeGen(visitor)}};VariableIdentifier._probeCrossArmShadowing=function _probeCrossArmShadowing(sa,child,needFindNames,symbols,referenceGlobalSymbolNames){var macroName=child.macroName;if(!macroName)return;if(needFindNames.indexOf(macroName)!==-1)return;if(BuiltinFunction.isExist(macroName)||BuiltinVariable.getVar(macroName))return;VariableIdentifier._lookupAndMarkGlobalReference(sa,macroName,symbols,referenceGlobalSymbolNames,null,EMPTY_BRANCH,undefined,true)};VariableIdentifier._lookupAndMarkGlobalReference=function _lookupAndMarkGlobalReference(sa,name,symbols,referenceGlobalSymbolNames,missErrorLoc,callsiteBranch,resolvedReference,retainPartialBranchCandidates,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity){if(retainPartialBranchCandidates===void 0)retainPartialBranchCandidates=false;if(captureResolution===void 0)captureResolution=false;var lookupSymbol=sa.lookupSymbol;lookupSymbol.set(name,ESymbolType.Any);var runtimeFallbacks=sa.runtimeFallbackScratch;sa.symbolTableStack.lookupAllWithRuntimeFallbacks(lookupSymbol,true,symbols,runtimeFallbacks,callsiteBranch);var directlyVisibleCount=0;for(var i=0,n=symbols.length;i<n;i++){var symbol=symbols[i];var _symbol_branchSignature;if(sa.isBranchVisibleFrom((_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH,callsiteBranch)){symbols[directlyVisibleCount++]=symbol}}if(directlyVisibleCount)symbols.length=directlyVisibleCount;var fallbackStart=symbols.length;for(var i1=0,n1=runtimeFallbacks.length;i1<n1;i1++){var fallback=runtimeFallbacks[i1];if(!(_instanceof(fallback,VarSymbol)||_instanceof(fallback,FnSymbol)))continue;if(symbols.indexOf(fallback)===-1)symbols.push(fallback)}resolvedReference==null?void 0:resolvedReference._registerReferenceResolution(sa,fallbackStart,callsiteBranch,captureResolution,replacementMemberOwner,requiresRuntimeOwnerExpansion,isValueIdentity);if(!symbols.length){if(missErrorLoc){if(sa.symbolTableStack.hasSymbol(lookupSymbol)){sa.symbolTableStack.lookupAll(lookupSymbol,true,symbols);sa.reportBranchAvailability(missErrorLoc,\"Identifier\",name,sa.getBranchCoverage(symbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),callsiteBranch));symbols.length=0;return false}}return false}var coverage=sa.getBranchCoverage(symbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),callsiteBranch);if((VariableIdentifier._containsGlobalSymbol(symbols)||VariableIdentifier._containsGlobalSymbol(runtimeFallbacks))&&referenceGlobalSymbolNames.indexOf(name)===-1){referenceGlobalSymbolNames.push(name)}if(!retainPartialBranchCandidates&&coverage!==\"covered\"&&!VariableIdentifier._hasConflictingGlobalBranches(sa,symbols)){if(missErrorLoc){sa.reportBranchAvailability(missErrorLoc,\"Identifier\",name,coverage)}return false}return true};VariableIdentifier._hasConflictingGlobalBranches=function _hasConflictingGlobalBranches(sa,symbols){for(var i=0,n=symbols.length;i<n;i++){var left=symbols[i];if(!_instanceof(left,FnSymbol)&&!left.isGlobalVariable)continue;for(var j=i+1;j<n;j++){var right=symbols[j];if(!_instanceof(right,FnSymbol)&&!right.isGlobalVariable)continue;var _left_branchSignature,_right_branchSignature;if(sa.canDeclarationsCoexist((_left_branchSignature=left.branchSignature)!=null?_left_branchSignature:EMPTY_BRANCH,(_right_branchSignature=right.branchSignature)!=null?_right_branchSignature:EMPTY_BRANCH))return true}}return false};VariableIdentifier._containsGlobalSymbol=function _containsGlobalSymbol(symbols){for(var i=0;i<symbols.length;i++){var symbol=symbols[i];if(_instanceof(symbol,FnSymbol)||_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable)return true}return false};return VariableIdentifier}(TreeNode);ASTNodes.VariableIdentifier=VariableIdentifier;VariableIdentifier=__decorate([ASTNodeDecorator(NoneTerminal.variable_identifier)],VariableIdentifier);var GLShaderProgram=function(TreeNode){_inherits(GLShaderProgram,TreeNode);function GLShaderProgram(){return TreeNode.apply(this,arguments)||this}var _proto=GLShaderProgram.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){this.shaderData=sa.shaderData;this.shaderData.symbolTable=sa.symbolTableStack.scope};return GLShaderProgram}(TreeNode);ASTNodes.GLShaderProgram=GLShaderProgram;GLShaderProgram=__decorate([ASTNodeDecorator(NoneTerminal.gs_shader_program)],GLShaderProgram);var GlobalDeclaration=function(TreeNode){_inherits(GlobalDeclaration,TreeNode);function GlobalDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalDeclaration.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var child=this.children[0];if(_instanceof(child,MacroUndef)||_instanceof(child,GlobalMacroIfStatement)||_instanceof(child,MacroDefine)||_instanceof(child,BaseToken)){sa.shaderData.globalMacroDeclarations.push(this);if(_instanceof(child,GlobalMacroIfStatement)){var _this_macroExpressions;(_this_macroExpressions=this.macroExpressions).push.apply(_this_macroExpressions,[].concat(child.macroExpressions))}else{this.macroExpressions.push(child)}}};return GlobalDeclaration}(TreeNode);ASTNodes.GlobalDeclaration=GlobalDeclaration;GlobalDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.global_declaration)],GlobalDeclaration);var MacroUndef=function(TreeNode){_inherits(MacroUndef,TreeNode);function MacroUndef(){return TreeNode.apply(this,arguments)||this}var _proto=MacroUndef.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroUndef}(TreeNode);ASTNodes.MacroUndef=MacroUndef;MacroUndef=__decorate([ASTNodeDecorator(NoneTerminal.macro_undef)],MacroUndef);var MacroPushContext=function(TreeNode){_inherits(MacroPushContext,TreeNode);function MacroPushContext(){return TreeNode.apply(this,arguments)||this}var _proto=MacroPushContext.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.symbolTableStack._macroLevel++};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroPushContext}(TreeNode);ASTNodes.MacroPushContext=MacroPushContext;MacroPushContext=__decorate([ASTNodeDecorator(NoneTerminal.macro_push_context)],MacroPushContext);var MacroPopContext=function(TreeNode){_inherits(MacroPopContext,TreeNode);function MacroPopContext(){return TreeNode.apply(this,arguments)||this}var _proto=MacroPopContext.prototype;_proto.semanticAnalyze=function semanticAnalyze(sa){sa.symbolTableStack._macroLevel--};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroPopContext}(TreeNode);ASTNodes.MacroPopContext=MacroPopContext;MacroPopContext=__decorate([ASTNodeDecorator(NoneTerminal.macro_pop_context)],MacroPopContext);var MacroElifExpression=function(TreeNode){_inherits(MacroElifExpression,TreeNode);function MacroElifExpression(){return TreeNode.apply(this,arguments)||this}var _proto=MacroElifExpression.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroElifExpression}(TreeNode);ASTNodes.MacroElifExpression=MacroElifExpression;MacroElifExpression=__decorate([ASTNodeDecorator(NoneTerminal.macro_elif_expression)],MacroElifExpression);var MacroElseExpression=function(TreeNode){_inherits(MacroElseExpression,TreeNode);function MacroElseExpression(){return TreeNode.apply(this,arguments)||this}var _proto=MacroElseExpression.prototype;_proto.codeGen=function codeGen(visitor){return visitor.cache(this,\"\\n\"+TreeNode.prototype.codeGen.call(this,visitor)+\"\\n\")};return MacroElseExpression}(TreeNode);ASTNodes.MacroElseExpression=MacroElseExpression;MacroElseExpression=__decorate([ASTNodeDecorator(NoneTerminal.macro_else_expression)],MacroElseExpression);var GlobalMacroDeclaration=function(TreeNode){_inherits(GlobalMacroDeclaration,TreeNode);function GlobalMacroDeclaration(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroDeclaration.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var macroExpressions=this.macroExpressions;if(children.length===1){var _macroExpressions;(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[0].macroExpressions))}else{var _macroExpressions1,_macroExpressions2;(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[0].macroExpressions));(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};_proto.codeGen=function codeGen(visitor){var children=this.children;if(children.length===1){return visitor.cache(this,children[0].codeGen(visitor))}else{return visitor.cache(this,children[0].codeGen(visitor)+\"\\n\"+children[1].codeGen(visitor))}};return GlobalMacroDeclaration}(TreeNode);ASTNodes.GlobalMacroDeclaration=GlobalMacroDeclaration;GlobalMacroDeclaration=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_declaration)],GlobalMacroDeclaration);var GlobalMacroIfStatement=function(TreeNode){_inherits(GlobalMacroIfStatement,TreeNode);function GlobalMacroIfStatement(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroIfStatement.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var macroExpressions=this.macroExpressions;if(children.length===3){var _macroExpressions,_macroExpressions1;macroExpressions.push(children[0]);(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[1].macroExpressions));(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(children[2].macroExpressions))}else{var _macroExpressions2;macroExpressions.push(children[0]);(_macroExpressions2=macroExpressions).push.apply(_macroExpressions2,[].concat(children[1].macroExpressions))}};return GlobalMacroIfStatement}(TreeNode);ASTNodes.GlobalMacroIfStatement=GlobalMacroIfStatement;GlobalMacroIfStatement=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_if_statement)],GlobalMacroIfStatement);var GlobalMacroBranch=function(TreeNode){_inherits(GlobalMacroBranch,TreeNode);function GlobalMacroBranch(){var _this;_this=TreeNode.apply(this,arguments)||this,_this.macroExpressions=[];return _this}var _proto=GlobalMacroBranch.prototype;_proto.init=function init(){this.macroExpressions.length=0};_proto.semanticAnalyze=function semanticAnalyze(sa){var children=this.children;var lastNode=children[children.length-1];var macroExpressions=this.macroExpressions;macroExpressions.push(children[0]);if(_instanceof(children[1],GlobalMacroDeclaration)){var _macroExpressions;(_macroExpressions=macroExpressions).push.apply(_macroExpressions,[].concat(children[1].macroExpressions))}if(_instanceof(lastNode,GlobalMacroBranch)){var _macroExpressions1;(_macroExpressions1=macroExpressions).push.apply(_macroExpressions1,[].concat(lastNode.macroExpressions))}if(children.length>1&&_instanceof(lastNode,MacroPopContext)){macroExpressions.push(lastNode)}};return GlobalMacroBranch}(TreeNode);ASTNodes.GlobalMacroBranch=GlobalMacroBranch;GlobalMacroBranch=__decorate([ASTNodeDecorator(NoneTerminal.global_macro_branch)],GlobalMacroBranch);var MacroIfStatement=function(TreeNode){_inherits(MacroIfStatement,TreeNode);function MacroIfStatement(){return TreeNode.apply(this,arguments)||this}return MacroIfStatement}(TreeNode);ASTNodes.MacroIfStatement=MacroIfStatement;MacroIfStatement=__decorate([ASTNodeDecorator(NoneTerminal.macro_if_statement)],MacroIfStatement);var MacroBranch=function(TreeNode){_inherits(MacroBranch,TreeNode);function MacroBranch(){return TreeNode.apply(this,arguments)||this}return MacroBranch}(TreeNode);ASTNodes.MacroBranch=MacroBranch;MacroBranch=__decorate([ASTNodeDecorator(NoneTerminal.macro_branch)],MacroBranch);var MacroCallSymbol=function(TreeNode1){_inherits(MacroCallSymbol,TreeNode1);function MacroCallSymbol(){var _this;_this=TreeNode1.apply(this,arguments)||this,_this.referenceSymbolNames=[],_this.referenceSymbols=[],_this.hasAstValue=false,_this.visibleHasAstValue=false,_this.isFunctionLikeMacro=false,_this.aliasesNonBuiltinIdent=false;return _this}var _proto=MacroCallSymbol.prototype;_proto.init=function init(){this.expandedSyntax=undefined;this.referenceSymbolNames.length=0;this.referenceSymbols.length=0;this.hasAstValue=false;this.visibleHasAstValue=false;this.isFunctionLikeMacro=false;this.aliasesNonBuiltinIdent=false};_proto.semanticAnalyze=function semanticAnalyze(sa){var _sa_semanticDiagnostics_macroExpansion,_sa_semanticDiagnostics;var nameToken=this.children[0];var macroName=nameToken.lexeme;this.macroName=macroName;var defList=sa.macroDefineList[macroName];var refs=this.referenceSymbolNames;refs.length=0;this.referenceSymbols.length=0;this._analyzeForCodegen(defList,refs);var callSiteBranch=nameToken.branch;var referenceSymbols=this.referenceSymbols;var visibleCount=0;var allAst=true;if(defList){for(var i=0,n=defList.length;i<n;i++){var info=defList[i];if(!sa.canBranchesOverlap(info.branch,callSiteBranch))continue;visibleCount++;if(info.valueAst==null){allAst=false;appendMacroReference(referenceSymbols,{unresolved:true,branch:mergeBranchSignatures(callSiteBranch,info.branch),isValueIdentity:true})}else{MacroCallSymbol._collectIdentifierRefs(info.valueAst,info.params,refs,referenceSymbols,callSiteBranch,undefined,ParserUtils.unwrapBareIdentifier(info.valueAst,{allowParens:true}))}}}this.visibleHasAstValue=visibleCount>0&&allAst;if(sa.diagnosticsEnabled)this.expandedSyntax=(_sa_semanticDiagnostics=sa.semanticDiagnostics)==null?void 0:(_sa_semanticDiagnostics_macroExpansion=_sa_semanticDiagnostics.macroExpansion)==null?void 0:_sa_semanticDiagnostics_macroExpansion.call(_sa_semanticDiagnostics,this,sa)};_proto._analyzeForCodegen=function _analyzeForCodegen(defList,refs){var allAst=true;var isFunctionLike=false;var allAliasNonBuiltinIdent=true;var _defList_length;var count=(_defList_length=defList==null?void 0:defList.length)!=null?_defList_length:0;for(var i=0;i<count;i++){var info=defList[i];if(!info.valueAst)allAst=false;if(info.isFunction)isFunctionLike=true;if(info.valueAst)MacroCallSymbol._collectIdentifierRefs(info.valueAst,info.params,refs);if(info.isFunction||!info.valueAst){allAliasNonBuiltinIdent=false}else{var leadingIdent=ParserUtils.unwrapBareIdentifier(info.valueAst,{allowParens:false});var leadingChild=leadingIdent==null?void 0:leadingIdent.children[0];var leadingId=_instanceof(leadingChild,BaseToken)?leadingChild.lexeme:undefined;if(!leadingId||BuiltinFunction.isExist(leadingId))allAliasNonBuiltinIdent=false}}this.hasAstValue=count>0&&allAst;this.isFunctionLikeMacro=isFunctionLike;this.aliasesNonBuiltinIdent=count>0&&allAliasNonBuiltinIdent};MacroCallSymbol._collectIdentifierRefs=function _collectIdentifierRefs(node,params,out,references,callSiteBranch,projectedMemberOwner,valueIdentity){if(callSiteBranch===void 0)callSiteBranch=EMPTY_BRANCH;if(_instanceof(node,PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var base=node.children[0];if(_instanceof(base,TreeNode)){var directOwner=ParserUtils.unwrapBareIdentifier(base,{allowParens:true});if(directOwner){MacroCallSymbol._collectIdentifierRefs(base,params,out,references,callSiteBranch,directOwner,valueIdentity);return}}}if(_instanceof(node,VariableIdentifier)){var child=node.children[0];var isValueIdentity=valueIdentity===node;var replacementMemberOwner=projectedMemberOwner===node?node:undefined;var branch=mergeBranchSignatures(callSiteBranch,node._branch);if(_instanceof(child,BaseToken)){var name=child.lexeme;var formalParameterIndex=params.indexOf(name);if(formalParameterIndex===-1){if(out.indexOf(name)===-1)out.push(name);if(references){appendMacroReference(references,{name:name,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner})}}else if(references&&(replacementMemberOwner||isValueIdentity)){appendMacroReference(references,{formalParameterIndex:formalParameterIndex,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:replacementMemberOwner?true:undefined})}}else if(_instanceof(child,MacroCallSymbol)||_instanceof(child,MacroCallFunction)){var nestedReferences=child.referenceSymbols;for(var _iterator=_create_for_of_iterator_helper_loose(nestedReferences),_step;!(_step=_iterator()).done;){var nestedReference=_step.value;if(nestedReference.unresolved){if(references&&(replacementMemberOwner||isValueIdentity)){appendMacroReference(references,{unresolved:true,branch:mergeBranchSignatures(branch,nestedReference.branch),isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:replacementMemberOwner?true:undefined})}continue}var name1=nestedReference.name;var formalParameterIndex1=nestedReference.formalParameterIndex;if(name1!==undefined){var outerFormalIndex=params.indexOf(name1);if(outerFormalIndex===-1){if(out.indexOf(name1)===-1)out.push(name1)}else{name1=undefined;formalParameterIndex1=outerFormalIndex}}if(!references)continue;var nestedBranch=mergeBranchSignatures(branch,nestedReference.branch);var nestedOwner=replacementMemberOwner!=null?replacementMemberOwner:nestedReference.replacementMemberOwner;var nestedIsValueIdentity=isValueIdentity&&nestedReference.isValueIdentity;var requiresRuntimeExpansion=replacementMemberOwner!==undefined||nestedReference.requiresRuntimeOwnerExpansion;if(name1!==undefined){appendMacroReference(references,{name:name1,branch:nestedBranch,isValueIdentity:nestedIsValueIdentity,replacementMemberOwner:nestedOwner,requiresRuntimeOwnerExpansion:requiresRuntimeExpansion})}else if(formalParameterIndex1!==undefined){appendMacroReference(references,{formalParameterIndex:formalParameterIndex1,branch:nestedBranch,isValueIdentity:nestedIsValueIdentity,replacementMemberOwner:nestedOwner,requiresRuntimeOwnerExpansion:requiresRuntimeExpansion})}}var hasNestedValueIdentity=nestedReferences.some(function(reference){return reference.isValueIdentity});if(references&&child.macroName&&(!nestedReferences.length&&replacementMemberOwner||isValueIdentity&&!hasNestedValueIdentity&&!child.visibleHasAstValue)){appendMacroReference(references,{name:child.macroName,branch:branch,isValueIdentity:isValueIdentity,replacementMemberOwner:replacementMemberOwner,requiresRuntimeOwnerExpansion:true});if(out.indexOf(child.macroName)===-1)out.push(child.macroName)}}return}var children=node.children;if(!children)return;for(var i=0,n=children.length;i<n;i++){var c=children[i];if(_instanceof(c,TreeNode)){MacroCallSymbol._collectIdentifierRefs(c,params,out,references,callSiteBranch,projectedMemberOwner,valueIdentity)}}};return MacroCallSymbol}(TreeNode);ASTNodes.MacroCallSymbol=MacroCallSymbol;MacroCallSymbol=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_symbol)],MacroCallSymbol);var MacroCallFunction=function(TreeNode1){_inherits(MacroCallFunction,TreeNode1);function MacroCallFunction(){var _this;_this=TreeNode1.apply(this,arguments)||this,_this.referenceSymbolNames=[],_this.referenceSymbols=[],_this.macroName=\"\",_this.hasAstValue=false,_this.visibleHasAstValue=false,_this.isFunctionLikeMacro=false,_this.aliasesNonBuiltinIdent=false;return _this}var _proto=MacroCallFunction.prototype;_proto.init=function init(){this.expandedSyntax=undefined;this.referenceSymbolNames.length=0;this.referenceSymbols.length=0;this.macroName=\"\";this.hasAstValue=false;this.visibleHasAstValue=false;this.isFunctionLikeMacro=false;this.aliasesNonBuiltinIdent=false};_proto.semanticAnalyze=function semanticAnalyze(sa){var _sa_semanticDiagnostics_macroExpansion,_sa_semanticDiagnostics;var child=this.children[0];var paramList=this.children[2];var paramNodes=_instanceof(paramList,FunctionCallParameterList)?paramList.paramNodes:undefined;for(var _iterator=_create_for_of_iterator_helper_loose(child.referenceSymbols),_step;!(_step=_iterator()).done;){var reference=_step.value;var formalParameterIndex=reference.formalParameterIndex;if(formalParameterIndex===undefined){appendMacroReference(this.referenceSymbols,reference);if(reference.name!==undefined&&this.referenceSymbolNames.indexOf(reference.name)===-1){this.referenceSymbolNames.push(reference.name)}continue}var actual=paramNodes==null?void 0:paramNodes[formalParameterIndex];if(!_instanceof(actual,TreeNode))continue;appendSubstitutedOwnerReferences(actual,reference,this.referenceSymbols,this.referenceSymbolNames)}this.macroName=child.macroName;this.hasAstValue=child.hasAstValue;this.visibleHasAstValue=child.visibleHasAstValue;this.isFunctionLikeMacro=child.isFunctionLikeMacro;this.aliasesNonBuiltinIdent=child.aliasesNonBuiltinIdent;if(sa.diagnosticsEnabled)this.expandedSyntax=(_sa_semanticDiagnostics=sa.semanticDiagnostics)==null?void 0:(_sa_semanticDiagnostics_macroExpansion=_sa_semanticDiagnostics.macroExpansion)==null?void 0:_sa_semanticDiagnostics_macroExpansion.call(_sa_semanticDiagnostics,this,sa)};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitMacroCallFunction(this))};return MacroCallFunction}(TreeNode);ASTNodes.MacroCallFunction=MacroCallFunction;MacroCallFunction=__decorate([ASTNodeDecorator(NoneTerminal.macro_call_function)],MacroCallFunction);var MacroDefine=function(TreeNode){_inherits(MacroDefine,TreeNode);function MacroDefine(){return TreeNode.apply(this,arguments)||this}var _proto=MacroDefine.prototype;_proto.init=function init(){this.macroName=\"\";this.isFunction=false;this.valueExpression=undefined};_proto.semanticAnalyze=function semanticAnalyze(sa){var _this=this;var children=this.children;this.macroName=children[1].lexeme;var params=[];var valueIdx=2;if(_instanceof(children[2],BaseToken)&&children[2].type===Keyword.MACRO_DEFINE_PARAMS){this.isFunction=true;params=ParserUtils.parseMacroParamList(children[2].lexeme);valueIdx=3}if(_instanceof(children[valueIdx],Expression)){this.valueExpression=children[valueIdx]}var definingBranch=children[1].branch;var list=sa.macroDefineList;var entries=list[this.macroName];var sameArity=function(info){return info.isFunction===_this.isFunction&&info.params.length===params.length&&info.params.every(function(p,i){return p===params[i]})};var upgradable=entries==null?void 0:entries.find(function(info){return!info.valueAst&&sameArity(info)&&sameBranch(info.branch,definingBranch)});if(upgradable){upgradable.valueAst=this.valueExpression}else{var info={isFunction:this.isFunction,params:params,valueAst:this.valueExpression,dedupKey:this.macroName+\"#ast/\"+(this.isFunction?params.join(\",\"):\"\"),branch:definingBranch};if(entries)entries.push(info);else list[this.macroName]=[info]}if(this.isFunction){sa.popScope()}};_proto.codeGen=function codeGen(visitor){return visitor.cache(this,visitor.visitMacroDefine(this))};return MacroDefine}(TreeNode);ASTNodes.MacroDefine=MacroDefine;MacroDefine=__decorate([ASTNodeDecorator(NoneTerminal.macro_define)],MacroDefine)})(ASTNodes||(ASTNodes={}));var ASTNode=ASTNodes;var ASTNodes;var EAction=function(EAction){EAction[EAction[\"Shift\"]=0]=\"Shift\";EAction[EAction[\"Reduce\"]=1]=\"Reduce\";EAction[EAction[\"Accept\"]=2]=\"Accept\";return EAction}({});var GrammarUtils=function(){function GrammarUtils(){}GrammarUtils.isTerminal=function isTerminal(sm){return sm<NoneTerminal.START};GrammarUtils.toString=function toString(sm){if(this.isTerminal(sm)){var _ETokenType_sm;return(_ETokenType_sm=ETokenType[sm])!=null?_ETokenType_sm:Keyword[sm]}return NoneTerminal[sm]};GrammarUtils.createProductionWithOptions=function createProductionWithOptions(goal,options,astType){return this._createProductionWithOptions(goal,options,astType,astType)};GrammarUtils.createAnalyzerProductionWithOptions=function createAnalyzerProductionWithOptions(goal,options,analyzerType){return this._createProductionWithOptions(goal,options,undefined,analyzerType)};GrammarUtils._createProductionWithOptions=function _createProductionWithOptions(goal,options,runtimeType,analyzerType){var _loop=function(){var opt=_step.value;var runtimeCanElide=!runtimeType&&opt.length===1&&!GrammarUtils.isTerminal(opt[0]);var analyzerCanElide=!analyzerType&&opt.length===1&&!GrammarUtils.isTerminal(opt[0]);ret.push([[].concat([goal],opt),function(sa){for(var _len=arguments.length,children=new Array(_len>1?_len-1:0),_key=1;_key<_len;_key++){children[_key-1]=arguments[_key]}if(!children[0])return;var analyzerMode=sa.diagnosticsEnabled;var canElide=analyzerMode?analyzerCanElide:runtimeCanElide;if(canElide){sa.semanticStack.push(children[0])}else{var start=children[0].location.start;var end=children[children.length-1].location.end;var location=sa.objectPool?sa.objectPool.createRange(start,end):ShaderCompilerUtils.createRange(start,end);ASTNode.get(analyzerMode?analyzerResolvedType:runtimeResolvedType,sa,location,children)}}])};var runtimeResolvedType=runtimeType!=null?runtimeType:ASTNode.TrivialNode;var analyzerResolvedType=analyzerType!=null?analyzerType:ASTNode.TrivialNode;var ret=[];for(var _iterator=_create_for_of_iterator_helper_loose(options),_step;!(_step=_iterator()).done;)_loop();return ret};GrammarUtils.addMapSetItem=function addMapSetItem(map,k,v){var _map_get;var set=(_map_get=map.get(k))!=null?_map_get:new Set;set.add(v);map.set(k,set)};GrammarUtils.isSubSet=function isSubSet(sa,sb){for(var _iterator=_create_for_of_iterator_helper_loose(sa),_step;!(_step=_iterator()).done;){var item=_step.value;if(!sb.has(item))return false}return true};GrammarUtils.isActionEqual=function isActionEqual(a,b){return a.action===b.action&&a.target===b.target};GrammarUtils.printAction=function printAction(actionInfo){var production=Production.pool.get(actionInfo.target);return\"<Action: \"+EAction[actionInfo.action]+\" -> \"+this.printProduction(production)+\">\"};GrammarUtils.printProduction=function printProduction(production){var deriv=production.derivation.map(function(gs){return GrammarUtils.toString(gs)}).join(\"|\");return NoneTerminal[production.goal]+\" :=> \"+deriv};return GrammarUtils}();var StateItem=function(){function StateItem(production,position,lookahead){this._needReInfer=true;this.production=production;this.position=position;this.lookaheadSet=new Set;for(var _iterator=_create_for_of_iterator_helper_loose(lookahead),_step;!(_step=_iterator()).done;){var la=_step.value;this.lookaheadSet.add(la)}this.id=StateItem._id++}var _proto=StateItem.prototype;_proto.addLookahead=function addLookahead(ts){for(var _iterator=_create_for_of_iterator_helper_loose(ts),_step;!(_step=_iterator()).done;){var t=_step.value;if(this.lookaheadSet.has(t))continue;this.lookaheadSet.add(t);this.needReInfer=true}};_proto.symbolByOffset=function symbolByOffset(offset){return this.production.derivation[this.position+offset]};_proto.canReduce=function canReduce(){if(this.position>this.production.derivation.length-1)return true;else{for(var i=this.position;i<this.production.derivation.length;i++){if(this.production.derivation[i]!==ETokenType.EPSILON)return false}return true}};_proto.advance=function advance(){if(this.canReduce())throw\"Error: advance reduce-able parsing state item\";return new StateItem(this.production,this.position+1,this.lookaheadSet)};_proto.toString=function toString(){var coreItem=this.production.derivation.map(function(item){return GrammarUtils.toString(item)});var _coreItem_this_position;coreItem[this.position]=\".\"+((_coreItem_this_position=coreItem[this.position])!=null?_coreItem_this_position:\"\");return NoneTerminal[this.production.goal]+\" :=> \"+coreItem.join(\"|\")+\" ;\"+Array.from(this.lookaheadSet).map(function(item){return GrammarUtils.toString(item)}).join(\"/\")};_create_class(StateItem,[{key:\"needReInfer\",get:function get(){return this._needReInfer},set:function set(v){this._needReInfer=v}},{key:\"curSymbol\",get:function get(){return this.production.derivation[this.position]}},{key:\"nextSymbol\",get:function get(){return this.production.derivation[this.position+1]}}]);return StateItem}();StateItem._id=0;var State=function(){function State(cores){this.closured=false;this._stateItemPool=new Map;this.id=State._id++;this._items=new Set([].concat(cores));this.cores=new Set([].concat(cores));for(var _iterator=_create_for_of_iterator_helper_loose(cores),_step;!(_step=_iterator()).done;){var it=_step.value;var itemMapKey=this.getStateItemMapKey(it.production,it.position);this._stateItemPool.set(itemMapKey,it)}State.pool.set(this.id,this)}var _proto=State.prototype;_proto.getStateItemMapKey=function getStateItemMapKey(production,position){return production.id+\",\"+position};_proto.createStateItem=function createStateItem(production,position,lookaheadSet){if(lookaheadSet===void 0)lookaheadSet=new Set;var mapId=this.getStateItemMapKey(production,position);var item=this._stateItemPool.get(mapId);if(item){for(var _iterator=_create_for_of_iterator_helper_loose(lookaheadSet),_step;!(_step=_iterator()).done;){var la=_step.value;if(item.lookaheadSet.has(la))continue;item.lookaheadSet.add(la);item.needReInfer=true}return item}var newItem=new StateItem(production,position,lookaheadSet);this._stateItemPool.set(mapId,newItem);return newItem};State.create=function create(cores){var cacheKey=this.getMapKey(cores);var state=this.closureMap.get(cacheKey);if(state){for(var _iterator=_create_for_of_iterator_helper_loose(cores),_step;!(_step=_iterator()).done;){var core=_step.value;state.createStateItem(core.production,core.position,core.lookaheadSet)}return state}var newState=new State(cores);this.closureMap.set(cacheKey,newState);return newState};State.getMapKey=function getMapKey(cores){return cores.map(function(item){return item.production.id+\",\"+item.position}).join(\";\")};_create_class(State,[{key:\"items\",get:function get(){return this._items}},{key:\"needReInfer\",get:function get(){for(var _iterator=_create_for_of_iterator_helper_loose(this.cores),_step;!(_step=_iterator()).done;){var core=_step.value;if(core.needReInfer)return true}return false}}]);return State}();State.closureMap=new Map;State.pool=new Map;State._id=0;var LALR1=function(){function LALR1(grammar){this.firstSetMap=new Map;this.followSetMap=new Map;this.actionTable=new Map;this.gotoTable=new Map;this._firstSetNTStack=[];this.grammar=grammar}var _proto=LALR1.prototype;_proto.generate=function generate(){this.computeFirstSet();this.buildStateTable()};_proto.buildStateTable=function buildStateTable(){var startStateItemCore=[new StateItem(this.grammar.productions[0],0,[ETokenType.EOF])];var startState=State.create(startStateItemCore);this._extendState(startState)};_proto._extendState=function _extendState(state){if(!state.needReInfer)return;this._closure(state);var newStates=this._inferNextState(state);for(var _iterator=_create_for_of_iterator_helper_loose(newStates),_step;!(_step=_iterator()).done;){var ns=_step.value;this._extendState(ns)}};_proto._closure=function _closure(state){for(var _iterator=_create_for_of_iterator_helper_loose(state.cores),_step;!(_step=_iterator()).done;){var core=_step.value;if(!core.canReduce()){this._extendStateItem(state,core)}}state.closured=true;return state};_proto._extendStateItem=function _extendStateItem(state,item){if(GrammarUtils.isTerminal(item.curSymbol))return;var productionList=this.grammar.getProductionList(item.curSymbol);if(item.nextSymbol!==undefined){var newLookaheadSet=new Set;var lastFirstSet;var terminalExist=false;for(var i=1,nextSymbol=item.symbolByOffset(1);nextSymbol!==undefined;nextSymbol=item.symbolByOffset(++i)){if(GrammarUtils.isTerminal(nextSymbol)){newLookaheadSet.add(nextSymbol);terminalExist=true;break}lastFirstSet=this.firstSetMap.get(nextSymbol);for(var _iterator=_create_for_of_iterator_helper_loose(lastFirstSet),_step;!(_step=_iterator()).done;){var t=_step.value;newLookaheadSet.add(t)}if(!lastFirstSet.has(ETokenType.EPSILON))break}if(!terminalExist&&(lastFirstSet==null?void 0:lastFirstSet.has(ETokenType.EPSILON))){for(var _iterator1=_create_for_of_iterator_helper_loose(item.lookaheadSet),_step1;!(_step1=_iterator1()).done;){var t1=_step1.value;newLookaheadSet.add(t1)}}for(var _iterator2=_create_for_of_iterator_helper_loose(productionList),_step2;!(_step2=_iterator2()).done;){var production=_step2.value;var newItem=state.createStateItem(production,0);if(!state.items.has(newItem)||!GrammarUtils.isSubSet(newLookaheadSet,newItem.lookaheadSet)){state.items.add(newItem);newItem.addLookahead(newLookaheadSet);this._extendStateItem(state,newItem)}}}else{for(var _iterator3=_create_for_of_iterator_helper_loose(productionList),_step3;!(_step3=_iterator3()).done;){var production1=_step3.value;var newItem1=state.createStateItem(production1,0);if(!state.items.has(newItem1)||!GrammarUtils.isSubSet(item.lookaheadSet,newItem1.lookaheadSet)){state.items.add(newItem1);newItem1.addLookahead(item.lookaheadSet);this._extendStateItem(state,newItem1)}}}};_proto._inferNextState=function _inferNextState(state){var coreMap=new Map;var _this_actionTable_get;var stateActionTable=(_this_actionTable_get=this.actionTable.get(state.id))!=null?_this_actionTable_get:new Map;var _this_gotoTable_get;var stateGotoTable=(_this_gotoTable_get=this.gotoTable.get(state.id))!=null?_this_gotoTable_get:new Map;this.actionTable.set(state.id,stateActionTable);this.gotoTable.set(state.id,stateGotoTable);for(var _iterator=_create_for_of_iterator_helper_loose(state.items),_step;!(_step=_iterator()).done;){var stateItem=_step.value;if(stateItem.canReduce()){var action=void 0;if(stateItem.production.goal!==NoneTerminal.START){action={action:EAction.Reduce,target:stateItem.production.id}}else{action={action:EAction.Accept}}for(var _iterator1=_create_for_of_iterator_helper_loose(stateItem.lookaheadSet),_step1;!(_step1=_iterator1()).done;){var t=_step1.value;this._addAction(stateActionTable,t,action)}}else{var nextItem=stateItem.advance();GrammarUtils.addMapSetItem(coreMap,stateItem.curSymbol,nextItem)}stateItem.needReInfer=false}var newStates=new Set;for(var _iterator2=_create_for_of_iterator_helper_loose(coreMap.entries()),_step2;!(_step2=_iterator2()).done;){var _step_value=_step2.value,gs=_step_value[0],cores=_step_value[1];var newState=State.create(Array.from(cores));if(GrammarUtils.isTerminal(gs)){this._addAction(stateActionTable,gs,{action:EAction.Shift,target:newState.id})}else{stateGotoTable.set(gs,newState.id)}newStates.add(newState)}return newStates};_proto._addAction=function _addAction(table,terminal,action){var exist=table.get(terminal);if(exist&&!GrammarUtils.isActionEqual(exist,action)){if(LALR1._isKnownShiftPreferred(terminal,exist,action)){if(exist.action===EAction.Shift&&action.action===EAction.Reduce)return}else{Logger.warn(\"conflict detect: <Terminal \"+GrammarUtils.toString(terminal)+\"> \\n\",GrammarUtils.printAction(exist),\"\\n\",GrammarUtils.printAction(action))}}table.set(terminal,action)};_proto.computeFirstSet=function computeFirstSet(){for(var _iterator=_create_for_of_iterator_helper_loose(this.grammar.productions.slice(1)),_step;!(_step=_iterator()).done;){var production=_step.value;this._computeFirstSetForNT(production.goal)}};_proto._computeFirstSetForNT=function _computeFirstSetForNT(NT){var idx=this._firstSetNTStack.findIndex(function(item){return item===NT});if(idx!==-1){var computingFS=this.firstSetMap.get(NT);var len=this._firstSetNTStack.length;for(var i=len-1;i>idx;i--){var curNT=this._firstSetNTStack[i];this.firstSetMap.set(curNT,computingFS)}return computingFS}this._firstSetNTStack.push(NT);var productionList=this.grammar.getProductionList(NT);var firstSet=new Set;this.firstSetMap.set(NT,firstSet);if(this.grammar.isNullableNT(NT))firstSet.add(ETokenType.EPSILON);for(var _iterator=_create_for_of_iterator_helper_loose(productionList),_step;!(_step=_iterator()).done;){var production=_step.value;var i1=0;for(;i1<production.derivation.length;i1++){var gs=production.derivation[i1];if(GrammarUtils.isTerminal(gs)){firstSet.add(gs);break}var succeedFirstSet=this._computeFirstSetForNT(gs);for(var _iterator1=_create_for_of_iterator_helper_loose(succeedFirstSet),_step1;!(_step1=_iterator1()).done;){var item=_step1.value;if(item!==ETokenType.EPSILON)firstSet.add(item)}if(!this.grammar.isNullableNT(gs))break}if(i1===production.derivation.length)firstSet.add(ETokenType.EPSILON)}this._firstSetNTStack.pop();return firstSet};LALR1._isKnownShiftPreferred=function _isKnownShiftPreferred(terminal,exist,action){if(terminal===Keyword.ELSE)return true;if(terminal!==ETokenType.LEFT_PAREN)return false;var reduce=exist.action===EAction.Reduce?exist:action.action===EAction.Reduce?action:null;if(!reduce)return false;var prod=Production.pool.get(reduce.target);return!!prod&&prod.goal===NoneTerminal.type_specifier_nonarray&&prod.derivation.length===1&&prod.derivation[0]===NoneTerminal.macro_call_symbol};return LALR1}();var Grammar=function(){function Grammar(start,productions){this.startSymbol=start;productions.unshift(new Production(NoneTerminal.START,[start]));this.productions=productions}var _proto=Grammar.prototype;_proto.getProductionList=function getProductionList(nonTerminal){return this.productions.filter(function(item){return item.goal===nonTerminal})};_proto.isNullableNT=function isNullableNT(NT){return this.productions.find(function(item){return item.goal===NT&&item.derivation[0]===ETokenType.EPSILON})};_proto.getProductionByID=function getProductionByID(pid){return Production.pool.get(pid)};Grammar.create=function create(start,productions){var _ps=productions.map(function(gsl){return new Production(gsl[0],gsl.slice(1))});return new Grammar(start,_ps)};return Grammar}();var productionAndRules=[].concat(GrammarUtils.createProductionWithOptions(NoneTerminal.gs_shader_program,[[NoneTerminal.global_declaration],[NoneTerminal.gs_shader_program,NoneTerminal.global_declaration]],ASTNode.GLShaderProgram),GrammarUtils.createProductionWithOptions(NoneTerminal.global_declaration,[[NoneTerminal.precision_specifier],[NoneTerminal.variable_declaration_statement],[NoneTerminal.struct_specifier],[NoneTerminal.function_definition],[NoneTerminal.global_macro_if_statement],[NoneTerminal.macro_undef],[NoneTerminal.macro_define],[Keyword.MACRO_DEFINE_EXPRESSION]],ASTNode.GlobalDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_define,[[Keyword.MACRO_DEFINE,ETokenType.ID,NoneTerminal.expression,Keyword.MACRO_DEFINE_END],[Keyword.MACRO_DEFINE,ETokenType.ID,Keyword.MACRO_DEFINE_PARAMS,NoneTerminal.expression,Keyword.MACRO_DEFINE_END]],ASTNode.MacroDefine),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_symbol,[[Keyword.MACRO_CALL]],ASTNode.MacroCallSymbol),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_function,[[NoneTerminal.macro_call_symbol,ETokenType.LEFT_PAREN,ETokenType.RIGHT_PAREN],[NoneTerminal.macro_call_symbol,ETokenType.LEFT_PAREN,NoneTerminal.function_call_parameter_list,ETokenType.RIGHT_PAREN]],ASTNode.MacroCallFunction),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_undef,[[Keyword.MACRO_UNDEF,ETokenType.ID],[Keyword.MACRO_UNDEF,Keyword.MACRO_CALL]],ASTNode.MacroUndef),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_push_context,[[Keyword.MACRO_IF,Keyword.MACRO_CONDITIONAL_EXPRESSION],[Keyword.MACRO_IFDEF,ETokenType.ID],[Keyword.MACRO_IFNDEF,ETokenType.ID],[Keyword.MACRO_IFDEF,NoneTerminal.macro_call_symbol],[Keyword.MACRO_IFNDEF,NoneTerminal.macro_call_symbol]],ASTNode.MacroPushContext),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_pop_context,[[Keyword.MACRO_ENDIF]],ASTNode.MacroPopContext),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_elif_expression,[[Keyword.MACRO_ELIF,Keyword.MACRO_CONDITIONAL_EXPRESSION]],ASTNode.MacroElifExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_else_expression,[[Keyword.MACRO_ELSE]],ASTNode.MacroElseExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_declaration,[[NoneTerminal.global_declaration],[NoneTerminal.global_macro_declaration,NoneTerminal.global_declaration]],ASTNode.GlobalMacroDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_if_statement,[[NoneTerminal.macro_push_context,NoneTerminal.global_macro_declaration,NoneTerminal.global_macro_branch],[NoneTerminal.macro_push_context,NoneTerminal.global_macro_branch]],ASTNode.GlobalMacroIfStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.global_macro_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.global_macro_declaration,NoneTerminal.global_macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.global_macro_declaration,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.global_macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.GlobalMacroBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration,[[NoneTerminal.fully_specified_type,ETokenType.ID],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.VariableDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration_list,[[NoneTerminal.variable_declaration],[NoneTerminal.variable_declaration_list,ETokenType.COMMA,ETokenType.ID],[NoneTerminal.variable_declaration_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.VariableDeclarationList),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_declaration_statement,[[NoneTerminal.variable_declaration_list,ETokenType.SEMICOLON]]),GrammarUtils.createProductionWithOptions(NoneTerminal.ext_builtin_type_specifier_nonarray,[[Keyword.VOID],[Keyword.FLOAT],[Keyword.BOOL],[Keyword.INT],[Keyword.UINT],[Keyword.VEC2],[Keyword.VEC3],[Keyword.VEC4],[Keyword.BVEC2],[Keyword.BVEC3],[Keyword.BVEC4],[Keyword.IVEC2],[Keyword.IVEC3],[Keyword.IVEC4],[Keyword.UVEC2],[Keyword.UVEC3],[Keyword.UVEC4],[Keyword.MAT2],[Keyword.MAT3],[Keyword.MAT4],[Keyword.MAT2X3],[Keyword.MAT2X4],[Keyword.MAT3X2],[Keyword.MAT3X4],[Keyword.MAT4X2],[Keyword.MAT4X3],[Keyword.SAMPLER2D],[Keyword.SAMPLER3D],[Keyword.SAMPLER_CUBE],[Keyword.SAMPLER2D_SHADOW],[Keyword.SAMPLER_CUBE_SHADOW],[Keyword.SAMPLER2D_ARRAY],[Keyword.SAMPLER2D_ARRAY_SHADOW],[Keyword.I_SAMPLER2D],[Keyword.I_SAMPLER3D],[Keyword.I_SAMPLER_CUBE],[Keyword.I_SAMPLER2D_ARRAY],[Keyword.U_SAMPLER2D],[Keyword.U_SAMPLER3D],[Keyword.U_SAMPLER_CUBE],[Keyword.U_SAMPLER2D_ARRAY]],ASTNode.ExtBuiltinTypeSpecifierNonArray),GrammarUtils.createProductionWithOptions(NoneTerminal.type_specifier_nonarray,[[ETokenType.ID],[NoneTerminal.ext_builtin_type_specifier_nonarray],[NoneTerminal.macro_call_symbol]],ASTNode.TypeSpecifierNonArray),GrammarUtils.createProductionWithOptions(NoneTerminal.fully_specified_type,[[NoneTerminal.type_specifier],[NoneTerminal.type_qualifier,NoneTerminal.type_specifier]],ASTNode.FullySpecifiedType),GrammarUtils.createProductionWithOptions(NoneTerminal.type_specifier,[[NoneTerminal.type_specifier_nonarray],[NoneTerminal.ext_builtin_type_specifier_nonarray,NoneTerminal.array_specifier]],ASTNode.TypeSpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.type_qualifier,[[NoneTerminal.single_type_qualifier],[NoneTerminal.type_qualifier,NoneTerminal.single_type_qualifier]],ASTNode.TypeQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.single_type_qualifier,[[NoneTerminal.storage_qualifier],[NoneTerminal.precision_qualifier],[NoneTerminal.interpolation_qualifier],[NoneTerminal.invariant_qualifier],[Keyword.PRECISE]],ASTNode.SingleTypeQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.storage_qualifier,[[Keyword.CONST],[Keyword.IN],[Keyword.INOUT],[Keyword.OUT],[Keyword.CENTROID]],ASTNode.StorageQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.interpolation_qualifier,[[Keyword.SMOOTH],[Keyword.FLAT]],ASTNode.InterpolationQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.invariant_qualifier,[[Keyword.INVARIANT]],ASTNode.InvariantQualifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.precision_qualifier,[[Keyword.HIGHP],[Keyword.MEDIUMP],[Keyword.LOWP]],ASTNode.PrecisionQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_specifier,[[Keyword.STRUCT,ETokenType.ID,ETokenType.LEFT_BRACE,NoneTerminal.struct_declaration_list,ETokenType.RIGHT_BRACE,ETokenType.SEMICOLON],[Keyword.STRUCT,ETokenType.LEFT_BRACE,NoneTerminal.struct_declaration_list,ETokenType.RIGHT_BRACE,ETokenType.SEMICOLON]],ASTNode.StructSpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declaration_list,[[NoneTerminal.struct_declaration],[NoneTerminal.struct_declaration_list,NoneTerminal.struct_declaration]],ASTNode.StructDeclarationList),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declaration,[[NoneTerminal.type_specifier,NoneTerminal.struct_declarator_list,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,NoneTerminal.type_specifier,NoneTerminal.struct_declarator_list,ETokenType.SEMICOLON],[NoneTerminal.layout_qualifier,NoneTerminal.type_specifier,NoneTerminal.struct_declarator,ETokenType.SEMICOLON],[NoneTerminal.macro_struct_declaration]],ASTNode.StructDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_struct_declaration,[[NoneTerminal.macro_push_context,NoneTerminal.struct_declaration_list,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_struct_branch]],ASTNode.MacroStructDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_struct_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.struct_declaration_list,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_else_expression,NoneTerminal.struct_declaration_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_struct_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroStructBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.layout_qualifier,[[Keyword.LAYOUT,ETokenType.LEFT_PAREN,Keyword.LOCATION,ETokenType.EQUAL,ETokenType.INT_CONSTANT,ETokenType.RIGHT_PAREN]],ASTNode.LayoutQualifier),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declarator_list,[[NoneTerminal.struct_declarator],[NoneTerminal.struct_declarator_list,ETokenType.COMMA,NoneTerminal.struct_declarator]],ASTNode.StructDeclaratorList),GrammarUtils.createProductionWithOptions(NoneTerminal.struct_declarator,[[ETokenType.ID],[ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.StructDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.array_specifier,[[ETokenType.LEFT_BRACKET,ETokenType.RIGHT_BRACKET],[ETokenType.LEFT_BRACKET,NoneTerminal.integer_constant_expression,ETokenType.RIGHT_BRACKET]],ASTNode.ArraySpecifier),GrammarUtils.createProductionWithOptions(NoneTerminal.integer_constant_expression_operator,[[ETokenType.PLUS],[ETokenType.DASH],[ETokenType.STAR],[ETokenType.SLASH],[ETokenType.PERCENT]],ASTNode.IntegerConstantExpressionOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.integer_constant_expression,[[NoneTerminal.variable_identifier],[ETokenType.INT_CONSTANT],[NoneTerminal.integer_constant_expression,NoneTerminal.integer_constant_expression_operator,ETokenType.INT_CONSTANT],[NoneTerminal.integer_constant_expression,NoneTerminal.integer_constant_expression_operator,NoneTerminal.variable_identifier]],ASTNode.IntegerConstantExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.conditional_expression,[[NoneTerminal.logical_or_expression],[NoneTerminal.logical_or_expression,ETokenType.QUESTION,NoneTerminal.expression,ETokenType.COLON,NoneTerminal.assignment_expression]],ASTNode.ConditionalExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_or_expression,[[NoneTerminal.logical_xor_expression],[NoneTerminal.logical_or_expression,ETokenType.OR_OP,NoneTerminal.logical_xor_expression]],ASTNode.LogicalOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_xor_expression,[[NoneTerminal.logical_and_expression],[NoneTerminal.logical_xor_expression,ETokenType.XOR_OP,NoneTerminal.logical_and_expression]],ASTNode.LogicalXorExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.logical_and_expression,[[NoneTerminal.inclusive_or_expression],[NoneTerminal.logical_and_expression,ETokenType.AND_OP,NoneTerminal.inclusive_or_expression]],ASTNode.LogicalAndExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.inclusive_or_expression,[[NoneTerminal.exclusive_or_expression],[NoneTerminal.inclusive_or_expression,ETokenType.VERTICAL_BAR,NoneTerminal.exclusive_or_expression]],ASTNode.InclusiveOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.exclusive_or_expression,[[NoneTerminal.and_expression],[NoneTerminal.exclusive_or_expression,ETokenType.CARET,NoneTerminal.and_expression]],ASTNode.ExclusiveOrExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.and_expression,[[NoneTerminal.equality_expression],[NoneTerminal.and_expression,ETokenType.AMPERSAND,NoneTerminal.equality_expression]],ASTNode.AndExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.equality_expression,[[NoneTerminal.relational_expression],[NoneTerminal.equality_expression,ETokenType.EQ_OP,NoneTerminal.relational_expression],[NoneTerminal.equality_expression,ETokenType.NE_OP,NoneTerminal.relational_expression]],ASTNode.EqualityExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.relational_expression,[[NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.LEFT_ANGLE,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.RIGHT_ANGLE,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.LE_OP,NoneTerminal.shift_expression],[NoneTerminal.relational_expression,ETokenType.GE_OP,NoneTerminal.shift_expression]],ASTNode.RelationalExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.shift_expression,[[NoneTerminal.additive_expression],[NoneTerminal.shift_expression,ETokenType.LEFT_OP,NoneTerminal.additive_expression],[NoneTerminal.shift_expression,ETokenType.RIGHT_OP,NoneTerminal.additive_expression]],ASTNode.ShiftExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.additive_expression,[[NoneTerminal.multiplicative_expression],[NoneTerminal.additive_expression,ETokenType.PLUS,NoneTerminal.multiplicative_expression],[NoneTerminal.additive_expression,ETokenType.DASH,NoneTerminal.multiplicative_expression]],ASTNode.AdditiveExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.multiplicative_expression,[[NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.STAR,NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.SLASH,NoneTerminal.unary_expression],[NoneTerminal.multiplicative_expression,ETokenType.PERCENT,NoneTerminal.unary_expression]],ASTNode.MultiplicativeExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.unary_expression,[[NoneTerminal.postfix_expression],[ETokenType.INC_OP,NoneTerminal.unary_expression],[ETokenType.DEC_OP,NoneTerminal.unary_expression],[NoneTerminal.unary_operator,NoneTerminal.unary_expression]],ASTNode.UnaryExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.unary_operator,[[ETokenType.PLUS],[ETokenType.DASH],[ETokenType.BANG],[ETokenType.TILDE]],ASTNode.UnaryOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.postfix_expression,[[NoneTerminal.primary_expression],[NoneTerminal.postfix_expression,ETokenType.LEFT_BRACKET,NoneTerminal.expression,ETokenType.RIGHT_BRACKET],[NoneTerminal.function_call],[NoneTerminal.postfix_expression,ETokenType.DOT,ETokenType.ID],[NoneTerminal.postfix_expression,ETokenType.DOT,NoneTerminal.function_call],[NoneTerminal.postfix_expression,ETokenType.INC_OP],[NoneTerminal.postfix_expression,ETokenType.DEC_OP]],ASTNode.PostfixExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.primary_expression,[[NoneTerminal.variable_identifier],[ETokenType.INT_CONSTANT],[ETokenType.FLOAT_CONSTANT],[Keyword.True],[Keyword.False],[ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN]],ASTNode.PrimaryExpression),GrammarUtils.createProductionWithOptions(NoneTerminal.expression,[[NoneTerminal.assignment_expression],[NoneTerminal.expression,ETokenType.COMMA,NoneTerminal.assignment_expression]],ASTNode.Expression),GrammarUtils.createProductionWithOptions(NoneTerminal.assignment_expression,[[NoneTerminal.conditional_expression],[NoneTerminal.unary_expression,NoneTerminal.assignment_operator,NoneTerminal.assignment_expression]],ASTNode.AssignmentExpression),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.assignment_operator,[[ETokenType.EQUAL],[ETokenType.MUL_ASSIGN],[ETokenType.DIV_ASSIGN],[ETokenType.MOD_ASSIGN],[ETokenType.ADD_ASSIGN],[ETokenType.SUB_ASSIGN],[ETokenType.LEFT_ASSIGN],[ETokenType.RIGHT_ASSIGN],[ETokenType.AND_ASSIGN],[ETokenType.XOR_ASSIGN],[ETokenType.OR_ASSIGN]],ASTNode.AssignmentOperator),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call,[[NoneTerminal.function_call_generic]],ASTNode.FunctionCall),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call_generic,[[NoneTerminal.function_identifier,ETokenType.LEFT_PAREN,NoneTerminal.function_call_parameter_list,ETokenType.RIGHT_PAREN],[NoneTerminal.function_identifier,ETokenType.LEFT_PAREN,ETokenType.RIGHT_PAREN],[NoneTerminal.function_identifier,Keyword.VOID,ETokenType.RIGHT_PAREN]],ASTNode.FunctionCallGeneric),GrammarUtils.createProductionWithOptions(NoneTerminal.function_call_parameter_list,[[NoneTerminal.assignment_expression],[NoneTerminal.function_call_parameter_list,ETokenType.COMMA,NoneTerminal.assignment_expression],[NoneTerminal.macro_call_arg_block],[NoneTerminal.function_call_parameter_list,NoneTerminal.macro_call_arg_block]],ASTNode.FunctionCallParameterList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_case_list,[[NoneTerminal.assignment_expression],[ETokenType.COMMA,NoneTerminal.assignment_expression],[NoneTerminal.macro_call_arg_block],[NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_block],[NoneTerminal.macro_call_arg_case_list,ETokenType.COMMA,NoneTerminal.assignment_expression]],ASTNode.MacroCallArgCaseList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_block,[[NoneTerminal.macro_push_context,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_branch]],ASTNode.MacroCallArgBlock),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_call_arg_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_call_arg_case_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_call_arg_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroCallArgBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.function_identifier,[[NoneTerminal.type_specifier]],ASTNode.FunctionIdentifier),GrammarUtils.createProductionWithOptions(NoneTerminal.function_definition,[[NoneTerminal.function_prototype,NoneTerminal.compound_statement_no_scope]],ASTNode.FunctionDefinition),GrammarUtils.createProductionWithOptions(NoneTerminal.function_prototype,[[NoneTerminal.function_declarator,ETokenType.RIGHT_PAREN]],ASTNode.FunctionProtoType),GrammarUtils.createProductionWithOptions(NoneTerminal.function_declarator,[[NoneTerminal.function_header],[NoneTerminal.function_header,NoneTerminal.function_parameter_list]],ASTNode.FunctionDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.function_header,[[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.LEFT_PAREN]],ASTNode.FunctionHeader),GrammarUtils.createProductionWithOptions(NoneTerminal.function_parameter_list,[[NoneTerminal.parameter_declaration],[NoneTerminal.function_parameter_list,ETokenType.COMMA,NoneTerminal.parameter_declaration],[NoneTerminal.macro_param_block],[NoneTerminal.function_parameter_list,NoneTerminal.macro_param_block]],ASTNode.FunctionParameterList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_param_case_list,[[NoneTerminal.parameter_declaration],[ETokenType.COMMA,NoneTerminal.parameter_declaration],[NoneTerminal.macro_param_block],[NoneTerminal.macro_param_case_list,NoneTerminal.macro_param_block],[NoneTerminal.macro_param_case_list,ETokenType.COMMA,NoneTerminal.parameter_declaration]],ASTNode.MacroParamCaseList),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_param_block,[[NoneTerminal.macro_push_context,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_param_case_list,NoneTerminal.macro_parameter_branch]],ASTNode.MacroParamBlock),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_parameter_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_param_case_list,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_param_case_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_parameter_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroParameterBranch),GrammarUtils.createProductionWithOptions(NoneTerminal.parameter_declaration,[[NoneTerminal.type_qualifier,NoneTerminal.parameter_declarator],[NoneTerminal.parameter_declarator],[NoneTerminal.macro_call_symbol],[NoneTerminal.macro_call_function]],ASTNode.ParameterDeclaration),GrammarUtils.createProductionWithOptions(NoneTerminal.parameter_declarator,[[NoneTerminal.type_specifier,ETokenType.ID],[NoneTerminal.type_specifier,ETokenType.ID,NoneTerminal.array_specifier]],ASTNode.ParameterDeclarator),GrammarUtils.createProductionWithOptions(NoneTerminal.statement_list,[[NoneTerminal.statement],[NoneTerminal.statement_list,NoneTerminal.statement]],ASTNode.StatementList),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.statement,[[NoneTerminal.compound_statement],[NoneTerminal.simple_statement]],ASTNode.Statement),GrammarUtils.createProductionWithOptions(NoneTerminal.compound_statement_no_scope,[[ETokenType.LEFT_BRACE,ETokenType.RIGHT_BRACE],[ETokenType.LEFT_BRACE,NoneTerminal.statement_list,ETokenType.RIGHT_BRACE]],ASTNode.CompoundStatementNoScope),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.compound_statement,[[ETokenType.LEFT_BRACE,ETokenType.RIGHT_BRACE],[NoneTerminal.scope_brace,NoneTerminal.statement_list,NoneTerminal.scope_end_brace]],ASTNode.CompoundStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.simple_statement,[[NoneTerminal.declaration],[NoneTerminal.expression_statement],[NoneTerminal.selection_statement],[NoneTerminal.iteration_statement],[NoneTerminal.jump_statement],[NoneTerminal.macro_if_statement],[NoneTerminal.macro_undef],[NoneTerminal.macro_define],[Keyword.MACRO_DEFINE_EXPRESSION]],ASTNode.SimpleStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.declaration,[[NoneTerminal.function_prototype,ETokenType.SEMICOLON],[NoneTerminal.init_declarator_list,ETokenType.SEMICOLON],[Keyword.PRECISION,NoneTerminal.precision_qualifier,NoneTerminal.ext_builtin_type_specifier_nonarray,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,ETokenType.ID,ETokenType.SEMICOLON],[NoneTerminal.type_qualifier,ETokenType.ID,NoneTerminal.identifier_list,ETokenType.SEMICOLON]],ASTNode.Declaration),GrammarUtils.createProductionWithOptions(NoneTerminal.identifier_list,[[ETokenType.COMMA,ETokenType.ID],[NoneTerminal.identifier_list,ETokenType.COMMA,ETokenType.ID]],ASTNode.IdentifierList),GrammarUtils.createProductionWithOptions(NoneTerminal.init_declarator_list,[[NoneTerminal.single_declaration],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,NoneTerminal.array_specifier,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.init_declarator_list,ETokenType.COMMA,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.InitDeclaratorList),GrammarUtils.createProductionWithOptions(NoneTerminal.single_declaration,[[NoneTerminal.fully_specified_type,ETokenType.ID],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier],[NoneTerminal.fully_specified_type,ETokenType.ID,NoneTerminal.array_specifier,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer],[NoneTerminal.fully_specified_type,Keyword.MACRO_CALL],[NoneTerminal.fully_specified_type,Keyword.MACRO_CALL,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.SingleDeclaration),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.initializer,[[NoneTerminal.assignment_expression],[ETokenType.LEFT_BRACE,NoneTerminal.initializer_list,ETokenType.RIGHT_BRACE]],ASTNode.Initializer),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.initializer_list,[[NoneTerminal.initializer],[NoneTerminal.initializer_list,ETokenType.COMMA,NoneTerminal.initializer]],ASTNode.InitializerList),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.expression_statement,[[ETokenType.SEMICOLON],[NoneTerminal.expression,ETokenType.SEMICOLON]],ASTNode.ExpressionStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.selection_statement,[[Keyword.IF,ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN,NoneTerminal.statement],[Keyword.IF,ETokenType.LEFT_PAREN,NoneTerminal.expression,ETokenType.RIGHT_PAREN,NoneTerminal.statement,Keyword.ELSE,NoneTerminal.statement]],ASTNode.SelectionStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.iteration_statement,[[Keyword.WHILE,ETokenType.LEFT_PAREN,NoneTerminal.condition,ETokenType.RIGHT_PAREN,NoneTerminal.statement],[Keyword.FOR,ETokenType.LEFT_PAREN,NoneTerminal.for_init_statement,NoneTerminal.for_rest_statement,ETokenType.RIGHT_PAREN,NoneTerminal.statement]],ASTNode.IterationStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.precision_specifier,[[Keyword.PRECISION,NoneTerminal.precision_qualifier,NoneTerminal.ext_builtin_type_specifier_nonarray,ETokenType.SEMICOLON]],ASTNode.PrecisionSpecifier),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.for_init_statement,[[NoneTerminal.expression_statement],[NoneTerminal.declaration]],ASTNode.ForInitStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.condition,[[NoneTerminal.expression],[NoneTerminal.fully_specified_type,ETokenType.ID,ETokenType.EQUAL,NoneTerminal.initializer]],ASTNode.Condition),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.for_rest_statement,[[NoneTerminal.conditionopt,ETokenType.SEMICOLON],[NoneTerminal.conditionopt,ETokenType.SEMICOLON,NoneTerminal.expression]],ASTNode.ForRestStatement),GrammarUtils.createAnalyzerProductionWithOptions(NoneTerminal.conditionopt,[[ETokenType.EPSILON],[NoneTerminal.condition]],ASTNode.ConditionOpt),GrammarUtils.createProductionWithOptions(NoneTerminal.jump_statement,[[Keyword.CONTINUE,ETokenType.SEMICOLON],[Keyword.BREAK,ETokenType.SEMICOLON],[Keyword.RETURN,ETokenType.SEMICOLON],[Keyword.RETURN,NoneTerminal.expression,ETokenType.SEMICOLON],[Keyword.DISCARD,ETokenType.SEMICOLON]],ASTNode.JumpStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.scope_brace,[[ETokenType.LEFT_BRACE]],ASTNode.ScopeBrace),GrammarUtils.createProductionWithOptions(NoneTerminal.scope_end_brace,[[ETokenType.RIGHT_BRACE]],ASTNode.ScopeEndBrace),GrammarUtils.createProductionWithOptions(NoneTerminal.variable_identifier,[[ETokenType.ID],[NoneTerminal.macro_call_symbol],[NoneTerminal.macro_call_function]],ASTNode.VariableIdentifier),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_if_statement,[[NoneTerminal.macro_push_context,NoneTerminal.statement_list,NoneTerminal.macro_branch],[NoneTerminal.macro_push_context,NoneTerminal.macro_branch]],ASTNode.MacroIfStatement),GrammarUtils.createProductionWithOptions(NoneTerminal.macro_branch,[[NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.statement_list,NoneTerminal.macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.statement_list,NoneTerminal.macro_pop_context],[NoneTerminal.macro_elif_expression,NoneTerminal.macro_branch],[NoneTerminal.macro_else_expression,NoneTerminal.macro_pop_context]],ASTNode.MacroBranch));var createGrammar=function(){return Grammar.create(NoneTerminal.gs_shader_program,productionAndRules.map(function(item){return item[0]}))};var translationRules=productionAndRules.map(function(item){return item[1]});var addTranslationRule=function(sa){sa.setTranslationRules(translationRules)};var ShaderData=function(){function ShaderData(){this.globalPrecisions=[];this.globalMacroDeclarations=[];this.directMemberOwnerReferences=[];this.referenceResolutionSnapshots=[]}var _proto=ShaderData.prototype;_proto.getOuterGlobalMacroDeclarations=function getOuterGlobalMacroDeclarations(){return this.globalMacroDeclarations.filter(function(node){return _instanceof(node.parent,ASTNode.GLShaderProgram)})};return ShaderData}();function createShaderDeclarationOwnership(symbolTable){var groups=new Map;var names=new Map;var keys=new Map;symbolTable.forEach(function(symbol){if(!symbol.astNode)return;var name=JSON.stringify([symbol.type,symbol.ident]);var _names_get;var candidates=(_names_get=names.get(name))!=null?_names_get:[];candidates.push(symbol);names.set(name,candidates);var key=declarationKey(symbol);keys.set(symbol,key);if(key===undefined)return;var _groups_get;var group=(_groups_get=groups.get(key))!=null?_groups_get:[];group.push(symbol);groups.set(key,group)});var declarations=new Map;var coverage=new Map;var unsupported=new Set;var groupId=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups.values()),_step;!(_step=_iterator()).done;){var _loop=function(){var earlier=_step1.value;var narrower=group.filter(function(candidate){return candidate.sourceScope>earlier.sourceScope});if(!narrower.length)return\"continue\";var proof=proveInheritanceBranchesCover(narrower.map(function(candidate){return candidate.branchSignature}),earlier.branchSignature);coverage.set(earlier,proof);deferred||(deferred=proof===undefined)};var group=_step.value;var deferred=false;for(var _iterator1=_create_for_of_iterator_helper_loose(group),_step1;!(_step1=_iterator1()).done;)_loop();if(!deferred)continue;groupId++;for(var _iterator2=_create_for_of_iterator_helper_loose(group),_step2;!(_step2=_iterator2()).done;){var symbol=_step2.value;declarations.set(symbol,{id:declarations.size+1,group:groupId,sourceScope:symbol.sourceScope});if(coverage.get(symbol)!==false)continue;for(var _iterator3=_create_for_of_iterator_helper_loose(group),_step3;!(_step3=_iterator3()).done;){var narrower=_step3.value;if(narrower.sourceScope<=symbol.sourceScope)continue;if(proveInheritanceBranchesCover([],symbol.branchSignature.concat(narrower.branchSignature))===false){unsupported.add(symbol);unsupported.add(narrower)}}}}for(var _iterator4=_create_for_of_iterator_helper_loose(names.values()),_step4;!(_step4=_iterator4()).done;){var _loop1=function(){var earlier=_step5.value;var narrower=candidates.filter(function(candidate){return candidate.sourceScope>earlier.sourceScope&&candidate.equal(earlier)});if(!narrower.length||keys.get(earlier)!==undefined&&narrower.every(function(candidate){return keys.get(candidate)}))return\"continue\";if(proveInheritanceBranchesCover(narrower.map(function(candidate){return candidate.branchSignature}),earlier.branchSignature)===undefined){unsupported.add(earlier);for(var _iterator=_create_for_of_iterator_helper_loose(narrower),_step;!(_step=_iterator()).done;){var candidate=_step.value;unsupported.add(candidate)}}};var candidates=_step4.value;if(!candidates.some(function(candidate){return keys.get(candidate)===undefined}))continue;for(var _iterator5=_create_for_of_iterator_helper_loose(candidates),_step5;!(_step5=_iterator5()).done;)_loop1()}return{declarations:declarations,unsupported:Array.from(unsupported),coverage:coverage}}function isDeferredDeclarationPair(facts,left,right){var _facts_declarations_get,_facts_declarations_get1;if(left.sourceScope===right.sourceScope)return false;var group=(_facts_declarations_get=facts.declarations.get(left))==null?void 0:_facts_declarations_get.group;if(group===undefined||((_facts_declarations_get1=facts.declarations.get(right))==null?void 0:_facts_declarations_get1.group)!==group)return false;var earlier=left.sourceScope<right.sourceScope?left:right;return facts.coverage.has(earlier)&&facts.coverage.get(earlier)===undefined}function declarationKey(symbol){if(symbol.type!==ESymbolType.FN)return JSON.stringify([symbol.type,symbol.ident]);if(!_instanceof(symbol,FnSymbol))return;var _symbol_astNode_protoType_parameterList;var parameters=(_symbol_astNode_protoType_parameterList=symbol.astNode.protoType.parameterList)!=null?_symbol_astNode_protoType_parameterList:[];var signature=[];for(var _iterator=_create_for_of_iterator_helper_loose(parameters),_step;!(_step=_iterator()).done;){var parameter=_step.value;var type=parameter.typeInfo;if(!type||type.type===TypeAny)return;if(type.type===Keyword.VOID&¶meters.length===1&&!type.arraySpecifier)continue;var array=type.arraySpecifier;var shape=null;if(array){if(array.children.some(function(child){return _instanceof(child,ASTNode.ArraySpecifier)}))return;if(array.children.length===2)shape=\"unsized\";else if(array.size!==undefined)shape=array.size;else return}signature.push([type.type,shape])}return JSON.stringify([symbol.type,symbol.ident,signature])}var SemanticAnalyzer=function(){function SemanticAnalyzer(branchSemantics,semanticDiagnostics,objectPool,diagnosticsEnabled){if(diagnosticsEnabled===void 0)diagnosticsEnabled=semanticDiagnostics!==undefined;this.branchSemantics=branchSemantics;this.semanticDiagnostics=semanticDiagnostics;this.objectPool=objectPool;this.lookupSymbol=new SymbolInfo(\"\",null);this.arraySymbolScratch=[];this.overloadScratch=[];this.structScratch=[];this.runtimeLookupScratch=[];this.runtimeFallbackScratch=[];this.semanticStack=[];this.acceptRule=undefined;this.symbolTableStack=new SymbolTableStack;this._functionCaptures=[];this._shaderData=new ShaderData;this._translationRules=[];this._sourceScopes=[];this._inheritedDeclarations=[];this.errors=[];this.inMacroDefinition=false;this._ambiguousReported=new Set;this.diagnosticsEnabled=diagnosticsEnabled;this.symbolTableStack.branchSemantics=branchSemantics;this.pushScope()}var _proto=SemanticAnalyzer.prototype;_proto.reset=function reset(macroDefineList){this._macroDefineList=macroDefineList;this.semanticStack.length=0;this._shaderData=new ShaderData;this.symbolTableStack.clear();this.pushScope();this.errors.length=0;this.inMacroDefinition=false;this._ambiguousReported.clear();this._inheritedDeclarations.length=0;this._functionCaptures.length=0;this.runtimeLookupScratch.length=0;this.runtimeFallbackScratch.length=0};_proto.pushScope=function pushScope(){this.symbolTableStack.pushScope(new SymbolTable)};_proto.popScope=function popScope(){return this.symbolTableStack.popScope()};_proto.setTranslationRules=function setTranslationRules(rules){this._translationRules=rules};_proto.setSourceScopes=function setSourceScopes(sourceScopes){this._sourceScopes=sourceScopes};_proto.assignSourceScope=function assignSourceScope(symbol,location){var offset=location.start.index;var segments=this._sourceScopes;var low=0;var high=segments.length-1;while(low<=high){var mid=low+high>>>1;var segment=segments[mid];if(offset<segment.generatedStart){high=mid-1}else if(offset>=segment.generatedEnd){low=mid+1}else{var _segment_sourceScope;symbol.sourceScope=(_segment_sourceScope=segment.sourceScope)!=null?_segment_sourceScope:0;return symbol}}symbol.sourceScope=0;return symbol};_proto.getTranslationRule=function getTranslationRule(pid){return this._translationRules[pid]};_proto.beginFunction=function beginFunction(header){this._functionCaptures.push({header:header,localVariables:[],calledFunctions:[]})};_proto.endFunction=function endFunction(){return this._functionCaptures.pop()};_proto.recordFunctionVariable=function recordFunctionVariable(variable){var _this__functionCaptures_;(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.localVariables.push(variable)};_proto.recordFunctionCall=function recordFunctionCall(fn){var _this__functionCaptures_;(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.calledFunctions.push(fn)};_proto.reportRedefinition=function reportRedefinition(loc,symbol,conflict){var _this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.redefinition(loc,symbol.ident,conflict,symbol.branchSignature));if(this.semanticDiagnostics&&symbol.sourceScope>0&&this.symbolTableStack.stack.length===1&&!this.inMacroDefinition&&this._isCurrentBranchReachable()){this._inheritedDeclarations.push({symbol:symbol,location:loc})}};_proto.finalizeInheritance=function finalizeInheritance(){var ownership=this._shaderData.declarationOwnership=createShaderDeclarationOwnership(this.symbolTableStack.scope);if(!this.branchSemantics||!this.semanticDiagnostics)return;for(var _iterator=_create_for_of_iterator_helper_loose(this._inheritedDeclarations),_step;!(_step=_iterator()).done;){var _step_value=_step.value,symbol=_step_value.symbol,location=_step_value.location;var conflict=this.symbolTableStack.scope.getInheritedConflict(symbol,this.branchSemantics,function(left,right){return isDeferredDeclarationPair(ownership,left,right)});var error=this.semanticDiagnostics.redefinition(location,symbol.ident,conflict,symbol.branchSignature);if(error)this.errors.push(error)}this._inheritedDeclarations.length=0};_proto.reportBranchAvailability=function reportBranchAvailability(loc,subjectKind,name,coverage){var _this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.branchAvailability(loc,subjectKind,name,coverage))};_proto.reportBranchAmbiguity=function reportBranchAmbiguity(loc,key,kind,name,owner){var _this_semanticDiagnostics;var createDiagnostic=(_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:_this_semanticDiagnostics.branchAmbiguity;if(!createDiagnostic)return;var dedupKey=kind+\":\"+key;if(this._ambiguousReported.has(dedupKey))return;var error=createDiagnostic.call(this.semanticDiagnostics,loc,kind,name,owner);if(!error)return;this._ambiguousReported.add(dedupKey);this._report(error)};_proto.reportNonConstArraySize=function reportNonConstArraySize(loc){var _this_semanticDiagnostics_nonConstArraySize,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_nonConstArraySize=_this_semanticDiagnostics.nonConstArraySize)==null?void 0:_this_semanticDiagnostics_nonConstArraySize.call(_this_semanticDiagnostics,loc))};_proto.reportExpectedSampler=function reportExpectedSampler(loc,functionName,actualType){var _this_semanticDiagnostics_expectedSampler,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_expectedSampler=_this_semanticDiagnostics.expectedSampler)==null?void 0:_this_semanticDiagnostics_expectedSampler.call(_this_semanticDiagnostics,loc,functionName,actualType))};_proto.reportNoMatchingOverload=function reportNoMatchingOverload(loc,functionName){var _this_semanticDiagnostics_noMatchingOverload,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_noMatchingOverload=_this_semanticDiagnostics.noMatchingOverload)==null?void 0:_this_semanticDiagnostics_noMatchingOverload.call(_this_semanticDiagnostics,loc,functionName))};_proto.reportUndeclaredStructMember=function reportUndeclaredStructMember(loc,structName,memberName){var _this_semanticDiagnostics_undeclaredStructMember,_this_semanticDiagnostics;this._report((_this_semanticDiagnostics=this.semanticDiagnostics)==null?void 0:(_this_semanticDiagnostics_undeclaredStructMember=_this_semanticDiagnostics.undeclaredStructMember)==null?void 0:_this_semanticDiagnostics_undeclaredStructMember.call(_this_semanticDiagnostics,loc,structName,memberName))};_proto.canBranchesOverlap=function canBranchesOverlap(left,right){var _this_branchSemantics;var _this_branchSemantics_canBranchesOverlap;return(_this_branchSemantics_canBranchesOverlap=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.canBranchesOverlap(left,right))!=null?_this_branchSemantics_canBranchesOverlap:getLexicalDeclarationCoexistence(left,right)!==\"exclusive\"};_proto.canDeclarationsCoexist=function canDeclarationsCoexist(earlier,later){var _this_branchSemantics;var _this_branchSemantics_canDeclarationsCoexist;return(_this_branchSemantics_canDeclarationsCoexist=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.canDeclarationsCoexist(earlier,later))!=null?_this_branchSemantics_canDeclarationsCoexist:true};_proto.getBranchCoverage=function getBranchCoverage(candidates,callSiteBranch){var _this_branchSemantics;var _this_branchSemantics_getBranchCoverage;return(_this_branchSemantics_getBranchCoverage=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.getBranchCoverage(candidates,callSiteBranch))!=null?_this_branchSemantics_getBranchCoverage:\"covered\"};_proto.isBranchVisibleFrom=function isBranchVisibleFrom(defBranch,callSiteBranch){var _this_branchSemantics;var _this_branchSemantics_isBranchVisibleFrom;return(_this_branchSemantics_isBranchVisibleFrom=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.isBranchVisibleFrom(defBranch,callSiteBranch))!=null?_this_branchSemantics_isBranchVisibleFrom:true};_proto._report=function _report(error){if(!error||this.inMacroDefinition||!this._isCurrentBranchReachable())return;this.errors.push(error)};_proto._isCurrentBranchReachable=function _isCurrentBranchReachable(){var _this_branchSemantics;var _this_branchSemantics_isBranchReachable;return(_this_branchSemantics_isBranchReachable=(_this_branchSemantics=this.branchSemantics)==null?void 0:_this_branchSemantics.isBranchReachable(this.symbolTableStack._currentBranch))!=null?_this_branchSemantics_isBranchReachable:true};_create_class(SemanticAnalyzer,[{key:\"shaderData\",get:function get(){return this._shaderData}},{key:\"macroDefineList\",get:function get(){return this._macroDefineList}},{key:\"currentFunctionHeader\",get:function get(){var _this__functionCaptures_;return(_this__functionCaptures_=this._functionCaptures[this._functionCaptures.length-1])==null?void 0:_this__functionCaptures_.header}}]);return SemanticAnalyzer}();var ShaderTargetParser=function(){function ShaderTargetParser(actionTable,gotoTable,grammar,branchSemantics,semanticDiagnostics,_source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled){if(semanticErrorsBlockCodegen===void 0)semanticErrorsBlockCodegen=false;if(authoringAnalysisEnabled===void 0)authoringAnalysisEnabled=semanticDiagnostics!==undefined;this._source=_source;this.semanticErrorsBlockCodegen=semanticErrorsBlockCodegen;this.blockingErrors=[];this._traceBackStack=[];this.actionTable=actionTable;this.gotoTable=gotoTable;this.grammar=grammar;this.semanticAnalyzer=new SemanticAnalyzer(branchSemantics,semanticDiagnostics,objectPool,authoringAnalysisEnabled)}var _proto=ShaderTargetParser.prototype;_proto.setSource=function setSource(source){var _this_semanticAnalyzer_semanticDiagnostics_setSource,_this_semanticAnalyzer_semanticDiagnostics;this._source=source;(_this_semanticAnalyzer_semanticDiagnostics=this.semanticAnalyzer.semanticDiagnostics)==null?void 0:(_this_semanticAnalyzer_semanticDiagnostics_setSource=_this_semanticAnalyzer_semanticDiagnostics.setSource)==null?void 0:_this_semanticAnalyzer_semanticDiagnostics_setSource.call(_this_semanticAnalyzer_semanticDiagnostics,source)};_proto.setSourceScopes=function setSourceScopes(sourceScopes){this.semanticAnalyzer.setSourceScopes(sourceScopes)};_proto.parse=function parse(tokens,macroDefineList){this.semanticAnalyzer.reset(macroDefineList);this.blockingErrors.length=0;var _this=this,traceBackStack=_this._traceBackStack,semanticAnalyzer=_this.semanticAnalyzer;traceBackStack.length=0;traceBackStack.push(0);try{var nextToken=tokens.next();while(true){var token=nextToken.value;var actionInfo=this.stateActionTable.get(token.type);if((actionInfo==null?void 0:actionInfo.action)===EAction.Shift){traceBackStack.push(token,actionInfo.target);if(token.type===Keyword.MACRO_DEFINE_PARAMS){semanticAnalyzer.pushScope();for(var _iterator=_create_for_of_iterator_helper_loose(ParserUtils.parseMacroParamList(token.lexeme)),_step;!(_step=_iterator()).done;){var p=_step.value;semanticAnalyzer.symbolTableStack.insert(new SymbolInfo(p,ESymbolType.VAR))}}if(semanticAnalyzer.semanticDiagnostics&&(token.type===Keyword.FOR||token.type===Keyword.WHILE)){semanticAnalyzer.pushScope()}nextToken=tokens.next()}else if((actionInfo==null?void 0:actionInfo.action)===EAction.Accept){semanticAnalyzer.acceptRule==null?void 0:semanticAnalyzer.acceptRule.call(semanticAnalyzer,semanticAnalyzer);semanticAnalyzer.finalizeInheritance();var program=semanticAnalyzer.semanticStack.pop();return program}else if((actionInfo==null?void 0:actionInfo.action)===EAction.Reduce){var target=actionInfo.target;var reduceProduction=this.grammar.getProductionByID(target);var translationRule=semanticAnalyzer.getTranslationRule(reduceProduction.id);var values=[];for(var i=reduceProduction.derivation.length-1;i>=0;i--){if(reduceProduction.derivation[i]===ETokenType.EPSILON)continue;traceBackStack.pop();var token1=traceBackStack.pop();if(_instanceof(token1,BaseToken)){values.unshift(token1)}else{var astNode=semanticAnalyzer.semanticStack.pop();values.unshift(astNode)}}translationRule==null?void 0:translationRule.apply(void 0,[].concat([semanticAnalyzer],values));if(semanticAnalyzer.semanticDiagnostics&&!semanticAnalyzer.diagnosticsEnabled&&reduceProduction.goal===NoneTerminal.iteration_statement){semanticAnalyzer.popScope()}var gotoTable=this.stateGotoTable;traceBackStack.push(reduceProduction.goal);var nextState=gotoTable.get(reduceProduction.goal);traceBackStack.push(nextState);continue}else{var _$error=ShaderCompilerUtils.createGSError(\"Unexpected token \"+token.lexeme,GSErrorName.CompilationError,this._source,token.location);this.semanticAnalyzer.errors.push(_$error);this.blockingErrors.push(_$error);return null}}}catch(error){if(!_instanceof(error,GSError)||error.name!==GSErrorName.ScannerError)throw error;this.semanticAnalyzer.errors.push(error);this.blockingErrors.push(error);return null}};ShaderTargetParser.create=function create(branchSemantics,semanticDiagnostics,source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled){if(semanticErrorsBlockCodegen===void 0)semanticErrorsBlockCodegen=false;if(authoringAnalysisEnabled===void 0)authoringAnalysisEnabled=semanticDiagnostics!==undefined;var tables=this._tables;if(!tables){var grammar=createGrammar();var generator=new LALR1(grammar);generator.generate();tables=this._tables={actionTable:generator.actionTable,gotoTable:generator.gotoTable,grammar:grammar}}var parser=new ShaderTargetParser(tables.actionTable,tables.gotoTable,tables.grammar,branchSemantics,semanticDiagnostics,source,objectPool,semanticErrorsBlockCodegen,authoringAnalysisEnabled);addTranslationRule(parser.semanticAnalyzer);return parser};_create_class(ShaderTargetParser,[{key:\"curState\",get:function get(){return this._traceBackStack[this._traceBackStack.length-1]}},{key:\"stateActionTable\",get:function get(){return this.actionTable.get(this.curState)}},{key:\"stateGotoTable\",get:function get(){return this.gotoTable.get(this.curState)}},{key:\"errors\",get:function get(){return this.semanticAnalyzer.errors}}]);return ShaderTargetParser}();var parsedShaderPassPayloads=new WeakMap;function createParsedShaderPass(data,vertexEntry,fragmentEntry,coreInfo){var pass=Object.freeze({});parsedShaderPassPayloads.set(pass,Object.freeze({data:data,vertexEntry:vertexEntry,fragmentEntry:fragmentEntry,coreInfo:coreInfo}));return pass}function getParsedShaderPassPayload(pass){var payload=parsedShaderPassPayloads.get(pass);if(!payload)throw new TypeError(\"Invalid parsed shader pass handle.\");return payload}var SHADER_ROOT_URL=\"shaders://root/\";var ABSOLUTE_URL_PATTERN$1=/^[A-Za-z][A-Za-z\\d+.-]*:/;function normalizeShaderSourceFile(sourceFile){if(!sourceFile)return undefined;var normalized=sourceFile.trim().replace(/\\\\/g,\"/\");if(!normalized)return undefined;if(normalized.startsWith(SHADER_ROOT_URL)){return normalized===SHADER_ROOT_URL?undefined:normalizeShaderIncludeKey(normalized)}if(!ABSOLUTE_URL_PATTERN$1.test(normalized)){return normalizeShaderIncludeKey(normalized)}return new URL(normalized).href}function normalizeShaderIncludeMap(includeMap){if(!includeMap)return Object.create(null);var inputKeysByCanonicalKey=Object.create(null);for(var _iterator=_create_for_of_iterator_helper_loose(Object.keys(includeMap)),_step;!(_step=_iterator()).done;){var inputKey=_step.value;var canonicalKey=normalizeShaderIncludeKey(inputKey);if(Object.prototype.hasOwnProperty.call(inputKeysByCanonicalKey,canonicalKey)){throw new Error('Shader include key collision after normalization: \"'+inputKey+'\" resolves to \"'+canonicalKey+'\".')}inputKeysByCanonicalKey[canonicalKey]=inputKey}return new Proxy(Object.create(null),{get:function get(_target,property){if(typeof property!==\"string\")return undefined;var inputKey=inputKeysByCanonicalKey[property];if(inputKey!==undefined){var source=includeMap[inputKey];return typeof source===\"string\"?source:undefined}var source1=includeMap[property];return typeof source1===\"string\"?source1:undefined}})}function shaderSourceBaseURL(sourceFile){if(!sourceFile)return\"\";if(!ABSOLUTE_URL_PATTERN$1.test(sourceFile)){return new URL(sourceFile,SHADER_ROOT_URL).href}return new URL(sourceFile).href}var PreprocessorMacroState=function(){function PreprocessorMacroState(){this._states=Object.create(null);this._versions=Object.create(null);this._frames=[];this._expressionContext={resolveIdentifier:function(){return{}},isDefined:function(){return undefined}};this.reachable=true}var _proto=PreprocessorMacroState.prototype;_proto.processDirective=function processDirective(directive,body){switch(directive){case\"if\":{var condition=this.reachable?this._evaluate(body):{value:undefined};return{keep:this._openConditional(condition),arm:this._arm(condition.value,[],condition),error:condition.error,errorStart:condition.errorStart,errorEnd:condition.errorEnd}}case\"ifdef\":{var condition1=this._definedCondition(body,true);return{keep:this._openConditional(condition1),arm:this._arm(condition1.value,[],condition1),error:condition1.error}}case\"ifndef\":{var condition2=this._definedCondition(body,false);return{keep:this._openConditional(condition2),arm:this._arm(condition2.value,[],condition2),error:condition2.error}}case\"elif\":return this._advanceConditional(body);case\"else\":return this._advanceElse();case\"endif\":return{keep:this._closeConditional()};case\"define\":{var keep=this.reachable;if(keep)this._define(body);return{keep:keep}}case\"undef\":{var keep1=this.reachable;if(keep1)this._undef(body);return{keep:keep1}}default:return{keep:this.reachable}}};_proto.captureSnapshot=function captureSnapshot(){return{states:PreprocessorMacroState._cloneStates(this._states),versions:Object.assign(Object.create(null),this._versions)}};_proto.createCachedState=function createCachedState(before){var names=new Set([].concat(Object.keys(before.states),Object.keys(this._states)));var mutatedNames=[];for(var _iterator=_create_for_of_iterator_helper_loose(names),_step;!(_step=_iterator()).done;){var name=_step.value;var _before_versions_name,_this__versions_name;if(((_before_versions_name=before.versions[name])!=null?_before_versions_name:0)!==((_this__versions_name=this._versions[name])!=null?_this__versions_name:0)){mutatedNames.push(name)}}return{snapshot:this.captureSnapshot(),mutatedNames:mutatedNames}};_proto.applyCachedState=function applyCachedState(cached){for(var _iterator=_create_for_of_iterator_helper_loose(cached.mutatedNames),_step;!(_step=_iterator()).done;){var name=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(this._frames),_step1;!(_step1=_iterator1()).done;){var frame=_step1.value;frame.mutatedNames.add(name)}}this._states=PreprocessorMacroState._cloneStates(cached.snapshot.states);this._versions=Object.assign(Object.create(null),cached.snapshot.versions);this._versionKey=undefined};_proto.cacheKey=function cacheKey(){var names=Object.keys(this._states).sort();var key=\"\";for(var i=0,n=names.length;i<n;i++){var name=names[i];var state=this._states[name];var defined=state.defined===undefined?\"?\":state.defined?\"1\":\"0\";var replacement=state.replacementKey;var _replacement_length;key+=name.length+\":\"+name+defined+(state.functionParams?\"f\":\"v\")+((_replacement_length=replacement==null?void 0:replacement.length)!=null?_replacement_length:\"?\")+\":\"+(replacement!=null?replacement:\"\")}return key+\"\\0\"+this._macroVersionKey()};_proto._openConditional=function _openConditional(condition){var parentReachable=this.reachable;var entryState=PreprocessorMacroState._cloneStates(this._states);var remainderState=PreprocessorMacroState._cloneStates(entryState);if(parentReachable&&condition.value===undefined){this._applyAssumption(this._states,condition.trueAssumption);this._applyAssumption(remainderState,condition.falseAssumption)}this._frames.push({parentReachable:parentReachable,remainderReachable:parentReachable&&condition.value!==true,remainderValue:condition.value===undefined?undefined:!condition.value,remainderConditions:this._appendCondition([],condition,true),hasElse:false,entryState:entryState,remainderState:remainderState,armStates:[],mutatedNames:new Set});this.reachable=parentReachable&&condition.value!==false;return parentReachable};_proto._advanceConditional=function _advanceConditional(body){var frame=this._frames[this._frames.length-1];if(!frame)return{keep:this.reachable};this._finishCurrentArm(frame);this._states=PreprocessorMacroState._cloneStates(frame.remainderState);if(frame.hasElse){this.reachable=false;return{keep:frame.parentReachable}}var keep=frame.remainderReachable;if(!keep){this.reachable=false;return{keep:false}}var condition=this._evaluate(body);var armValue=PreprocessorMacroState._and(frame.remainderValue,condition.value);var arm=this._arm(armValue,frame.remainderConditions,condition);frame.remainderConditions=this._appendCondition(frame.remainderConditions,condition,true);frame.remainderValue=PreprocessorMacroState._and(frame.remainderValue,condition.value===undefined?undefined:!condition.value);frame.remainderState=PreprocessorMacroState._cloneStates(this._states);if(condition.value===undefined){this._applyAssumption(this._states,condition.trueAssumption);this._applyAssumption(frame.remainderState,condition.falseAssumption)}this.reachable=condition.value!==false;if(condition.value===true)frame.remainderReachable=false;return{keep:true,arm:arm,error:condition.error,errorStart:condition.errorStart,errorEnd:condition.errorEnd}};_proto._advanceElse=function _advanceElse(){var frame=this._frames[this._frames.length-1];if(!frame)return{keep:this.reachable};this._finishCurrentArm(frame);this._states=PreprocessorMacroState._cloneStates(frame.remainderState);var keep=!frame.hasElse&&frame.remainderReachable;var armValue=frame.hasElse?false:frame.remainderValue;this.reachable=keep;frame.remainderReachable=false;frame.remainderValue=false;frame.hasElse=true;return{keep:keep,arm:{value:armValue,predicates:frame.remainderConditions}}};_proto._closeConditional=function _closeConditional(){var frame=this._frames.pop();if(!frame)return this.reachable;this._finishCurrentArm(frame);if(!frame.hasElse&&frame.remainderReachable){frame.armStates.push(PreprocessorMacroState._cloneStates(frame.remainderState))}this._states=this._mergeStates(frame);this.reachable=frame.parentReachable;return frame.parentReachable};_proto._finishCurrentArm=function _finishCurrentArm(frame){if(this.reachable)frame.armStates.push(PreprocessorMacroState._cloneStates(this._states))};_proto._mergeStates=function _mergeStates(frame){var _this,_loop=function(){var name=_step.value;var candidates=frame.armStates.map(function(state){return _this1._stateFrom(state,name)});var _candidates_;var first=(_candidates_=candidates[0])!=null?_candidates_:_this._stateFrom(frame.entryState,name);if(candidates.every(function(candidate){return PreprocessorMacroState._sameState(first,candidate)})){merged[name]=first;return\"continue\"}var defined=candidates.every(function(candidate){return candidate.defined===true})?true:candidates.every(function(candidate){return candidate.defined===false})?false:undefined;merged[name]={defined:defined}};var _this1=this;var merged=PreprocessorMacroState._cloneStates(frame.entryState);for(var _iterator=_create_for_of_iterator_helper_loose(frame.mutatedNames),_step;!(_step=_iterator()).done;)_this=this,_loop();return merged};_proto._define=function _define(body){var match=/^[ \\t]*([A-Za-z_]\\w*)([\\s\\S]*)$/.exec(body);if(!match)return;var name=match[1];var suffix=match[2];this._markMutation(name);var replacementKey=suffix.trim();if(suffix[0]===\"(\"){var closeParen=suffix.indexOf(\")\");if(closeParen<0){this._states[name]={defined:true,replacementKey:replacementKey};return}var params=suffix.slice(1,closeParen).split(\",\").map(function(param){return param.trim()}).filter(Boolean);this._states[name]={defined:true,replacementKey:replacementKey,functionParams:params,functionBody:suffix.slice(closeParen+1).trim()};return}this._states[name]={defined:true,replacementKey:replacementKey}};_proto._undef=function _undef(body){var _exec;var name=(_exec=/^[ \\t]*([A-Za-z_]\\w*)/.exec(body))==null?void 0:_exec[1];if(!name)return;this._markMutation(name);this._states[name]={defined:false}};_proto._markMutation=function _markMutation(name){var _this__versions_name;this._versions[name]=((_this__versions_name=this._versions[name])!=null?_this__versions_name:0)+1;this._versionKey=undefined;for(var i=0,n=this._frames.length;i<n;i++)this._frames[i].mutatedNames.add(name)};_proto._evaluate=function _evaluate(expression){var _this=this;var trimmedExpression=expression.trim();var unexpanded=parsePreprocessorExpression(trimmedExpression);var withDefinedValues=resolvePreprocessorDefinedOperators(trimmedExpression,function(name){return _this._state(name).defined});var expansion=expandPreprocessorExpressionMacros(withDefinedValues,function(name){return _this._state(name).defined===false?{body:\"0\"}:_this._macro(name)});if(expansion.error){return{value:undefined,error:expansion.error,errorStart:0,errorEnd:trimmedExpression.length}}var expandedExpression=resolvePreprocessorDefinedOperators(expansion.expression,function(name){return _this._state(name).defined});var parsed=parsePreprocessorExpression(expandedExpression);if(\"error\"in parsed){if(\"error\"in unexpanded&&unexpanded.error.certain){return{value:undefined,error:unexpanded.error.message,errorStart:unexpanded.error.start,errorEnd:unexpanded.error.end}}var error=parsed.error.certain||!parsed.hasExpandableIdentifier?expandedExpression===withDefinedValues?parsed.error.message:\"Invalid preprocessor expression after expanding source macros: \"+parsed.error.message:undefined;return{value:undefined,error:error,errorStart:0,errorEnd:trimmedExpression.length}}var evaluated=parsed.hasExpandableIdentifier?{value:undefined,error:undefined}:evaluatePartiallyKnownPreprocessorConditionResult(parsed.condition,this._expressionContext);var value=evaluated.value!==undefined&&!getPreprocessorConditionRange(parsed.condition)?undefined:evaluated.value;var assumptions=PreprocessorMacroState._conditionAssumptions(parsed.condition);return{value:value===undefined?undefined:value!==0,condition:value!==undefined?undefined:parsed.hasExpandableIdentifier?{kind:\"opaque\",identity:JSON.stringify([expandedExpression,this._macroVersionKey()])}:capturePreprocessorCondition(parsed.condition,this._versions),error:evaluated.error,errorStart:evaluated.error?0:undefined,errorEnd:evaluated.error?trimmedExpression.length:undefined,trueAssumption:assumptions==null?void 0:assumptions.trueAssumption,falseAssumption:assumptions==null?void 0:assumptions.falseAssumption}};_proto._definedCondition=function _definedCondition(body,whenDefined){var _exec;var name=(_exec=/^[ \\t]*([A-Za-z_]\\w*)/.exec(body))==null?void 0:_exec[1];if(!name||!this.reachable)return{value:undefined};var defined=this._state(name).defined;return{value:defined===undefined?undefined:defined===whenDefined,condition:capturePreprocessorCondition({t:whenDefined?\"def\":\"ndef\",m:name},this._versions),trueAssumption:{name:name,defined:whenDefined},falseAssumption:{name:name,defined:!whenDefined}}};_proto._arm=function _arm(value,preceding,condition){return{value:value,predicates:value===true?[]:this._appendCondition(preceding,condition)}};_proto._appendCondition=function _appendCondition(preceding,condition,negate){if(negate===void 0)negate=false;if(!preceding)return;if(condition.value!==undefined)return condition.value!==negate?preceding:undefined;if(!condition.condition)return;return[].concat(preceding,[{condition:condition.condition,negated:negate}])};_proto._macroVersionKey=function _macroVersionKey(){var _this=this;var _this__versionKey;return(_this__versionKey=this._versionKey)!=null?_this__versionKey:this._versionKey=JSON.stringify(Object.keys(this._versions).sort().map(function(name){return[name,_this._versions[name]]}))};_proto._applyAssumption=function _applyAssumption(states,assumption){if(!assumption)return;var current=this._stateFrom(states,assumption.name);states[assumption.name]=assumption.defined?_extends({},current,{defined:true}):{defined:false}};_proto._macro=function _macro(name){var state=this._state(name);if(state.defined!==true||state.replacementKey===undefined)return;var _state_functionBody;return state.functionParams?{body:(_state_functionBody=state.functionBody)!=null?_state_functionBody:\"\",parameters:state.functionParams}:{body:state.replacementKey}};_proto._state=function _state(name){return this._stateFrom(this._states,name)};_proto._stateFrom=function _stateFrom(states,name){var _states_name;return(_states_name=states[name])!=null?_states_name:{defined:undefined}};PreprocessorMacroState._cloneStates=function _cloneStates(states){var clone=Object.create(null);for(var name in states)clone[name]=states[name];return clone};PreprocessorMacroState._sameState=function _sameState(left,right){return left.defined===right.defined&&left.replacementKey===right.replacementKey&&!!left.functionParams===!!right.functionParams};PreprocessorMacroState._and=function _and(left,right){return left===false||right===false?false:left===true&&right===true?true:undefined};PreprocessorMacroState._conditionAssumptions=function _conditionAssumptions(condition){if(condition.t===\"def\"){return{trueAssumption:{name:condition.m,defined:true},falseAssumption:{name:condition.m,defined:false}}}if(condition.t===\"ndef\"){return{trueAssumption:{name:condition.m,defined:false},falseAssumption:{name:condition.m,defined:true}}}if(condition.t!==\"not\")return;var nested=this._conditionAssumptions(condition.c);return nested?{trueAssumption:nested.falseAssumption,falseAssumption:nested.trueAssumption}:undefined};return PreprocessorMacroState}();var SHADER_ROOT_PATH=\"shaders://root/\";var ABSOLUTE_URL_PATTERN=/^[A-Za-z][A-Za-z\\d+.-]*:/;var cachedMacroStates=new WeakMap;var expandedSegmentCounts=new WeakMap;var MAX_INCLUDE_DEPTH=128;var MAX_EXPANDED_SOURCE_LENGTH=8*1024*1024;var MAX_EXPANDED_SOURCE_SEGMENTS=65536;var Preprocessor=function(){function Preprocessor(){}Preprocessor.parse=function parse(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,sourceScopeStarts){var result=this.parseWithErrors(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,true,sourceScopeStarts);for(var _iterator=_create_for_of_iterator_helper_loose(result.errors),_step;!(_step=_iterator()).done;){var error=_step.value;Logger.error(error.toString())}return result.content};Preprocessor.parseWithErrors=function parseWithErrors(source,basePathForIncludeKey,includeMap,chunkOutputCache,sourceFile,trackSourceMap,sourceScopeStarts){if(trackSourceMap===void 0)trackSourceMap=true;try{return this._expand(source,basePathForIncludeKey,includeMap,chunkOutputCache,new Set,sourceFile,trackSourceMap,new PreprocessorMacroState,sourceScopeStarts,0)}catch(error){if(!_instanceof(error,GSError)||error.name!==GSErrorName.PreprocessorError)throw error;return{content:\"\",errors:[error],sourceMap:[],sourceScopes:[],conditionalArms:new Map}}};Preprocessor._expand=function _expand(source,basePathForIncludeKey,includeMap,chunkOutputCache,activeIncludePaths,sourceFile,trackSourceMap,macroState,sourceScopeStarts,inheritedSourceScope){var _this=this;var splices=[];var removed=0;var logicalSource=source.replace(/\\\\(?:\\r\\n|\\n|\\r)/g,function(text,offset){splices.push({offset:offset-removed,length:text.length,removed:removed+text.length});removed+=text.length;return\"\"});if(splices.length){var logicalScopeStarts=sourceScopeStarts==null?void 0:sourceScopeStarts.map(function(start){var removedBefore=0;for(var _iterator=_create_for_of_iterator_helper_loose(splices),_step;!(_step=_iterator()).done;){var splice=_step.value;removedBefore+=Math.min(splice.length,Math.max(0,start-splice.offset-removedBefore))}return start-removedBefore});sourceScopeStarts=logicalScopeStarts}var originalSource=source;source=logicalSource;var errors=[];var sourceMap=[];var sourceScopes=[];var conditionalArms=new Map;var parts=[];var sourceOffset=0;var generatedOffset=0;var segmentCount=0;var match;var directiveSource=this._maskDirectiveTrivia(source);var directiveReg=new RegExp(this._directiveReg.source,this._directiveReg.flags);var failExpansion=function(offset,message){throw _this._createPreprocessorError(originalSource,_this._physicalOffset(offset,splices),message,sourceFile)};var reserveExpansion=function(length,segments,offset){if(generatedOffset+length>MAX_EXPANDED_SOURCE_LENGTH){failExpansion(offset,\"Expanded shader source exceeds \"+MAX_EXPANDED_SOURCE_LENGTH+\" characters.\")}if(segmentCount+segments>MAX_EXPANDED_SOURCE_SEGMENTS){failExpansion(offset,\"Shader include expansion exceeds \"+MAX_EXPANDED_SOURCE_SEGMENTS+\" source segments.\")}segmentCount+=segments};reserveExpansion(0,splices.length,0);var currentScope;var appendScope=function(length,sourceScope){if(!(sourceScopeStarts==null?void 0:sourceScopeStarts.length)||!length)return;if((currentScope==null?void 0:currentScope.sourceScope)===sourceScope){currentScope.generatedEnd=generatedOffset+length}else{currentScope={generatedStart:generatedOffset,generatedEnd:generatedOffset+length,sourceScope:sourceScope};sourceScopes.push(currentScope)}};var appendSource=function(start,end,keep){while(start<end){var nextBoundary=_this._nextSourceScopeStart(start,end,sourceScopeStarts);var segmentEnd=nextBoundary!=null?nextBoundary:end;var originalText=source.slice(start,segmentEnd);var text=keep?originalText:_this._maskText(originalText);var sourceScope=_this._sourceScopeAt(start,sourceScopeStarts,inheritedSourceScope);reserveExpansion(text.length,1,start);parts.push(text);appendScope(text.length,sourceScope);if(trackSourceMap){sourceMap.push({generatedStart:generatedOffset,generatedEnd:generatedOffset+text.length,sourceStart:start,source:source,sourceFile:sourceFile,sourceScope:sourceScope})}generatedOffset+=text.length;start=segmentEnd}};while(match=directiveReg.exec(directiveSource)){var _errors;var _this__includePathReg_exec;appendSource(sourceOffset,match.index,macroState.reachable);var directive=match[1];var _match_;var directiveBody=(_match_=match[2])!=null?_match_:\"\";if(directive!==\"include\"){var result=macroState.processDirective(directive,this._stripLineComment(directiveBody));if(result.keep&&result.arm){var hashOffset=directiveSource.indexOf(\"#\",match.index)-match.index;conditionalArms.set(generatedOffset+hashOffset,result.arm)}if(result.error){var leadingWhitespace=directiveBody.length-directiveBody.trimStart().length;var expressionLength=directiveBody.trim().length;var expressionOffset=directiveReg.lastIndex-directiveBody.length+leadingWhitespace;var _result_errorStart;var expressionStart=expressionOffset+Math.min((_result_errorStart=result.errorStart)!=null?_result_errorStart:0,expressionLength);var _result_errorEnd;var expressionEnd=expressionOffset+Math.min((_result_errorEnd=result.errorEnd)!=null?_result_errorEnd:expressionLength,expressionLength);errors.push(this._createPreprocessorError(source,expressionStart,result.error,sourceFile,expressionEnd))}appendSource(match.index,directiveReg.lastIndex,result.keep);sourceOffset=directiveReg.lastIndex;continue}if(!macroState.reachable){appendSource(match.index,directiveReg.lastIndex,false);sourceOffset=directiveReg.lastIndex;continue}var includeName=(_this__includePathReg_exec=this._includePathReg.exec(directiveBody))==null?void 0:_this__includePathReg_exec[1];if(!includeName){errors.push(this._createPreprocessorError(source,match.index,\"Invalid shader include directive.\",sourceFile));sourceOffset=directiveReg.lastIndex;continue}var path=this._resolveIncludePath(includeName,basePathForIncludeKey);if(!path){errors.push(this._createPreprocessorError(source,match.index,'Invalid shader include path \"'+includeName+'\".',sourceFile));sourceOffset=directiveReg.lastIndex;continue}var chunk=includeMap[path];if(chunk===undefined){errors.push(this._createPreprocessorError(source,match.index,'Shader include \"'+path+'\" was not found.',sourceFile));sourceOffset=directiveReg.lastIndex;continue}if(activeIncludePaths.has(path)){errors.push(this._createPreprocessorError(source,match.index,'Shader include cycle detected at \"'+path+'\".',sourceFile));sourceOffset=directiveReg.lastIndex;continue}if(activeIncludePaths.size>=MAX_INCLUDE_DEPTH){failExpansion(match.index,\"Shader include nesting exceeds \"+MAX_INCLUDE_DEPTH+\" levels.\")}var inputMacroState=macroState.captureSnapshot();var includeSourceScope=this._sourceScopeAt(match.index,sourceScopeStarts,inheritedSourceScope);var cacheKey=(trackSourceMap?1:0)+\"\\0\"+path+\"\\0\"+macroState.cacheKey();var expanded=chunkOutputCache.get(cacheKey);var cachedState=expanded&&cachedMacroStates.get(expanded);if(!expanded||!cachedState){activeIncludePaths.add(path);expanded=this._expand(chunk,this._canonicalIncludeURL(path),includeMap,chunkOutputCache,activeIncludePaths,path,trackSourceMap,macroState,undefined,includeSourceScope);activeIncludePaths.delete(path);cachedMacroStates.set(expanded,macroState.createCachedState(inputMacroState));chunkOutputCache.set(cacheKey,expanded)}else{macroState.applyCachedState(cachedState)}var _expandedSegmentCounts_get;reserveExpansion(expanded.content.length,(_expandedSegmentCounts_get=expandedSegmentCounts.get(expanded))!=null?_expandedSegmentCounts_get:1,match.index);for(var _iterator=_create_for_of_iterator_helper_loose(expanded.conditionalArms),_step;!(_step=_iterator()).done;){var _step_value=_step.value,offset=_step_value[0],value=_step_value[1];conditionalArms.set(generatedOffset+offset,value)}parts.push(expanded.content);appendScope(expanded.content.length,includeSourceScope);if(trackSourceMap){for(var _iterator1=_create_for_of_iterator_helper_loose(expanded.sourceMap),_step1;!(_step1=_iterator1()).done;){var segment=_step1.value;sourceMap.push({generatedStart:generatedOffset+segment.generatedStart,generatedEnd:generatedOffset+segment.generatedEnd,sourceStart:segment.sourceStart,source:segment.source,sourceFile:segment.sourceFile,sourceScope:includeSourceScope})}}generatedOffset+=expanded.content.length;(_errors=errors).push.apply(_errors,[].concat(expanded.errors));sourceOffset=directiveReg.lastIndex}appendSource(sourceOffset,source.length,macroState.reachable);var result1={content:parts.join(\"\"),errors:errors,sourceMap:sourceMap,sourceScopes:sourceScopes,conditionalArms:conditionalArms};if(splices.length)this._restoreSplicedSource(result1,source,originalSource,sourceFile,splices);expandedSegmentCounts.set(result1,segmentCount);return result1};Preprocessor._restoreSplicedSource=function _restoreSplicedSource(result,source,originalSource,sourceFile,splices){var _loop=function(){var segment=_step.value;if(segment.source!==source||segment.sourceFile!==sourceFile){mappedSegments.push(segment);return\"continue\"}var start=segment.sourceStart;var end=start+segment.generatedEnd-segment.generatedStart;var append=function(partEnd){if(partEnd<=start)return;mappedSegments.push(_extends({},segment,{generatedStart:segment.generatedStart+start-segment.sourceStart,generatedEnd:segment.generatedStart+partEnd-segment.sourceStart,sourceStart:_this._physicalOffset(start,splices),source:originalSource}));start=partEnd};while(spliceIndex<splices.length&&splices[spliceIndex].offset<=start)spliceIndex++;while(spliceIndex<splices.length&&splices[spliceIndex].offset<end)append(splices[spliceIndex++].offset);append(end)};var _this=this;var mappedSegments=[];var spliceIndex=0;for(var _iterator=_create_for_of_iterator_helper_loose(result.sourceMap),_step;!(_step=_iterator()).done;)_loop();result.sourceMap=mappedSegments;result.errors=result.errors.map(function(error){if(error.source!==source||error.file!==sourceFile)return error;var location=error.location;var start=\"start\"in location?location.start.index:location.index;var end=\"end\"in location?location.end.index:start;return _this._createPreprocessorError(originalSource,_this._physicalOffset(start,splices),error.message,sourceFile,_this._physicalOffset(end,splices,end>start))});return result};Preprocessor._physicalOffset=function _physicalOffset(offset,splices,isEnd){if(isEnd===void 0)isEnd=false;var low=0;var high=splices.length;while(low<high){var middle=low+high>>>1;var seam=splices[middle].offset;if(seam<offset||!isEnd&&seam===offset)low=middle+1;else high=middle}return offset+(low?splices[low-1].removed:0)};Preprocessor._sourceScopeAt=function _sourceScopeAt(offset,scopeStarts,inheritedScope){if(!(scopeStarts==null?void 0:scopeStarts.length))return inheritedScope;var scope=0;for(var index=1;index<scopeStarts.length&&scopeStarts[index]<=offset;index++)scope=index;return scope};Preprocessor._nextSourceScopeStart=function _nextSourceScopeStart(offset,end,scopeStarts){if(!scopeStarts)return;for(var _iterator=_create_for_of_iterator_helper_loose(scopeStarts),_step;!(_step=_iterator()).done;){var start=_step.value;if(start>offset&&start<end)return start}};Preprocessor._maskDirectiveTrivia=function _maskDirectiveTrivia(source){return source.replace(/\\/\\/[^\\r\\n]*|\"[^\"\\r\\n]*\"|\\/\\*[\\s\\S]*?\\*\\//g,function(trivia){return trivia.startsWith(\"/*\")?trivia.replace(/[^\\r\\n]/g,\" \"):trivia})};Preprocessor._stripLineComment=function _stripLineComment(source){return source.replace(/\\/\\/.*$/,\"\")};Preprocessor._maskText=function _maskText(source){return source.replace(/[^\\r\\n]/g,\" \")};Preprocessor._resolveIncludePath=function _resolveIncludePath(includeName,basePathForIncludeKey){var basePath=includeName[0]===\".\"?basePathForIncludeKey||SHADER_ROOT_PATH:SHADER_ROOT_PATH;if(!ABSOLUTE_URL_PATTERN.test(includeName)&&basePath.startsWith(SHADER_ROOT_PATH)){return normalizeShaderIncludeKey(new URL(includeName,basePath).href)}try{var url=new URL(includeName,basePath);return normalizeShaderIncludeKey(url.href)}catch(e){return}};Preprocessor._canonicalIncludeURL=function _canonicalIncludeURL(path){return ABSOLUTE_URL_PATTERN.test(path)?new URL(path).href:new URL(path,SHADER_ROOT_PATH).href};Preprocessor._createPreprocessorError=function _createPreprocessorError(source,offset,message,file,endOffset){if(endOffset===void 0)endOffset=offset;var start=this._positionAt(source,offset);if(endOffset<=offset)return new GSError(GSErrorName.PreprocessorError,message,start,source,file);var range=new ShaderRange;range.set(start,this._positionAt(source,endOffset));return new GSError(GSErrorName.PreprocessorError,message,range,source,file)};Preprocessor._positionAt=function _positionAt(source,offset){var line=0;var lastBreak=-1;for(var i=0;i<offset;i++){var char=source.charCodeAt(i);if(char===10){line++;lastBreak=i}else if(char===13){lastBreak=i}}var position=new ShaderPosition;position.set(offset,line,offset-lastBreak-1);return position};return Preprocessor}();Preprocessor._includePathReg=/^[ \\t]*\"([^\"\\r\\n]+)\"[ \\t]*(?:(?:\\/\\/.*)|(?:\\/\\*.*\\*\\/[ \\t]*))?$/;Preprocessor._directiveReg=/^[ \\t]*#[ \\t]*(include|define|undef|if|ifdef|ifndef|elif|else|endif)\\b([^\\r\\n]*)/gm;var ShaderClueIR=function ShaderClueIR(program,source,sourceMap){if(sourceMap===void 0)sourceMap=[];this.program=program;this.source=source;this.sourceMap=sourceMap;this.shaderData=program.shaderData};function findUnsupportedStructOwnership(ownership,entries,roles,snapshots){var _loop=function(){var _loop=function(){var _loop=function(){var _loop=function(){var member=_step1.value;if(proveInheritanceBranchesCover([],selected.branchSignature.concat(member.branch))===true)return\"continue\";var declarations=member.declarations.filter(function(type){return structs.has(type)});if(!declarations.length)return\"continue\";members.push({declarations:declarations,field:member.field,branch:member.branch});if(targetRole&&declarations.some(function(type){return roles.get(type)===targetRole})&&target.propList.some(function(prop){return prop.ident.lexeme===member.field.lexeme}))referenced=true};var consumer=pending.pop();if(visited.has(consumer)||!consumer.astNode)return\"continue\";visited.add(consumer);var context=selected.branchSignature.concat(consumer.branchSignature);if(proveInheritanceBranchesCover([],context)===true)return\"continue\";var owner=ownership.declarations.get(consumer);var alternatives=owner?families.get(owner.group):[consumer];var replacements=alternatives.filter(function(candidate){return candidate.sourceScope>consumer.sourceScope});if(replacements.length&&proveInheritanceBranchesCover(replacements.map(function(candidate){return candidate.branchSignature}),context)===true)return\"continue\";var facts=references(consumer);for(var _iterator=_create_for_of_iterator_helper_loose(facts.symbols),_step;!(_step=_iterator()).done;){var dependency=_step.value;var _pending;var dependencyOwner=ownership.declarations.get(dependency);(_pending=pending).push.apply(_pending,[].concat(dependencyOwner?families.get(dependencyOwner.group):[dependency]))}if(facts.types.some(function(type){return structs.has(type)&&!roles.has(type)}))referenced=true;for(var _iterator1=_create_for_of_iterator_helper_loose(facts.members),_step1;!(_step1=_iterator1()).done;)_loop()},_loop1=function(){var _step_value=_step1.value,declarations=_step_value.declarations,field=_step_value.field,branch=_step_value.branch;for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var _loop=function(){var prop=_step2.value;var compatible=target.propList.filter(function(candidate){return compatibleProperty(prop,candidate)});if(roles.get(source)!==targetRole||proveInheritanceBranchesCover(compatible.map(function(candidate){return candidate.ident.branch}),selected.branchSignature.concat(branch,prop.ident.branch))!==true)unsupported.add(selected)};var source=_step.value;if(source===target)continue;var sourceProps=source.propList.filter(function(prop){return prop.ident.lexeme===field.lexeme});for(var _iterator1=_create_for_of_iterator_helper_loose(sourceProps),_step2;!(_step2=_iterator1()).done;)_loop()}};var selected=_step.value;var target=selected.astNode;var targetRole=roles.get(target);var visited=new Set;var pending=entries.slice();var members=[];var referenced=false;while(pending.length)_loop();if(!referenced)return\"continue\";for(var _iterator=_create_for_of_iterator_helper_loose(members),_step1;!(_step1=_iterator()).done;)_loop1()};var family=_step2.value;if(!_instanceof(family[0],StructSymbol))return\"continue\";var structs=new Set(family.map(function(symbol){return symbol.astNode}));for(var _iterator=_create_for_of_iterator_helper_loose(family),_step;!(_step=_iterator()).done;)_loop()};var families=new Map;var hasStructFamily=false;ownership.declarations.forEach(function(owner,symbol){if(_instanceof(symbol,StructSymbol))hasStructFamily=true;var _families_get;var family=(_families_get=families.get(owner.group))!=null?_families_get:[];family.push(symbol);families.set(owner.group,family)});if(!hasStructFamily)return[];var projectedMembers=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(snapshots),_step;!(_step=_iterator()).done;){var snapshot=_step.value;var _declarations;var _symbol_dataType;var node=snapshot.replacementMemberOwner;if(!node)continue;while(node&&!(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3))node=node.parent;var field=node==null?void 0:node.children[2];if(!_instanceof(field,BaseToken))continue;var declarations=[];var _symbol_dataType_structDeclarations;for(var _iterator1=_create_for_of_iterator_helper_loose(snapshot.symbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;(_declarations=declarations).push.apply(_declarations,[].concat((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]))}var _projectedMembers_get;var members=(_projectedMembers_get=projectedMembers.get(snapshot.reference))!=null?_projectedMembers_get:[];members.push({declarations:declarations,field:field,branch:snapshot.callSiteBranch});projectedMembers.set(snapshot.reference,members)}var unsupported=new Set;var referenceCache=new Map;var references=function(symbol){var facts=referenceCache.get(symbol);if(!facts){facts=collectReferences(symbol,projectedMembers);referenceCache.set(symbol,facts)}return facts};for(var _iterator2=_create_for_of_iterator_helper_loose(families.values()),_step2;!(_step2=_iterator2()).done;)_loop();return Array.from(unsupported)}function collectReferences(symbol,projectedMembers){var symbols=new Set(_instanceof(symbol,FnSymbol)?symbol.calledFunctions:[]);var types=new Set;var members=[];var pending=[symbol.astNode];var visited=new Set;while(pending.length){var node=pending.pop();if(visited.has(node))continue;visited.add(node);if(_instanceof(node,ASTNode.TypeSpecifier)){for(var _iterator=_create_for_of_iterator_helper_loose(node.structDeclarations),_step;!(_step=_iterator()).done;){var type=_step.value;types.add(type);pending.push(type)}}else if(_instanceof(node,ASTNode.VariableIdentifier)){var _members;var _projectedMembers_get;(_members=members).push.apply(_members,[].concat((_projectedMembers_get=projectedMembers.get(node))!=null?_projectedMembers_get:[]));for(var _iterator1=_create_for_of_iterator_helper_loose(node.resolvedSymbols()),_step1;!(_step1=_iterator1()).done;){var reference=_step1.value;if(_instanceof(reference,FnSymbol)||reference.isGlobalVariable)symbols.add(reference)}}else if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var declarations=expressionStructs(node.children[0]);if(declarations.length)members.push({declarations:declarations,field:node.children[2],branch:node._branch})}for(var _iterator2=_create_for_of_iterator_helper_loose(node.children),_step2;!(_step2=_iterator2()).done;){var child=_step2.value;if(_instanceof(child,TreeNode))pending.push(child)}}return{symbols:Array.from(symbols),types:Array.from(types),members:members}}function expressionStructs(node){if(_instanceof(node,ASTNode.VariableIdentifier)){var _result;var _symbol_dataType;var result=[];var _symbol_dataType_structDeclarations;for(var _iterator=_create_for_of_iterator_helper_loose(node.resolvedValueSymbols()),_step;!(_step=_iterator()).done;){var symbol=_step.value;(_result=result).push.apply(_result,[].concat((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]))}return result}if(_instanceof(node,ASTNode.FunctionCallGeneric)){var result1=[];var _node_fnSymbols;for(var _iterator1=_create_for_of_iterator_helper_loose((_node_fnSymbols=node.fnSymbols)!=null?_node_fnSymbols:node.fnSymbol?[node.fnSymbol]:[]),_step1;!(_step1=_iterator1()).done;){var symbol1=_step1.value;var _result1;var _symbol_dataType1;var _symbol_dataType_structDeclarations1;(_result1=result1).push.apply(_result1,[].concat((_symbol_dataType_structDeclarations1=(_symbol_dataType1=symbol1.dataType)==null?void 0:_symbol_dataType1.structDeclarations)!=null?_symbol_dataType_structDeclarations1:[]))}return result1}if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3&&_instanceof(node.children[2],BaseToken)){var result2=[];for(var _iterator2=_create_for_of_iterator_helper_loose(expressionStructs(node.children[0])),_step2;!(_step2=_iterator2()).done;){var type=_step2.value;for(var _iterator3=_create_for_of_iterator_helper_loose(type.propList),_step3;!(_step3=_iterator3()).done;){var prop=_step3.value;var _result2;if(prop.ident.lexeme===node.children[2].lexeme)(_result2=result2).push.apply(_result2,[].concat(prop.typeInfo.structDeclarations))}}return result2}var child=node.children[_instanceof(node.children[0],BaseToken)?1:0];return _instanceof(child,TreeNode)?expressionStructs(child):[]}function compatibleProperty(source,target){if(source.ident.lexeme!==target.ident.lexeme||source.typeInfo.type!==target.typeInfo.type||source.isFlat!==target.isFlat||source.mrtIndex!==target.mrtIndex)return false;var left=source.typeInfo.arraySpecifier;var right=target.typeInfo.arraySpecifier;if(!left||!right)return left===right;return left===right||left.size!==undefined&&left.size===right.size}var ShaderStructRole=function(ShaderStructRole){ShaderStructRole[\"Varying\"]=\"varying\";ShaderStructRole[\"Attribute\"]=\"attribute\";ShaderStructRole[\"Mrt\"]=\"mrt\";return ShaderStructRole}({});var ShaderCoreInfo=function(){function ShaderCoreInfo(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage){this.getDeclarationCoexistence=getDeclarationCoexistence;this.getBranchCoverage=getBranchCoverage;var symbolTable=ir.shaderData.symbolTable;var ownership=ir.shaderData.declarationOwnership;this.deferredDeclarationOwnership=ownership.declarations;var vertexFunctions=findFunctions(symbolTable,vertexEntry);var fragmentFunctions=findFunctions(symbolTable,fragmentEntry);this.vertexEntry=createEntryPointInfo(EShaderStage.VERTEX,vertexEntry,vertexFunctions,getDeclarationCoexistence,ownership);this.fragmentEntry=createEntryPointInfo(EShaderStage.FRAGMENT,fragmentEntry,fragmentFunctions,getDeclarationCoexistence,ownership);var mutableIO=createIOInfo();collectEntryIO(vertexFunctions,fragmentFunctions,mutableIO);this.roleConflicts=removeRoleConflicts(mutableIO);var roles=new Map;registerStructRoles(roles,mutableIO.attributeStructs,\"attribute\");registerStructRoles(roles,mutableIO.varyingStructs,\"varying\");registerStructRoles(roles,mutableIO.mrtStructs,\"mrt\");this.unsupportedDeferredDeclarations=ownership.unsupported.concat(findUnsupportedStructOwnership(ownership,vertexFunctions.concat(fragmentFunctions),roles,ir.shaderData.referenceResolutionSnapshots));deriveStructVariableRoles(symbolTable,vertexFunctions,fragmentFunctions,mutableIO,roles);this.io=mutableIO;this.outerGlobalMacroDeclarations=ir.shaderData.getOuterGlobalMacroDeclarations()}ShaderCoreInfo.create=function create(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage){if(getDeclarationCoexistence===void 0)getDeclarationCoexistence=getLexicalDeclarationCoexistence;if(getBranchCoverage===void 0)getBranchCoverage=getLexicalBranchCoverage;return new ShaderCoreInfo(ir,vertexEntry,fragmentEntry,getDeclarationCoexistence,getBranchCoverage)};return ShaderCoreInfo}();function createIOInfo(){return{attributeStructs:[],attributeList:[],varyingStructs:[],varyingList:[],mrtStructs:[],mrtList:[],structVariableRoles:new Map,vertexStructVariableRoles:new Map,fragmentStructVariableRoles:new Map}}function findFunctions(symbolTable,entry){var lookupSymbol=new SymbolInfo(\"\",null);lookupSymbol.set(entry,ESymbolType.FN);var functions=symbolTable.getSymbols(lookupSymbol,true,[]);functions.sort(function(left,right){return left.astNode.location.start.index-right.astNode.location.start.index});return functions}function createEntryPointInfo(stage,name,functions,getDeclarationCoexistence,ownership){var hasDefiniteAmbiguity=false;for(var i=0,n=functions.length;i<n&&!hasDefiniteAmbiguity;i++){for(var j=i+1;j<n;j++){if(isDeferredDeclarationPair(ownership,functions[i],functions[j]))continue;if(getDeclarationCoexistence(functions[i].branchSignature,functions[j].branchSignature)===\"coexist\"){hasDefiniteAmbiguity=true;break}}}return{stage:stage,name:name,functions:functions,hasDefiniteAmbiguity:hasDefiniteAmbiguity}}function appendStructs(declarations,structs,props,seen){for(var _iterator=_create_for_of_iterator_helper_loose(declarations),_step;!(_step=_iterator()).done;){var node=_step.value;var _props;if(seen.has(node))continue;seen.add(node);structs.push(node);(_props=props).push.apply(_props,[].concat(node.propList))}}function collectEntryIO(vertexFunctions,fragmentFunctions,io){var attributeStructs=new Set;var varyingStructs=new Set;var mrtStructs=new Set;for(var _iterator=_create_for_of_iterator_helper_loose(vertexFunctions),_step;!(_step=_iterator()).done;){var fn=_step.value;var _proto_parameterList_,_proto_parameterList;var proto=fn.astNode.protoType;if(typeof proto.returnType.type===\"string\"){appendStructs(proto.returnType.typeSpecifier.structDeclarations,io.varyingStructs,io.varyingList,varyingStructs)}var attributeType=(_proto_parameterList=proto.parameterList)==null?void 0:(_proto_parameterList_=_proto_parameterList[0])==null?void 0:_proto_parameterList_.typeInfo.type;if(typeof attributeType===\"string\"){appendStructs(proto.parameterList[0].typeInfo.structDeclarations,io.attributeStructs,io.attributeList,attributeStructs)}}for(var _iterator1=_create_for_of_iterator_helper_loose(fragmentFunctions),_step1;!(_step1=_iterator1()).done;){var fn1=_step1.value;var returnType=fn1.astNode.protoType.returnType.type;if(typeof returnType===\"string\"){appendStructs(fn1.astNode.protoType.returnType.typeSpecifier.structDeclarations,io.mrtStructs,io.mrtList,mrtStructs)}}}function removeRoleConflicts(io){var roles=new Map;var register=function(nodes,role){for(var _iterator=_create_for_of_iterator_helper_loose(nodes),_step;!(_step=_iterator()).done;){var node=_step.value;var _roles_get;var nodeRoles=(_roles_get=roles.get(node))!=null?_roles_get:[];if(nodeRoles.indexOf(role)===-1)nodeRoles.push(role);roles.set(node,nodeRoles)}};register(io.attributeStructs,\"attribute\");register(io.varyingStructs,\"varying\");register(io.mrtStructs,\"mrt\");var conflicts=[];var conflictingStructs=new Set;roles.forEach(function(structRoles,struct){if(structRoles.length>1){conflicts.push({struct:struct,roles:structRoles});conflictingStructs.add(struct)}});if(!conflictingStructs.size)return conflicts;var droppedProps=new Set;var filterStructs=function(structs){for(var index=structs.length-1;index>=0;index--){if(conflictingStructs.has(structs[index])){for(var _iterator=_create_for_of_iterator_helper_loose(structs[index].propList),_step;!(_step=_iterator()).done;){var prop=_step.value;droppedProps.add(prop)}structs.splice(index,1)}}};filterStructs(io.attributeStructs);filterStructs(io.varyingStructs);filterStructs(io.mrtStructs);var filterProps=function(props){for(var index=props.length-1;index>=0;index--){if(droppedProps.has(props[index]))props.splice(index,1)}};filterProps(io.attributeList);filterProps(io.varyingList);filterProps(io.mrtList);return conflicts}function deriveStructVariableRoles(symbolTable,vertexFunctions,fragmentFunctions,io,structRoles){var functionFacts=new Map;symbolTable.forEach(function(symbol){if(_instanceof(symbol,FnSymbol)){functionFacts.set(symbol,collectFunctionRoleFacts(symbol,structRoles,io.structVariableRoles))}else if(_instanceof(symbol,VarSymbol)&&symbol.isGlobalVariable){registerVariableRole(io.structVariableRoles,symbol,structRoles);registerVariableRole(io.vertexStructVariableRoles,symbol,structRoles);registerVariableRole(io.fragmentStructVariableRoles,symbol,structRoles)}});populateReachableFunctionVariables(io.vertexStructVariableRoles,vertexFunctions,functionFacts);populateReachableFunctionVariables(io.fragmentStructVariableRoles,fragmentFunctions,functionFacts)}function populateReachableFunctionVariables(target,entries,functionFacts){var visited=new Set;var pending=entries.slice();while(pending.length){var _pending;var fn=pending.pop();if(visited.has(fn))continue;visited.add(fn);var facts=functionFacts.get(fn);if(!facts)continue;for(var _iterator=_create_for_of_iterator_helper_loose(facts.variables),_step;!(_step=_iterator()).done;){var _step_value=_step.value,variable=_step_value.variable,role=_step_value.role;target.set(variable,role)}(_pending=pending).push.apply(_pending,[].concat(facts.callees))}}function collectFunctionRoleFacts(fn,roles,allVariableRoles){var _callees;var variables=[];var callees=[];var register=function(variable){var role=resolveVariableRole(variable,roles);if(!role)return;variables.push({variable:variable,role:role});allVariableRoles.set(variable,role)};var parameters=fn.astNode.protoType.parameterList;if(parameters){for(var _iterator=_create_for_of_iterator_helper_loose(parameters),_step;!(_step=_iterator()).done;){var parameter=_step.value;var parameterNode=parameter.astNode;if(_instanceof(parameterNode,ASTNode.ParameterDeclaration)&¶meterNode.symbol){register(parameterNode.symbol)}}}for(var _iterator1=_create_for_of_iterator_helper_loose(fn.localVariables),_step1;!(_step1=_iterator1()).done;){var variable=_step1.value;register(variable)}(_callees=callees).push.apply(_callees,[].concat(fn.calledFunctions));return{variables:variables,callees:callees}}function registerStructRoles(roles,structs,role){for(var _iterator=_create_for_of_iterator_helper_loose(structs),_step;!(_step=_iterator()).done;){var struct=_step.value;roles.set(struct,role)}}function registerVariableRole(target,variable,roles){var role=resolveVariableRole(variable,roles);if(role)target.set(variable,role)}function resolveVariableRole(variable,roles){var _variable_dataType;var resolvedRole;var _variable_dataType_structDeclarations;for(var _iterator=_create_for_of_iterator_helper_loose((_variable_dataType_structDeclarations=(_variable_dataType=variable.dataType)==null?void 0:_variable_dataType.structDeclarations)!=null?_variable_dataType_structDeclarations:[]),_step;!(_step=_iterator()).done;){var declaration=_step.value;var role=roles.get(declaration);if(!role||resolvedRole&&resolvedRole!==role)return;resolvedRole=role}return resolvedRole}var SIGNED_INT32_MIN=-0x80000000;var SIGNED_INT32_MAX=0x7fffffff;var MAX_BRANCH_PROOF_STATES=256;function areConditionsComplementary(left,right){if(!left||!right)return false;if(left.kind===\"constant\"||right.kind===\"constant\"){return left.kind===\"constant\"&&right.kind===\"constant\"&&left.value!==right.value}if(left.kind===\"expression\"||right.kind===\"expression\"){return left.kind===\"expression\"&&right.kind===\"expression\"&&sameExpression(left,right)&&left.negated!==right.negated}if(left.kind!==right.kind||left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"&&right.kind===\"defined\")return left.defined!==right.defined;if(left.kind!==\"comparison\"||right.kind!==\"comparison\")return false;if(hasExactIntegerValue(left)&&hasExactIntegerValue(right)){return complementaryConditionKey(left)===simpleConditionKey(right)}if(left.value!==right.value)return false;return left.operator===\"==\"&&right.operator===\"!=\"||left.operator===\"!=\"&&right.operator===\"==\"||left.operator===\">\"&&right.operator===\"<=\"||left.operator===\">=\"&&right.operator===\"<\"||left.operator===\"<\"&&right.operator===\">=\"||left.operator===\"<=\"&&right.operator===\">\"}function isConditionalChainExhaustive(constraints){for(var i=0,n=constraints.length;i<n;i++){var condition=constraints[i].condition;if((condition==null?void 0:condition.kind)===\"constant\"&&condition.value)return true;var _constraints_i_precedingConditions;if(condition&&isConditionImplied(condition,(_constraints_i_precedingConditions=constraints[i].precedingConditions)!=null?_constraints_i_precedingConditions:[]))return true;for(var j=0;j<i;j++){if(areConditionsComplementary(constraints[j].condition,condition))return true}}return false}function isBranchVisibleFrom(defBranch,callSiteBranch){var _loop=function(i,n){var constraint=defBranch[i];if(constraint.conditionalGroup!==undefined){var matchingArm=callSiteBranch.find(function(candidate){return candidate.conditionalGroup===constraint.conditionalGroup&&candidate.conditionalArm===constraint.conditionalArm});var otherArm=callSiteBranch.find(function(candidate){return candidate.conditionalGroup===constraint.conditionalGroup&&candidate.conditionalArm!==constraint.conditionalArm});if(otherArm)return{v:false};if(matchingArm)return\"continue\"}var required=getConstraintConditions(constraint);if(!constraint.condition&&required.length===0)return{v:false};for(var j=0,m=required.length;j<m;j++){if(!isConditionImplied(required[j],callConditions))return{v:false}}};if(!isBranchReachable(callSiteBranch)||!canBranchesOverlap(defBranch,callSiteBranch))return false;var callConditions=getConditions(callSiteBranch);for(var i=0,n=defBranch.length;i<n;i++){var _ret=_loop(i);if(_type_of(_ret)===\"object\")return _ret.v}return true}function canDeclarationsCoexist(earlier,later){return getDeclarationCoexistence(earlier,later)!==\"exclusive\"}function getDeclarationCoexistence(earlier,later){if(!canBranchesOverlap(earlier,later))return\"exclusive\";for(var i=0,n=earlier.length;i<n;i++){var left=earlier[i];if(left.defined||!left.selfGuarding)continue;for(var j=0,m=later.length;j<m;j++){var right=later[j];if(!right.defined&&right.name===left.name&&left.conditionalGroup!==undefined&&right.conditionalGroup!==undefined&&right.conditionalGroup>left.conditionalGroup){if(!hasCompatibleGuardUndef(earlier,left,later,right))return\"exclusive\"}}}if(hasUnresolvedCondition(earlier)||hasUnresolvedCondition(later))return\"unknown\";var conditions=getConditions(earlier);appendConditions(later,conditions);var satisfiability=getConditionConjunctionSatisfiability(conditions);return satisfiability===\"satisfiable\"?\"coexist\":satisfiability===\"unsatisfiable\"?\"exclusive\":\"unknown\"}function hasUnresolvedCondition(branch){return branch.some(function(constraint){var _constraint_precedingConditions;var _constraint_precedingConditions_length;return!constraint.condition&&((_constraint_precedingConditions_length=(_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.length)!=null?_constraint_precedingConditions_length:0)===0})}function isBranchReachable(branch){return getBranchReachability(branch)!==\"unreachable\"}function getBranchReachability(branch){for(var i=0,n=branch.length;i<n;i++){var left=branch[i];if(left.conditionalGroup===undefined)continue;for(var j=i+1;j<n;j++){var right=branch[j];if(right.conditionalGroup===left.conditionalGroup&&right.conditionalArm!==left.conditionalArm){return\"unreachable\"}}}if(hasUnresolvedCondition(branch))return\"unknown\";var satisfiability=getConditionConjunctionSatisfiability(getConditions(branch));return satisfiability===\"satisfiable\"?\"reachable\":satisfiability===\"unsatisfiable\"?\"unreachable\":\"unknown\"}function areConditionsReachable(conditions){for(var i=0,n=conditions.length;i<n;i++){var condition=conditions[i];if(condition.kind===\"constant\"&&!condition.value)return false;for(var j=i+1;j<n;j++){if(areConditionsMutuallyExclusive(conditions[i],conditions[j]))return false}}return getConditionConjunctionSatisfiability(conditions)!==\"unsatisfiable\"}function getConditionConjunctionSatisfiability(conditions,budget){if(budget===void 0)budget={remaining:MAX_BRANCH_PROOF_STATES};if(--budget.remaining<0)return\"unknown\";var expressionIndex=conditions.findIndex(function(condition){return condition.kind===\"expression\"});if(expressionIndex<0){return conditions.every(hasExactIntegerValue)?isAtomicConjunctionSatisfiable(conditions)?\"satisfiable\":\"unsatisfiable\":\"unknown\"}var expression=conditions[expressionIndex];if(expression.opaque)return\"unknown\";var remaining=conditions.slice();remaining.splice(expressionIndex,1);var operands=expression.negated?expression.operands.map(negateCondition):expression.operands;var operator=expression.negated?expression.operator===\"&&\"?\"||\":\"&&\":expression.operator;if(operator===\"&&\")return getConditionConjunctionSatisfiability([].concat(remaining,operands),budget);var sawUnknown=false;for(var i=0,n=operands.length;i<n;i++){var result=getConditionConjunctionSatisfiability([].concat(remaining,[operands[i]]),budget);if(result===\"satisfiable\")return result;if(result===\"unknown\")sawUnknown=true}return sawUnknown?\"unknown\":\"unsatisfiable\"}function canBranchesOverlap(left,right){for(var i=0,n=left.length;i<n;i++){var leftConstraint=left[i];for(var j=0,m=right.length;j<m;j++){var rightConstraint=right[j];if(leftConstraint.conditionalGroup!==undefined&&leftConstraint.conditionalGroup===rightConstraint.conditionalGroup&&leftConstraint.conditionalArm!==rightConstraint.conditionalArm){return false}}}var conditions=getConditions(left);appendConditions(right,conditions);return areConditionsReachable(conditions)}function canBranchesCoverCallsite(candidates,callSiteBranch){return getBranchCoverage(candidates,callSiteBranch)===\"covered\"}function getBranchCoverage(candidates,callSiteBranch){var _loop=function(i,n){var candidate=normalizedCandidates[i];if(!uniqueCandidates.some(function(existing){return sameBranch(existing,candidate)}))uniqueCandidates.push(candidate)};var normalizedCandidates=candidates.map(removeSelfGuardingConstraints);var normalizedCallsite=removeSelfGuardingConstraints(callSiteBranch);if(canCandidateSetCoverCallsite(normalizedCandidates,normalizedCallsite))return\"covered\";var uniqueCandidates=[];for(var i=0,n=normalizedCandidates.length;i<n;i++)_loop(i);uniqueCandidates.sort(compareBranchSourceOrder);return hasAtomicCoverageCounterexample(uniqueCandidates,normalizedCallsite)?\"uncovered\":\"unknown\"}function compareBranchSourceOrder(left,right){var length=Math.min(left.length,right.length);for(var i=0;i<length;i++){var _left_i_conditionalGroup;var leftGroup=(_left_i_conditionalGroup=left[i].conditionalGroup)!=null?_left_i_conditionalGroup:Number.MAX_SAFE_INTEGER;var _right_i_conditionalGroup;var rightGroup=(_right_i_conditionalGroup=right[i].conditionalGroup)!=null?_right_i_conditionalGroup:Number.MAX_SAFE_INTEGER;if(leftGroup!==rightGroup)return leftGroup-rightGroup;var _left_i_conditionalArm;var leftArm=(_left_i_conditionalArm=left[i].conditionalArm)!=null?_left_i_conditionalArm:Number.MAX_SAFE_INTEGER;var _right_i_conditionalArm;var rightArm=(_right_i_conditionalArm=right[i].conditionalArm)!=null?_right_i_conditionalArm:Number.MAX_SAFE_INTEGER;if(leftArm!==rightArm)return leftArm-rightArm}return left.length-right.length}function hasAtomicCoverageCounterexample(candidates,callSiteBranch){if(candidates.length===0)return false;if(candidates.every(function(candidate){return!canBranchesOverlap(candidate,callSiteBranch)}))return true;if(!hasOnlyAtomicConditions(callSiteBranch)||candidates.some(function(candidate){return!hasOnlyAtomicConditions(candidate)})){return false}var counterexampleFacts=getConditions(callSiteBranch);if(!isAtomicConjunctionSatisfiable(counterexampleFacts))return false;for(var i=0,n=candidates.length;i<n;i++){var candidateConditions=getConditions(candidates[i]);if(!isAtomicConjunctionSatisfiable([].concat(counterexampleFacts,candidateConditions)))continue;var excluded=false;for(var j=0,m=candidateConditions.length;j<m;j++){var negated=negateCondition(candidateConditions[j]);if(isAtomicConjunctionSatisfiable([].concat(counterexampleFacts,[negated]))){counterexampleFacts.push(negated);excluded=true;break}}if(!excluded)return false}return true}function hasOnlyAtomicConditions(branch){for(var i=0,n=branch.length;i<n;i++){var _constraint_condition;var constraint=branch[i];var preceding=constraint.precedingConditions;if(!constraint.condition&&!(preceding==null?void 0:preceding.length))return false;if(((_constraint_condition=constraint.condition)==null?void 0:_constraint_condition.kind)===\"expression\")return false;if(constraint.condition&&!hasExactIntegerValue(constraint.condition))return false;if(preceding==null?void 0:preceding.some(function(condition){return condition.kind===\"expression\"}))return false;if(preceding==null?void 0:preceding.some(function(condition){return!hasExactIntegerValue(condition)}))return false}return true}function hasExactIntegerValue(condition){return condition.kind!==\"comparison\"||Number.isInteger(condition.value)&&condition.value>=SIGNED_INT32_MIN&&condition.value<=SIGNED_INT32_MAX}function isAtomicConjunctionSatisfiable(conditions){var _loop=function(){var state=_step.value;if(state.defined===false){if(state.comparisons.some(function(comparison){return!matchesComparison(0,comparison)}))return{v:false};return\"continue\"}var exact=void 0;var minimum=SIGNED_INT32_MIN;var maximum=SIGNED_INT32_MAX;var excluded=new Set;for(var i=0,n=state.comparisons.length;i<n;i++){var comparison=state.comparisons[i];if(comparison.operator===\"==\"){if(exact!==undefined&&exact!==comparison.value)return{v:false};exact=comparison.value}else if(comparison.operator===\"!=\"){excluded.add(comparison.value)}else{var candidateLower=lowerBound(comparison);if(candidateLower){minimum=Math.max(minimum,candidateLower.value+(candidateLower.inclusive?0:1))}var candidateUpper=upperBound(comparison);if(candidateUpper){maximum=Math.min(maximum,candidateUpper.value-(candidateUpper.inclusive?0:1))}}}if(exact!==undefined){if(excluded.has(exact))return{v:false};if(state.comparisons.some(function(comparison){return!matchesComparison(exact,comparison)}))return{v:false};return\"continue\"}if(minimum>maximum)return{v:false};if(Number.isFinite(minimum)&&Number.isFinite(maximum)){var excludedInRange=0;for(var _iterator=_create_for_of_iterator_helper_loose(excluded),_step1;!(_step1=_iterator()).done;){var value=_step1.value;if(value>=minimum&&value<=maximum)excludedInRange++}if(maximum-minimum+1<=excludedInRange)return{v:false}}};var states=new Map;for(var i=0,n=conditions.length;i<n;i++){var condition=conditions[i];if(condition.kind===\"constant\"){if(!condition.value)return false;continue}if(condition.kind===\"expression\")return false;var key=condition.name+\":\"+condition.version;var _states_get;var state=(_states_get=states.get(key))!=null?_states_get:{comparisons:[]};states.set(key,state);if(condition.kind===\"defined\"){if(state.defined!==undefined&&state.defined!==condition.defined)return false;state.defined=condition.defined}else{state.comparisons.push(condition)}}for(var _iterator=_create_for_of_iterator_helper_loose(states.values()),_step;!(_step=_iterator()).done;){var _ret=_loop();if(_type_of(_ret)===\"object\")return _ret.v}return true}function removeSelfGuardingConstraints(branch){return branch.some(function(constraint){return constraint.selfGuarding})?branch.filter(function(constraint){return!constraint.selfGuarding}):branch}function canCandidateSetCoverCallsite(candidates,callSiteBranch,memo){var _loop=function(){var _loop=function(arm){var _representative_conditionalReachableArms;var _representative_conditionalReachableArms_arm;var armReachable=(_representative_conditionalReachableArms_arm=representative==null?void 0:(_representative_conditionalReachableArms=representative.conditionalReachableArms)==null?void 0:_representative_conditionalReachableArms[arm])!=null?_representative_conditionalReachableArms_arm:true;if(!armReachable)return\"continue\";var armCandidates=compatible.filter(function(candidate){var _candidate_find;return((_candidate_find=candidate.find(function(constraint){return constraint.conditionalGroup===group}))==null?void 0:_candidate_find.conditionalArm)===arm}).map(function(candidate){return removeConditionalGroup(candidate,group)});if(!armCandidates.length){everyArmHasCandidates=false;return\"break\"}candidatesByArm.push(armCandidates)};var group=_step.value;var callSiteConstraint=callSiteBranch.find(function(constraint){return constraint.conditionalGroup===group});if((callSiteConstraint==null?void 0:callSiteConstraint.conditionalArm)!==undefined){var inCurrentArm=compatible.filter(function(candidate){var _candidate_find;return((_candidate_find=candidate.find(function(constraint){return constraint.conditionalGroup===group}))==null?void 0:_candidate_find.conditionalArm)===callSiteConstraint.conditionalArm}).map(function(candidate){return removeConditionalGroup(candidate,group)});if(inCurrentArm.length&&canCandidateSetCoverCallsite(inCurrentArm,removeConditionalGroup(callSiteBranch,group),memo)){memo.results.set(key,true);return{v:true}}return\"continue\"}var representative=compatible.map(function(candidate){return candidate.find(function(constraint){return constraint.conditionalGroup===group})}).find(function(constraint){return(constraint==null?void 0:constraint.conditionalArmCount)!==undefined});var armCount=representative==null?void 0:representative.conditionalArmCount;if(armCount===undefined)return\"continue\";var candidatesByArm=[];var everyArmHasCandidates=true;for(var arm=0;arm<armCount;arm++){var _ret=_loop(arm);if(_ret===\"break\")break}if(everyArmHasCandidates&&candidatesByArm.every(function(armCandidates){return canCandidateSetCoverCallsite(armCandidates,callSiteBranch,memo)})){memo.results.set(key,true);return{v:true}}};if(!isBranchReachable(callSiteBranch))return true;var compatible=candidates.filter(function(candidate){return canBranchesOverlap(candidate,callSiteBranch)});for(var i=0,n=compatible.length;i<n;i++){if(isBranchVisibleFrom(compatible[i],callSiteBranch))return true}var groups=new Set;for(var i1=0,n1=compatible.length;i1<n1;i1++){var candidate=compatible[i1];for(var j=0,m=candidate.length;j<m;j++){var constraint=candidate[j];if(constraint.conditionalComplete&&constraint.conditionalGroup!==undefined&&constraint.conditionalArmCount!==undefined){groups.add(constraint.conditionalGroup)}}}if(!groups.size)return canComplementarySimpleCandidatesCoverCallsite(compatible,callSiteBranch);memo!=null?memo:memo={constraints:new Map,results:new Map};var key=coverageStateKey(compatible,callSiteBranch,memo.constraints);var cached=memo.results.get(key);if(cached!==undefined)return cached;var commonGroup=findIndependentCommonGroup(compatible,callSiteBranch);for(var _iterator=_create_for_of_iterator_helper_loose(commonGroup===undefined?groups:[commonGroup]),_step;!(_step=_iterator()).done;){var _ret=_loop();if(_type_of(_ret)===\"object\")return _ret.v}var covered=canComplementarySimpleCandidatesCoverCallsite(compatible,callSiteBranch);memo.results.set(key,covered);return covered}function coverageStateKey(candidates,callSiteBranch,constraints){return[].concat([callSiteBranch],candidates).map(function(branch){return branch.map(function(constraint){var id=constraints.get(constraint);if(id===undefined)constraints.set(constraint,id=constraints.size);return id}).join(\",\")}).join(\";\")}function findIndependentCommonGroup(candidates,callSiteBranch){var _candidates__find,_candidates_;if(callSiteBranch.length)return;var groups=new Map;var macros=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(candidates),_step;!(_step=_iterator()).done;){var candidate=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(candidate),_step1;!(_step1=_iterator1()).done;){var constraint=_step1.value;var _constraint_conditionalReachableArms;var group=constraint.conditionalGroup;var conditions=getConstraintConditions(constraint);var condition=conditions[0];if(group===undefined||!constraint.conditionalComplete||constraint.conditionalArmCount!==2||constraint.conditionalArm!==0&&constraint.conditionalArm!==1||((_constraint_conditionalReachableArms=constraint.conditionalReachableArms)==null?void 0:_constraint_conditionalReachableArms.some(function(reachable){return!reachable}))||conditions.length!==1||condition.kind!==\"defined\"&&condition.kind!==\"comparison\"||!hasExactIntegerValue(condition)){return}var macro=condition.name+\":\"+condition.version;var arm0Condition=constraint.conditionalArm===0?condition:negateCondition(condition);var existing=groups.get(group);if(existing&&(existing.macro!==macro||!sameCondition(existing.condition,arm0Condition))||macros.has(macro)&¯os.get(macro)!==group){return}groups.set(group,{macro:macro,condition:arm0Condition});macros.set(macro,group)}}return(_candidates_=candidates[0])==null?void 0:(_candidates__find=_candidates_.find(function(constraint){return candidates.every(function(candidate){return candidate.some(function(arm){return arm.conditionalGroup===constraint.conditionalGroup})})}))==null?void 0:_candidates__find.conditionalGroup}function canComplementarySimpleCandidatesCoverCallsite(candidates,callSiteBranch){var seen=new Set;for(var i=0,n=candidates.length;i<n;i++){var candidate=candidates[i];for(var j=0,m=candidate.length;j<m;j++){var _constraint_precedingConditions;var constraint=candidate[j];var condition=constraint.condition;if(!condition||((_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.length))continue;var remaining=[].concat(candidate.slice(0,j),candidate.slice(j+1));if(!isBranchVisibleFrom(remaining,callSiteBranch))continue;var remainderKey=branchKey(remaining);var conditionKey=simpleConditionKey(condition);var complementKey=complementaryConditionKey(condition);if(complementKey&&seen.has(remainderKey+\"|\"+complementKey))return true;seen.add(remainderKey+\"|\"+conditionKey)}}return false}function removeConditionalGroup(branch,group){return branch.filter(function(constraint){return constraint.conditionalGroup!==group})}function branchKey(branch){return branch.map(function(constraint){var _constraint_precedingConditions;return[constraint.name,constraint.defined,simpleConditionKey(constraint.condition),(_constraint_precedingConditions=constraint.precedingConditions)==null?void 0:_constraint_precedingConditions.map(simpleConditionKey).join(\",\")]}).join(\"|\")}function simpleConditionKey(condition){if(!condition)return\"\";if(condition.kind===\"constant\")return\"constant:\"+condition.value;if(condition.kind===\"defined\")return\"defined:\"+condition.name+\":\"+condition.version+\":\"+condition.defined;if(condition.kind===\"expression\"){return\"expression:\"+condition.expression+\":\"+condition.names.map(function(name,i){return name+\":\"+condition.versions[i]}).join(\",\")+\":\"+condition.negated}var normalized=normalizeIntegerComparison(condition);return\"comparison:\"+normalized.name+\":\"+normalized.version+\":\"+normalized.operator+\":\"+normalized.value}function complementaryConditionKey(condition){if(condition.kind===\"constant\")return\"constant:\"+!condition.value;if(condition.kind===\"defined\")return\"defined:\"+condition.name+\":\"+condition.version+\":\"+!condition.defined;if(condition.kind===\"expression\"){return\"expression:\"+condition.expression+\":\"+condition.names.map(function(name,i){return name+\":\"+condition.versions[i]}).join(\",\")+\":\"+!condition.negated}if(!hasExactIntegerValue(condition)){var operator=condition.operator===\"==\"?\"!=\":condition.operator===\"!=\"?\"==\":condition.operator===\">\"?\"<=\":condition.operator===\">=\"?\"<\":condition.operator===\"<\"?\">=\":\">\";return\"comparison:\"+condition.name+\":\"+condition.version+\":\"+operator+\":\"+condition.value}var normalized=normalizeIntegerComparison(condition);var operator1=normalized.operator===\"==\"?\"!=\":normalized.operator===\"!=\"?\"==\":normalized.operator===\">=\"?\"<=\":\">=\";var value=normalized.operator===\">=\"?normalized.value-1:normalized.operator===\"<=\"?normalized.value+1:normalized.value;return\"comparison:\"+normalized.name+\":\"+normalized.version+\":\"+operator1+\":\"+value}function normalizeIntegerComparison(condition){if(!hasExactIntegerValue(condition))return condition;if(condition.operator===\">\")return _extends({},condition,{operator:\">=\",value:condition.value+1});if(condition.operator===\"<\")return _extends({},condition,{operator:\"<=\",value:condition.value-1});return condition}function hasCompatibleGuardUndef(earlier,earlierGuard,later,laterGuard){var events=laterGuard.guardUndefBranches;if(!events)return false;var _earlierGuard_guardUndefStart;var start=(_earlierGuard_guardUndefStart=earlierGuard.guardUndefStart)!=null?_earlierGuard_guardUndefStart:0;var _laterGuard_guardUndefStart;var end=(_laterGuard_guardUndefStart=laterGuard.guardUndefStart)!=null?_laterGuard_guardUndefStart:0;for(var i=start;i<end;i++){var event=events[i];if(canBranchesOverlap(earlier,event)&&canBranchesOverlap(event,later))return true}return false}function getConditions(branch){var conditions=[];appendConditions(branch,conditions);return conditions}function appendConditions(branch,conditions){for(var i=0,n=branch.length;i<n;i++){var constraint=branch[i];var preceding=constraint.precedingConditions;if(preceding){for(var j=0,m=preceding.length;j<m;j++)conditions.push(preceding[j])}if(constraint.condition)conditions.push(constraint.condition)}}function getConstraintConditions(constraint){var conditions=constraint.precedingConditions?[].concat(constraint.precedingConditions):[];if(constraint.condition)conditions.push(constraint.condition);return conditions}function isConditionImplied(required,facts){if(required.kind===\"constant\")return required.value;if(facts.some(function(fact){return sameCondition(fact,required)}))return true;if(required.kind===\"expression\"){if(required.opaque)return false;if(!required.negated&&required.operator===\"&&\"){if(required.operands.every(function(operand){return isConditionImplied(operand,facts)}))return true}if(!required.negated&&required.operator===\"||\"){if(required.operands.some(function(operand){return isConditionImplied(operand,facts)}))return true}if(required.negated&&required.operator===\"||\"){if(required.operands.every(function(operand){return isConditionImplied(negateCondition(operand),facts)}))return true}if(required.negated&&required.operator===\"&&\"){if(required.operands.some(function(operand){return isConditionImplied(negateCondition(operand),facts)}))return true}return facts.length>1&&doDefinedBooleanFactsImply(required,facts)}for(var i=0,n=facts.length;i<n;i++){var fact=facts[i];if(fact.kind===\"constant\")continue;if(fact.kind===\"expression\"){if(expressionImpliesCondition(fact,required))return true;continue}if(fact.name!==required.name||fact.version!==required.version)continue;if(conditionImplies(fact,required))return true}return facts.length>1&&doDefinedBooleanFactsImply(required,facts)}function doDefinedBooleanFactsImply(required,facts){var known=[];var changed=true;while(changed){changed=false;for(var i=0,n=facts.length;i<n;i++){var simplified=simplifyDefinedBooleanCondition(facts[i],known);if(simplified.kind===\"constant\"&&!simplified.value)return true;changed=collectGuaranteedDefinedFacts(simplified,known)||changed}}var simplifiedRequired=simplifyDefinedBooleanCondition(required,known);return simplifiedRequired.kind===\"constant\"&&simplifiedRequired.value}function collectGuaranteedDefinedFacts(condition,known){if(condition.kind===\"constant\"||condition.kind===\"comparison\")return false;if(condition.kind===\"defined\"){if(known.some(function(candidate){return sameCondition(candidate,condition)}))return false;known.push(condition);return true}if(condition.opaque)return false;if(!condition.negated&&condition.operator===\"&&\"){return condition.operands.reduce(function(changed,operand){return collectGuaranteedDefinedFacts(operand,known)||changed},false)}if(condition.negated&&condition.operator===\"||\"){return condition.operands.reduce(function(changed,operand){return collectGuaranteedDefinedFacts(negateCondition(operand),known)||changed},false)}return false}function simplifyDefinedBooleanCondition(condition,known){if(condition.kind===\"constant\"||condition.kind===\"comparison\")return condition;if(condition.kind===\"defined\"){if(known.some(function(candidate){return sameCondition(candidate,condition)}))return{kind:\"constant\",value:true};if(known.some(function(candidate){return areConditionsComplementary(candidate,condition)})){return{kind:\"constant\",value:false}}return condition}if(condition.opaque)return condition;var operands=condition.operands.map(function(operand){return simplifyDefinedBooleanCondition(operand,known)});var hasTrue=operands.some(function(operand){return operand.kind===\"constant\"&&operand.value});var hasFalse=operands.some(function(operand){return operand.kind===\"constant\"&&!operand.value});var remaining=operands.filter(function(operand){return operand.kind!==\"constant\"});var innerValue=condition.operator===\"&&\"?hasFalse?false:remaining.length===0?true:undefined:hasTrue?true:remaining.length===0?false:undefined;if(innerValue!==undefined)return{kind:\"constant\",value:condition.negated?!innerValue:innerValue};if(!condition.negated&&remaining.length===1)return remaining[0];return _extends({},condition,{operands:remaining})}function expressionImpliesCondition(fact,required){if(fact.opaque)return false;if(!fact.negated&&fact.operator===\"&&\"){return fact.operands.some(function(operand){return isConditionImplied(required,[operand])})}if(!fact.negated&&fact.operator===\"||\"){return fact.operands.every(function(operand){return isConditionImplied(required,[operand])})}if(fact.negated&&fact.operator===\"||\"){return fact.operands.some(function(operand){return isConditionImplied(required,[negateCondition(operand)])})}if(fact.negated&&fact.operator===\"&&\"){return fact.operands.every(function(operand){return isConditionImplied(required,[negateCondition(operand)])})}return false}function negateCondition(condition){if(condition.kind===\"constant\")return{kind:\"constant\",value:!condition.value};if(condition.kind===\"defined\")return _extends({},condition,{defined:!condition.defined});if(condition.kind===\"expression\")return _extends({},condition,{negated:!condition.negated});switch(condition.operator){case\"==\":return _extends({},condition,{operator:\"!=\"});case\"!=\":return _extends({},condition,{operator:\"==\"});case\">\":return _extends({},condition,{operator:\"<=\"});case\">=\":return _extends({},condition,{operator:\"<\"});case\"<\":return _extends({},condition,{operator:\">=\"});case\"<=\":return _extends({},condition,{operator:\">\"})}}function conditionImplies(fact,required){if(fact.kind===\"expression\"||required.kind===\"expression\")return sameCondition(fact,required);if(fact.kind===\"defined\"){if(required.kind===\"defined\")return fact.defined===required.defined;return!fact.defined&&matchesComparison(0,required)}if(required.kind===\"defined\"){return required.defined&&!matchesComparison(0,fact)}if(fact.operator===\"==\")return matchesComparison(fact.value,required);if(required.operator===\"!=\")return!matchesComparison(required.value,fact);var factLower=lowerBound(fact);var factUpper=upperBound(fact);var requiredLower=lowerBound(required);var requiredUpper=upperBound(required);if(requiredLower&&(!factLower||!isLowerBoundAtLeast(factLower,requiredLower)))return false;if(requiredUpper&&(!factUpper||!isUpperBoundAtMost(factUpper,requiredUpper)))return false;return!!(requiredLower||requiredUpper)}function areConditionsMutuallyExclusive(left,right){if(!left||!right)return false;if(left.kind===\"constant\"||right.kind===\"constant\"){return left.kind===\"constant\"&&!left.value||right.kind===\"constant\"&&!right.value}if(left.kind===\"expression\"||right.kind===\"expression\"){return left.kind===\"expression\"&&right.kind===\"expression\"&&sameExpression(left,right)&&left.negated!==right.negated}if(left.name!==right.name||left.version!==right.version)return false;if(left.kind===\"defined\"){if(right.kind===\"defined\")return left.defined!==right.defined;return!left.defined&&!matchesComparison(0,right)}if(right.kind===\"defined\")return!right.defined&&!matchesComparison(0,left);if(left.operator===\"==\")return!matchesComparison(left.value,right);if(right.operator===\"==\")return!matchesComparison(right.value,left);var leftLower=lowerBound(left);var rightLower=lowerBound(right);var leftUpper=upperBound(left);var rightUpper=upperBound(right);return leftLower!==undefined&&rightUpper!==undefined&&isEmptyInterval(leftLower,rightUpper)||rightLower!==undefined&&leftUpper!==undefined&&isEmptyInterval(rightLower,leftUpper)}function isLowerBoundAtLeast(actual,required){return actual.value>required.value||actual.value===required.value&&(required.inclusive||!actual.inclusive)}function isUpperBoundAtMost(actual,required){return actual.value<required.value||actual.value===required.value&&(required.inclusive||!actual.inclusive)}function matchesComparison(value,comparison){switch(comparison.operator){case\"==\":return value===comparison.value;case\"!=\":return value!==comparison.value;case\">\":return value>comparison.value;case\">=\":return value>=comparison.value;case\"<\":return value<comparison.value;case\"<=\":return value<=comparison.value}}function lowerBound(comparison){switch(comparison.operator){case\">\":return{value:comparison.value,inclusive:false};case\">=\":return{value:comparison.value,inclusive:true};default:return undefined}}function upperBound(comparison){switch(comparison.operator){case\"<\":return{value:comparison.value,inclusive:false};case\"<=\":return{value:comparison.value,inclusive:true};default:return undefined}}function isEmptyInterval(lower,upper){return lower.value>upper.value||lower.value===upper.value&&(!lower.inclusive||!upper.inclusive)}var branchAnalysis={canBranchesOverlap:canBranchesOverlap,canDeclarationsCoexist:canDeclarationsCoexist,getBranchCoverage:getBranchCoverage,getDeclarationCoexistence:getDeclarationCoexistence,isBranchReachable:isBranchReachable,isBranchVisibleFrom:isBranchVisibleFrom};var ParserSemanticValidation=function(){function ParserSemanticValidation(){}ParserSemanticValidation.collect=function collect(root){var issues=[];var pending=[root];while(pending.length){var node=pending.pop();if(!isBranchReachable(node._branch)||_instanceof(node,ASTNode.MacroDefine))continue;if(_instanceof(node,ASTNode.AssignmentExpression)){var targetIssue=this.assignmentTargetIssue(node);var typeIssue=this.assignmentTypeIssue(node);if(targetIssue)issues.push(targetIssue);if(typeIssue)issues.push(typeIssue)}else if(_instanceof(node,ASTNode.UnaryExpression)||_instanceof(node,ASTNode.PostfixExpression)){var issue=this.incrementTargetIssue(node);if(issue)issues.push(issue)}else if(_instanceof(node,ASTNode.SelectionStatement)){var issue1=this.selectionConditionIssue(node);if(issue1)issues.push(issue1)}else if(_instanceof(node,ASTNode.IterationStatement)){var issue2=this.iterationConditionIssue(node);if(issue2)issues.push(issue2)}else if(_instanceof(node,ASTNode.ConditionalExpression)){var issue3=this.ternaryConditionIssue(node);if(issue3)issues.push(issue3)}else if(_instanceof(node,ASTNode.FunctionCallGeneric)){var _issues;var issue4=this.constructorIssue(node);if(issue4)issues.push(issue4);(_issues=issues).push.apply(_issues,[].concat(this.outputArgumentIssues(node)))}else if(_instanceof(node,ASTNode.FunctionDeclarator)){var issue5=this.functionReturnTypeIssue(node);if(issue5)issues.push(issue5)}for(var index=node.children.length-1;index>=0;index--){var child=node.children[index];if(_instanceof(child,TreeNode))pending.push(child)}}return issues};ParserSemanticValidation.nonAssignableReason=function nonAssignableReason(node){if(_instanceof(node,ASTNode.ConditionalExpression)&&node.children.length>1){return\"a ternary expression result\"}if((_instanceof(node,ASTNode.LogicalOrExpression)||_instanceof(node,ASTNode.LogicalXorExpression)||_instanceof(node,ASTNode.LogicalAndExpression)||_instanceof(node,ASTNode.InclusiveOrExpression)||_instanceof(node,ASTNode.ExclusiveOrExpression)||_instanceof(node,ASTNode.AndExpression)||_instanceof(node,ASTNode.EqualityExpression)||_instanceof(node,ASTNode.RelationalExpression)||_instanceof(node,ASTNode.ShiftExpression)||_instanceof(node,ASTNode.AdditiveExpression)||_instanceof(node,ASTNode.MultiplicativeExpression))&&node.children.length>1){return\"a compound expression\"}if(_instanceof(node,ASTNode.UnaryExpression)&&node.children.length>1){return\"a unary-operator result\"}if(_instanceof(node,ASTNode.FunctionCallGeneric)){return\"a function call result\"}if(_instanceof(node,ASTNode.PostfixExpression)){var base=node.children[0];var field=node.children[2];if(node.children.length===3&&_instanceof(base,ASTNode.ExpressionAstNode)&&_instanceof(field,BaseToken)){var size=this._vectorComponentCount(base);if(size){if(ParserUtils.swizzleError(base.type,field.lexeme,size))return\"an invalid swizzle '.\"+field.lexeme+\"'\";if(new Set(field.lexeme).size!==field.lexeme.length){return\"a swizzle with repeated components '.\"+field.lexeme+\"'\"}}}return _instanceof(base,TreeNode)?ParserSemanticValidation.nonAssignableReason(base):\"an unassignable postfix expression\"}if(_instanceof(node,ASTNode.PrimaryExpression)){if(node.children.length===1){var child=node.children[0];if(_instanceof(child,ASTNode.VariableIdentifier))return ParserSemanticValidation.nonAssignableReason(child);if(_instanceof(child,BaseToken)){if(child.type===ETokenType.INT_CONSTANT||child.type===ETokenType.FLOAT_CONSTANT){return\"a numeric literal\"}if(child.type===Keyword.True||child.type===Keyword.False)return\"a boolean literal\"}return}var inner=node.children[1];return _instanceof(inner,TreeNode)?ParserSemanticValidation.nonAssignableReason(inner):undefined}if(_instanceof(node,ASTNode.VariableIdentifier)){var child1=node.children[0];if(_instanceof(child1,ASTNode.MacroCallSymbol)||_instanceof(child1,ASTNode.MacroCallFunction))return;var symbols=node.resolvedValueSymbols();if(!symbols.length)return;var sharedReason;for(var _iterator=_create_for_of_iterator_helper_loose(symbols),_step;!(_step=_iterator()).done;){var symbol=_step.value;var _symbol_dataType;if(!_instanceof(symbol,VarSymbol))return;var reason=symbol.isConst?\"a const-qualified variable\":TypeSystem.isSamplerType((_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.type)?\"a sampler\":symbol.isUniform?\"a uniform variable\":undefined;if(!reason)return;if(sharedReason&&sharedReason!==reason)return\"a non-modifiable variable\";sharedReason=reason}return sharedReason}if(node.children.length===1){var child2=node.children[0];if(_instanceof(child2,TreeNode))return ParserSemanticValidation.nonAssignableReason(child2)}return};ParserSemanticValidation._vectorComponentCount=function _vectorComponentCount(node){var size=TypeSystem.vectorComponentCount(node.type);if(size)return size;if(_instanceof(node,ASTNode.PostfixExpression)&&node.children.length===3){var base=node.children[0];var field=node.children[2];if(_instanceof(base,ASTNode.ExpressionAstNode)&&_instanceof(field,BaseToken)){var baseSize=this._vectorComponentCount(base);if(baseSize&&!ParserUtils.swizzleError(base.type,field.lexeme,baseSize)){return field.lexeme.length>1?field.lexeme.length:0}}}var child=node.children[_instanceof(node,ASTNode.PrimaryExpression)&&node.children.length===3?1:0];if((node.children.length===1||_instanceof(node,ASTNode.PrimaryExpression))&&_instanceof(child,ASTNode.ExpressionAstNode)){return this._vectorComponentCount(child)}return 0};ParserSemanticValidation.outputArgumentIssues=function outputArgumentIssues(node){var argumentsNode=node.children[2];if(!_instanceof(argumentsNode,ASTNode.FunctionCallParameterList))return[];var _node_fnSymbols;var candidates=(_node_fnSymbols=node.fnSymbols)!=null?_node_fnSymbols:_instanceof(node.fnSymbol,FnSymbol)?[node.fnSymbol]:[];if(!candidates.length)return[];var issues=[];for(var _iterator=_create_for_of_iterator_helper_loose(candidates),_step;!(_step=_iterator()).done;){var candidate=_step.value;var branch=node._branch.concat(candidate.branchSignature);if(getBranchReachability(branch)!==\"reachable\")continue;for(var index=0;index<argumentsNode.paramNodes.length;index++){var _candidate_astNode_protoType_parameterList_index,_candidate_astNode_protoType_parameterList;var argument=argumentsNode.paramNodes[index];if(!_instanceof(argument,TreeNode))continue;var parameter=(_candidate_astNode_protoType_parameterList=candidate.astNode.protoType.parameterList)==null?void 0:(_candidate_astNode_protoType_parameterList_index=_candidate_astNode_protoType_parameterList[index])==null?void 0:_candidate_astNode_protoType_parameterList_index.astNode;if(!_instanceof(parameter,ASTNode.ParameterDeclaration)||!(ParserUtils.hasQualifier(parameter,Keyword.OUT)||ParserUtils.hasQualifier(parameter,Keyword.INOUT)))continue;var reason=this.nonAssignableReason(argument);if(reason){issues.push({code:\"InvalidAssignmentTarget\",message:\"Cannot pass \"+reason+\" to an out or inout parameter — the argument must be a modifiable l-value.\",location:argument.location,branch:branch})}}}return issues};ParserSemanticValidation.assignmentTargetIssue=function assignmentTargetIssue(node){if(node.children.length!==3)return;var lhs=node.children[0];if(!_instanceof(lhs,ASTNode.ExpressionAstNode))return;var reason=this.nonAssignableReason(lhs);return reason?{code:\"InvalidAssignmentTarget\",message:\"Cannot assign to \"+reason+\" — the left operand of '=' must be a modifiable l-value.\",location:lhs.location}:undefined};ParserSemanticValidation.incrementTargetIssue=function incrementTargetIssue(node){if(node.children.length!==2)return;var prefix=_instanceof(node,ASTNode.UnaryExpression);var operator=node.children[prefix?0:1];var operand=node.children[prefix?1:0];if(!_instanceof(operator,BaseToken)||operator.type!==ETokenType.INC_OP&&operator.type!==ETokenType.DEC_OP||!_instanceof(operand,TreeNode)){return}var reason=this.nonAssignableReason(operand);return reason?{code:\"InvalidAssignmentTarget\",message:\"Cannot apply '\"+operator.lexeme+\"' to \"+reason+\" — the operand of '\"+operator.lexeme+\"' must be a modifiable l-value.\",location:operand.location}:undefined};ParserSemanticValidation.assignmentTypeIssue=function assignmentTypeIssue(node){var _operator_children_;if(node.children.length!==3)return;var lhs=node.children[0];var operator=node.children[1];var rhs=node.children[2];if(!_instanceof(lhs,ASTNode.ExpressionAstNode)||!_instanceof(operator,ASTNode.AssignmentOperator)||!_instanceof(rhs,ASTNode.AssignmentExpression)){return}var operatorType=(_operator_children_=operator.children[0])==null?void 0:_operator_children_.type;var compoundOperator=operatorType===ETokenType.MUL_ASSIGN?\"*\":operatorType===ETokenType.DIV_ASSIGN?\"/\":operatorType===ETokenType.MOD_ASSIGN?\"%\":operatorType===ETokenType.ADD_ASSIGN?\"+\":operatorType===ETokenType.SUB_ASSIGN?\"-\":undefined;var arithmetic=compoundOperator?TypeSystem.arithmeticOperation(lhs.type,rhs.type,compoundOperator):undefined;if((arithmetic==null?void 0:arithmetic.valid)===false){return{code:\"InvalidBinaryOperands\",message:\"Operator '\"+compoundOperator+\"=' cannot combine '\"+TypeSystem.typeName(lhs.type)+\"' and '\"+TypeSystem.typeName(rhs.type)+\"'.\",location:node.location}}var _arithmetic_resultType;var assignedType=(_arithmetic_resultType=arithmetic==null?void 0:arithmetic.resultType)!=null?_arithmetic_resultType:rhs.type;if(!TypeSystem.isAssignable(lhs.type,assignedType)){return{code:\"AssignTypeMismatch\",message:\"Cannot assign a value of type '\"+TypeSystem.typeName(rhs.type)+\"' to '\"+TypeSystem.typeName(lhs.type)+\"'.\",location:node.location}}return};ParserSemanticValidation.nonBoolConditionIssue=function nonBoolConditionIssue(condition,label){var type=condition.type;if(type===TypeAny||type===Keyword.BOOL)return;return{code:\"NonBoolCondition\",message:\"\"+label[0].toUpperCase()+label.slice(1)+\" must be a bool, got '\"+TypeSystem.typeName(type)+\"'.\",location:condition.location}};ParserSemanticValidation.selectionConditionIssue=function selectionConditionIssue(node){var condition=node.children.find(function(child){return _instanceof(child,ASTNode.ExpressionAstNode)});return _instanceof(condition,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(condition,\"'if' condition\"):undefined};ParserSemanticValidation.iterationConditionIssue=function iterationConditionIssue(node){var keyword=node.children[0];if(!_instanceof(keyword,BaseToken))return;var condition;var label;if(keyword.type===Keyword.WHILE){var candidate=node.children[2];if(_instanceof(candidate,ASTNode.Condition))condition=candidate;label=\"'while' condition\"}else if(keyword.type===Keyword.FOR){var rest=node.children[3];var optionalCondition=_instanceof(rest,ASTNode.ForRestStatement)?rest.children[0]:undefined;var candidate1=_instanceof(optionalCondition,ASTNode.ConditionOpt)&&optionalCondition.children.length===1?optionalCondition.children[0]:undefined;if(_instanceof(candidate1,ASTNode.Condition))condition=candidate1;label=\"'for' condition\"}else{return}if(!condition)return;var children=condition.children;var expression=children.length===1&&_instanceof(children[0],ASTNode.ExpressionAstNode)?children[0]:children.length===4&&_instanceof(children[3],ASTNode.ExpressionAstNode)?children[3]:undefined;return _instanceof(expression,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(expression,label):undefined};ParserSemanticValidation.ternaryConditionIssue=function ternaryConditionIssue(node){var condition=node.children.length===5?node.children[0]:undefined;return _instanceof(condition,ASTNode.ExpressionAstNode)?this.nonBoolConditionIssue(condition,\"ternary condition\"):undefined};ParserSemanticValidation.constructorIssue=function constructorIssue(node){var functionIdentifier=node.children[0];if(!functionIdentifier.isBuiltin)return;var list=node.children.length===4?node.children[2]:undefined;if(!_instanceof(list,ASTNode.FunctionCallParameterList))return;var badIndex=list.paramSig.findIndex(function(type){return TypeSystem.isSamplerType(type)||typeof type===\"string\"});if(badIndex>=0){var argument=list.paramNodes[badIndex];return{code:\"ConstructorArgType\",message:\"Cannot construct '\"+TypeSystem.typeName(functionIdentifier.ident)+\"' from a '\"+TypeSystem.typeName(list.paramSig[badIndex])+\"' argument.\",location:_instanceof(argument,TreeNode)?argument.location:list.location}}var matrixComponents=TypeSystem.matrixComponentCount(functionIdentifier.ident);var requiredComponents=TypeSystem.vectorComponentCount(functionIdentifier.ident)||matrixComponents;if(requiredComponents<=0)return;if(matrixComponents>0&&list.paramSig.length===1&&TypeSystem.matrixComponentCount(list.paramSig[0])>0){return}if(matrixComponents===0&&list.paramSig.length===1&&TypeSystem.vectorComponentCount(list.paramSig[0])>=requiredComponents){return}var providedComponents=0;var countable=list.paramSig.length>0;for(var _iterator=_create_for_of_iterator_helper_loose(list.paramSig),_step;!(_step=_iterator()).done;){var type=_step.value;var components=TypeSystem.isScalarType(type)?1:TypeSystem.vectorComponentCount(type)||TypeSystem.matrixComponentCount(type);if(components===0){countable=false;break}providedComponents+=components}var singleScalar=list.paramSig.length===1&&TypeSystem.isScalarType(list.paramSig[0]);return countable&&!singleScalar&&providedComponents!==requiredComponents?{code:\"ConstructorArgCount\",message:\"Constructor '\"+TypeSystem.typeName(functionIdentifier.ident)+\"' needs \"+requiredComponents+\" components but the arguments provide \"+providedComponents+\".\",location:list.location}:undefined};ParserSemanticValidation.functionReturnTypeIssue=function functionReturnTypeIssue(node){var _this=this;var returnType=node.returnType;var type=returnType.type;if(TypeSystem.isSamplerType(type)){return{code:\"NonConstructibleReturnType\",message:\"Function return type '\"+TypeSystem.typeName(type)+\"' is not constructible; samplers cannot be returned.\",location:returnType.location}}if(typeof type===\"string\"&&returnType.typeSpecifier.structDeclarations.some(function(declaration){return _this._structContainsSampler(declaration,new Set)})){return{code:\"NonConstructibleReturnType\",message:\"Function return type '\"+type+\"' is not constructible; structs containing samplers cannot be returned.\",location:returnType.location}}return};ParserSemanticValidation._structContainsSampler=function _structContainsSampler(declaration,visited){if(visited.has(declaration))return false;visited.add(declaration);for(var _iterator=_create_for_of_iterator_helper_loose(declaration.propList),_step;!(_step=_iterator()).done;){var property=_step.value;if(TypeSystem.isSamplerType(property.typeInfo.type))return true;for(var _iterator1=_create_for_of_iterator_helper_loose(property.typeInfo.structDeclarations),_step1;!(_step1=_iterator1()).done;){var nestedDeclaration=_step1.value;if(this._structContainsSampler(nestedDeclaration,visited))return true}}return false};return ParserSemanticValidation}();var EMPTY_ERRORS$1=Object.freeze([]);var EMPTY_PREPROCESSOR_EXPRESSIONS$1=new Map;function mapExpandedShaderRange(startOffset,endOffset,segments){var startSegment=findSourceMapSegment(startOffset,segments,false);if(!startSegment)return undefined;var endSegment=findSourceMapSegment(endOffset,segments,true);var mappedStartOffset=startSegment.sourceStart+startOffset-startSegment.generatedStart;var mappedEndOffset=(endSegment==null?void 0:endSegment.source)===startSegment.source&&endSegment.sourceFile===startSegment.sourceFile?endSegment.sourceStart+endOffset-endSegment.generatedStart:mappedStartOffset;return{source:startSegment.source,sourceFile:startSegment.sourceFile,start:shaderPositionAt(startSegment.source,mappedStartOffset),end:shaderPositionAt(startSegment.source,mappedEndOffset)}}function mapExpandedShaderError(error,expandedSource,segments){if(!_instanceof(error,GSError)||error.source!==expandedSource)return error;var location=error.location;var range=\"start\"in location?location:{start:location,end:location};var mapped=mapExpandedShaderRange(range.start.index,range.end.index,segments);if(!mapped)return error;var mappedLocation=new ShaderRange;mappedLocation.set(mapped.start,mapped.end);var _mapped_sourceFile;return new GSError(error.name,error.message,mappedLocation,mapped.source,(_mapped_sourceFile=mapped.sourceFile)!=null?_mapped_sourceFile:error.file,error.code)}function findSourceMapSegment(offset,segments,isEnd){for(var _iterator=_create_for_of_iterator_helper_loose(segments),_step;!(_step=_iterator()).done;){var segment=_step.value;if(offset>=segment.generatedStart&&(isEnd?offset<=segment.generatedEnd&&offset>segment.generatedStart:offset<segment.generatedEnd)){return segment}}var last=segments[segments.length-1];return last&&offset===last.generatedEnd?last:undefined}function shaderPositionAt(source,offset){var line=0;var column=0;for(var index=0;index<offset;index++){if(source.charCodeAt(index)===10){line++;column=0}else{column++}}var position=new ShaderPosition;position.set(offset,line,column);return position}function parseShaderPassWith(source,includeMap,cache,basePathForIncludeKey,createLexer,createParser,sourceFile,objectPool,trackSourceMap,sourceScopeStarts){if(trackSourceMap===void 0)trackSourceMap=true;objectPool==null?void 0:objectPool.reset();var macroDefineList={};var _Preprocessor_parseWithErrors=Preprocessor.parseWithErrors(source,basePathForIncludeKey,includeMap,cache,sourceFile,trackSourceMap,sourceScopeStarts),expandedSource=_Preprocessor_parseWithErrors.content,preprocessErrors=_Preprocessor_parseWithErrors.errors,sourceMap=_Preprocessor_parseWithErrors.sourceMap,conditionalArms=_Preprocessor_parseWithErrors.conditionalArms;for(var _iterator=_create_for_of_iterator_helper_loose(sourceMap),_step;!(_step=_iterator()).done;){var segment=_step.value;Object.freeze(segment)}var frozenSourceMap=Object.freeze(sourceMap);if(preprocessErrors.length){var errors=Object.freeze([].concat(preprocessErrors));return Object.freeze({ir:null,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:EMPTY_PREPROCESSOR_EXPRESSIONS$1,errors:errors,blockingErrors:errors})}var lexer=createLexer(expandedSource,macroDefineList,objectPool,conditionalArms);var tokens=lexer.tokenize();var parser=createParser(expandedSource,objectPool);parser.setSourceScopes(frozenSourceMap);var program=parser.parse(tokens,macroDefineList);var mappedParserErrors=parser.errors.map(function(error){return mapExpandedShaderError(error,expandedSource,frozenSourceMap)});var errors1=mappedParserErrors.length?Object.freeze(mappedParserErrors):EMPTY_ERRORS$1;var parserBlockingErrors=parser.semanticErrorsBlockCodegen?parser.errors:parser.blockingErrors;var blockingErrors=parser.errors.length===parserBlockingErrors.length?errors1:Object.freeze(parserBlockingErrors.map(function(error){return mapExpandedShaderError(error,expandedSource,frozenSourceMap)}));var ir=program?Object.freeze(new ShaderClueIR(program,expandedSource,frozenSourceMap)):null;if(ir){var semanticIssues=ParserSemanticValidation.collect(ir.program);if(semanticIssues.length){var semanticErrors=semanticIssues.map(function(issue){return mapExpandedShaderError(ShaderCompilerUtils.createGSError(issue.message,GSErrorName.CompilationError,expandedSource,issue.location,issue.code),expandedSource,frozenSourceMap)});return Object.freeze({ir:ir,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:lexer.preprocessorExpressions,errors:Object.freeze([].concat(errors1,semanticErrors)),blockingErrors:Object.freeze([].concat(blockingErrors,semanticErrors))})}}return Object.freeze({ir:ir,expandedSource:expandedSource,sourceMap:frozenSourceMap,preprocessorExpressions:lexer.preprocessorExpressions,errors:errors1,blockingErrors:blockingErrors})}var EMPTY_ERRORS=Object.freeze([]);var EMPTY_SOURCE_MAP=Object.freeze([]);var EMPTY_PREPROCESSOR_EXPRESSIONS=new Map;function createRuntimeShaderTargetParser(objectPool){return ShaderTargetParser.create(undefined,undefined,undefined,objectPool)}function parseRuntimeShaderPass(source,includeMap,cache,sourceFile,objectPool,runtimeParser,sourceScopeStarts){objectPool==null?void 0:objectPool.reset();if(!(sourceScopeStarts==null?void 0:sourceScopeStarts.some(function(offset){return offset>0})))sourceScopeStarts=undefined;var normalizedSourceFile=normalizeShaderSourceFile(sourceFile);var preprocessResult=Preprocessor.parseWithErrors(source,shaderSourceBaseURL(normalizedSourceFile),includeMap,cache,normalizedSourceFile,false,sourceScopeStarts);var expandedSource=preprocessResult.content;if(preprocessResult.errors.length){var errors=freezeErrors(preprocessResult.errors);return Object.freeze({ir:null,expandedSource:expandedSource,sourceMap:EMPTY_SOURCE_MAP,preprocessorExpressions:EMPTY_PREPROCESSOR_EXPRESSIONS,errors:errors,blockingErrors:errors})}var macroDefineList={};var lexer=new Lexer(expandedSource,macroDefineList,objectPool,preprocessResult.conditionalArms);var parser=runtimeParser!=null?runtimeParser:createRuntimeShaderTargetParser(objectPool);parser.setSource(expandedSource);parser.setSourceScopes(preprocessResult.sourceScopes);var program=parser.parse(lexer.tokenize(),macroDefineList);var errors1=freezeErrors(parser.errors);var blockingErrors=freezeErrors(parser.blockingErrors);return Object.freeze({ir:program?Object.freeze(new ShaderClueIR(program,expandedSource,EMPTY_SOURCE_MAP)):null,expandedSource:expandedSource,sourceMap:EMPTY_SOURCE_MAP,preprocessorExpressions:lexer.preprocessorExpressions,errors:errors1,blockingErrors:blockingErrors})}function freezeErrors(){for(var _len=arguments.length,groups=new Array(_len),_key=0;_key<_len;_key++){groups[_key]=arguments[_key]}var _errors;var count=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups),_step;!(_step=_iterator()).done;){var group=_step.value;count+=group.length}if(count===0)return EMPTY_ERRORS;var errors=[];for(var _iterator1=_create_for_of_iterator_helper_loose(groups),_step1;!(_step1=_iterator1()).done;){var group1=_step1.value;(_errors=errors).push.apply(_errors,[].concat(group1))}return Object.freeze(errors)}var ShaderSourceFactory=function(){function ShaderSourceFactory(){}ShaderSourceFactory.createRenderStates=function createRenderStates(){return{constantMap:{},variableMap:{}}};ShaderSourceFactory.createShaderSource=function createShaderSource(name){return{name:name,subShaders:[],pendingContents:[],renderStates:this.createRenderStates()}};ShaderSourceFactory.createSubShaderSource=function createSubShaderSource(name){return{name:name,passes:[],pendingContents:[],tags:{},renderStates:this.createRenderStates()}};ShaderSourceFactory.createShaderPassSource=function createShaderPassSource(name){return{name:name,pendingContents:[],contentScopeStarts:[],isUsePass:false,tags:{},renderStates:this.createRenderStates(),contents:\"\",vertexEntry:\"\",fragmentEntry:\"\"}};ShaderSourceFactory.createUsePass=function createUsePass(name){return{name:name,pendingContents:[],contentScopeStarts:[],isUsePass:true,tags:{},renderStates:this.createRenderStates(),contents:\"\",vertexEntry:\"\",fragmentEntry:\"\"}};return ShaderSourceFactory}();var ShaderSourceSymbol=function(){function ShaderSourceSymbol(ident,type,value){this.ident=ident;this.type=type;this.value=value;this.isInMacroBranch=false;this.branchSignature=EMPTY_BRANCH}var _proto=ShaderSourceSymbol.prototype;_proto.set=function set(ident,type,value){this.ident=ident;this.type=type;this.value=value};_proto.equal=function equal(other){return this.type===other.type};return ShaderSourceSymbol}();var SourceLexer=function(BaseLexer1){_inherits(SourceLexer,BaseLexer1);function SourceLexer(){var _this;_this=BaseLexer1.apply(this,arguments)||this,_this.hasPendingContent=false;return _this}var _proto=SourceLexer.prototype;_proto.setSource=function setSource(source){BaseLexer1.prototype.setSource.call(this,source);this.hasPendingContent=false};_proto.scanNumber=function scanNumber(){this.skipCommentsAndSpace();var start=this._currentIndex;var source=this._source;var index=this._currentIndex;index=SourceLexer._scanDigits(source,index);if(source[index]===\".\"){index=SourceLexer._scanDigits(source,index+1)}this.advance(index-this._currentIndex);return Number(source.substring(start,index))};_proto.scanColor=function scanColor(){this.scanLexeme(\"(\");var r=this.scanNumber();var g=0;var b=0;var a=1;this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");g=this.scanNumber();this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");b=this.scanNumber();this.skipCommentsAndSpace();if(this.peek(1)!==\")\"){this.scanLexeme(\",\");a=this.scanNumber();this.skipCommentsAndSpace()}}}this.scanLexeme(\")\");return new Color(r,g,b,a)};_proto.scanToken=function scanToken(){while(true){this.skipCommentsAndSpace();if(this.isEnd()){return this._createEOFToken()}var start=this.getShaderPosition(0);if(BaseLexer.isAlpha(this.getCurCharCode())){var wordToken=this._scanWord(start);if(wordToken!==null){return wordToken}this.hasPendingContent=true;continue}var currentChar=this.getCurChar();var symbolKeyword=SourceLexer._symbolLexemeTable[currentChar];if(symbolKeyword!==undefined){this.advance(1);var token=this._createToken();token.set(symbolKeyword,currentChar,start);return token}this.advance(1)}};_proto.scanToCharacter=function scanToCharacter(char){while(this.getCurChar()!==char&&this.getCurChar()!==\"}\"&&!this.isEnd()){this.advance(1)}if(this.getCurChar()!==char)return false;this.advance(1);return true};_proto.createCompileError=function createCompileError(message,location,code){return ShaderCompilerUtils.createGSError(message,GSErrorName.CompilationError,this.source,location!=null?location:this.getShaderPosition(0),code)};_proto._scanWord=function _scanWord(start){while(BaseLexer.isAlnum(this.getCurCharCode())&&!this.isEnd()){this.advance(1)}var end=this.getShaderPosition(0);if(!this._validateWordBoundaries(start.index,end.index)){return null}var lexeme=this._source.substring(start.index,end.index);var _SourceLexer__keywordLexemeTable_lexeme;var tokenType=(_SourceLexer__keywordLexemeTable_lexeme=SourceLexer._keywordLexemeTable[lexeme])!=null?_SourceLexer__keywordLexemeTable_lexeme:ETokenType.ID;var range=this._createRange(start,end);var token=this._createToken();token.set(tokenType,lexeme,range);return token};_proto._validateWordBoundaries=function _validateWordBoundaries(startIndex,endIndex){var source=this._source;if(startIndex>0){var prevCharCode=source.charCodeAt(startIndex-1);if(!this._isValidWordBoundary(prevCharCode)){return false}}if(endIndex<source.length){var nextCharCode=source.charCodeAt(endIndex);if(!this._isValidWordBoundary(nextCharCode)){return false}}return true};_proto._isValidWordBoundary=function _isValidWordBoundary(charCode){return BaseLexer.isWhiteSpaceChar(charCode,true)||SourceLexer._isWordSeparatorChar(charCode)};SourceLexer._isWordSeparatorChar=function _isWordSeparatorChar(charCode){return charCode===123||charCode===125||charCode===61||charCode===59||charCode===46||charCode===91||charCode===40||charCode===124};SourceLexer._scanDigits=function _scanDigits(source,startIndex){var currentIndex=startIndex;while(currentIndex<source.length){var charCode=source.charCodeAt(currentIndex);if(BaseLexer.isDigit(charCode)){currentIndex++}else{break}}return currentIndex};return SourceLexer}(BaseLexer);SourceLexer._keywordLexemeTable={RenderQueueType:Keyword.GSRenderQueueType,BlendState:Keyword.GSBlendState,DepthState:Keyword.GSDepthState,StencilState:Keyword.GSStencilState,RasterState:Keyword.GSRasterState,EditorProperties:Keyword.GSEditorProperties,EditorMacros:Keyword.GSEditorMacros,Editor:Keyword.GSEditor,Tags:Keyword.GSTags,VertexShader:Keyword.GSVertexShader,FragmentShader:Keyword.GSFragmentShader,SubShader:Keyword.GSSubShader,Pass:Keyword.GSPass,BlendFactor:Keyword.GSBlendFactor,BlendOperation:Keyword.GSBlendOperation,Bool:Keyword.GSBool,Number:Keyword.GSNumber,Color:Keyword.GSColor,CompareFunction:Keyword.GSCompareFunction,StencilOperation:Keyword.GSStencilOperation,CullMode:Keyword.GSCullMode,ColorWriteMask:Keyword.GSColorWriteMask,UsePass:Keyword.GSUsePass,true:Keyword.True,false:Keyword.False};SourceLexer._symbolLexemeTable={\"{\":Keyword.LeftBrace,\"}\":Keyword.RightBrace,\"=\":Keyword.Equal,\"|\":Keyword.BitwiseOr};var renderStateConstMap={RenderQueueType:RenderQueueType,CompareFunction:CompareFunction,StencilOperation:StencilOperation,BlendOperation:BlendOperation,BlendFactor:BlendFactor,CullMode:CullMode,ColorWriteMask:ColorWriteMask};var ShaderSourceParser=function(){function ShaderSourceParser(){}ShaderSourceParser.parse=function parse(sourceCode){return new ShaderSourceParserSession().parse(sourceCode).shaderSource};ShaderSourceParser.parseStrict=function parseStrict(sourceCode,objectPool){return new ShaderSourceParserSession(objectPool).parse(sourceCode)};ShaderSourceParser.parseWithErrors=function parseWithErrors(sourceCode){return new ShaderSourceParserSession().parseWithErrors(sourceCode)};return ShaderSourceParser}();var ShaderSourceParserSession=function(){function ShaderSourceParserSession(_objectPool){this._objectPool=_objectPool;this._errors=[];this._symbolTableStack=new SymbolTableStack;this._lookupSymbol=new ShaderSourceSymbol(\"\",null);this._shaderSource=ShaderSourceFactory.createShaderSource(\"\");this._reportedUnexpectedEnd=false;this._lexer=new SourceLexer(undefined,this._objectPool)}var _proto=ShaderSourceParserSession.prototype;_proto.parseWithErrors=function parseWithErrors(sourceCode){try{return this.parse(sourceCode)}catch(error){if(!_instanceof(error,GSError))throw error;this._errors.push(error);return{shaderSource:this._shaderSource,errors:Object.freeze(this._errors.slice())}}};_proto.parse=function parse(sourceCode){var _this__objectPool;(_this__objectPool=this._objectPool)==null?void 0:_this__objectPool.reset();this._pushScope();var lexer=this._lexer;lexer.setSource(sourceCode);var shaderSource=this._parseShader(lexer);var shaderPendingContents=shaderSource.pendingContents;var shaderRenderStates=shaderSource.renderStates;for(var i=0,n=shaderSource.subShaders.length;i<n;i++){var subShader=shaderSource.subShaders[i];var globalSubShaderStates={constantMap:_extends({},shaderRenderStates.constantMap),variableMap:_extends({},shaderRenderStates.variableMap)};this._mergeRenderStates(globalSubShaderStates,subShader.renderStates);for(var j=0,m=subShader.passes.length;j<m;j++){var pass=subShader.passes[j];var globalPassRenderStates={constantMap:_extends({},globalSubShaderStates.constantMap),variableMap:_extends({},globalSubShaderStates.variableMap)};this._mergeRenderStates(globalPassRenderStates,pass.renderStates);pass.renderStates=globalPassRenderStates;if(pass.isUsePass)continue;var composed=this._composePassContents([shaderPendingContents,subShader.pendingContents,pass.pendingContents]);pass.contents=composed.contents;pass.contentScopeStarts=composed.scopeStarts}}return{shaderSource:shaderSource,errors:Object.freeze(this._errors.slice())}};_proto._composePassContents=function _composePassContents(groups){var parts=[];var scopeStarts=[];var length=0;for(var _iterator=_create_for_of_iterator_helper_loose(groups),_step;!(_step=_iterator()).done;){var group=_step.value;scopeStarts.push(length);for(var _iterator1=_create_for_of_iterator_helper_loose(group),_step1;!(_step1=_iterator1()).done;){var statement=_step1.value;if(parts.length)length++;parts.push(statement.content);length+=statement.content.length}}return{contents:parts.join(\"\\n\"),scopeStarts:Object.freeze(scopeStarts)}};_proto._parseShader=function _parseShader(lexer){lexer.scanLexeme(\"Shader\");var name=lexer.scanPairedChar('\"','\"',false,false);var shaderSource=ShaderSourceFactory.createShaderSource(name);this._shaderSource=shaderSource;lexer.scanLexeme(\"{\");var braceLevel=1;lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);var pendingContents=shaderSource.pendingContents;while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,pendingContents);this._reportUnexpectedEnd(token,\"Shader\");this._popScope();return shaderSource;case Keyword.GSSubShader:{this._addPendingContents(start,token.lexeme.length,pendingContents);var subShader=this._parseSubShader();shaderSource.subShaders.push(subShader);start=lexer.getShaderPosition(0);break}case Keyword.GSEditorProperties:case Keyword.GSEditorMacros:case Keyword.GSEditor:this._addPendingContents(start,token.lexeme.length,pendingContents);lexer.scanPairedChar(\"{\",\"}\",true,false);start=lexer.getShaderPosition(0);break;case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,pendingContents);this._popScope();return shaderSource}break;default:start=this._parseRenderState(token,start,pendingContents,shaderSource.renderStates)}}};_proto._parseRenderStateDeclarationOrAssignment=function _parseRenderStateDeclarationOrAssignment(outRenderStates,stateToken){var lexer=this._lexer;var token=lexer.scanToken();if(token.type===ETokenType.ID){lexer.scanLexeme(\"{\");var renderState=this._parseRenderStateProperties(stateToken.lexeme);var symbol=new ShaderSourceSymbol(token.lexeme,stateToken.type,renderState);this._symbolTableStack.insert(symbol)}else if(token.lexeme===\"=\"){var nextToken=lexer.scanToken();if(nextToken.type===ETokenType.EOF)return;var renderState1;if(nextToken.lexeme===\"{\"){renderState1=this._parseRenderStateProperties(stateToken.lexeme)}else{lexer.scanLexeme(\";\");var lookupSymbol=this._lookupSymbol;lookupSymbol.set(nextToken.lexeme,stateToken.type);var sm=this._symbolTableStack.lookup(lookupSymbol);if(!(sm==null?void 0:sm.value)){this._createCompileError('Invalid \"'+stateToken.lexeme+'\" variable: '+nextToken.lexeme+\" — property will not be applied.\",nextToken.location,\"InvalidRenderStateVariable\");return}renderState1=sm.value}this._mergeRenderStates(outRenderStates,renderState1)}};_proto._mergeRenderStates=function _mergeRenderStates(outTarget,source){var targetConstantMap=outTarget.constantMap,targetVariableMap=outTarget.variableMap;var sourceConstantMap=source.constantMap,sourceVariableMap=source.variableMap;for(var key in sourceConstantMap){delete targetVariableMap[key];targetConstantMap[key]=sourceConstantMap[key]}for(var key1 in sourceVariableMap){delete targetConstantMap[key1];targetVariableMap[key1]=sourceVariableMap[key1]}};_proto._parseVariableDeclaration=function _parseVariableDeclaration(){var lexer=this._lexer;var token=lexer.scanToken();lexer.scanLexeme(\";\");var symbol=new ShaderSourceSymbol(token.lexeme,token.type);this._symbolTableStack.insert(symbol)};_proto._pushScope=function _pushScope(){var symbolTable=new SymbolTable;this._symbolTableStack.pushScope(symbolTable)};_proto._popScope=function _popScope(){this._symbolTableStack.popScope()};_proto._parseRenderStateProperties=function _parseRenderStateProperties(state){var lexer=this._lexer;var renderStates=ShaderSourceFactory.createRenderStates();while(lexer.getCurChar()!==\"}\"&&!lexer.isEnd()){this._parseRenderStateProperty(state,renderStates);lexer.skipCommentsAndSpace()}if(lexer.getCurChar()===\"}\")lexer.advance(1);return renderStates};_proto._createCompileError=function _createCompileError(message,location,code){var error=this._lexer.createCompileError(message,location,code);this._errors.push(error)};_proto._scanEnumConstValue=function _scanEnumConstValue(enumName){var _renderStateConstMap_enumName;var lexer=this._lexer;lexer.advance(1);var constValueToken=lexer.scanToken();var value=(_renderStateConstMap_enumName=renderStateConstMap[enumName])==null?void 0:_renderStateConstMap_enumName[constValueToken.lexeme];if(value==undefined){this._createCompileError(\"Invalid engine constant: \"+enumName+\".\"+constValueToken.lexeme+\" — property will not be applied.\",constValueToken.location,\"InvalidEnumValue\");lexer.scanToCharacter(\";\")}return value};_proto._parseRenderStateProperty=function _parseRenderStateProperty(stateLexeme,out){var lexer=this._lexer;var propertyToken=lexer.scanToken();var propertyLexeme=propertyToken.lexeme;var stateElementKey=propertyLexeme;if(stateLexeme===\"BlendState\"&&propertyLexeme!==\"BlendColor\"&&propertyLexeme!==\"AlphaToCoverage\"){var keyIndex=0;var scannedLexeme=lexer.scanTwoExpectedLexemes(\"[\",\"=\");if(scannedLexeme===\"[\"){keyIndex=lexer.scanNumber();lexer.scanLexeme(\"]\");lexer.scanLexeme(\"=\")}else if(scannedLexeme!==\"=\"){this._createCompileError(\"Invalid syntax, expect '[' or '=', but got unexpected token\",undefined,\"SyntaxError\");lexer.scanToCharacter(\";\");return}stateElementKey+=keyIndex}else{lexer.scanLexeme(\"=\")}var renderStateElementKey=RenderStateElementKey[stateLexeme+stateElementKey];if(renderStateElementKey===undefined){this._createCompileError(\"Invalid render state property \"+propertyLexeme+\" — property will not be applied.\",propertyToken.location,\"InvalidRenderStateProperty\");lexer.scanToCharacter(\";\");return}lexer.skipCommentsAndSpace();var propertyValue;var curCharCode=lexer.getCurCharCode();if(BaseLexer.isDigit(curCharCode)||curCharCode===46){propertyValue=lexer.scanNumber()}else{var valueToken=lexer.scanToken();var valueTokenType=valueToken.type;if(valueTokenType===ETokenType.EOF)return;if(valueTokenType===Keyword.True){propertyValue=true}else if(valueTokenType===Keyword.False){propertyValue=false}else if(valueTokenType===Keyword.GSColor){propertyValue=lexer.scanColor()}else if(lexer.getCurChar()===\".\"){propertyValue=this._scanEnumConstValue(valueToken.lexeme);if(propertyValue==undefined)return;lexer.skipCommentsAndSpace();if(lexer.getCurChar()===\"|\"){if(valueToken.lexeme!==\"ColorWriteMask\"){this._createCompileError(\"Bitwise OR '|' is not supported for '\"+valueToken.lexeme+\"', only bitmask enums like 'ColorWriteMask' support this — property will not be applied.\",valueToken.location,\"BitwiseOrOnNonBitmask\");lexer.scanToCharacter(\";\");return}while(lexer.getCurChar()===\"|\"){lexer.advance(1);var nextEnumToken=lexer.scanToken();if(nextEnumToken==undefined||lexer.getCurChar()!==\".\"){this._createCompileError(\"Invalid syntax after '|', expect 'EnumType.Value'\",nextEnumToken==null?void 0:nextEnumToken.location,\"SyntaxError\");lexer.scanToCharacter(\";\");return}if(nextEnumToken.lexeme!==valueToken.lexeme){this._createCompileError(\"Cannot mix enum types in bitwise OR: expected '\"+valueToken.lexeme+\"' but got '\"+nextEnumToken.lexeme+\"' — property will not be applied.\",nextEnumToken.location,\"MixedEnumTypes\");lexer.scanToCharacter(\";\");return}var nextValue=this._scanEnumConstValue(nextEnumToken.lexeme);if(nextValue==undefined)return;propertyValue=propertyValue|nextValue;lexer.skipCommentsAndSpace()}}}else{propertyValue=valueToken.lexeme;var lookupSymbol=this._lookupSymbol;lookupSymbol.set(valueToken.lexeme,ETokenType.ID);if(!this._symbolTableStack.lookup(lookupSymbol)){this._createCompileError(\"Invalid \"+stateLexeme+\" variable: \"+valueToken.lexeme+\" — property will not be applied.\",valueToken.location,\"InvalidRenderStateVariable\");lexer.scanToCharacter(\";\");return}}}lexer.scanLexeme(\";\");if(typeof propertyValue===\"string\"){out.variableMap[renderStateElementKey]=propertyValue}else{out.constantMap[renderStateElementKey]=propertyValue}};_proto._parseRenderQueueDeclarationOrAssignment=function _parseRenderQueueDeclarationOrAssignment(renderStates){var lexer=this._lexer;var token=lexer.scanToken();if(token.type===ETokenType.ID){lexer.scanLexeme(\";\");var symbol=new ShaderSourceSymbol(token.lexeme,Keyword.GSRenderQueueType);this._symbolTableStack.insert(symbol);return}if(token.lexeme!==\"=\"){this._createCompileError(\"Invalid syntax, expect character '=', but got \"+token.lexeme,token.location,\"SyntaxError\");return}var word=lexer.scanToken();lexer.scanLexeme(\";\");var value=renderStateConstMap.RenderQueueType[word.lexeme];var key=RenderStateElementKey.RenderQueueType;if(value==undefined){var lookupSymbol=this._lookupSymbol;lookupSymbol.set(word.lexeme,Keyword.GSRenderQueueType);var sm=this._symbolTableStack.lookup(lookupSymbol);if(!sm){this._createCompileError(\"Invalid RenderQueueType variable: \"+word.lexeme+\" — property will not be applied at runtime.\",word.location,\"InvalidRenderQueueVariable\");return}renderStates.variableMap[key]=word.lexeme}else{renderStates.constantMap[key]=value}};_proto._addPendingContents=function _addPendingContents(start,backOffset,outPendingContents){var lexer=this._lexer;if(lexer.hasPendingContent){var endIndex=lexer.currentIndex-backOffset;outPendingContents.push({range:{start:start,end:_extends({},lexer.getShaderPosition(0),{index:endIndex-1})},content:lexer.source.substring(start.index,endIndex-1)});lexer.hasPendingContent=false}};_proto._parseSubShader=function _parseSubShader(){var lexer=this._lexer;this._pushScope();var braceLevel=1;var name=lexer.scanPairedChar('\"','\"',false,false);var subShaderSource=ShaderSourceFactory.createSubShaderSource(name);lexer.scanLexeme(\"{\");lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,subShaderSource.pendingContents);this._reportUnexpectedEnd(token,\"SubShader\");this._popScope();return subShaderSource;case Keyword.GSPass:{this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);var pass=this._parsePass(this._retainRange(token.location));subShaderSource.passes.push(pass);start=lexer.getShaderPosition(0);break}case Keyword.GSUsePass:{this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);var name1=lexer.scanPairedChar('\"','\"',false,false);subShaderSource.passes.push(ShaderSourceFactory.createUsePass(name1));start=lexer.getShaderPosition(0);break}case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,subShaderSource.pendingContents);this._popScope();return subShaderSource}break;default:start=this._parseRenderStateAndTags(token,start,subShaderSource.pendingContents,subShaderSource.renderStates,subShaderSource.tags)}}};_proto._parseTags=function _parseTags(tags){var lexer=this._lexer;lexer.scanLexeme(\"{\");while(true){var ident=lexer.scanToken();lexer.scanLexeme(\"=\");var value=lexer.scanPairedChar('\"','\"',false,false);lexer.skipCommentsAndSpace();tags[ident.lexeme]=value;if(lexer.peek(1)===\"}\"){lexer.advance(1);return}lexer.scanLexeme(\",\")}};_proto._parsePass=function _parsePass(passLocation){this._pushScope();var lexer=this._lexer;var name=lexer.scanPairedChar('\"','\"',false,false);var passSource=ShaderSourceFactory.createShaderPassSource(name);lexer.scanLexeme(\"{\");var braceLevel=1;lexer.skipCommentsAndSpace();var start=lexer.getShaderPosition(0);while(true){var token=lexer.scanToken();switch(token.type){case ETokenType.EOF:this._addPendingContents(start,0,passSource.pendingContents);this._reportUnexpectedEnd(token,\"Pass\");this._popScope();return passSource;case Keyword.GSVertexShader:case Keyword.GSFragmentShader:{this._addPendingContents(start,token.lexeme.length,passSource.pendingContents);lexer.scanLexeme(\"=\");var entry=lexer.scanToken();var isVertex=token.type===Keyword.GSVertexShader;var key=isVertex?\"vertexEntry\":\"fragmentEntry\";if(passSource[key]){this._createCompileError(\"Reassignment of \"+(isVertex?\"VertexShader\":\"FragmentShader\")+\" entry — the first binding is kept.\",entry.location,\"DuplicateEntryAssignment\");lexer.scanLexeme(\";\");start=lexer.getShaderPosition(0);break}passSource[key]=entry.lexeme;passSource[isVertex?\"vertexEntryLocation\":\"fragmentEntryLocation\"]=this._retainRange(entry.location);lexer.scanLexeme(\";\");start=lexer.getShaderPosition(0);break}case Keyword.LeftBrace:++braceLevel;break;case Keyword.RightBrace:if(--braceLevel===0){this._addPendingContents(start,token.lexeme.length,passSource.pendingContents);if(!passSource.vertexEntry||!passSource.fragmentEntry){this._createCompileError(\"Pass must bind both VertexShader and FragmentShader entries.\",passLocation,\"MissingEntry\")}this._popScope();return passSource}break;default:start=this._parseRenderStateAndTags(token,start,passSource.pendingContents,passSource.renderStates,passSource.tags)}}};_proto._reportUnexpectedEnd=function _reportUnexpectedEnd(token,construct){if(this._reportedUnexpectedEnd)return;this._reportedUnexpectedEnd=true;this._createCompileError(\"Unexpected end of source while parsing \"+construct+\".\",token.location,\"SyntaxError\")};_proto._retainRange=function _retainRange(range){if(!this._objectPool)return range;var start=new ShaderPosition;start.set(range.start.index,range.start.line,range.start.column);var end=new ShaderPosition;end.set(range.end.index,range.end.line,range.end.column);var retained=new ShaderRange;retained.set(start,end);return retained};_proto._parseRenderStateAndTags=function _parseRenderStateAndTags(token,start,outGlobalContents,outRenderStates,outTags){switch(token.type){case Keyword.GSTags:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseTags(outTags);start=this._lexer.getShaderPosition(0);break;default:start=this._parseRenderState(token,start,outGlobalContents,outRenderStates)}return start};_proto._parseRenderState=function _parseRenderState(token,start,outGlobalContents,outRenderStates){switch(token.type){case Keyword.GSBlendState:case Keyword.GSDepthState:case Keyword.GSRasterState:case Keyword.GSStencilState:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseRenderStateDeclarationOrAssignment(outRenderStates,token);start=this._lexer.getShaderPosition(0);break;case Keyword.GSBlendFactor:case Keyword.GSBlendOperation:case Keyword.GSBool:case Keyword.GSNumber:case Keyword.GSColor:case Keyword.GSCompareFunction:case Keyword.GSStencilOperation:case Keyword.GSCullMode:case Keyword.GSColorWriteMask:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseVariableDeclaration();start=this._lexer.getShaderPosition(0);break;case Keyword.GSRenderQueueType:this._addPendingContents(start,token.lexeme.length,outGlobalContents);this._parseRenderQueueDeclarationOrAssignment(outRenderStates);start=this._lexer.getShaderPosition(0);break;default:this._lexer.hasPendingContent=true}return start};return ShaderSourceParserSession}();var nextNodePoolId=0;var ParserObjectPool=function(){function ParserObjectPool(){this._tokens={values:[],used:0};this._positions={values:[],used:0};this._ranges={values:[],used:0};this._nodes=[]}var _proto=ParserObjectPool.prototype;_proto.reset=function reset(){this._tokens.used=0;this._positions.used=0;this._ranges.used=0;for(var _iterator=_create_for_of_iterator_helper_loose(this._nodes),_step;!(_step=_iterator()).done;){var list=_step.value;if(list)list.used=0}};_proto.createToken=function createToken(){var list=this._tokens;var index=list.used++;var _list_values_index;return(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new BaseToken(this)};_proto.createPosition=function createPosition(index,line,column){var list=this._positions;var itemIndex=list.used++;var _list_values_itemIndex;var position=(_list_values_itemIndex=list.values[itemIndex])!=null?_list_values_itemIndex:list.values[itemIndex]=new ShaderPosition;position.set(index,line,column);return position};_proto.createRange=function createRange(start,end){var list=this._ranges;var index=list.used++;var _list_values_index;var range=(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new ShaderRange;range.set(start,end);return range};_proto.createNode=function createNode(type){var pooledType=type;var _pooledType___parserObjectPoolId;var poolId=(_pooledType___parserObjectPoolId=pooledType.__parserObjectPoolId)!=null?_pooledType___parserObjectPoolId:pooledType.__parserObjectPoolId=nextNodePoolId++;var list=this._nodes[poolId];if(!list){list={values:[],used:0};this._nodes[poolId]=list}var index=list.used++;var _list_values_index;return(_list_values_index=list.values[index])!=null?_list_values_index:list.values[index]=new type};return ParserObjectPool}();var GLESShaderInfo=function GLESShaderInfo(ir,coreInfo){var io=coreInfo.io,vertexEntry=coreInfo.vertexEntry,fragmentEntry=coreInfo.fragmentEntry,getDeclarationCoexistence=coreInfo.getDeclarationCoexistence,getBranchCoverage=coreInfo.getBranchCoverage;this.mrtOutputIssues=collectMrtOutputIssues(io.mrtList,getDeclarationCoexistence);this.invalidMrtReturnLocations=collectInvalidEntryReturns(fragmentEntry.functions,io.mrtStructs,false);this.invalidVaryingReturnLocations=collectInvalidEntryReturns(vertexEntry.functions,io.varyingStructs,true);this.structMemberOwnerIssues=collectStructMemberOwnerIssues([].concat(vertexEntry.functions,fragmentEntry.functions),ir.shaderData.directMemberOwnerReferences,ir.shaderData.referenceResolutionSnapshots,io.structVariableRoles,getBranchCoverage)};function collectStructMemberOwnerIssues(entries,directMemberReferences,snapshots,variableRoles,getBranchCoverage){var _loop=function(){var reference=_step1.value;var _snapshotsByReference_get;if(!isReferenceReachable(reference,reachableFunctions))return\"continue\";var child=reference.children[0];var referenceSnapshots=(_snapshotsByReference_get=snapshotsByReference.get(reference))==null?void 0:_snapshotsByReference_get.filter(function(snapshot){return snapshot.replacementMemberOwner===undefined&&(_instanceof(child,BaseToken)||snapshot.isValueIdentity)});var resolutions=void 0;if(_instanceof(child,BaseToken)){var symbols=reference.resolvedValueSymbols();resolutions=(referenceSnapshots==null?void 0:referenceSnapshots.length)?referenceSnapshots:[{symbols:symbols,fallbackStart:symbols.length,callSiteBranch:reference._branch}]}else if(_instanceof(child,ASTNode.MacroCallSymbol)||_instanceof(child,ASTNode.MacroCallFunction)){resolutions=referenceSnapshots}if(resolutions==null?void 0:resolutions.length){var hasUnresolvedMacroOwner=!_instanceof(child,BaseToken)&&resolutions.some(function(resolution){return resolution.symbols.length===0});if(hasUnresolvedMacroOwner){recordOwnerIssue(issues,reference,\"unresolved-owner\",\"unknown\")}var member=_instanceof(child,BaseToken)||hasUnresolvedMacroOwner?undefined:findDirectMember(reference);if(member){recordOwnerIssue(issues,reference,\"incompatible-io-member\",classifyIOMemberAvailability(member,resolutions,variableRoles,getBranchCoverage))}recordOwnerIssue(issues,reference,\"mixed-owner-roles\",classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage))}};var visitedFunctions=new Set;var reachableFunctions=new Set;var pending=entries.slice();while(pending.length){var _pending;var fn=pending.pop();if(visitedFunctions.has(fn))continue;visitedFunctions.add(fn);reachableFunctions.add(fn.astNode);(_pending=pending).push.apply(_pending,[].concat(fn.calledFunctions))}var snapshotsByReference=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(snapshots),_step;!(_step=_iterator()).done;){var snapshot=_step.value;var referenceSnapshots=snapshotsByReference.get(snapshot.reference);if(!referenceSnapshots)snapshotsByReference.set(snapshot.reference,referenceSnapshots=[]);referenceSnapshots.push(snapshot)}var issues=new Map;for(var _iterator1=_create_for_of_iterator_helper_loose(directMemberReferences),_step1;!(_step1=_iterator1()).done;)_loop();var replacementOwnerGroups=new Map;for(var _iterator2=_create_for_of_iterator_helper_loose(snapshots),_step2;!(_step2=_iterator2()).done;){var snapshot1=_step2.value;var owner=snapshot1.replacementMemberOwner;if(owner===undefined||!isReferenceReachable(snapshot1.reference,reachableFunctions))continue;var ownerGroups=replacementOwnerGroups.get(snapshot1.reference);if(!ownerGroups)replacementOwnerGroups.set(snapshot1.reference,ownerGroups=new Map);var group=ownerGroups.get(owner);if(!group)ownerGroups.set(owner,group=[]);group.push(snapshot1)}for(var _iterator3=_create_for_of_iterator_helper_loose(replacementOwnerGroups),_step3;!(_step3=_iterator3()).done;){var _step_value=_step3.value,reference=_step_value[0],ownerGroups1=_step_value[1];for(var _iterator4=_create_for_of_iterator_helper_loose(ownerGroups1.values()),_step4;!(_step4=_iterator4()).done;){var resolutions=_step4.value;if(resolutions.some(function(resolution){return resolution.symbols.length===0})){recordOwnerIssue(issues,reference,\"unresolved-owner\",\"unknown\")}if(resolutions.some(function(resolution){return resolution.requiresRuntimeOwnerExpansion})){recordOwnerIssue(issues,reference,\"runtime-expanded-io-owner\",classifyRuntimeExpandedOwner(resolutions,variableRoles,getBranchCoverage))}recordOwnerIssue(issues,reference,\"mixed-owner-roles\",classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage))}}return Array.from(issues,function(param){var reference=param[0],issue=param[1];return _extends({location:reference.location},issue)})}function isReferenceReachable(reference,reachableFunctions){var current=reference.parent;while(current){if(_instanceof(current,ASTNode.FunctionDefinition))return reachableFunctions.has(current);current=current.parent}return false}function findDirectMember(reference){var current=reference.parent;while(current){if(_instanceof(current,ASTNode.PostfixExpression)&¤t.children.length===3){var base=current.children[0];var member=current.children[2];if(_instanceof(base,TreeNode)&&_instanceof(member,BaseToken)&&ParserUtils.unwrapBareIdentifier(base,{allowParens:true})===reference){return member}}current=current.parent}return undefined}function classifyIOMemberAvailability(member,resolutions,variableRoles,getBranchCoverage){var certainty;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primarySymbols=resolution.symbols.slice(0,resolution.fallbackStart);var primaryCoverage=getBranchCoverage(primarySymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);var retainedSymbols=primaryCoverage===\"covered\"?primarySymbols:resolution.symbols;for(var _iterator1=_create_for_of_iterator_helper_loose(retainedSymbols),_step1;!(_step1=_iterator1()).done;){var symbol=_step1.value;var _symbol_dataType;if(!_instanceof(symbol,VarSymbol)||!variableRoles.has(symbol))continue;var _symbol_branchSignature;var ownerBranch=mergeBranchSignatures(resolution.callSiteBranch,(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH);var memberBranches=[];var _symbol_dataType_structDeclarations;for(var _iterator2=_create_for_of_iterator_helper_loose((_symbol_dataType_structDeclarations=(_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations)!=null?_symbol_dataType_structDeclarations:[]),_step2;!(_step2=_iterator2()).done;){var struct=_step2.value;for(var _iterator3=_create_for_of_iterator_helper_loose(struct.propList),_step3;!(_step3=_iterator3()).done;){var prop=_step3.value;if(prop.ident.lexeme!==member.lexeme)continue;memberBranches.push(mergeBranchSignatures(ownerBranch,struct._branch,prop.ident.branch))}}var memberCoverage=getBranchCoverage(memberBranches,ownerBranch);if(!memberBranches.length||memberCoverage===\"uncovered\")return\"definite\";if(memberCoverage===\"unknown\")certainty=\"unknown\"}}return certainty}function mergeBranchSignatures(){for(var _len=arguments.length,branches=new Array(_len),_key=0;_key<_len;_key++){branches[_key]=arguments[_key]}var merged=[];for(var _iterator=_create_for_of_iterator_helper_loose(branches),_step;!(_step=_iterator()).done;){var branch=_step.value;for(var _iterator1=_create_for_of_iterator_helper_loose(branch),_step1;!(_step1=_iterator1()).done;){var constraint=_step1.value;if(merged.indexOf(constraint)===-1)merged.push(constraint)}}return merged}function classifyOwnerResolutions(reference,resolutions,variableRoles,getBranchCoverage){var resolutionKinds=[];var hasUnknownConflict=false;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primaryBranches=[];for(var i=0;i<resolution.fallbackStart;i++){var _resolution_symbols_i_branchSignature;primaryBranches.push((_resolution_symbols_i_branchSignature=resolution.symbols[i].branchSignature)!=null?_resolution_symbols_i_branchSignature:EMPTY_BRANCH)}var primaryCoverage=getBranchCoverage(primaryBranches,resolution.callSiteBranch);var primaryKinds=collectOwnerKinds(resolution.symbols,variableRoles,resolution.fallbackStart);var retainedKinds=primaryCoverage===\"covered\"?primaryKinds:collectOwnerKinds(resolution.symbols,variableRoles);if(retainedKinds.size>1){if(primaryKinds.size>1&&primaryCoverage===\"covered\"||primaryKinds.size<=1&&primaryCoverage===\"uncovered\"){return\"definite\"}hasUnknownConflict=true}for(var _iterator1=_create_for_of_iterator_helper_loose(retainedKinds),_step1;!(_step1=_iterator1()).done;){var kind=_step1.value;if(resolutionKinds.indexOf(kind)===-1)resolutionKinds.push(kind)}}if(hasUnknownConflict)return\"unknown\";if(resolutionKinds.length<=1)return undefined;var replacementCoverage=getBranchCoverage(resolutions.map(function(resolution){return resolution.callSiteBranch}),reference._branch);return replacementCoverage===\"covered\"?\"definite\":\"unknown\"}function classifyRuntimeExpandedOwner(resolutions,variableRoles,getBranchCoverage){var hasUnknownIOOwner=false;for(var _iterator=_create_for_of_iterator_helper_loose(resolutions),_step;!(_step=_iterator()).done;){var resolution=_step.value;var primarySymbols=resolution.symbols.slice(0,resolution.fallbackStart);var primaryCoverage=getBranchCoverage(primarySymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);var retainedSymbols=primaryCoverage===\"covered\"?primarySymbols:resolution.symbols;if(!containsStructIORole(retainedSymbols,variableRoles))continue;var retainedCoverage=primaryCoverage===\"covered\"?primaryCoverage:getBranchCoverage(retainedSymbols.map(function(symbol){var _symbol_branchSignature;return(_symbol_branchSignature=symbol.branchSignature)!=null?_symbol_branchSignature:EMPTY_BRANCH}),resolution.callSiteBranch);if(retainedCoverage===\"covered\")return\"definite\";hasUnknownIOOwner=true}return hasUnknownIOOwner?\"unknown\":undefined}function containsStructIORole(symbols,variableRoles){return symbols.some(function(symbol){return _instanceof(symbol,VarSymbol)&&variableRoles.has(symbol)})}function collectOwnerKinds(symbols,variableRoles,end){if(end===void 0)end=symbols.length;var kinds=new Set;for(var i=0;i<end;i++){var symbol=symbols[i];var _variableRoles_get;if(_instanceof(symbol,VarSymbol))kinds.add((_variableRoles_get=variableRoles.get(symbol))!=null?_variableRoles_get:\"ordinary\")}return kinds}function recordOwnerIssue(issues,reference,kind,certainty){if(!certainty)return;var existing=issues.get(reference);if(!existing||existing.certainty===\"unknown\"&&certainty===\"definite\"){issues.set(reference,{kind:kind,certainty:certainty})}}function collectInvalidEntryReturns(functions,ioStructs,allowFunctionResult){var locations=[];for(var _iterator=_create_for_of_iterator_helper_loose(functions),_step;!(_step=_iterator()).done;){var fn=_step.value;var returnStructs=fn.astNode.protoType.returnType.typeSpecifier.structDeclarations;if(!returnStructs.some(function(struct){return ioStructs.includes(struct)}))continue;collectInvalidReturnsInNode(fn.astNode.statements,returnStructs,allowFunctionResult,locations)}return locations}function collectInvalidReturnsInNode(node,returnStructs,allowFunctionResult,out){if(_instanceof(node,ASTNode.JumpStatement)&&node.children.length===3){var expression=node.children[1];if(!_instanceof(expression,TreeNode)||!isEntryReturnExpression(expression,returnStructs,allowFunctionResult)){out.push(node.location)}return}for(var _iterator=_create_for_of_iterator_helper_loose(node.children),_step;!(_step=_iterator()).done;){var child=_step.value;if(_instanceof(child,TreeNode))collectInvalidReturnsInNode(child,returnStructs,allowFunctionResult,out)}}function isEntryReturnExpression(expression,returnStructs,allowFunctionResult){var _generic_fnSymbol_dataType;var variable=ParserUtils.unwrapBareIdentifier(expression,{allowParens:true});var _variable_resolvedValueSymbols;var symbols=(_variable_resolvedValueSymbols=variable==null?void 0:variable.resolvedValueSymbols())!=null?_variable_resolvedValueSymbols:[];if(symbols.length>0&&symbols.every(function(symbol){var _symbol_dataType;return _instanceof(symbol,VarSymbol)&&((_symbol_dataType=symbol.dataType)==null?void 0:_symbol_dataType.structDeclarations.some(function(struct){return returnStructs.includes(struct)}))}))return true;if(!allowFunctionResult)return false;var call=ParserUtils.unwrapNodeByType(expression,NoneTerminal.function_call);var generic=call==null?void 0:call.children[0];return _instanceof(generic==null?void 0:generic.fnSymbol,FnSymbol)&&((_generic_fnSymbol_dataType=generic.fnSymbol.dataType)==null?void 0:_generic_fnSymbol_dataType.structDeclarations.some(function(struct){return returnStructs.includes(struct)}))===true}function collectMrtOutputIssues(props,getDeclarationCoexistence){var _loop=function(){var prop=_step.value;var _occupiedLocations_get;if(prop.typeInfo.type!==Keyword.VEC4){issues.push({prop:prop,kind:\"invalid-type\"})}var location=prop.mrtIndex;if(location===undefined){issues.push({prop:prop,kind:\"missing-location\"})}else if(!Number.isInteger(location)||location<0){issues.push({prop:prop,kind:\"invalid-location\"})}else if((_occupiedLocations_get=occupiedLocations.get(location))==null?void 0:_occupiedLocations_get.some(function(existing){return getDeclarationCoexistence(existing.ident.branch,prop.ident.branch)===\"coexist\"})){issues.push({prop:prop,kind:\"duplicate-location\"})}else{var _occupiedLocations_get1;var occupants=(_occupiedLocations_get1=occupiedLocations.get(location))!=null?_occupiedLocations_get1:[];occupants.push(prop);occupiedLocations.set(location,occupants)}};var issues=[];var occupiedLocations=new Map;for(var _iterator=_create_for_of_iterator_helper_loose(props),_step;!(_step=_iterator()).done;)_loop();return issues}export{GSError as $,ASTNode as A,BaseToken as B,ShaderData as C,StructSymbol as D,EMPTY_BRANCH as E,FnSymbol as F,Grammar as G,SymbolDataType as H,ESymbolType as I,SymbolInfo as J,Keyword as K,Lexer as L,ShaderClueIR as M,NoneTerminal as N,ShaderStructRole as O,ShaderCoreInfo as P,ShaderBuiltinSemantic as Q,createShaderDeclarationOwnership as R,ShaderTargetParser as S,TypeAny as T,isDeferredDeclarationPair as U,VarSymbol as V,ShaderSourceParser as W,ShaderSourceFactory as X,Preprocessor as Y,ParserObjectPool as Z,ParserUtils as _,EOF as a,GSErrorName as a0,ShaderCompilerUtils as a1,GLESShaderInfo as a2,_instanceof as a3,canBranchesOverlap as a4,getBranchCoverage as a5,_create_for_of_iterator_helper_loose as a6,BuiltinVariable as a7,BuiltinFunction as a8,_inherits as a9,__generator as aa,_extends as ab,isConditionalChainExhaustive as ac,isBranchReachable as ad,TypeSystem as ae,branchAnalysis as af,normalizeShaderSourceFile as ag,parseShaderPassWith as ah,shaderSourceBaseURL as ai,areConditionsComplementary as aj,isBranchVisibleFrom as ak,canDeclarationsCoexist as al,getDeclarationCoexistence as am,getBranchReachability as an,canBranchesCoverCallsite as ao,mapExpandedShaderRange as ap,createParsedShaderPass as aq,GenericType as ar,BuiltinVariableTable as as,ParserSemanticValidation as at,formatDiagnosticSource as au,getParsedShaderPassPayload as b,canInheritanceBranchesCover as c,ShaderRange as d,ShaderPosition as e,ETokenType as f,getLexicalDeclarationCoexistence as g,BaseLexer as h,parsePreprocessorCondition as i,toPreprocessorCondition as j,SymbolTable as k,SymbolTableStack as l,mapExpandedShaderError as m,normalizeShaderIncludeMap as n,EShaderStage as o,proveInheritanceBranchesCover as p,LALR1 as q,addTranslationRule as r,sameBranch as s,tryParsePreprocessorCondition as t,createGrammar as u,createRuntimeShaderTargetParser as v,parseRuntimeShaderPass as w,TreeNode as x,SymbolType as y,StructProp as z};\n//# sourceMappingURL=GLESShaderInfo.module.js.map\n","function _type_of(obj) {\n \"@swc/helpers - typeof\";\n\n return obj && typeof Symbol !== \"undefined\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n}\nexport { _type_of as _ };\n","function _set_prototype_of(o, p) {\n _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {\n o.__proto__ = p;\n\n return o;\n };\n\n return _set_prototype_of(o, p);\n}\nexport { _set_prototype_of as _ };\n","import { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\n\nfunction _inherits(subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function\");\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } });\n\n if (superClass) _set_prototype_of(subClass, superClass);\n}\nexport { _inherits as _ };\n","function _is_native_reflect_construct() {\n // Since Reflect.construct can't be properly polyfilled, some\n // implementations (e.g. core-js@2) don't set the correct internal slots.\n // Those polyfills don't allow us to subclass built-ins, so we need to\n // use our fallback implementation.\n try {\n // If the internal slots aren't set, this throws an error similar to\n // TypeError: this is not a Boolean object.\n var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));\n } catch (_) {}\n return (_is_native_reflect_construct = function() {\n return !!result;\n })();\n}\n\nexport { _is_native_reflect_construct as _ };\n","import { _ as _is_native_reflect_construct } from \"./_is_native_reflect_construct.js\";\nimport { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\nfunction _construct(Parent, args, Class) {\n if (_is_native_reflect_construct()) _construct = Reflect.construct;\n else {\n _construct = function construct(Parent, args, Class) {\n var a = [null];\n a.push.apply(a, args);\n var Constructor = Function.bind.apply(Parent, a);\n var instance = new Constructor();\n\n if (Class) _set_prototype_of(instance, Class.prototype);\n\n return instance;\n };\n }\n\n return _construct.apply(null, arguments);\n}\nexport { _construct as _ };\n","function _get_prototype_of(o) {\n _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {\n return o.__proto__ || Object.getPrototypeOf(o);\n };\n\n return _get_prototype_of(o);\n}\nexport { _get_prototype_of as _ };\n","import { _ as _construct } from \"./_construct.js\";\nimport { _ as _get_prototype_of } from \"./_get_prototype_of.js\";\nimport { _ as _is_native_function } from \"./_is_native_function.js\";\nimport { _ as _set_prototype_of } from \"./_set_prototype_of.js\";\n\nfunction _wrap_native_super(Class) {\n var _cache = typeof Map === \"function\" ? new Map() : undefined;\n _wrap_native_super = function(Class) {\n if (Class === null || !_is_native_function(Class)) return Class;\n if (typeof Class !== \"function\") throw new TypeError(\"Super expression must either be null or a function\");\n if (typeof _cache !== \"undefined\") {\n if (_cache.has(Class)) return _cache.get(Class);\n _cache.set(Class, Wrapper);\n }\n\n function Wrapper() {\n return _construct(Class, arguments, _get_prototype_of(this).constructor);\n }\n Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } });\n\n return _set_prototype_of(Wrapper, Class);\n };\n\n return _wrap_native_super(Class);\n}\nexport { _wrap_native_super as _ };\n","function _is_native_function(fn) {\n return Function.toString.call(fn).indexOf(\"[native code]\") !== -1;\n}\nexport { _is_native_function as _ };\n","function _array_like_to_array(arr, len) {\n if (len == null || len > arr.length) len = arr.length;\n\n for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];\n\n return arr2;\n}\nexport { _array_like_to_array as _ };\n","import { _ as _unsupported_iterable_to_array } from \"./_unsupported_iterable_to_array.js\";\n\nfunction _create_for_of_iterator_helper_loose(o, allowArrayLike) {\n var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"];\n\n if (it) return (it = it.call(o)).next.bind(it);\n // Fallback for engines without symbol support\n if (Array.isArray(o) || (it = _unsupported_iterable_to_array(o)) || allowArrayLike && o && typeof o.length === \"number\") {\n if (it) o = it;\n\n var i = 0;\n\n return function() {\n if (i >= o.length) return { done: true };\n\n return { done: false, value: o[i++] };\n };\n }\n\n throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nexport { _create_for_of_iterator_helper_loose as _ };\n","import { _ as _array_like_to_array } from \"./_array_like_to_array.js\";\n\nfunction _unsupported_iterable_to_array(o, minLen) {\n if (!o) return;\n if (typeof o === \"string\") return _array_like_to_array(o, minLen);\n\n var n = Object.prototype.toString.call(o).slice(8, -1);\n\n if (n === \"Object\" && o.constructor) n = o.constructor.name;\n if (n === \"Map\" || n === \"Set\") return Array.from(n);\n if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);\n}\nexport { _unsupported_iterable_to_array as _ };\n","/**\n * Words that ShaderLab accepts as identifiers but GLSL ES 1.00 or 3.00 reserves. GLES100 output also runs as\n * GLSL ES 3.00 on WebGL2, so both versions apply to every target.\n */\nconst reservedWords = new Set(\n (\n \"asm attribute active atomic_uint case cast centroid class coherent common default double dvec2 dvec3 dvec4 \" +\n \"enum extern external filter fixed flat fvec2 fvec3 fvec4 goto half hvec2 hvec3 hvec4 iimage1D iimage1DArray \" +\n \"iimage2D iimage2DArray iimage3D iimageBuffer iimageCube image1D image1DArray image2D image2DArray image3D \" +\n \"imageBuffer imageCube inline input interface isampler1D isampler1DArray isampler2D isampler2DArray \" +\n \"isampler2DMS isampler2DMSArray isampler2DRect isampler3D isamplerBuffer isamplerCube layout long mat2x2 \" +\n \"mat2x3 mat2x4 mat3x2 mat3x3 mat3x4 mat4x2 mat4x3 mat4x4 namespace noinline noperspective output packed \" +\n \"partition patch public readonly resource restrict sample sampler1D sampler1DArray sampler1DArrayShadow \" +\n \"sampler1DShadow sampler2DArray sampler2DArrayShadow sampler2DMS sampler2DMSArray sampler2DRect \" +\n \"sampler2DRectShadow sampler2DShadow sampler3D sampler3DRect samplerBuffer samplerCubeShadow short sizeof \" +\n \"smooth static subroutine superp switch template this typedef uimage1D uimage1DArray uimage2D uimage2DArray \" +\n \"uimage3D uimageBuffer uimageCube uint union unsigned usampler1D usampler1DArray usampler2D usampler2DArray \" +\n \"usampler2DMS usampler2DMSArray usampler2DRect usampler3D usamplerBuffer usamplerCube using uvec2 uvec3 uvec4 \" +\n \"varying volatile writeonly\"\n ).split(\" \")\n);\n\n/**\n * Tests whether GLSL ES rejects an identifier that ShaderLab accepts.\n * @param name - Source identifier\n * @returns Whether the identifier uses a reserved word or namespace\n * @internal\n */\nexport function isUnsafeGLSLIdentifier(name: string): boolean {\n return reservedWords.has(name) || name.startsWith(\"gl_\") || name.includes(\"__\");\n}\n\n/**\n * Allocates generated identifiers that avoid source identifiers and each other.\n * @internal\n */\nexport class NameAllocator {\n private readonly _used = new Set<string>();\n private readonly _names = new Map<unknown, string>();\n\n /**\n * Reserves a source identifier so that generated names never shadow it.\n * @param name - Source identifier\n */\n reserve(name: string): void {\n this._used.add(name);\n }\n\n /**\n * Keeps a source identifier when GLSL accepts it, otherwise assigns a legal name to its identity.\n * @param key - Source declaration or namespace identity\n * @param name - Source identifier\n * @returns Identifier used by the declaration and its references\n */\n sourceName(key: unknown, name: string): string {\n if (!isUnsafeGLSLIdentifier(name)) return name;\n return this.allocate(key, name.startsWith(\"gl_\") ? `user_${name}` : `${name}_`);\n }\n\n /**\n * Returns the same identifier for every request with the same key.\n * @param key - Identity of the generated declaration, independent of its spelling\n * @param preferred - Readable base name. Repeated underscores collapse to one, because WebGL rejects `__`\n * @returns An identifier that differs from every reserved and previously allocated name\n */\n allocate(key: unknown, preferred: string): string {\n let name = this._names.get(key);\n if (name === undefined) {\n const base = preferred.replace(/_{2,}/g, \"_\");\n const separator = base.endsWith(\"_\") ? \"\" : \"_\";\n name = base;\n for (let suffix = 1; this._used.has(name); suffix++) name = `${base}${separator}${suffix}`;\n this._used.add(name);\n this._names.set(key, name);\n }\n return name;\n }\n\n /** Releases all reservations and allocations between compilation requests. */\n reset(): void {\n this._used.clear();\n this._names.clear();\n }\n}\n","import { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { SymbolTable } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType, SymbolInfo, VarSymbol } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole, StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { NameAllocator } from \"./NameAllocator\";\n\n/** @internal */\nexport class VisitorContext {\n readonly names = new NameAllocator();\n private readonly _lookupSymbol = new SymbolInfo(\"\", null);\n private readonly _structRoles = new Map<ASTNode.StructSpecifier, ShaderStructRole>();\n private readonly _vertexUnresolvedVariableRoles = new Map<string, ShaderStructRole>();\n private readonly _fragmentUnresolvedVariableRoles = new Map<string, ShaderStructRole>();\n private readonly _vertexAmbiguousVariableNames = new Set<string>();\n private readonly _fragmentAmbiguousVariableNames = new Set<string>();\n\n attributeStructs: ASTNode.StructSpecifier[] = [];\n attributeList: StructProp[] = [];\n varyingStructs: ASTNode.StructSpecifier[] = [];\n varyingList: StructProp[] = [];\n mrtStructs: ASTNode.StructSpecifier[] = [];\n mrtList: StructProp[] = [];\n\n stage: EShaderStage;\n stageEntry: string;\n\n _referencedAttributeList: Record<string, StructProp[]>;\n _referencedVaryingList: Record<string, StructProp[]>;\n _referencedMRTList: Record<string, StructProp[]>;\n _referencedGlobals: Record<string, SymbolInfo[]>;\n readonly _referencedGlobalSymbols = new Set<SymbolInfo>();\n private _globalSymbolQueries: Record<string, Partial<Record<ESymbolType, SymbolInfo[]>>>;\n _referencedGlobalMacroASTs: TreeNode[] = [];\n private readonly _structVariableRoles = new Map<VarSymbol, ShaderStructRole>();\n\n _passSymbolTable?: SymbolTable<SymbolInfo>;\n /** Receives every global use, including uses of declarations already discovered. */\n onReferenceGlobal?: (symbols: readonly SymbolInfo[]) => void;\n /** Receives interface uses so generated fields retain their declaration dependencies. */\n onReferenceStructProps?: (props: readonly StructProp[]) => void;\n readonly codeCache = new Map<TreeNode, string>();\n\n constructor() {\n this.reset();\n }\n\n reset(resetAll = true) {\n this.codeCache.clear();\n if (resetAll) {\n this.attributeStructs.length = 0;\n this.attributeList.length = 0;\n this.varyingStructs.length = 0;\n this.varyingList.length = 0;\n this.mrtStructs.length = 0;\n this.mrtList.length = 0;\n this._structRoles.clear();\n this._vertexUnresolvedVariableRoles.clear();\n this._fragmentUnresolvedVariableRoles.clear();\n this._vertexAmbiguousVariableNames.clear();\n this._fragmentAmbiguousVariableNames.clear();\n }\n\n this._referencedAttributeList = Object.create(null);\n this._referencedVaryingList = Object.create(null);\n this._referencedMRTList = Object.create(null);\n this._referencedGlobals = Object.create(null);\n this._referencedGlobalSymbols.clear();\n this._globalSymbolQueries = Object.create(null);\n this._referencedGlobalMacroASTs.length = 0;\n if (resetAll) {\n this._structVariableRoles.clear();\n this._passSymbolTable = undefined;\n }\n }\n\n /**\n * Finds the shared interface role of custom-struct declaration candidates.\n * @param declarations - Exact parser struct identities resolved at one type occurrence.\n * @returns Interface role, or `undefined` when the type is not an unambiguous interface struct.\n */\n getStructRole(declarations: readonly ASTNode.StructSpecifier[]): ShaderStructRole | undefined {\n let resolvedRole: ShaderStructRole | undefined;\n for (const declaration of declarations) {\n const role = this._structRoles.get(declaration);\n if (!role || (resolvedRole && resolvedRole !== role)) return;\n resolvedRole = role;\n }\n return resolvedRole;\n }\n\n /**\n * Tests the exact interface role of one struct declaration.\n * @param declaration - Parser struct identity.\n * @param role - Expected interface role.\n * @returns Whether the declaration owns that role.\n */\n hasStructRole(declaration: ASTNode.StructSpecifier, role: ShaderStructRole): boolean {\n return this._structRoles.get(declaration) === role;\n }\n\n /**\n * Registers stage-interface struct types for constant-time role lookup.\n * @param role - Interface role shared by the supplied structs.\n * @param structs - Struct declarations derived from parser IR.\n * @internal\n */\n registerStructTypes(role: ShaderStructRole, structs: readonly ASTNode.StructSpecifier[]): void {\n for (const struct of structs) {\n this._structRoles.set(struct, role);\n }\n }\n\n /**\n * Registers a resolved variable that holds an interface struct.\n * @param variable - Parser symbol identity for the declaration.\n * @param role - Struct interface role.\n * @param stage - Optional stage from whose entry the variable is reachable. Omit when only exact\n * symbol lookup is required.\n */\n registerStructVar(variable: VarSymbol, role: ShaderStructRole, stage?: EShaderStage): void {\n this._structVariableRoles.set(variable, role);\n if (stage === undefined) return;\n const roles =\n stage === EShaderStage.VERTEX ? this._vertexUnresolvedVariableRoles : this._fragmentUnresolvedVariableRoles;\n const ambiguous =\n stage === EShaderStage.VERTEX ? this._vertexAmbiguousVariableNames : this._fragmentAmbiguousVariableNames;\n const name = variable.ident;\n if (ambiguous.has(name)) return;\n const existing = roles.get(name);\n if (existing && existing !== role) {\n roles.delete(name);\n ambiguous.add(name);\n } else {\n roles.set(name, role);\n }\n }\n\n /**\n * Finds an interface role for a global macro value that has no lexical symbol identity.\n * @param variableName - Bare variable name in the macro replacement AST.\n * @returns A role only when every stage-reachable declaration with that name agrees.\n */\n getUnresolvedStructVarRole(variableName: string): ShaderStructRole | undefined {\n const roles =\n this.stage === EShaderStage.VERTEX ? this._vertexUnresolvedVariableRoles : this._fragmentUnresolvedVariableRoles;\n const ambiguous =\n this.stage === EShaderStage.VERTEX ? this._vertexAmbiguousVariableNames : this._fragmentAmbiguousVariableNames;\n return ambiguous.has(variableName) ? undefined : roles.get(variableName);\n }\n\n /**\n * Finds the shared interface role of branch-visible variable candidates.\n * @param symbols - Exact parser symbols resolved at one reference.\n * @returns Interface role, or `undefined` when the reference is not an unambiguous interface value.\n */\n getStructVarRole(symbols: readonly SymbolInfo[]): ShaderStructRole | undefined {\n let resolvedRole: ShaderStructRole | undefined;\n for (const symbol of symbols) {\n if (!(symbol instanceof VarSymbol)) return;\n const role = this._structVariableRoles.get(symbol);\n if (!role || (resolvedRole && resolvedRole !== role)) return;\n resolvedRole = role;\n }\n return resolvedRole;\n }\n\n referenceAttribute(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.attributeList, this._referencedAttributeList);\n }\n\n referenceVarying(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.varyingList, this._referencedVaryingList);\n }\n\n referenceMRTProp(ident: BaseToken): void {\n this._referenceProp(ident.lexeme, this.mrtList, this._referencedMRTList);\n }\n\n referenceGlobal(ident: string, type: ESymbolType): void {\n const queries = (this._globalSymbolQueries[ident] ??= Object.create(null));\n let symbols = queries[type];\n if (!symbols) {\n this._lookupSymbol.set(ident, type);\n symbols = queries[type] = this._passSymbolTable!.getSymbols(this._lookupSymbol, true, []);\n const namedSymbols = (this._referencedGlobals[ident] ??= []);\n for (const symbol of symbols) {\n if (!this._referencedGlobalSymbols.has(symbol)) {\n this._referencedGlobalSymbols.add(symbol);\n namedSymbols.push(symbol);\n }\n }\n }\n // Repeated uses still establish edges from each declaration's owner.\n this.onReferenceGlobal?.(symbols);\n }\n\n // Track which IO props are actually referenced (drives in/out emission). A missing member is no\n // longer flagged here — that's the parser's struct-field check (UndeclaredStructMember).\n private _referenceProp(name: string, list: StructProp[], refList: Record<string, StructProp[]>): void {\n if (!refList[name]) refList[name] = list.filter((item) => item.ident.lexeme === name);\n this.onReferenceStructProps?.(refList[name]);\n }\n}\n","import type { IPoolElement } from \"@galacean/engine-core\";\n\nexport class TempArray<T> implements IPoolElement {\n array: Array<T> = new Array();\n\n dispose(): void {\n this.array.length = 0;\n }\n}\n","import { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType, FnSymbol } from \"@galacean/engine-shader-parser/internal\";\nimport { NodeChild, StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport type { BranchSignature, ICodeGenVisitor } from \"@galacean/engine-shader-parser/internal\";\nimport { VisitorContext } from \"./VisitorContext\";\nimport { ReturnableObjectPool } from \"@galacean/engine-core\";\nimport { TempArray } from \"../TempArray\";\n\n/**\n * @internal\n * The code generator\n */\nexport abstract class CodeGenVisitor implements ICodeGenVisitor {\n abstract getAttributeProp(prop: StructProp): string;\n abstract getVaryingProp(prop: StructProp): string;\n abstract getMRTProp(prop: StructProp): string | null;\n\n protected static _tmpArrayPool = new ReturnableObjectPool(TempArray<string>, 10);\n protected readonly context = new VisitorContext();\n\n cache(node: TreeNode, code: string): string {\n this.context.codeCache.set(node, code);\n return code;\n }\n\n getCachedCode(node: TreeNode): string | undefined {\n return this.context.codeCache.get(node);\n }\n\n defaultCodeGen(children: NodeChild[]) {\n const pool = CodeGenVisitor._tmpArrayPool;\n const ret = pool.get();\n ret.dispose();\n for (const child of children) {\n if (child instanceof BaseToken) {\n // Legacy opaque `#define` lexemes carry the directive verbatim; expression-style defines use the AST path\n ret.array.push(this.tokenLexeme(child));\n } else {\n ret.array.push(child.codeGen(this));\n }\n }\n const result = ret.array.join(\" \");\n ret.dispose();\n pool.return(ret);\n return result;\n }\n\n /**\n * Spells a source token in the generated code.\n * @param token - Source token\n * @returns Generated text for the token\n */\n protected tokenLexeme(token: BaseToken): string {\n return token.lexeme;\n }\n\n protected interfaceMemberName(name: string): string {\n return name;\n }\n\n visitPostfixExpression(node: ASTNode.PostfixExpression): string {\n const children = node.children;\n const derivationLength = children.length;\n const context = this.context;\n\n if (derivationLength === 3) {\n const postExpr = children[0] as ASTNode.PostfixExpression;\n const prop = children[2];\n\n if (prop instanceof BaseToken) {\n // Direct variables use parser symbol identity so lexical shadowing cannot inherit an IO role\n // from a same-named declaration. Macro-expanded identifiers can lack a resolved symbol, so\n // only that zero-symbol path consults the current stage's unambiguous name-to-role map.\n let role: ShaderStructRole | undefined;\n const directRoot = ParserUtils.unwrapBareIdentifier(postExpr, { allowParens: true });\n if (directRoot) {\n const symbols = directRoot.resolvedValueSymbols();\n const unresolvedName = ParserUtils.extractDirectIdentLexeme(postExpr);\n role = symbols.length\n ? context.getStructVarRole(symbols)\n : unresolvedName\n ? context.getUnresolvedStructVarRole(unresolvedName)\n : undefined;\n }\n\n if (!directRoot) role = context.getStructRole(node.resolvedMemberOwners);\n\n if (role) {\n if (role === ShaderStructRole.Attribute) context.referenceAttribute(prop);\n else if (role === ShaderStructRole.Varying) context.referenceVarying(prop);\n else context.referenceMRTProp(prop);\n }\n\n return `${postExpr.codeGen(this)}.${role ? this.interfaceMemberName(prop.lexeme) : prop.lexeme}`;\n } else {\n return `${postExpr.codeGen(this)}.${prop.codeGen(this)}`;\n }\n } else if (derivationLength === 4) {\n const identNode = children[0] as ASTNode.PostfixExpression;\n const indexNode = children[2] as ASTNode.Expression;\n return `${identNode.codeGen(this)}[${indexNode.codeGen(this)}]`;\n }\n\n return this.defaultCodeGen(node.children);\n }\n\n visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n for (const name of node.referenceGlobalSymbolNames) {\n this.context.referenceGlobal(name, ESymbolType.Any);\n }\n for (const symbol of node.resolvedSymbols()) {\n if (symbol instanceof FnSymbol) this.referenceFunction(symbol, node.location.start.index, node._branch);\n }\n\n return node.getLexeme(this);\n }\n\n protected referenceFunction(symbol: FnSymbol, referenceIndex: number, branch: BranchSignature): void {\n void referenceIndex;\n void branch;\n this.context.referenceGlobal(symbol.ident, ESymbolType.FN);\n }\n\n visitFunctionCall(node: ASTNode.FunctionCall): string {\n const call = node.children[0] as ASTNode.FunctionCallGeneric;\n if (call.fnSymbol instanceof FnSymbol) {\n for (const symbol of call.fnSymbols?.length ? call.fnSymbols : [call.fnSymbol]) {\n this.referenceFunction(symbol, node.location.start.index, node._branch);\n }\n }\n\n return this.defaultCodeGen(node.children);\n }\n\n visitMacroCallFunction(node: ASTNode.MacroCallFunction): string {\n const children = node.children;\n const paramList = children[2];\n if (paramList instanceof ASTNode.FunctionCallParameterList) {\n const astNodes = paramList.paramNodes;\n const params = astNodes;\n\n let paramsCode = \"\";\n for (let i = 0, length = params.length; i < length; i++) {\n const argNode = params[i];\n const code = argNode.codeGen(this);\n\n if (argNode instanceof ASTNode.MacroCallArgBlock || i === 0) {\n paramsCode += code;\n } else {\n paramsCode += `, ${code}`;\n }\n }\n\n return `${node.macroName}(${paramsCode})`;\n } else {\n return this.defaultCodeGen(node.children);\n }\n }\n\n visitStatementList(node: ASTNode.StatementList): string {\n const children = node.children as TreeNode[];\n if (children.length === 1) {\n return children[0].codeGen(this);\n } else {\n return `${children[0].codeGen(this)}\\n${children[1].codeGen(this)}`;\n }\n }\n\n /**\n * Code-generate a `#define` macro parsed as expression AST. Produces a `#define`\n * directive whose value retains ordinary expression and member-access semantics.\n */\n visitMacroDefine(node: ASTNode.MacroDefine): string {\n // For function-like macros, preserve the original `(params)` lexeme verbatim —\n // the parameter list is user-authored text that shouldn't be canonicalized.\n let paramsLexeme = \"\";\n if (node.isFunction) {\n const paramsToken = node.children[2];\n if (paramsToken instanceof BaseToken) paramsLexeme = paramsToken.lexeme;\n }\n const valueCode = node.valueExpression ? node.valueExpression.codeGen(this) : \"\";\n // Newlines around the directive keep `#` at the start of its physical line per\n // GLSL ES 3.0 §3.4, regardless of how surrounding tokens are joined.\n return `\\n#define ${node.macroName}${paramsLexeme}${valueCode ? \" \" + valueCode : \"\"}\\n`;\n }\n\n visitSingleDeclaration(node: ASTNode.SingleDeclaration): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitGlobalVariableDeclaration(node: ASTNode.VariableDeclaration): string {\n const children = node.children;\n const fullType = children[0];\n if (fullType instanceof ASTNode.FullySpecifiedType && fullType.typeSpecifier.isCustom) {\n const context = this.context;\n // Global interface variables are mutable shader values, not material bindings.\n if (context.getStructVarRole([node.declarator.symbol])) {\n return this.defaultCodeGen(children);\n }\n context.referenceGlobal(<string>fullType.type, ESymbolType.STRUCT);\n }\n return `uniform ${this.defaultCodeGen(children)}`;\n }\n\n visitDeclaration(node: ASTNode.Declaration): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitFunctionParameterList(node: ASTNode.FunctionParameterList): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitFunctionHeader(node: ASTNode.FunctionHeader): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitJumpStatement(node: ASTNode.JumpStatement): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitTypeSpecifier(node: ASTNode.TypeSpecifier): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitStructSpecifier(node: ASTNode.StructSpecifier): string {\n return this.defaultCodeGen(node.children);\n }\n\n visitFunctionDefinition(fnNode: ASTNode.FunctionDefinition): string {\n return this.defaultCodeGen(fnNode.children);\n }\n}\n","import type { Condition, PreprocessorExpressionParseResult, ShaderInstruction } from \"@galacean/engine-design\";\nimport { ShaderPreprocessorDirective } from \"@galacean/engine-core\";\nimport { parsePreprocessorExpression, toPreprocessorCondition } from \"@galacean/engine-shader-parser/internal\";\nimport type { DeferredDeclarationOwnership } from \"@galacean/engine-shader-parser/internal\";\n\nexport type { ShaderInstruction } from \"@galacean/engine-design\";\n\n/**\n * @internal\n */\nexport class ShaderInstructionEncoder {\n private static _DIRECTIVE_RE = /^[ \\t]*#[ \\t]*(if|ifdef|ifndef|elif|else|endif|define|undef)\\b(.*)/;\n private static _FUNC_MACRO_RE = /^(\\w+)\\(([^)]*)\\)\\s*(.*)/;\n\n /**\n * Marks compiler-owned text without placing parser objects in the instruction stream.\n * @param text - Declaration or derived declaration text.\n * @param owner - Neutral declaration identity, if runtime selection is required.\n * @param activate - Whether this is the declaration's original source position.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static declaration(text: string, owner?: DeferredDeclarationOwnership, activate = true): string {\n if (!owner) return text;\n const activation = activate ? `\\0D${owner.id},${owner.group},${owner.sourceScope}\\0\\n` : \"\";\n return text ? `${activation}\\0T${owner.id}\\0\\n${text}\\n\\0E\\0\\n` : activation;\n }\n\n /**\n * Marks derived text shared by any selected, reachable declaration without activating an owner.\n * @param text - Shared derived declaration text.\n * @param owners - Declarations that require the text; an empty list never retains it.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static sharedDeclaration(text: string, owners: readonly DeferredDeclarationOwnership[]): string {\n return text ? `\\0T${owners.map((owner) => owner.id).join(\",\")}\\0\\n${text}\\n\\0E\\0\\n` : \"\";\n }\n\n /**\n * Records a declaration dependency for variant-time reachability after ownership selection.\n * @param from - Referencing declaration identity, or zero for a stage root.\n * @param to - Referenced declaration identity.\n * @returns Intermediate source consumed by the instruction encoder.\n * @internal\n */\n static reference(from: number, to: number): string {\n return `\\0R${from},${to}\\0\\n`;\n }\n\n /**\n * Removes private emission markers from the public source view after instruction encoding.\n * @param source - Encoded intermediate stage source.\n * @returns GLSL source without compiler metadata.\n * @internal\n */\n static source(source: string): string {\n return source.indexOf(\"\\0\") < 0 ? source : source.replace(/\\0[^\\0]*\\0\\n?/g, \"\");\n }\n\n /**\n * Encodes generated GLSL directives into runtime-selectable instructions.\n * @param glsl - Generated stage source.\n * @param preprocessorExpressions - Parser-owned expression trees keyed by logical directive text.\n * @returns Runtime shader instruction stream.\n * @throws Error when a conditional directive is malformed or has a deterministic evaluation failure.\n * @internal\n */\n static parse(\n glsl: string,\n preprocessorExpressions?: ReadonlyMap<string, PreprocessorExpressionParseResult>\n ): ShaderInstruction[] {\n const instructions: ShaderInstruction[] = [];\n const length = glsl.length;\n let pos = 0;\n let owners: number[] | undefined;\n const backfillStack: number[][] = [];\n\n while (pos < length) {\n const directiveStart = ShaderInstructionEncoder._findDirectiveStart(glsl, pos, length);\n\n if (directiveStart === -1) {\n ShaderInstructionEncoder._pushText(instructions, glsl, pos, length, owners);\n break;\n }\n\n if (directiveStart > pos) {\n ShaderInstructionEncoder._pushText(instructions, glsl, pos, directiveStart, owners);\n }\n\n const lineEnd = ShaderInstructionEncoder._findLogicalLineEnd(glsl, directiveStart, length);\n const line = glsl.substring(directiveStart, lineEnd).replace(/\\\\(?:\\r\\n|\\n|\\r)/g, \"\");\n pos = lineEnd < length ? lineEnd + 1 : length;\n\n if (line.charCodeAt(0) === 0) {\n const kind = line.charAt(1);\n if (kind === \"D\") {\n const fields = line.slice(2, -1).split(\",\").map(Number);\n instructions.push([ShaderPreprocessorDirective.Declaration, fields[0], fields[1], fields[2]]);\n } else if (kind === \"R\") {\n const fields = line.slice(2, -1).split(\",\").map(Number);\n instructions.push([ShaderPreprocessorDirective.Reference, fields[0], fields[1]]);\n } else {\n const ids = line.slice(2, -1);\n owners = kind === \"T\" ? (ids ? ids.split(\",\").map(Number) : []) : undefined;\n }\n continue;\n }\n\n const match = ShaderInstructionEncoder._DIRECTIVE_RE.exec(line);\n if (!match) {\n const text = lineEnd < length ? line + \"\\n\" : line;\n ShaderInstructionEncoder._pushText(instructions, text, 0, text.length, owners);\n continue;\n }\n\n const keyword = match[1];\n const rest = match[2].trim();\n\n switch (keyword) {\n case \"ifdef\": {\n const idx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.IfDef, rest, -1]);\n backfillStack.push([idx]);\n break;\n }\n case \"ifndef\": {\n const idx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.IfNdef, rest, -1]);\n backfillStack.push([idx]);\n break;\n }\n case \"if\": {\n const cond = ShaderInstructionEncoder._parseCondition(rest, preprocessorExpressions);\n const idx = instructions.length;\n ShaderInstructionEncoder._pushConditionInstruction(instructions, cond);\n backfillStack.push([idx]);\n break;\n }\n case \"elif\": {\n const stack = backfillStack[backfillStack.length - 1];\n const prevIdx = stack[stack.length - 1];\n const elseIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Else, -1]);\n stack.push(elseIdx);\n ShaderInstructionEncoder._backfillJump(instructions[prevIdx], instructions.length);\n\n const cond = ShaderInstructionEncoder._parseCondition(rest, preprocessorExpressions);\n const idx = instructions.length;\n ShaderInstructionEncoder._pushConditionInstruction(instructions, cond);\n stack.push(idx);\n break;\n }\n case \"else\": {\n const stack = backfillStack[backfillStack.length - 1];\n const prevIdx = stack[stack.length - 1];\n const elseIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Else, -1]);\n stack.push(elseIdx);\n ShaderInstructionEncoder._backfillJump(instructions[prevIdx], instructions.length);\n break;\n }\n case \"endif\": {\n const endifIdx = instructions.length;\n instructions.push([ShaderPreprocessorDirective.Endif]);\n const stack = backfillStack.pop();\n if (stack) {\n const afterEndif = endifIdx + 1;\n for (let j = 0; j < stack.length; j++) {\n const inst = instructions[stack[j]];\n if (inst[0] === ShaderPreprocessorDirective.Else) {\n (inst as [number, number])[1] = afterEndif;\n } else {\n ShaderInstructionEncoder._backfillJump(inst, afterEndif, true);\n }\n }\n }\n break;\n }\n case \"define\": {\n const funcMatch = ShaderInstructionEncoder._FUNC_MACRO_RE.exec(rest);\n if (funcMatch) {\n const params = funcMatch[2]\n .split(\",\")\n .map((p) => p.trim())\n .filter((p) => p.length > 0);\n instructions.push([\n ShaderPreprocessorDirective.DefineFunc,\n funcMatch[1],\n params,\n ShaderInstructionEncoder._stripLineComment(funcMatch[3].trim())\n ]);\n } else {\n const separator = ShaderInstructionEncoder._findInlineWhitespace(rest);\n if (separator === rest.length) {\n instructions.push([ShaderPreprocessorDirective.Define, rest]);\n } else {\n instructions.push([\n ShaderPreprocessorDirective.DefineVal,\n rest.substring(0, separator),\n ShaderInstructionEncoder._stripLineComment(rest.substring(separator + 1).trim())\n ]);\n }\n }\n break;\n }\n case \"undef\": {\n instructions.push([ShaderPreprocessorDirective.Undef, rest]);\n break;\n }\n }\n }\n\n return instructions;\n }\n\n private static _pushConditionInstruction(instructions: ShaderInstruction[], cond: Condition): void {\n if (cond.t === \"def\") {\n instructions.push([ShaderPreprocessorDirective.IfDef, cond.m, -1]);\n } else if (cond.t === \"ndef\") {\n instructions.push([ShaderPreprocessorDirective.IfNdef, cond.m, -1]);\n } else if (cond.t === \"cmp\") {\n instructions.push([ShaderPreprocessorDirective.IfCmp, cond.m, cond.op, cond.v, -1]);\n } else {\n instructions.push([ShaderPreprocessorDirective.IfExpr, cond, -1]);\n }\n }\n\n private static _parseCondition(\n expression: string,\n preprocessorExpressions?: ReadonlyMap<string, PreprocessorExpressionParseResult>\n ): Condition {\n const result = preprocessorExpressions?.get(expression) ?? parsePreprocessorExpression(expression);\n if (\"error\" in result) {\n if (!result.error.certain && result.hasExpandableIdentifier) return { t: \"deferred\", e: expression };\n throw new Error(result.error.message);\n }\n if (result.evaluationError) throw new Error(result.evaluationError);\n const compact = toPreprocessorCondition(result.condition);\n if (compact && !result.hasExpandableIdentifier) return compact;\n return result.hasExpandableIdentifier ? { t: \"deferred\", e: expression } : result.condition;\n }\n\n private static _findDirectiveStart(source: string, from: number, length: number): number {\n let i = from;\n while (i < length) {\n let j = i;\n while (j < length) {\n const c = source.charCodeAt(j);\n if (c === 32 /* space */ || c === 9 /* tab */) {\n j++;\n } else {\n break;\n }\n }\n if (j < length && (source.charCodeAt(j) === 35 /* '#' */ || source.charCodeAt(j) === 0)) return i;\n\n const nl = source.indexOf(\"\\n\", i);\n if (nl === -1) break;\n i = nl + 1;\n }\n return -1;\n }\n\n private static _findLogicalLineEnd(source: string, start: number, length: number): number {\n let lineEnd = source.indexOf(\"\\n\", start);\n while (lineEnd !== -1) {\n const beforeBreak = source.charCodeAt(lineEnd - 1) === 13 ? lineEnd - 2 : lineEnd - 1;\n if (beforeBreak < start || source.charCodeAt(beforeBreak) !== 92) return lineEnd;\n lineEnd = source.indexOf(\"\\n\", lineEnd + 1);\n }\n return length;\n }\n\n private static _findInlineWhitespace(source: string): number {\n let index = 0;\n while (index < source.length) {\n const charCode = source.charCodeAt(index);\n if (charCode === 32 /* space */ || charCode === 9 /* tab */) break;\n index++;\n }\n return index;\n }\n\n private static _pushText(\n instructions: ShaderInstruction[],\n source: string,\n from: number,\n to: number,\n owners?: readonly number[]\n ): void {\n if (from >= to) return;\n const last = instructions.length > 0 ? instructions[instructions.length - 1] : null;\n const directive = owners === undefined ? ShaderPreprocessorDirective.Text : ShaderPreprocessorDirective.OwnedText;\n if (\n last &&\n last[0] === directive &&\n (owners === undefined ||\n (last.length === owners.length + 2 && owners.every((owner, index) => last[index + 2] === owner)))\n ) {\n (last as [number, string])[1] += source.substring(from, to);\n } else {\n instructions.push(\n owners === undefined\n ? [directive, source.substring(from, to)]\n : [directive, source.substring(from, to), ...owners]\n );\n }\n }\n\n /**\n * Backfill jump offset of an IF/ELIF instruction.\n * When onlyPlaceholder is true, only backfill if the current value is still -1\n */\n private static _backfillJump(inst: ShaderInstruction, target: number, onlyPlaceholder = false): void {\n const directive = inst[0];\n if (directive === ShaderPreprocessorDirective.IfDef || directive === ShaderPreprocessorDirective.IfNdef) {\n if (!onlyPlaceholder || inst[2] === -1) (inst as [number, string, number])[2] = target;\n } else if (directive === ShaderPreprocessorDirective.IfCmp) {\n if (!onlyPlaceholder || inst[4] === -1) (inst as [number, string, string, number, number])[4] = target;\n } else if (directive === ShaderPreprocessorDirective.IfExpr) {\n if (!onlyPlaceholder || inst[2] === -1) (inst as [number, Condition, number])[2] = target;\n }\n }\n\n private static _stripLineComment(s: string): string {\n const idx = s.indexOf(\"//\");\n return idx >= 0 ? s.substring(0, idx).trimEnd() : s;\n }\n}\n","import type { IShaderInfo } from \"@galacean/engine-design\";\nimport type { IPoolElement } from \"@galacean/engine-core\";\nimport { BaseToken } from \"@galacean/engine-shader-parser/internal\";\nimport { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { Keyword } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode, TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { NodeChild } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderData } from \"@galacean/engine-shader-parser/internal\";\nimport { ESymbolType } from \"@galacean/engine-shader-parser/internal\";\nimport {\n FnSymbol,\n StructSymbol,\n VarSymbol,\n canInheritanceBranchesCover,\n getLexicalDeclarationCoexistence\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GSError, GSErrorName, mapExpandedShaderError } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport type {\n BranchSignature,\n StructProp,\n ShaderClueIR,\n ShaderCoreInfo,\n ShaderEntryPointInfo,\n DeferredDeclarationOwnership\n} from \"@galacean/engine-shader-parser/internal\";\nimport { CodeGenVisitor } from \"./CodeGenVisitor\";\nimport { isUnsafeGLSLIdentifier } from \"./NameAllocator\";\nimport { ICodeSegment } from \"./types\";\nimport type { ShaderBackend } from \"../ShaderBackend\";\nimport { ShaderInstructionEncoder } from \"../ShaderInstructionEncoder\";\n\n/**\n * @internal\n */\nexport abstract class GLESVisitor extends CodeGenVisitor implements ShaderBackend, IPoolElement {\n protected readonly supportsArrayStructReturn: boolean = true;\n /** Names of pass-scope declarations, which stage-interface globals must not redeclare. */\n private readonly _globalNames = new Set<string>();\n /** Interface type and variable tokens whose source names GLSL ES rejects. */\n private readonly _escapedDeclarations = new Map<BaseToken, string>();\n private _vertexOutputNames?: Record<string, string>;\n private readonly _fragmentVaryingProps = new Set<StructProp>();\n private readonly _globalInputs = new Map<EShaderStage, VarSymbol[]>();\n private readonly _inputHelperBodies = new Map<TreeNode, string>();\n private readonly _inputHelperGroups = new Map<number, { name: string; fallback: DeferredDeclarationOwnership }>();\n private _globalCodeArray: ICodeSegment[] = [];\n private readonly _forwardFunctionDeclarations = new Map<ASTNode.FunctionDefinition, string>();\n private readonly _forwardStructIndices = new Map<ASTNode.StructSpecifier, number>();\n private readonly _structCodeSegments = new Map<ASTNode.StructSpecifier, ICodeSegment>();\n private readonly _forwardVariableIndices = new Map<ASTNode.VariableDeclaration, number>();\n private readonly _variableCodeSegments = new Map<ASTNode.VariableDeclaration, ICodeSegment>();\n private readonly _declarationOwners = new Map<TreeNode, DeferredDeclarationOwnership>();\n private readonly _deferredPrototypes = new Map<ASTNode.FunctionDefinition, ICodeSegment>();\n private readonly _declarationReferences = new Map<number, Set<number>>();\n private _currentDeclaration?: TreeNode;\n private _sourceIR?: ShaderClueIR;\n private _outerMacroDeclarations: readonly ASTNode.GlobalDeclaration[] = [];\n\n /**\n * Clears pass-local output retained by the pooled visitor.\n */\n reset(): void {\n const { _globalCodeArray: globalCodeArray } = this;\n globalCodeArray.length = 0;\n this._forwardFunctionDeclarations.clear();\n this._forwardStructIndices.clear();\n this._structCodeSegments.clear();\n this._forwardVariableIndices.clear();\n this._variableCodeSegments.clear();\n this._deferredPrototypes.clear();\n this._declarationReferences.clear();\n this._inputHelperBodies.clear();\n this._inputHelperGroups.clear();\n this._currentDeclaration = undefined;\n }\n\n /**\n * Releases references retained by an idle visitor when its pool is collected.\n * @internal\n */\n dispose(): void {\n this.context.reset();\n this.context.names.reset();\n this._globalNames.clear();\n this._escapedDeclarations.clear();\n this._vertexOutputNames = undefined;\n this.reset();\n }\n\n /**\n * Emits target-specific declarations that precede generated global code.\n * @param data - Parser-owned shader facts.\n * @param out - Destination code segments.\n */\n getOtherGlobal(data: ShaderData, out: ICodeSegment[]): void {\n for (const { name, fallback } of this._inputHelperGroups.values()) {\n out.push({\n text:\n ShaderInstructionEncoder.declaration(`void ${name}() {}`, fallback) +\n ShaderInstructionEncoder.reference(0, fallback.id),\n index: -1\n });\n }\n for (const precision of data.globalPrecisions) {\n out.push({ text: precision.codeGen(this), index: precision.location.start.index });\n }\n }\n\n /**\n * Generates vertex and fragment source from neutral parser facts.\n * @param ir - Request-owned neutral shader IR.\n * @param coreInfo - Entry and stage-interface facts derived from the same IR.\n * @returns Generated vertex and fragment source.\n */\n generate(ir: ShaderClueIR, coreInfo: ShaderCoreInfo): IShaderInfo {\n this.context.reset();\n this.context.names.reset();\n this._globalNames.clear();\n this._escapedDeclarations.clear();\n this._vertexOutputNames = undefined;\n this.reset();\n\n const node = ir.program;\n const shaderData = node.shaderData;\n const context = this.context;\n context._passSymbolTable = shaderData.symbolTable;\n let hasUnsafeIdentifier = false;\n for (const name of ir.source.match(/[A-Za-z_][A-Za-z0-9_]*/g) ?? []) {\n context.names.reserve(name);\n hasUnsafeIdentifier ||= isUnsafeGLSLIdentifier(name);\n }\n shaderData.symbolTable.forEach((symbol) => this._globalNames.add(symbol.ident));\n\n const outerGlobalMacroDeclarations = coreInfo.outerGlobalMacroDeclarations;\n const { io } = coreInfo;\n context.attributeStructs.push(...io.attributeStructs);\n context.attributeList.push(...io.attributeList);\n context.varyingStructs.push(...io.varyingStructs);\n context.varyingList.push(...io.varyingList);\n context.mrtStructs.push(...io.mrtStructs);\n context.mrtList.push(...io.mrtList);\n context.registerStructTypes(ShaderStructRole.Attribute, io.attributeStructs);\n context.registerStructTypes(ShaderStructRole.Varying, io.varyingStructs);\n context.registerStructTypes(ShaderStructRole.Mrt, io.mrtStructs);\n io.structVariableRoles.forEach((role, variable) => context.registerStructVar(variable, role));\n io.vertexStructVariableRoles.forEach((role, variable) => {\n context.registerStructVar(variable, role, EShaderStage.VERTEX);\n });\n io.fragmentStructVariableRoles.forEach((role, variable) => {\n context.registerStructVar(variable, role, EShaderStage.FRAGMENT);\n });\n if (hasUnsafeIdentifier) this._collectEscapedDeclarations(node);\n\n this._globalInputs.clear();\n for (const [stage, variables] of [\n [EShaderStage.VERTEX, io.vertexStructVariableRoles],\n [EShaderStage.FRAGMENT, io.fragmentStructVariableRoles]\n ] as const) {\n const inputRole = stage === EShaderStage.VERTEX ? ShaderStructRole.Attribute : ShaderStructRole.Varying;\n this._globalInputs.set(\n stage,\n Array.from(variables)\n .filter(([variable, role]) => role === inputRole && variable.astNode instanceof ASTNode.VariableDeclaration)\n .map(([variable]) => variable)\n );\n }\n\n this._sourceIR = ir;\n this._outerMacroDeclarations = outerGlobalMacroDeclarations;\n try {\n coreInfo.deferredDeclarationOwnership.forEach((owner, symbol) =>\n this._declarationOwners.set(symbol.astNode!, owner)\n );\n let nextInputOwner = 0;\n for (const owner of this._declarationOwners.values())\n nextInputOwner = Math.max(nextInputOwner, owner.id, owner.group);\n for (const variables of this._globalInputs.values()) {\n for (const variable of variables) {\n if (this._declarationOwners.has(variable.astNode!)) continue;\n const id = ++nextInputOwner;\n this._declarationOwners.set(variable.astNode!, { id, group: id, sourceScope: variable.sourceScope });\n }\n }\n if (this._declarationOwners.size) {\n // `nextInputOwner` already exceeds every owner id and group.\n let nextId = nextInputOwner;\n let nextGroup = nextInputOwner;\n // Reachability follows the selected declaration, including dependencies without an override.\n shaderData.symbolTable.forEach((symbol) => {\n if (symbol.astNode && !this._declarationOwners.has(symbol.astNode)) {\n this._declarationOwners.set(symbol.astNode, {\n id: ++nextId,\n group: ++nextGroup,\n sourceScope: symbol.sourceScope\n });\n }\n });\n context.onReferenceGlobal = (symbols) => {\n const from = this.currentDeclarationOwner?.id ?? 0;\n for (const symbol of symbols) this._referenceDeclaration(from, symbol.astNode!);\n };\n const propDeclarations = new Map();\n for (const struct of [...io.attributeStructs, ...io.varyingStructs, ...io.mrtStructs]) {\n for (const prop of struct.propList) propDeclarations.set(prop, struct);\n }\n context.onReferenceStructProps = (props) => {\n const from = this.currentDeclarationOwner?.id ?? 0;\n for (const prop of props) this._referenceDeclaration(from, propDeclarations.get(prop));\n };\n }\n if (coreInfo.unsupportedDeferredDeclarations.length) {\n throw mapExpandedShaderError(\n new GSError(\n GSErrorName.CompilationError,\n \"Deferred inheritance requires exact signatures and cannot resolve a known partial-coverage conflict.\",\n coreInfo.unsupportedDeferredDeclarations[0].astNode!.location,\n ir.source,\n undefined,\n \"UnsupportedDeferredDeclaration\"\n ),\n ir.source,\n ir.sourceMap\n );\n }\n this._fragmentVaryingProps.clear();\n const fragment = this._fragmentMain(coreInfo.fragmentEntry, shaderData, outerGlobalMacroDeclarations);\n const vertex = this._vertexMain(coreInfo.vertexEntry, shaderData, outerGlobalMacroDeclarations);\n return { vertex, fragment, vertexOutputNames: this._vertexOutputNames };\n } finally {\n this._sourceIR = undefined;\n this._outerMacroDeclarations = [];\n this._globalInputs.clear();\n this._declarationOwners.clear();\n context.onReferenceGlobal = undefined;\n context.onReferenceStructProps = undefined;\n this._fragmentVaryingProps.clear();\n this._globalNames.clear();\n this._escapedDeclarations.clear();\n this._vertexOutputNames = undefined;\n context.reset();\n context.names.reset();\n }\n }\n\n private _vertexMain(\n entryInfo: ShaderEntryPointInfo,\n data: ShaderData,\n outerGlobalMacroDeclarations: readonly ASTNode.GlobalDeclaration[]\n ): string {\n const context = this.context;\n context.stage = EShaderStage.VERTEX;\n context.stageEntry = entryInfo.name;\n for (const prop of this._fragmentVaryingProps) context.referenceVarying(prop.ident);\n\n // Attribute/varying structs were collected in ShaderCoreInfo\n\n // Pre-walk global `#define` values so referenced struct properties emit `attribute`/`varying` declarations.\n this._preRegisterGlobalMacroRefs(outerGlobalMacroDeclarations);\n\n const globalCodeArray = this._globalCodeArray;\n context.referenceGlobal(entryInfo.name, ESymbolType.FN);\n\n this._referenceInterfaceDependencies([...context.attributeStructs, ...context.varyingStructs]);\n this._initializeGlobalInputs();\n this._getGlobalSymbol(globalCodeArray);\n this._getCustomStruct(context.attributeStructs, globalCodeArray);\n this._getCustomStruct(context.varyingStructs, globalCodeArray);\n this._getGlobalMacroDeclarations(outerGlobalMacroDeclarations, globalCodeArray);\n this.getOtherGlobal(data, globalCodeArray);\n this._emitDeclarationReferences(globalCodeArray);\n\n const globalCode = globalCodeArray\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n\n context.reset(false);\n this.reset();\n\n return globalCode;\n }\n\n private _fragmentMain(\n entryInfo: ShaderEntryPointInfo,\n data: ShaderData,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): string {\n const context = this.context;\n context.stage = EShaderStage.FRAGMENT;\n context.stageEntry = entryInfo.name;\n this.prepareFragment(entryInfo, outerGlobalMacroStatements);\n\n // Struct-variable identities are already populated from ShaderCoreInfo; just pre-walk macro\n // refs so struct codegen sees the references.\n this._preRegisterGlobalMacroRefs(outerGlobalMacroStatements);\n\n const globalCodeArray = this._globalCodeArray;\n context.referenceGlobal(entryInfo.name, ESymbolType.FN);\n\n this._referenceInterfaceDependencies([...context.varyingStructs, ...context.mrtStructs]);\n this._initializeGlobalInputs();\n this._getGlobalSymbol(globalCodeArray);\n this._getCustomStruct(context.varyingStructs, globalCodeArray);\n this._getCustomStruct(context.mrtStructs, globalCodeArray);\n this._getGlobalMacroDeclarations(outerGlobalMacroStatements, globalCodeArray);\n this.getOtherGlobal(data, globalCodeArray);\n this._emitDeclarationReferences(globalCodeArray);\n\n const globalCode = globalCodeArray\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n\n for (const props of Object.values(context._referencedVaryingList)) {\n for (const prop of props) this._fragmentVaryingProps.add(prop);\n }\n context.reset(false);\n this.reset();\n\n return globalCode;\n }\n\n private _referenceInterfaceDependencies(structs: readonly ASTNode.StructSpecifier[]): void {\n for (const struct of structs) {\n this._currentDeclaration = struct;\n for (const prop of struct.propList) {\n for (const dependency of prop.typeInfo.structDeclarations) {\n if (dependency.ident) this.context.referenceGlobal(dependency.ident.lexeme, ESymbolType.STRUCT);\n }\n prop.typeInfo.arraySpecifier?.codeGen(this);\n }\n }\n this._currentDeclaration = undefined;\n }\n\n /**\n * Resolves an interface member's global name, shared by both stages for varyings.\n * @param prop - Interface member\n * @param role - Stage-interface role of the member's structure\n * @returns Generated global identifier\n */\n protected interfaceName(prop: StructProp, role: ShaderStructRole): string {\n const context = this.context;\n const name = prop.ident.lexeme;\n const isOutput = role === ShaderStructRole.Mrt;\n const sameName = (item: StructProp) => item.ident.lexeme === name;\n const conflicts =\n this._globalNames.has(name) ||\n // Vertex attributes and fragment outputs share a stage scope with varyings.\n (!isOutput && (context.attributeList.some(sameName) || context.mrtList.some(sameName)));\n const key = `${isOutput ? \"output\" : \"varying\"}:${name}`;\n const generated = isUnsafeGLSLIdentifier(name)\n ? context.names.sourceName(key, name)\n : conflicts\n ? context.names.allocate(key, name)\n : name;\n if (!isOutput && context.stage === EShaderStage.VERTEX && generated !== name) {\n (this._vertexOutputNames ??= Object.create(null))[name] = generated;\n }\n return generated;\n }\n\n protected override interfaceMemberName(name: string): string {\n return this.context.names.sourceName(`member:${name}`, name);\n }\n\n private _interfaceTypeName(struct: ASTNode.StructSpecifier): string {\n const name = struct.ident!.lexeme;\n return this.context.names.sourceName(`type:${name}`, name);\n }\n\n /**\n * Escapes interface-typed variables whose names GLSL ES reserves.\n * @param name - Source name\n * @param structs - Struct declarations of the variable type\n * @returns The escaped name, or the source name when no escape is necessary\n */\n private _interfaceVariableName(name: string, structs: readonly ASTNode.StructSpecifier[] | undefined): string {\n return structs?.length && this.context.getStructRole(structs)\n ? this.context.names.sourceName(`variable:${name}`, name)\n : name;\n }\n\n private _collectEscapedDeclarations(node: TreeNode): void {\n if (node instanceof ASTNode.TypeSpecifier && this.context.getStructRole(node.structDeclarations)) {\n const token = (node.children[0] as TreeNode).children[0];\n if (token instanceof BaseToken && token.lexeme === node.structDeclarations[0].ident?.lexeme) {\n const name = this._interfaceTypeName(node.structDeclarations[0]);\n if (name !== token.lexeme) this._escapedDeclarations.set(token, name);\n }\n }\n let identifier: BaseToken | undefined;\n let structs: readonly ASTNode.StructSpecifier[] | undefined;\n if (node instanceof ASTNode.ParameterDeclarator) {\n identifier = node.ident;\n structs = node.typeInfo?.structDeclarations;\n } else {\n // Local, global and multi-variable declarations share the parser's `declarator` record.\n const { declarator } = node as {\n declarator?: { identifier?: BaseToken; typeInfo?: { structDeclarations: readonly ASTNode.StructSpecifier[] } };\n };\n identifier = declarator?.identifier;\n structs = declarator?.typeInfo?.structDeclarations;\n }\n if (identifier) {\n const name = this._interfaceVariableName(identifier.lexeme, structs);\n if (name !== identifier.lexeme) this._escapedDeclarations.set(identifier, name);\n }\n for (const child of node.children) {\n if (child instanceof TreeNode) this._collectEscapedDeclarations(child);\n }\n }\n\n protected override tokenLexeme(token: BaseToken): string {\n return this._escapedDeclarations.get(token) ?? token.lexeme;\n }\n\n private _escapedReference(node: ASTNode.VariableIdentifier): string | undefined {\n const token = node.children[0];\n if (!this._escapedDeclarations.size || !(token instanceof BaseToken) || !isUnsafeGLSLIdentifier(token.lexeme)) {\n return undefined;\n }\n const symbols = node.resolvedValueSymbols();\n if (!symbols.length) {\n // Macro values can lack symbols. The stage's unambiguous name-to-role map binds them, as for member access.\n return this.context.getUnresolvedStructVarRole(token.lexeme)\n ? this.context.names.sourceName(`variable:${token.lexeme}`, token.lexeme)\n : undefined;\n }\n let name: string | undefined;\n for (const symbol of symbols) {\n const candidate =\n symbol instanceof VarSymbol\n ? this._interfaceVariableName(token.lexeme, symbol.dataType?.structDeclarations)\n : symbol instanceof StructSymbol && this.context.getStructRole([symbol.astNode])\n ? this._interfaceTypeName(symbol.astNode)\n : token.lexeme;\n // Branch candidates must agree, otherwise the reference keeps its source spelling.\n if (name !== undefined && name !== candidate) return undefined;\n name = candidate;\n }\n return name;\n }\n\n protected abstract fragmentColorOutput(): string;\n protected abstract mrtOutput(prop: StructProp): string;\n\n private _transferName(struct: ASTNode.StructSpecifier, read: boolean): string {\n return this.context.names.allocate(\n `${read ? \"read\" : \"write\"}:${struct.ident!.lexeme}`,\n `${read ? \"read\" : \"write\"}_${struct.ident!.lexeme}`\n );\n }\n\n override visitStructSpecifier(node: ASTNode.StructSpecifier): string {\n const context = this.context;\n const role = context.getStructRole([node]);\n if (!role) return super.visitStructSpecifier(node);\n const typeName = this._interfaceTypeName(node);\n const memberCode = (emit: (prop: StructProp) => string) => {\n const segments: ICodeSegment[] = node.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }));\n for (const prop of node.propList) {\n if (!retain(prop)) continue;\n segments.push({ text: emit(prop), index: prop.ident.location.start.index });\n }\n return segments\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n };\n const references =\n role === ShaderStructRole.Attribute\n ? context._referencedAttributeList\n : role === ShaderStructRole.Varying\n ? context._referencedVaryingList\n : context._referencedMRTList;\n const used = (prop: StructProp) => !!references[prop.ident.lexeme]?.includes(prop);\n // Interface members have no array wire form, and GLSL ES 1.00 functions cannot return structures that contain\n // arrays. GLES100 therefore omits array members from interface structures.\n const retain = (prop: StructProp) => this.supportsArrayStructReturn || !this._containsArray(prop);\n const declaration = (prop: StructProp) =>\n `${prop.typeInfo.typeLexeme} ${this.interfaceMemberName(prop.ident.lexeme)}${prop.typeInfo.arraySpecifier?.codeGen(this) ?? \"\"};`;\n let structCode: string;\n const hasRetainedField = node.propList.some(retain);\n if (hasRetainedField && !node.macroExpressions.length) {\n structCode = `struct ${typeName} {\\n${memberCode(declaration)}\\n};`;\n } else {\n const hasFields = context.names.allocate(node, `${typeName}_has_fields`);\n const padding = context.names.allocate(\"empty-interface-member\", \"interface_padding\");\n // A macro configuration can remove every source field; GLSL still requires a nonempty struct.\n structCode = `#undef ${hasFields}\\nstruct ${typeName} {\\n${memberCode((prop) => `${declaration(prop)}\\n#define ${hasFields}\\n`)}\\n#ifndef ${hasFields}\\nfloat ${padding};\\n#endif\\n};\\n#undef ${hasFields}\\n`;\n }\n const declarations = memberCode((prop) =>\n !used(prop)\n ? \"\"\n : role === ShaderStructRole.Attribute\n ? this.getAttributeProp(prop)\n : role === ShaderStructRole.Varying\n ? this.getVaryingProp(prop)\n : (this.getMRTProp(prop) ?? \"\")\n );\n const read =\n role === ShaderStructRole.Attribute ||\n (role === ShaderStructRole.Varying && context.stage === EShaderStage.FRAGMENT);\n const value = context.names.allocate(\"interface-value\", \"interface_value\");\n const assignments = memberCode((prop) => {\n if (!used(prop)) return \"\";\n const wire =\n role === ShaderStructRole.Attribute\n ? prop.ident.lexeme\n : role === ShaderStructRole.Mrt\n ? this.mrtOutput(prop)\n : this.interfaceName(prop, role);\n const member = `${value}.${this.interfaceMemberName(prop.ident.lexeme)}`;\n return read ? `${member} = ${wire};` : `${wire} = ${member};`;\n });\n const transfer = read\n ? `${typeName} ${this._transferName(node, true)}() { ${typeName} ${value};\\n${assignments}\\nreturn ${value}; }`\n : `void ${this._transferName(node, false)}(${typeName} ${value}) {\\n${assignments}\\n}`;\n return `${structCode}\\n${declarations}\\n${transfer}`;\n }\n\n private _containsArray(prop: StructProp, visited = new Set<ASTNode.StructSpecifier>()): boolean {\n if (prop.typeInfo.arraySpecifier) return true;\n for (const struct of prop.typeInfo.structDeclarations) {\n if (visited.has(struct)) continue;\n visited.add(struct);\n if (struct.propList.some((member) => this._containsArray(member, visited))) return true;\n }\n return false;\n }\n\n override defaultCodeGen(children: NodeChild[]): string {\n const parent = children[0] instanceof TreeNode ? children[0].parent : undefined;\n if (parent instanceof ASTNode.EqualityExpression && children.length === 3) {\n const observe = (node: TreeNode) => {\n if (node instanceof ASTNode.VariableIdentifier) {\n for (const symbol of node.resolvedValueSymbols()) {\n if (symbol instanceof VarSymbol)\n for (const struct of symbol.dataType?.structDeclarations ?? []) this._observeWholeStruct(struct);\n }\n }\n if (node instanceof ASTNode.FunctionCallGeneric) {\n const declaration = node.fnSymbol?.astNode;\n if (declaration instanceof ASTNode.StructSpecifier) this._observeWholeStruct(declaration);\n else if (declaration instanceof ASTNode.FunctionDefinition) {\n for (const struct of declaration.protoType.returnType.typeSpecifier.structDeclarations)\n this._observeWholeStruct(struct);\n }\n }\n for (const child of node.children) if (child instanceof TreeNode) observe(child);\n };\n for (const child of children)\n if (child instanceof TreeNode && typeof (child as ASTNode.ExpressionAstNode).type === \"string\") observe(child);\n }\n return super.defaultCodeGen(children);\n }\n\n private _observeWholeStruct(struct: ASTNode.StructSpecifier): void {\n const role = this.context.getStructRole([struct]);\n for (const prop of struct.propList) {\n if (role === ShaderStructRole.Attribute) this.context.referenceAttribute(prop.ident);\n else if (role === ShaderStructRole.Varying) this.context.referenceVarying(prop.ident);\n else if (role === ShaderStructRole.Mrt) this.context.referenceMRTProp(prop.ident);\n }\n }\n\n override visitFunctionHeader(node: ASTNode.FunctionHeader): string {\n if (node.ident.lexeme === \"main\" && this.context.stageEntry === \"main\") {\n return `${node.returnType.codeGen(this)} ${this.context.names.allocate(\"entry-main\", \"entry_main\")}(`;\n }\n return super.visitFunctionHeader(node);\n }\n\n override visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string {\n const call = node.parent;\n if (\n node.lexeme === \"main\" &&\n this.context.stageEntry === \"main\" &&\n call instanceof ASTNode.FunctionCallGeneric &&\n call.fnSymbol instanceof FnSymbol\n ) {\n return this.context.names.allocate(\"entry-main\", \"entry_main\");\n }\n return super.visitFunctionIdentifier(node);\n }\n\n override visitFunctionDefinition(fnNode: ASTNode.FunctionDefinition): string {\n const definition = super.visitFunctionDefinition(fnNode);\n if (fnNode.protoType.ident.lexeme !== this.context.stageEntry) return definition;\n const args: string[] = [];\n const parameters: string[] = [];\n for (const parameter of fnNode.protoType.parameterList ?? []) {\n if (!parameter.ident || !parameter.typeInfo) continue;\n const struct = parameter.typeInfo.structDeclarations[0];\n if (struct) {\n const name = this.context.names.allocate(parameter, `input_${parameter.ident.lexeme}`);\n parameters.push(`${this._interfaceTypeName(struct)} ${name} = ${this._transferName(struct, true)}();`);\n args.push(name);\n }\n }\n const name = fnNode.protoType.ident.lexeme;\n const entryName = name === \"main\" ? this.context.names.allocate(\"entry-main\", \"entry_main\") : name;\n const call = `${entryName}(${args.join(\", \")})`;\n const type = fnNode.protoType.returnType;\n const struct = type.typeSpecifier.structDeclarations[0];\n let statement: string;\n if (struct) {\n statement = `${this._transferName(struct, false)}(${call});`;\n } else if (this.context.stage === EShaderStage.FRAGMENT && type.type === Keyword.VEC4) {\n statement = `${this.fragmentColorOutput()} = ${call};`;\n } else statement = `${call};`;\n const inputs = this._initializeGlobalInputs();\n return `${definition}\\nvoid main() {\\n${inputs.join(\"\\n\")}\\n${parameters.join(\"\\n\")}\\n${statement} }`;\n }\n\n private _initializeGlobalInputs(): string[] {\n const calls = new Set<string>();\n for (const variable of this._globalInputs.get(this.context.stage) ?? []) {\n this.context.referenceGlobal(variable.ident, ESymbolType.VAR);\n const struct = variable.dataType!.structDeclarations[0];\n const owner = this._declarationOwners.get(variable.astNode!)!;\n this._referenceDeclaration(owner.id, struct);\n let group = this._inputHelperGroups.get(owner.group);\n if (!group) {\n let nextId = 0;\n for (const declaration of this._declarationOwners.values()) nextId = Math.max(nextId, declaration.id);\n for (const helper of this._inputHelperGroups.values()) nextId = Math.max(nextId, helper.fallback.id);\n // A missing conditional input selects the no-op; an active declaration selects its own initializer.\n const fallback = { id: nextId + 1, group: owner.group, sourceScope: -1 };\n const name = this.context.names.allocate(`input-initializer:${owner.group}`, `initialize_${variable.ident}`);\n this._inputHelperGroups.set(owner.group, (group = { name, fallback }));\n }\n const target = this._interfaceVariableName(variable.ident, variable.dataType!.structDeclarations);\n this._inputHelperBodies.set(\n variable.astNode!,\n `void ${group.name}() { ${target} = ${this._transferName(struct, true)}(); }`\n );\n calls.add(`${group.name}();`);\n }\n return Array.from(calls);\n }\n\n protected prepareFragment(\n entryInfo: ShaderEntryPointInfo,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): void {\n void entryInfo;\n void outerGlobalMacroStatements;\n }\n\n /**\n * Pre-walk `#define` values in global macro declarations and register any\n * `structVar.prop` member accesses as referenced struct props. This must run before\n * struct codegen emits the declaration lists (`attribute …`, `varying …`, `MRT …`),\n * otherwise properties used only from macros would be missing from the output.\n */\n private _preRegisterGlobalMacroRefs(macros: readonly ASTNode.GlobalDeclaration[]): void {\n for (const macro of macros) {\n this._walkMacroDefineTokens(macro.children);\n }\n }\n\n private _walkMacroDefineTokens(children: NodeChild[]): void {\n for (const child of children) {\n if (child instanceof ASTNode.MacroDefine) {\n // Codegen the value once so the enclosed `visitPostfixExpression` calls\n // register their struct-prop references. The returned string is discarded\n // — the real emit happens later in `_getGlobalMacroDeclarations`.\n if (child.valueExpression) child.valueExpression.codeGen(this);\n } else if (child instanceof TreeNode) {\n const previous = this._currentDeclaration;\n if (child instanceof ASTNode.FunctionDefinition) this._currentDeclaration = child;\n this._walkMacroDefineTokens(child.children);\n this._currentDeclaration = previous;\n }\n }\n }\n\n private _getGlobalSymbol(out: ICodeSegment[]): void {\n const context = this.context;\n // Set iteration includes dependencies discovered while generating earlier declarations.\n for (const sm of context._referencedGlobalSymbols) {\n this._currentDeclaration = sm.astNode;\n const codeGenResult = sm.astNode!.codeGen(this);\n this._currentDeclaration = undefined;\n if (!codeGenResult) continue;\n const text = codeGenResult + (sm.type === ESymbolType.VAR ? \";\" : \"\");\n if (!sm.isInMacroBranch) {\n const segment = {\n text: this._declaration(text, sm.astNode!),\n index: sm.astNode!.location.start.index\n };\n out.push(segment);\n if (sm.astNode instanceof ASTNode.StructSpecifier) this._structCodeSegments.set(sm.astNode, segment);\n if (sm.astNode instanceof ASTNode.VariableDeclaration) this._variableCodeSegments.set(sm.astNode, segment);\n }\n }\n this._getForwardDeclarations(out);\n for (const segment of this._deferredPrototypes.values()) out.push(segment);\n for (const [definition, text] of this._forwardFunctionDeclarations) {\n if (!definition.isInMacroBranch) out.push({ text, index: definition.location.start.index });\n }\n }\n\n protected override referenceFunction(symbol: FnSymbol, referenceIndex: number, branch: BranchSignature): void {\n super.referenceFunction(symbol, referenceIndex, branch);\n const definition = symbol.astNode;\n const declarations = this._forwardFunctionDeclarations;\n if (symbol.ident === this.context.stageEntry) return;\n const candidates = this.context._referencedGlobals[symbol.ident].filter(\n (candidate): candidate is FnSymbol => candidate instanceof FnSymbol && candidate.equal(symbol)\n );\n const owner = this._declarationOwners.get(definition);\n if (owner) {\n for (const candidate of candidates) {\n const replacement = candidate.astNode;\n const nextOwner = this._declarationOwners.get(replacement);\n if (\n !nextOwner ||\n nextOwner.group !== owner.group ||\n nextOwner.sourceScope <= owner.sourceScope ||\n replacement.location.start.index <= referenceIndex\n )\n continue;\n const prototype = replacement.protoType;\n const anchor = definition.location.start.index;\n const previous = this._deferredPrototypes.get(replacement);\n if (previous && previous.index <= anchor) continue;\n if (\n !this._isContextIndependent(prototype) ||\n this._hasDeclarationContextBarrier(anchor, prototype.location.start.index, false)\n ) {\n this._unsupportedForwardDeclaration(prototype);\n }\n const outer = this._outerMacroDeclarations.find(\n (macro) => macro.location.start.index <= anchor && macro.location.end.index >= definition.location.end.index\n );\n const typeAnchor = outer?.location.start.index ?? anchor;\n this._prepareForwardTypes(prototype.returnType.typeSpecifier.structDeclarations, anchor, typeAnchor);\n for (const parameter of prototype.parameterList ?? []) {\n this._prepareForwardTypes(parameter.typeInfo?.structDeclarations ?? [], anchor, typeAnchor);\n }\n // Selection is determined at the later definition, so the prototype must not replay its guard here.\n this._deferredPrototypes.set(replacement, {\n text: this._declaration(`${prototype.codeGen(this)};`, replacement, false),\n index: typeAnchor\n });\n }\n return;\n }\n if (candidates.some((candidate) => candidate.astNode === definition)) return;\n const compatible = candidates.filter((candidate) => this._canBranchesOverlap(candidate.branchSignature, branch));\n const preceding = compatible.filter((candidate) => candidate.astNode.location.start.index < referenceIndex);\n if (\n canInheritanceBranchesCover(\n preceding.map((candidate) => candidate.branchSignature),\n branch\n )\n )\n return;\n const replacement = compatible.find((candidate) => candidate.astNode.location.start.index > referenceIndex);\n if (replacement) {\n // An inherited helper can call a declaration whose overriding body occurs later. Keep the\n // original declaration's macro/type context and emit only the final backend signature there.\n const prototype = replacement.astNode.protoType;\n const anchor = definition.location.start.index;\n const text = `${prototype.codeGen(this)};`;\n const signature = this._getForwardSignature(prototype);\n for (const candidate of candidates) {\n if (\n this._canBranchesOverlap(candidate.branchSignature, symbol.branchSignature) &&\n this._getForwardSignature(candidate.astNode.protoType) !== signature\n ) {\n this._unsupportedForwardDeclaration(candidate.astNode.protoType);\n }\n }\n if (declarations.has(definition)) return;\n if (\n !this._isContextIndependent(prototype) ||\n this._hasDeclarationContextBarrier(anchor, prototype.location.start.index, false)\n ) {\n this._unsupportedForwardDeclaration(prototype);\n }\n const outerMacro = this._outerMacroDeclarations.find(\n (macro) => macro.location.start.index <= anchor && macro.location.end.index >= definition.location.end.index\n );\n const typeAnchor = outerMacro?.location.start.index ?? anchor;\n this._prepareForwardTypes(prototype.returnType.typeSpecifier.structDeclarations, anchor, typeAnchor);\n for (const parameter of prototype.parameterList ?? []) {\n this._prepareForwardTypes(parameter.typeInfo?.structDeclarations ?? [], anchor, typeAnchor);\n }\n declarations.set(definition, text);\n }\n }\n\n private _getForwardSignature(prototype: ASTNode.FunctionProtoType): string {\n const parameters: string[] = [];\n for (const parameter of prototype.parameterList ?? []) {\n const declaration = parameter.astNode!;\n const tokens: string[] = [];\n const visit = (node: NodeChild) => {\n if (node instanceof BaseToken) {\n if (node !== parameter.ident && node.type !== Keyword.IN) tokens.push(node.lexeme);\n } else {\n node.children.forEach(visit);\n }\n };\n visit(declaration);\n const text = tokens.join(\" \");\n if (text !== \"void\") parameters.push(text);\n }\n return `${prototype.returnType.codeGen(this)}(${parameters.join(\",\")})`;\n }\n\n private _canBranchesOverlap(left: BranchSignature, right: BranchSignature): boolean {\n return (\n getLexicalDeclarationCoexistence(left, right) !== \"exclusive\" &&\n !canInheritanceBranchesCover([], [...left, ...right])\n );\n }\n\n override visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n const code = super.visitVariableIdentifier(node);\n for (const symbol of node.resolvedSymbols()) {\n if (!(symbol instanceof VarSymbol) || !symbol.isUniform) continue;\n const candidates = this.context._referencedGlobals[symbol.ident]?.filter(\n (candidate): candidate is VarSymbol => candidate instanceof VarSymbol\n );\n const owner = this._declarationOwners.get(symbol.astNode);\n if (!candidates || (!owner && candidates.includes(symbol))) continue;\n const preceding = candidates.filter(\n (candidate) => candidate.astNode!.location.start.index < node.location.start.index\n );\n if (\n !owner &&\n canInheritanceBranchesCover(\n preceding.map((candidate) => candidate.branchSignature),\n node._branch\n )\n )\n continue;\n const oldMacro = this._outerMacroDeclarations.find(\n (macro) =>\n macro.location.start.index <= symbol.astNode.location.start.index &&\n macro.location.end.index >= symbol.astNode.location.end.index\n );\n const anchor = oldMacro?.location.start.index ?? symbol.astNode.location.start.index;\n for (const candidate of candidates) {\n if (candidate.astNode!.location.start.index <= node.location.start.index) continue;\n if (owner) {\n const nextOwner = this._declarationOwners.get(candidate.astNode!);\n if (!nextOwner || nextOwner.group !== owner.group || nextOwner.sourceScope <= owner.sourceScope) continue;\n }\n const declaration = candidate.astNode!;\n if (\n !(candidate instanceof VarSymbol) ||\n !candidate.isUniform ||\n !(declaration instanceof ASTNode.VariableDeclaration)\n ) {\n this._unsupportedForwardDeclaration(declaration);\n }\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= declaration.location.start.index &&\n item.location.end.index >= declaration.location.end.index\n );\n if (\n !this._isContextIndependent(declaration) ||\n this._hasDeclarationContextBarrier(anchor, macro?.location.end.index ?? declaration.location.end.index, true)\n ) {\n this._unsupportedForwardDeclaration(declaration);\n }\n this._prepareForwardTypes(candidate.dataType!.structDeclarations, anchor);\n this._forwardVariableIndices.set(\n declaration,\n Math.min(this._forwardVariableIndices.get(declaration) ?? Infinity, anchor)\n );\n }\n }\n return this._escapedReference(node) ?? code;\n }\n\n private _getForwardDeclarations(out: ICodeSegment[]): void {\n type Declaration = ASTNode.StructSpecifier | ASTNode.VariableDeclaration;\n const guarded = new Map<ASTNode.GlobalDeclaration, { index: number; declarations: Declaration[] }>();\n const declarations: [Declaration, number][] = Array.from(this._forwardStructIndices);\n for (const entry of this._forwardVariableIndices) declarations.push(entry);\n const code = (declaration: Declaration) =>\n this._declaration(\n declaration.codeGen(this) + (declaration instanceof ASTNode.VariableDeclaration ? \";\" : \"\"),\n declaration,\n false\n );\n for (const [declaration, index] of declarations) {\n const owner = this._declarationOwners.get(declaration);\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= declaration.location.start.index &&\n item.location.end.index >= declaration.location.end.index\n );\n if (!macro) {\n const previous =\n declaration instanceof ASTNode.StructSpecifier\n ? this._structCodeSegments.get(declaration)\n : this._variableCodeSegments.get(declaration);\n if (previous) {\n if (owner) previous.text = this._declaration(\"\", declaration);\n else out.splice(out.indexOf(previous), 1);\n }\n out.push({ text: code(declaration), index });\n } else if (owner) {\n out.push({ text: code(declaration), index });\n } else {\n let group = guarded.get(macro);\n if (!group) guarded.set(macro, (group = { index, declarations: [] }));\n group.index = Math.min(group.index, index);\n group.declarations.push(declaration);\n }\n }\n for (const [macro, group] of guarded) {\n const segments: ICodeSegment[] = macro.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }));\n for (const declaration of group.declarations) {\n segments.push({ text: code(declaration), index: declaration.location.start.index });\n }\n out.push({\n text: segments\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\"),\n index: group.index\n });\n }\n }\n\n override visitTypeSpecifier(node: ASTNode.TypeSpecifier): string {\n const call = node.parent instanceof ASTNode.FunctionIdentifier ? node.parent.parent : undefined;\n if (call instanceof ASTNode.FunctionCallGeneric && call.fnSymbol instanceof FnSymbol) {\n return super.visitTypeSpecifier(node);\n }\n for (const type of node.structDependencies) {\n if (!type.ident || this.context.getStructRole([type])) continue;\n // A function-local struct can shadow a global name without participating in inheritance.\n let parent = type.parent;\n while (\n parent &&\n !(parent instanceof ASTNode.GlobalDeclaration) &&\n !(parent instanceof ASTNode.FunctionDefinition)\n ) {\n parent = parent.parent;\n }\n if (parent instanceof ASTNode.FunctionDefinition) continue;\n this.context.referenceGlobal(type.ident.lexeme, ESymbolType.STRUCT);\n const final = this.context._referencedGlobals[type.ident.lexeme];\n const owner = this._declarationOwners.get(type);\n if (!owner && final.some((symbol) => symbol.astNode === type)) continue;\n const oldMacro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= type.location.start.index && item.location.end.index >= type.location.end.index\n );\n this._prepareForwardTypes(\n final\n .filter((symbol) => {\n if (!owner) return true;\n const nextOwner = this._declarationOwners.get(symbol.astNode!);\n return nextOwner?.group === owner.group && nextOwner.sourceScope > owner.sourceScope;\n })\n .map((symbol) => symbol.astNode)\n .filter((item): item is ASTNode.StructSpecifier => item instanceof ASTNode.StructSpecifier),\n oldMacro?.location.start.index ?? type.location.start.index\n );\n }\n return super.visitTypeSpecifier(node);\n }\n\n private _prepareForwardTypes(types: readonly ASTNode.StructSpecifier[], anchor: number, hoistAnchor = anchor): void {\n if (this.context.getStructRole(types)) return;\n for (const type of types) {\n if ((this._forwardStructIndices.get(type) ?? Infinity) <= anchor) continue;\n if (type.ident) {\n this.context.referenceGlobal(type.ident.lexeme, ESymbolType.STRUCT);\n const final = this.context._referencedGlobals[type.ident.lexeme];\n if (!final.some((symbol) => symbol.astNode === type)) {\n this._prepareForwardTypes(\n final\n .map((symbol) => symbol.astNode)\n .filter((item): item is ASTNode.StructSpecifier => item instanceof ASTNode.StructSpecifier),\n anchor,\n hoistAnchor\n );\n continue;\n }\n }\n const needsHoist = type.location.start.index > anchor;\n const macro = this._outerMacroDeclarations.find(\n (item) =>\n item.location.start.index <= type.location.start.index && item.location.end.index >= type.location.end.index\n );\n if (\n needsHoist &&\n (!this._isContextIndependent(type) ||\n this._hasDeclarationContextBarrier(hoistAnchor, macro?.location.end.index ?? type.location.end.index, true))\n ) {\n this._unsupportedForwardDeclaration(type);\n }\n const dependencyAnchor = needsHoist ? hoistAnchor : type.location.start.index;\n for (const property of type.propList) {\n this._prepareForwardTypes(property.typeInfo.structDeclarations, dependencyAnchor);\n }\n if (needsHoist) this._forwardStructIndices.set(type, hoistAnchor);\n }\n }\n\n private _isContextIndependent(node: TreeNode): boolean {\n if (\n node instanceof ASTNode.VariableIdentifier ||\n node instanceof ASTNode.MacroCallSymbol ||\n node instanceof ASTNode.MacroCallFunction\n )\n return false;\n if (node instanceof ASTNode.TypeSpecifier && node.isCustom && !node.structDeclarations.length) return false;\n return node.children.every((child) =>\n child instanceof TreeNode\n ? this._isContextIndependent(child)\n : child.type < Keyword.MACRO_IF || child.type > Keyword.MACRO_DEFINE_PARAMS\n );\n }\n\n private _hasDeclarationContextBarrier(start: number, end: number, includeMacros: boolean): boolean {\n const visit = (node: TreeNode, inFunction = false): boolean => {\n if (node.location.end.index <= start || node.location.start.index >= end) return false;\n if (node instanceof ASTNode.PrecisionSpecifier && !inFunction) return true;\n if (includeMacros && node instanceof ASTNode.MacroDefine) return true;\n inFunction ||= node instanceof ASTNode.FunctionDefinition;\n return node.children.some((child) =>\n child instanceof TreeNode\n ? visit(child, inFunction)\n : includeMacros &&\n child.location.start.index > start &&\n child.location.start.index < end &&\n (child.type === Keyword.MACRO_UNDEF || child.type === Keyword.MACRO_DEFINE_EXPRESSION)\n );\n };\n return visit(this._sourceIR!.program);\n }\n\n private _unsupportedForwardDeclaration(node: TreeNode): never {\n const ir = this._sourceIR!;\n throw mapExpandedShaderError(\n new GSError(\n GSErrorName.CompilationError,\n \"Inherited declarations require incompatible forward signatures or depend on a later macro or precision context.\",\n node.location,\n ir.source,\n undefined,\n \"UnsupportedForwardDeclaration\"\n ),\n ir.source,\n ir.sourceMap\n );\n }\n\n private _getCustomStruct(structNodes: ASTNode.StructSpecifier[], out: ICodeSegment[]): void {\n for (const node of structNodes) {\n if (this._structCodeSegments.has(node)) continue;\n const text = node.codeGen(this);\n\n if (!node.isInMacroBranch) {\n out.push({ text: this._declaration(text, node), index: node.location.start.index });\n }\n }\n }\n\n private _getGlobalMacroDeclarations(macros: readonly ASTNode.GlobalDeclaration[], out: ICodeSegment[]): void {\n const context = this.context;\n const referencedGlobalMacroASTs = context._referencedGlobalMacroASTs;\n referencedGlobalMacroASTs.length = 0;\n\n for (const symbol of context._referencedGlobalSymbols) {\n if (symbol.isInMacroBranch) referencedGlobalMacroASTs.push(symbol.astNode!);\n }\n\n for (const macro of macros) {\n let text: string;\n const child = macro.children[0];\n\n if (child instanceof ASTNode.GlobalMacroIfStatement) {\n const result: ICodeSegment[] = [];\n result.push(\n ...macro.macroExpressions.map((item) => ({\n text: item instanceof BaseToken ? item.lexeme : item.codeGen(this),\n index: item.location.start.index\n }))\n );\n\n this._visitGlobalMacroIfStatement(child, result);\n\n text = result\n .sort((a, b) => a.index - b.index)\n .map((item) => item.text)\n .join(\"\\n\");\n } else if (child instanceof BaseToken && child.type === Keyword.MACRO_DEFINE_EXPRESSION) {\n // Legacy opaque `#define` — its lexeme is the complete directive text,\n // newlines included; emit verbatim.\n text = child.lexeme;\n } else {\n text = macro.codeGen(this);\n }\n\n out.push({\n text,\n index: macro.location.start.index\n });\n }\n }\n\n private _visitGlobalMacroIfStatement(node: TreeNode, out: ICodeSegment[]): void {\n const children = node.children;\n for (let i = 0; i < children.length; i++) {\n const child = children[i];\n if (child instanceof ASTNode.PrecisionSpecifier) {\n out.push({\n text: child.codeGen(this),\n index: child.location.start.index\n });\n } else if (child instanceof ASTNode.FunctionDefinition) {\n const text =\n this.context._referencedGlobalMacroASTs.indexOf(child) !== -1\n ? this.getCachedCode(child)\n : this._forwardFunctionDeclarations.get(child);\n if (text !== undefined) {\n out.push({\n text: this._declaration(text, child),\n index: child.location.start.index\n });\n }\n } else if (child instanceof ASTNode.StructSpecifier) {\n if (this._forwardStructIndices.has(child)) {\n const text = this._declaration(\"\", child);\n if (text) out.push({ text, index: child.location.start.index });\n continue;\n }\n const context = this.context;\n const stage = context.stage;\n if (\n context._referencedGlobalMacroASTs.indexOf(child) !== -1 ||\n (stage === EShaderStage.VERTEX\n ? context.hasStructRole(child, ShaderStructRole.Attribute) ||\n context.hasStructRole(child, ShaderStructRole.Varying)\n : context.hasStructRole(child, ShaderStructRole.Varying) ||\n context.hasStructRole(child, ShaderStructRole.Mrt))\n ) {\n out.push({\n text: this._declaration(this.getCachedCode(child) ?? \"\", child),\n index: child.location.start.index\n });\n }\n } else if (child instanceof ASTNode.VariableDeclarationList) {\n const variableDeclarations = child.variableDeclarations;\n for (let i = 0; i < variableDeclarations.length; i++) {\n const variableDeclaration = variableDeclarations[i];\n if (this.context._referencedGlobalMacroASTs.indexOf(variableDeclaration) !== -1) {\n out.push({\n text: this._declaration(\n this._forwardVariableIndices.has(variableDeclaration)\n ? \"\"\n : `${this.getCachedCode(variableDeclaration) ?? \"\"};`,\n variableDeclaration\n ),\n index: variableDeclaration.location.start.index\n });\n }\n }\n }\n\n if (child instanceof TreeNode) {\n this._visitGlobalMacroIfStatement(child, out);\n }\n }\n }\n\n /** Ownership of the declaration currently generating dependencies. @internal */\n protected get currentDeclarationOwner(): DeferredDeclarationOwnership | undefined {\n return this._currentDeclaration && this._declarationOwners.get(this._currentDeclaration);\n }\n\n private _referenceDeclaration(from: number, node: TreeNode): void {\n const owner = this._declarationOwners.get(node);\n if (!owner) return;\n let targets = this._declarationReferences.get(from);\n if (!targets) this._declarationReferences.set(from, (targets = new Set()));\n targets.add(owner.id);\n }\n\n private _emitDeclarationReferences(out: ICodeSegment[]): void {\n for (const [from, targets] of this._declarationReferences) {\n for (const to of targets) out.push({ text: ShaderInstructionEncoder.reference(from, to), index: -1 });\n }\n }\n\n private _declaration(text: string, node: TreeNode, activate = true): string {\n const initializer = text && this._inputHelperBodies.get(node);\n return ShaderInstructionEncoder.declaration(\n initializer ? `${text}\\n${initializer}` : text,\n this._declarationOwners.get(node),\n activate\n );\n }\n}\n","function _defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n\n if (\"value\" in descriptor) descriptor.writable = true;\n\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n}\nfunction _create_class(Constructor, protoProps, staticProps) {\n if (protoProps) _defineProperties(Constructor.prototype, protoProps);\n if (staticProps) _defineProperties(Constructor, staticProps);\n\n return Constructor;\n}\nexport { _create_class as _ };\n","import { ShaderStructRole, StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { GLESVisitor } from \"./GLESVisitor\";\n\nexport class GLES100Visitor extends GLESVisitor {\n protected override readonly supportsArrayStructReturn = false;\n override getAttributeProp(prop: StructProp): string {\n return `attribute ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getVaryingProp(prop: StructProp): string {\n return `varying ${prop.typeInfo.typeLexeme} ${this.interfaceName(prop, ShaderStructRole.Varying)};`;\n }\n\n override getMRTProp(): string {\n return \"\";\n }\n\n protected override fragmentColorOutput(): string {\n return \"gl_FragColor\";\n }\n\n protected override mrtOutput(prop: StructProp): string {\n return `gl_FragData[${prop.mrtIndex}]`;\n }\n}\n","import { EShaderStage } from \"@galacean/engine-shader-parser/internal\";\nimport { ASTNode } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderData } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderBuiltinSemantic } from \"@galacean/engine-shader-parser/internal\";\nimport { ParserUtils } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderEntryPointInfo } from \"@galacean/engine-shader-parser/internal\";\nimport { TreeNode } from \"@galacean/engine-shader-parser/internal\";\nimport { StructProp } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderStructRole } from \"@galacean/engine-shader-parser/internal\";\nimport { GLESVisitor } from \"./GLESVisitor\";\nimport { ICodeSegment } from \"./types\";\nimport type { DeferredDeclarationOwnership } from \"@galacean/engine-shader-parser/internal\";\nimport { ShaderInstructionEncoder } from \"../ShaderInstructionEncoder\";\n\nexport class GLES300Visitor extends GLESVisitor {\n private readonly _outputDeclarations = new Map<\n string,\n { text: string; owners: Map<number, DeferredDeclarationOwnership>; unconditional: boolean }\n >();\n private _fragDataArrayRequired = false;\n private readonly _fragDataIndices = new Map<ASTNode.PostfixExpression, number>();\n private readonly _scannedFragmentFunctions = new Set<ShaderEntryPointInfo[\"functions\"][number]>();\n\n override reset(): void {\n super.reset();\n\n this._outputDeclarations.clear();\n this._fragDataArrayRequired = false;\n this._fragDataIndices.clear();\n this._scannedFragmentFunctions.clear();\n }\n\n override getOtherGlobal(data: ShaderData, out: ICodeSegment[]): void {\n super.getOtherGlobal(data, out);\n\n for (const output of this._outputDeclarations.values()) {\n out.push({\n text: output.unconditional\n ? output.text\n : ShaderInstructionEncoder.sharedDeclaration(output.text, Array.from(output.owners.values())),\n // A source macro block can start at zero and contain the first output use.\n index: -1\n });\n }\n }\n\n override getAttributeProp(prop: StructProp): string {\n return `in ${prop.typeInfo.typeLexeme} ${prop.ident.lexeme};`;\n }\n\n override getVaryingProp(prop: StructProp): string {\n const qualifier = this.context.stage === EShaderStage.FRAGMENT ? \"in\" : \"out\";\n return `${qualifier} ${prop.typeInfo.typeLexeme} ${this.interfaceName(prop, ShaderStructRole.Varying)};`;\n }\n\n override getMRTProp(prop: StructProp): string {\n return `layout(location = ${prop.mrtIndex}) out vec4 ${this.interfaceName(prop, ShaderStructRole.Mrt)};`;\n }\n\n override visitFunctionIdentifier(node: ASTNode.FunctionIdentifier): string {\n const children = node.children;\n const typeSpecifier = children[0] as ASTNode.TypeSpecifier;\n if (!node.isBuiltin || typeSpecifier.children.length !== 1 || typeSpecifier.structDependencies.length) {\n // Struct constructors still need the shared type-dependency visitor.\n return super.visitFunctionIdentifier(node);\n }\n let ident = node.lexeme;\n switch (node.ident) {\n case \"texture2D\":\n case \"textureCube\":\n ident = \"texture\";\n break;\n case \"texture2DProj\":\n ident = \"textureProj\";\n break;\n case \"texture2DLodEXT\":\n case \"textureCubeLodEXT\":\n ident = \"textureLod\";\n break;\n case \"texture2DGradEXT\":\n case \"textureCubeGradEXT\":\n ident = \"textureGrad\";\n break;\n case \"texture2DProjLodEXT\":\n ident = \"textureProjLod\";\n break;\n case \"texture2DProjGradEXT\":\n ident = \"textureProjGrad\";\n break;\n }\n return ident;\n }\n\n override visitVariableIdentifier(node: ASTNode.VariableIdentifier): string {\n const context = this.context;\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutput0) {\n this._registerFragColorVariable();\n return this._fragmentColorName();\n }\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentDepth) {\n return \"gl_FragDepth\";\n }\n if (context.stage === EShaderStage.FRAGMENT && node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray) {\n this._registerFragDataArray();\n return this._fragmentDataName();\n }\n return super.visitVariableIdentifier(node);\n }\n\n override visitPostfixExpression(node: ASTNode.PostfixExpression): string {\n if (!this._fragDataArrayRequired) {\n const index = this._fragDataIndices.get(node);\n if (index !== undefined) return this._registerFragDataVariable(index);\n }\n return super.visitPostfixExpression(node);\n }\n\n protected override fragmentColorOutput(): string {\n this._registerFragColorVariable();\n return this._fragmentColorName();\n }\n\n protected override mrtOutput(prop: StructProp): string {\n return this.interfaceName(prop, ShaderStructRole.Mrt);\n }\n\n private _fragmentColorName(): string {\n return this.context.names.allocate(\"fragment-output\", \"output_color\");\n }\n\n private _fragmentDataName(): string {\n return this.context.names.allocate(\"fragment-output-array\", \"output_colors\");\n }\n\n private _registerFragColorVariable(): void {\n const name = this._fragmentColorName();\n this._registerOutput(name, `out vec4 ${name};`);\n }\n\n private _registerOutput(name: string, text: string): void {\n let output = this._outputDeclarations.get(name);\n if (!output) this._outputDeclarations.set(name, (output = { text, owners: new Map(), unconditional: false }));\n const owner = this.currentDeclarationOwner;\n if (owner) output.owners.set(owner.id, owner);\n else output.unconditional = true;\n }\n\n protected override prepareFragment(\n entryInfo: ShaderEntryPointInfo,\n outerGlobalMacroStatements: readonly ASTNode.GlobalDeclaration[]\n ): void {\n const pending = entryInfo.functions.slice();\n while (pending.length) {\n const fn = pending.pop()!;\n if (this._scannedFragmentFunctions.has(fn)) continue;\n this._scannedFragmentFunctions.add(fn);\n this._scanFragmentOutputs(fn.astNode);\n pending.push(...fn.calledFunctions);\n }\n for (const macro of outerGlobalMacroStatements) this._scanFragmentOutputs(macro);\n }\n\n private _scanFragmentOutputs(node: TreeNode): void {\n if (node instanceof ASTNode.PostfixExpression && node.children.length === 4) {\n const base = node.children[0];\n const index = node.children[2];\n if (\n base instanceof TreeNode &&\n index instanceof TreeNode &&\n ParserUtils.unwrapBareIdentifier(base, { allowParens: true })?.builtinSemantic ===\n ShaderBuiltinSemantic.FragmentOutputArray\n ) {\n const value = ParserUtils.constIntegerValue(index);\n if (value === undefined || value < 0) this._fragDataArrayRequired = true;\n else this._fragDataIndices.set(node, value);\n this._scanFragmentOutputs(index);\n return;\n }\n }\n if (\n node instanceof ASTNode.VariableIdentifier &&\n node.builtinSemantic === ShaderBuiltinSemantic.FragmentOutputArray\n ) {\n this._fragDataArrayRequired = true;\n return;\n }\n for (const child of node.children) {\n if (child instanceof TreeNode) this._scanFragmentOutputs(child);\n }\n }\n\n private _registerFragDataArray(): void {\n const name = this._fragmentDataName();\n this._registerOutput(name, `layout(location = 0) out vec4 ${name}[gl_MaxDrawBuffers];`);\n }\n\n private _registerFragDataVariable(index: number): string {\n const name = this.context.names.allocate(`fragment-output:${index}`, `output_color_${index}`);\n this._registerOutput(name, `layout(location = ${index}) out vec4 ${name};`);\n return name;\n }\n}\n","import type { IShaderInfo } from \"@galacean/engine-design\";\nimport { Logger, ReturnableObjectPool, ShaderLanguage } from \"@galacean/engine-core\";\nimport {\n GSError,\n GLESShaderInfo,\n type ShaderClueIR,\n type ShaderCoreInfo\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GLES100Visitor, GLES300Visitor } from \"./codeGen\";\nimport type { GLESVisitor } from \"./codeGen/GLESVisitor\";\n\n/**\n * Static internal facade for GLES source generation.\n * @internal\n */\nexport class GLESBackend {\n private static readonly _gles100VisitorPool = new ReturnableObjectPool(GLES100Visitor);\n private static readonly _gles300VisitorPool = new ReturnableObjectPool(GLES300Visitor);\n\n private constructor() {}\n\n /**\n * Generates one GLES program with request-owned visitor state.\n * @param ir - Request-owned neutral parser IR consumed read-only.\n * @param coreInfo - Entry and stage-interface facts derived from the same IR.\n * @param target - GLES language version to emit.\n * @returns Generated vertex and fragment source.\n * @internal\n */\n static generate(ir: ShaderClueIR, coreInfo: ShaderCoreInfo, target: ShaderLanguage): IShaderInfo | undefined {\n const glesInfo = new GLESShaderInfo(ir, coreInfo);\n if (glesInfo.mrtOutputIssues.length || glesInfo.invalidMrtReturnLocations.length) {\n Logger.error(\n \"MRT outputs require unique non-negative locations, vec4 members, and returns through an assigned struct variable.\"\n );\n return undefined;\n }\n if (glesInfo.invalidVaryingReturnLocations.length) {\n Logger.error(\"Varying vertex entries must return a struct variable or same-type function result.\");\n return undefined;\n }\n if (glesInfo.structMemberOwnerIssues.length) {\n Logger.error(\"A struct member reference cannot be lowered safely across runtime macro expansion.\");\n return undefined;\n }\n\n return target === ShaderLanguage.GLSLES100\n ? GLESBackend._generateWithPool(GLESBackend._gles100VisitorPool, ir, coreInfo)\n : GLESBackend._generateWithPool(GLESBackend._gles300VisitorPool, ir, coreInfo);\n }\n\n private static _generateWithPool<T extends GLESVisitor>(\n pool: ReturnableObjectPool<T>,\n ir: ShaderClueIR,\n coreInfo: ShaderCoreInfo\n ): IShaderInfo | undefined {\n const visitor = pool.get();\n try {\n return visitor.generate(ir, coreInfo);\n } catch (error) {\n visitor.dispose();\n if (!(error instanceof GSError)) throw error;\n Logger.error(`${error.file ? `${error.file}: ` : \"\"}${error.code ? `${error.code}: ` : \"\"}${error.toString()}`);\n return undefined;\n } finally {\n pool.return(visitor);\n }\n }\n}\n","import { Logger, ShaderLanguage } from \"@galacean/engine-core\";\nimport type { IRenderStates, IShaderSource } from \"@galacean/engine-design\";\nimport type { IShaderProgramSource } from \"@galacean/engine-design/types/shader-compiler/IShaderProgramSource\";\nimport { Color } from \"@galacean/engine-math\";\nimport {\n GSError,\n ShaderCoreInfo,\n type ParsedShaderPassData,\n type ShaderClueIR,\n type ShaderSourceParseResult\n} from \"@galacean/engine-shader-parser/internal\";\nimport { GLESBackend } from \"./GLESBackend\";\nimport { ShaderInstructionEncoder } from \"./ShaderInstructionEncoder\";\n\nclass ShaderSourceParseError extends Error {\n constructor(readonly errors: readonly Error[]) {\n super(errors.map((error) => error.toString()).join(\"\\n\"));\n this.name = \"ShaderSourceParseError\";\n }\n}\n\n/**\n * Rejects a partial ShaderLab structure when source parsing produced errors.\n * @param result - ShaderLab source-parser result.\n * @returns Complete parsed ShaderLab structure.\n * @throws ShaderSourceParseError when structural source diagnostics exist.\n * @internal\n */\nexport function requireValidShaderSource(result: ShaderSourceParseResult): IShaderSource {\n if (result.errors.length) throw new ShaderSourceParseError(result.errors);\n return result.shaderSource;\n}\n\n/**\n * Generates one backend program from a parser-owned pass without reparsing it.\n * @param parsed - Neutral parser output.\n * @param vertexEntry - Vertex entry name.\n * @param fragmentEntry - Fragment entry name.\n * @param backend - Target GLES language.\n * @param coreInfo - Optional stage facts already derived from this exact parser result.\n * @returns Generated program, or `undefined` when parser or entry admission fails.\n * @internal\n */\nexport function generateParsedShaderPassData(\n parsed: ParsedShaderPassData,\n vertexEntry: string,\n fragmentEntry: string,\n backend: ShaderLanguage,\n coreInfo?: ShaderCoreInfo\n): IShaderProgramSource | undefined {\n if (parsed.blockingErrors.length) {\n for (const error of parsed.blockingErrors) Logger.error(error.toString());\n return undefined;\n }\n if (!parsed.ir) return undefined;\n const resolvedCoreInfo = coreInfo ?? ShaderCoreInfo.create(parsed.ir, vertexEntry, fragmentEntry);\n return generateShaderProgram(parsed.ir, resolvedCoreInfo, backend, parsed.preprocessorExpressions);\n}\n\nfunction generateShaderProgram(\n ir: ShaderClueIR,\n coreInfo: ShaderCoreInfo,\n backend: ShaderLanguage,\n preprocessorExpressions: ParsedShaderPassData[\"preprocessorExpressions\"]\n): IShaderProgramSource | undefined {\n if (!coreInfo.vertexEntry.functions.length) {\n Logger.error(`Vertex entry function '${coreInfo.vertexEntry.name}' not found.`);\n return undefined;\n }\n if (!coreInfo.fragmentEntry.functions.length) {\n Logger.error(`Fragment entry function '${coreInfo.fragmentEntry.name}' not found.`);\n return undefined;\n }\n if (coreInfo.vertexEntry.hasDefiniteAmbiguity) {\n Logger.error(`Vertex entry function '${coreInfo.vertexEntry.name}' resolves to multiple declarations.`);\n return undefined;\n }\n if (coreInfo.fragmentEntry.hasDefiniteAmbiguity) {\n Logger.error(`Fragment entry function '${coreInfo.fragmentEntry.name}' resolves to multiple declarations.`);\n return undefined;\n }\n if (coreInfo.roleConflicts.length) {\n Logger.error(\"A shader IO struct cannot serve multiple stage-interface roles.\");\n return undefined;\n }\n const result = GLESBackend.generate(ir, coreInfo, backend);\n if (result) {\n result.vertexShaderInstructions = ShaderInstructionEncoder.parse(result.vertex, preprocessorExpressions);\n result.fragmentShaderInstructions = ShaderInstructionEncoder.parse(result.fragment, preprocessorExpressions);\n result.vertex = ShaderInstructionEncoder.source(result.vertex);\n result.fragment = ShaderInstructionEncoder.source(result.fragment);\n }\n return result;\n}\n\n/**\n * Converts parser-owned render states into JSON-safe precompile data.\n * @param renderStates - Parsed render-state maps.\n * @returns Serializable constant and variable maps.\n * @internal\n */\nexport function serializeRenderStates(renderStates: IRenderStates): {\n constantMap: Record<string, number | string | boolean | number[]>;\n variableMap: Record<string, string>;\n} {\n const constantMap: Record<string, number | string | boolean | number[]> = {};\n for (const key in renderStates.constantMap) {\n const value = renderStates.constantMap[key];\n if (value instanceof Color) {\n constantMap[key] = [value.r, value.g, value.b, value.a];\n } else {\n constantMap[key] = value as number | string | boolean;\n }\n }\n return { constantMap, variableMap: renderStates.variableMap };\n}\n\n/**\n * Formats a parser failure with include-source attribution.\n * @param error - Parser failure.\n * @returns User-facing error text.\n * @internal\n */\nexport function formatShaderError(error: Error): string {\n const text = error.toString();\n return error instanceof GSError && error.file ? `${error.file}: ${text}` : text;\n}\n","import { ShaderLanguage } from \"@galacean/engine-core\";\nimport type { IShaderSource } from \"@galacean/engine-design\";\nimport type { IShaderProgramSource } from \"@galacean/engine-design/types/shader-compiler/IShaderProgramSource\";\nimport {\n getParsedShaderPassPayload,\n normalizeShaderIncludeMap,\n ParserObjectPool,\n createRuntimeShaderTargetParser,\n parseRuntimeShaderPass,\n type IncludeMap,\n type ChunkOutputCache,\n ShaderSourceParser\n} from \"@galacean/engine-shader-parser/internal\";\nimport type { ParsedShaderPass } from \"@galacean/engine-shader-parser/shared\";\nimport { generateParsedShaderPassData, requireValidShaderSource } from \"./ShaderCompilation\";\n\n/**\n * Compiles ShaderLab sources into runtime GLES programs.\n *\n * Source parsing and backend generation remain independent of authoring diagnostics; structural\n * source errors reject compilation before partial runtime programs can be created. Offline `.shaderc`\n * validation lives in the bundler-only precompiler entry and is excluded from this runtime package surface.\n */\nexport class ShaderCompiler {\n private _includeMap: IncludeMap = {};\n private readonly _chunkOutputCache: ChunkOutputCache = new Map();\n private readonly _sourceParserObjectPool = new ParserObjectPool();\n private readonly _parserObjectPool = new ParserObjectPool();\n private readonly _runtimeParser = createRuntimeShaderTargetParser(this._parserObjectPool);\n\n /**\n * Replaces the `#include` lookup table and clears the derived chunk cache.\n * @param includeMap - Canonical include paths mapped to shader chunks.\n * @internal\n */\n _setIncludeMap(includeMap: IncludeMap): void {\n this._includeMap = normalizeShaderIncludeMap(includeMap);\n this._chunkOutputCache.clear();\n }\n\n /**\n * Parses one ShaderLab document into its source structure.\n * @param sourceCode - Complete ShaderLab source.\n * @returns Parsed subshaders, passes, entries, and render states.\n * @throws ShaderSourceParseError when source-structure diagnostics were produced.\n * @internal\n */\n _parseShaderSource(sourceCode: string): IShaderSource {\n this._chunkOutputCache.clear();\n return requireValidShaderSource(ShaderSourceParser.parseStrict(sourceCode, this._sourceParserObjectPool));\n }\n\n /**\n * Parses and generates one runtime ShaderLab pass.\n * @param source - GLSL source contained by the pass.\n * @param vertexEntry - Vertex entry function name.\n * @param fragmentEntry - Fragment entry function name.\n * @param backend - Target GLES language version.\n * @param sourceFile - Optional logical source location used for relative includes and attribution.\n * @param sourceScopeStarts - Inherited ShaderLab content boundaries from source parsing.\n * @returns Generated stage program, or `undefined` after a blocking parser or backend error.\n * @internal\n */\n _parseShaderPass(\n source: string,\n vertexEntry: string,\n fragmentEntry: string,\n backend: ShaderLanguage,\n sourceFile?: string,\n sourceScopeStarts?: readonly number[]\n ): IShaderProgramSource | undefined {\n const parsed = parseRuntimeShaderPass(\n source,\n this._includeMap,\n this._chunkOutputCache,\n sourceFile,\n this._parserObjectPool,\n this._runtimeParser,\n sourceScopeStarts\n );\n return generateParsedShaderPassData(parsed, vertexEntry, fragmentEntry, backend);\n }\n\n /**\n * Generates backend source from a pass returned by `ShaderAnalyzer.analyze()` without parsing it again.\n * @param pass - Opaque parsed-pass handle from the analyzer result.\n * @param backend - Target GLES language version.\n * @returns Variant-selectable instructions and unselected text for inspection, or `undefined` on validation failure.\n * @throws TypeError when `pass` was not created by the compatible shader-parser package instance.\n */\n generate(pass: ParsedShaderPass, backend: ShaderLanguage): IShaderProgramSource | undefined {\n const { data, vertexEntry, fragmentEntry, coreInfo } = getParsedShaderPassPayload(pass);\n return generateParsedShaderPassData(data, vertexEntry, fragmentEntry, backend, coreInfo);\n }\n}\n","import { Logger } from \"@galacean/engine-core\";\n\nexport { ShaderCompiler } from \"./ShaderCompiler\";\n\nexport { GSError, GSErrorName } from \"@galacean/engine-shader-parser/internal\";\n\n/**\n * Version of the shader compiler package, replaced with the package version during builds.\n */\nexport const version = `__buildVersion`;\n\nLogger.info(`Galacean Engine Shader Compiler Version: ${version}`);\n"],"names":["_instanceof","left","right","Symbol","hasInstance","_extends","Object","assign","target","i","arguments","length","source","key","prototype","hasOwnProperty","call","apply","ShaderRange","set","start","end","obj","constructor","_set_prototype_of","o","p","setPrototypeOf","__proto__","_inherits","subClass","superClass","TypeError","create","value","writable","configurable","_is_native_reflect_construct","result","Boolean","valueOf","Reflect","construct","_","_construct","Parent","args","Class","a","push","instance","Function","bind","_get_prototype_of","getPrototypeOf","_wrap_native_super","_cache","Map","undefined","toString","indexOf","has","get","Wrapper","enumerable","_array_like_to_array","arr","len","arr2","Array","_create_for_of_iterator_helper_loose","allowArrayLike","it","iterator","next","isArray","_unsupported_iterable_to_array","minLen","n","slice","name","from","test","done","reservedWords","Set","split","isUnsafeGLSLIdentifier","startsWith","includes","NameAllocator","_used","_names","reserve","add","sourceName","allocate","preferred","base","replace","separator","endsWith","suffix","reset","clear","VisitorContext","names","_lookupSymbol","SymbolInfo","_structRoles","_vertexUnresolvedVariableRoles","_fragmentUnresolvedVariableRoles","_vertexAmbiguousVariableNames","_fragmentAmbiguousVariableNames","attributeStructs","attributeList","varyingStructs","varyingList","mrtStructs","mrtList","_referencedGlobalSymbols","_referencedGlobalMacroASTs","_structVariableRoles","codeCache","resetAll","_referencedAttributeList","_referencedVaryingList","_referencedMRTList","_referencedGlobals","_globalSymbolQueries","_passSymbolTable","getStructRole","declarations","resolvedRole","_step","_iterator","declaration","role","hasStructRole","registerStructTypes","structs","struct","registerStructVar","variable","stage","roles","EShaderStage","VERTEX","ambiguous","ident","existing","delete","getUnresolvedStructVarRole","variableName","getStructVarRole","symbols","symbol","VarSymbol","referenceAttribute","_referenceProp","lexeme","referenceVarying","referenceMRTProp","referenceGlobal","type","queries","_this__globalSymbolQueries","getSymbols","_this__referencedGlobals","namedSymbols","_1","onReferenceGlobal","_proto","list","refList","filter","item","onReferenceStructProps","TempArray","array","dispose","CodeGenVisitor","context","cache","node","code","getCachedCode","defaultCodeGen","children","pool","_tmpArrayPool","ret","child","BaseToken","tokenLexeme","codeGen","join","return","token","interfaceMemberName","visitPostfixExpression","derivationLength","postExpr","prop","directRoot","ParserUtils","unwrapBareIdentifier","allowParens","resolvedValueSymbols","unresolvedName","extractDirectIdentLexeme","resolvedMemberOwners","ShaderStructRole","Attribute","Varying","identNode","indexNode","visitVariableIdentifier","referenceGlobalSymbolNames","ESymbolType","Any","_step1","resolvedSymbols","_iterator1","FnSymbol","referenceFunction","location","index","_branch","getLexeme","referenceIndex","branch","FN","visitFunctionCall","fnSymbol","fnSymbols","visitMacroCallFunction","paramList","ASTNode","FunctionCallParameterList","astNodes","paramNodes","paramsCode","params","argNode","MacroCallArgBlock","macroName","visitStatementList","visitMacroDefine","paramsLexeme","isFunction","paramsToken","valueCode","valueExpression","visitSingleDeclaration","visitGlobalVariableDeclaration","fullType","FullySpecifiedType","typeSpecifier","isCustom","declarator","STRUCT","visitDeclaration","visitFunctionParameterList","visitFunctionHeader","visitJumpStatement","visitFunctionIdentifier","visitTypeSpecifier","visitStructSpecifier","visitFunctionDefinition","fnNode","ReturnableObjectPool","ShaderInstructionEncoder","text","owner","activate","activation","id","group","sourceScope","sharedDeclaration","owners","map","reference","to","parse","glsl","preprocessorExpressions","instructions","pos","backfillStack","directiveStart","_findDirectiveStart","_pushText","lineEnd","_findLogicalLineEnd","line","substring","charCodeAt","kind","charAt","fields","Number","ShaderPreprocessorDirective","Declaration","Reference","ids","match","_DIRECTIVE_RE","exec","keyword","rest","trim","idx","IfDef","IfNdef","cond","_parseCondition","_pushConditionInstruction","stack","prevIdx","elseIdx","Else","_backfillJump","endifIdx","Endif","pop","afterEndif","j","inst","funcMatch","_FUNC_MACRO_RE","DefineFunc","_stripLineComment","_findInlineWhitespace","Define","DefineVal","Undef","t","m","IfCmp","op","v","IfExpr","expression","parsePreprocessorExpression","error","certain","hasExpandableIdentifier","e","Error","message","evaluationError","compact","toPreprocessorCondition","condition","c","nl","beforeBreak","charCode","last","directive","Text","OwnedText","every","concat","onlyPlaceholder","s","trimEnd","GLESVisitor","supportsArrayStructReturn","_globalNames","_escapedDeclarations","_fragmentVaryingProps","_globalInputs","_inputHelperBodies","_inputHelperGroups","_globalCodeArray","_forwardFunctionDeclarations","_forwardStructIndices","_structCodeSegments","_forwardVariableIndices","_variableCodeSegments","_declarationOwners","_deferredPrototypes","_declarationReferences","_outerMacroDeclarations","protoProps","globalCodeArray","_this","_currentDeclaration","_vertexOutputNames","getOtherGlobal","data","out","values","fallback","globalPrecisions","precision","generate","ir","coreInfo","program","shaderData","symbolTable","hasUnsafeIdentifier","forEach","_this1","outerGlobalMacroDeclarations","io","Mrt","structVariableRoles","vertexStructVariableRoles","fragmentStructVariableRoles","FRAGMENT","_collectEscapedDeclarations","_i","_iter","_loop","_iter__i","variables","inputRole","param","astNode","VariableDeclaration","_sourceIR","deferredDeclarationOwnership","nextInputOwner","Math","max","_step2","_iterator2","_step3","_iterator3","size","nextId","nextGroup","_this_currentDeclarationOwner","_this_currentDeclarationOwner_id","currentDeclarationOwner","_referenceDeclaration","_step4","propDeclarations","_iterator4","_step5","_iterator5","propList","props","unsupportedDeferredDeclarations","mapExpandedShaderError","GSError","GSErrorName","CompilationError","sourceMap","fragment","_fragmentMain","fragmentEntry","vertex","_vertexMain","vertexEntry","vertexOutputNames","entryInfo","stageEntry","_preRegisterGlobalMacroRefs","_referenceInterfaceDependencies","_initializeGlobalInputs","_getGlobalSymbol","_getCustomStruct","_getGlobalMacroDeclarations","_emitDeclarationReferences","globalCode","sort","b","outerGlobalMacroStatements","prepareFragment","typeInfo","structDeclarations","dependency","arraySpecifier","interfaceName","isOutput","sameName","conflicts","some","generated","_this__vertexOutputNames","_interfaceTypeName","_interfaceVariableName","TypeSpecifier","ParameterDeclarator","identifier","TreeNode","_this__escapedDeclarations_get","_escapedReference","candidate","dataType","StructSymbol","_transferName","read","structCode","typeName","memberCode","emit","segments","macroExpressions","retain","references","used","_containsArray","typeLexeme","hasRetainedField","hasFields","padding","_this_getMRTProp","getAttributeProp","getVaryingProp","getMRTProp","assignments","wire","mrtOutput","member","visited","parent","EqualityExpression","observe","VariableIdentifier","_observeWholeStruct","FunctionCallGeneric","StructSpecifier","FunctionDefinition","protoType","returnType","statement","definition","parameters","parameterList","parameter","entryName","Keyword","VEC4","fragmentColorOutput","inputs","_this__globalInputs_get","calls","VAR","helper","macros","macro","_walkMacroDefineTokens","MacroDefine","previous","sm","codeGenResult","isInMacroBranch","segment","_declaration","_getForwardDeclarations","candidates","equal","replacement","nextOwner","anchor","_isContextIndependent","_hasDeclarationContextBarrier","_unsupportedForwardDeclaration","outer","find","typeAnchor","_prepareForwardTypes","compatible","_canBranchesOverlap","branchSignature","canInheritanceBranchesCover","preceding","signature","_getForwardSignature","outerMacro","tokens","visit","IN","getLexicalDeclarationCoexistence","_this__escapedReference","isUniform","_this_context__referencedGlobals_symbol_ident","oldMacro","_this__forwardVariableIndices_get","min","Infinity","guarded","entry","splice","FunctionIdentifier","structDependencies","GlobalDeclaration","final","types","hoistAnchor","_this__forwardStructIndices_get","needsHoist","dependencyAnchor","property","MacroCallSymbol","MacroCallFunction","MACRO_IF","MACRO_DEFINE_PARAMS","includeMacros","inFunction","PrecisionSpecifier","MACRO_UNDEF","MACRO_DEFINE_EXPRESSION","structNodes","referencedGlobalMacroASTs","GlobalMacroIfStatement","_visitGlobalMacroIfStatement","_this_getCachedCode","VariableDeclarationList","variableDeclarations","_this_getCachedCode1","variableDeclaration","targets","initializer","_defineProperties","descriptor","defineProperty","Constructor","GLES100Visitor","mrtIndex","GLES300Visitor","_outputDeclarations","_fragDataArrayRequired","_fragDataIndices","_scannedFragmentFunctions","output","unconditional","qualifier","isBuiltin","builtinSemantic","ShaderBuiltinSemantic","FragmentOutput0","_registerFragColorVariable","_fragmentColorName","FragmentDepth","FragmentOutputArray","_registerFragDataArray","_fragmentDataName","_registerFragDataVariable","_registerOutput","pending","functions","fn","_scanFragmentOutputs","calledFunctions","PostfixExpression","constIntegerValue","GLESBackend","glesInfo","GLESShaderInfo","mrtOutputIssues","invalidMrtReturnLocations","Logger","invalidVaryingReturnLocations","structMemberOwnerIssues","ShaderLanguage","GLSLES100","_generateWithPool","_gles100VisitorPool","_gles300VisitorPool","visitor","file","ShaderSourceParseError","Error1","errors","generateParsedShaderPassData","parsed","backend","blockingErrors","resolvedCoreInfo","ShaderCoreInfo","generateShaderProgram","hasDefiniteAmbiguity","roleConflicts","vertexShaderInstructions","fragmentShaderInstructions","ShaderCompiler","_includeMap","_chunkOutputCache","_sourceParserObjectPool","ParserObjectPool","_parserObjectPool","_runtimeParser","createRuntimeShaderTargetParser","_setIncludeMap","includeMap","normalizeShaderIncludeMap","_parseShaderSource","sourceCode","requireValidShaderSource","shaderSource","ShaderSourceParser","parseStrict","_parseShaderPass","sourceFile","sourceScopeStarts","parseRuntimeShaderPass","pass","getParsedShaderPassPayload","version","info"],"mappings":"saAAA,SAASA,EAAYC,CAAI,CAAEC,CAAK,SAC5B,AAAIA,AAAS,MAATA,GAAiB,AAAkB,aAAlB,OAAOC,QAA0BD,CAAK,CAACC,OAAOC,WAAW,CAAC,CACpE,CAAC,CAACF,CAAK,CAACC,OAAOC,WAAW,CAAC,CAACH,GACzBA,aAAgBC,CAClC,CCJA,SAASG,IAUL,MAAOA,AATPA,CAAAA,EAAWC,OAAOC,MAAM,EAAI,SAAgBC,CAAM,EAC9C,IAAK,IAAIC,EAAI,EAAGA,EAAIC,UAAUC,MAAM,CAAEF,IAAK,CACvC,IAAIG,EAASF,SAAS,CAACD,EAAE,CACzB,IAAK,IAAII,KAAOD,EAAYN,OAAOQ,SAAS,CAACC,cAAc,CAACC,IAAI,CAACJ,EAAQC,IAAML,CAAAA,CAAM,CAACK,EAAI,CAAGD,CAAM,CAACC,EAAI,AAAD,CAC1G,CAED,OAAOL,CACf,CAAA,EAEoBS,KAAK,CAAC,IAAI,CAAEP,UAChC,ggUCLO,IAAMQ,EAAN,WAAMA,SAAAA,IAAAA,CAAAA,OAYXC,AAZWD,EAAAA,SAYXC,CAAAA,GAGC,CAHDA,SAAIC,CAAqB,CAAEC,CAAmB,EAC5C,IAAI,CAACD,KAAK,CAAGA,EACb,IAAI,CAACC,GAAG,CAAGA,CACb,EAfWH,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