From cb6504669d1b69172b4fdb69d1a9fe170568288e Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Fri, 5 Feb 2016 16:34:17 -0600 Subject: [PATCH] Add return statements for DECORATE. --- src/thingdef/thingdef_exp.h | 13 +++++++++++++ src/thingdef/thingdef_expression.cpp | 15 +++++++++++++++ src/thingdef/thingdef_states.cpp | 6 ++++++ 3 files changed, 34 insertions(+) diff --git a/src/thingdef/thingdef_exp.h b/src/thingdef/thingdef_exp.h index d1f7e75da..691d4b872 100644 --- a/src/thingdef/thingdef_exp.h +++ b/src/thingdef/thingdef_exp.h @@ -892,6 +892,19 @@ public: ExpEmit Emit(VMFunctionBuilder *build, bool tailcall); }; +//========================================================================== +// +// FxReturnStatement +// +//========================================================================== + +class FxReturnStatement : public FxTailable +{ +public: + FxReturnStatement(const FScriptPosition &pos); + ExpEmit Emit(VMFunctionBuilder *build, bool tailcall); +}; + //========================================================================== // // diff --git a/src/thingdef/thingdef_expression.cpp b/src/thingdef/thingdef_expression.cpp index 2a756a68c..19c02837c 100644 --- a/src/thingdef/thingdef_expression.cpp +++ b/src/thingdef/thingdef_expression.cpp @@ -3484,6 +3484,21 @@ ExpEmit FxIfStatement::Emit(VMFunctionBuilder *build, bool tailcall) // //========================================================================== +FxReturnStatement::FxReturnStatement(const FScriptPosition &pos) +: FxTailable(pos) +{ +} + +ExpEmit FxReturnStatement::Emit(VMFunctionBuilder *build, bool tailcall) +{ + build->Emit(OP_RET, RET_FINAL, REGT_NIL, 0); + return ExpEmit(); +} + +//========================================================================== +// +//========================================================================== + FxClassTypeCast::FxClassTypeCast(const PClass *dtype, FxExpression *x) : FxExpression(x->ScriptPosition) { diff --git a/src/thingdef/thingdef_states.cpp b/src/thingdef/thingdef_states.cpp index a44fa1ed1..d6f3eb939 100644 --- a/src/thingdef/thingdef_states.cpp +++ b/src/thingdef/thingdef_states.cpp @@ -386,6 +386,12 @@ FxTailable *ParseActions(FScanner &sc, FState state, FString statestring, Baggag } add = new FxIfStatement(cond, true_part, false_part, sc); } + else if (sc.Compare("return")) + { // Handle a return statement + sc.MustGetStringName(";"); + sc.MustGetString(); + add = new FxReturnStatement(sc); + } else { // Handle a regular action function call add = ParseAction(sc, state, statestring, bag);