Removed unnecessary member variables from TIntermAggregate. Replaced operator overloading with a proper function in TFunction.
Review URL: http://codereview.appspot.com/2137043
git-svn-id: https://angleproject.googlecode.com/svn/trunk@414 736b8ea6-26fd-11df-bfd4-992fa37f6226
diff --git a/src/compiler/ParseHelper.cpp b/src/compiler/ParseHelper.cpp
index 8fab970..3c61615 100644
--- a/src/compiler/ParseHelper.cpp
+++ b/src/compiler/ParseHelper.cpp
@@ -471,17 +471,18 @@
bool matrixInMatrix = false;
bool arrayArg = false;
for (int i = 0; i < function.getParamCount(); ++i) {
- size += function[i].type->getObjectSize();
+ const TParameter& param = function.getParam(i);
+ size += param.type->getObjectSize();
- if (constructingMatrix && function[i].type->isMatrix())
+ if (constructingMatrix && param.type->isMatrix())
matrixInMatrix = true;
if (full)
overFull = true;
if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
full = true;
- if (function[i].type->getQualifier() != EvqConst)
+ if (param.type->getQualifier() != EvqConst)
constType = false;
- if (function[i].type->isArray())
+ if (param.type->isArray())
arrayArg = true;
}
diff --git a/src/compiler/SymbolTable.h b/src/compiler/SymbolTable.h
index b1a80b5..7476407 100644
--- a/src/compiler/SymbolTable.h
+++ b/src/compiler/SymbolTable.h
@@ -161,9 +161,8 @@
void setDefined() { defined = true; }
bool isDefined() { return defined; }
- int getParamCount() const { return static_cast<int>(parameters.size()); }
- TParameter& operator [](int i) { return parameters[i]; }
- const TParameter& operator [](int i) const { return parameters[i]; }
+ int getParamCount() const { return static_cast<int>(parameters.size()); }
+ const TParameter& getParam(int i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const;
TFunction(const TFunction&, TStructureMap& remapper);
diff --git a/src/compiler/glslang.y b/src/compiler/glslang.y
index 4a7a239..1044873 100644
--- a/src/compiler/glslang.y
+++ b/src/compiler/glslang.y
@@ -537,16 +537,14 @@
$$->getAsAggregate()->setName(fnCandidate->getMangledName());
TQualifier qual;
- TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier();
for (int i = 0; i < fnCandidate->getParamCount(); ++i) {
- qual = (*fnCandidate)[i].type->getQualifier();
+ qual = fnCandidate->getParam(i).type->getQualifier();
if (qual == EvqOut || qual == EvqInOut) {
if (parseContext->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) {
parseContext->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
parseContext->recover();
}
}
- qualifierList.push_back(qual);
}
}
$$->setType(fnCandidate->getReturnType());
@@ -989,7 +987,7 @@
for (int i = 0; i < function.getParamCount(); i++)
{
- TParameter ¶m = function[i];
+ const TParameter ¶m = function.getParam(i);
if (param.name != 0)
{
TVariable *variable = new TVariable(param.name, *param.type);
@@ -1033,8 +1031,8 @@
parseContext->recover();
}
for (int i = 0; i < prevDec->getParamCount(); ++i) {
- if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) {
- parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), "");
+ if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) {
+ parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), "");
parseContext->recover();
}
}
@@ -1992,8 +1990,8 @@
function_definition
: function_prototype {
- TFunction& function = *($1.function);
- TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find(function.getMangledName()));
+ TFunction* function = $1.function;
+ TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find(function->getMangledName()));
//
// Note: 'prevDec' could be 'function' if this is the first time we've seen function
// as it would have just been put in the symbol table. Otherwise, we're looking up
@@ -2003,7 +2001,7 @@
//
// Then this function already has a body.
//
- parseContext->error($1.line, "function already has a body", function.getName().c_str(), "");
+ parseContext->error($1.line, "function already has a body", function->getName().c_str(), "");
parseContext->recover();
}
prevDec->setDefined();
@@ -2011,13 +2009,13 @@
//
// Raise error message if main function takes any parameters or return anything other than void
//
- if (function.getName() == "main") {
- if (function.getParamCount() > 0) {
- parseContext->error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), "");
+ if (function->getName() == "main") {
+ if (function->getParamCount() > 0) {
+ parseContext->error($1.line, "function cannot take any parameter(s)", function->getName().c_str(), "");
parseContext->recover();
}
- if (function.getReturnType().getBasicType() != EbtVoid) {
- parseContext->error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value");
+ if (function->getReturnType().getBasicType() != EbtVoid) {
+ parseContext->error($1.line, "", function->getReturnType().getBasicString(), "main function cannot return a value");
parseContext->recover();
}
}
@@ -2042,8 +2040,8 @@
// knows where to find parameters.
//
TIntermAggregate* paramNodes = new TIntermAggregate;
- for (int i = 0; i < function.getParamCount(); i++) {
- TParameter& param = function[i];
+ for (int i = 0; i < function->getParamCount(); i++) {
+ const TParameter& param = function->getParam(i);
if (param.name != 0) {
TVariable *variable = new TVariable(param.name, *param.type);
//
@@ -2054,10 +2052,6 @@
parseContext->recover();
delete variable;
}
- //
- // Transfer ownership of name pointer to symbol table.
- //
- param.name = 0;
//
// Add the parameter to the HIL
diff --git a/src/compiler/intermediate.h b/src/compiler/intermediate.h
index 21f89a4..dd269e1 100644
--- a/src/compiler/intermediate.h
+++ b/src/compiler/intermediate.h
@@ -418,12 +418,13 @@
virtual void traverse(TIntermTraverser*);
TIntermSequence& getSequence() { return sequence; }
+
void setName(const TString& n) { name = n; }
const TString& getName() const { return name; }
void setUserDefined() { userDefined = true; }
bool isUserDefined() { return userDefined; }
- TQualifierList& getQualifier() { return qualifier; }
+
void setOptimize(bool o) { optimize = o; }
bool getOptimize() { return optimize; }
void setDebug(bool d) { debug = d; }
@@ -435,9 +436,9 @@
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermSequence sequence;
- TQualifierList qualifier;
TString name;
bool userDefined; // used for user defined function names
+
bool optimize;
bool debug;
TPragmaTable *pragmaTable;