- no more simplify in state parameters.

- resolving constants with the backend requires a few more error checks.
This commit is contained in:
Christoph Oelckers 2017-01-22 23:53:50 +01:00
commit 061ba48dc1
5 changed files with 119 additions and 72 deletions

View file

@ -5653,6 +5653,12 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
if (Identifier == NAME_Default)
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to access class defaults from constant declaration");
delete this;
return nullptr;
}
if (ctx.Function->Variants[0].SelfClass == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to access class defaults from static function");
@ -5680,6 +5686,13 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
{
if (sym->IsKindOf(RUNTIME_CLASS(PField)))
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to access class member %s from constant declaration", sym->SymbolName.GetChars());
delete this;
return nullptr;
}
FxExpression *self = new FxSelf(ScriptPosition);
self = self->Resolve(ctx);
newex = ResolveMember(ctx, ctx.Function->Variants[0].SelfClass, self, ctx.Function->Variants[0].SelfClass);
@ -5697,6 +5710,12 @@ FxExpression *FxIdentifier::Resolve(FCompileContext& ctx)
newex = FxConstant::MakeConstant(sym, ScriptPosition);
goto foundit;
}
else if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to access class member %s from constant declaration", sym->SymbolName.GetChars());
delete this;
return nullptr;
}
// Do this check for ZScript as well, so that a clearer error message can be printed. MSG_OPTERROR will default to MSG_ERROR there.
else if (ctx.Function->Variants[0].SelfClass != ctx.Class && sym->IsKindOf(RUNTIME_CLASS(PField)))
{
@ -7166,6 +7185,13 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
if (afd != nullptr)
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to call function %s from constant declaration", MethodName.GetChars());
delete this;
return nullptr;
}
if (!CheckFunctionCompatiblity(ScriptPosition, ctx.Function, afd))
{
delete this;
@ -7202,7 +7228,13 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx)
if (special != 0 && min >= 0)
{
int paramcount = ArgList.Size();
if (paramcount < min)
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to call action special %s from constant declaration", MethodName.GetChars());
delete this;
return nullptr;
}
else if (paramcount < min)
{
ScriptPosition.Message(MSG_ERROR, "Not enough parameters for '%s' (expected %d, got %d)",
MethodName.GetChars(), min, paramcount);
@ -7467,6 +7499,12 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
staticonly = true;
if (ccls->IsKindOf(RUNTIME_CLASS(PClass)))
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to call %s from constant declaration", MethodName.GetChars());
delete this;
return nullptr;
}
auto clstype = dyn_cast<PClass>(ctx.Function->Variants[0].SelfClass);
if (clstype != nullptr)
{
@ -7493,6 +7531,12 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
if (Self->ExprType == EFX_Super)
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to call %s from constant declaration", MethodName.GetChars());
delete this;
return nullptr;
}
auto clstype = dyn_cast<PClass>(ctx.Function->Variants[0].SelfClass);
if (clstype != nullptr)
{
@ -7743,6 +7787,12 @@ isresolved:
if (afd->Variants[0].Flags & VARF_Method)
{
if (ctx.Function == nullptr)
{
ScriptPosition.Message(MSG_ERROR, "Unable to call %s from constant declaration", MethodName.GetChars());
delete this;
return nullptr;
}
if (Self->ExprType == EFX_Self)
{
if (!CheckFunctionCompatiblity(ScriptPosition, ctx.Function, afd))