Front-end infrastructure: simplify and localize creating symbol nodes, reducing replication.
This commit is contained in:
parent
2cc221ade3
commit
952543e757
3 changed files with 22 additions and 14 deletions
|
|
@ -61,27 +61,35 @@ namespace glslang {
|
||||||
// Returns the added node.
|
// Returns the added node.
|
||||||
//
|
//
|
||||||
|
|
||||||
TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, const TSourceLoc& loc)
|
TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, const TConstUnionArray& constArray, const TSourceLoc& loc)
|
||||||
{
|
{
|
||||||
TIntermSymbol* node = new TIntermSymbol(id, name, type);
|
TIntermSymbol* node = new TIntermSymbol(id, name, type);
|
||||||
node->setLoc(loc);
|
node->setLoc(loc);
|
||||||
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
|
|
||||||
TIntermSymbol* TIntermediate::addSymbol(int id, const TString& name, const TType& type, const TConstUnionArray& constArray, const TSourceLoc& loc)
|
|
||||||
{
|
|
||||||
TIntermSymbol* node = addSymbol(id, name, type, loc);
|
|
||||||
node->setConstArray(constArray);
|
node->setConstArray(constArray);
|
||||||
|
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TIntermSymbol* TIntermediate::addSymbol(const TVariable& variable)
|
||||||
|
{
|
||||||
|
glslang::TSourceLoc loc; // just a null location
|
||||||
|
loc.init();
|
||||||
|
|
||||||
|
return addSymbol(variable, loc);
|
||||||
|
}
|
||||||
|
|
||||||
TIntermSymbol* TIntermediate::addSymbol(const TVariable& variable, const TSourceLoc& loc)
|
TIntermSymbol* TIntermediate::addSymbol(const TVariable& variable, const TSourceLoc& loc)
|
||||||
{
|
{
|
||||||
return addSymbol(variable.getUniqueId(), variable.getName(), variable.getType(), variable.getConstArray(), loc);
|
return addSymbol(variable.getUniqueId(), variable.getName(), variable.getType(), variable.getConstArray(), loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TIntermSymbol* TIntermediate::addSymbol(const TType& type, const TSourceLoc& loc)
|
||||||
|
{
|
||||||
|
TConstUnionArray unionArray; // just a null constant
|
||||||
|
|
||||||
|
return addSymbol(0, "", type, unionArray, loc);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Connect two nodes with a new parent that does a binary operation on the nodes.
|
// Connect two nodes with a new parent that does a binary operation on the nodes.
|
||||||
//
|
//
|
||||||
|
|
@ -1018,8 +1026,7 @@ void TIntermediate::addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymb
|
||||||
const TAnonMember* anon = symbol.getAsAnonMember();
|
const TAnonMember* anon = symbol.getAsAnonMember();
|
||||||
variable = &anon->getAnonContainer();
|
variable = &anon->getAnonContainer();
|
||||||
}
|
}
|
||||||
TIntermSymbol* node = new TIntermSymbol(variable->getUniqueId(), variable->getName(), variable->getType());
|
TIntermSymbol* node = addSymbol(*variable);
|
||||||
node->setConstArray(variable->getConstArray());
|
|
||||||
linkage = growAggregate(linkage, node);
|
linkage = growAggregate(linkage, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1017,7 +1017,7 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
|
||||||
loc);
|
loc);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
paramNodes = intermediate.growAggregate(paramNodes, intermediate.addSymbol(0, "", *param.type, loc), loc);
|
paramNodes = intermediate.growAggregate(paramNodes, intermediate.addSymbol(*param.type, loc), loc);
|
||||||
}
|
}
|
||||||
intermediate.setAggregateOperator(paramNodes, EOpParameters, TType(EbtVoid), loc);
|
intermediate.setAggregateOperator(paramNodes, EOpParameters, TType(EbtVoid), loc);
|
||||||
loopNestingLevel = 0;
|
loopNestingLevel = 0;
|
||||||
|
|
|
||||||
|
|
@ -163,9 +163,9 @@ public:
|
||||||
void addPushConstantCount() { ++numPushConstants; }
|
void addPushConstantCount() { ++numPushConstants; }
|
||||||
bool isRecursive() const { return recursive; }
|
bool isRecursive() const { return recursive; }
|
||||||
|
|
||||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, const TSourceLoc&);
|
TIntermSymbol* addSymbol(const TVariable&);
|
||||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&);
|
|
||||||
TIntermSymbol* addSymbol(const TVariable&, const TSourceLoc&);
|
TIntermSymbol* addSymbol(const TVariable&, const TSourceLoc&);
|
||||||
|
TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
|
||||||
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const;
|
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const;
|
||||||
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||||
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
|
||||||
|
|
@ -326,6 +326,7 @@ public:
|
||||||
static int getBaseAlignment(const TType&, int& size, int& stride, bool std140, bool rowMajor);
|
static int getBaseAlignment(const TType&, int& size, int& stride, bool std140, bool rowMajor);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, const TSourceLoc&);
|
||||||
void error(TInfoSink& infoSink, const char*);
|
void error(TInfoSink& infoSink, const char*);
|
||||||
void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals);
|
void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals);
|
||||||
void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects);
|
void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue