Merge branch 'zscript' into gz-zscript

This commit is contained in:
Christoph Oelckers 2016-11-15 15:35:35 +01:00
commit b0a0056097
2 changed files with 11 additions and 9 deletions

View file

@ -1847,8 +1847,8 @@ FxExpression *FxUnaryNotBoolean::Resolve(FCompileContext& ctx)
ExpEmit FxUnaryNotBoolean::Emit(VMFunctionBuilder *build) ExpEmit FxUnaryNotBoolean::Emit(VMFunctionBuilder *build)
{ {
assert(Operand->ValueType == ValueType); assert(Operand->ValueType == TypeBool);
assert(ValueType == TypeBool); assert(ValueType == TypeBool || IsInteger()); // this may have been changed by an int cast.
ExpEmit from = Operand->Emit(build); ExpEmit from = Operand->Emit(build);
assert(!from.Konst); assert(!from.Konst);
// boolean not is the same as XOR-ing the lowest bit // boolean not is the same as XOR-ing the lowest bit
@ -8069,11 +8069,10 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx)
{ {
if (!cls->IsDescendantOf(desttype)) if (!cls->IsDescendantOf(desttype))
{ {
ScriptPosition.Message(MSG_ERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); ScriptPosition.Message(MSG_OPTERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars());
delete this; cls = nullptr;
return nullptr;
} }
ScriptPosition.Message(MSG_DEBUGLOG, "resolving '%s' as class name", clsname.GetChars()); else ScriptPosition.Message(MSG_DEBUGLOG, "resolving '%s' as class name", clsname.GetChars());
} }
} }
FxExpression *x = new FxConstant(cls, to, ScriptPosition); FxExpression *x = new FxConstant(cls, to, ScriptPosition);

View file

@ -477,9 +477,12 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls)
exp = new FxRuntimeStateIndex(ParseExpressionM(sc, cls)); exp = new FxRuntimeStateIndex(ParseExpressionM(sc, cls));
} }
// The parsed expression is of type 'statelabel', but we want a real state here so we must convert it. // The parsed expression is of type 'statelabel', but we want a real state here so we must convert it.
FArgumentList args; if (!exp->isConstant())
args.Push(exp); {
exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc); FArgumentList args;
args.Push(exp);
exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc);
}
sc.MustGetToken(')'); sc.MustGetToken(')');
return exp; return exp;
} }