- 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.
This commit is contained in:
Christoph Oelckers 2016-10-19 16:15:02 +02:00
parent 458c68775f
commit 8a6230d64a
5 changed files with 17 additions and 13 deletions

View File

@ -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)
{

View File

@ -1079,16 +1079,16 @@ public:
//==========================================================================
//
// FxSequence
// FxCompoundStatement
//
//==========================================================================
class FxSequence : public FxExpression
class FxCompoundStatement : public FxExpression
{
TDeletingArray<FxExpression *> 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); }

View File

@ -314,7 +314,7 @@ do_stop:
ScriptCode = ParseActions(sc, state, statestring, bag, hasfinalret);
if (!hasfinalret && ScriptCode != nullptr)
{
static_cast<FxSequence *>(ScriptCode)->Add(new FxReturnStatement(nullptr, sc));
static_cast<FxCompoundStatement *>(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);
}

View File

@ -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*/ }

View File

@ -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<FxSequence *>(tcall->Code)->Add(new FxReturnStatement(nullptr, sc));
static_cast<FxCompoundStatement *>(tcall->Code)->Add(new FxReturnStatement(nullptr, sc));
}
*/