Skip to content

Commit

Permalink
- changed order of identifier types to be checked to what it was in 4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 17, 2020
1 parent 28a12d2 commit 565a5ac
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/common/scripting/backend/codegen.cpp
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/common/scripting/backend/codegen.h
Expand Up @@ -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);
Expand Down
14 changes: 11 additions & 3 deletions src/scripting/backend/codegen_doom.cpp
Expand Up @@ -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;

Expand All @@ -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)))
Expand All @@ -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))
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 565a5ac

Please sign in to comment.