diff options
| author | Yong He <yonghe@outlook.com> | 2020-06-18 15:05:58 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-06-18 15:05:58 -0700 |
| commit | aa6aca498cd1f7fbbdb143e72dd48b1d714c8fbb (patch) | |
| tree | a2361c042e6a03ff957bd4a921f73efbb89dc1b7 /source/slang/slang-lower-to-ir.cpp | |
| parent | 5952e3b3d7f505a7e6d71ecd0793911224f5bac3 (diff) | |
| parent | 82ba914db9c3823ad7a0834d46b7fccedfe0acee (diff) | |
Merge pull request #1400 from csyonghe/dyndispatch
Dynamic dispatch non-static functions.
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 01bd0e972..ea04ea85c 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -6157,6 +6157,8 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> LoweredValInfo paramVal; + IRParam* irParam = nullptr; + switch( paramInfo.direction ) { default: @@ -6166,15 +6168,15 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // // TODO: Is this the best representation we can use? - IRParam* irParamPtr = subBuilder->emitParam(irParamType); + irParam = subBuilder->emitParam(irParamType); if(auto paramDecl = paramInfo.decl) { - addVarDecorations(context, irParamPtr, paramDecl); - subBuilder->addHighLevelDeclDecoration(irParamPtr, paramDecl); + addVarDecorations(context, irParam, paramDecl); + subBuilder->addHighLevelDeclDecoration(irParam, paramDecl); } - addParamNameHint(irParamPtr, paramInfo); + addParamNameHint(irParam, paramInfo); - paramVal = LoweredValInfo::ptr(irParamPtr); + paramVal = LoweredValInfo::ptr(irParam); // TODO: We might want to copy the pointed-to value into // a temporary at the start of the function, and then copy @@ -6194,7 +6196,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // We start by declaring an IR parameter of the same type. // auto paramDecl = paramInfo.decl; - IRParam* irParam = subBuilder->emitParam(irParamType); + irParam = subBuilder->emitParam(irParamType); if( paramDecl ) { addVarDecorations(context, irParam, paramDecl); @@ -6249,6 +6251,14 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> if (paramInfo.isThisParam) { subContext->thisVal = paramVal; + subBuilder->addThisPointerDecoration(irParam); + } + + // Add a [polymorphic] decoration for generic-typed parameters. + if (as<IRParam>(irParamType) && + as<IRTypeType>(irParamType->getFullType())) + { + subBuilder->addPolymorphicDecoration(irParam); } } |
