Commit b19403a1 by alokp@chromium.org

Removed unnecessary member variables from TIntermAggregate. Replaced operator…

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
parent ad771eb2
...@@ -471,17 +471,18 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction ...@@ -471,17 +471,18 @@ bool TParseContext::constructorErrorCheck(int line, TIntermNode* node, TFunction
bool matrixInMatrix = false; bool matrixInMatrix = false;
bool arrayArg = false; bool arrayArg = false;
for (int i = 0; i < function.getParamCount(); ++i) { 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; matrixInMatrix = true;
if (full) if (full)
overFull = true; overFull = true;
if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize()) if (op != EOpConstructStruct && !type->isArray() && size >= type->getObjectSize())
full = true; full = true;
if (function[i].type->getQualifier() != EvqConst) if (param.type->getQualifier() != EvqConst)
constType = false; constType = false;
if (function[i].type->isArray()) if (param.type->isArray())
arrayArg = true; arrayArg = true;
} }
......
...@@ -161,9 +161,8 @@ public: ...@@ -161,9 +161,8 @@ public:
void setDefined() { defined = true; } void setDefined() { defined = true; }
bool isDefined() { return defined; } bool isDefined() { return defined; }
int getParamCount() const { return static_cast<int>(parameters.size()); } int getParamCount() const { return static_cast<int>(parameters.size()); }
TParameter& operator [](int i) { return parameters[i]; } const TParameter& getParam(int i) const { return parameters[i]; }
const TParameter& operator [](int i) const { return parameters[i]; }
virtual void dump(TInfoSink &infoSink) const; virtual void dump(TInfoSink &infoSink) const;
TFunction(const TFunction&, TStructureMap& remapper); TFunction(const TFunction&, TStructureMap& remapper);
......
...@@ -537,16 +537,14 @@ function_call ...@@ -537,16 +537,14 @@ function_call
$$->getAsAggregate()->setName(fnCandidate->getMangledName()); $$->getAsAggregate()->setName(fnCandidate->getMangledName());
TQualifier qual; TQualifier qual;
TQualifierList& qualifierList = $$->getAsAggregate()->getQualifier();
for (int i = 0; i < fnCandidate->getParamCount(); ++i) { 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 (qual == EvqOut || qual == EvqInOut) {
if (parseContext->lValueErrorCheck($$->getLine(), "assign", $$->getAsAggregate()->getSequence()[i]->getAsTyped())) { 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->error($1.intermNode->getLine(), "Constant value cannot be passed for 'out' or 'inout' parameters.", "Error", "");
parseContext->recover(); parseContext->recover();
} }
} }
qualifierList.push_back(qual);
} }
} }
$$->setType(fnCandidate->getReturnType()); $$->setType(fnCandidate->getReturnType());
...@@ -989,7 +987,7 @@ declaration ...@@ -989,7 +987,7 @@ declaration
for (int i = 0; i < function.getParamCount(); i++) for (int i = 0; i < function.getParamCount(); i++)
{ {
TParameter &param = function[i]; const TParameter &param = function.getParam(i);
if (param.name != 0) if (param.name != 0)
{ {
TVariable *variable = new TVariable(param.name, *param.type); TVariable *variable = new TVariable(param.name, *param.type);
...@@ -1033,8 +1031,8 @@ function_prototype ...@@ -1033,8 +1031,8 @@ function_prototype
parseContext->recover(); parseContext->recover();
} }
for (int i = 0; i < prevDec->getParamCount(); ++i) { for (int i = 0; i < prevDec->getParamCount(); ++i) {
if ((*prevDec)[i].type->getQualifier() != (*$1)[i].type->getQualifier()) { if (prevDec->getParam(i).type->getQualifier() != $1->getParam(i).type->getQualifier()) {
parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", (*$1)[i].type->getQualifierString(), ""); parseContext->error($2.line, "overloaded functions must have the same parameter qualifiers", $1->getParam(i).type->getQualifierString(), "");
parseContext->recover(); parseContext->recover();
} }
} }
...@@ -1992,8 +1990,8 @@ external_declaration ...@@ -1992,8 +1990,8 @@ external_declaration
function_definition function_definition
: function_prototype { : function_prototype {
TFunction& function = *($1.function); TFunction* function = $1.function;
TFunction* prevDec = static_cast<TFunction*>(parseContext->symbolTable.find(function.getMangledName())); 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 // 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 // as it would have just been put in the symbol table. Otherwise, we're looking up
...@@ -2003,7 +2001,7 @@ function_definition ...@@ -2003,7 +2001,7 @@ function_definition
// //
// Then this function already has a body. // 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(); parseContext->recover();
} }
prevDec->setDefined(); prevDec->setDefined();
...@@ -2011,13 +2009,13 @@ function_definition ...@@ -2011,13 +2009,13 @@ function_definition
// //
// Raise error message if main function takes any parameters or return anything other than void // Raise error message if main function takes any parameters or return anything other than void
// //
if (function.getName() == "main") { if (function->getName() == "main") {
if (function.getParamCount() > 0) { if (function->getParamCount() > 0) {
parseContext->error($1.line, "function cannot take any parameter(s)", function.getName().c_str(), ""); parseContext->error($1.line, "function cannot take any parameter(s)", function->getName().c_str(), "");
parseContext->recover(); parseContext->recover();
} }
if (function.getReturnType().getBasicType() != EbtVoid) { if (function->getReturnType().getBasicType() != EbtVoid) {
parseContext->error($1.line, "", function.getReturnType().getBasicString(), "main function cannot return a value"); parseContext->error($1.line, "", function->getReturnType().getBasicString(), "main function cannot return a value");
parseContext->recover(); parseContext->recover();
} }
} }
...@@ -2042,8 +2040,8 @@ function_definition ...@@ -2042,8 +2040,8 @@ function_definition
// knows where to find parameters. // knows where to find parameters.
// //
TIntermAggregate* paramNodes = new TIntermAggregate; TIntermAggregate* paramNodes = new TIntermAggregate;
for (int i = 0; i < function.getParamCount(); i++) { for (int i = 0; i < function->getParamCount(); i++) {
TParameter& param = function[i]; const TParameter& param = function->getParam(i);
if (param.name != 0) { if (param.name != 0) {
TVariable *variable = new TVariable(param.name, *param.type); TVariable *variable = new TVariable(param.name, *param.type);
// //
...@@ -2054,10 +2052,6 @@ function_definition ...@@ -2054,10 +2052,6 @@ function_definition
parseContext->recover(); parseContext->recover();
delete variable; delete variable;
} }
//
// Transfer ownership of name pointer to symbol table.
//
param.name = 0;
// //
// Add the parameter to the HIL // Add the parameter to the HIL
......
...@@ -418,12 +418,13 @@ public: ...@@ -418,12 +418,13 @@ public:
virtual void traverse(TIntermTraverser*); virtual void traverse(TIntermTraverser*);
TIntermSequence& getSequence() { return sequence; } TIntermSequence& getSequence() { return sequence; }
void setName(const TString& n) { name = n; } void setName(const TString& n) { name = n; }
const TString& getName() const { return name; } const TString& getName() const { return name; }
void setUserDefined() { userDefined = true; } void setUserDefined() { userDefined = true; }
bool isUserDefined() { return userDefined; } bool isUserDefined() { return userDefined; }
TQualifierList& getQualifier() { return qualifier; }
void setOptimize(bool o) { optimize = o; } void setOptimize(bool o) { optimize = o; }
bool getOptimize() { return optimize; } bool getOptimize() { return optimize; }
void setDebug(bool d) { debug = d; } void setDebug(bool d) { debug = d; }
...@@ -435,9 +436,9 @@ protected: ...@@ -435,9 +436,9 @@ protected:
TIntermAggregate(const TIntermAggregate&); // disallow copy constructor TIntermAggregate(const TIntermAggregate&); // disallow copy constructor
TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator TIntermAggregate& operator=(const TIntermAggregate&); // disallow assignment operator
TIntermSequence sequence; TIntermSequence sequence;
TQualifierList qualifier;
TString name; TString name;
bool userDefined; // used for user defined function names bool userDefined; // used for user defined function names
bool optimize; bool optimize;
bool debug; bool debug;
TPragmaTable *pragmaTable; TPragmaTable *pragmaTable;
......
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