summaryrefslogtreecommitdiff
path: root/source/slang/slang-lower-to-ir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/slang/slang-lower-to-ir.cpp')
-rw-r--r--source/slang/slang-lower-to-ir.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index ab488a41f..d2d15735c 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -2961,6 +2961,16 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
if (auto aggTypeDeclRef = declRef.as<AggTypeDecl>())
{
List<IRInst*> args;
+
+ if (auto structTypeDeclRef = aggTypeDeclRef.as<StructDecl>())
+ {
+ if (auto baseStructType = findBaseStructType(getASTBuilder(), structTypeDeclRef))
+ {
+ auto irBaseVal = getSimpleVal(context, getDefaultVal(baseStructType));
+ args.add(irBaseVal);
+ }
+ }
+
for (auto ff : getMembersOfType<VarDecl>(aggTypeDeclRef, MemberFilterStyle::Instance))
{
auto irFieldVal = getSimpleVal(context, getDefaultVal(ff));
@@ -3082,6 +3092,30 @@ struct ExprLoweringVisitorBase : ExprVisitor<Derived, LoweredValInfo>
if (auto aggTypeDeclRef = declRef.as<AggTypeDecl>())
{
UInt argCounter = 0;
+
+ // If the type is a structure type that inherits from another
+ // structure type, then we need to treat the base type as
+ // an implicit first field.
+ //
+ if(auto structTypeDeclRef = aggTypeDeclRef.as<StructDecl>())
+ {
+ if (auto baseStructType = findBaseStructType(getASTBuilder(), structTypeDeclRef))
+ {
+ UInt argIndex = argCounter++;
+ if (argIndex < argCount)
+ {
+ auto argExpr = expr->args[argIndex];
+ LoweredValInfo argVal = lowerRValueExpr(context, argExpr);
+ args.add(getSimpleVal(context, argVal));
+ }
+ else
+ {
+ auto irDefaultValue = getSimpleVal(context, getDefaultVal(baseStructType));
+ args.add(irDefaultValue);
+ }
+ }
+ }
+
for (auto ff : getMembersOfType<VarDecl>(aggTypeDeclRef, MemberFilterStyle::Instance))
{
UInt argIndex = argCounter++;