summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-10-25 07:50:14 -0700
committerGitHub <noreply@github.com>2023-10-25 22:50:14 +0800
commit5dc3c2f57963de93ad03724a01ea48b8585dc15a (patch)
tree072748b952eb03da7950110ed3a8f87da9b5e72f /source/slang/slang-lower-to-ir.cpp
parentf8bf75cf1ae0aeee155996a917c2925bc500f3e2 (diff)
Add `IArray`. (#3281)
* Initial support for generic interfaces. * Cleanup. * Add generic syntax for interfaces. * Add `IArray`. * Fix. * Fix. * Fix. --------- Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp25
1 files changed, 16 insertions, 9 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index d75b66a9b..b4dac190a 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -1432,9 +1432,10 @@ bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl)
{
if (const auto funcDecl = as<CallableDecl>(requirementDecl))
{
- }
- else if (const auto propertyDecl = as<PropertyDecl>(requirementDecl))
- {
+ // Subscript decl itself won't have a witness table entry.
+ // But its accessors will.
+ if (const auto subscriptDecl = as<SubscriptDecl>(requirementDecl))
+ return false;
}
else if (const auto assocTypeDecl = as<AssocTypeDecl>(requirementDecl))
{
@@ -1451,6 +1452,9 @@ bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl)
}
else
{
+ // We will return false for PropertyDecl because the property decl itself
+ // won't have a witness table entry. Instead there will be witness entries
+ // for its accessors.
return false;
}
return true;
@@ -3020,6 +3024,7 @@ void _lowerFuncDeclBaseTypeInfo(
auto& parameterLists = outInfo.parameterLists;
collectParameterLists(
context,
+
declRef,
&parameterLists, kParameterListCollectMode_Default, kParameterDirection_In);
@@ -3501,6 +3506,14 @@ struct ExprLoweringContext
// appropriately.
auto funcDeclRef = resolvedInfo.funcDeclRef;
auto baseExpr = resolvedInfo.baseExpr;
+ if (baseExpr)
+ {
+ // The base expression might be an "upcast" to a base interface, in
+ // which case we don't want to emit the result of the cast, but instead
+ // the source.
+ //
+ baseExpr = this->maybeIgnoreCastToInterface(baseExpr);
+ }
// If the thing being invoked is a subscript operation,
// then we need to handle multiple extra details
@@ -3550,12 +3563,6 @@ struct ExprLoweringContext
// a member function:
if (baseExpr)
{
- // The base expression might be an "upcast" to a base interface, in
- // which case we don't want to emit the result of the cast, but instead
- // the source.
- //
- baseExpr = this->maybeIgnoreCastToInterface(baseExpr);
-
auto thisType = getThisParamTypeForCallable(context, funcDeclRef);
auto irThisType = lowerType(context, thisType);
addCallArgsForParam(