From d4d6b739e00c2ebf043e9cd05287b90774ddc206 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 13:52:38 +0100 Subject: [PATCH 1/3] - fixed: FxUnaryNotBoolean is not necessarily TypeBoolean, it can be altered by a type cast so the asserts had to be adjusted to cover that case. --- src/scripting/codegeneration/codegen.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 626dcde24..dad7402e8 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -1847,8 +1847,8 @@ FxExpression *FxUnaryNotBoolean::Resolve(FCompileContext& ctx) ExpEmit FxUnaryNotBoolean::Emit(VMFunctionBuilder *build) { - assert(Operand->ValueType == ValueType); - assert(ValueType == TypeBool); + assert(Operand->ValueType == TypeBool); + assert(ValueType == TypeBool || IsInteger()); // this may have been changed by an int cast. ExpEmit from = Operand->Emit(build); assert(!from.Konst); // boolean not is the same as XOR-ing the lowest bit From 97e643c7e1731e574f2bc5ffc78d1918b6f7e3ec Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 14:53:01 +0100 Subject: [PATCH 2/3] - fixed: DECORATE tried to resolved null states again, causing a type conflict. --- src/scripting/decorate/thingdef_exp.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/scripting/decorate/thingdef_exp.cpp b/src/scripting/decorate/thingdef_exp.cpp index 229c8f1f4..2d69be340 100644 --- a/src/scripting/decorate/thingdef_exp.cpp +++ b/src/scripting/decorate/thingdef_exp.cpp @@ -477,9 +477,12 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *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. - FArgumentList args; - args.Push(exp); - exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc); + if (!exp->isConstant()) + { + FArgumentList args; + args.Push(exp); + exp = new FxFunctionCall(NAME_ResolveState, NAME_None, args, sc); + } sc.MustGetToken(')'); return exp; } From 77a99890cf4a54c905c88602637f96675cc4f440 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 15 Nov 2016 15:34:00 +0100 Subject: [PATCH 3/3] - relaxed the message for incompatible class types in DECORATE to a warning. Like finding no class at all here, this initially fell under a situation that was not discoverable and there's mods that break by making it a fatal error. --- src/scripting/codegeneration/codegen.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index dad7402e8..f45bea5e3 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -8069,11 +8069,10 @@ FxExpression *FxClassTypeCast::Resolve(FCompileContext &ctx) { if (!cls->IsDescendantOf(desttype)) { - ScriptPosition.Message(MSG_ERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); - delete this; - return nullptr; + ScriptPosition.Message(MSG_OPTERROR, "class '%s' is not compatible with '%s'", clsname.GetChars(), desttype->TypeName.GetChars()); + cls = 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);