HLSL: Add implicit-this tracking to TFunction.
This commit is contained in:
parent
f3d88bd498
commit
dfbdd9eb20
@ -1802,7 +1802,7 @@ public:
|
||||
}
|
||||
|
||||
// append this type's mangled name to the passed in 'name'
|
||||
void appendMangledName(TString& name)
|
||||
void appendMangledName(TString& name) const
|
||||
{
|
||||
buildMangledName(name);
|
||||
name += ';' ;
|
||||
@ -1926,7 +1926,7 @@ protected:
|
||||
}
|
||||
|
||||
|
||||
void buildMangledName(TString&);
|
||||
void buildMangledName(TString&) const;
|
||||
|
||||
TBasicType basicType : 8;
|
||||
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.
|
||||
//
|
||||
void TType::buildMangledName(TString& mangledName)
|
||||
void TType::buildMangledName(TString& mangledName) const
|
||||
{
|
||||
if (isMatrix())
|
||||
mangledName += 'm';
|
||||
@ -299,6 +299,7 @@ TFunction::TFunction(const TFunction& copyOf) : TSymbol(copyOf)
|
||||
op = copyOf.op;
|
||||
defined = copyOf.defined;
|
||||
prototyped = copyOf.prototyped;
|
||||
implicitThis = copyOf.implicitThis;
|
||||
defaultParamCount = copyOf.defaultParamCount;
|
||||
}
|
||||
|
||||
|
@ -219,12 +219,12 @@ public:
|
||||
explicit TFunction(TOperator o) :
|
||||
TSymbol(0),
|
||||
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) :
|
||||
TSymbol(name),
|
||||
mangledName(*name + '('),
|
||||
op(tOp),
|
||||
defined(false), prototyped(false), defaultParamCount(0)
|
||||
defined(false), prototyped(false), implicitThis(false), defaultParamCount(0)
|
||||
{
|
||||
returnType.shallowCopy(retType);
|
||||
declaredBuiltIn = retType.getQualifier().builtIn;
|
||||
@ -235,6 +235,9 @@ public:
|
||||
virtual TFunction* getAsFunction() 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)
|
||||
{
|
||||
assert(writable);
|
||||
@ -245,6 +248,16 @@ public:
|
||||
if (p.defaultValue != nullptr)
|
||||
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
|
||||
{
|
||||
TSymbol::addPrefix(prefix);
|
||||
@ -261,6 +274,8 @@ public:
|
||||
virtual bool isDefined() const { return defined; }
|
||||
virtual void setPrototyped() { assert(writable); prototyped = true; }
|
||||
virtual bool isPrototyped() const { return prototyped; }
|
||||
virtual void setImplicitThis() { assert(writable); implicitThis = true; }
|
||||
virtual bool hasImplicitThis() const { return implicitThis; }
|
||||
|
||||
// Return total number of parameters
|
||||
virtual int getParamCount() const { return static_cast<int>(parameters.size()); }
|
||||
@ -287,6 +302,7 @@ protected:
|
||||
TOperator op;
|
||||
bool defined;
|
||||
bool prototyped;
|
||||
bool implicitThis;
|
||||
int defaultParamCount;
|
||||
};
|
||||
|
||||
|
@ -2794,8 +2794,10 @@ bool HlslGrammar::acceptFunctionCall(HlslToken callToken, TIntermTyped*& node, T
|
||||
|
||||
// arguments
|
||||
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);
|
||||
}
|
||||
if (! acceptArguments(function, arguments))
|
||||
return false;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user