From 8c6e02bd094bbc0c9afb141265be9675f99ddb61 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 17 Jun 2020 22:41:56 -0700 Subject: Dynamic dipatch non-static functions. --- source/slang/slang-lower-to-ir.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source/slang/slang-lower-to-ir.cpp') 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 LoweredValInfo paramVal; + IRParam* irParam = nullptr; + switch( paramInfo.direction ) { default: @@ -6166,15 +6168,15 @@ struct DeclLoweringVisitor : DeclVisitor // // 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 // 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 if (paramInfo.isThisParam) { subContext->thisVal = paramVal; + subBuilder->addThisPointerDecoration(irParam); + } + + // Add a [polymorphic] decoration for generic-typed parameters. + if (as(irParamType) && + as(irParamType->getFullType())) + { + subBuilder->addPolymorphicDecoration(irParam); } } -- cgit v1.2.3