From 2a0c3e63a365fda17b421b02147a3083abb0cee7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 20 Jul 2018 10:38:55 +0200 Subject: [PATCH] - allow temporary strings to be used as self pointer for String's member functions. Due to how function calls get resolved by the code generator there were some incorrect flags on the self pointer which triggered an assert and caused incorrect code generation. Fortunately this was a mostly contained special case for which a workaround was possible. --- src/scripting/backend/codegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripting/backend/codegen.cpp b/src/scripting/backend/codegen.cpp index 36e680c668..75f04d4213 100644 --- a/src/scripting/backend/codegen.cpp +++ b/src/scripting/backend/codegen.cpp @@ -9057,7 +9057,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build) { assert(Self != nullptr); selfemit = Self->Emit(build); - assert((selfemit.RegType == REGT_POINTER) || (selfemit.Fixed && selfemit.Target)); + assert(selfemit.RegType == REGT_POINTER || selfemit.RegType == REGT_STRING || (selfemit.Fixed && selfemit.Target)); int innerside = FScopeBarrier::SideFromFlags(Function->Variants[0].Flags); @@ -9077,7 +9077,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build) } } - if (selfemit.Fixed && selfemit.Target) + if ((selfemit.Fixed && selfemit.Target) || selfemit.RegType == REGT_STRING) { // Address of a local variable. build->Emit(OP_PARAM, 0, selfemit.RegType | REGT_ADDROF, selfemit.RegNum);