From dfdf243f07c977fa59b1a5968ce053bf590f8120 Mon Sep 17 00:00:00 2001 From: Yong He Date: Tue, 26 Mar 2024 17:35:24 -0700 Subject: Support mutable existential parameters. (#3836) * Support mutable existential parameters. * Update test. --- source/slang/slang-lower-to-ir.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 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 41638dc83..799faec88 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -2503,6 +2503,7 @@ void addArg( LoweredValInfo argVal, //< The lowered value of the argument to add IRType* paramType, //< The type of the corresponding parameter ParameterDirection paramDirection, //< The direction of the parameter (`in`, `out`, etc.) + Type* argType, //< The AST-level type of the argument SourceLoc loc) //< A location to use if we need to report an error { switch(paramDirection) @@ -2543,6 +2544,12 @@ void addArg( // If the value is not one that could yield a simple l-value // then we need to convert it into a temporary // + if (as(paramType)) + { + // When paramType is ThisType, we need to get the actual argument type + // from the arg. + paramType = lowerType(context, argType); + } if (auto refType = as(paramType)) { paramType = refType->getValueType(); @@ -2616,7 +2623,7 @@ void addCallArgsForParam( case kParameterDirection_InOut: { LoweredValInfo loweredArg = lowerLValueExpr(context, argExpr); - addArg(context, ioArgs, ioFixups, loweredArg, paramType, paramDirection, argExpr->loc); + addArg(context, ioArgs, ioFixups, loweredArg, paramType, paramDirection, argExpr->type, argExpr->loc); } break; @@ -3223,7 +3230,7 @@ static LoweredValInfo _emitCallToAccessor( auto thisParam = info.parameterLists.params[0]; auto thisParamType = lowerType(context, thisParam.type); - addArg(context, &allArgs, &fixups, base, thisParamType, thisParam.direction, SourceLoc()); + addArg(context, &allArgs, &fixups, base, thisParamType, thisParam.direction, thisParam.type, SourceLoc()); } allArgs.addRange(args, argCount); -- cgit v1.2.3