Commit 53fb4657 by John Kessenich

Change infrastructure to support constant folding across built-in functions, as…

Change infrastructure to support constant folding across built-in functions, as required by 1.2 semantics. Partially fleshed out with min/max and some trig functions. Still have to complete all operations. git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@20806 e7fa87d3-cd2b-0410-9028-fcbf551c1848
parent 3f3e0ad3
...@@ -18,5 +18,5 @@ void main() ...@@ -18,5 +18,5 @@ void main()
vec4 e[constInt + uniformInt]; // error vec4 e[constInt + uniformInt]; // error
vec4 f[uniformInt + constInt]; // error vec4 f[uniformInt + constInt]; // error
vec4 g[sin(3.2)]; // okay vec4 g[int(sin(0.3)) + 1]; // okay
} }
#version 430
const int a = 1;
const int b = 2;
const int c = a + b; // 3
const int d = c - a; // 2
const float e = float(d); // 2.0
const float f = e * float(c); // 6.0
const float g = f / float(d); // 3.0
in vec4 inv;
out vec4 FragColor;
void main()
{
vec4 dx = dFdx(inv);
const ivec4 v = ivec4(a, b, c, d);
vec4 array2[v.y]; // 2
const ivec4 u = ~v;
const float h = degrees(g); // 171.88
FragColor = vec4(e, f, g, h); // 2, 6, 3, 171.88
vec4 array3[c]; // 3
vec4 arrayMax[int(max(float(array2.length()), float(array3.length())))];
vec4 arrayMin[int(min(float(array2.length()), float(array3.length())))];
FragColor = vec4(arrayMax.length(), arrayMin.length(), sin(3.14), cos(3.14)); // 3, 2, .00159, -.999
}
...@@ -26,4 +26,5 @@ comment.frag ...@@ -26,4 +26,5 @@ comment.frag
330.frag 330.frag
330comp.frag 330comp.frag
constErrors.frag constErrors.frag
constFold.frag
errors.frag errors.frag
...@@ -147,6 +147,7 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command> ...@@ -147,6 +147,7 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command>
</ResourceCompile> </ResourceCompile>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="glslang\MachineIndependent\Constant.cpp" />
<ClCompile Include="glslang\MachineIndependent\gen_glslang.cpp" /> <ClCompile Include="glslang\MachineIndependent\gen_glslang.cpp" />
<ClCompile Include="glslang\MachineIndependent\glslang_tab.cpp" /> <ClCompile Include="glslang\MachineIndependent\glslang_tab.cpp" />
<ClCompile Include="glslang\MachineIndependent\InfoSink.cpp" /> <ClCompile Include="glslang\MachineIndependent\InfoSink.cpp" />
......
...@@ -106,6 +106,9 @@ ...@@ -106,6 +106,9 @@
<ClCompile Include="glslang\MachineIndependent\Versions.cpp"> <ClCompile Include="glslang\MachineIndependent\Versions.cpp">
<Filter>Machine Independent</Filter> <Filter>Machine Independent</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="glslang\MachineIndependent\Constant.cpp">
<Filter>Machine Independent</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="glslang\MachineIndependent\Initialize.h"> <ClInclude Include="glslang\MachineIndependent\Initialize.h">
......
...@@ -406,6 +406,7 @@ public: ...@@ -406,6 +406,7 @@ public:
virtual TIntermConstantUnion* getAsConstantUnion() { return this; } virtual TIntermConstantUnion* getAsConstantUnion() { return this; }
virtual void traverse(TIntermTraverser* ); virtual void traverse(TIntermTraverser* );
virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&); virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
protected: protected:
constUnion *unionArrayPointer; constUnion *unionArrayPointer;
}; };
......
...@@ -1161,33 +1161,12 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu ...@@ -1161,33 +1161,12 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, TPu
return false; return false;
} }
bool TParseContext::areAllChildConst(TIntermAggregate* aggrNode)
{
if (!aggrNode->isConstructor())
return false;
bool allConstant = true;
// check if all the child nodes are constants so that they can be inserted into
// the parent node
if (aggrNode) {
TIntermSequence &childSequenceVector = aggrNode->getSequence() ;
for (TIntermSequence::iterator p = childSequenceVector.begin();
p != childSequenceVector.end(); p++) {
if (!(*p)->getAsTyped()->getAsConstantUnion())
return false;
}
}
return allConstant;
}
// This function is used to test for the correctness of the parameters passed to various constructor functions // This function is used to test for the correctness of the parameters passed to various constructor functions
// and also convert them to the right datatype if it is allowed and required. // and also convert them to the right datatype if it is allowed and required.
// //
// Returns 0 for an error or the constructed node (aggregate or typed) for no error. // Returns 0 for an error or the constructed node (aggregate or typed) for no error.
// //
TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type, TOperator op, TFunction* fnCall, TSourceLoc line) TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType& type, TOperator op, TFunction* fnCall, TSourceLoc line)
{ {
if (node == 0) if (node == 0)
return 0; return 0;
...@@ -1196,10 +1175,10 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type ...@@ -1196,10 +1175,10 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
TTypeList::iterator memberTypes; TTypeList::iterator memberTypes;
if (op == EOpConstructStruct) if (op == EOpConstructStruct)
memberTypes = type->getStruct()->begin(); memberTypes = type.getStruct()->begin();
TType elementType = *type; TType elementType = type;
if (type->isArray()) if (type.isArray())
elementType.dereference(); elementType.dereference();
bool singleArg; bool singleArg;
...@@ -1215,18 +1194,15 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type ...@@ -1215,18 +1194,15 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
if (singleArg) { if (singleArg) {
// If structure constructor or array constructor is being called // If structure constructor or array constructor is being called
// for only one parameter inside the structure, we need to call constructStruct function once. // for only one parameter inside the structure, we need to call constructStruct function once.
if (type->isArray()) if (type.isArray())
newNode = constructStruct(node, &elementType, 1, node->getLine(), false); newNode = constructStruct(node, elementType, 1, node->getLine());
else if (op == EOpConstructStruct) else if (op == EOpConstructStruct)
newNode = constructStruct(node, (*memberTypes).type, 1, node->getLine(), false); newNode = constructStruct(node, *(*memberTypes).type, 1, node->getLine());
else else
newNode = constructBuiltIn(type, op, node, node->getLine(), false); newNode = constructBuiltIn(type, op, node, node->getLine(), false);
if (newNode && newNode->getAsAggregate()) { if (newNode && (type.isArray() || op == EOpConstructStruct))
TIntermTyped* constConstructor = foldConstConstructor(newNode->getAsAggregate(), *type); newNode = intermediate.setAggregateOperator(newNode, EOpConstructStruct, type, line);
if (constConstructor)
return constConstructor;
}
return newNode; return newNode;
} }
...@@ -1246,10 +1222,10 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type ...@@ -1246,10 +1222,10 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
for (TIntermSequence::iterator p = sequenceVector.begin(); for (TIntermSequence::iterator p = sequenceVector.begin();
p != sequenceVector.end(); p++, paramCount++) { p != sequenceVector.end(); p++, paramCount++) {
if (type->isArray()) if (type.isArray())
newNode = constructStruct(*p, &elementType, paramCount+1, node->getLine(), true); newNode = constructStruct(*p, elementType, paramCount+1, node->getLine());
else if (op == EOpConstructStruct) else if (op == EOpConstructStruct)
newNode = constructStruct(*p, (memberTypes[paramCount]).type, paramCount+1, node->getLine(), true); newNode = constructStruct(*p, *(memberTypes[paramCount]).type, paramCount+1, node->getLine());
else else
newNode = constructBuiltIn(type, op, *p, node->getLine(), true); newNode = constructBuiltIn(type, op, *p, node->getLine(), true);
...@@ -1259,36 +1235,11 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type ...@@ -1259,36 +1235,11 @@ TIntermTyped* TParseContext::addConstructor(TIntermNode* node, const TType* type
} }
} }
TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op, line); TIntermTyped* constructor = intermediate.setAggregateOperator(aggrNode, op, type, line);
TIntermTyped* constConstructor = foldConstConstructor(constructor->getAsAggregate(), *type);
if (constConstructor)
return constConstructor;
return constructor; return constructor;
} }
TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, const TType& type)
{
bool canBeFolded = areAllChildConst(aggrNode);
aggrNode->setType(type);
if (canBeFolded) {
bool returnVal = false;
constUnion* unionArray = new constUnion[type.getObjectSize()];
if (aggrNode->getSequence().size() == 1) {
returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), symbolTable, type, true);
}
else {
returnVal = intermediate.parseConstTree(aggrNode->getLine(), aggrNode, unionArray, aggrNode->getOp(), symbolTable, type);
}
if (returnVal)
return 0;
return intermediate.addConstantUnion(unionArray, type, aggrNode->getLine());
}
return 0;
}
// Function for constructor implementation. Calls addUnaryMath with appropriate EOp value // Function for constructor implementation. Calls addUnaryMath with appropriate EOp value
// for the parameter to the constructor (passed to this function). Essentially, it converts // for the parameter to the constructor (passed to this function). Essentially, it converts
// the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a // the parameter types correctly. If a constructor expects an int (like ivec2) and is passed a
...@@ -1296,7 +1247,7 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co ...@@ -1296,7 +1247,7 @@ TIntermTyped* TParseContext::foldConstConstructor(TIntermAggregate* aggrNode, co
// //
// Returns 0 for an error or the constructed node. // Returns 0 for an error or the constructed node.
// //
TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, TIntermNode* node, TSourceLoc line, bool subset) TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, TIntermNode* node, TSourceLoc line, bool subset)
{ {
TIntermTyped* newNode; TIntermTyped* newNode;
TOperator basicOp; TOperator basicOp;
...@@ -1368,11 +1319,11 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T ...@@ -1368,11 +1319,11 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
// //
// Otherwise, skip out early. // Otherwise, skip out early.
if (subset || newNode != node && newNode->getType() == *type) if (subset || newNode != node && newNode->getType() == type)
return newNode; return newNode;
// setAggregateOperator will insert a new node for the constructor, as needed. // setAggregateOperator will insert a new node for the constructor, as needed.
return intermediate.setAggregateOperator(newNode, op, line); return intermediate.setAggregateOperator(newNode, op, type, line);
} }
// This function tests for the type of the parameters to the structures constructors. Raises // This function tests for the type of the parameters to the structures constructors. Raises
...@@ -1380,21 +1331,18 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T ...@@ -1380,21 +1331,18 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType* type, TOperator op, T
// //
// Returns 0 for an error or the input node itself if the expected and the given parameter types match. // Returns 0 for an error or the input node itself if the expected and the given parameter types match.
// //
TIntermTyped* TParseContext::constructStruct(TIntermNode* node, TType* type, int paramCount, TSourceLoc line, bool subset) TIntermTyped* TParseContext::constructStruct(TIntermNode* node, const TType& type, int paramCount, TSourceLoc line)
{ {
TIntermNode* converted = intermediate.addConversion(EOpConstructStruct, *type, node->getAsTyped()); TIntermTyped* converted = intermediate.addConversion(EOpConstructStruct, type, node->getAsTyped());
if (converted->getAsTyped()->getType() == *type) { if (! converted || converted->getType() != type) {
if (subset)
return converted->getAsTyped();
else
return intermediate.setAggregateOperator(converted->getAsTyped(), EOpConstructStruct, line);
} else {
error(line, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount, error(line, "", "constructor", "cannot convert parameter %d from '%s' to '%s'", paramCount,
node->getAsTyped()->getType().getCompleteTypeString().c_str(), type->getCompleteTypeString().c_str()); node->getAsTyped()->getType().getCompleteTypeString().c_str(), type.getCompleteTypeString().c_str());
recover(); recover();
}
return 0; return 0;
}
return converted;
} }
// //
......
...@@ -130,11 +130,9 @@ struct TParseContext { ...@@ -130,11 +130,9 @@ struct TParseContext {
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0); const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
bool areAllChildConst(TIntermAggregate* aggrNode); TIntermTyped* addConstructor(TIntermNode*, const TType&, TOperator, TFunction*, TSourceLoc);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc); TIntermTyped* constructStruct(TIntermNode*, const TType&, int, TSourceLoc);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* constructBuiltIn(const TType&, TOperator, TIntermNode*, TSourceLoc, bool subset);
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
......
...@@ -105,7 +105,7 @@ int yy_input(char* buf, int max_size); ...@@ -105,7 +105,7 @@ int yy_input(char* buf, int max_size);
%% %%
<*>"//"[^\n]*"\n" { /* ?? carriage and/or line-feed? */ }; <*>"//"[^\n]*"\n" { /* CPP should have taken care of this */ };
"attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); } // TODO ES 30 reserved "attribute" { pyylval->lex.line = yylineno; return(ATTRIBUTE); } // TODO ES 30 reserved
"const" { pyylval->lex.line = yylineno; return(CONST); } "const" { pyylval->lex.line = yylineno; return(CONST); }
......
...@@ -336,6 +336,7 @@ postfix_expression ...@@ -336,6 +336,7 @@ postfix_expression
$$ = parseContext.intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line); $$ = parseContext.intermediate.addIndex(EOpIndexIndirect, $1, $3, $2.line);
} }
} }
if ($$ == 0) { if ($$ == 0) {
constUnion *unionArray = new constUnion[1]; constUnion *unionArray = new constUnion[1];
unionArray->setFConst(0.0f); unionArray->setFConst(0.0f);
...@@ -344,8 +345,7 @@ postfix_expression ...@@ -344,8 +345,7 @@ postfix_expression
TType newType = $1->getType(); TType newType = $1->getType();
newType.dereference(); newType.dereference();
$$->setType(newType); $$->setType(newType);
//?? why wouldn't the code above get the type right? // TODO: testing: write a set of dereference tests
//?? write a dereference test
} }
} }
| function_call { | function_call {
...@@ -511,14 +511,13 @@ function_call ...@@ -511,14 +511,13 @@ function_call
// //
// It's a constructor, of type 'type'. // It's a constructor, of type 'type'.
// //
$$ = parseContext.addConstructor($1.intermNode, &type, op, fnCall, $1.line); $$ = parseContext.addConstructor($1.intermNode, type, op, fnCall, $1.line);
} }
if ($$ == 0) { if ($$ == 0) {
parseContext.recover(); parseContext.recover();
$$ = parseContext.intermediate.setAggregateOperator(0, op, $1.line); $$ = parseContext.intermediate.setAggregateOperator(0, op, type, $1.line);
} }
$$->setType(type);
} else { } else {
// //
// Not a constructor. Find it in the symbol table. // Not a constructor. Find it in the symbol table.
...@@ -539,6 +538,8 @@ function_call ...@@ -539,6 +538,8 @@ function_call
if (fnCandidate->getParamCount() == 1) { if (fnCandidate->getParamCount() == 1) {
// //
// Treat it like a built-in unary operator. // Treat it like a built-in unary operator.
// addUnaryMath() should get the type correct on its own;
// including constness (which would differ from the prototype).
// //
$$ = parseContext.intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext.symbolTable); $$ = parseContext.intermediate.addUnaryMath(op, $1.intermNode, 0, parseContext.symbolTable);
if ($$ == 0) { if ($$ == 0) {
...@@ -548,13 +549,12 @@ function_call ...@@ -548,13 +549,12 @@ function_call
YYERROR; YYERROR;
} }
} else { } else {
$$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, op, $1.line); $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, op, fnCandidate->getReturnType(), $1.line);
} }
} else { } else {
// This is a real function call // This is a real function call
$$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, $1.line); $$ = parseContext.intermediate.setAggregateOperator($1.intermAggregate, EOpFunctionCall, fnCandidate->getReturnType(), $1.line);
$$->setType(fnCandidate->getReturnType());
// this is how we know whether the given function is a builtIn function or a user defined function // this is how we know whether the given function is a builtIn function or a user defined function
// if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also // if builtIn == false, it's a userDefined -> could be an overloaded builtIn function also
...@@ -576,7 +576,6 @@ function_call ...@@ -576,7 +576,6 @@ function_call
qualifierList.push_back(qual); qualifierList.push_back(qual);
} }
} }
$$->setType(fnCandidate->getReturnType());
} else { } else {
// error message was put out by PaFindFunction() // error message was put out by PaFindFunction()
// Put on a dummy node for error recovery // Put on a dummy node for error recovery
...@@ -2991,7 +2990,7 @@ function_definition ...@@ -2991,7 +2990,7 @@ function_definition
paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, $1.line), $1.line); paramNodes = parseContext.intermediate.growAggregate(paramNodes, parseContext.intermediate.addSymbol(0, "", *param.type, $1.line), $1.line);
} }
} }
parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, $1.line); parseContext.intermediate.setAggregateOperator(paramNodes, EOpParameters, TType(EbtVoid), $1.line);
$1.intermAggregate = paramNodes; $1.intermAggregate = paramNodes;
parseContext.loopNestingLevel = 0; parseContext.loopNestingLevel = 0;
} }
...@@ -3003,9 +3002,8 @@ function_definition ...@@ -3003,9 +3002,8 @@ function_definition
} }
parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]); parseContext.symbolTable.pop(&parseContext.defaultPrecision[0]);
$$ = parseContext.intermediate.growAggregate($1.intermAggregate, $3, 0); $$ = parseContext.intermediate.growAggregate($1.intermAggregate, $3, 0);
parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.line); parseContext.intermediate.setAggregateOperator($$, EOpFunction, $1.function->getReturnType(), $1.line);
$$->getAsAggregate()->setName($1.function->getMangledName().c_str()); $$->getAsAggregate()->setName($1.function->getMangledName().c_str());
$$->getAsAggregate()->setType($1.function->getReturnType());
// store the pragma information for debug and optimize and other vendor specific // store the pragma information for debug and optimize and other vendor specific
// information. This information can be queried from the parse tree // information. This information can be queried from the parse tree
......
...@@ -63,14 +63,17 @@ public: ...@@ -63,14 +63,17 @@ public:
bool canImplicitlyPromote(TBasicType from, TBasicType to); bool canImplicitlyPromote(TBasicType from, TBasicType to);
TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc); TIntermAggregate* growAggregate(TIntermNode* left, TIntermNode* right, TSourceLoc);
TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc); TIntermAggregate* makeAggregate(TIntermNode* node, TSourceLoc);
TIntermAggregate* setAggregateOperator(TIntermNode*, TOperator, TSourceLoc); TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, TSourceLoc);
bool areAllChildConst(TIntermAggregate* aggrNode);
TIntermTyped* fold(TIntermAggregate* aggrNode);
TIntermTyped* foldConstructor(TIntermAggregate* aggrNode);
TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc); TIntermNode* addSelection(TIntermTyped* cond, TIntermNodePair code, TSourceLoc);
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc); TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc); TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc); TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc); TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ; TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TSymbolTable&, TType, bool singleConstantParam = false); bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, TType, bool singleConstantParam = false);
TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc); TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
TIntermBranch* addBranch(TOperator, TSourceLoc); TIntermBranch* addBranch(TOperator, TSourceLoc);
TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc); TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
// //
class TConstTraverser : public TIntermTraverser { class TConstTraverser : public TIntermTraverser {
public: public:
TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TSymbolTable& symTable, TType& t) : unionArray(cUnion), type(t), TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, TType& t) : unionArray(cUnion), type(t),
constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), symbolTable(symTable), error(false), isMatrix(false), constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false),
matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;} matrixCols(0), matrixRows(0) { index = 0; tOp = EOpNull;}
int index ; int index ;
constUnion *unionArray; constUnion *unionArray;
...@@ -50,7 +50,6 @@ public: ...@@ -50,7 +50,6 @@ public:
TOperator constructorType; TOperator constructorType;
bool singleConstantParam; bool singleConstantParam;
TInfoSink& infoSink; TInfoSink& infoSink;
TSymbolTable& symbolTable;
bool error; bool error;
int size; // size of the constructor ( 4 for vec4) int size; // size of the constructor ( 4 for vec4)
bool isMatrix; bool isMatrix;
...@@ -256,12 +255,12 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it) ...@@ -256,12 +255,12 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
// Individual functions can be initialized to 0 to skip processing of that // Individual functions can be initialized to 0 to skip processing of that
// type of node. It's children will still be processed. // type of node. It's children will still be processed.
// //
bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TSymbolTable& symbolTable, TType t, bool singleConstantParam) bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, TType t, bool singleConstantParam)
{ {
if (root == 0) if (root == 0)
return false; return false;
TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, symbolTable, t); TConstTraverser it(unionArray, singleConstantParam, constructorType, infoSink, t);
it.visitAggregate = ParseAggregate; it.visitAggregate = ParseAggregate;
it.visitBinary = ParseBinary; it.visitBinary = ParseBinary;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment