- split up FxCompoundStatement into the old FxSequence and a new subclass. FxSequence is just a sequence of expressions, while FxCompoundStatement is the one that actually implements handling of local variables. The split was done so that ZCCCompiler::ConvertNode can return multiple statements as one object and for that FxCompoundStatement is not suitable.

- added conversion of local variable declarations. This is still untested
This commit is contained in:
Christoph Oelckers 2016-10-20 01:09:35 +02:00
commit ffc38d422e
3 changed files with 95 additions and 21 deletions

View file

@ -1087,25 +1087,41 @@ public:
//==========================================================================
//
// FxCompoundStatement
// FxSequence (a list of statements with no semantics attached - used to return multiple nodes as one)
//
//==========================================================================
class FxLocalVariableDeclaration;
class FxCompoundStatement : public FxExpression
class FxSequence : public FxExpression
{
TDeletingArray<FxExpression *> Expressions;
public:
FxSequence(const FScriptPosition &pos) : FxExpression(pos) {}
FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build);
void Add(FxExpression *expr) { if (expr != NULL) Expressions.Push(expr); }
VMFunction *GetDirectFunction();
};
//==========================================================================
//
// FxCompoundStatement (like a list but implements maintenance of local variables)
//
//==========================================================================
class FxLocalVariableDeclaration;
class FxCompoundStatement : public FxSequence
{
TArray<FxLocalVariableDeclaration *> LocalVars;
TDeletingArray<FxExpression *> Expressions;
FxCompoundStatement *Outer = nullptr;
friend class FxLocalVariableDeclaration;
public:
FxCompoundStatement(const FScriptPosition &pos) : FxExpression(pos) {}
FxCompoundStatement(const FScriptPosition &pos) : FxSequence(pos) {}
FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build);
void Add(FxExpression *expr) { if (expr != NULL) Expressions.Push(expr); }
VMFunction *GetDirectFunction();
FxLocalVariableDeclaration *FindLocalVariable(FName name);
bool CheckLocalVariable(FName name);
};