@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.
- package/dist/browser.js +297 -503
- package/dist/browser.js.map +1 -1
- package/dist/browser.min.js +1 -1
- package/dist/browser.min.js.map +1 -1
- package/dist/browser.verbose.js +306 -519
- package/dist/browser.verbose.js.map +1 -1
- package/dist/browser.verbose.min.js +1 -1
- package/dist/browser.verbose.min.js.map +1 -1
- package/dist/main.js +297 -503
- package/dist/main.js.map +1 -1
- package/dist/main.verbose.js +306 -519
- package/dist/main.verbose.js.map +1 -1
- package/dist/module.js +297 -503
- package/dist/module.js.map +1 -1
- package/dist/module.verbose.js +306 -519
- package/dist/module.verbose.js.map +1 -1
- package/package.json +4 -4
- package/types/lalr/CFG.d.ts +2 -2
- package/types/lexer/Utils.d.ts +1 -1
- package/types/parser/AST.d.ts +111 -95
- package/types/parser/SemanticAnalyzer.d.ts +1 -1
package/dist/module.js
CHANGED
|
@@ -626,7 +626,7 @@ var LexerUtils = /*#__PURE__*/ function() {
|
|
|
626
626
|
charCode >= 97 && charCode <= 122 // a - z
|
|
627
627
|
;
|
|
628
628
|
};
|
|
629
|
-
LexerUtils.
|
|
629
|
+
LexerUtils.isPpCharacters = function isPpCharacters(charCode) {
|
|
630
630
|
return charCode === 35 || // #
|
|
631
631
|
charCode === 46 || // .
|
|
632
632
|
charCode === 95 || // _
|
|
@@ -1359,8 +1359,8 @@ var VarSymbol = /*#__PURE__*/ function(SymbolInfo) {
|
|
|
1359
1359
|
return VarSymbol;
|
|
1360
1360
|
}(SymbolInfo);
|
|
1361
1361
|
|
|
1362
|
-
var
|
|
1363
|
-
function
|
|
1362
|
+
var SemanticAnalyzer = /*#__PURE__*/ function() {
|
|
1363
|
+
function SemanticAnalyzer() {
|
|
1364
1364
|
this.semanticStack = [];
|
|
1365
1365
|
this.acceptRule = undefined;
|
|
1366
1366
|
this.symbolTableStack = new SymbolTableStack();
|
|
@@ -1369,7 +1369,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
|
|
|
1369
1369
|
this._translationRuleTable = new Map();
|
|
1370
1370
|
this.newScope();
|
|
1371
1371
|
}
|
|
1372
|
-
var _proto =
|
|
1372
|
+
var _proto = SemanticAnalyzer.prototype;
|
|
1373
1373
|
_proto.reset = function reset() {
|
|
1374
1374
|
this.semanticStack.length = 0;
|
|
1375
1375
|
this._shaderData = new ShaderData();
|
|
@@ -1400,7 +1400,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
|
|
|
1400
1400
|
_proto.reportError = function reportError(loc, message) {
|
|
1401
1401
|
Logger.error(message);
|
|
1402
1402
|
};
|
|
1403
|
-
_create_class(
|
|
1403
|
+
_create_class(SemanticAnalyzer, [
|
|
1404
1404
|
{
|
|
1405
1405
|
key: "shaderData",
|
|
1406
1406
|
get: function get() {
|
|
@@ -1408,7 +1408,7 @@ var SematicAnalyzer = /*#__PURE__*/ function() {
|
|
|
1408
1408
|
}
|
|
1409
1409
|
}
|
|
1410
1410
|
]);
|
|
1411
|
-
return
|
|
1411
|
+
return SemanticAnalyzer;
|
|
1412
1412
|
}();
|
|
1413
1413
|
|
|
1414
1414
|
var NoneTerminal = /*#__PURE__*/ function(NoneTerminal) {
|
|
@@ -1757,28 +1757,12 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1757
1757
|
function FullySpecifiedType() {
|
|
1758
1758
|
return TreeNode.apply(this, arguments) || this;
|
|
1759
1759
|
}
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
},
|
|
1769
|
-
{
|
|
1770
|
-
key: "typeSpecifier",
|
|
1771
|
-
get: function get() {
|
|
1772
|
-
return this.children.length === 1 ? this.children[0] : this.children[1];
|
|
1773
|
-
}
|
|
1774
|
-
},
|
|
1775
|
-
{
|
|
1776
|
-
key: "type",
|
|
1777
|
-
get: function get() {
|
|
1778
|
-
return this.typeSpecifier.type;
|
|
1779
|
-
}
|
|
1780
|
-
}
|
|
1781
|
-
]);
|
|
1760
|
+
var _proto = FullySpecifiedType.prototype;
|
|
1761
|
+
_proto.semanticAnalyze = function semanticAnalyze(_) {
|
|
1762
|
+
var children = this.children;
|
|
1763
|
+
this.typeSpecifier = children.length === 1 ? children[0] : children[1];
|
|
1764
|
+
this.type = this.typeSpecifier.type;
|
|
1765
|
+
};
|
|
1782
1766
|
return FullySpecifiedType;
|
|
1783
1767
|
}(TreeNode);
|
|
1784
1768
|
ASTNode.FullySpecifiedType = FullySpecifiedType;
|
|
@@ -1790,18 +1774,6 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1790
1774
|
function TypeQualifier() {
|
|
1791
1775
|
return TreeNode.apply(this, arguments) || this;
|
|
1792
1776
|
}
|
|
1793
|
-
var _proto = TypeQualifier.prototype;
|
|
1794
|
-
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1795
|
-
if (this.children.length > 1) {
|
|
1796
|
-
this.qualifierList = [].concat(this.children[0].qualifierList, [
|
|
1797
|
-
this.children[1].qualifier
|
|
1798
|
-
]);
|
|
1799
|
-
} else {
|
|
1800
|
-
this.qualifierList = [
|
|
1801
|
-
this.children[0].qualifier
|
|
1802
|
-
];
|
|
1803
|
-
}
|
|
1804
|
-
};
|
|
1805
1777
|
return TypeQualifier;
|
|
1806
1778
|
}(TreeNode);
|
|
1807
1779
|
ASTNode.TypeQualifier = TypeQualifier;
|
|
@@ -1835,37 +1807,25 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1835
1807
|
function TypeSpecifier() {
|
|
1836
1808
|
return TreeNode.apply(this, arguments) || this;
|
|
1837
1809
|
}
|
|
1810
|
+
var _proto = TypeSpecifier.prototype;
|
|
1811
|
+
_proto.init = function init() {
|
|
1812
|
+
this.arraySize = undefined;
|
|
1813
|
+
};
|
|
1814
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1815
|
+
var _children_;
|
|
1816
|
+
var children = this.children;
|
|
1817
|
+
var firstChild = children[0];
|
|
1818
|
+
this.type = firstChild.type;
|
|
1819
|
+
this.lexeme = firstChild.lexeme;
|
|
1820
|
+
this.arraySize = children == null ? void 0 : (_children_ = children[1]) == null ? void 0 : _children_.size;
|
|
1821
|
+
this.isCustom = typeof this.type === "string";
|
|
1822
|
+
};
|
|
1838
1823
|
_create_class(TypeSpecifier, [
|
|
1839
|
-
{
|
|
1840
|
-
key: "type",
|
|
1841
|
-
get: function get() {
|
|
1842
|
-
return this.children[0].type;
|
|
1843
|
-
}
|
|
1844
|
-
},
|
|
1845
|
-
{
|
|
1846
|
-
key: "lexeme",
|
|
1847
|
-
get: function get() {
|
|
1848
|
-
return this.children[0].lexeme;
|
|
1849
|
-
}
|
|
1850
|
-
},
|
|
1851
|
-
{
|
|
1852
|
-
key: "arraySize",
|
|
1853
|
-
get: function get() {
|
|
1854
|
-
var _this_children_, _this_children;
|
|
1855
|
-
return (_this_children = this.children) == null ? void 0 : (_this_children_ = _this_children[1]) == null ? void 0 : _this_children_.size;
|
|
1856
|
-
}
|
|
1857
|
-
},
|
|
1858
1824
|
{
|
|
1859
1825
|
key: "arraySpecifier",
|
|
1860
1826
|
get: function get() {
|
|
1861
1827
|
return this.children[1];
|
|
1862
1828
|
}
|
|
1863
|
-
},
|
|
1864
|
-
{
|
|
1865
|
-
key: "isCustom",
|
|
1866
|
-
get: function get() {
|
|
1867
|
-
return typeof this.type === "string";
|
|
1868
|
-
}
|
|
1869
1829
|
}
|
|
1870
1830
|
]);
|
|
1871
1831
|
return TypeSpecifier;
|
|
@@ -1879,15 +1839,11 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1879
1839
|
function ArraySpecifier() {
|
|
1880
1840
|
return TreeNode.apply(this, arguments) || this;
|
|
1881
1841
|
}
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
return integerConstantExpr.value;
|
|
1888
|
-
}
|
|
1889
|
-
}
|
|
1890
|
-
]);
|
|
1842
|
+
var _proto = ArraySpecifier.prototype;
|
|
1843
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1844
|
+
var integerConstantExpr = this.children[1];
|
|
1845
|
+
this.size = integerConstantExpr.value;
|
|
1846
|
+
};
|
|
1891
1847
|
return ArraySpecifier;
|
|
1892
1848
|
}(TreeNode);
|
|
1893
1849
|
ASTNode.ArraySpecifier = ArraySpecifier;
|
|
@@ -1902,6 +1858,7 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1902
1858
|
var _proto = IntegerConstantExpressionOperator.prototype;
|
|
1903
1859
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1904
1860
|
var operator = this.children[0];
|
|
1861
|
+
this.lexeme = operator.lexeme;
|
|
1905
1862
|
switch(operator.type){
|
|
1906
1863
|
case ETokenType.PLUS:
|
|
1907
1864
|
this.compute = function(a, b) {
|
|
@@ -1932,14 +1889,6 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
1932
1889
|
sa.reportError(operator.location, "not implemented operator " + operator.lexeme);
|
|
1933
1890
|
}
|
|
1934
1891
|
};
|
|
1935
|
-
_create_class(IntegerConstantExpressionOperator, [
|
|
1936
|
-
{
|
|
1937
|
-
key: "lexeme",
|
|
1938
|
-
get: function get() {
|
|
1939
|
-
return this.children[0].lexeme;
|
|
1940
|
-
}
|
|
1941
|
-
}
|
|
1942
|
-
]);
|
|
1943
1892
|
return IntegerConstantExpressionOperator;
|
|
1944
1893
|
}(TreeNode);
|
|
1945
1894
|
ASTNode.IntegerConstantExpressionOperator = IntegerConstantExpressionOperator;
|
|
@@ -2016,32 +1965,28 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2016
1965
|
var _proto = InitDeclaratorList.prototype;
|
|
2017
1966
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2018
1967
|
var sm;
|
|
2019
|
-
|
|
2020
|
-
|
|
1968
|
+
var children = this.children;
|
|
1969
|
+
var childrenLength = children.length;
|
|
1970
|
+
if (childrenLength === 1) {
|
|
1971
|
+
var _children_ = children[0], typeSpecifier = _children_.typeSpecifier, arraySpecifier = _children_.arraySpecifier;
|
|
1972
|
+
this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
1973
|
+
} else {
|
|
1974
|
+
var initDeclList = children[0];
|
|
1975
|
+
this.typeInfo = initDeclList.typeInfo;
|
|
1976
|
+
}
|
|
1977
|
+
if (childrenLength === 3 || childrenLength === 5) {
|
|
1978
|
+
var id = children[2];
|
|
2021
1979
|
sm = new VarSymbol(id.lexeme, this.typeInfo, false, this);
|
|
2022
1980
|
sa.symbolTableStack.insert(sm);
|
|
2023
|
-
} else if (
|
|
1981
|
+
} else if (childrenLength === 4 || childrenLength === 6) {
|
|
2024
1982
|
var typeInfo = this.typeInfo;
|
|
2025
|
-
var
|
|
2026
|
-
typeInfo.arraySpecifier =
|
|
2027
|
-
var id1 =
|
|
1983
|
+
var arraySpecifier1 = this.children[3];
|
|
1984
|
+
typeInfo.arraySpecifier = arraySpecifier1;
|
|
1985
|
+
var id1 = children[2];
|
|
2028
1986
|
sm = new VarSymbol(id1.lexeme, typeInfo, false, this);
|
|
2029
1987
|
sa.symbolTableStack.insert(sm);
|
|
2030
1988
|
}
|
|
2031
1989
|
};
|
|
2032
|
-
_create_class(InitDeclaratorList, [
|
|
2033
|
-
{
|
|
2034
|
-
key: "typeInfo",
|
|
2035
|
-
get: function get() {
|
|
2036
|
-
if (this.children.length === 1) {
|
|
2037
|
-
var singleDecl = this.children[0];
|
|
2038
|
-
return new SymbolType(singleDecl.typeSpecifier.type, singleDecl.typeSpecifier.lexeme, singleDecl.arraySpecifier);
|
|
2039
|
-
}
|
|
2040
|
-
var initDeclList = this.children[0];
|
|
2041
|
-
return initDeclList.typeInfo;
|
|
2042
|
-
}
|
|
2043
|
-
}
|
|
2044
|
-
]);
|
|
2045
1990
|
return InitDeclaratorList;
|
|
2046
1991
|
}(TreeNode);
|
|
2047
1992
|
ASTNode.InitDeclaratorList = InitDeclaratorList;
|
|
@@ -2051,23 +1996,29 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2051
1996
|
var IdentifierList = /*#__PURE__*/ function(TreeNode) {
|
|
2052
1997
|
_inherits(IdentifierList, TreeNode);
|
|
2053
1998
|
function IdentifierList() {
|
|
2054
|
-
|
|
1999
|
+
var _this;
|
|
2000
|
+
_this = TreeNode.apply(this, arguments) || this, _this.idList = [];
|
|
2001
|
+
return _this;
|
|
2055
2002
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2003
|
+
var _proto = IdentifierList.prototype;
|
|
2004
|
+
_proto.init = function init() {
|
|
2005
|
+
this.idList.length = 0;
|
|
2006
|
+
};
|
|
2007
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2008
|
+
var _this = this, children = _this.children, curIdList = _this.idList;
|
|
2009
|
+
if (children.length === 2) {
|
|
2010
|
+
curIdList.push(children[1]);
|
|
2011
|
+
} else {
|
|
2012
|
+
var list = children[0];
|
|
2013
|
+
var id = children[2];
|
|
2014
|
+
var listIdLength = list.idList.length;
|
|
2015
|
+
curIdList.length = listIdLength + 1;
|
|
2016
|
+
for(var i = 0; i < listIdLength; i++){
|
|
2017
|
+
curIdList[i] = list.idList[i];
|
|
2068
2018
|
}
|
|
2019
|
+
curIdList[listIdLength] = id;
|
|
2069
2020
|
}
|
|
2070
|
-
|
|
2021
|
+
};
|
|
2071
2022
|
return IdentifierList;
|
|
2072
2023
|
}(TreeNode);
|
|
2073
2024
|
ASTNode.IdentifierList = IdentifierList;
|
|
@@ -2095,41 +2046,16 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2095
2046
|
return TreeNode.apply(this, arguments) || this;
|
|
2096
2047
|
}
|
|
2097
2048
|
var _proto = FunctionProtoType.prototype;
|
|
2049
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2050
|
+
var declarator = this.children[0];
|
|
2051
|
+
this.ident = declarator.ident;
|
|
2052
|
+
this.returnType = declarator.returnType;
|
|
2053
|
+
this.parameterList = declarator.parameterInfoList;
|
|
2054
|
+
this.paramSig = declarator.paramSig;
|
|
2055
|
+
};
|
|
2098
2056
|
_proto.codeGen = function codeGen(visitor) {
|
|
2099
2057
|
return visitor.visitFunctionProtoType(this);
|
|
2100
2058
|
};
|
|
2101
|
-
_create_class(FunctionProtoType, [
|
|
2102
|
-
{
|
|
2103
|
-
key: "declarator",
|
|
2104
|
-
get: function get() {
|
|
2105
|
-
return this.children[0];
|
|
2106
|
-
}
|
|
2107
|
-
},
|
|
2108
|
-
{
|
|
2109
|
-
key: "ident",
|
|
2110
|
-
get: function get() {
|
|
2111
|
-
return this.declarator.ident;
|
|
2112
|
-
}
|
|
2113
|
-
},
|
|
2114
|
-
{
|
|
2115
|
-
key: "returnType",
|
|
2116
|
-
get: function get() {
|
|
2117
|
-
return this.declarator.returnType;
|
|
2118
|
-
}
|
|
2119
|
-
},
|
|
2120
|
-
{
|
|
2121
|
-
key: "parameterList",
|
|
2122
|
-
get: function get() {
|
|
2123
|
-
return this.declarator.parameterInfoList;
|
|
2124
|
-
}
|
|
2125
|
-
},
|
|
2126
|
-
{
|
|
2127
|
-
key: "paramSig",
|
|
2128
|
-
get: function get() {
|
|
2129
|
-
return this.declarator.paramSig;
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
]);
|
|
2133
2059
|
return FunctionProtoType;
|
|
2134
2060
|
}(TreeNode);
|
|
2135
2061
|
ASTNode.FunctionProtoType = FunctionProtoType;
|
|
@@ -2145,47 +2071,14 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2145
2071
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2146
2072
|
sa.curFunctionInfo.returnStatement = null;
|
|
2147
2073
|
sa.curFunctionInfo.header = this;
|
|
2074
|
+
var children = this.children;
|
|
2075
|
+
var header = children[0];
|
|
2076
|
+
var parameterList = children[1];
|
|
2077
|
+
this.ident = header.ident;
|
|
2078
|
+
this.returnType = header.returnType;
|
|
2079
|
+
this.parameterInfoList = parameterList == null ? void 0 : parameterList.parameterInfoList;
|
|
2080
|
+
this.paramSig = parameterList == null ? void 0 : parameterList.paramSig;
|
|
2148
2081
|
};
|
|
2149
|
-
_create_class(FunctionDeclarator, [
|
|
2150
|
-
{
|
|
2151
|
-
key: "header",
|
|
2152
|
-
get: function get() {
|
|
2153
|
-
return this.children[0];
|
|
2154
|
-
}
|
|
2155
|
-
},
|
|
2156
|
-
{
|
|
2157
|
-
key: "parameterList",
|
|
2158
|
-
get: function get() {
|
|
2159
|
-
return this.children[1];
|
|
2160
|
-
}
|
|
2161
|
-
},
|
|
2162
|
-
{
|
|
2163
|
-
key: "ident",
|
|
2164
|
-
get: function get() {
|
|
2165
|
-
return this.header.ident;
|
|
2166
|
-
}
|
|
2167
|
-
},
|
|
2168
|
-
{
|
|
2169
|
-
key: "returnType",
|
|
2170
|
-
get: function get() {
|
|
2171
|
-
return this.header.returnType;
|
|
2172
|
-
}
|
|
2173
|
-
},
|
|
2174
|
-
{
|
|
2175
|
-
key: "parameterInfoList",
|
|
2176
|
-
get: function get() {
|
|
2177
|
-
var _this_parameterList;
|
|
2178
|
-
return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.parameterInfoList;
|
|
2179
|
-
}
|
|
2180
|
-
},
|
|
2181
|
-
{
|
|
2182
|
-
key: "paramSig",
|
|
2183
|
-
get: function get() {
|
|
2184
|
-
var _this_parameterList;
|
|
2185
|
-
return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.paramSig;
|
|
2186
|
-
}
|
|
2187
|
-
}
|
|
2188
|
-
]);
|
|
2189
2082
|
return FunctionDeclarator;
|
|
2190
2083
|
}(TreeNode);
|
|
2191
2084
|
ASTNode.FunctionDeclarator = FunctionDeclarator;
|
|
@@ -2200,24 +2093,13 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2200
2093
|
var _proto = FunctionHeader.prototype;
|
|
2201
2094
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2202
2095
|
sa.newScope();
|
|
2096
|
+
var children = this.children;
|
|
2097
|
+
this.ident = children[1];
|
|
2098
|
+
this.returnType = children[0];
|
|
2203
2099
|
};
|
|
2204
2100
|
_proto.codeGen = function codeGen(visitor) {
|
|
2205
2101
|
return visitor.visitFunctionHeader(this);
|
|
2206
2102
|
};
|
|
2207
|
-
_create_class(FunctionHeader, [
|
|
2208
|
-
{
|
|
2209
|
-
key: "ident",
|
|
2210
|
-
get: function get() {
|
|
2211
|
-
return this.children[1];
|
|
2212
|
-
}
|
|
2213
|
-
},
|
|
2214
|
-
{
|
|
2215
|
-
key: "returnType",
|
|
2216
|
-
get: function get() {
|
|
2217
|
-
return this.children[0];
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
]);
|
|
2221
2103
|
return FunctionHeader;
|
|
2222
2104
|
}(TreeNode);
|
|
2223
2105
|
ASTNode.FunctionHeader = FunctionHeader;
|
|
@@ -2227,55 +2109,48 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2227
2109
|
var FunctionParameterList = /*#__PURE__*/ function(TreeNode) {
|
|
2228
2110
|
_inherits(FunctionParameterList, TreeNode);
|
|
2229
2111
|
function FunctionParameterList() {
|
|
2230
|
-
|
|
2112
|
+
var _this;
|
|
2113
|
+
_this = TreeNode.apply(this, arguments) || this, _this.parameterInfoList = [], _this.paramSig = [];
|
|
2114
|
+
return _this;
|
|
2231
2115
|
}
|
|
2232
2116
|
var _proto = FunctionParameterList.prototype;
|
|
2233
|
-
_proto.
|
|
2234
|
-
|
|
2117
|
+
_proto.init = function init() {
|
|
2118
|
+
this.parameterInfoList.length = 0;
|
|
2119
|
+
this.paramSig.length = 0;
|
|
2235
2120
|
};
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
}
|
|
2258
|
-
]);
|
|
2259
|
-
}
|
|
2260
|
-
},
|
|
2261
|
-
{
|
|
2262
|
-
key: "paramSig",
|
|
2263
|
-
get: function get() {
|
|
2264
|
-
if (this.children.length === 1) {
|
|
2265
|
-
var decl = this.children[0];
|
|
2266
|
-
return [
|
|
2267
|
-
decl.typeInfo.type
|
|
2268
|
-
];
|
|
2269
|
-
} else {
|
|
2270
|
-
var list = this.children[0];
|
|
2271
|
-
var decl1 = this.children[2];
|
|
2272
|
-
return list.paramSig.concat([
|
|
2273
|
-
decl1.typeInfo.type
|
|
2274
|
-
]);
|
|
2275
|
-
}
|
|
2121
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2122
|
+
var children = this.children;
|
|
2123
|
+
var childrenLength = children.length;
|
|
2124
|
+
var _this = this, parameterInfoList = _this.parameterInfoList, paramSig = _this.paramSig;
|
|
2125
|
+
if (childrenLength === 1) {
|
|
2126
|
+
var decl = children[0];
|
|
2127
|
+
parameterInfoList.push({
|
|
2128
|
+
ident: decl.ident,
|
|
2129
|
+
typeInfo: decl.typeInfo,
|
|
2130
|
+
astNode: decl
|
|
2131
|
+
});
|
|
2132
|
+
paramSig.push(decl.typeInfo.type);
|
|
2133
|
+
} else {
|
|
2134
|
+
var list = children[0];
|
|
2135
|
+
var decl1 = children[2];
|
|
2136
|
+
var listParamLength = list.parameterInfoList.length;
|
|
2137
|
+
parameterInfoList.length = listParamLength + 1;
|
|
2138
|
+
paramSig.length = listParamLength + 1;
|
|
2139
|
+
for(var i = 0; i < listParamLength; i++){
|
|
2140
|
+
parameterInfoList[i] = list.parameterInfoList[i];
|
|
2141
|
+
paramSig[i] = list.paramSig[i];
|
|
2276
2142
|
}
|
|
2143
|
+
parameterInfoList[listParamLength] = {
|
|
2144
|
+
ident: decl1.ident,
|
|
2145
|
+
typeInfo: decl1.typeInfo,
|
|
2146
|
+
astNode: decl1
|
|
2147
|
+
};
|
|
2148
|
+
paramSig[listParamLength] = decl1.typeInfo.type;
|
|
2277
2149
|
}
|
|
2278
|
-
|
|
2150
|
+
};
|
|
2151
|
+
_proto.codeGen = function codeGen(visitor) {
|
|
2152
|
+
return visitor.visitFunctionParameterList(this);
|
|
2153
|
+
};
|
|
2279
2154
|
return FunctionParameterList;
|
|
2280
2155
|
}(TreeNode);
|
|
2281
2156
|
ASTNode.FunctionParameterList = FunctionParameterList;
|
|
@@ -2288,43 +2163,26 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2288
2163
|
return TreeNode.apply(this, arguments) || this;
|
|
2289
2164
|
}
|
|
2290
2165
|
var _proto = ParameterDeclaration.prototype;
|
|
2166
|
+
_proto.init = function init() {
|
|
2167
|
+
this.typeQualifier = undefined;
|
|
2168
|
+
};
|
|
2291
2169
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2292
|
-
var
|
|
2293
|
-
|
|
2294
|
-
|
|
2170
|
+
var children = this.children;
|
|
2171
|
+
var childrenLength = children.length;
|
|
2172
|
+
var parameterDeclarator;
|
|
2173
|
+
if (childrenLength === 1) {
|
|
2174
|
+
parameterDeclarator = children[0];
|
|
2295
2175
|
} else {
|
|
2296
|
-
|
|
2176
|
+
parameterDeclarator = children[1];
|
|
2177
|
+
}
|
|
2178
|
+
if (childrenLength === 2) {
|
|
2179
|
+
this.typeQualifier = children[0];
|
|
2297
2180
|
}
|
|
2298
|
-
|
|
2181
|
+
this.typeInfo = parameterDeclarator.typeInfo;
|
|
2182
|
+
this.ident = parameterDeclarator.ident;
|
|
2183
|
+
var varSymbol = new VarSymbol(parameterDeclarator.ident.lexeme, parameterDeclarator.typeInfo, false, this);
|
|
2299
2184
|
sa.symbolTableStack.insert(varSymbol);
|
|
2300
2185
|
};
|
|
2301
|
-
_create_class(ParameterDeclaration, [
|
|
2302
|
-
{
|
|
2303
|
-
key: "typeQualifier",
|
|
2304
|
-
get: function get() {
|
|
2305
|
-
if (this.children.length === 2) return this.children[0];
|
|
2306
|
-
}
|
|
2307
|
-
},
|
|
2308
|
-
{
|
|
2309
|
-
key: "parameterDeclarator",
|
|
2310
|
-
get: function get() {
|
|
2311
|
-
if (this.children.length === 1) return this.children[0];
|
|
2312
|
-
return this.children[1];
|
|
2313
|
-
}
|
|
2314
|
-
},
|
|
2315
|
-
{
|
|
2316
|
-
key: "typeInfo",
|
|
2317
|
-
get: function get() {
|
|
2318
|
-
return this.parameterDeclarator.typeInfo;
|
|
2319
|
-
}
|
|
2320
|
-
},
|
|
2321
|
-
{
|
|
2322
|
-
key: "ident",
|
|
2323
|
-
get: function get() {
|
|
2324
|
-
return this.parameterDeclarator.ident;
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
]);
|
|
2328
2186
|
return ParameterDeclaration;
|
|
2329
2187
|
}(TreeNode);
|
|
2330
2188
|
ASTNode.ParameterDeclaration = ParameterDeclaration;
|
|
@@ -2336,22 +2194,14 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2336
2194
|
function ParameterDeclarator() {
|
|
2337
2195
|
return TreeNode.apply(this, arguments) || this;
|
|
2338
2196
|
}
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
key: "typeInfo",
|
|
2348
|
-
get: function get() {
|
|
2349
|
-
var typeSpecifier = this.children[0];
|
|
2350
|
-
var arraySpecifier = this.children[2];
|
|
2351
|
-
return new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
2352
|
-
}
|
|
2353
|
-
}
|
|
2354
|
-
]);
|
|
2197
|
+
var _proto = ParameterDeclarator.prototype;
|
|
2198
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2199
|
+
var children = this.children;
|
|
2200
|
+
this.ident = children[1];
|
|
2201
|
+
var typeSpecifier = children[0];
|
|
2202
|
+
var arraySpecifier = children[2];
|
|
2203
|
+
this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
2204
|
+
};
|
|
2355
2205
|
return ParameterDeclarator;
|
|
2356
2206
|
}(TreeNode);
|
|
2357
2207
|
ASTNode.ParameterDeclarator = ParameterDeclarator;
|
|
@@ -2391,9 +2241,12 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2391
2241
|
}
|
|
2392
2242
|
var _proto = FunctionDefinition.prototype;
|
|
2393
2243
|
_proto.init = function init() {
|
|
2394
|
-
this.
|
|
2244
|
+
this.returnStatement = undefined;
|
|
2395
2245
|
};
|
|
2396
2246
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2247
|
+
var children = this.children;
|
|
2248
|
+
this.protoType = children[0];
|
|
2249
|
+
this.statements = children[1];
|
|
2397
2250
|
sa.dropScope();
|
|
2398
2251
|
var sm = new FnSymbol(this.protoType.ident.lexeme, this);
|
|
2399
2252
|
sa.symbolTableStack.insert(sm);
|
|
@@ -2407,7 +2260,7 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2407
2260
|
if (!returnStatement) {
|
|
2408
2261
|
sa.reportError(header.returnType.location, "No return statement found.");
|
|
2409
2262
|
} else {
|
|
2410
|
-
this.
|
|
2263
|
+
this.returnStatement = returnStatement;
|
|
2411
2264
|
}
|
|
2412
2265
|
}
|
|
2413
2266
|
curFunctionInfo.header = undefined;
|
|
@@ -2416,26 +2269,6 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2416
2269
|
_proto.codeGen = function codeGen(visitor) {
|
|
2417
2270
|
return visitor.visitFunctionDefinition(this);
|
|
2418
2271
|
};
|
|
2419
|
-
_create_class(FunctionDefinition, [
|
|
2420
|
-
{
|
|
2421
|
-
key: "returnStatement",
|
|
2422
|
-
get: function get() {
|
|
2423
|
-
return this._returnStatement;
|
|
2424
|
-
}
|
|
2425
|
-
},
|
|
2426
|
-
{
|
|
2427
|
-
key: "protoType",
|
|
2428
|
-
get: function get() {
|
|
2429
|
-
return this.children[0];
|
|
2430
|
-
}
|
|
2431
|
-
},
|
|
2432
|
-
{
|
|
2433
|
-
key: "statements",
|
|
2434
|
-
get: function get() {
|
|
2435
|
-
return this.children[1];
|
|
2436
|
-
}
|
|
2437
|
-
}
|
|
2438
|
-
]);
|
|
2439
2272
|
return FunctionDefinition;
|
|
2440
2273
|
}(TreeNode);
|
|
2441
2274
|
ASTNode.FunctionDefinition = FunctionDefinition;
|
|
@@ -2501,52 +2334,43 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2501
2334
|
var FunctionCallParameterList = /*#__PURE__*/ function(TreeNode) {
|
|
2502
2335
|
_inherits(FunctionCallParameterList, TreeNode);
|
|
2503
2336
|
function FunctionCallParameterList() {
|
|
2504
|
-
|
|
2337
|
+
var _this;
|
|
2338
|
+
_this = TreeNode.apply(this, arguments) || this, _this.paramSig = [], _this.paramNodes = [];
|
|
2339
|
+
return _this;
|
|
2505
2340
|
}
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
var list = this.children[0];
|
|
2520
|
-
var decl = this.children[2];
|
|
2521
|
-
if (list.paramSig == undefined || decl.type == undefined) {
|
|
2522
|
-
return [
|
|
2523
|
-
TypeAny
|
|
2524
|
-
];
|
|
2525
|
-
} else {
|
|
2526
|
-
return list.paramSig.concat([
|
|
2527
|
-
decl.type
|
|
2528
|
-
]);
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2341
|
+
var _proto = FunctionCallParameterList.prototype;
|
|
2342
|
+
_proto.init = function init() {
|
|
2343
|
+
this.paramSig.length = 0;
|
|
2344
|
+
this.paramNodes.length = 0;
|
|
2345
|
+
};
|
|
2346
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2347
|
+
var _this = this, children = _this.children, paramSig = _this.paramSig, paramNodes = _this.paramNodes;
|
|
2348
|
+
if (children.length === 1) {
|
|
2349
|
+
var expr = children[0];
|
|
2350
|
+
if (expr.type == undefined) {
|
|
2351
|
+
paramSig.push(TypeAny);
|
|
2352
|
+
} else {
|
|
2353
|
+
paramSig.push(expr.type);
|
|
2531
2354
|
}
|
|
2532
|
-
|
|
2533
|
-
{
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
]);
|
|
2355
|
+
this.paramNodes.push(expr);
|
|
2356
|
+
} else {
|
|
2357
|
+
var list = children[0];
|
|
2358
|
+
var decl = children[2];
|
|
2359
|
+
if (list.paramSig.length === 0 || decl.type == undefined) {
|
|
2360
|
+
this.paramSig.push(TypeAny);
|
|
2361
|
+
} else {
|
|
2362
|
+
var listParamLength = list.paramSig.length;
|
|
2363
|
+
paramSig.length = listParamLength + 1;
|
|
2364
|
+
paramNodes.length = listParamLength + 1;
|
|
2365
|
+
for(var i = 0; i < listParamLength; i++){
|
|
2366
|
+
paramSig[i] = list.paramSig[i];
|
|
2367
|
+
paramNodes[i] = list.paramNodes[i];
|
|
2546
2368
|
}
|
|
2369
|
+
paramSig[listParamLength] = decl.type;
|
|
2370
|
+
paramNodes[listParamLength] = decl;
|
|
2547
2371
|
}
|
|
2548
2372
|
}
|
|
2549
|
-
|
|
2373
|
+
};
|
|
2550
2374
|
return FunctionCallParameterList;
|
|
2551
2375
|
}(TreeNode);
|
|
2552
2376
|
ASTNode.FunctionCallParameterList = FunctionCallParameterList;
|
|
@@ -2574,32 +2398,15 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2574
2398
|
return TreeNode.apply(this, arguments) || this;
|
|
2575
2399
|
}
|
|
2576
2400
|
var _proto = FunctionIdentifier.prototype;
|
|
2577
|
-
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2401
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2402
|
+
var typeSpecifier = this.children[0];
|
|
2403
|
+
this.ident = typeSpecifier.type;
|
|
2404
|
+
this.lexeme = typeSpecifier.lexeme;
|
|
2405
|
+
this.isBuiltin = typeof this.ident !== "string";
|
|
2406
|
+
};
|
|
2578
2407
|
_proto.codeGen = function codeGen(visitor) {
|
|
2579
2408
|
return visitor.visitFunctionIdentifier(this);
|
|
2580
2409
|
};
|
|
2581
|
-
_create_class(FunctionIdentifier, [
|
|
2582
|
-
{
|
|
2583
|
-
key: "ident",
|
|
2584
|
-
get: function get() {
|
|
2585
|
-
var ty = this.children[0];
|
|
2586
|
-
return ty.type;
|
|
2587
|
-
}
|
|
2588
|
-
},
|
|
2589
|
-
{
|
|
2590
|
-
key: "lexeme",
|
|
2591
|
-
get: function get() {
|
|
2592
|
-
var ty = this.children[0];
|
|
2593
|
-
return ty.lexeme;
|
|
2594
|
-
}
|
|
2595
|
-
},
|
|
2596
|
-
{
|
|
2597
|
-
key: "isBuiltin",
|
|
2598
|
-
get: function get() {
|
|
2599
|
-
return typeof this.ident !== "string";
|
|
2600
|
-
}
|
|
2601
|
-
}
|
|
2602
|
-
]);
|
|
2603
2410
|
return FunctionIdentifier;
|
|
2604
2411
|
}(TreeNode);
|
|
2605
2412
|
ASTNode.FunctionIdentifier = FunctionIdentifier;
|
|
@@ -2693,21 +2500,19 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2693
2500
|
return TreeNode.apply(this, arguments) || this;
|
|
2694
2501
|
}
|
|
2695
2502
|
var _proto = StructSpecifier.prototype;
|
|
2503
|
+
_proto.init = function init() {
|
|
2504
|
+
this.ident = undefined;
|
|
2505
|
+
};
|
|
2696
2506
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2697
|
-
|
|
2698
|
-
|
|
2507
|
+
var children = this.children;
|
|
2508
|
+
if (children.length === 6) {
|
|
2509
|
+
this.ident = children[1];
|
|
2699
2510
|
sa.symbolTableStack.insert(new StructSymbol(this.ident.lexeme, this));
|
|
2511
|
+
this.propList = children[3].propList;
|
|
2512
|
+
} else {
|
|
2513
|
+
this.propList = children[2].propList;
|
|
2700
2514
|
}
|
|
2701
2515
|
};
|
|
2702
|
-
_create_class(StructSpecifier, [
|
|
2703
|
-
{
|
|
2704
|
-
key: "propList",
|
|
2705
|
-
get: function get() {
|
|
2706
|
-
var declList = this.children.length === 6 ? this.children[3] : this.children[2];
|
|
2707
|
-
return declList.propList;
|
|
2708
|
-
}
|
|
2709
|
-
}
|
|
2710
|
-
]);
|
|
2711
2516
|
return StructSpecifier;
|
|
2712
2517
|
}(TreeNode);
|
|
2713
2518
|
ASTNode.StructSpecifier = StructSpecifier;
|
|
@@ -2717,24 +2522,37 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2717
2522
|
var StructDeclarationList = /*#__PURE__*/ function(TreeNode) {
|
|
2718
2523
|
_inherits(StructDeclarationList, TreeNode);
|
|
2719
2524
|
function StructDeclarationList() {
|
|
2720
|
-
|
|
2525
|
+
var _this;
|
|
2526
|
+
_this = TreeNode.apply(this, arguments) || this, _this.propList = [];
|
|
2527
|
+
return _this;
|
|
2721
2528
|
}
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2529
|
+
var _proto = StructDeclarationList.prototype;
|
|
2530
|
+
_proto.init = function init() {
|
|
2531
|
+
this.propList.length = 0;
|
|
2532
|
+
};
|
|
2533
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2534
|
+
var _this = this, children = _this.children, propList = _this.propList;
|
|
2535
|
+
if (children.length === 1) {
|
|
2536
|
+
var props = children[0].props;
|
|
2537
|
+
var propsLength = props.length;
|
|
2538
|
+
propList.length = propsLength;
|
|
2539
|
+
for(var i = 0; i < propsLength; i++){
|
|
2540
|
+
propList[i] = props[i];
|
|
2541
|
+
}
|
|
2542
|
+
} else {
|
|
2543
|
+
var listProps = children[0].propList;
|
|
2544
|
+
var declProps = children[1].props;
|
|
2545
|
+
var listPropLength = listProps.length;
|
|
2546
|
+
var declPropLength = declProps.length;
|
|
2547
|
+
propList.length = listPropLength + declPropLength;
|
|
2548
|
+
for(var i1 = 0; i1 < listPropLength; i1++){
|
|
2549
|
+
propList[i1] = listProps[i1];
|
|
2550
|
+
}
|
|
2551
|
+
for(var i2 = 0; i2 < declPropLength; i2++){
|
|
2552
|
+
propList[i2 + listPropLength] = declProps[i2];
|
|
2735
2553
|
}
|
|
2736
2554
|
}
|
|
2737
|
-
|
|
2555
|
+
};
|
|
2738
2556
|
return StructDeclarationList;
|
|
2739
2557
|
}(TreeNode);
|
|
2740
2558
|
ASTNode.StructDeclarationList = StructDeclarationList;
|
|
@@ -2744,50 +2562,44 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2744
2562
|
var StructDeclaration = /*#__PURE__*/ function(TreeNode) {
|
|
2745
2563
|
_inherits(StructDeclaration, TreeNode);
|
|
2746
2564
|
function StructDeclaration() {
|
|
2747
|
-
|
|
2565
|
+
var _this;
|
|
2566
|
+
_this = TreeNode.apply(this, arguments) || this, _this.props = [];
|
|
2567
|
+
return _this;
|
|
2748
2568
|
}
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
for(var i = 0; i < this.declaratorList.declaratorList.length; i++){
|
|
2781
|
-
var declarator1 = this.declaratorList.declaratorList[i];
|
|
2782
|
-
var typeInfo1 = new SymbolType(this.typeSpecifier.type, this.typeSpecifier.lexeme, declarator1.arraySpecifier);
|
|
2783
|
-
var prop1 = new StructProp(typeInfo1, declarator1.ident);
|
|
2784
|
-
ret.push(prop1);
|
|
2785
|
-
}
|
|
2786
|
-
}
|
|
2787
|
-
return ret;
|
|
2569
|
+
var _proto = StructDeclaration.prototype;
|
|
2570
|
+
_proto.init = function init() {
|
|
2571
|
+
this.typeSpecifier = undefined;
|
|
2572
|
+
this.declaratorList = undefined;
|
|
2573
|
+
this.props.length = 0;
|
|
2574
|
+
};
|
|
2575
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2576
|
+
var _this = this, children = _this.children, props = _this.props;
|
|
2577
|
+
if (children.length === 3) {
|
|
2578
|
+
this.typeSpecifier = children[0];
|
|
2579
|
+
this.declaratorList = children[1];
|
|
2580
|
+
} else {
|
|
2581
|
+
this.typeSpecifier = children[1];
|
|
2582
|
+
this.declaratorList = children[2];
|
|
2583
|
+
}
|
|
2584
|
+
var firstChild = children[0];
|
|
2585
|
+
var _this_typeSpecifier = this.typeSpecifier, type = _this_typeSpecifier.type, lexeme = _this_typeSpecifier.lexeme;
|
|
2586
|
+
if (_instanceof(firstChild, LayoutQualifier)) {
|
|
2587
|
+
var declarator = children[2];
|
|
2588
|
+
var typeInfo = new SymbolType(type, lexeme);
|
|
2589
|
+
var prop = new StructProp(typeInfo, declarator.ident, firstChild.index);
|
|
2590
|
+
props.push(prop);
|
|
2591
|
+
} else {
|
|
2592
|
+
var declaratorList = this.declaratorList.declaratorList;
|
|
2593
|
+
var declaratorListLength = declaratorList.length;
|
|
2594
|
+
props.length = declaratorListLength;
|
|
2595
|
+
for(var i = 0; i < declaratorListLength; i++){
|
|
2596
|
+
var declarator1 = declaratorList[i];
|
|
2597
|
+
var typeInfo1 = new SymbolType(type, lexeme, declarator1.arraySpecifier);
|
|
2598
|
+
var prop1 = new StructProp(typeInfo1, declarator1.ident);
|
|
2599
|
+
props[i] = prop1;
|
|
2788
2600
|
}
|
|
2789
2601
|
}
|
|
2790
|
-
|
|
2602
|
+
};
|
|
2791
2603
|
return StructDeclaration;
|
|
2792
2604
|
}(TreeNode);
|
|
2793
2605
|
ASTNode.StructDeclaration = StructDeclaration;
|
|
@@ -2799,14 +2611,10 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2799
2611
|
function LayoutQualifier() {
|
|
2800
2612
|
return TreeNode.apply(this, arguments) || this;
|
|
2801
2613
|
}
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
return Number(this.children[4].lexeme);
|
|
2807
|
-
}
|
|
2808
|
-
}
|
|
2809
|
-
]);
|
|
2614
|
+
var _proto = LayoutQualifier.prototype;
|
|
2615
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2616
|
+
this.index = Number(this.children[4].lexeme);
|
|
2617
|
+
};
|
|
2810
2618
|
return LayoutQualifier;
|
|
2811
2619
|
}(TreeNode);
|
|
2812
2620
|
ASTNode.LayoutQualifier = LayoutQualifier;
|
|
@@ -2816,25 +2624,29 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2816
2624
|
var StructDeclaratorList = /*#__PURE__*/ function(TreeNode) {
|
|
2817
2625
|
_inherits(StructDeclaratorList, TreeNode);
|
|
2818
2626
|
function StructDeclaratorList() {
|
|
2819
|
-
|
|
2627
|
+
var _this;
|
|
2628
|
+
_this = TreeNode.apply(this, arguments) || this, _this.declaratorList = [];
|
|
2629
|
+
return _this;
|
|
2820
2630
|
}
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2631
|
+
var _proto = StructDeclaratorList.prototype;
|
|
2632
|
+
_proto.init = function init() {
|
|
2633
|
+
this.declaratorList.length = 0;
|
|
2634
|
+
};
|
|
2635
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2636
|
+
var _this = this, children = _this.children, declaratorList = _this.declaratorList;
|
|
2637
|
+
if (children.length === 1) {
|
|
2638
|
+
declaratorList.push(children[0]);
|
|
2639
|
+
} else {
|
|
2640
|
+
var list = children[0];
|
|
2641
|
+
var declarator = children[1];
|
|
2642
|
+
var listLength = list.declaratorList.length;
|
|
2643
|
+
declaratorList.length = listLength + 1;
|
|
2644
|
+
for(var i = 0; i < listLength; i++){
|
|
2645
|
+
declaratorList[i] = list.declaratorList[i];
|
|
2835
2646
|
}
|
|
2647
|
+
declaratorList[listLength] = declarator;
|
|
2836
2648
|
}
|
|
2837
|
-
|
|
2649
|
+
};
|
|
2838
2650
|
return StructDeclaratorList;
|
|
2839
2651
|
}(TreeNode);
|
|
2840
2652
|
ASTNode.StructDeclaratorList = StructDeclaratorList;
|
|
@@ -2846,20 +2658,15 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2846
2658
|
function StructDeclarator() {
|
|
2847
2659
|
return TreeNode.apply(this, arguments) || this;
|
|
2848
2660
|
}
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
get: function get() {
|
|
2859
|
-
return this.children[1];
|
|
2860
|
-
}
|
|
2861
|
-
}
|
|
2862
|
-
]);
|
|
2661
|
+
var _proto = StructDeclarator.prototype;
|
|
2662
|
+
_proto.init = function init() {
|
|
2663
|
+
this.arraySpecifier = undefined;
|
|
2664
|
+
};
|
|
2665
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2666
|
+
var children = this.children;
|
|
2667
|
+
this.ident = children[0];
|
|
2668
|
+
this.arraySpecifier = children[1];
|
|
2669
|
+
};
|
|
2863
2670
|
return StructDeclarator;
|
|
2864
2671
|
}(TreeNode);
|
|
2865
2672
|
ASTNode.StructDeclarator = StructDeclarator;
|
|
@@ -2935,28 +2742,15 @@ var TreeNode = /*#__PURE__*/ function() {
|
|
|
2935
2742
|
}
|
|
2936
2743
|
var _proto = VariableIdentifier.prototype;
|
|
2937
2744
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2745
|
+
var _this_symbolInfo_dataType, _this_symbolInfo;
|
|
2938
2746
|
var token = this.children[0];
|
|
2747
|
+
this.lexeme = token.lexeme;
|
|
2939
2748
|
this.symbolInfo = sa.lookupSymbolBy(token.lexeme, ESymbolType.VAR);
|
|
2749
|
+
this.typeInfo = (_this_symbolInfo = this.symbolInfo) == null ? void 0 : (_this_symbolInfo_dataType = _this_symbolInfo.dataType) == null ? void 0 : _this_symbolInfo_dataType.type;
|
|
2940
2750
|
};
|
|
2941
2751
|
_proto.codeGen = function codeGen(visitor) {
|
|
2942
2752
|
return visitor.visitVariableIdentifier(this);
|
|
2943
2753
|
};
|
|
2944
|
-
_create_class(VariableIdentifier, [
|
|
2945
|
-
{
|
|
2946
|
-
key: "lexeme",
|
|
2947
|
-
get: function get() {
|
|
2948
|
-
return this.children[0].lexeme;
|
|
2949
|
-
}
|
|
2950
|
-
},
|
|
2951
|
-
{
|
|
2952
|
-
key: "typeInfo",
|
|
2953
|
-
get: function get() {
|
|
2954
|
-
var _this_symbolInfo;
|
|
2955
|
-
if (_instanceof(this.symbolInfo, VarSymbol)) return this.symbolInfo.dataType.type;
|
|
2956
|
-
return (_this_symbolInfo = this.symbolInfo) == null ? void 0 : _this_symbolInfo.type;
|
|
2957
|
-
}
|
|
2958
|
-
}
|
|
2959
|
-
]);
|
|
2960
2754
|
return VariableIdentifier;
|
|
2961
2755
|
}(TreeNode);
|
|
2962
2756
|
ASTNode.VariableIdentifier = VariableIdentifier;
|
|
@@ -4416,7 +4210,7 @@ State._id = 0;
|
|
|
4416
4210
|
this.actionTable = actionTable;
|
|
4417
4211
|
this.gotoTable = gotoTable;
|
|
4418
4212
|
this.grammar = grammar;
|
|
4419
|
-
this.sematicAnalyzer = new
|
|
4213
|
+
this.sematicAnalyzer = new SemanticAnalyzer();
|
|
4420
4214
|
}
|
|
4421
4215
|
var _proto = ShaderTargetParser.prototype;
|
|
4422
4216
|
_proto.parse = function parse(tokens) {
|
|
@@ -4743,7 +4537,7 @@ var PpScanner = /*#__PURE__*/ function(BaseScanner) {
|
|
|
4743
4537
|
var start = this._currentIndex;
|
|
4744
4538
|
var found = false;
|
|
4745
4539
|
for(var n = source.length; this._currentIndex < n;){
|
|
4746
|
-
if (LexerUtils.
|
|
4540
|
+
if (LexerUtils.isPpCharacters(source.charCodeAt(this._currentIndex))) {
|
|
4747
4541
|
this._advance();
|
|
4748
4542
|
found = true;
|
|
4749
4543
|
} else {
|
|
@@ -6798,7 +6592,7 @@ ShaderLab._shaderPositionPool = ShaderLabUtils.createObjectPool(ShaderPosition);
|
|
|
6798
6592
|
ShaderLab._shaderRangePool = ShaderLabUtils.createObjectPool(ShaderRange);
|
|
6799
6593
|
|
|
6800
6594
|
//@ts-ignore
|
|
6801
|
-
var version = "1.4.
|
|
6595
|
+
var version = "1.4.11";
|
|
6802
6596
|
var mode = "Release";
|
|
6803
6597
|
console.log("Galacean Engine ShaderLab Version: " + version + " | Mode: " + mode);
|
|
6804
6598
|
|