@galacean/engine-shader-parser 2.0.0-alpha.55 → 2.0.0-alpha.57

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.
@@ -1,2 +1,2 @@
1
- "use strict";var engineDesign=require("@galacean/engine-design");var engineCore=require("@galacean/engine-core");var engineMath=require("@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=engineDesign.parsePreprocessorExpression(expression);var result=parsedExpression;if(!result.ok||result.evaluationError)return undefined;var constantValue=engineDesign.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=engineDesign.evaluateContextFreePreprocessorCondition(condition.r);if(condition.l.t==="id"&&right!==undefined){return{t:"cmp",m:condition.l.m,op:condition.op,v:right}}var left=engineDesign.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=engineDesign.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=engineDesign.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=engineDesign.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]:engineDesign.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?engineDesign.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=engineDesign.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)&&current.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{engineCore.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&&parameters.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:engineDesign.normalizeShaderIncludeKey(normalized)}if(!ABSOLUTE_URL_PATTERN$1.test(normalized)){return engineDesign.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=engineDesign.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=engineDesign.parsePreprocessorExpression(trimmedExpression);var withDefinedValues=engineDesign.resolvePreprocessorDefinedOperators(trimmedExpression,function(name){return _this._state(name).defined});var expansion=engineDesign.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=engineDesign.resolvePreprocessorDefinedOperators(expansion.expression,function(name){return _this._state(name).defined});var parsed=engineDesign.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}:engineDesign.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;engineCore.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 engineDesign.normalizeShaderIncludeKey(new URL(includeName,basePath).href)}try{var url=new URL(includeName,basePath);return engineDesign.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)&&parameterNode.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)&&macros.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 engineMath.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:engineCore.RenderQueueType,CompareFunction:engineCore.CompareFunction,StencilOperation:engineCore.StencilOperation,BlendOperation:engineCore.BlendOperation,BlendFactor:engineCore.BlendFactor,CullMode:engineCore.CullMode,ColorWriteMask:engineCore.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=engineCore.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=engineCore.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)&&current.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}exports.ASTNode=ASTNode;exports.BaseLexer=BaseLexer;exports.BaseToken=BaseToken;exports.BuiltinFunction=BuiltinFunction;exports.BuiltinVariable=BuiltinVariable;exports.BuiltinVariableTable=BuiltinVariableTable;exports.EMPTY_BRANCH=EMPTY_BRANCH;exports.EOF=EOF;exports.EShaderStage=EShaderStage;exports.ESymbolType=ESymbolType;exports.ETokenType=ETokenType;exports.FnSymbol=FnSymbol;exports.GLESShaderInfo=GLESShaderInfo;exports.GSError=GSError;exports.GSErrorName=GSErrorName;exports.GenericType=GenericType;exports.Grammar=Grammar;exports.Keyword=Keyword;exports.LALR1=LALR1;exports.Lexer=Lexer;exports.NoneTerminal=NoneTerminal;exports.ParserObjectPool=ParserObjectPool;exports.ParserSemanticValidation=ParserSemanticValidation;exports.ParserUtils=ParserUtils;exports.Preprocessor=Preprocessor;exports.ShaderBuiltinSemantic=ShaderBuiltinSemantic;exports.ShaderClueIR=ShaderClueIR;exports.ShaderCompilerUtils=ShaderCompilerUtils;exports.ShaderCoreInfo=ShaderCoreInfo;exports.ShaderData=ShaderData;exports.ShaderPosition=ShaderPosition;exports.ShaderRange=ShaderRange;exports.ShaderSourceFactory=ShaderSourceFactory;exports.ShaderSourceParser=ShaderSourceParser;exports.ShaderStructRole=ShaderStructRole;exports.ShaderTargetParser=ShaderTargetParser;exports.StructProp=StructProp;exports.StructSymbol=StructSymbol;exports.SymbolDataType=SymbolDataType;exports.SymbolInfo=SymbolInfo;exports.SymbolTable=SymbolTable;exports.SymbolTableStack=SymbolTableStack;exports.SymbolType=SymbolType;exports.TreeNode=TreeNode;exports.TypeAny=TypeAny;exports.TypeSystem=TypeSystem;exports.VarSymbol=VarSymbol;exports.__generator=__generator;exports._create_for_of_iterator_helper_loose=_create_for_of_iterator_helper_loose;exports._extends=_extends;exports._inherits=_inherits;exports._instanceof=_instanceof;exports.addTranslationRule=addTranslationRule;exports.areConditionsComplementary=areConditionsComplementary;exports.branchAnalysis=branchAnalysis;exports.canBranchesCoverCallsite=canBranchesCoverCallsite;exports.canBranchesOverlap=canBranchesOverlap;exports.canDeclarationsCoexist=canDeclarationsCoexist;exports.canInheritanceBranchesCover=canInheritanceBranchesCover;exports.createGrammar=createGrammar;exports.createParsedShaderPass=createParsedShaderPass;exports.createRuntimeShaderTargetParser=createRuntimeShaderTargetParser;exports.createShaderDeclarationOwnership=createShaderDeclarationOwnership;exports.formatDiagnosticSource=formatDiagnosticSource;exports.getBranchCoverage=getBranchCoverage;exports.getBranchReachability=getBranchReachability;exports.getDeclarationCoexistence=getDeclarationCoexistence;exports.getLexicalDeclarationCoexistence=getLexicalDeclarationCoexistence;exports.getParsedShaderPassPayload=getParsedShaderPassPayload;exports.isBranchReachable=isBranchReachable;exports.isBranchVisibleFrom=isBranchVisibleFrom;exports.isConditionalChainExhaustive=isConditionalChainExhaustive;exports.isDeferredDeclarationPair=isDeferredDeclarationPair;exports.mapExpandedShaderError=mapExpandedShaderError;exports.mapExpandedShaderRange=mapExpandedShaderRange;exports.normalizeShaderIncludeMap=normalizeShaderIncludeMap;exports.normalizeShaderSourceFile=normalizeShaderSourceFile;exports.parsePreprocessorCondition=parsePreprocessorCondition;exports.parseRuntimeShaderPass=parseRuntimeShaderPass;exports.parseShaderPassWith=parseShaderPassWith;exports.proveInheritanceBranchesCover=proveInheritanceBranchesCover;exports.sameBranch=sameBranch;exports.shaderSourceBaseURL=shaderSourceBaseURL;exports.toPreprocessorCondition=toPreprocessorCondition;exports.tryParsePreprocessorCondition=tryParsePreprocessorCondition;
1
+ "use strict";var engineDesign=require("@galacean/engine-design");var engineCore=require("@galacean/engine-core");var engineMath=require("@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=engineDesign.parsePreprocessorExpression(expression);var result=parsedExpression;if(!result.ok||result.evaluationError)return undefined;var constantValue=engineDesign.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=engineDesign.evaluateContextFreePreprocessorCondition(condition.r);if(condition.l.t==="id"&&right!==undefined){return{t:"cmp",m:condition.l.m,op:condition.op,v:right}}var left=engineDesign.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=engineDesign.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=engineDesign.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=engineDesign.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]:engineDesign.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?engineDesign.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=engineDesign.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)&&current.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{engineCore.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&&parameters.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:engineDesign.normalizeShaderIncludeKey(normalized)}if(!ABSOLUTE_URL_PATTERN$1.test(normalized)){return engineDesign.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=engineDesign.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=engineDesign.parsePreprocessorExpression(trimmedExpression);var withDefinedValues=engineDesign.resolvePreprocessorDefinedOperators(trimmedExpression,function(name){return _this._state(name).defined});var expansion=engineDesign.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=engineDesign.resolvePreprocessorDefinedOperators(expansion.expression,function(name){return _this._state(name).defined});var parsed=engineDesign.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}:engineDesign.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;engineCore.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 engineDesign.normalizeShaderIncludeKey(new URL(includeName,basePath).href)}try{var url=new URL(includeName,basePath);return engineDesign.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)&&parameterNode.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)&&macros.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 engineMath.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:engineCore.RenderQueueType,CompareFunction:engineCore.CompareFunction,StencilOperation:engineCore.StencilOperation,BlendOperation:engineCore.BlendOperation,BlendFactor:engineCore.BlendFactor,CullMode:engineCore.CullMode,ColorWriteMask:engineCore.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=engineCore.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=engineCore.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)&&current.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}exports.ASTNode=ASTNode;exports.BaseLexer=BaseLexer;exports.BaseToken=BaseToken;exports.BuiltinFunction=BuiltinFunction;exports.BuiltinVariable=BuiltinVariable;exports.BuiltinVariableTable=BuiltinVariableTable;exports.EMPTY_BRANCH=EMPTY_BRANCH;exports.EOF=EOF;exports.EShaderStage=EShaderStage;exports.ESymbolType=ESymbolType;exports.ETokenType=ETokenType;exports.FnSymbol=FnSymbol;exports.GLESShaderInfo=GLESShaderInfo;exports.GSError=GSError;exports.GSErrorName=GSErrorName;exports.GenericType=GenericType;exports.Grammar=Grammar;exports.Keyword=Keyword;exports.LALR1=LALR1;exports.Lexer=Lexer;exports.NoneTerminal=NoneTerminal;exports.ParserObjectPool=ParserObjectPool;exports.ParserSemanticValidation=ParserSemanticValidation;exports.ParserUtils=ParserUtils;exports.Preprocessor=Preprocessor;exports.ShaderBuiltinSemantic=ShaderBuiltinSemantic;exports.ShaderClueIR=ShaderClueIR;exports.ShaderCompilerUtils=ShaderCompilerUtils;exports.ShaderCoreInfo=ShaderCoreInfo;exports.ShaderData=ShaderData;exports.ShaderPosition=ShaderPosition;exports.ShaderRange=ShaderRange;exports.ShaderSourceFactory=ShaderSourceFactory;exports.ShaderSourceParser=ShaderSourceParser;exports.ShaderStructRole=ShaderStructRole;exports.ShaderTargetParser=ShaderTargetParser;exports.StructProp=StructProp;exports.StructSymbol=StructSymbol;exports.SymbolDataType=SymbolDataType;exports.SymbolInfo=SymbolInfo;exports.SymbolTable=SymbolTable;exports.SymbolTableStack=SymbolTableStack;exports.SymbolType=SymbolType;exports.TreeNode=TreeNode;exports.TypeAny=TypeAny;exports.TypeSystem=TypeSystem;exports.VarSymbol=VarSymbol;exports.__generator=__generator;exports._create_for_of_iterator_helper_loose=_create_for_of_iterator_helper_loose;exports._extends=_extends;exports._inherits=_inherits;exports._instanceof=_instanceof;exports.addTranslationRule=addTranslationRule;exports.areConditionsComplementary=areConditionsComplementary;exports.branchAnalysis=branchAnalysis;exports.canBranchesCoverCallsite=canBranchesCoverCallsite;exports.canBranchesOverlap=canBranchesOverlap;exports.canDeclarationsCoexist=canDeclarationsCoexist;exports.canInheritanceBranchesCover=canInheritanceBranchesCover;exports.createGrammar=createGrammar;exports.createParsedShaderPass=createParsedShaderPass;exports.createRuntimeShaderTargetParser=createRuntimeShaderTargetParser;exports.createShaderDeclarationOwnership=createShaderDeclarationOwnership;exports.formatDiagnosticSource=formatDiagnosticSource;exports.getBranchCoverage=getBranchCoverage;exports.getBranchReachability=getBranchReachability;exports.getDeclarationCoexistence=getDeclarationCoexistence;exports.getLexicalDeclarationCoexistence=getLexicalDeclarationCoexistence;exports.getParsedShaderPassPayload=getParsedShaderPassPayload;exports.isBranchReachable=isBranchReachable;exports.isBranchVisibleFrom=isBranchVisibleFrom;exports.isConditionalChainExhaustive=isConditionalChainExhaustive;exports.isDeferredDeclarationPair=isDeferredDeclarationPair;exports.mapExpandedShaderError=mapExpandedShaderError;exports.mapExpandedShaderRange=mapExpandedShaderRange;exports.normalizeShaderIncludeMap=normalizeShaderIncludeMap;exports.normalizeShaderSourceFile=normalizeShaderSourceFile;exports.parsePreprocessorCondition=parsePreprocessorCondition;exports.parseRuntimeShaderPass=parseRuntimeShaderPass;exports.parseShaderPassWith=parseShaderPassWith;exports.proveInheritanceBranchesCover=proveInheritanceBranchesCover;exports.sameBranch=sameBranch;exports.shaderSourceBaseURL=shaderSourceBaseURL;exports.toPreprocessorCondition=toPreprocessorCondition;exports.tryParsePreprocessorCondition=tryParsePreprocessorCondition;
2
2
  //# sourceMappingURL=GLESShaderInfo.main.js.map