@galacean/engine-shaderlab 1.4.9 → 1.4.10

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