- fixed and cleaned up state index jump handling
* use the function build list instead of the function to pass the info. The function is permanent so not the best place for compile-time info. * pass along the current state index which is needed to calculate the target state.
This commit is contained in:
parent
c354000f1c
commit
2ac0046cda
9 changed files with 24 additions and 18 deletions
|
|
@ -93,12 +93,14 @@ static const FLOP FxFlops[] =
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FCompileContext::FCompileContext(PFunction *fnc, PPrototype *ret, bool fromdecorate) : ReturnProto(ret), Function(fnc), Class(nullptr), FromDecorate(fromdecorate)
|
||||
FCompileContext::FCompileContext(PFunction *fnc, PPrototype *ret, bool fromdecorate, int stateindex, int statecount)
|
||||
: ReturnProto(ret), Function(fnc), Class(nullptr), FromDecorate(fromdecorate), StateIndex(stateindex), StateCount(statecount)
|
||||
{
|
||||
if (fnc != nullptr) Class = fnc->OwningClass;
|
||||
}
|
||||
|
||||
FCompileContext::FCompileContext(PClass *cls, bool fromdecorate) : ReturnProto(nullptr), Function(nullptr), Class(cls), FromDecorate(fromdecorate)
|
||||
FCompileContext::FCompileContext(PClass *cls, bool fromdecorate)
|
||||
: ReturnProto(nullptr), Function(nullptr), Class(cls), FromDecorate(fromdecorate), StateIndex(-1), StateCount(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -1426,13 +1428,13 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx)
|
|||
}
|
||||
else if (basex->IsNumeric() && basex->ValueType != TypeSound && basex->ValueType != TypeColor)
|
||||
{
|
||||
if (ctx.Function->SymbolName != NAME_None || !(ctx.Function->Variants[0].Flags & VARF_Action))
|
||||
if (ctx.StateIndex < 0)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "State jumps with index can only be used in anonymous state functions.");
|
||||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
if (ctx.Function->StateCount != 1)
|
||||
if (ctx.StateCount != 1)
|
||||
{
|
||||
ScriptPosition.Message(MSG_ERROR, "State jumps with index cannot be used on multistate definitions");
|
||||
delete this;
|
||||
|
|
@ -1447,7 +1449,7 @@ FxExpression *FxTypeCast::Resolve(FCompileContext &ctx)
|
|||
delete this;
|
||||
return nullptr;
|
||||
}
|
||||
FxExpression *x = new FxStateByIndex(i, ScriptPosition);
|
||||
FxExpression *x = new FxStateByIndex(ctx.StateIndex + i, ScriptPosition);
|
||||
x = x->Resolve(ctx);
|
||||
basex = nullptr;
|
||||
delete this;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue