This commit is contained in:
Areloch 2017-11-05 22:33:32 -06:00
parent 03794ad3eb
commit 407bbce509
23 changed files with 9203 additions and 7477 deletions

View file

@ -56,7 +56,7 @@ struct StmtNode
StmtNode();
virtual ~StmtNode() {}
/// @name next Accessors
/// @{
@ -99,17 +99,17 @@ struct StmtNode
struct BreakStmtNode : StmtNode
{
static BreakStmtNode *alloc( S32 lineNumber );
static BreakStmtNode *alloc(S32 lineNumber);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(BreakStmtNode);
};
struct ContinueStmtNode : StmtNode
{
static ContinueStmtNode *alloc( S32 lineNumber );
static ContinueStmtNode *alloc(S32 lineNumber);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(ContinueStmtNode);
};
@ -117,7 +117,7 @@ struct ContinueStmtNode : StmtNode
/// A mathematical expression.
struct ExprNode : StmtNode
{
U32 compileStmt(CodeStream &codeStream, U32 ip);
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type) = 0;
@ -128,8 +128,8 @@ struct ReturnStmtNode : StmtNode
{
ExprNode *expr;
static ReturnStmtNode *alloc( S32 lineNumber, ExprNode *expr );
static ReturnStmtNode *alloc(S32 lineNumber, ExprNode *expr);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(ReturnStmtNode);
};
@ -143,10 +143,10 @@ struct IfStmtNode : StmtNode
bool integer;
bool propagate;
static IfStmtNode *alloc( S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagateThrough );
static IfStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagateThrough);
void propagateSwitchExpr(ExprNode *left, bool string);
ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(IfStmtNode);
};
@ -163,8 +163,8 @@ struct LoopStmtNode : StmtNode
U32 loopBlockStartOffset;
bool integer;
static LoopStmtNode *alloc( S32 lineNumber, ExprNode *testExpr, ExprNode *initExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop );
static LoopStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *initExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(LoopStmtNode);
};
@ -174,22 +174,22 @@ struct IterStmtNode : StmtNode
{
/// Local variable name to use for the container element.
StringTableEntry varName;
/// Expression evaluating to a SimSet object.
ExprNode* containerExpr;
/// The statement body.
StmtNode* body;
/// If true, this is a 'foreach$'.
bool isStringIter;
/// Bytecode size of body statement. Set by precompileStmt.
U32 bodySize;
static IterStmtNode* alloc( S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter );
U32 compileStmt( CodeStream &codeStream, U32 ip );
static IterStmtNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter);
U32 compileStmt(CodeStream &codeStream, U32 ip);
};
/// A binary mathematical expression (ie, left op right).
@ -202,8 +202,8 @@ struct BinaryExprNode : ExprNode
struct FloatBinaryExprNode : BinaryExprNode
{
static FloatBinaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right );
static FloatBinaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(FloatBinaryExprNode);
@ -215,8 +215,8 @@ struct ConditionalExprNode : ExprNode
ExprNode *trueExpr;
ExprNode *falseExpr;
bool integer;
static ConditionalExprNode *alloc( S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr );
static ConditionalExprNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr);
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
virtual TypeReq getPreferredType();
DBG_STMT_TYPE(ConditionalExprNode);
@ -227,10 +227,10 @@ struct IntBinaryExprNode : BinaryExprNode
TypeReq subType;
U32 operand;
static IntBinaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right );
static IntBinaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right);
void getSubTypeOperand();
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(IntBinaryExprNode);
@ -239,8 +239,8 @@ struct IntBinaryExprNode : BinaryExprNode
struct StreqExprNode : BinaryExprNode
{
bool eq;
static StreqExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right, bool eq );
static StreqExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, bool eq);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(StreqExprNode);
@ -249,8 +249,8 @@ struct StreqExprNode : BinaryExprNode
struct StrcatExprNode : BinaryExprNode
{
S32 appendChar;
static StrcatExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar );
static StrcatExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(StrcatExprNode);
@ -258,9 +258,9 @@ struct StrcatExprNode : BinaryExprNode
struct CommaCatExprNode : BinaryExprNode
{
static CommaCatExprNode *alloc( S32 lineNumber, ExprNode *left, ExprNode *right );
static CommaCatExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(CommaCatExprNode);
@ -272,8 +272,8 @@ struct IntUnaryExprNode : ExprNode
ExprNode *expr;
bool integer;
static IntUnaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *expr );
static IntUnaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *expr);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(IntUnaryExprNode);
@ -284,8 +284,8 @@ struct FloatUnaryExprNode : ExprNode
S32 op;
ExprNode *expr;
static FloatUnaryExprNode *alloc( S32 lineNumber, S32 op, ExprNode *expr );
static FloatUnaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *expr);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(FloatUnaryExprNode);
@ -296,8 +296,8 @@ struct VarNode : ExprNode
StringTableEntry varName;
ExprNode *arrayIndex;
static VarNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex );
static VarNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(VarNode);
@ -308,8 +308,8 @@ struct IntNode : ExprNode
S32 value;
U32 index; // if it's converted to float/string
static IntNode *alloc( S32 lineNumber, S32 value );
static IntNode *alloc(S32 lineNumber, S32 value);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(IntNode);
@ -320,8 +320,8 @@ struct FloatNode : ExprNode
F64 value;
U32 index;
static FloatNode *alloc( S32 lineNumber, F64 value );
static FloatNode *alloc(S32 lineNumber, F64 value);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(FloatNode);
@ -335,8 +335,8 @@ struct StrConstNode : ExprNode
bool tag;
bool doc; // Specifies that this string is a documentation block.
static StrConstNode *alloc( S32 lineNumber, char *str, bool tag, bool doc = false );
static StrConstNode *alloc(S32 lineNumber, char *str, bool tag, bool doc = false);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(StrConstNode);
@ -348,8 +348,8 @@ struct ConstantNode : ExprNode
F64 fVal;
U32 index;
static ConstantNode *alloc( S32 lineNumber, StringTableEntry value );
static ConstantNode *alloc(S32 lineNumber, StringTableEntry value);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(ConstantNode);
@ -362,8 +362,8 @@ struct AssignExprNode : ExprNode
ExprNode *arrayIndex;
TypeReq subType;
static AssignExprNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr );
static AssignExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(AssignExprNode);
@ -386,8 +386,8 @@ struct AssignOpExprNode : ExprNode
U32 operand;
TypeReq subType;
static AssignOpExprNode *alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op );
static AssignOpExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(AssignOpExprNode);
@ -399,8 +399,8 @@ struct TTagSetStmtNode : StmtNode
ExprNode *valueExpr;
ExprNode *stringExpr;
static TTagSetStmtNode *alloc( S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr );
static TTagSetStmtNode *alloc(S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr);
U32 compileStmt(CodeStream &codeStream, U32 ip);
DBG_STMT_TYPE(TTagSetStmtNode);
};
@ -409,8 +409,8 @@ struct TTagDerefNode : ExprNode
{
ExprNode *expr;
static TTagDerefNode *alloc( S32 lineNumber, ExprNode *expr );
static TTagDerefNode *alloc(S32 lineNumber, ExprNode *expr);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(TTagDerefNode);
@ -420,8 +420,8 @@ struct TTagExprNode : ExprNode
{
StringTableEntry tag;
static TTagExprNode *alloc( S32 lineNumber, StringTableEntry tag );
static TTagExprNode *alloc(S32 lineNumber, StringTableEntry tag);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(TTagExprNode);
@ -439,21 +439,33 @@ struct FuncCallExprNode : ExprNode
ParentCall
};
static FuncCallExprNode *alloc( S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot );
static FuncCallExprNode *alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(FuncCallExprNode);
};
struct FuncPointerCallExprNode : ExprNode
{
ExprNode *funcPointer;
ExprNode *args;
static FuncPointerCallExprNode *alloc(S32 lineNumber, ExprNode *stmt, ExprNode *args);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(FuncPointerCallExprNode);
};
struct AssertCallExprNode : ExprNode
{
ExprNode *testExpr;
const char *message;
U32 messageIndex;
static AssertCallExprNode *alloc( S32 lineNumber, ExprNode *testExpr, const char *message );
static AssertCallExprNode *alloc(S32 lineNumber, ExprNode *testExpr, const char *message);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(AssertCallExprNode);
@ -472,8 +484,8 @@ struct SlotAccessNode : ExprNode
ExprNode *objectExpr, *arrayExpr;
StringTableEntry slotName;
static SlotAccessNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName );
static SlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(SlotAccessNode);
@ -492,8 +504,8 @@ struct InternalSlotAccessNode : ExprNode
ExprNode *objectExpr, *slotExpr;
bool recurse;
static InternalSlotAccessNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse );
static InternalSlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(InternalSlotAccessNode);
@ -506,8 +518,8 @@ struct SlotAssignNode : ExprNode
ExprNode *valueExpr;
U32 typeID;
static SlotAssignNode *alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID = -1 );
static SlotAssignNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID = -1);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(SlotAssignNode);
@ -522,8 +534,8 @@ struct SlotAssignOpNode : ExprNode
U32 operand;
TypeReq subType;
static SlotAssignOpNode *alloc( S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr );
static SlotAssignOpNode *alloc(S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
TypeReq getPreferredType();
DBG_STMT_TYPE(SlotAssignOpNode);
@ -542,8 +554,8 @@ struct ObjectDeclNode : ExprNode
bool isClassNameInternal;
bool isSingleton;
static ObjectDeclNode *alloc( S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton );
static ObjectDeclNode *alloc(S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton);
U32 precompileSubObject(bool);
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
U32 compileSubObject(CodeStream &codeStream, U32 ip, bool);
@ -567,8 +579,8 @@ struct FunctionDeclStmtNode : StmtNode
U32 endOffset;
U32 argc;
static FunctionDeclStmtNode *alloc( S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts );
static FunctionDeclStmtNode *alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts);
U32 compileStmt(CodeStream &codeStream, U32 ip);
void setPackage(StringTableEntry packageName);
DBG_STMT_TYPE(FunctionDeclStmtNode);