From 8823b60c0dbfb7e5d342d09728934fb7fdb0e83d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 9 Feb 2016 11:51:19 +0100 Subject: [PATCH] - fixed: FxClassTypeCast must use FindClassTentative to get the class type. This function may well be invoked before a class is actually defined, so it needs to create a placeholder to be filled in later. --- src/thingdef/thingdef_exp.h | 4 ++-- src/thingdef/thingdef_expression.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index 691d4b8723..6dd11a681b 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -913,12 +913,12 @@ public: class FxClassTypeCast : public FxExpression { - const PClass *desttype; + PClass *desttype; FxExpression *basex; public: - FxClassTypeCast(const PClass *dtype, FxExpression *x); + FxClassTypeCast(PClass *dtype, FxExpression *x); ~FxClassTypeCast(); FxExpression *Resolve(FCompileContext&); ExpEmit Emit(VMFunctionBuilder *build); diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index f4c2b1f608..9124071e57 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3503,7 +3503,7 @@ ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build, bool tailcall) // //========================================================================== -FxClassTypeCast::FxClassTypeCast(const PClass *dtype, FxExpression *x) +FxClassTypeCast::FxClassTypeCast(PClass *dtype, FxExpression *x) : FxExpression(x->ScriptPosition) { desttype = dtype; @@ -3542,11 +3542,11 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) if (basex->isConstant()) { FName clsname = static_cast(basex)->GetValue().GetName(); - const PClass *cls = NULL; + PClass *cls = NULL; if (clsname != NAME_None) { - cls = PClass::FindClass(clsname); + cls = desttype->FindClassTentative(clsname); if (cls == NULL) { /* lax */