mirror of
https://github.com/libretro/glslang.git
synced 2024-12-12 10:16:01 +00:00
Front-end infrastructure: simplify and localize creating symbol nodes, reducing replication.
This commit is contained in:
parent
2cc221ade3
commit
952543e757
@ -61,27 +61,35 @@ namespace glslang {
|
||||
// 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);
|
||||
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);
|
||||
|
||||
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)
|
||||
{
|
||||
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.
|
||||
//
|
||||
@ -1018,8 +1026,7 @@ void TIntermediate::addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymb
|
||||
const TAnonMember* anon = symbol.getAsAnonMember();
|
||||
variable = &anon->getAnonContainer();
|
||||
}
|
||||
TIntermSymbol* node = new TIntermSymbol(variable->getUniqueId(), variable->getName(), variable->getType());
|
||||
node->setConstArray(variable->getConstArray());
|
||||
TIntermSymbol* node = addSymbol(*variable);
|
||||
linkage = growAggregate(linkage, node);
|
||||
}
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ TIntermAggregate* TParseContext::handleFunctionDefinition(const TSourceLoc& loc,
|
||||
loc);
|
||||
}
|
||||
} 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);
|
||||
loopNestingLevel = 0;
|
||||
|
@ -162,10 +162,10 @@ public:
|
||||
int getNumErrors() const { return numErrors; }
|
||||
void addPushConstantCount() { ++numPushConstants; }
|
||||
bool isRecursive() const { return recursive; }
|
||||
|
||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, const TSourceLoc&);
|
||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TSourceLoc&);
|
||||
|
||||
TIntermSymbol* addSymbol(const TVariable&);
|
||||
TIntermSymbol* addSymbol(const TVariable&, const TSourceLoc&);
|
||||
TIntermSymbol* addSymbol(const TType&, const TSourceLoc&);
|
||||
TIntermTyped* addConversion(TOperator, const TType&, TIntermTyped*) const;
|
||||
TIntermTyped* addBinaryMath(TOperator, 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);
|
||||
|
||||
protected:
|
||||
TIntermSymbol* addSymbol(int Id, const TString&, const TType&, const TConstUnionArray&, const TSourceLoc&);
|
||||
void error(TInfoSink& infoSink, const char*);
|
||||
void mergeBodies(TInfoSink&, TIntermSequence& globals, const TIntermSequence& unitGlobals);
|
||||
void mergeLinkerObjects(TInfoSink&, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects);
|
||||
|
Loading…
Reference in New Issue
Block a user