- reinstated abort-on-error for any problem that gets reported during DECORATE code generation.

- fixed: DECORATE allowed a silent conversion from names to integers.

In old versions the name was converted to 0, since the scripting branch to the name index. Reverted to the old behavior but added a warning message.
This commit is contained in:
Christoph Oelckers 2016-06-08 10:46:35 +02:00
parent 1703842a94
commit cf21bb1524
3 changed files with 37 additions and 16 deletions

View file

@ -431,11 +431,11 @@ void LoadActors ()
FScanner sc(lump); FScanner sc(lump);
ParseDecorate (sc); ParseDecorate (sc);
} }
FinishThingdef();
if (FScriptPosition::ErrorCounter > 0) if (FScriptPosition::ErrorCounter > 0)
{ {
I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter); I_Error("%d errors while parsing DECORATE scripts", FScriptPosition::ErrorCounter);
} }
FinishThingdef();
timer.Unclock(); timer.Unclock();
if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS()); if (!batchrun) Printf("DECORATE parsing took %.2f ms\n", timer.TimeMS());
// Base time: ~52 ms // Base time: ~52 ms

View file

@ -208,7 +208,7 @@ public:
virtual bool isConstant() const; virtual bool isConstant() const;
virtual void RequestAddress(); virtual void RequestAddress();
virtual VMFunction *GetDirectFunction(); virtual VMFunction *GetDirectFunction();
bool IsNumeric() const { return ValueType->GetRegType() == REGT_INT || ValueType->GetRegType() == REGT_FLOAT; } bool IsNumeric() const { return ValueType != TypeName && (ValueType->GetRegType() == REGT_INT || ValueType->GetRegType() == REGT_FLOAT); }
bool IsPointer() const { return ValueType->GetRegType() == REGT_POINTER; } bool IsPointer() const { return ValueType->GetRegType() == REGT_POINTER; }
virtual ExpEmit Emit(VMFunctionBuilder *build); virtual ExpEmit Emit(VMFunctionBuilder *build);

View file

@ -358,10 +358,22 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
if (basex->ValueType->GetRegType() == REGT_INT) if (basex->ValueType->GetRegType() == REGT_INT)
{ {
FxExpression *x = basex; if (basex->ValueType != TypeName)
basex = NULL; {
delete this; FxExpression *x = basex;
return x; basex = NULL;
delete this;
return x;
}
else
{
// Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :(
if (!basex->isConstant()) ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got a name");
else ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got \"%s\"", static_cast<FxConstant*>(basex)->GetValue().GetName().GetChars());
FxExpression * x = new FxConstant(0, ScriptPosition);
delete this;
return x;
}
} }
else if (basex->ValueType->GetRegType() == REGT_FLOAT) else if (basex->ValueType->GetRegType() == REGT_FLOAT)
{ {
@ -374,12 +386,9 @@ FxExpression *FxIntCast::Resolve(FCompileContext &ctx)
} }
return this; return this;
} }
else ScriptPosition.Message(MSG_ERROR, "Numeric type expected");
{ delete this;
ScriptPosition.Message(MSG_ERROR, "Numeric type expected"); return NULL;
delete this;
return NULL;
}
} }
//========================================================================== //==========================================================================
@ -443,14 +452,26 @@ FxExpression *FxFloatCast::Resolve(FCompileContext &ctx)
} }
else if (basex->ValueType->GetRegType() == REGT_INT) else if (basex->ValueType->GetRegType() == REGT_INT)
{ {
if (basex->isConstant()) if (basex->ValueType != TypeName)
{ {
ExpVal constval = static_cast<FxConstant *>(basex)->GetValue(); if (basex->isConstant())
FxExpression *x = new FxConstant(constval.GetFloat(), ScriptPosition); {
ExpVal constval = static_cast<FxConstant *>(basex)->GetValue();
FxExpression *x = new FxConstant(constval.GetFloat(), ScriptPosition);
delete this;
return x;
}
return this;
}
else
{
// Ugh. This should abort, but too many mods fell into this logic hole somewhere, so this seroious error needs to be reduced to a warning. :(
if (!basex->isConstant()) ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got a name");
else ScriptPosition.Message(MSG_WARNING, "Numeric type expected, got \"%s\"", static_cast<FxConstant*>(basex)->GetValue().GetName().GetChars());
FxExpression *x = new FxConstant(0.0, ScriptPosition);
delete this; delete this;
return x; return x;
} }
return this;
} }
else else
{ {