Untabify compiler code

TRAC #12156 Signed-off-by: Shannon Woods Signed-off-by: Daniel Koch Author: Nicolas Capens git-svn-id: https://angleproject.googlecode.com/svn/trunk@292 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 0a311a46
...@@ -12,20 +12,20 @@ ...@@ -12,20 +12,20 @@
// //
enum TPrecision enum TPrecision
{ {
EbpHigh, EbpHigh,
EbpMedium, EbpMedium,
EbpLow, EbpLow,
}; };
__inline const char* getPrecisionString(TPrecision p) __inline const char* getPrecisionString(TPrecision p)
{ {
switch(p) switch(p)
{ {
case EbpHigh: return "highp"; break; case EbpHigh: return "highp"; break;
case EbpMedium: return "mediump"; break; case EbpMedium: return "mediump"; break;
case EbpLow: return "lowp"; break; case EbpLow: return "lowp"; break;
default: return "unknown precision"; default: return "unknown precision";
} }
} }
// //
...@@ -33,21 +33,21 @@ __inline const char* getPrecisionString(TPrecision p) ...@@ -33,21 +33,21 @@ __inline const char* getPrecisionString(TPrecision p)
// //
enum TBasicType enum TBasicType
{ {
EbtVoid, EbtVoid,
EbtFloat, EbtFloat,
EbtInt, EbtInt,
EbtBool, EbtBool,
EbtGuardSamplerBegin, // non type: see implementation of IsSampler() EbtGuardSamplerBegin, // non type: see implementation of IsSampler()
EbtSampler2D, EbtSampler2D,
EbtSamplerCube, EbtSamplerCube,
EbtGuardSamplerEnd, // non type: see implementation of IsSampler() EbtGuardSamplerEnd, // non type: see implementation of IsSampler()
EbtStruct, EbtStruct,
EbtAddress, // should be deprecated?? EbtAddress, // should be deprecated??
}; };
__inline bool IsSampler(TBasicType type) __inline bool IsSampler(TBasicType type)
{ {
return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd; return type > EbtGuardSamplerBegin && type < EbtGuardSamplerEnd;
} }
// //
...@@ -58,41 +58,41 @@ __inline bool IsSampler(TBasicType type) ...@@ -58,41 +58,41 @@ __inline bool IsSampler(TBasicType type)
// //
enum TQualifier enum TQualifier
{ {
EvqTemporary, // For temporaries (within a function), read/write EvqTemporary, // For temporaries (within a function), read/write
EvqGlobal, // For globals read/write EvqGlobal, // For globals read/write
EvqConst, // User defined constants and non-output parameters in functions EvqConst, // User defined constants and non-output parameters in functions
EvqAttribute, // Readonly EvqAttribute, // Readonly
EvqVaryingIn, // readonly, fragment shaders only EvqVaryingIn, // readonly, fragment shaders only
EvqVaryingOut, // vertex shaders only read/write EvqVaryingOut, // vertex shaders only read/write
EvqInvariantVaryingIn, // readonly, fragment shaders only EvqInvariantVaryingIn, // readonly, fragment shaders only
EvqInvariantVaryingOut, // vertex shaders only read/write EvqInvariantVaryingOut, // vertex shaders only read/write
EvqUniform, // Readonly, vertex and fragment EvqUniform, // Readonly, vertex and fragment
// pack/unpack input and output // pack/unpack input and output
EvqInput, EvqInput,
EvqOutput, EvqOutput,
// parameters // parameters
EvqIn, EvqIn,
EvqOut, EvqOut,
EvqInOut, EvqInOut,
EvqConstReadOnly, EvqConstReadOnly,
// built-ins written by vertex shader // built-ins written by vertex shader
EvqPosition, EvqPosition,
EvqPointSize, EvqPointSize,
// built-ins read by fragment shader // built-ins read by fragment shader
EvqFragCoord, EvqFragCoord,
EvqFrontFacing, EvqFrontFacing,
EvqPointCoord, EvqPointCoord,
// built-ins written by fragment shader // built-ins written by fragment shader
EvqFragColor, EvqFragColor,
EvqFragData, EvqFragData,
// end of list // end of list
EvqLast, EvqLast,
}; };
// //
...@@ -100,31 +100,31 @@ enum TQualifier ...@@ -100,31 +100,31 @@ enum TQualifier
// //
__inline const char* getQualifierString(TQualifier q) __inline const char* getQualifierString(TQualifier q)
{ {
switch(q) switch(q)
{ {
case EvqTemporary: return "Temporary"; break; case EvqTemporary: return "Temporary"; break;
case EvqGlobal: return "Global"; break; case EvqGlobal: return "Global"; break;
case EvqConst: return "const"; break; case EvqConst: return "const"; break;
case EvqConstReadOnly: return "const"; break; case EvqConstReadOnly: return "const"; break;
case EvqAttribute: return "attribute"; break; case EvqAttribute: return "attribute"; break;
case EvqVaryingIn: return "varying"; break; case EvqVaryingIn: return "varying"; break;
case EvqVaryingOut: return "varying"; break; case EvqVaryingOut: return "varying"; break;
case EvqInvariantVaryingIn: return "invariant varying"; break; case EvqInvariantVaryingIn: return "invariant varying"; break;
case EvqInvariantVaryingOut:return "invariant varying"; break; case EvqInvariantVaryingOut:return "invariant varying"; break;
case EvqUniform: return "uniform"; break; case EvqUniform: return "uniform"; break;
case EvqIn: return "in"; break; case EvqIn: return "in"; break;
case EvqOut: return "out"; break; case EvqOut: return "out"; break;
case EvqInOut: return "inout"; break; case EvqInOut: return "inout"; break;
case EvqInput: return "input"; break; case EvqInput: return "input"; break;
case EvqOutput: return "output"; break; case EvqOutput: return "output"; break;
case EvqPosition: return "Position"; break; case EvqPosition: return "Position"; break;
case EvqPointSize: return "PointSize"; break; case EvqPointSize: return "PointSize"; break;
case EvqFragCoord: return "FragCoord"; break; case EvqFragCoord: return "FragCoord"; break;
case EvqFrontFacing: return "FrontFacing"; break; case EvqFrontFacing: return "FrontFacing"; break;
case EvqFragColor: return "FragColor"; break; case EvqFragColor: return "FragColor"; break;
case EvqFragData: return "FragData"; break; case EvqFragData: return "FragData"; break;
default: return "unknown qualifier"; default: return "unknown qualifier";
} }
} }
#endif // _BASICTYPES_INCLUDED_ #endif // _BASICTYPES_INCLUDED_
...@@ -11,24 +11,24 @@ ...@@ -11,24 +11,24 @@
#include "compiler/localintermediate.h" #include "compiler/localintermediate.h"
struct TMatrixFields { struct TMatrixFields {
bool wholeRow; bool wholeRow;
bool wholeCol; bool wholeCol;
int row; int row;
int col; int col;
}; };
typedef enum { typedef enum {
EBhRequire, EBhRequire,
EBhEnable, EBhEnable,
EBhWarn, EBhWarn,
EBhDisable EBhDisable
} TBehavior; } TBehavior;
struct TPragma { struct TPragma {
TPragma(bool o, bool d) : optimize(o), debug(d) { } TPragma(bool o, bool d) : optimize(o), debug(d) { }
bool optimize; bool optimize;
bool debug; bool debug;
TPragmaTable pragmaTable; TPragmaTable pragmaTable;
}; };
// //
...@@ -36,71 +36,71 @@ struct TPragma { ...@@ -36,71 +36,71 @@ struct TPragma {
// they can be passed to the parser without needing a global. // they can be passed to the parser without needing a global.
// //
struct TParseContext { struct TParseContext {
TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) : TParseContext(TSymbolTable& symt, TIntermediate& interm, EShLanguage L, TInfoSink& is) :
intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0),
recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0), recoveredFromError(false), numErrors(0), lexAfterType(false), loopNestingLevel(0),
inTypeParen(false), contextPragma(true, false) { } inTypeParen(false), contextPragma(true, false) { }
TIntermediate& intermediate; // to hold and build a parse tree TIntermediate& intermediate; // to hold and build a parse tree
TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed TSymbolTable& symbolTable; // symbol table that goes with the language currently being parsed
TInfoSink& infoSink; TInfoSink& infoSink;
EShLanguage language; // vertex or fragment language (future: pack or unpack) EShLanguage language; // vertex or fragment language (future: pack or unpack)
TIntermNode* treeRoot; // root of parse tree being created TIntermNode* treeRoot; // root of parse tree being created
bool recoveredFromError; // true if a parse error has occurred, but we continue to parse bool recoveredFromError; // true if a parse error has occurred, but we continue to parse
int numErrors; int numErrors;
bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier bool lexAfterType; // true if we've recognized a type, so can only be looking for an identifier
int loopNestingLevel; // 0 if outside all loops int loopNestingLevel; // 0 if outside all loops
bool inTypeParen; // true if in parentheses, looking only for an identifier bool inTypeParen; // true if in parentheses, looking only for an identifier
const TType* currentFunctionType; // the return type of the function that's currently being parsed const TType* currentFunctionType; // the return type of the function that's currently being parsed
bool functionReturnsValue; // true if a non-void function has a return bool functionReturnsValue; // true if a non-void function has a return
TMap<TString, TBehavior> extensionBehavior; TMap<TString, TBehavior> extensionBehavior;
void initializeExtensionBehavior(); void initializeExtensionBehavior();
void C_DECL error(TSourceLoc, const char *szReason, const char *szToken, void C_DECL error(TSourceLoc, const char *szReason, const char *szToken,
const char *szExtraInfoFormat, ...); const char *szExtraInfoFormat, ...);
bool reservedErrorCheck(int line, const TString& identifier); bool reservedErrorCheck(int line, const TString& identifier);
void recover(); void recover();
bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line); bool parseVectorFields(const TString&, int vecSize, TVectorFields&, int line);
bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line); bool parseMatrixFields(const TString&, int matSize, TMatrixFields&, int line);
void assignError(int line, const char* op, TString left, TString right); void assignError(int line, const char* op, TString left, TString right);
void unaryOpError(int line, const char* op, TString operand); void unaryOpError(int line, const char* op, TString operand);
void binaryOpError(int line, const char* op, TString left, TString right); void binaryOpError(int line, const char* op, TString left, TString right);
bool lValueErrorCheck(int line, const char* op, TIntermTyped*); bool lValueErrorCheck(int line, const char* op, TIntermTyped*);
bool constErrorCheck(TIntermTyped* node); bool constErrorCheck(TIntermTyped* node);
bool integerErrorCheck(TIntermTyped* node, const char* token); bool integerErrorCheck(TIntermTyped* node, const char* token);
bool globalErrorCheck(int line, bool global, const char* token); bool globalErrorCheck(int line, bool global, const char* token);
bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*); bool constructorErrorCheck(int line, TIntermNode*, TFunction&, TOperator, TType*);
bool arraySizeErrorCheck(int line, TIntermTyped* expr, int& size); bool arraySizeErrorCheck(int line, TIntermTyped* expr, int& size);
bool arrayQualifierErrorCheck(int line, TPublicType type); bool arrayQualifierErrorCheck(int line, TPublicType type);
bool arrayTypeErrorCheck(int line, TPublicType type); bool arrayTypeErrorCheck(int line, TPublicType type);
bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TVariable*& variable); bool arrayErrorCheck(int line, TString& identifier, TPublicType type, TVariable*& variable);
bool voidErrorCheck(int, const TString&, const TPublicType&); bool voidErrorCheck(int, const TString&, const TPublicType&);
bool boolErrorCheck(int, const TIntermTyped*); bool boolErrorCheck(int, const TIntermTyped*);
bool boolErrorCheck(int, const TPublicType&); bool boolErrorCheck(int, const TPublicType&);
bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason); bool samplerErrorCheck(int line, const TPublicType& pType, const char* reason);
bool structQualifierErrorCheck(int line, const TPublicType& pType); bool structQualifierErrorCheck(int line, const TPublicType& pType);
bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type); bool parameterSamplerErrorCheck(int line, TQualifier qualifier, const TType& type);
bool containsSampler(TType& type); bool containsSampler(TType& type);
bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type); bool nonInitConstErrorCheck(int line, TString& identifier, TPublicType& type);
bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type); bool nonInitErrorCheck(int line, TString& identifier, TPublicType& type);
bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type); bool paramErrorCheck(int line, TQualifier qualifier, TQualifier paramQualifier, TType* type);
bool extensionErrorCheck(int line, const char*); bool extensionErrorCheck(int line, const char*);
const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0); const TFunction* findFunction(int line, TFunction* pfnCall, bool *builtIn = 0);
bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType, bool executeInitializer(TSourceLoc line, TString& identifier, TPublicType& pType,
TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0); TIntermTyped* initializer, TIntermNode*& intermNode, TVariable* variable = 0);
bool areAllChildConst(TIntermAggregate* aggrNode); bool areAllChildConst(TIntermAggregate* aggrNode);
TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc); TIntermTyped* addConstructor(TIntermNode*, const TType*, TOperator, TFunction*, TSourceLoc);
TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type); TIntermTyped* foldConstConstructor(TIntermAggregate* aggrNode, const TType& type);
TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset); TIntermTyped* constructStruct(TIntermNode*, TType*, int, TSourceLoc, bool subset);
TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset); TIntermTyped* constructBuiltIn(const TType*, TOperator, TIntermNode*, TSourceLoc, bool subset);
TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc); TIntermTyped* addConstVectorNode(TVectorFields&, TIntermTyped*, TSourceLoc);
TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc); TIntermTyped* addConstMatrixNode(int , TIntermTyped*, TSourceLoc);
TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line); TIntermTyped* addConstArrayNode(int index, TIntermTyped* node, TSourceLoc line);
TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc); TIntermTyped* addConstStruct(TString& , TIntermTyped*, TSourceLoc);
bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc); bool arraySetMaxSize(TIntermSymbol*, TType*, int, bool, TSourceLoc);
struct TPragma contextPragma; struct TPragma contextPragma;
TString HashErrMsg; TString HashErrMsg;
bool AfterEOF; bool AfterEOF;
}; };
int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&); int PaParseStrings(char* argv[], int strLen[], int argc, TParseContext&);
...@@ -115,7 +115,7 @@ extern TParseContextPointer& GetGlobalParseContext(); ...@@ -115,7 +115,7 @@ extern TParseContextPointer& GetGlobalParseContext();
typedef struct TThreadParseContextRec typedef struct TThreadParseContextRec
{ {
TParseContext *lpGlobalParseContext; TParseContext *lpGlobalParseContext;
} TThreadParseContext; } TThreadParseContext;
#endif // _PARSER_HELPER_INCLUDED_ #endif // _PARSER_HELPER_INCLUDED_
...@@ -20,53 +20,53 @@ ...@@ -20,53 +20,53 @@
// //
void TType::buildMangledName(TString& mangledName) void TType::buildMangledName(TString& mangledName)
{ {
if (isMatrix()) if (isMatrix())
mangledName += 'm'; mangledName += 'm';
else if (isVector()) else if (isVector())
mangledName += 'v'; mangledName += 'v';
switch (type) { switch (type) {
case EbtFloat: mangledName += 'f'; break; case EbtFloat: mangledName += 'f'; break;
case EbtInt: mangledName += 'i'; break; case EbtInt: mangledName += 'i'; break;
case EbtBool: mangledName += 'b'; break; case EbtBool: mangledName += 'b'; break;
case EbtSampler2D: mangledName += "s2"; break; case EbtSampler2D: mangledName += "s2"; break;
case EbtSamplerCube: mangledName += "sC"; break; case EbtSamplerCube: mangledName += "sC"; break;
case EbtStruct: case EbtStruct:
mangledName += "struct-"; mangledName += "struct-";
if (typeName) if (typeName)
mangledName += *typeName; mangledName += *typeName;
{// support MSVC++6.0 {// support MSVC++6.0
for (unsigned int i = 0; i < structure->size(); ++i) { for (unsigned int i = 0; i < structure->size(); ++i) {
mangledName += '-'; mangledName += '-';
(*structure)[i].type->buildMangledName(mangledName); (*structure)[i].type->buildMangledName(mangledName);
} }
} }
default: default:
break; break;
} }
mangledName += static_cast<char>('0' + getNominalSize()); mangledName += static_cast<char>('0' + getNominalSize());
if (isArray()) { if (isArray()) {
char buf[20]; char buf[20];
sprintf(buf, "%d", arraySize); sprintf(buf, "%d", arraySize);
mangledName += '['; mangledName += '[';
mangledName += buf; mangledName += buf;
mangledName += ']'; mangledName += ']';
} }
} }
int TType::getStructSize() const int TType::getStructSize() const
{ {
if (!getStruct()) { if (!getStruct()) {
assert(false && "Not a struct"); assert(false && "Not a struct");
return 0; return 0;
} }
if (structureSize == 0) if (structureSize == 0)
for (TTypeList::iterator tl = getStruct()->begin(); tl != getStruct()->end(); tl++) for (TTypeList::iterator tl = getStruct()->begin(); tl != getStruct()->end(); tl++)
structureSize += ((*tl).type)->getObjectSize(); structureSize += ((*tl).type)->getObjectSize();
return structureSize; return structureSize;
} }
// //
...@@ -75,31 +75,31 @@ int TType::getStructSize() const ...@@ -75,31 +75,31 @@ int TType::getStructSize() const
void TVariable::dump(TInfoSink& infoSink) const void TVariable::dump(TInfoSink& infoSink) const
{ {
infoSink.debug << getName().c_str() << ": " << type.getQualifierString() << " " << type.getBasicString(); infoSink.debug << getName().c_str() << ": " << type.getQualifierString() << " " << type.getBasicString();
if (type.isArray()) { if (type.isArray()) {
infoSink.debug << "[0]"; infoSink.debug << "[0]";
} }
infoSink.debug << "\n"; infoSink.debug << "\n";
} }
void TFunction::dump(TInfoSink &infoSink) const void TFunction::dump(TInfoSink &infoSink) const
{ {
infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n"; infoSink.debug << getName().c_str() << ": " << returnType.getBasicString() << " " << getMangledName().c_str() << "\n";
} }
void TSymbolTableLevel::dump(TInfoSink &infoSink) const void TSymbolTableLevel::dump(TInfoSink &infoSink) const
{ {
tLevel::const_iterator it; tLevel::const_iterator it;
for (it = level.begin(); it != level.end(); ++it) for (it = level.begin(); it != level.end(); ++it)
(*it).second->dump(infoSink); (*it).second->dump(infoSink);
} }
void TSymbolTable::dump(TInfoSink &infoSink) const void TSymbolTable::dump(TInfoSink &infoSink) const
{ {
for (int level = currentLevel(); level >= 0; --level) { for (int level = currentLevel(); level >= 0; --level) {
infoSink.debug << "LEVEL " << level << "\n"; infoSink.debug << "LEVEL " << level << "\n";
table[level]->dump(infoSink); table[level]->dump(infoSink);
} }
} }
// //
...@@ -107,8 +107,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const ...@@ -107,8 +107,8 @@ void TSymbolTable::dump(TInfoSink &infoSink) const
// //
TFunction::~TFunction() TFunction::~TFunction()
{ {
for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i) for (TParamList::iterator i = parameters.begin(); i != parameters.end(); ++i)
delete (*i).type; delete (*i).type;
} }
// //
...@@ -116,8 +116,8 @@ TFunction::~TFunction() ...@@ -116,8 +116,8 @@ TFunction::~TFunction()
// //
TSymbolTableLevel::~TSymbolTableLevel() TSymbolTableLevel::~TSymbolTableLevel()
{ {
for (tLevel::iterator it = level.begin(); it != level.end(); ++it) for (tLevel::iterator it = level.begin(); it != level.end(); ++it)
delete (*it).second; delete (*it).second;
} }
// //
...@@ -128,84 +128,84 @@ TSymbolTableLevel::~TSymbolTableLevel() ...@@ -128,84 +128,84 @@ TSymbolTableLevel::~TSymbolTableLevel()
// //
void TSymbolTableLevel::relateToOperator(const char* name, TOperator op) void TSymbolTableLevel::relateToOperator(const char* name, TOperator op)
{ {
tLevel::iterator it; tLevel::iterator it;
for (it = level.begin(); it != level.end(); ++it) { for (it = level.begin(); it != level.end(); ++it) {
if ((*it).second->isFunction()) { if ((*it).second->isFunction()) {
TFunction* function = static_cast<TFunction*>((*it).second); TFunction* function = static_cast<TFunction*>((*it).second);
if (function->getName() == name) if (function->getName() == name)
function->relateToOperator(op); function->relateToOperator(op);
} }
} }
} }
TSymbol::TSymbol(const TSymbol& copyOf) TSymbol::TSymbol(const TSymbol& copyOf)
{ {
name = NewPoolTString(copyOf.name->c_str()); name = NewPoolTString(copyOf.name->c_str());
uniqueId = copyOf.uniqueId; uniqueId = copyOf.uniqueId;
} }
TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf) TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
{ {
type.copyType(copyOf.type, remapper); type.copyType(copyOf.type, remapper);
userType = copyOf.userType; userType = copyOf.userType;
// for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL // for builtIn symbol table level, unionArray and arrayInformation pointers should be NULL
assert(copyOf.arrayInformationType == 0); assert(copyOf.arrayInformationType == 0);
arrayInformationType = 0; arrayInformationType = 0;
if (copyOf.unionArray) { if (copyOf.unionArray) {
assert(!copyOf.type.getStruct()); assert(!copyOf.type.getStruct());
assert(copyOf.type.getObjectSize() == 1); assert(copyOf.type.getObjectSize() == 1);
unionArray = new ConstantUnion[1]; unionArray = new ConstantUnion[1];
unionArray[0] = copyOf.unionArray[0]; unionArray[0] = copyOf.unionArray[0];
} else } else
unionArray = 0; unionArray = 0;
} }
TVariable* TVariable::clone(TStructureMap& remapper) TVariable* TVariable::clone(TStructureMap& remapper)
{ {
TVariable *variable = new TVariable(*this, remapper); TVariable *variable = new TVariable(*this, remapper);
return variable; return variable;
} }
TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf) TFunction::TFunction(const TFunction& copyOf, TStructureMap& remapper) : TSymbol(copyOf)
{ {
for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) { for (unsigned int i = 0; i < copyOf.parameters.size(); ++i) {
TParameter param; TParameter param;
parameters.push_back(param); parameters.push_back(param);
parameters.back().copyParam(copyOf.parameters[i], remapper); parameters.back().copyParam(copyOf.parameters[i], remapper);
} }
returnType.copyType(copyOf.returnType, remapper); returnType.copyType(copyOf.returnType, remapper);
mangledName = copyOf.mangledName; mangledName = copyOf.mangledName;
op = copyOf.op; op = copyOf.op;
defined = copyOf.defined; defined = copyOf.defined;
} }
TFunction* TFunction::clone(TStructureMap& remapper) TFunction* TFunction::clone(TStructureMap& remapper)
{ {
TFunction *function = new TFunction(*this, remapper); TFunction *function = new TFunction(*this, remapper);
return function; return function;
} }
TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper) TSymbolTableLevel* TSymbolTableLevel::clone(TStructureMap& remapper)
{ {
TSymbolTableLevel *symTableLevel = new TSymbolTableLevel(); TSymbolTableLevel *symTableLevel = new TSymbolTableLevel();
tLevel::iterator iter; tLevel::iterator iter;
for (iter = level.begin(); iter != level.end(); ++iter) { for (iter = level.begin(); iter != level.end(); ++iter) {
symTableLevel->insert(*iter->second->clone(remapper)); symTableLevel->insert(*iter->second->clone(remapper));
} }
return symTableLevel; return symTableLevel;
} }
void TSymbolTable::copyTable(const TSymbolTable& copyOf) void TSymbolTable::copyTable(const TSymbolTable& copyOf)
{ {
TStructureMap remapper; TStructureMap remapper;
uniqueId = copyOf.uniqueId; uniqueId = copyOf.uniqueId;
for (unsigned int i = 0; i < copyOf.table.size(); ++i) { for (unsigned int i = 0; i < copyOf.table.size(); ++i) {
table.push_back(copyOf.table[i]->clone(remapper)); table.push_back(copyOf.table[i]->clone(remapper));
} }
} }
...@@ -732,7 +732,7 @@ unary_expression ...@@ -732,7 +732,7 @@ unary_expression
switch($1.op) { switch($1.op) {
case EOpNegative: errorOp = "-"; break; case EOpNegative: errorOp = "-"; break;
case EOpLogicalNot: errorOp = "!"; break; case EOpLogicalNot: errorOp = "!"; break;
default: break; default: break;
} }
parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString()); parseContext->unaryOpError($1.line, errorOp, $2->getCompleteString());
parseContext->recover(); parseContext->recover();
...@@ -1011,12 +1011,12 @@ declaration ...@@ -1011,12 +1011,12 @@ declaration
$$ = prototype; $$ = prototype;
} }
| init_declarator_list SEMICOLON { | init_declarator_list SEMICOLON {
if ($1.intermAggregate) if ($1.intermAggregate)
$1.intermAggregate->setOperator(EOpDeclaration); $1.intermAggregate->setOperator(EOpDeclaration);
$$ = $1.intermAggregate; $$ = $1.intermAggregate;
} }
| PRECISION precision_qualifier type_specifier_no_prec SEMICOLON { | PRECISION precision_qualifier type_specifier_no_prec SEMICOLON {
$$ = 0; $$ = 0;
} }
; ;
...@@ -1274,7 +1274,7 @@ init_declarator_list ...@@ -1274,7 +1274,7 @@ init_declarator_list
if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type)) if (parseContext->arrayTypeErrorCheck($4.line, $1.type) || parseContext->arrayQualifierErrorCheck($4.line, $1.type))
parseContext->recover(); parseContext->recover();
else { else {
$1.type.setArray(true, $7->getType().getArraySize()); $1.type.setArray(true, $7->getType().getArraySize());
if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable)) if (parseContext->arrayErrorCheck($4.line, *$3.string, $1.type, variable))
parseContext->recover(); parseContext->recover();
} }
...@@ -1345,7 +1345,7 @@ init_declarator_list ...@@ -1345,7 +1345,7 @@ init_declarator_list
// build the intermediate representation // build the intermediate representation
// //
if (intermNode) if (intermNode)
$$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $4.line); $$.intermAggregate = parseContext->intermediate.growAggregate($1.intermNode, intermNode, $4.line);
else else
$$.intermAggregate = $1.intermAggregate; $$.intermAggregate = $1.intermAggregate;
} else { } else {
...@@ -1361,7 +1361,7 @@ single_declaration ...@@ -1361,7 +1361,7 @@ single_declaration
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, "", TType($1), $1.line), $1.line);
} }
| fully_specified_type IDENTIFIER { | fully_specified_type IDENTIFIER {
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, TType($1), $2.line), $2.line);
if (parseContext->structQualifierErrorCheck($2.line, $$.type)) if (parseContext->structQualifierErrorCheck($2.line, $$.type))
parseContext->recover(); parseContext->recover();
...@@ -1395,11 +1395,11 @@ single_declaration ...@@ -1395,11 +1395,11 @@ single_declaration
} }
} }
| fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET { | fully_specified_type IDENTIFIER LEFT_BRACKET constant_expression RIGHT_BRACKET {
TType type = TType($1); TType type = TType($1);
int size; int size;
if (parseContext->arraySizeErrorCheck($2.line, $4, size)) if (parseContext->arraySizeErrorCheck($2.line, $4, size))
parseContext->recover(); parseContext->recover();
type.setArraySize(size); type.setArraySize(size);
$$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(parseContext->intermediate.addSymbol(0, *$2.string, type, $2.line), $2.line);
if (parseContext->structQualifierErrorCheck($2.line, $1)) if (parseContext->structQualifierErrorCheck($2.line, $1))
...@@ -1429,24 +1429,24 @@ single_declaration ...@@ -1429,24 +1429,24 @@ single_declaration
$$.type = $1; $$.type = $1;
TIntermNode* intermNode; TIntermNode* intermNode;
if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) { if (!parseContext->executeInitializer($2.line, *$2.string, $1, $4, intermNode)) {
// //
// Build intermediate representation // Build intermediate representation
// //
if(intermNode) if(intermNode)
$$.intermAggregate = parseContext->intermediate.makeAggregate(intermNode, $3.line); $$.intermAggregate = parseContext->intermediate.makeAggregate(intermNode, $3.line);
else else
$$.intermAggregate = 0; $$.intermAggregate = 0;
} else { } else {
parseContext->recover(); parseContext->recover();
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
} }
| INVARIANT IDENTIFIER { | INVARIANT IDENTIFIER {
VERTEX_ONLY("invariant declaration", $1.line); VERTEX_ONLY("invariant declaration", $1.line);
$$.qualifier = EvqInvariantVaryingOut; $$.qualifier = EvqInvariantVaryingOut;
$$.intermAggregate = 0; $$.intermAggregate = 0;
} }
// //
...@@ -1589,23 +1589,23 @@ type_qualifier ...@@ -1589,23 +1589,23 @@ type_qualifier
type_specifier type_specifier
: type_specifier_no_prec { : type_specifier_no_prec {
$$ = $1; $$ = $1;
} }
| precision_qualifier type_specifier_no_prec { | precision_qualifier type_specifier_no_prec {
$$ = $2; $$ = $2;
$$.setPrecision($1); $$.setPrecision($1);
} }
; ;
precision_qualifier precision_qualifier
: HIGH_PRECISION { : HIGH_PRECISION {
$$ = EbpHigh; $$ = EbpHigh;
} }
| MEDIUM_PRECISION { | MEDIUM_PRECISION {
$$ = EbpMedium; $$ = EbpMedium;
} }
| LOW_PRECISION { | LOW_PRECISION {
$$ = EbpLow; $$ = EbpLow;
} }
; ;
......
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