HLSL: Add implicit-this tracking to TFunction.
This commit is contained in:
parent
f3d88bd498
commit
dfbdd9eb20
4 changed files with 25 additions and 6 deletions
|
|
@ -1802,7 +1802,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// append this type's mangled name to the passed in 'name'
|
// append this type's mangled name to the passed in 'name'
|
||||||
void appendMangledName(TString& name)
|
void appendMangledName(TString& name) const
|
||||||
{
|
{
|
||||||
buildMangledName(name);
|
buildMangledName(name);
|
||||||
name += ';' ;
|
name += ';' ;
|
||||||
|
|
@ -1926,7 +1926,7 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void buildMangledName(TString&);
|
void buildMangledName(TString&) const;
|
||||||
|
|
||||||
TBasicType basicType : 8;
|
TBasicType basicType : 8;
|
||||||
int vectorSize : 4; // 1 means either scalar or 1-component vector; see vector1 to disambiguate.
|
int vectorSize : 4; // 1 means either scalar or 1-component vector; see vector1 to disambiguate.
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ namespace glslang {
|
||||||
//
|
//
|
||||||
// Recursively generate mangled names.
|
// Recursively generate mangled names.
|
||||||
//
|
//
|
||||||
void TType::buildMangledName(TString& mangledName)
|
void TType::buildMangledName(TString& mangledName) const
|
||||||
{
|
{
|
||||||
if (isMatrix())
|
if (isMatrix())
|
||||||
mangledName += 'm';
|
mangledName += 'm';
|
||||||
|
|
@ -299,6 +299,7 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
|
||||||
op = copyOf.op;
|
op = copyOf.op;
|
||||||
defined = copyOf.defined;
|
defined = copyOf.defined;
|
||||||
prototyped = copyOf.prototyped;
|
prototyped = copyOf.prototyped;
|
||||||
|
implicitThis = copyOf.implicitThis;
|
||||||
defaultParamCount = copyOf.defaultParamCount;
|
defaultParamCount = copyOf.defaultParamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,12 +219,12 @@ public:
|
||||||
explicit TFunction(TOperator o) :
|
explicit TFunction(TOperator o) :
|
||||||
TSymbol(0),
|
TSymbol(0),
|
||||||
op(o),
|
op(o),
|
||||||
defined(false), prototyped(false), defaultParamCount(0) { }
|
defined(false), prototyped(false), implicitThis(false), defaultParamCount(0) { }
|
||||||
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
|
TFunction(const TString *name, const TType& retType, TOperator tOp = EOpNull) :
|
||||||
TSymbol(name),
|
TSymbol(name),
|
||||||
mangledName(*name + '('),
|
mangledName(*name + '('),
|
||||||
op(tOp),
|
op(tOp),
|
||||||
defined(false), prototyped(false), defaultParamCount(0)
|
defined(false), prototyped(false), implicitThis(false), defaultParamCount(0)
|
||||||
{
|
{
|
||||||
returnType.shallowCopy(retType);
|
returnType.shallowCopy(retType);
|
||||||
declaredBuiltIn = retType.getQualifier().builtIn;
|
declaredBuiltIn = retType.getQualifier().builtIn;
|
||||||
|
|
@ -235,6 +235,9 @@ public:
|
||||||
virtual TFunction* getAsFunction() override { return this; }
|
virtual TFunction* getAsFunction() override { return this; }
|
||||||
virtual const TFunction* getAsFunction() const override { return this; }
|
virtual const TFunction* getAsFunction() const override { return this; }
|
||||||
|
|
||||||
|
// Install 'p' as the (non-'this') last parameter.
|
||||||
|
// Non-'this' parameters are reflected in both the list of parameters and the
|
||||||
|
// mangled name.
|
||||||
virtual void addParameter(TParameter& p)
|
virtual void addParameter(TParameter& p)
|
||||||
{
|
{
|
||||||
assert(writable);
|
assert(writable);
|
||||||
|
|
@ -245,6 +248,16 @@ public:
|
||||||
if (p.defaultValue != nullptr)
|
if (p.defaultValue != nullptr)
|
||||||
defaultParamCount++;
|
defaultParamCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Install 'this' as the first parameter.
|
||||||
|
// 'this' is reflected in the list of parameters, but not the mangled name.
|
||||||
|
virtual void addThisParameter(TType& type)
|
||||||
|
{
|
||||||
|
TParameter p = { NewPoolTString("this"), new TType, nullptr };
|
||||||
|
p.type->shallowCopy(type);
|
||||||
|
parameters.insert(parameters.begin(), p);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void addPrefix(const char* prefix) override
|
virtual void addPrefix(const char* prefix) override
|
||||||
{
|
{
|
||||||
TSymbol::addPrefix(prefix);
|
TSymbol::addPrefix(prefix);
|
||||||
|
|
@ -261,6 +274,8 @@ public:
|
||||||
virtual bool isDefined() const { return defined; }
|
virtual bool isDefined() const { return defined; }
|
||||||
virtual void setPrototyped() { assert(writable); prototyped = true; }
|
virtual void setPrototyped() { assert(writable); prototyped = true; }
|
||||||
virtual bool isPrototyped() const { return prototyped; }
|
virtual bool isPrototyped() const { return prototyped; }
|
||||||
|
virtual void setImplicitThis() { assert(writable); implicitThis = true; }
|
||||||
|
virtual bool hasImplicitThis() const { return implicitThis; }
|
||||||
|
|
||||||
// Return total number of parameters
|
// Return total number of parameters
|
||||||
virtual int getParamCount() const { return static_cast<int>(parameters.size()); }
|
virtual int getParamCount() const { return static_cast<int>(parameters.size()); }
|
||||||
|
|
@ -287,6 +302,7 @@ protected:
|
||||||
TOperator op;
|
TOperator op;
|
||||||
bool defined;
|
bool defined;
|
||||||
bool prototyped;
|
bool prototyped;
|
||||||
|
bool implicitThis;
|
||||||
int defaultParamCount;
|
int defaultParamCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2794,8 +2794,10 @@ bool HlslGrammar::acceptFunctionCall(HlslToken callToken, TIntermTyped*& node, T
|
||||||
|
|
||||||
// arguments
|
// arguments
|
||||||
TIntermTyped* arguments = nullptr;
|
TIntermTyped* arguments = nullptr;
|
||||||
if (baseObject != nullptr)
|
if (baseObject != nullptr) {
|
||||||
|
// Non-static member functions have an implicit first argument of the base object.
|
||||||
parseContext.handleFunctionArgument(function, arguments, baseObject);
|
parseContext.handleFunctionArgument(function, arguments, baseObject);
|
||||||
|
}
|
||||||
if (! acceptArguments(function, arguments))
|
if (! acceptArguments(function, arguments))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue