Permalink
Browse files

refactor; add ir_add_symbol that takes TVariable and does setGlobal

  • Loading branch information...
1 parent c560255 commit 82dab367344d42649baef8f88cfdd3676701f9bf @aras-p committed Oct 26, 2012
@@ -23,14 +23,14 @@ static TPrecision GetHigherPrecision (TPrecision left, TPrecision right) {
// Add a terminal node for an identifier in an expression.
-TIntermSymbol* ir_add_symbol(int id, const TString& name, const TType& type, TSourceLoc line)
+TIntermSymbol* ir_add_symbol(const TVariable* var, TSourceLoc line)
{
- TIntermSymbol* node = new TIntermSymbol(id, name, type);
- node->setLine(line);
+ TIntermSymbol* node = ir_add_symbol_internal(var->getUniqueId(), var->getName(), var->getInfo(), var->getType(), line);
+ node->setGlobal(var->isGlobal());
return node;
}
-TIntermSymbol* ir_add_symbol(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line)
+TIntermSymbol* ir_add_symbol_internal(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line)
{
TIntermSymbol* node = new TIntermSymbol(id, name, info, type);
node->setLine(line);
@@ -569,8 +569,7 @@ TIntermDeclaration* ir_add_declaration(TIntermSymbol* symbol, TIntermTyped* init
TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initializer, TSourceLoc line, TInfoSink& infoSink)
{
TVariable* var = static_cast<TVariable*>(symbol);
- TIntermSymbol* sym = ir_add_symbol(var->getUniqueId(), var->getName(), var->getType(), line);
- sym->setGlobal(symbol->isGlobal());
+ TIntermSymbol* sym = ir_add_symbol(var, line);
return ir_add_declaration(sym, initializer, line, infoSink);
}
@@ -579,8 +578,7 @@ TIntermDeclaration* ir_add_declaration(TSymbol* symbol, TIntermTyped* initialize
TIntermDeclaration* ir_grow_declaration(TIntermDeclaration* declaration, TSymbol* symbol, TIntermTyped* initializer, TInfoSink& infoSink)
{
TVariable* var = static_cast<TVariable*>(symbol);
- TIntermSymbol* sym = ir_add_symbol(var->getUniqueId(), var->getName(), var->getType(), var->getType().getLine());
- sym->setGlobal(symbol->isGlobal());
+ TIntermSymbol* sym = ir_add_symbol(var, var->getType().getLine());
return ir_grow_declaration(declaration, sym, initializer, infoSink);
}
@@ -1349,8 +1349,7 @@ bool TParseContext::executeInitializer(TSourceLoc line, TString& identifier, con
}
}
- TIntermSymbol* intermSymbol = ir_add_symbol(variable->getUniqueId(), variable->getName(), variable->getInfo(), variable->getType(), line);
- intermSymbol->setGlobal(variable->isGlobal());
+ TIntermSymbol* intermSymbol = ir_add_symbol(variable, line);
intermNode = intermSymbol;
return false;
}
@@ -199,11 +199,7 @@ variable_identifier
}
else
{
- TIntermSymbol* sym = ir_add_symbol(variable->getUniqueId(),
- variable->getName(),
- variable->getInfo(),
- variable->getType(), $1.line);
- sym->setGlobal(variable->isGlobal());
+ TIntermSymbol* sym = ir_add_symbol(variable, $1.line);
$$ = sym;
}
}
@@ -2230,13 +2226,10 @@ function_definition
//
paramNodes = ir_grow_aggregate(
paramNodes,
- ir_add_symbol(variable->getUniqueId(),
- variable->getName(),
- variable->getInfo(),
- variable->getType(), $1.line),
+ ir_add_symbol(variable, $1.line),
$1.line);
} else {
- paramNodes = ir_grow_aggregate(paramNodes, ir_add_symbol(0, "", param.info, *param.type, $1.line), $1.line);
+ paramNodes = ir_grow_aggregate(paramNodes, ir_add_symbol_internal(0, "", param.info, *param.type, $1.line), $1.line);
}
}
ir_set_aggregate_op(paramNodes, EOpParameters, $1.line);
@@ -21,8 +21,8 @@ struct TVectorFields
//
class TInfoSink;
-TIntermSymbol* ir_add_symbol(int Id, const TString&, const TType&, TSourceLoc);
-TIntermSymbol* ir_add_symbol(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line);
+TIntermSymbol* ir_add_symbol(const TVariable* var, TSourceLoc);
+TIntermSymbol* ir_add_symbol_internal(int id, const TString& name, const TTypeInfo *info, const TType& type, TSourceLoc line);
TIntermConstant* ir_add_constant(const TType&, TSourceLoc);
TIntermTyped* ir_add_index(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
TIntermTyped* ir_add_comma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);

0 comments on commit 82dab36

Please sign in to comment.