@galacean/engine-shaderlab 1.4.9 → 1.4.11

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.
@@ -754,7 +754,7 @@ var LexerUtils = /*#__PURE__*/ function() {
754
754
  charCode >= 97 && charCode <= 122 // a - z
755
755
  ;
756
756
  };
757
- LexerUtils.isPpCharactors = function isPpCharactors(charCode) {
757
+ LexerUtils.isPpCharacters = function isPpCharacters(charCode) {
758
758
  return charCode === 35 || // #
759
759
  charCode === 46 || // .
760
760
  charCode === 95 || // _
@@ -1504,8 +1504,8 @@ var VarSymbol = /*#__PURE__*/ function(SymbolInfo) {
1504
1504
  return VarSymbol;
1505
1505
  }(SymbolInfo);
1506
1506
 
1507
- var SematicAnalyzer = /*#__PURE__*/ function() {
1508
- function SematicAnalyzer() {
1507
+ var SemanticAnalyzer = /*#__PURE__*/ function() {
1508
+ function SemanticAnalyzer() {
1509
1509
  this.semanticStack = [];
1510
1510
  this.acceptRule = undefined;
1511
1511
  this.symbolTableStack = new SymbolTableStack();
@@ -1515,7 +1515,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
1515
1515
  this.errors = [];
1516
1516
  this.newScope();
1517
1517
  }
1518
- var _proto = SematicAnalyzer.prototype;
1518
+ var _proto = SemanticAnalyzer.prototype;
1519
1519
  _proto.reset = function reset() {
1520
1520
  this.semanticStack.length = 0;
1521
1521
  this._shaderData = new ShaderData();
@@ -1547,7 +1547,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
1547
1547
  _proto.reportError = function reportError(loc, message) {
1548
1548
  this.errors.push(new GSError(GSErrorName.CompilationError, message, loc, ShaderLab._processingPassText));
1549
1549
  };
1550
- _create_class(SematicAnalyzer, [
1550
+ _create_class(SemanticAnalyzer, [
1551
1551
  {
1552
1552
  key: "shaderData",
1553
1553
  get: function get() {
@@ -1555,7 +1555,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
1555
1555
  }
1556
1556
  }
1557
1557
  ]);
1558
- return SematicAnalyzer;
1558
+ return SemanticAnalyzer;
1559
1559
  }();
1560
1560
 
1561
1561
  var NoneTerminal = /*#__PURE__*/ function(NoneTerminal) {
@@ -2582,28 +2582,12 @@ var TreeNode = /*#__PURE__*/ function() {
2582
2582
  function FullySpecifiedType() {
2583
2583
  return TreeNode.apply(this, arguments) || this;
2584
2584
  }
2585
- _create_class(FullySpecifiedType, [
2586
- {
2587
- key: "qualifierList",
2588
- get: function get() {
2589
- if (this.children.length > 1) {
2590
- return this.children[0].qualifierList;
2591
- }
2592
- }
2593
- },
2594
- {
2595
- key: "typeSpecifier",
2596
- get: function get() {
2597
- return this.children.length === 1 ? this.children[0] : this.children[1];
2598
- }
2599
- },
2600
- {
2601
- key: "type",
2602
- get: function get() {
2603
- return this.typeSpecifier.type;
2604
- }
2605
- }
2606
- ]);
2585
+ var _proto = FullySpecifiedType.prototype;
2586
+ _proto.semanticAnalyze = function semanticAnalyze(_) {
2587
+ var children = this.children;
2588
+ this.typeSpecifier = children.length === 1 ? children[0] : children[1];
2589
+ this.type = this.typeSpecifier.type;
2590
+ };
2607
2591
  return FullySpecifiedType;
2608
2592
  }(TreeNode);
2609
2593
  ASTNode.FullySpecifiedType = FullySpecifiedType;
@@ -2615,18 +2599,6 @@ var TreeNode = /*#__PURE__*/ function() {
2615
2599
  function TypeQualifier() {
2616
2600
  return TreeNode.apply(this, arguments) || this;
2617
2601
  }
2618
- var _proto = TypeQualifier.prototype;
2619
- _proto.semanticAnalyze = function semanticAnalyze(sa) {
2620
- if (this.children.length > 1) {
2621
- this.qualifierList = [].concat(this.children[0].qualifierList, [
2622
- this.children[1].qualifier
2623
- ]);
2624
- } else {
2625
- this.qualifierList = [
2626
- this.children[0].qualifier
2627
- ];
2628
- }
2629
- };
2630
2602
  return TypeQualifier;
2631
2603
  }(TreeNode);
2632
2604
  ASTNode.TypeQualifier = TypeQualifier;
@@ -2660,20 +2632,12 @@ var TreeNode = /*#__PURE__*/ function() {
2660
2632
  function BasicTypeQualifier() {
2661
2633
  return TreeNode.apply(this, arguments) || this;
2662
2634
  }
2663
- _create_class(BasicTypeQualifier, [
2664
- {
2665
- key: "qualifier",
2666
- get: function get() {
2667
- return this.children[0].type;
2668
- }
2669
- },
2670
- {
2671
- key: "lexeme",
2672
- get: function get() {
2673
- return this.children[0].lexeme;
2674
- }
2675
- }
2676
- ]);
2635
+ var _proto = BasicTypeQualifier.prototype;
2636
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
2637
+ var token = this.children[0];
2638
+ this.qualifier = token.type;
2639
+ this.lexeme = token.lexeme;
2640
+ };
2677
2641
  return BasicTypeQualifier;
2678
2642
  }(TreeNode);
2679
2643
  var StorageQualifier = /*#__PURE__*/ function(BasicTypeQualifier) {
@@ -2725,37 +2689,25 @@ var TreeNode = /*#__PURE__*/ function() {
2725
2689
  function TypeSpecifier() {
2726
2690
  return TreeNode.apply(this, arguments) || this;
2727
2691
  }
2692
+ var _proto = TypeSpecifier.prototype;
2693
+ _proto.init = function init() {
2694
+ this.arraySize = undefined;
2695
+ };
2696
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
2697
+ var _children_;
2698
+ var children = this.children;
2699
+ var firstChild = children[0];
2700
+ this.type = firstChild.type;
2701
+ this.lexeme = firstChild.lexeme;
2702
+ this.arraySize = children == null ? void 0 : (_children_ = children[1]) == null ? void 0 : _children_.size;
2703
+ this.isCustom = typeof this.type === "string";
2704
+ };
2728
2705
  _create_class(TypeSpecifier, [
2729
- {
2730
- key: "type",
2731
- get: function get() {
2732
- return this.children[0].type;
2733
- }
2734
- },
2735
- {
2736
- key: "lexeme",
2737
- get: function get() {
2738
- return this.children[0].lexeme;
2739
- }
2740
- },
2741
- {
2742
- key: "arraySize",
2743
- get: function get() {
2744
- var _this_children_, _this_children;
2745
- return (_this_children = this.children) == null ? void 0 : (_this_children_ = _this_children[1]) == null ? void 0 : _this_children_.size;
2746
- }
2747
- },
2748
2706
  {
2749
2707
  key: "arraySpecifier",
2750
2708
  get: function get() {
2751
2709
  return this.children[1];
2752
2710
  }
2753
- },
2754
- {
2755
- key: "isCustom",
2756
- get: function get() {
2757
- return typeof this.type === "string";
2758
- }
2759
2711
  }
2760
2712
  ]);
2761
2713
  return TypeSpecifier;
@@ -2769,15 +2721,11 @@ var TreeNode = /*#__PURE__*/ function() {
2769
2721
  function ArraySpecifier() {
2770
2722
  return TreeNode.apply(this, arguments) || this;
2771
2723
  }
2772
- _create_class(ArraySpecifier, [
2773
- {
2774
- key: "size",
2775
- get: function get() {
2776
- var integerConstantExpr = this.children[1];
2777
- return integerConstantExpr.value;
2778
- }
2779
- }
2780
- ]);
2724
+ var _proto = ArraySpecifier.prototype;
2725
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
2726
+ var integerConstantExpr = this.children[1];
2727
+ this.size = integerConstantExpr.value;
2728
+ };
2781
2729
  return ArraySpecifier;
2782
2730
  }(TreeNode);
2783
2731
  ASTNode.ArraySpecifier = ArraySpecifier;
@@ -2792,6 +2740,7 @@ var TreeNode = /*#__PURE__*/ function() {
2792
2740
  var _proto = IntegerConstantExpressionOperator.prototype;
2793
2741
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
2794
2742
  var operator = this.children[0];
2743
+ this.lexeme = operator.lexeme;
2795
2744
  switch(operator.type){
2796
2745
  case ETokenType.PLUS:
2797
2746
  this.compute = function(a, b) {
@@ -2822,14 +2771,6 @@ var TreeNode = /*#__PURE__*/ function() {
2822
2771
  sa.reportError(operator.location, "not implemented operator " + operator.lexeme);
2823
2772
  }
2824
2773
  };
2825
- _create_class(IntegerConstantExpressionOperator, [
2826
- {
2827
- key: "lexeme",
2828
- get: function get() {
2829
- return this.children[0].lexeme;
2830
- }
2831
- }
2832
- ]);
2833
2774
  return IntegerConstantExpressionOperator;
2834
2775
  }(TreeNode);
2835
2776
  ASTNode.IntegerConstantExpressionOperator = IntegerConstantExpressionOperator;
@@ -2915,35 +2856,31 @@ var TreeNode = /*#__PURE__*/ function() {
2915
2856
  var _proto = InitDeclaratorList.prototype;
2916
2857
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
2917
2858
  var sm;
2918
- if (this.children.length === 3 || this.children.length === 5) {
2919
- var id = this.children[2];
2859
+ var children = this.children;
2860
+ var childrenLength = children.length;
2861
+ if (childrenLength === 1) {
2862
+ var _children_ = children[0], typeSpecifier = _children_.typeSpecifier, arraySpecifier = _children_.arraySpecifier;
2863
+ this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
2864
+ } else {
2865
+ var initDeclList = children[0];
2866
+ this.typeInfo = initDeclList.typeInfo;
2867
+ }
2868
+ if (childrenLength === 3 || childrenLength === 5) {
2869
+ var id = children[2];
2920
2870
  sm = new VarSymbol(id.lexeme, this.typeInfo, false, this);
2921
2871
  sa.symbolTableStack.insert(sm);
2922
- } else if (this.children.length === 4 || this.children.length === 6) {
2872
+ } else if (childrenLength === 4 || childrenLength === 6) {
2923
2873
  var typeInfo = this.typeInfo;
2924
- var arraySpecifier = this.children[3];
2925
- if (typeInfo.arraySpecifier && arraySpecifier) {
2926
- sa.reportError(arraySpecifier.location, "Array of array is not supported.");
2874
+ var arraySpecifier1 = this.children[3];
2875
+ if (typeInfo.arraySpecifier && arraySpecifier1) {
2876
+ sa.reportError(arraySpecifier1.location, "Array of array is not supported.");
2927
2877
  }
2928
- typeInfo.arraySpecifier = arraySpecifier;
2929
- var id1 = this.children[2];
2878
+ typeInfo.arraySpecifier = arraySpecifier1;
2879
+ var id1 = children[2];
2930
2880
  sm = new VarSymbol(id1.lexeme, typeInfo, false, this);
2931
2881
  sa.symbolTableStack.insert(sm);
2932
2882
  }
2933
2883
  };
2934
- _create_class(InitDeclaratorList, [
2935
- {
2936
- key: "typeInfo",
2937
- get: function get() {
2938
- if (this.children.length === 1) {
2939
- var singleDecl = this.children[0];
2940
- return new SymbolType(singleDecl.typeSpecifier.type, singleDecl.typeSpecifier.lexeme, singleDecl.arraySpecifier);
2941
- }
2942
- var initDeclList = this.children[0];
2943
- return initDeclList.typeInfo;
2944
- }
2945
- }
2946
- ]);
2947
2884
  return InitDeclaratorList;
2948
2885
  }(TreeNode);
2949
2886
  ASTNode.InitDeclaratorList = InitDeclaratorList;
@@ -2953,23 +2890,29 @@ var TreeNode = /*#__PURE__*/ function() {
2953
2890
  var IdentifierList = /*#__PURE__*/ function(TreeNode) {
2954
2891
  _inherits(IdentifierList, TreeNode);
2955
2892
  function IdentifierList() {
2956
- return TreeNode.apply(this, arguments) || this;
2893
+ var _this;
2894
+ _this = TreeNode.apply(this, arguments) || this, _this.idList = [];
2895
+ return _this;
2957
2896
  }
2958
- _create_class(IdentifierList, [
2959
- {
2960
- key: "idList",
2961
- get: function get() {
2962
- if (this.children.length === 2) {
2963
- return [
2964
- this.children[1]
2965
- ];
2966
- }
2967
- return [].concat(this.children[0].idList, [
2968
- this.children[2]
2969
- ]);
2897
+ var _proto = IdentifierList.prototype;
2898
+ _proto.init = function init() {
2899
+ this.idList.length = 0;
2900
+ };
2901
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
2902
+ var _this = this, children = _this.children, curIdList = _this.idList;
2903
+ if (children.length === 2) {
2904
+ curIdList.push(children[1]);
2905
+ } else {
2906
+ var list = children[0];
2907
+ var id = children[2];
2908
+ var listIdLength = list.idList.length;
2909
+ curIdList.length = listIdLength + 1;
2910
+ for(var i = 0; i < listIdLength; i++){
2911
+ curIdList[i] = list.idList[i];
2970
2912
  }
2913
+ curIdList[listIdLength] = id;
2971
2914
  }
2972
- ]);
2915
+ };
2973
2916
  return IdentifierList;
2974
2917
  }(TreeNode);
2975
2918
  ASTNode.IdentifierList = IdentifierList;
@@ -2997,41 +2940,16 @@ var TreeNode = /*#__PURE__*/ function() {
2997
2940
  return TreeNode.apply(this, arguments) || this;
2998
2941
  }
2999
2942
  var _proto = FunctionProtoType.prototype;
2943
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
2944
+ var declarator = this.children[0];
2945
+ this.ident = declarator.ident;
2946
+ this.returnType = declarator.returnType;
2947
+ this.parameterList = declarator.parameterInfoList;
2948
+ this.paramSig = declarator.paramSig;
2949
+ };
3000
2950
  _proto.codeGen = function codeGen(visitor) {
3001
2951
  return visitor.visitFunctionProtoType(this);
3002
2952
  };
3003
- _create_class(FunctionProtoType, [
3004
- {
3005
- key: "declarator",
3006
- get: function get() {
3007
- return this.children[0];
3008
- }
3009
- },
3010
- {
3011
- key: "ident",
3012
- get: function get() {
3013
- return this.declarator.ident;
3014
- }
3015
- },
3016
- {
3017
- key: "returnType",
3018
- get: function get() {
3019
- return this.declarator.returnType;
3020
- }
3021
- },
3022
- {
3023
- key: "parameterList",
3024
- get: function get() {
3025
- return this.declarator.parameterInfoList;
3026
- }
3027
- },
3028
- {
3029
- key: "paramSig",
3030
- get: function get() {
3031
- return this.declarator.paramSig;
3032
- }
3033
- }
3034
- ]);
3035
2953
  return FunctionProtoType;
3036
2954
  }(TreeNode);
3037
2955
  ASTNode.FunctionProtoType = FunctionProtoType;
@@ -3047,47 +2965,14 @@ var TreeNode = /*#__PURE__*/ function() {
3047
2965
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3048
2966
  sa.curFunctionInfo.returnStatement = null;
3049
2967
  sa.curFunctionInfo.header = this;
2968
+ var children = this.children;
2969
+ var header = children[0];
2970
+ var parameterList = children[1];
2971
+ this.ident = header.ident;
2972
+ this.returnType = header.returnType;
2973
+ this.parameterInfoList = parameterList == null ? void 0 : parameterList.parameterInfoList;
2974
+ this.paramSig = parameterList == null ? void 0 : parameterList.paramSig;
3050
2975
  };
3051
- _create_class(FunctionDeclarator, [
3052
- {
3053
- key: "header",
3054
- get: function get() {
3055
- return this.children[0];
3056
- }
3057
- },
3058
- {
3059
- key: "parameterList",
3060
- get: function get() {
3061
- return this.children[1];
3062
- }
3063
- },
3064
- {
3065
- key: "ident",
3066
- get: function get() {
3067
- return this.header.ident;
3068
- }
3069
- },
3070
- {
3071
- key: "returnType",
3072
- get: function get() {
3073
- return this.header.returnType;
3074
- }
3075
- },
3076
- {
3077
- key: "parameterInfoList",
3078
- get: function get() {
3079
- var _this_parameterList;
3080
- return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.parameterInfoList;
3081
- }
3082
- },
3083
- {
3084
- key: "paramSig",
3085
- get: function get() {
3086
- var _this_parameterList;
3087
- return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.paramSig;
3088
- }
3089
- }
3090
- ]);
3091
2976
  return FunctionDeclarator;
3092
2977
  }(TreeNode);
3093
2978
  ASTNode.FunctionDeclarator = FunctionDeclarator;
@@ -3102,24 +2987,13 @@ var TreeNode = /*#__PURE__*/ function() {
3102
2987
  var _proto = FunctionHeader.prototype;
3103
2988
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3104
2989
  sa.newScope();
2990
+ var children = this.children;
2991
+ this.ident = children[1];
2992
+ this.returnType = children[0];
3105
2993
  };
3106
2994
  _proto.codeGen = function codeGen(visitor) {
3107
2995
  return visitor.visitFunctionHeader(this);
3108
2996
  };
3109
- _create_class(FunctionHeader, [
3110
- {
3111
- key: "ident",
3112
- get: function get() {
3113
- return this.children[1];
3114
- }
3115
- },
3116
- {
3117
- key: "returnType",
3118
- get: function get() {
3119
- return this.children[0];
3120
- }
3121
- }
3122
- ]);
3123
2997
  return FunctionHeader;
3124
2998
  }(TreeNode);
3125
2999
  ASTNode.FunctionHeader = FunctionHeader;
@@ -3129,55 +3003,48 @@ var TreeNode = /*#__PURE__*/ function() {
3129
3003
  var FunctionParameterList = /*#__PURE__*/ function(TreeNode) {
3130
3004
  _inherits(FunctionParameterList, TreeNode);
3131
3005
  function FunctionParameterList() {
3132
- return TreeNode.apply(this, arguments) || this;
3006
+ var _this;
3007
+ _this = TreeNode.apply(this, arguments) || this, _this.parameterInfoList = [], _this.paramSig = [];
3008
+ return _this;
3133
3009
  }
3134
3010
  var _proto = FunctionParameterList.prototype;
3135
- _proto.codeGen = function codeGen(visitor) {
3136
- return visitor.visitFunctionParameterList(this);
3011
+ _proto.init = function init() {
3012
+ this.parameterInfoList.length = 0;
3013
+ this.paramSig.length = 0;
3137
3014
  };
3138
- _create_class(FunctionParameterList, [
3139
- {
3140
- key: "parameterInfoList",
3141
- get: function get() {
3142
- if (this.children.length === 1) {
3143
- var decl = this.children[0];
3144
- return [
3145
- {
3146
- ident: decl.ident,
3147
- typeInfo: decl.typeInfo,
3148
- astNode: decl
3149
- }
3150
- ];
3151
- }
3152
- var list = this.children[0];
3153
- var decl1 = this.children[2];
3154
- return [].concat(list.parameterInfoList, [
3155
- {
3156
- ident: decl1.ident,
3157
- typeInfo: decl1.typeInfo,
3158
- astNode: decl1
3159
- }
3160
- ]);
3161
- }
3162
- },
3163
- {
3164
- key: "paramSig",
3165
- get: function get() {
3166
- if (this.children.length === 1) {
3167
- var decl = this.children[0];
3168
- return [
3169
- decl.typeInfo.type
3170
- ];
3171
- } else {
3172
- var list = this.children[0];
3173
- var decl1 = this.children[2];
3174
- return list.paramSig.concat([
3175
- decl1.typeInfo.type
3176
- ]);
3177
- }
3015
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3016
+ var children = this.children;
3017
+ var childrenLength = children.length;
3018
+ var _this = this, parameterInfoList = _this.parameterInfoList, paramSig = _this.paramSig;
3019
+ if (childrenLength === 1) {
3020
+ var decl = children[0];
3021
+ parameterInfoList.push({
3022
+ ident: decl.ident,
3023
+ typeInfo: decl.typeInfo,
3024
+ astNode: decl
3025
+ });
3026
+ paramSig.push(decl.typeInfo.type);
3027
+ } else {
3028
+ var list = children[0];
3029
+ var decl1 = children[2];
3030
+ var listParamLength = list.parameterInfoList.length;
3031
+ parameterInfoList.length = listParamLength + 1;
3032
+ paramSig.length = listParamLength + 1;
3033
+ for(var i = 0; i < listParamLength; i++){
3034
+ parameterInfoList[i] = list.parameterInfoList[i];
3035
+ paramSig[i] = list.paramSig[i];
3178
3036
  }
3037
+ parameterInfoList[listParamLength] = {
3038
+ ident: decl1.ident,
3039
+ typeInfo: decl1.typeInfo,
3040
+ astNode: decl1
3041
+ };
3042
+ paramSig[listParamLength] = decl1.typeInfo.type;
3179
3043
  }
3180
- ]);
3044
+ };
3045
+ _proto.codeGen = function codeGen(visitor) {
3046
+ return visitor.visitFunctionParameterList(this);
3047
+ };
3181
3048
  return FunctionParameterList;
3182
3049
  }(TreeNode);
3183
3050
  ASTNode.FunctionParameterList = FunctionParameterList;
@@ -3190,43 +3057,26 @@ var TreeNode = /*#__PURE__*/ function() {
3190
3057
  return TreeNode.apply(this, arguments) || this;
3191
3058
  }
3192
3059
  var _proto = ParameterDeclaration.prototype;
3060
+ _proto.init = function init() {
3061
+ this.typeQualifier = undefined;
3062
+ };
3193
3063
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3194
- var declarator;
3195
- if (this.children.length === 1) {
3196
- declarator = this.children[0];
3064
+ var children = this.children;
3065
+ var childrenLength = children.length;
3066
+ var parameterDeclarator;
3067
+ if (childrenLength === 1) {
3068
+ parameterDeclarator = children[0];
3197
3069
  } else {
3198
- declarator = this.children[1];
3070
+ parameterDeclarator = children[1];
3199
3071
  }
3200
- var varSymbol = new VarSymbol(declarator.ident.lexeme, declarator.typeInfo, false, this);
3072
+ if (childrenLength === 2) {
3073
+ this.typeQualifier = children[0];
3074
+ }
3075
+ this.typeInfo = parameterDeclarator.typeInfo;
3076
+ this.ident = parameterDeclarator.ident;
3077
+ var varSymbol = new VarSymbol(parameterDeclarator.ident.lexeme, parameterDeclarator.typeInfo, false, this);
3201
3078
  sa.symbolTableStack.insert(varSymbol);
3202
3079
  };
3203
- _create_class(ParameterDeclaration, [
3204
- {
3205
- key: "typeQualifier",
3206
- get: function get() {
3207
- if (this.children.length === 2) return this.children[0];
3208
- }
3209
- },
3210
- {
3211
- key: "parameterDeclarator",
3212
- get: function get() {
3213
- if (this.children.length === 1) return this.children[0];
3214
- return this.children[1];
3215
- }
3216
- },
3217
- {
3218
- key: "typeInfo",
3219
- get: function get() {
3220
- return this.parameterDeclarator.typeInfo;
3221
- }
3222
- },
3223
- {
3224
- key: "ident",
3225
- get: function get() {
3226
- return this.parameterDeclarator.ident;
3227
- }
3228
- }
3229
- ]);
3230
3080
  return ParameterDeclaration;
3231
3081
  }(TreeNode);
3232
3082
  ASTNode.ParameterDeclaration = ParameterDeclaration;
@@ -3238,22 +3088,14 @@ var TreeNode = /*#__PURE__*/ function() {
3238
3088
  function ParameterDeclarator() {
3239
3089
  return TreeNode.apply(this, arguments) || this;
3240
3090
  }
3241
- _create_class(ParameterDeclarator, [
3242
- {
3243
- key: "ident",
3244
- get: function get() {
3245
- return this.children[1];
3246
- }
3247
- },
3248
- {
3249
- key: "typeInfo",
3250
- get: function get() {
3251
- var typeSpecifier = this.children[0];
3252
- var arraySpecifier = this.children[2];
3253
- return new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
3254
- }
3255
- }
3256
- ]);
3091
+ var _proto = ParameterDeclarator.prototype;
3092
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3093
+ var children = this.children;
3094
+ this.ident = children[1];
3095
+ var typeSpecifier = children[0];
3096
+ var arraySpecifier = children[2];
3097
+ this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
3098
+ };
3257
3099
  return ParameterDeclarator;
3258
3100
  }(TreeNode);
3259
3101
  ASTNode.ParameterDeclarator = ParameterDeclarator;
@@ -3326,9 +3168,12 @@ var TreeNode = /*#__PURE__*/ function() {
3326
3168
  }
3327
3169
  var _proto = FunctionDefinition.prototype;
3328
3170
  _proto.init = function init() {
3329
- this._returnStatement = undefined;
3171
+ this.returnStatement = undefined;
3330
3172
  };
3331
3173
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3174
+ var children = this.children;
3175
+ this.protoType = children[0];
3176
+ this.statements = children[1];
3332
3177
  sa.dropScope();
3333
3178
  var sm = new FnSymbol(this.protoType.ident.lexeme, this);
3334
3179
  sa.symbolTableStack.insert(sm);
@@ -3342,7 +3187,7 @@ var TreeNode = /*#__PURE__*/ function() {
3342
3187
  if (!returnStatement) {
3343
3188
  sa.reportError(header.returnType.location, "No return statement found.");
3344
3189
  } else {
3345
- this._returnStatement = returnStatement;
3190
+ this.returnStatement = returnStatement;
3346
3191
  }
3347
3192
  }
3348
3193
  curFunctionInfo.header = undefined;
@@ -3351,26 +3196,6 @@ var TreeNode = /*#__PURE__*/ function() {
3351
3196
  _proto.codeGen = function codeGen(visitor) {
3352
3197
  return visitor.visitFunctionDefinition(this);
3353
3198
  };
3354
- _create_class(FunctionDefinition, [
3355
- {
3356
- key: "returnStatement",
3357
- get: function get() {
3358
- return this._returnStatement;
3359
- }
3360
- },
3361
- {
3362
- key: "protoType",
3363
- get: function get() {
3364
- return this.children[0];
3365
- }
3366
- },
3367
- {
3368
- key: "statements",
3369
- get: function get() {
3370
- return this.children[1];
3371
- }
3372
- }
3373
- ]);
3374
3199
  return FunctionDefinition;
3375
3200
  }(TreeNode);
3376
3201
  ASTNode.FunctionDefinition = FunctionDefinition;
@@ -3442,52 +3267,43 @@ var TreeNode = /*#__PURE__*/ function() {
3442
3267
  var FunctionCallParameterList = /*#__PURE__*/ function(TreeNode) {
3443
3268
  _inherits(FunctionCallParameterList, TreeNode);
3444
3269
  function FunctionCallParameterList() {
3445
- return TreeNode.apply(this, arguments) || this;
3270
+ var _this;
3271
+ _this = TreeNode.apply(this, arguments) || this, _this.paramSig = [], _this.paramNodes = [];
3272
+ return _this;
3446
3273
  }
3447
- _create_class(FunctionCallParameterList, [
3448
- {
3449
- key: "paramSig",
3450
- get: function get() {
3451
- if (this.children.length === 1) {
3452
- var expr = this.children[0];
3453
- if (expr.type == undefined) return [
3454
- TypeAny
3455
- ];
3456
- return [
3457
- expr.type
3458
- ];
3459
- } else {
3460
- var list = this.children[0];
3461
- var decl = this.children[2];
3462
- if (list.paramSig == undefined || decl.type == undefined) {
3463
- return [
3464
- TypeAny
3465
- ];
3466
- } else {
3467
- return list.paramSig.concat([
3468
- decl.type
3469
- ]);
3470
- }
3471
- }
3274
+ var _proto = FunctionCallParameterList.prototype;
3275
+ _proto.init = function init() {
3276
+ this.paramSig.length = 0;
3277
+ this.paramNodes.length = 0;
3278
+ };
3279
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3280
+ var _this = this, children = _this.children, paramSig = _this.paramSig, paramNodes = _this.paramNodes;
3281
+ if (children.length === 1) {
3282
+ var expr = children[0];
3283
+ if (expr.type == undefined) {
3284
+ paramSig.push(TypeAny);
3285
+ } else {
3286
+ paramSig.push(expr.type);
3472
3287
  }
3473
- },
3474
- {
3475
- key: "paramNodes",
3476
- get: function get() {
3477
- if (this.children.length === 1) {
3478
- return [
3479
- this.children[0]
3480
- ];
3481
- } else {
3482
- var list = this.children[0];
3483
- var decl = this.children[2];
3484
- return list.paramNodes.concat([
3485
- decl
3486
- ]);
3288
+ this.paramNodes.push(expr);
3289
+ } else {
3290
+ var list = children[0];
3291
+ var decl = children[2];
3292
+ if (list.paramSig.length === 0 || decl.type == undefined) {
3293
+ this.paramSig.push(TypeAny);
3294
+ } else {
3295
+ var listParamLength = list.paramSig.length;
3296
+ paramSig.length = listParamLength + 1;
3297
+ paramNodes.length = listParamLength + 1;
3298
+ for(var i = 0; i < listParamLength; i++){
3299
+ paramSig[i] = list.paramSig[i];
3300
+ paramNodes[i] = list.paramNodes[i];
3487
3301
  }
3302
+ paramSig[listParamLength] = decl.type;
3303
+ paramNodes[listParamLength] = decl;
3488
3304
  }
3489
3305
  }
3490
- ]);
3306
+ };
3491
3307
  return FunctionCallParameterList;
3492
3308
  }(TreeNode);
3493
3309
  ASTNode.FunctionCallParameterList = FunctionCallParameterList;
@@ -3515,32 +3331,15 @@ var TreeNode = /*#__PURE__*/ function() {
3515
3331
  return TreeNode.apply(this, arguments) || this;
3516
3332
  }
3517
3333
  var _proto = FunctionIdentifier.prototype;
3518
- _proto.semanticAnalyze = function semanticAnalyze(sa) {};
3334
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3335
+ var typeSpecifier = this.children[0];
3336
+ this.ident = typeSpecifier.type;
3337
+ this.lexeme = typeSpecifier.lexeme;
3338
+ this.isBuiltin = typeof this.ident !== "string";
3339
+ };
3519
3340
  _proto.codeGen = function codeGen(visitor) {
3520
3341
  return visitor.visitFunctionIdentifier(this);
3521
3342
  };
3522
- _create_class(FunctionIdentifier, [
3523
- {
3524
- key: "ident",
3525
- get: function get() {
3526
- var ty = this.children[0];
3527
- return ty.type;
3528
- }
3529
- },
3530
- {
3531
- key: "lexeme",
3532
- get: function get() {
3533
- var ty = this.children[0];
3534
- return ty.lexeme;
3535
- }
3536
- },
3537
- {
3538
- key: "isBuiltin",
3539
- get: function get() {
3540
- return typeof this.ident !== "string";
3541
- }
3542
- }
3543
- ]);
3544
3343
  return FunctionIdentifier;
3545
3344
  }(TreeNode);
3546
3345
  ASTNode.FunctionIdentifier = FunctionIdentifier;
@@ -3928,21 +3727,19 @@ var TreeNode = /*#__PURE__*/ function() {
3928
3727
  return TreeNode.apply(this, arguments) || this;
3929
3728
  }
3930
3729
  var _proto = StructSpecifier.prototype;
3730
+ _proto.init = function init() {
3731
+ this.ident = undefined;
3732
+ };
3931
3733
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3932
- if (this.children.length === 6) {
3933
- this.ident = this.children[1];
3734
+ var children = this.children;
3735
+ if (children.length === 6) {
3736
+ this.ident = children[1];
3934
3737
  sa.symbolTableStack.insert(new StructSymbol(this.ident.lexeme, this));
3738
+ this.propList = children[3].propList;
3739
+ } else {
3740
+ this.propList = children[2].propList;
3935
3741
  }
3936
3742
  };
3937
- _create_class(StructSpecifier, [
3938
- {
3939
- key: "propList",
3940
- get: function get() {
3941
- var declList = this.children.length === 6 ? this.children[3] : this.children[2];
3942
- return declList.propList;
3943
- }
3944
- }
3945
- ]);
3946
3743
  return StructSpecifier;
3947
3744
  }(TreeNode);
3948
3745
  ASTNode.StructSpecifier = StructSpecifier;
@@ -3952,24 +3749,37 @@ var TreeNode = /*#__PURE__*/ function() {
3952
3749
  var StructDeclarationList = /*#__PURE__*/ function(TreeNode) {
3953
3750
  _inherits(StructDeclarationList, TreeNode);
3954
3751
  function StructDeclarationList() {
3955
- return TreeNode.apply(this, arguments) || this;
3752
+ var _this;
3753
+ _this = TreeNode.apply(this, arguments) || this, _this.propList = [];
3754
+ return _this;
3956
3755
  }
3957
- _create_class(StructDeclarationList, [
3958
- {
3959
- key: "propList",
3960
- get: function get() {
3961
- if (this.children.length === 1) {
3962
- return this.children[0].propList;
3963
- }
3964
- var list = this.children[0];
3965
- var decl = this.children[1];
3966
- return [
3967
- list.propList,
3968
- decl.propList
3969
- ].flat();
3756
+ var _proto = StructDeclarationList.prototype;
3757
+ _proto.init = function init() {
3758
+ this.propList.length = 0;
3759
+ };
3760
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3761
+ var _this = this, children = _this.children, propList = _this.propList;
3762
+ if (children.length === 1) {
3763
+ var props = children[0].props;
3764
+ var propsLength = props.length;
3765
+ propList.length = propsLength;
3766
+ for(var i = 0; i < propsLength; i++){
3767
+ propList[i] = props[i];
3768
+ }
3769
+ } else {
3770
+ var listProps = children[0].propList;
3771
+ var declProps = children[1].props;
3772
+ var listPropLength = listProps.length;
3773
+ var declPropLength = declProps.length;
3774
+ propList.length = listPropLength + declPropLength;
3775
+ for(var i1 = 0; i1 < listPropLength; i1++){
3776
+ propList[i1] = listProps[i1];
3777
+ }
3778
+ for(var i2 = 0; i2 < declPropLength; i2++){
3779
+ propList[i2 + listPropLength] = declProps[i2];
3970
3780
  }
3971
3781
  }
3972
- ]);
3782
+ };
3973
3783
  return StructDeclarationList;
3974
3784
  }(TreeNode);
3975
3785
  ASTNode.StructDeclarationList = StructDeclarationList;
@@ -3979,50 +3789,44 @@ var TreeNode = /*#__PURE__*/ function() {
3979
3789
  var StructDeclaration = /*#__PURE__*/ function(TreeNode) {
3980
3790
  _inherits(StructDeclaration, TreeNode);
3981
3791
  function StructDeclaration() {
3982
- return TreeNode.apply(this, arguments) || this;
3792
+ var _this;
3793
+ _this = TreeNode.apply(this, arguments) || this, _this.props = [];
3794
+ return _this;
3983
3795
  }
3984
- _create_class(StructDeclaration, [
3985
- {
3986
- key: "typeSpecifier",
3987
- get: function get() {
3988
- if (this.children.length === 3) {
3989
- return this.children[0];
3990
- }
3991
- return this.children[1];
3992
- }
3993
- },
3994
- {
3995
- key: "declaratorList",
3996
- get: function get() {
3997
- if (this.children.length === 3) {
3998
- return this.children[1];
3999
- }
4000
- return this.children[2];
4001
- }
4002
- },
4003
- {
4004
- key: "propList",
4005
- get: function get() {
4006
- var ret = [];
4007
- var firstChild = this.children[0];
4008
- if (_instanceof(firstChild, LayoutQualifier)) {
4009
- var typeSpecifier = this.children[1];
4010
- var declarator = this.children[2];
4011
- var typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme);
4012
- var prop = new StructProp(typeInfo, declarator.ident, firstChild.index);
4013
- ret.push(prop);
4014
- } else {
4015
- for(var i = 0; i < this.declaratorList.declaratorList.length; i++){
4016
- var declarator1 = this.declaratorList.declaratorList[i];
4017
- var typeInfo1 = new SymbolType(this.typeSpecifier.type, this.typeSpecifier.lexeme, declarator1.arraySpecifier);
4018
- var prop1 = new StructProp(typeInfo1, declarator1.ident);
4019
- ret.push(prop1);
4020
- }
4021
- }
4022
- return ret;
3796
+ var _proto = StructDeclaration.prototype;
3797
+ _proto.init = function init() {
3798
+ this.typeSpecifier = undefined;
3799
+ this.declaratorList = undefined;
3800
+ this.props.length = 0;
3801
+ };
3802
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3803
+ var _this = this, children = _this.children, props = _this.props;
3804
+ if (children.length === 3) {
3805
+ this.typeSpecifier = children[0];
3806
+ this.declaratorList = children[1];
3807
+ } else {
3808
+ this.typeSpecifier = children[1];
3809
+ this.declaratorList = children[2];
3810
+ }
3811
+ var firstChild = children[0];
3812
+ var _this_typeSpecifier = this.typeSpecifier, type = _this_typeSpecifier.type, lexeme = _this_typeSpecifier.lexeme;
3813
+ if (_instanceof(firstChild, LayoutQualifier)) {
3814
+ var declarator = children[2];
3815
+ var typeInfo = new SymbolType(type, lexeme);
3816
+ var prop = new StructProp(typeInfo, declarator.ident, firstChild.index);
3817
+ props.push(prop);
3818
+ } else {
3819
+ var declaratorList = this.declaratorList.declaratorList;
3820
+ var declaratorListLength = declaratorList.length;
3821
+ props.length = declaratorListLength;
3822
+ for(var i = 0; i < declaratorListLength; i++){
3823
+ var declarator1 = declaratorList[i];
3824
+ var typeInfo1 = new SymbolType(type, lexeme, declarator1.arraySpecifier);
3825
+ var prop1 = new StructProp(typeInfo1, declarator1.ident);
3826
+ props[i] = prop1;
4023
3827
  }
4024
3828
  }
4025
- ]);
3829
+ };
4026
3830
  return StructDeclaration;
4027
3831
  }(TreeNode);
4028
3832
  ASTNode.StructDeclaration = StructDeclaration;
@@ -4034,14 +3838,10 @@ var TreeNode = /*#__PURE__*/ function() {
4034
3838
  function LayoutQualifier() {
4035
3839
  return TreeNode.apply(this, arguments) || this;
4036
3840
  }
4037
- _create_class(LayoutQualifier, [
4038
- {
4039
- key: "index",
4040
- get: function get() {
4041
- return Number(this.children[4].lexeme);
4042
- }
4043
- }
4044
- ]);
3841
+ var _proto = LayoutQualifier.prototype;
3842
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3843
+ this.index = Number(this.children[4].lexeme);
3844
+ };
4045
3845
  return LayoutQualifier;
4046
3846
  }(TreeNode);
4047
3847
  ASTNode.LayoutQualifier = LayoutQualifier;
@@ -4051,25 +3851,29 @@ var TreeNode = /*#__PURE__*/ function() {
4051
3851
  var StructDeclaratorList = /*#__PURE__*/ function(TreeNode) {
4052
3852
  _inherits(StructDeclaratorList, TreeNode);
4053
3853
  function StructDeclaratorList() {
4054
- return TreeNode.apply(this, arguments) || this;
3854
+ var _this;
3855
+ _this = TreeNode.apply(this, arguments) || this, _this.declaratorList = [];
3856
+ return _this;
4055
3857
  }
4056
- _create_class(StructDeclaratorList, [
4057
- {
4058
- key: "declaratorList",
4059
- get: function get() {
4060
- if (this.children.length === 1) {
4061
- return [
4062
- this.children[0]
4063
- ];
4064
- } else {
4065
- var list = this.children[0];
4066
- return [].concat(list.declaratorList, [
4067
- this.children[1]
4068
- ]);
4069
- }
3858
+ var _proto = StructDeclaratorList.prototype;
3859
+ _proto.init = function init() {
3860
+ this.declaratorList.length = 0;
3861
+ };
3862
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3863
+ var _this = this, children = _this.children, declaratorList = _this.declaratorList;
3864
+ if (children.length === 1) {
3865
+ declaratorList.push(children[0]);
3866
+ } else {
3867
+ var list = children[0];
3868
+ var declarator = children[1];
3869
+ var listLength = list.declaratorList.length;
3870
+ declaratorList.length = listLength + 1;
3871
+ for(var i = 0; i < listLength; i++){
3872
+ declaratorList[i] = list.declaratorList[i];
4070
3873
  }
3874
+ declaratorList[listLength] = declarator;
4071
3875
  }
4072
- ]);
3876
+ };
4073
3877
  return StructDeclaratorList;
4074
3878
  }(TreeNode);
4075
3879
  ASTNode.StructDeclaratorList = StructDeclaratorList;
@@ -4081,20 +3885,15 @@ var TreeNode = /*#__PURE__*/ function() {
4081
3885
  function StructDeclarator() {
4082
3886
  return TreeNode.apply(this, arguments) || this;
4083
3887
  }
4084
- _create_class(StructDeclarator, [
4085
- {
4086
- key: "ident",
4087
- get: function get() {
4088
- return this.children[0];
4089
- }
4090
- },
4091
- {
4092
- key: "arraySpecifier",
4093
- get: function get() {
4094
- return this.children[1];
4095
- }
4096
- }
4097
- ]);
3888
+ var _proto = StructDeclarator.prototype;
3889
+ _proto.init = function init() {
3890
+ this.arraySpecifier = undefined;
3891
+ };
3892
+ _proto.semanticAnalyze = function semanticAnalyze(sa) {
3893
+ var children = this.children;
3894
+ this.ident = children[0];
3895
+ this.arraySpecifier = children[1];
3896
+ };
4098
3897
  return StructDeclarator;
4099
3898
  }(TreeNode);
4100
3899
  ASTNode.StructDeclarator = StructDeclarator;
@@ -4170,36 +3969,24 @@ var TreeNode = /*#__PURE__*/ function() {
4170
3969
  }
4171
3970
  var _proto = VariableIdentifier.prototype;
4172
3971
  _proto.semanticAnalyze = function semanticAnalyze(sa) {
3972
+ var _this_symbolInfo_dataType, _this_symbolInfo;
4173
3973
  var token = this.children[0];
3974
+ this.lexeme = token.lexeme;
4174
3975
  var builtinVar = BuiltinVariable.getVar(token.lexeme);
4175
3976
  if (builtinVar) {
4176
3977
  this.symbolInfo = builtinVar;
3978
+ this.typeInfo = builtinVar.type;
4177
3979
  return;
4178
3980
  }
4179
3981
  this.symbolInfo = sa.lookupSymbolBy(token.lexeme, ESymbolType.VAR);
4180
3982
  if (!this.symbolInfo) {
4181
3983
  sa.reportError(this.location, "undeclared identifier: " + token.lexeme);
4182
3984
  }
3985
+ this.typeInfo = (_this_symbolInfo = this.symbolInfo) == null ? void 0 : (_this_symbolInfo_dataType = _this_symbolInfo.dataType) == null ? void 0 : _this_symbolInfo_dataType.type;
4183
3986
  };
4184
3987
  _proto.codeGen = function codeGen(visitor) {
4185
3988
  return visitor.visitVariableIdentifier(this);
4186
3989
  };
4187
- _create_class(VariableIdentifier, [
4188
- {
4189
- key: "lexeme",
4190
- get: function get() {
4191
- return this.children[0].lexeme;
4192
- }
4193
- },
4194
- {
4195
- key: "typeInfo",
4196
- get: function get() {
4197
- var _this_symbolInfo;
4198
- if (_instanceof(this.symbolInfo, VarSymbol)) return this.symbolInfo.dataType.type;
4199
- return (_this_symbolInfo = this.symbolInfo) == null ? void 0 : _this_symbolInfo.type;
4200
- }
4201
- }
4202
- ]);
4203
3990
  return VariableIdentifier;
4204
3991
  }(TreeNode);
4205
3992
  ASTNode.VariableIdentifier = VariableIdentifier;
@@ -5526,7 +5313,7 @@ var addTranslationRule = function(sa) {
5526
5313
  this.actionTable = actionTable;
5527
5314
  this.gotoTable = gotoTable;
5528
5315
  this.grammar = grammar;
5529
- this.sematicAnalyzer = new SematicAnalyzer();
5316
+ this.sematicAnalyzer = new SemanticAnalyzer();
5530
5317
  }
5531
5318
  var _proto = ShaderTargetParser.prototype;
5532
5319
  _proto.parse = function parse(tokens) {
@@ -5954,7 +5741,7 @@ var PpScanner = /*#__PURE__*/ function(BaseScanner) {
5954
5741
  var start = this._currentIndex;
5955
5742
  var found = false;
5956
5743
  for(var n = source.length; this._currentIndex < n;){
5957
- if (LexerUtils.isPpCharactors(source.charCodeAt(this._currentIndex))) {
5744
+ if (LexerUtils.isPpCharacters(source.charCodeAt(this._currentIndex))) {
5958
5745
  this._advance();
5959
5746
  found = true;
5960
5747
  } else {
@@ -8063,7 +7850,7 @@ ShaderLab._shaderPositionPool = ShaderLabUtils.createObjectPool(ShaderPosition);
8063
7850
  ShaderLab._shaderRangePool = ShaderLabUtils.createObjectPool(ShaderRange);
8064
7851
 
8065
7852
  //@ts-ignore
8066
- var version = "1.4.9";
7853
+ var version = "1.4.11";
8067
7854
  var mode = "Release";
8068
7855
  mode = "Verbose";
8069
7856
  console.log("Galacean Engine ShaderLab Version: " + version + " | Mode: " + mode);