Commit 4388487c by alokp@chromium.org

Moved code to unmangle function name to a common place and used it in both…

Moved code to unmangle function name to a common place and used it in both OutputGLSL and OutputHLSL. Review URL: http://codereview.appspot.com/838041 git-svn-id: https://angleproject.googlecode.com/svn/trunk@83 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 60fe407c
...@@ -42,11 +42,6 @@ TString getTypeName(const TType& type) ...@@ -42,11 +42,6 @@ TString getTypeName(const TType& type)
return TString(out.c_str()); return TString(out.c_str());
} }
TString getUnmangledFunctionName(const TString& mangledName)
{
return TString(mangledName.c_str(), mangledName.find_first_of('('));
}
TString getIndentationString(int depth) TString getIndentationString(int depth)
{ {
TString indentation(depth, ' '); TString indentation(depth, ' ');
...@@ -344,7 +339,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node) ...@@ -344,7 +339,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
if (visit == PreVisit) if (visit == PreVisit)
{ {
TString returnType = node->getBasicString(); TString returnType = node->getBasicString();
TString functionName = getUnmangledFunctionName(node->getName()); TString functionName = TFunction::unmangleName(node->getName());
out << returnType << " " << functionName; out << returnType << " " << functionName;
} }
else if (visit == InVisit) else if (visit == InVisit)
...@@ -362,7 +357,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node) ...@@ -362,7 +357,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpFunctionCall: case EOpFunctionCall:
if (visit == PreVisit) if (visit == PreVisit)
{ {
TString functionName = getUnmangledFunctionName(node->getName()); TString functionName = TFunction::unmangleName(node->getName());
out << functionName << "("; out << functionName << "(";
} }
else if (visit == InVisit) else if (visit == InVisit)
......
...@@ -793,8 +793,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -793,8 +793,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpComma: UNIMPLEMENTED(); /* FIXME */ out << "Comma\n"; return true; case EOpComma: UNIMPLEMENTED(); /* FIXME */ out << "Comma\n"; return true;
case EOpFunction: case EOpFunction:
{ {
const TString &mangledName = node->getName(); TString name = TFunction::unmangleName(node->getName());
TString name = TString(mangledName.c_str(), mangledName.find_first_of('('));
if (visit == PreVisit) if (visit == PreVisit)
{ {
...@@ -842,8 +841,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node) ...@@ -842,8 +841,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{ {
if (visit == PreVisit) if (visit == PreVisit)
{ {
const TString &mangledName = node->getName(); TString name = TFunction::unmangleName(node->getName());
TString name = TString(mangledName.c_str(), mangledName.find_first_of('('));
if (node->isUserDefined()) if (node->isUserDefined())
{ {
......
...@@ -81,7 +81,8 @@ public: ...@@ -81,7 +81,8 @@ public:
virtual void dump(TInfoSink &infoSink) const; virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstPointer() { constUnion* getConstPointer()
{
if (!unionArray) if (!unionArray)
unionArray = new constUnion[type.getObjectSize()]; unionArray = new constUnion[type.getObjectSize()];
...@@ -114,7 +115,8 @@ protected: ...@@ -114,7 +115,8 @@ protected:
struct TParameter { struct TParameter {
TString *name; TString *name;
TType* type; TType* type;
void copyParam(const TParameter& param, TStructureMap& remapper) { void copyParam(const TParameter& param, TStructureMap& remapper)
{
name = NewPoolTString(param.name->c_str()); name = NewPoolTString(param.name->c_str());
type = param.type->clone(remapper); type = param.type->clone(remapper);
} }
...@@ -133,12 +135,18 @@ public: ...@@ -133,12 +135,18 @@ public:
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) : TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
TSymbol(name), TSymbol(name),
returnType(retType), returnType(retType),
mangledName(*name + '('), mangledName(TFunction::mangleName(*name)),
op(tOp), op(tOp),
defined(false) { } defined(false) { }
virtual ~TFunction(); virtual ~TFunction();
virtual bool isFunction() const { return true; } virtual bool isFunction() const { return true; }
static TString mangleName(const TString& name) { return name + '('; }
static TString unmangleName(const TString& mangledName)
{
return TString(mangledName.c_str(), mangledName.find_first_of('('));
}
void addParameter(TParameter& p) void addParameter(TParameter& p)
{ {
parameters.push_back(p); parameters.push_back(p);
...@@ -252,11 +260,13 @@ public: ...@@ -252,11 +260,13 @@ public:
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); } bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
bool atSharedBuiltInLevel() { return table.size() == 1; } bool atSharedBuiltInLevel() { return table.size() == 1; }
bool atGlobalLevel() { return table.size() <= 3; } bool atGlobalLevel() { return table.size() <= 3; }
void push() { void push()
{
table.push_back(new TSymbolTableLevel); table.push_back(new TSymbolTableLevel);
} }
void pop() { void pop()
{
delete table[currentLevel()]; delete table[currentLevel()];
table.pop_back(); table.pop_back();
} }
......
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