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)
return TString(out.c_str());
}
TString getUnmangledFunctionName(const TString& mangledName)
{
return TString(mangledName.c_str(), mangledName.find_first_of('('));
}
TString getIndentationString(int depth)
{
TString indentation(depth, ' ');
......@@ -344,7 +339,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
if (visit == PreVisit)
{
TString returnType = node->getBasicString();
TString functionName = getUnmangledFunctionName(node->getName());
TString functionName = TFunction::unmangleName(node->getName());
out << returnType << " " << functionName;
}
else if (visit == InVisit)
......@@ -362,7 +357,7 @@ bool TOutputGLSL::visitAggregate(Visit visit, TIntermAggregate* node)
case EOpFunctionCall:
if (visit == PreVisit)
{
TString functionName = getUnmangledFunctionName(node->getName());
TString functionName = TFunction::unmangleName(node->getName());
out << functionName << "(";
}
else if (visit == InVisit)
......
......@@ -793,8 +793,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
case EOpComma: UNIMPLEMENTED(); /* FIXME */ out << "Comma\n"; return true;
case EOpFunction:
{
const TString &mangledName = node->getName();
TString name = TString(mangledName.c_str(), mangledName.find_first_of('('));
TString name = TFunction::unmangleName(node->getName());
if (visit == PreVisit)
{
......@@ -842,8 +841,7 @@ bool OutputHLSL::visitAggregate(Visit visit, TIntermAggregate *node)
{
if (visit == PreVisit)
{
const TString &mangledName = node->getName();
TString name = TString(mangledName.c_str(), mangledName.find_first_of('('));
TString name = TFunction::unmangleName(node->getName());
if (node->isUserDefined())
{
......
......@@ -81,7 +81,8 @@ public:
virtual void dump(TInfoSink &infoSink) const;
constUnion* getConstPointer() {
constUnion* getConstPointer()
{
if (!unionArray)
unionArray = new constUnion[type.getObjectSize()];
......@@ -114,7 +115,8 @@ protected:
struct TParameter {
TString *name;
TType* type;
void copyParam(const TParameter& param, TStructureMap& remapper) {
void copyParam(const TParameter& param, TStructureMap& remapper)
{
name = NewPoolTString(param.name->c_str());
type = param.type->clone(remapper);
}
......@@ -133,12 +135,18 @@ public:
TFunction(const TString *name, TType& retType, TOperator tOp = EOpNull) :
TSymbol(name),
returnType(retType),
mangledName(*name + '('),
mangledName(TFunction::mangleName(*name)),
op(tOp),
defined(false) { }
virtual ~TFunction();
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)
{
parameters.push_back(p);
......@@ -252,11 +260,13 @@ public:
bool atBuiltInLevel() { return atSharedBuiltInLevel() || atDynamicBuiltInLevel(); }
bool atSharedBuiltInLevel() { return table.size() == 1; }
bool atGlobalLevel() { return table.size() <= 3; }
void push() {
void push()
{
table.push_back(new TSymbolTableLevel);
}
void pop() {
void pop()
{
delete table[currentLevel()];
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