- added static constant arrays. At the moment they can only be defined inside functions due to lack of dedicated storage inside classes for static data.

- added new VM instructions to access the constant tables with a variable index.
- refactored VMFunctionBuilder's constant tables so that they are not limited to one entry per value. While this works fine for single values, it makes it impossible to store constant arrays in here.
This commit is contained in:
Christoph Oelckers 2016-11-20 18:00:37 +01:00
commit 5951a9449c
11 changed files with 412 additions and 105 deletions

View file

@ -282,6 +282,8 @@ enum EFxType
EFX_Super,
EFX_StackVariable,
EFX_MultiAssign,
EFX_StaticArray,
EFX_StaticArrayVariable,
EFX_COUNT
};
@ -1308,6 +1310,25 @@ public:
ExpEmit Emit(VMFunctionBuilder *build);
};
//==========================================================================
//
// FxLocalVariable
//
//==========================================================================
class FxStaticArray;
class FxStaticArrayVariable : public FxExpression
{
public:
FxStaticArray *Variable;
bool AddressRequested;
FxStaticArrayVariable(FxLocalVariableDeclaration*, const FScriptPosition&);
FxExpression *Resolve(FCompileContext&);
bool RequestAddress(FCompileContext &ctx, bool *writable);
ExpEmit Emit(VMFunctionBuilder *build);
};
//==========================================================================
//
// FxSelf
@ -1529,6 +1550,7 @@ class FxCompoundStatement : public FxSequence
FxCompoundStatement *Outer = nullptr;
friend class FxLocalVariableDeclaration;
friend class FxStaticArray;
friend class FxMultiAssign;
public:
@ -1841,6 +1863,7 @@ class FxLocalVariableDeclaration : public FxExpression
{
friend class FxCompoundStatement;
friend class FxLocalVariable;
friend class FxStaticArrayVariable;
FName Name;
FxExpression *Init;
@ -1859,4 +1882,25 @@ public:
};
//==========================================================================
//
//
//
//==========================================================================
class FxStaticArray : public FxLocalVariableDeclaration
{
friend class FxStaticArrayVariable;
PType *ElementType;
FArgumentList values;
public:
FxStaticArray(PType *type, FName name, FArgumentList &args, const FScriptPosition &pos);
FxExpression *Resolve(FCompileContext&);
ExpEmit Emit(VMFunctionBuilder *build);
};
#endif