@galacean/engine-shaderlab 1.4.8 → 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.
- 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/browser.js
CHANGED
|
@@ -630,7 +630,7 @@
|
|
|
630
630
|
charCode >= 97 && charCode <= 122 // a - z
|
|
631
631
|
;
|
|
632
632
|
};
|
|
633
|
-
LexerUtils.
|
|
633
|
+
LexerUtils.isPpCharacters = function isPpCharacters(charCode) {
|
|
634
634
|
return charCode === 35 || // #
|
|
635
635
|
charCode === 46 || // .
|
|
636
636
|
charCode === 95 || // _
|
|
@@ -1363,8 +1363,8 @@
|
|
|
1363
1363
|
return VarSymbol;
|
|
1364
1364
|
}(SymbolInfo);
|
|
1365
1365
|
|
|
1366
|
-
var
|
|
1367
|
-
function
|
|
1366
|
+
var SemanticAnalyzer = /*#__PURE__*/ function() {
|
|
1367
|
+
function SemanticAnalyzer() {
|
|
1368
1368
|
this.semanticStack = [];
|
|
1369
1369
|
this.acceptRule = undefined;
|
|
1370
1370
|
this.symbolTableStack = new SymbolTableStack();
|
|
@@ -1373,7 +1373,7 @@
|
|
|
1373
1373
|
this._translationRuleTable = new Map();
|
|
1374
1374
|
this.newScope();
|
|
1375
1375
|
}
|
|
1376
|
-
var _proto =
|
|
1376
|
+
var _proto = SemanticAnalyzer.prototype;
|
|
1377
1377
|
_proto.reset = function reset() {
|
|
1378
1378
|
this.semanticStack.length = 0;
|
|
1379
1379
|
this._shaderData = new ShaderData();
|
|
@@ -1404,7 +1404,7 @@
|
|
|
1404
1404
|
_proto.reportError = function reportError(loc, message) {
|
|
1405
1405
|
engine.Logger.error(message);
|
|
1406
1406
|
};
|
|
1407
|
-
_create_class(
|
|
1407
|
+
_create_class(SemanticAnalyzer, [
|
|
1408
1408
|
{
|
|
1409
1409
|
key: "shaderData",
|
|
1410
1410
|
get: function get() {
|
|
@@ -1412,7 +1412,7 @@
|
|
|
1412
1412
|
}
|
|
1413
1413
|
}
|
|
1414
1414
|
]);
|
|
1415
|
-
return
|
|
1415
|
+
return SemanticAnalyzer;
|
|
1416
1416
|
}();
|
|
1417
1417
|
|
|
1418
1418
|
var NoneTerminal = /*#__PURE__*/ function(NoneTerminal) {
|
|
@@ -1761,28 +1761,12 @@
|
|
|
1761
1761
|
function FullySpecifiedType() {
|
|
1762
1762
|
return TreeNode.apply(this, arguments) || this;
|
|
1763
1763
|
}
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
},
|
|
1773
|
-
{
|
|
1774
|
-
key: "typeSpecifier",
|
|
1775
|
-
get: function get() {
|
|
1776
|
-
return this.children.length === 1 ? this.children[0] : this.children[1];
|
|
1777
|
-
}
|
|
1778
|
-
},
|
|
1779
|
-
{
|
|
1780
|
-
key: "type",
|
|
1781
|
-
get: function get() {
|
|
1782
|
-
return this.typeSpecifier.type;
|
|
1783
|
-
}
|
|
1784
|
-
}
|
|
1785
|
-
]);
|
|
1764
|
+
var _proto = FullySpecifiedType.prototype;
|
|
1765
|
+
_proto.semanticAnalyze = function semanticAnalyze(_) {
|
|
1766
|
+
var children = this.children;
|
|
1767
|
+
this.typeSpecifier = children.length === 1 ? children[0] : children[1];
|
|
1768
|
+
this.type = this.typeSpecifier.type;
|
|
1769
|
+
};
|
|
1786
1770
|
return FullySpecifiedType;
|
|
1787
1771
|
}(TreeNode);
|
|
1788
1772
|
ASTNode.FullySpecifiedType = FullySpecifiedType;
|
|
@@ -1794,18 +1778,6 @@
|
|
|
1794
1778
|
function TypeQualifier() {
|
|
1795
1779
|
return TreeNode.apply(this, arguments) || this;
|
|
1796
1780
|
}
|
|
1797
|
-
var _proto = TypeQualifier.prototype;
|
|
1798
|
-
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1799
|
-
if (this.children.length > 1) {
|
|
1800
|
-
this.qualifierList = [].concat(this.children[0].qualifierList, [
|
|
1801
|
-
this.children[1].qualifier
|
|
1802
|
-
]);
|
|
1803
|
-
} else {
|
|
1804
|
-
this.qualifierList = [
|
|
1805
|
-
this.children[0].qualifier
|
|
1806
|
-
];
|
|
1807
|
-
}
|
|
1808
|
-
};
|
|
1809
1781
|
return TypeQualifier;
|
|
1810
1782
|
}(TreeNode);
|
|
1811
1783
|
ASTNode.TypeQualifier = TypeQualifier;
|
|
@@ -1839,37 +1811,25 @@
|
|
|
1839
1811
|
function TypeSpecifier() {
|
|
1840
1812
|
return TreeNode.apply(this, arguments) || this;
|
|
1841
1813
|
}
|
|
1814
|
+
var _proto = TypeSpecifier.prototype;
|
|
1815
|
+
_proto.init = function init() {
|
|
1816
|
+
this.arraySize = undefined;
|
|
1817
|
+
};
|
|
1818
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1819
|
+
var _children_;
|
|
1820
|
+
var children = this.children;
|
|
1821
|
+
var firstChild = children[0];
|
|
1822
|
+
this.type = firstChild.type;
|
|
1823
|
+
this.lexeme = firstChild.lexeme;
|
|
1824
|
+
this.arraySize = children == null ? void 0 : (_children_ = children[1]) == null ? void 0 : _children_.size;
|
|
1825
|
+
this.isCustom = typeof this.type === "string";
|
|
1826
|
+
};
|
|
1842
1827
|
_create_class(TypeSpecifier, [
|
|
1843
|
-
{
|
|
1844
|
-
key: "type",
|
|
1845
|
-
get: function get() {
|
|
1846
|
-
return this.children[0].type;
|
|
1847
|
-
}
|
|
1848
|
-
},
|
|
1849
|
-
{
|
|
1850
|
-
key: "lexeme",
|
|
1851
|
-
get: function get() {
|
|
1852
|
-
return this.children[0].lexeme;
|
|
1853
|
-
}
|
|
1854
|
-
},
|
|
1855
|
-
{
|
|
1856
|
-
key: "arraySize",
|
|
1857
|
-
get: function get() {
|
|
1858
|
-
var _this_children_, _this_children;
|
|
1859
|
-
return (_this_children = this.children) == null ? void 0 : (_this_children_ = _this_children[1]) == null ? void 0 : _this_children_.size;
|
|
1860
|
-
}
|
|
1861
|
-
},
|
|
1862
1828
|
{
|
|
1863
1829
|
key: "arraySpecifier",
|
|
1864
1830
|
get: function get() {
|
|
1865
1831
|
return this.children[1];
|
|
1866
1832
|
}
|
|
1867
|
-
},
|
|
1868
|
-
{
|
|
1869
|
-
key: "isCustom",
|
|
1870
|
-
get: function get() {
|
|
1871
|
-
return typeof this.type === "string";
|
|
1872
|
-
}
|
|
1873
1833
|
}
|
|
1874
1834
|
]);
|
|
1875
1835
|
return TypeSpecifier;
|
|
@@ -1883,15 +1843,11 @@
|
|
|
1883
1843
|
function ArraySpecifier() {
|
|
1884
1844
|
return TreeNode.apply(this, arguments) || this;
|
|
1885
1845
|
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
return integerConstantExpr.value;
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
]);
|
|
1846
|
+
var _proto = ArraySpecifier.prototype;
|
|
1847
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1848
|
+
var integerConstantExpr = this.children[1];
|
|
1849
|
+
this.size = integerConstantExpr.value;
|
|
1850
|
+
};
|
|
1895
1851
|
return ArraySpecifier;
|
|
1896
1852
|
}(TreeNode);
|
|
1897
1853
|
ASTNode.ArraySpecifier = ArraySpecifier;
|
|
@@ -1906,6 +1862,7 @@
|
|
|
1906
1862
|
var _proto = IntegerConstantExpressionOperator.prototype;
|
|
1907
1863
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
1908
1864
|
var operator = this.children[0];
|
|
1865
|
+
this.lexeme = operator.lexeme;
|
|
1909
1866
|
switch(operator.type){
|
|
1910
1867
|
case ETokenType.PLUS:
|
|
1911
1868
|
this.compute = function(a, b) {
|
|
@@ -1936,14 +1893,6 @@
|
|
|
1936
1893
|
sa.reportError(operator.location, "not implemented operator " + operator.lexeme);
|
|
1937
1894
|
}
|
|
1938
1895
|
};
|
|
1939
|
-
_create_class(IntegerConstantExpressionOperator, [
|
|
1940
|
-
{
|
|
1941
|
-
key: "lexeme",
|
|
1942
|
-
get: function get() {
|
|
1943
|
-
return this.children[0].lexeme;
|
|
1944
|
-
}
|
|
1945
|
-
}
|
|
1946
|
-
]);
|
|
1947
1896
|
return IntegerConstantExpressionOperator;
|
|
1948
1897
|
}(TreeNode);
|
|
1949
1898
|
ASTNode.IntegerConstantExpressionOperator = IntegerConstantExpressionOperator;
|
|
@@ -2020,32 +1969,28 @@
|
|
|
2020
1969
|
var _proto = InitDeclaratorList.prototype;
|
|
2021
1970
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2022
1971
|
var sm;
|
|
2023
|
-
|
|
2024
|
-
|
|
1972
|
+
var children = this.children;
|
|
1973
|
+
var childrenLength = children.length;
|
|
1974
|
+
if (childrenLength === 1) {
|
|
1975
|
+
var _children_ = children[0], typeSpecifier = _children_.typeSpecifier, arraySpecifier = _children_.arraySpecifier;
|
|
1976
|
+
this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
1977
|
+
} else {
|
|
1978
|
+
var initDeclList = children[0];
|
|
1979
|
+
this.typeInfo = initDeclList.typeInfo;
|
|
1980
|
+
}
|
|
1981
|
+
if (childrenLength === 3 || childrenLength === 5) {
|
|
1982
|
+
var id = children[2];
|
|
2025
1983
|
sm = new VarSymbol(id.lexeme, this.typeInfo, false, this);
|
|
2026
1984
|
sa.symbolTableStack.insert(sm);
|
|
2027
|
-
} else if (
|
|
1985
|
+
} else if (childrenLength === 4 || childrenLength === 6) {
|
|
2028
1986
|
var typeInfo = this.typeInfo;
|
|
2029
|
-
var
|
|
2030
|
-
typeInfo.arraySpecifier =
|
|
2031
|
-
var id1 =
|
|
1987
|
+
var arraySpecifier1 = this.children[3];
|
|
1988
|
+
typeInfo.arraySpecifier = arraySpecifier1;
|
|
1989
|
+
var id1 = children[2];
|
|
2032
1990
|
sm = new VarSymbol(id1.lexeme, typeInfo, false, this);
|
|
2033
1991
|
sa.symbolTableStack.insert(sm);
|
|
2034
1992
|
}
|
|
2035
1993
|
};
|
|
2036
|
-
_create_class(InitDeclaratorList, [
|
|
2037
|
-
{
|
|
2038
|
-
key: "typeInfo",
|
|
2039
|
-
get: function get() {
|
|
2040
|
-
if (this.children.length === 1) {
|
|
2041
|
-
var singleDecl = this.children[0];
|
|
2042
|
-
return new SymbolType(singleDecl.typeSpecifier.type, singleDecl.typeSpecifier.lexeme, singleDecl.arraySpecifier);
|
|
2043
|
-
}
|
|
2044
|
-
var initDeclList = this.children[0];
|
|
2045
|
-
return initDeclList.typeInfo;
|
|
2046
|
-
}
|
|
2047
|
-
}
|
|
2048
|
-
]);
|
|
2049
1994
|
return InitDeclaratorList;
|
|
2050
1995
|
}(TreeNode);
|
|
2051
1996
|
ASTNode.InitDeclaratorList = InitDeclaratorList;
|
|
@@ -2055,23 +2000,29 @@
|
|
|
2055
2000
|
var IdentifierList = /*#__PURE__*/ function(TreeNode) {
|
|
2056
2001
|
_inherits(IdentifierList, TreeNode);
|
|
2057
2002
|
function IdentifierList() {
|
|
2058
|
-
|
|
2003
|
+
var _this;
|
|
2004
|
+
_this = TreeNode.apply(this, arguments) || this, _this.idList = [];
|
|
2005
|
+
return _this;
|
|
2059
2006
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2007
|
+
var _proto = IdentifierList.prototype;
|
|
2008
|
+
_proto.init = function init() {
|
|
2009
|
+
this.idList.length = 0;
|
|
2010
|
+
};
|
|
2011
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2012
|
+
var _this = this, children = _this.children, curIdList = _this.idList;
|
|
2013
|
+
if (children.length === 2) {
|
|
2014
|
+
curIdList.push(children[1]);
|
|
2015
|
+
} else {
|
|
2016
|
+
var list = children[0];
|
|
2017
|
+
var id = children[2];
|
|
2018
|
+
var listIdLength = list.idList.length;
|
|
2019
|
+
curIdList.length = listIdLength + 1;
|
|
2020
|
+
for(var i = 0; i < listIdLength; i++){
|
|
2021
|
+
curIdList[i] = list.idList[i];
|
|
2072
2022
|
}
|
|
2023
|
+
curIdList[listIdLength] = id;
|
|
2073
2024
|
}
|
|
2074
|
-
|
|
2025
|
+
};
|
|
2075
2026
|
return IdentifierList;
|
|
2076
2027
|
}(TreeNode);
|
|
2077
2028
|
ASTNode.IdentifierList = IdentifierList;
|
|
@@ -2099,41 +2050,16 @@
|
|
|
2099
2050
|
return TreeNode.apply(this, arguments) || this;
|
|
2100
2051
|
}
|
|
2101
2052
|
var _proto = FunctionProtoType.prototype;
|
|
2053
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2054
|
+
var declarator = this.children[0];
|
|
2055
|
+
this.ident = declarator.ident;
|
|
2056
|
+
this.returnType = declarator.returnType;
|
|
2057
|
+
this.parameterList = declarator.parameterInfoList;
|
|
2058
|
+
this.paramSig = declarator.paramSig;
|
|
2059
|
+
};
|
|
2102
2060
|
_proto.codeGen = function codeGen(visitor) {
|
|
2103
2061
|
return visitor.visitFunctionProtoType(this);
|
|
2104
2062
|
};
|
|
2105
|
-
_create_class(FunctionProtoType, [
|
|
2106
|
-
{
|
|
2107
|
-
key: "declarator",
|
|
2108
|
-
get: function get() {
|
|
2109
|
-
return this.children[0];
|
|
2110
|
-
}
|
|
2111
|
-
},
|
|
2112
|
-
{
|
|
2113
|
-
key: "ident",
|
|
2114
|
-
get: function get() {
|
|
2115
|
-
return this.declarator.ident;
|
|
2116
|
-
}
|
|
2117
|
-
},
|
|
2118
|
-
{
|
|
2119
|
-
key: "returnType",
|
|
2120
|
-
get: function get() {
|
|
2121
|
-
return this.declarator.returnType;
|
|
2122
|
-
}
|
|
2123
|
-
},
|
|
2124
|
-
{
|
|
2125
|
-
key: "parameterList",
|
|
2126
|
-
get: function get() {
|
|
2127
|
-
return this.declarator.parameterInfoList;
|
|
2128
|
-
}
|
|
2129
|
-
},
|
|
2130
|
-
{
|
|
2131
|
-
key: "paramSig",
|
|
2132
|
-
get: function get() {
|
|
2133
|
-
return this.declarator.paramSig;
|
|
2134
|
-
}
|
|
2135
|
-
}
|
|
2136
|
-
]);
|
|
2137
2063
|
return FunctionProtoType;
|
|
2138
2064
|
}(TreeNode);
|
|
2139
2065
|
ASTNode.FunctionProtoType = FunctionProtoType;
|
|
@@ -2149,47 +2075,14 @@
|
|
|
2149
2075
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2150
2076
|
sa.curFunctionInfo.returnStatement = null;
|
|
2151
2077
|
sa.curFunctionInfo.header = this;
|
|
2078
|
+
var children = this.children;
|
|
2079
|
+
var header = children[0];
|
|
2080
|
+
var parameterList = children[1];
|
|
2081
|
+
this.ident = header.ident;
|
|
2082
|
+
this.returnType = header.returnType;
|
|
2083
|
+
this.parameterInfoList = parameterList == null ? void 0 : parameterList.parameterInfoList;
|
|
2084
|
+
this.paramSig = parameterList == null ? void 0 : parameterList.paramSig;
|
|
2152
2085
|
};
|
|
2153
|
-
_create_class(FunctionDeclarator, [
|
|
2154
|
-
{
|
|
2155
|
-
key: "header",
|
|
2156
|
-
get: function get() {
|
|
2157
|
-
return this.children[0];
|
|
2158
|
-
}
|
|
2159
|
-
},
|
|
2160
|
-
{
|
|
2161
|
-
key: "parameterList",
|
|
2162
|
-
get: function get() {
|
|
2163
|
-
return this.children[1];
|
|
2164
|
-
}
|
|
2165
|
-
},
|
|
2166
|
-
{
|
|
2167
|
-
key: "ident",
|
|
2168
|
-
get: function get() {
|
|
2169
|
-
return this.header.ident;
|
|
2170
|
-
}
|
|
2171
|
-
},
|
|
2172
|
-
{
|
|
2173
|
-
key: "returnType",
|
|
2174
|
-
get: function get() {
|
|
2175
|
-
return this.header.returnType;
|
|
2176
|
-
}
|
|
2177
|
-
},
|
|
2178
|
-
{
|
|
2179
|
-
key: "parameterInfoList",
|
|
2180
|
-
get: function get() {
|
|
2181
|
-
var _this_parameterList;
|
|
2182
|
-
return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.parameterInfoList;
|
|
2183
|
-
}
|
|
2184
|
-
},
|
|
2185
|
-
{
|
|
2186
|
-
key: "paramSig",
|
|
2187
|
-
get: function get() {
|
|
2188
|
-
var _this_parameterList;
|
|
2189
|
-
return (_this_parameterList = this.parameterList) == null ? void 0 : _this_parameterList.paramSig;
|
|
2190
|
-
}
|
|
2191
|
-
}
|
|
2192
|
-
]);
|
|
2193
2086
|
return FunctionDeclarator;
|
|
2194
2087
|
}(TreeNode);
|
|
2195
2088
|
ASTNode.FunctionDeclarator = FunctionDeclarator;
|
|
@@ -2204,24 +2097,13 @@
|
|
|
2204
2097
|
var _proto = FunctionHeader.prototype;
|
|
2205
2098
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2206
2099
|
sa.newScope();
|
|
2100
|
+
var children = this.children;
|
|
2101
|
+
this.ident = children[1];
|
|
2102
|
+
this.returnType = children[0];
|
|
2207
2103
|
};
|
|
2208
2104
|
_proto.codeGen = function codeGen(visitor) {
|
|
2209
2105
|
return visitor.visitFunctionHeader(this);
|
|
2210
2106
|
};
|
|
2211
|
-
_create_class(FunctionHeader, [
|
|
2212
|
-
{
|
|
2213
|
-
key: "ident",
|
|
2214
|
-
get: function get() {
|
|
2215
|
-
return this.children[1];
|
|
2216
|
-
}
|
|
2217
|
-
},
|
|
2218
|
-
{
|
|
2219
|
-
key: "returnType",
|
|
2220
|
-
get: function get() {
|
|
2221
|
-
return this.children[0];
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
]);
|
|
2225
2107
|
return FunctionHeader;
|
|
2226
2108
|
}(TreeNode);
|
|
2227
2109
|
ASTNode.FunctionHeader = FunctionHeader;
|
|
@@ -2231,55 +2113,48 @@
|
|
|
2231
2113
|
var FunctionParameterList = /*#__PURE__*/ function(TreeNode) {
|
|
2232
2114
|
_inherits(FunctionParameterList, TreeNode);
|
|
2233
2115
|
function FunctionParameterList() {
|
|
2234
|
-
|
|
2116
|
+
var _this;
|
|
2117
|
+
_this = TreeNode.apply(this, arguments) || this, _this.parameterInfoList = [], _this.paramSig = [];
|
|
2118
|
+
return _this;
|
|
2235
2119
|
}
|
|
2236
2120
|
var _proto = FunctionParameterList.prototype;
|
|
2237
|
-
_proto.
|
|
2238
|
-
|
|
2121
|
+
_proto.init = function init() {
|
|
2122
|
+
this.parameterInfoList.length = 0;
|
|
2123
|
+
this.paramSig.length = 0;
|
|
2239
2124
|
};
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
}
|
|
2262
|
-
]);
|
|
2263
|
-
}
|
|
2264
|
-
},
|
|
2265
|
-
{
|
|
2266
|
-
key: "paramSig",
|
|
2267
|
-
get: function get() {
|
|
2268
|
-
if (this.children.length === 1) {
|
|
2269
|
-
var decl = this.children[0];
|
|
2270
|
-
return [
|
|
2271
|
-
decl.typeInfo.type
|
|
2272
|
-
];
|
|
2273
|
-
} else {
|
|
2274
|
-
var list = this.children[0];
|
|
2275
|
-
var decl1 = this.children[2];
|
|
2276
|
-
return list.paramSig.concat([
|
|
2277
|
-
decl1.typeInfo.type
|
|
2278
|
-
]);
|
|
2279
|
-
}
|
|
2125
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2126
|
+
var children = this.children;
|
|
2127
|
+
var childrenLength = children.length;
|
|
2128
|
+
var _this = this, parameterInfoList = _this.parameterInfoList, paramSig = _this.paramSig;
|
|
2129
|
+
if (childrenLength === 1) {
|
|
2130
|
+
var decl = children[0];
|
|
2131
|
+
parameterInfoList.push({
|
|
2132
|
+
ident: decl.ident,
|
|
2133
|
+
typeInfo: decl.typeInfo,
|
|
2134
|
+
astNode: decl
|
|
2135
|
+
});
|
|
2136
|
+
paramSig.push(decl.typeInfo.type);
|
|
2137
|
+
} else {
|
|
2138
|
+
var list = children[0];
|
|
2139
|
+
var decl1 = children[2];
|
|
2140
|
+
var listParamLength = list.parameterInfoList.length;
|
|
2141
|
+
parameterInfoList.length = listParamLength + 1;
|
|
2142
|
+
paramSig.length = listParamLength + 1;
|
|
2143
|
+
for(var i = 0; i < listParamLength; i++){
|
|
2144
|
+
parameterInfoList[i] = list.parameterInfoList[i];
|
|
2145
|
+
paramSig[i] = list.paramSig[i];
|
|
2280
2146
|
}
|
|
2147
|
+
parameterInfoList[listParamLength] = {
|
|
2148
|
+
ident: decl1.ident,
|
|
2149
|
+
typeInfo: decl1.typeInfo,
|
|
2150
|
+
astNode: decl1
|
|
2151
|
+
};
|
|
2152
|
+
paramSig[listParamLength] = decl1.typeInfo.type;
|
|
2281
2153
|
}
|
|
2282
|
-
|
|
2154
|
+
};
|
|
2155
|
+
_proto.codeGen = function codeGen(visitor) {
|
|
2156
|
+
return visitor.visitFunctionParameterList(this);
|
|
2157
|
+
};
|
|
2283
2158
|
return FunctionParameterList;
|
|
2284
2159
|
}(TreeNode);
|
|
2285
2160
|
ASTNode.FunctionParameterList = FunctionParameterList;
|
|
@@ -2292,43 +2167,26 @@
|
|
|
2292
2167
|
return TreeNode.apply(this, arguments) || this;
|
|
2293
2168
|
}
|
|
2294
2169
|
var _proto = ParameterDeclaration.prototype;
|
|
2170
|
+
_proto.init = function init() {
|
|
2171
|
+
this.typeQualifier = undefined;
|
|
2172
|
+
};
|
|
2295
2173
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2296
|
-
var
|
|
2297
|
-
|
|
2298
|
-
|
|
2174
|
+
var children = this.children;
|
|
2175
|
+
var childrenLength = children.length;
|
|
2176
|
+
var parameterDeclarator;
|
|
2177
|
+
if (childrenLength === 1) {
|
|
2178
|
+
parameterDeclarator = children[0];
|
|
2299
2179
|
} else {
|
|
2300
|
-
|
|
2180
|
+
parameterDeclarator = children[1];
|
|
2181
|
+
}
|
|
2182
|
+
if (childrenLength === 2) {
|
|
2183
|
+
this.typeQualifier = children[0];
|
|
2301
2184
|
}
|
|
2302
|
-
|
|
2185
|
+
this.typeInfo = parameterDeclarator.typeInfo;
|
|
2186
|
+
this.ident = parameterDeclarator.ident;
|
|
2187
|
+
var varSymbol = new VarSymbol(parameterDeclarator.ident.lexeme, parameterDeclarator.typeInfo, false, this);
|
|
2303
2188
|
sa.symbolTableStack.insert(varSymbol);
|
|
2304
2189
|
};
|
|
2305
|
-
_create_class(ParameterDeclaration, [
|
|
2306
|
-
{
|
|
2307
|
-
key: "typeQualifier",
|
|
2308
|
-
get: function get() {
|
|
2309
|
-
if (this.children.length === 2) return this.children[0];
|
|
2310
|
-
}
|
|
2311
|
-
},
|
|
2312
|
-
{
|
|
2313
|
-
key: "parameterDeclarator",
|
|
2314
|
-
get: function get() {
|
|
2315
|
-
if (this.children.length === 1) return this.children[0];
|
|
2316
|
-
return this.children[1];
|
|
2317
|
-
}
|
|
2318
|
-
},
|
|
2319
|
-
{
|
|
2320
|
-
key: "typeInfo",
|
|
2321
|
-
get: function get() {
|
|
2322
|
-
return this.parameterDeclarator.typeInfo;
|
|
2323
|
-
}
|
|
2324
|
-
},
|
|
2325
|
-
{
|
|
2326
|
-
key: "ident",
|
|
2327
|
-
get: function get() {
|
|
2328
|
-
return this.parameterDeclarator.ident;
|
|
2329
|
-
}
|
|
2330
|
-
}
|
|
2331
|
-
]);
|
|
2332
2190
|
return ParameterDeclaration;
|
|
2333
2191
|
}(TreeNode);
|
|
2334
2192
|
ASTNode.ParameterDeclaration = ParameterDeclaration;
|
|
@@ -2340,22 +2198,14 @@
|
|
|
2340
2198
|
function ParameterDeclarator() {
|
|
2341
2199
|
return TreeNode.apply(this, arguments) || this;
|
|
2342
2200
|
}
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
key: "typeInfo",
|
|
2352
|
-
get: function get() {
|
|
2353
|
-
var typeSpecifier = this.children[0];
|
|
2354
|
-
var arraySpecifier = this.children[2];
|
|
2355
|
-
return new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
2356
|
-
}
|
|
2357
|
-
}
|
|
2358
|
-
]);
|
|
2201
|
+
var _proto = ParameterDeclarator.prototype;
|
|
2202
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2203
|
+
var children = this.children;
|
|
2204
|
+
this.ident = children[1];
|
|
2205
|
+
var typeSpecifier = children[0];
|
|
2206
|
+
var arraySpecifier = children[2];
|
|
2207
|
+
this.typeInfo = new SymbolType(typeSpecifier.type, typeSpecifier.lexeme, arraySpecifier);
|
|
2208
|
+
};
|
|
2359
2209
|
return ParameterDeclarator;
|
|
2360
2210
|
}(TreeNode);
|
|
2361
2211
|
ASTNode.ParameterDeclarator = ParameterDeclarator;
|
|
@@ -2395,9 +2245,12 @@
|
|
|
2395
2245
|
}
|
|
2396
2246
|
var _proto = FunctionDefinition.prototype;
|
|
2397
2247
|
_proto.init = function init() {
|
|
2398
|
-
this.
|
|
2248
|
+
this.returnStatement = undefined;
|
|
2399
2249
|
};
|
|
2400
2250
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2251
|
+
var children = this.children;
|
|
2252
|
+
this.protoType = children[0];
|
|
2253
|
+
this.statements = children[1];
|
|
2401
2254
|
sa.dropScope();
|
|
2402
2255
|
var sm = new FnSymbol(this.protoType.ident.lexeme, this);
|
|
2403
2256
|
sa.symbolTableStack.insert(sm);
|
|
@@ -2411,7 +2264,7 @@
|
|
|
2411
2264
|
if (!returnStatement) {
|
|
2412
2265
|
sa.reportError(header.returnType.location, "No return statement found.");
|
|
2413
2266
|
} else {
|
|
2414
|
-
this.
|
|
2267
|
+
this.returnStatement = returnStatement;
|
|
2415
2268
|
}
|
|
2416
2269
|
}
|
|
2417
2270
|
curFunctionInfo.header = undefined;
|
|
@@ -2420,26 +2273,6 @@
|
|
|
2420
2273
|
_proto.codeGen = function codeGen(visitor) {
|
|
2421
2274
|
return visitor.visitFunctionDefinition(this);
|
|
2422
2275
|
};
|
|
2423
|
-
_create_class(FunctionDefinition, [
|
|
2424
|
-
{
|
|
2425
|
-
key: "returnStatement",
|
|
2426
|
-
get: function get() {
|
|
2427
|
-
return this._returnStatement;
|
|
2428
|
-
}
|
|
2429
|
-
},
|
|
2430
|
-
{
|
|
2431
|
-
key: "protoType",
|
|
2432
|
-
get: function get() {
|
|
2433
|
-
return this.children[0];
|
|
2434
|
-
}
|
|
2435
|
-
},
|
|
2436
|
-
{
|
|
2437
|
-
key: "statements",
|
|
2438
|
-
get: function get() {
|
|
2439
|
-
return this.children[1];
|
|
2440
|
-
}
|
|
2441
|
-
}
|
|
2442
|
-
]);
|
|
2443
2276
|
return FunctionDefinition;
|
|
2444
2277
|
}(TreeNode);
|
|
2445
2278
|
ASTNode.FunctionDefinition = FunctionDefinition;
|
|
@@ -2505,52 +2338,43 @@
|
|
|
2505
2338
|
var FunctionCallParameterList = /*#__PURE__*/ function(TreeNode) {
|
|
2506
2339
|
_inherits(FunctionCallParameterList, TreeNode);
|
|
2507
2340
|
function FunctionCallParameterList() {
|
|
2508
|
-
|
|
2341
|
+
var _this;
|
|
2342
|
+
_this = TreeNode.apply(this, arguments) || this, _this.paramSig = [], _this.paramNodes = [];
|
|
2343
|
+
return _this;
|
|
2509
2344
|
}
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
var list = this.children[0];
|
|
2524
|
-
var decl = this.children[2];
|
|
2525
|
-
if (list.paramSig == undefined || decl.type == undefined) {
|
|
2526
|
-
return [
|
|
2527
|
-
TypeAny
|
|
2528
|
-
];
|
|
2529
|
-
} else {
|
|
2530
|
-
return list.paramSig.concat([
|
|
2531
|
-
decl.type
|
|
2532
|
-
]);
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2345
|
+
var _proto = FunctionCallParameterList.prototype;
|
|
2346
|
+
_proto.init = function init() {
|
|
2347
|
+
this.paramSig.length = 0;
|
|
2348
|
+
this.paramNodes.length = 0;
|
|
2349
|
+
};
|
|
2350
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2351
|
+
var _this = this, children = _this.children, paramSig = _this.paramSig, paramNodes = _this.paramNodes;
|
|
2352
|
+
if (children.length === 1) {
|
|
2353
|
+
var expr = children[0];
|
|
2354
|
+
if (expr.type == undefined) {
|
|
2355
|
+
paramSig.push(TypeAny);
|
|
2356
|
+
} else {
|
|
2357
|
+
paramSig.push(expr.type);
|
|
2535
2358
|
}
|
|
2536
|
-
|
|
2537
|
-
{
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
]);
|
|
2359
|
+
this.paramNodes.push(expr);
|
|
2360
|
+
} else {
|
|
2361
|
+
var list = children[0];
|
|
2362
|
+
var decl = children[2];
|
|
2363
|
+
if (list.paramSig.length === 0 || decl.type == undefined) {
|
|
2364
|
+
this.paramSig.push(TypeAny);
|
|
2365
|
+
} else {
|
|
2366
|
+
var listParamLength = list.paramSig.length;
|
|
2367
|
+
paramSig.length = listParamLength + 1;
|
|
2368
|
+
paramNodes.length = listParamLength + 1;
|
|
2369
|
+
for(var i = 0; i < listParamLength; i++){
|
|
2370
|
+
paramSig[i] = list.paramSig[i];
|
|
2371
|
+
paramNodes[i] = list.paramNodes[i];
|
|
2550
2372
|
}
|
|
2373
|
+
paramSig[listParamLength] = decl.type;
|
|
2374
|
+
paramNodes[listParamLength] = decl;
|
|
2551
2375
|
}
|
|
2552
2376
|
}
|
|
2553
|
-
|
|
2377
|
+
};
|
|
2554
2378
|
return FunctionCallParameterList;
|
|
2555
2379
|
}(TreeNode);
|
|
2556
2380
|
ASTNode.FunctionCallParameterList = FunctionCallParameterList;
|
|
@@ -2578,32 +2402,15 @@
|
|
|
2578
2402
|
return TreeNode.apply(this, arguments) || this;
|
|
2579
2403
|
}
|
|
2580
2404
|
var _proto = FunctionIdentifier.prototype;
|
|
2581
|
-
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2405
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2406
|
+
var typeSpecifier = this.children[0];
|
|
2407
|
+
this.ident = typeSpecifier.type;
|
|
2408
|
+
this.lexeme = typeSpecifier.lexeme;
|
|
2409
|
+
this.isBuiltin = typeof this.ident !== "string";
|
|
2410
|
+
};
|
|
2582
2411
|
_proto.codeGen = function codeGen(visitor) {
|
|
2583
2412
|
return visitor.visitFunctionIdentifier(this);
|
|
2584
2413
|
};
|
|
2585
|
-
_create_class(FunctionIdentifier, [
|
|
2586
|
-
{
|
|
2587
|
-
key: "ident",
|
|
2588
|
-
get: function get() {
|
|
2589
|
-
var ty = this.children[0];
|
|
2590
|
-
return ty.type;
|
|
2591
|
-
}
|
|
2592
|
-
},
|
|
2593
|
-
{
|
|
2594
|
-
key: "lexeme",
|
|
2595
|
-
get: function get() {
|
|
2596
|
-
var ty = this.children[0];
|
|
2597
|
-
return ty.lexeme;
|
|
2598
|
-
}
|
|
2599
|
-
},
|
|
2600
|
-
{
|
|
2601
|
-
key: "isBuiltin",
|
|
2602
|
-
get: function get() {
|
|
2603
|
-
return typeof this.ident !== "string";
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
]);
|
|
2607
2414
|
return FunctionIdentifier;
|
|
2608
2415
|
}(TreeNode);
|
|
2609
2416
|
ASTNode.FunctionIdentifier = FunctionIdentifier;
|
|
@@ -2697,21 +2504,19 @@
|
|
|
2697
2504
|
return TreeNode.apply(this, arguments) || this;
|
|
2698
2505
|
}
|
|
2699
2506
|
var _proto = StructSpecifier.prototype;
|
|
2507
|
+
_proto.init = function init() {
|
|
2508
|
+
this.ident = undefined;
|
|
2509
|
+
};
|
|
2700
2510
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2701
|
-
|
|
2702
|
-
|
|
2511
|
+
var children = this.children;
|
|
2512
|
+
if (children.length === 6) {
|
|
2513
|
+
this.ident = children[1];
|
|
2703
2514
|
sa.symbolTableStack.insert(new StructSymbol(this.ident.lexeme, this));
|
|
2515
|
+
this.propList = children[3].propList;
|
|
2516
|
+
} else {
|
|
2517
|
+
this.propList = children[2].propList;
|
|
2704
2518
|
}
|
|
2705
2519
|
};
|
|
2706
|
-
_create_class(StructSpecifier, [
|
|
2707
|
-
{
|
|
2708
|
-
key: "propList",
|
|
2709
|
-
get: function get() {
|
|
2710
|
-
var declList = this.children.length === 6 ? this.children[3] : this.children[2];
|
|
2711
|
-
return declList.propList;
|
|
2712
|
-
}
|
|
2713
|
-
}
|
|
2714
|
-
]);
|
|
2715
2520
|
return StructSpecifier;
|
|
2716
2521
|
}(TreeNode);
|
|
2717
2522
|
ASTNode.StructSpecifier = StructSpecifier;
|
|
@@ -2721,24 +2526,37 @@
|
|
|
2721
2526
|
var StructDeclarationList = /*#__PURE__*/ function(TreeNode) {
|
|
2722
2527
|
_inherits(StructDeclarationList, TreeNode);
|
|
2723
2528
|
function StructDeclarationList() {
|
|
2724
|
-
|
|
2529
|
+
var _this;
|
|
2530
|
+
_this = TreeNode.apply(this, arguments) || this, _this.propList = [];
|
|
2531
|
+
return _this;
|
|
2725
2532
|
}
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2533
|
+
var _proto = StructDeclarationList.prototype;
|
|
2534
|
+
_proto.init = function init() {
|
|
2535
|
+
this.propList.length = 0;
|
|
2536
|
+
};
|
|
2537
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2538
|
+
var _this = this, children = _this.children, propList = _this.propList;
|
|
2539
|
+
if (children.length === 1) {
|
|
2540
|
+
var props = children[0].props;
|
|
2541
|
+
var propsLength = props.length;
|
|
2542
|
+
propList.length = propsLength;
|
|
2543
|
+
for(var i = 0; i < propsLength; i++){
|
|
2544
|
+
propList[i] = props[i];
|
|
2545
|
+
}
|
|
2546
|
+
} else {
|
|
2547
|
+
var listProps = children[0].propList;
|
|
2548
|
+
var declProps = children[1].props;
|
|
2549
|
+
var listPropLength = listProps.length;
|
|
2550
|
+
var declPropLength = declProps.length;
|
|
2551
|
+
propList.length = listPropLength + declPropLength;
|
|
2552
|
+
for(var i1 = 0; i1 < listPropLength; i1++){
|
|
2553
|
+
propList[i1] = listProps[i1];
|
|
2554
|
+
}
|
|
2555
|
+
for(var i2 = 0; i2 < declPropLength; i2++){
|
|
2556
|
+
propList[i2 + listPropLength] = declProps[i2];
|
|
2739
2557
|
}
|
|
2740
2558
|
}
|
|
2741
|
-
|
|
2559
|
+
};
|
|
2742
2560
|
return StructDeclarationList;
|
|
2743
2561
|
}(TreeNode);
|
|
2744
2562
|
ASTNode.StructDeclarationList = StructDeclarationList;
|
|
@@ -2748,50 +2566,44 @@
|
|
|
2748
2566
|
var StructDeclaration = /*#__PURE__*/ function(TreeNode) {
|
|
2749
2567
|
_inherits(StructDeclaration, TreeNode);
|
|
2750
2568
|
function StructDeclaration() {
|
|
2751
|
-
|
|
2569
|
+
var _this;
|
|
2570
|
+
_this = TreeNode.apply(this, arguments) || this, _this.props = [];
|
|
2571
|
+
return _this;
|
|
2752
2572
|
}
|
|
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
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
for(var i = 0; i < this.declaratorList.declaratorList.length; i++){
|
|
2785
|
-
var declarator1 = this.declaratorList.declaratorList[i];
|
|
2786
|
-
var typeInfo1 = new SymbolType(this.typeSpecifier.type, this.typeSpecifier.lexeme, declarator1.arraySpecifier);
|
|
2787
|
-
var prop1 = new StructProp(typeInfo1, declarator1.ident);
|
|
2788
|
-
ret.push(prop1);
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
return ret;
|
|
2573
|
+
var _proto = StructDeclaration.prototype;
|
|
2574
|
+
_proto.init = function init() {
|
|
2575
|
+
this.typeSpecifier = undefined;
|
|
2576
|
+
this.declaratorList = undefined;
|
|
2577
|
+
this.props.length = 0;
|
|
2578
|
+
};
|
|
2579
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2580
|
+
var _this = this, children = _this.children, props = _this.props;
|
|
2581
|
+
if (children.length === 3) {
|
|
2582
|
+
this.typeSpecifier = children[0];
|
|
2583
|
+
this.declaratorList = children[1];
|
|
2584
|
+
} else {
|
|
2585
|
+
this.typeSpecifier = children[1];
|
|
2586
|
+
this.declaratorList = children[2];
|
|
2587
|
+
}
|
|
2588
|
+
var firstChild = children[0];
|
|
2589
|
+
var _this_typeSpecifier = this.typeSpecifier, type = _this_typeSpecifier.type, lexeme = _this_typeSpecifier.lexeme;
|
|
2590
|
+
if (_instanceof(firstChild, LayoutQualifier)) {
|
|
2591
|
+
var declarator = children[2];
|
|
2592
|
+
var typeInfo = new SymbolType(type, lexeme);
|
|
2593
|
+
var prop = new StructProp(typeInfo, declarator.ident, firstChild.index);
|
|
2594
|
+
props.push(prop);
|
|
2595
|
+
} else {
|
|
2596
|
+
var declaratorList = this.declaratorList.declaratorList;
|
|
2597
|
+
var declaratorListLength = declaratorList.length;
|
|
2598
|
+
props.length = declaratorListLength;
|
|
2599
|
+
for(var i = 0; i < declaratorListLength; i++){
|
|
2600
|
+
var declarator1 = declaratorList[i];
|
|
2601
|
+
var typeInfo1 = new SymbolType(type, lexeme, declarator1.arraySpecifier);
|
|
2602
|
+
var prop1 = new StructProp(typeInfo1, declarator1.ident);
|
|
2603
|
+
props[i] = prop1;
|
|
2792
2604
|
}
|
|
2793
2605
|
}
|
|
2794
|
-
|
|
2606
|
+
};
|
|
2795
2607
|
return StructDeclaration;
|
|
2796
2608
|
}(TreeNode);
|
|
2797
2609
|
ASTNode.StructDeclaration = StructDeclaration;
|
|
@@ -2803,14 +2615,10 @@
|
|
|
2803
2615
|
function LayoutQualifier() {
|
|
2804
2616
|
return TreeNode.apply(this, arguments) || this;
|
|
2805
2617
|
}
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
return Number(this.children[4].lexeme);
|
|
2811
|
-
}
|
|
2812
|
-
}
|
|
2813
|
-
]);
|
|
2618
|
+
var _proto = LayoutQualifier.prototype;
|
|
2619
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2620
|
+
this.index = Number(this.children[4].lexeme);
|
|
2621
|
+
};
|
|
2814
2622
|
return LayoutQualifier;
|
|
2815
2623
|
}(TreeNode);
|
|
2816
2624
|
ASTNode.LayoutQualifier = LayoutQualifier;
|
|
@@ -2820,25 +2628,29 @@
|
|
|
2820
2628
|
var StructDeclaratorList = /*#__PURE__*/ function(TreeNode) {
|
|
2821
2629
|
_inherits(StructDeclaratorList, TreeNode);
|
|
2822
2630
|
function StructDeclaratorList() {
|
|
2823
|
-
|
|
2631
|
+
var _this;
|
|
2632
|
+
_this = TreeNode.apply(this, arguments) || this, _this.declaratorList = [];
|
|
2633
|
+
return _this;
|
|
2824
2634
|
}
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2635
|
+
var _proto = StructDeclaratorList.prototype;
|
|
2636
|
+
_proto.init = function init() {
|
|
2637
|
+
this.declaratorList.length = 0;
|
|
2638
|
+
};
|
|
2639
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2640
|
+
var _this = this, children = _this.children, declaratorList = _this.declaratorList;
|
|
2641
|
+
if (children.length === 1) {
|
|
2642
|
+
declaratorList.push(children[0]);
|
|
2643
|
+
} else {
|
|
2644
|
+
var list = children[0];
|
|
2645
|
+
var declarator = children[1];
|
|
2646
|
+
var listLength = list.declaratorList.length;
|
|
2647
|
+
declaratorList.length = listLength + 1;
|
|
2648
|
+
for(var i = 0; i < listLength; i++){
|
|
2649
|
+
declaratorList[i] = list.declaratorList[i];
|
|
2839
2650
|
}
|
|
2651
|
+
declaratorList[listLength] = declarator;
|
|
2840
2652
|
}
|
|
2841
|
-
|
|
2653
|
+
};
|
|
2842
2654
|
return StructDeclaratorList;
|
|
2843
2655
|
}(TreeNode);
|
|
2844
2656
|
ASTNode.StructDeclaratorList = StructDeclaratorList;
|
|
@@ -2850,20 +2662,15 @@
|
|
|
2850
2662
|
function StructDeclarator() {
|
|
2851
2663
|
return TreeNode.apply(this, arguments) || this;
|
|
2852
2664
|
}
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2862
|
-
get: function get() {
|
|
2863
|
-
return this.children[1];
|
|
2864
|
-
}
|
|
2865
|
-
}
|
|
2866
|
-
]);
|
|
2665
|
+
var _proto = StructDeclarator.prototype;
|
|
2666
|
+
_proto.init = function init() {
|
|
2667
|
+
this.arraySpecifier = undefined;
|
|
2668
|
+
};
|
|
2669
|
+
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2670
|
+
var children = this.children;
|
|
2671
|
+
this.ident = children[0];
|
|
2672
|
+
this.arraySpecifier = children[1];
|
|
2673
|
+
};
|
|
2867
2674
|
return StructDeclarator;
|
|
2868
2675
|
}(TreeNode);
|
|
2869
2676
|
ASTNode.StructDeclarator = StructDeclarator;
|
|
@@ -2939,28 +2746,15 @@
|
|
|
2939
2746
|
}
|
|
2940
2747
|
var _proto = VariableIdentifier.prototype;
|
|
2941
2748
|
_proto.semanticAnalyze = function semanticAnalyze(sa) {
|
|
2749
|
+
var _this_symbolInfo_dataType, _this_symbolInfo;
|
|
2942
2750
|
var token = this.children[0];
|
|
2751
|
+
this.lexeme = token.lexeme;
|
|
2943
2752
|
this.symbolInfo = sa.lookupSymbolBy(token.lexeme, ESymbolType.VAR);
|
|
2753
|
+
this.typeInfo = (_this_symbolInfo = this.symbolInfo) == null ? void 0 : (_this_symbolInfo_dataType = _this_symbolInfo.dataType) == null ? void 0 : _this_symbolInfo_dataType.type;
|
|
2944
2754
|
};
|
|
2945
2755
|
_proto.codeGen = function codeGen(visitor) {
|
|
2946
2756
|
return visitor.visitVariableIdentifier(this);
|
|
2947
2757
|
};
|
|
2948
|
-
_create_class(VariableIdentifier, [
|
|
2949
|
-
{
|
|
2950
|
-
key: "lexeme",
|
|
2951
|
-
get: function get() {
|
|
2952
|
-
return this.children[0].lexeme;
|
|
2953
|
-
}
|
|
2954
|
-
},
|
|
2955
|
-
{
|
|
2956
|
-
key: "typeInfo",
|
|
2957
|
-
get: function get() {
|
|
2958
|
-
var _this_symbolInfo;
|
|
2959
|
-
if (_instanceof(this.symbolInfo, VarSymbol)) return this.symbolInfo.dataType.type;
|
|
2960
|
-
return (_this_symbolInfo = this.symbolInfo) == null ? void 0 : _this_symbolInfo.type;
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
]);
|
|
2964
2758
|
return VariableIdentifier;
|
|
2965
2759
|
}(TreeNode);
|
|
2966
2760
|
ASTNode.VariableIdentifier = VariableIdentifier;
|
|
@@ -4420,7 +4214,7 @@
|
|
|
4420
4214
|
this.actionTable = actionTable;
|
|
4421
4215
|
this.gotoTable = gotoTable;
|
|
4422
4216
|
this.grammar = grammar;
|
|
4423
|
-
this.sematicAnalyzer = new
|
|
4217
|
+
this.sematicAnalyzer = new SemanticAnalyzer();
|
|
4424
4218
|
}
|
|
4425
4219
|
var _proto = ShaderTargetParser.prototype;
|
|
4426
4220
|
_proto.parse = function parse(tokens) {
|
|
@@ -4747,7 +4541,7 @@
|
|
|
4747
4541
|
var start = this._currentIndex;
|
|
4748
4542
|
var found = false;
|
|
4749
4543
|
for(var n = source.length; this._currentIndex < n;){
|
|
4750
|
-
if (LexerUtils.
|
|
4544
|
+
if (LexerUtils.isPpCharacters(source.charCodeAt(this._currentIndex))) {
|
|
4751
4545
|
this._advance();
|
|
4752
4546
|
found = true;
|
|
4753
4547
|
} else {
|
|
@@ -6802,7 +6596,7 @@
|
|
|
6802
6596
|
ShaderLab._shaderRangePool = ShaderLabUtils.createObjectPool(ShaderRange);
|
|
6803
6597
|
|
|
6804
6598
|
//@ts-ignore
|
|
6805
|
-
var version = "1.4.
|
|
6599
|
+
var version = "1.4.10";
|
|
6806
6600
|
var mode = "Release";
|
|
6807
6601
|
console.log("Galacean Engine ShaderLab Version: " + version + " | Mode: " + mode);
|
|
6808
6602
|
|