- 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.
This commit is contained in:
Christoph Oelckers 2016-02-09 11:51:19 +01:00
parent 1ca2293983
commit 8823b60c0d
2 changed files with 5 additions and 5 deletions

View file

@ -913,12 +913,12 @@ public:
class FxClassTypeCast : public FxExpression class FxClassTypeCast : public FxExpression
{ {
const PClass *desttype; PClass *desttype;
FxExpression *basex; FxExpression *basex;
public: public:
FxClassTypeCast(const PClass *dtype, FxExpression *x); FxClassTypeCast(PClass *dtype, FxExpression *x);
~FxClassTypeCast(); ~FxClassTypeCast();
FxExpression *Resolve(FCompileContext&); FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build); ExpEmit Emit(VMFunctionBuilder *build);

View file

@ -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) : FxExpression(x->ScriptPosition)
{ {
desttype = dtype; desttype = dtype;
@ -3542,11 +3542,11 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
if (basex->isConstant()) if (basex->isConstant())
{ {
FName clsname = static_cast<FxConstant *>(basex)->GetValue().GetName(); FName clsname = static_cast<FxConstant *>(basex)->GetValue().GetName();
const PClass *cls = NULL; PClass *cls = NULL;
if (clsname != NAME_None) if (clsname != NAME_None)
{ {
cls = PClass::FindClass(clsname); cls = desttype->FindClassTentative(clsname);
if (cls == NULL) if (cls == NULL)
{ {
/* lax */ /* lax */