From 565a5acd85c9a8ad12680ca1cbf249639fe0a6f5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 17 Oct 2020 15:13:14 +0200 Subject: [PATCH] - changed order of identifier types to be checked to what it was in 4.3 --- src/common/scripting/backend/codegen.cpp | 6 ++++++ src/common/scripting/backend/codegen.h | 1 + src/scripting/backend/codegen_doom.cpp | 14 +++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index fe3d8e9382..d17c47cad3 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -6055,6 +6055,12 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx) } } + if (compileEnvironment.CheckSpecialGlobalIdentifier) + { + auto result = compileEnvironment.CheckSpecialGlobalIdentifier(this, ctx); + if (result != this) return result; + } + if (auto *cvar = FindCVar(Identifier.GetChars(), nullptr)) { if (cvar->GetFlags() & CVAR_USERINFO) diff --git a/src/common/scripting/backend/codegen.h b/src/common/scripting/backend/codegen.h index bcadae39db..59037929c5 100644 --- a/src/common/scripting/backend/codegen.h +++ b/src/common/scripting/backend/codegen.h @@ -2131,6 +2131,7 @@ struct CompileEnvironment FxExpression* (*SpecialTypeCast)(FxTypeCast* func, FCompileContext& ctx); bool (*CheckForCustomAddition)(FxAddSub* func, FCompileContext& ctx); FxExpression* (*CheckSpecialIdentifier)(FxIdentifier* func, FCompileContext& ctx); + FxExpression* (*CheckSpecialGlobalIdentifier)(FxIdentifier* func, FCompileContext& ctx); FxExpression* (*ResolveSpecialIdentifier)(FxIdentifier* func, FxExpression*& object, PContainerType* objtype, FCompileContext& ctx); FxExpression* (*CheckSpecialMember)(FxStructMember* func, FCompileContext& ctx); FxExpression* (*CheckCustomGlobalFunctions)(FxFunctionCall* func, FCompileContext& ctx); diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index dab3ed1f0d..111147c2c0 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -165,7 +165,7 @@ static bool CheckForCustomAddition(FxAddSub *func, FCompileContext &ctx) // //========================================================================== -static FxExpression* CheckForDefault(FxIdentifier *func, FCompileContext &ctx) +static FxExpression* CheckForDefault(FxIdentifier* func, FCompileContext& ctx) { auto& ScriptPosition = func->ScriptPosition; @@ -190,11 +190,17 @@ static FxExpression* CheckForDefault(FxIdentifier *func, FCompileContext &ctx) return nullptr; } - FxExpression * x = new FxClassDefaults(new FxSelf(ScriptPosition), ScriptPosition); + FxExpression* x = new FxClassDefaults(new FxSelf(ScriptPosition), ScriptPosition); delete func; return x->Resolve(ctx); } - + return func; +} + +static FxExpression* CheckForLineSpecial(FxIdentifier* func, FCompileContext& ctx) +{ + auto& ScriptPosition = func->ScriptPosition; + // and line specials int num; if ((num = P_FindLineSpecial(func->Identifier.GetChars(), nullptr, nullptr))) @@ -215,6 +221,7 @@ static FxExpression* CheckForDefault(FxIdentifier *func, FCompileContext &ctx) static FxExpression *ResolveForDefault(FxIdentifier *expr, FxExpression*& object, PContainerType* objtype, FCompileContext &ctx) { + if (expr->Identifier == NAME_Default) { if (!isActor(objtype)) @@ -953,6 +960,7 @@ void SetDoomCompileEnvironment() compileEnvironment.SpecialTypeCast = CustomTypeCast; compileEnvironment.CheckForCustomAddition = CheckForCustomAddition; compileEnvironment.CheckSpecialIdentifier = CheckForDefault; + compileEnvironment.CheckSpecialGlobalIdentifier = CheckForLineSpecial; compileEnvironment.ResolveSpecialIdentifier = ResolveForDefault; compileEnvironment.CheckSpecialMember = CheckForMemberDefault; compileEnvironment.ResolveSpecialFunction = AJumpProcessing;