From 8a6230d64a23a8c51e5dc519322ceddc0ca51032 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 19 Oct 2016 16:15:02 +0200 Subject: [PATCH] - Renamed FxSequence to FxCompoundStatement. - fixed: The state parser was unable to accept empty anonymous functions, which should be treated as if there is none at all. --- src/scripting/codegeneration/codegen.cpp | 12 ++++++------ src/scripting/codegeneration/codegen.h | 6 +++--- src/scripting/decorate/thingdef_states.cpp | 6 +++--- src/scripting/zscript/zcc-parse.lemon | 4 ++++ src/scripting/zscript/zcc_compile.cpp | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index d5c70f493d..7a7ff7f130 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -5016,11 +5016,11 @@ ExpEmit FxFlopFunctionCall::Emit(VMFunctionBuilder *build) //========================================================================== // -// FxSequence :: Resolve +// FxCompoundStatement :: Resolve // //========================================================================== -FxExpression *FxSequence::Resolve(FCompileContext &ctx) +FxExpression *FxCompoundStatement::Resolve(FCompileContext &ctx) { CHECKRESOLVED(); for (unsigned i = 0; i < Expressions.Size(); ++i) @@ -5036,11 +5036,11 @@ FxExpression *FxSequence::Resolve(FCompileContext &ctx) //========================================================================== // -// FxSequence :: Emit +// FxCompoundStatement :: Emit // //========================================================================== -ExpEmit FxSequence::Emit(VMFunctionBuilder *build) +ExpEmit FxCompoundStatement::Emit(VMFunctionBuilder *build) { for (unsigned i = 0; i < Expressions.Size(); ++i) { @@ -5053,11 +5053,11 @@ ExpEmit FxSequence::Emit(VMFunctionBuilder *build) //========================================================================== // -// FxSequence :: GetDirectFunction +// FxCompoundStatement :: GetDirectFunction // //========================================================================== -VMFunction *FxSequence::GetDirectFunction() +VMFunction *FxCompoundStatement::GetDirectFunction() { if (Expressions.Size() == 1) { diff --git a/src/scripting/codegeneration/codegen.h b/src/scripting/codegeneration/codegen.h index c4e1753bd5..57a6d42579 100644 --- a/src/scripting/codegeneration/codegen.h +++ b/src/scripting/codegeneration/codegen.h @@ -1079,16 +1079,16 @@ public: //========================================================================== // -// FxSequence +// FxCompoundStatement // //========================================================================== -class FxSequence : public FxExpression +class FxCompoundStatement : public FxExpression { TDeletingArray Expressions; public: - FxSequence(const FScriptPosition &pos) : FxExpression(pos) {} + FxCompoundStatement(const FScriptPosition &pos) : FxExpression(pos) {} FxExpression *Resolve(FCompileContext&); ExpEmit Emit(VMFunctionBuilder *build); void Add(FxExpression *expr) { if (expr != NULL) Expressions.Push(expr); } diff --git a/src/scripting/decorate/thingdef_states.cpp b/src/scripting/decorate/thingdef_states.cpp index 59ec3e39d4..11db1504d5 100644 --- a/src/scripting/decorate/thingdef_states.cpp +++ b/src/scripting/decorate/thingdef_states.cpp @@ -314,7 +314,7 @@ do_stop: ScriptCode = ParseActions(sc, state, statestring, bag, hasfinalret); if (!hasfinalret && ScriptCode != nullptr) { - static_cast(ScriptCode)->Add(new FxReturnStatement(nullptr, sc)); + static_cast(ScriptCode)->Add(new FxReturnStatement(nullptr, sc)); } goto endofstate; } @@ -474,7 +474,7 @@ FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Bagg const FScriptPosition pos(sc); - FxSequence *seq = NULL; + FxCompoundStatement *seq = NULL; bool lastwasret = false; sc.MustGetString(); @@ -536,7 +536,7 @@ FxExpression *ParseActions(FScanner &sc, FState state, FString statestring, Bagg { if (seq == NULL) { - seq = new FxSequence(pos); + seq = new FxCompoundStatement(pos); } seq->Add(add); } diff --git a/src/scripting/zscript/zcc-parse.lemon b/src/scripting/zscript/zcc-parse.lemon index 43d7d02ab4..0c493d54aa 100644 --- a/src/scripting/zscript/zcc-parse.lemon +++ b/src/scripting/zscript/zcc-parse.lemon @@ -528,6 +528,10 @@ state_action(X) ::= LBRACE(T) statement_list(A) scanner_mode RBRACE. stmt->Content = A; X = stmt; } +state_action(X) ::= LBRACE scanner_mode RBRACE. +{ + X = NULL; +} state_action(X) ::= LBRACE error scanner_mode RBRACE. { X = NULL; } state_action(X) ::= state_call(A) scanner_mode SEMICOLON. { X = A; /*X-overwrites-A*/ } diff --git a/src/scripting/zscript/zcc_compile.cpp b/src/scripting/zscript/zcc_compile.cpp index 43219acb1e..e86a7c959e 100644 --- a/src/scripting/zscript/zcc_compile.cpp +++ b/src/scripting/zscript/zcc_compile.cpp @@ -2087,7 +2087,7 @@ FxExpression *ZCCCompiler::SetupActionFunction(PClassActor *cls, ZCC_TreeNode *a tcall->Code = ParseActions(sc, state, statestring, bag, hasfinalret); if (!hasfinalret && tcall->Code != nullptr) { - static_cast(tcall->Code)->Add(new FxReturnStatement(nullptr, sc)); + static_cast(tcall->Code)->Add(new FxReturnStatement(nullptr, sc)); } */