- removed a parsing hack for the old internal definitions.

- fixed: The state cast hack for DECORATE could not properly create state constants.

Instead they were passed to FxRuntimeStateIndex without resolving them to something constant. This adds proper handling of constant indices within that class.
This commit is contained in:
Christoph Oelckers 2016-11-06 23:10:23 +01:00
parent 779f9d7a72
commit 7da4e0d03d
2 changed files with 22 additions and 10 deletions

View file

@ -8101,12 +8101,28 @@ FxExpression *FxRuntimeStateIndex::Resolve(FCompileContext &ctx)
delete this;
return nullptr;
}
else if (Index->isConstant() && static_cast<FxConstant *>(Index)->GetValue().GetInt() <= 0)
else if (Index->isConstant())
{
int index = static_cast<FxConstant *>(Index)->GetValue().GetInt();
if (index < 0 || (index == 0 && !ctx.FromDecorate))
{
ScriptPosition.Message(MSG_ERROR, "State index must be positive");
delete this;
return nullptr;
}
else if (index == 0)
{
auto x = new FxConstant((FState*)nullptr, ScriptPosition);
delete this;
return x->Resolve(ctx);
}
else
{
auto x = new FxStateByIndex(index, ScriptPosition);
delete this;
return x->Resolve(ctx);
}
}
else if (Index->ValueType->GetRegType() != REGT_INT)
{ // Float.
Index = new FxIntCast(Index, ctx.FromDecorate);

View file

@ -181,15 +181,11 @@ FxExpression *ParseParameter(FScanner &sc, PClassActor *cls, PType *type, bool c
{
if (sc.String[0] == 0 || sc.Compare("None"))
{
x = new FxConstant((FState*)NULL, sc);
x = new FxConstant((FState*)nullptr, sc);
}
else if (sc.Compare("*"))
{
if (constant)
{
x = new FxConstant((FState*)(intptr_t)-1, sc);
}
else sc.ScriptError("Invalid state name '*'");
sc.ScriptError("Invalid state name '*'");
}
else
{