Torque3D/Engine/source/console/torquescript/ast.h

612 lines
16 KiB
C
Raw Normal View History

2012-09-19 15:15:01 +00:00
//-----------------------------------------------------------------------------
// Copyright (c) 2012 GarageGames, LLC
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.
//-----------------------------------------------------------------------------
#ifndef _AST_H_
#define _AST_H_
2023-04-23 08:39:54 +00:00
#include "evalState.h"
#include "platform/types.h"
2012-09-19 15:15:01 +00:00
class SimObject;
class SimGroup;
class CodeStream;
2012-09-19 15:15:01 +00:00
/// Enable this #define if you are seeing the message "precompile size mismatch" in the console.
/// This will help track down which node type is causing the error. It could be
/// due to incorrect compiler optimization.
//#define DEBUG_AST_NODES
enum TypeReq
{
TypeReqNone,
TypeReqUInt,
TypeReqFloat,
2021-03-30 23:33:19 +00:00
TypeReqString
};
enum ExprNodeName
{
NameExprNode,
NameFloatNode,
NameIntNode,
NameVarNode
2012-09-19 15:15:01 +00:00
};
/// Representation of a node for the scripting language parser.
///
/// When the scripting language is evaluated, it is turned from a string representation,
/// into a parse tree, thence into byte code, which is ultimately interpreted by the VM.
///
/// This is the base class for the nodes in the parse tree. There are a great many subclasses,
/// each representing a different language construct.
struct StmtNode
{
2021-03-30 23:33:19 +00:00
StmtNode* next; ///< Next entry in parse tree.
2012-09-19 15:15:01 +00:00
StmtNode();
virtual ~StmtNode() {}
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
/// @name next Accessors
/// @{
///
2021-03-30 23:33:19 +00:00
void append(StmtNode* next);
StmtNode* getNext() const { return next; }
2012-09-19 15:15:01 +00:00
/// @}
/// @name Debug Info
/// @{
StringTableEntry dbgFileName; ///< Name of file this node is associated with.
S32 dbgLineNumber; ///< Line number this node is associated with.
#ifdef DEBUG_AST_NODES
virtual String dbgStmtType() const = 0;
#endif
/// @}
/// @name Breaking
/// @{
2021-03-30 23:33:19 +00:00
void addBreakLine(CodeStream& codeStream);
2012-09-19 15:15:01 +00:00
/// @}
/// @name Compilation
/// @{
2021-03-30 23:33:19 +00:00
virtual U32 compileStmt(CodeStream& codeStream, U32 ip) = 0;
2012-09-19 15:15:01 +00:00
virtual void setPackage(StringTableEntry packageName);
/// @}
};
/// Helper macro
#ifndef DEBUG_AST_NODES
2021-03-30 23:33:19 +00:00
# define DBG_STMT_TYPE(s) virtual const char* dbgStmtType() const { return "#s"; }
2012-09-19 15:15:01 +00:00
#else
2023-04-23 08:39:54 +00:00
# define DBG_STMT_TYPE(s)
2012-09-19 15:15:01 +00:00
#endif
struct BreakStmtNode : StmtNode
{
2021-03-30 23:33:19 +00:00
static BreakStmtNode* alloc(S32 lineNumber);
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(BreakStmtNode);
};
struct ContinueStmtNode : StmtNode
{
2021-03-30 23:33:19 +00:00
static ContinueStmtNode* alloc(S32 lineNumber);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(ContinueStmtNode);
};
/// A mathematical expression.
struct ExprNode : StmtNode
{
2021-03-30 23:33:19 +00:00
ExprNode* optimizedNode;
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
2021-03-30 23:33:19 +00:00
virtual U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) = 0;
2012-09-19 15:15:01 +00:00
virtual TypeReq getPreferredType() = 0;
2021-03-30 23:33:19 +00:00
virtual ExprNodeName getExprNodeNameEnum() const { return NameExprNode; }
2012-09-19 15:15:01 +00:00
};
struct ReturnStmtNode : StmtNode
{
2021-03-30 23:33:19 +00:00
ExprNode* expr;
2012-09-19 15:15:01 +00:00
2021-03-30 23:33:19 +00:00
static ReturnStmtNode* alloc(S32 lineNumber, ExprNode* expr);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(ReturnStmtNode);
};
struct IfStmtNode : StmtNode
{
2021-03-30 23:33:19 +00:00
ExprNode* testExpr;
StmtNode* ifBlock, * elseBlock;
2012-09-19 15:15:01 +00:00
U32 endifOffset;
U32 elseOffset;
bool integer;
bool propagate;
2021-03-30 23:33:19 +00:00
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);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(IfStmtNode);
};
struct LoopStmtNode : StmtNode
{
2021-03-30 23:33:19 +00:00
ExprNode* testExpr;
ExprNode* initExpr;
ExprNode* endLoopExpr;
StmtNode* loopBlock;
2012-09-19 15:15:01 +00:00
bool isDoLoop;
U32 breakOffset;
U32 continueOffset;
U32 loopBlockStartOffset;
bool integer;
2021-03-30 23:33:19 +00:00
static LoopStmtNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* initExpr, ExprNode* endLoopExpr, StmtNode* loopBlock, bool isDoLoop);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(LoopStmtNode);
};
/// A "foreach" statement.
struct IterStmtNode : StmtNode
{
/// Local variable name to use for the container element.
StringTableEntry varName;
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
/// Expression evaluating to a SimSet object.
ExprNode* containerExpr;
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
/// The statement body.
StmtNode* body;
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
/// If true, this is a 'foreach$'.
bool isStringIter;
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
/// Bytecode size of body statement. Set by precompileStmt.
U32 bodySize;
2017-11-06 04:33:32 +00:00
static IterStmtNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter);
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
};
/// A binary mathematical expression (ie, left op right).
struct BinaryExprNode : ExprNode
{
S32 op;
2021-03-30 23:33:19 +00:00
ExprNode* left;
ExprNode* right;
2012-09-19 15:15:01 +00:00
};
struct FloatBinaryExprNode : BinaryExprNode
{
2021-03-30 23:33:19 +00:00
static FloatBinaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right);
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
2021-03-30 23:33:19 +00:00
bool optimize();
2017-11-06 04:33:32 +00:00
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(FloatBinaryExprNode);
};
struct ConditionalExprNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* testExpr;
ExprNode* trueExpr;
ExprNode* falseExpr;
2012-09-19 15:15:01 +00:00
bool integer;
2021-03-30 23:33:19 +00:00
static ConditionalExprNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* trueExpr, ExprNode* falseExpr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(ConditionalExprNode);
};
struct IntBinaryExprNode : BinaryExprNode
{
TypeReq subType;
U32 operand;
2021-03-30 23:33:19 +00:00
static IntBinaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right);
2012-09-19 15:15:01 +00:00
void getSubTypeOperand();
2017-11-06 04:33:32 +00:00
2021-03-30 23:33:19 +00:00
bool optimize();
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(IntBinaryExprNode);
};
struct StreqExprNode : BinaryExprNode
{
bool eq;
2021-03-30 23:33:19 +00:00
static StreqExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, bool eq);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(StreqExprNode);
};
struct StrcatExprNode : BinaryExprNode
{
S32 appendChar;
2021-03-30 23:33:19 +00:00
static StrcatExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, S32 appendChar);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(StrcatExprNode);
};
struct CommaCatExprNode : BinaryExprNode
{
2021-03-30 23:33:19 +00:00
static CommaCatExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right);
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(CommaCatExprNode);
};
struct IntUnaryExprNode : ExprNode
{
S32 op;
2021-03-30 23:33:19 +00:00
ExprNode* expr;
2012-09-19 15:15:01 +00:00
bool integer;
2021-03-30 23:33:19 +00:00
static IntUnaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* expr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(IntUnaryExprNode);
};
struct FloatUnaryExprNode : ExprNode
{
S32 op;
2021-03-30 23:33:19 +00:00
ExprNode* expr;
2012-09-19 15:15:01 +00:00
2021-03-30 23:33:19 +00:00
static FloatUnaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* expr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(FloatUnaryExprNode);
};
struct VarNode : ExprNode
{
StringTableEntry varName;
2021-03-30 23:33:19 +00:00
ExprNode* arrayIndex;
2012-09-19 15:15:01 +00:00
ExprNode* defaultValue; // optional expression
2021-03-30 23:33:19 +00:00
static VarNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex);
2017-11-06 04:33:32 +00:00
// function params initialization.
static VarNode* allocParam(S32 lineNumber, StringTableEntry varName, ExprNode* defaultValue);
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
ExprNodeName getExprNodeNameEnum() const override { return NameVarNode; }
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(VarNode);
};
struct IntNode : ExprNode
{
S32 value;
U32 index; // if it's converted to float/string
2021-03-30 23:33:19 +00:00
static IntNode* alloc(S32 lineNumber, S32 value);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
ExprNodeName getExprNodeNameEnum() const override { return NameIntNode; }
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(IntNode);
};
struct FloatNode : ExprNode
{
F64 value;
U32 index;
2021-03-30 23:33:19 +00:00
static FloatNode* alloc(S32 lineNumber, F64 value);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
ExprNodeName getExprNodeNameEnum() const override { return NameFloatNode; }
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(FloatNode);
};
struct StrConstNode : ExprNode
{
2021-03-30 23:33:19 +00:00
char* str;
2012-09-19 15:15:01 +00:00
F64 fVal;
U32 index;
bool tag;
bool doc; // Specifies that this string is a documentation block.
2022-11-28 04:08:07 +00:00
static StrConstNode* alloc(S32 lineNumber, const char* str, bool tag, bool doc = false);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(StrConstNode);
};
struct ConstantNode : ExprNode
{
StringTableEntry value;
F64 fVal;
U32 index;
2021-03-30 23:33:19 +00:00
static ConstantNode* alloc(S32 lineNumber, StringTableEntry value);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(ConstantNode);
};
struct AssignExprNode : ExprNode
{
StringTableEntry varName;
2021-03-30 23:33:19 +00:00
ExprNode* expr;
ExprNode* arrayIndex;
2012-09-19 15:15:01 +00:00
TypeReq subType;
2021-03-30 23:33:19 +00:00
static AssignExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(AssignExprNode);
};
struct AssignDecl
{
S32 lineNumber;
S32 token;
2021-03-30 23:33:19 +00:00
ExprNode* expr;
2012-09-19 15:15:01 +00:00
bool integer;
};
struct AssignOpExprNode : ExprNode
{
StringTableEntry varName;
2021-03-30 23:33:19 +00:00
ExprNode* expr;
ExprNode* arrayIndex;
2012-09-19 15:15:01 +00:00
S32 op;
U32 operand;
TypeReq subType;
2021-03-30 23:33:19 +00:00
static AssignOpExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr, S32 op);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(AssignOpExprNode);
};
struct TTagSetStmtNode : StmtNode
{
StringTableEntry tag;
2021-03-30 23:33:19 +00:00
ExprNode* valueExpr;
ExprNode* stringExpr;
2012-09-19 15:15:01 +00:00
2021-03-30 23:33:19 +00:00
static TTagSetStmtNode* alloc(S32 lineNumber, StringTableEntry tag, ExprNode* valueExpr, ExprNode* stringExpr);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(TTagSetStmtNode);
};
struct TTagDerefNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* expr;
2012-09-19 15:15:01 +00:00
2021-03-30 23:33:19 +00:00
static TTagDerefNode* alloc(S32 lineNumber, ExprNode* expr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(TTagDerefNode);
};
struct TTagExprNode : ExprNode
{
StringTableEntry tag;
2021-03-30 23:33:19 +00:00
static TTagExprNode* alloc(S32 lineNumber, StringTableEntry tag);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(TTagExprNode);
};
struct FuncCallExprNode : ExprNode
{
StringTableEntry funcName;
StringTableEntry nameSpace;
2021-03-30 23:33:19 +00:00
ExprNode* args;
2012-09-19 15:15:01 +00:00
U32 callType;
enum {
FunctionCall,
2021-03-30 23:33:19 +00:00
StaticCall,
2012-09-19 15:15:01 +00:00
MethodCall,
ParentCall
};
2021-03-30 23:33:19 +00:00
static FuncCallExprNode* alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode* args, bool dot);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(FuncCallExprNode);
};
struct AssertCallExprNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* testExpr;
const char* message;
2012-09-19 15:15:01 +00:00
U32 messageIndex;
2021-03-30 23:33:19 +00:00
static AssertCallExprNode* alloc(S32 lineNumber, ExprNode* testExpr, const char* message);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(AssertCallExprNode);
};
struct SlotDecl
{
S32 lineNumber;
2021-03-30 23:33:19 +00:00
ExprNode* object;
2012-09-19 15:15:01 +00:00
StringTableEntry slotName;
2021-03-30 23:33:19 +00:00
ExprNode* array;
2012-09-19 15:15:01 +00:00
};
struct SlotAccessNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* objectExpr, * arrayExpr;
2012-09-19 15:15:01 +00:00
StringTableEntry slotName;
2021-03-30 23:33:19 +00:00
static SlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(SlotAccessNode);
};
struct InternalSlotDecl
{
S32 lineNumber;
2021-03-30 23:33:19 +00:00
ExprNode* object;
ExprNode* slotExpr;
2012-09-19 15:15:01 +00:00
bool recurse;
};
struct InternalSlotAccessNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* objectExpr, * slotExpr;
2012-09-19 15:15:01 +00:00
bool recurse;
2021-03-30 23:33:19 +00:00
static InternalSlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* slotExpr, bool recurse);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(InternalSlotAccessNode);
};
struct SlotAssignNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* objectExpr, * arrayExpr;
2012-09-19 15:15:01 +00:00
StringTableEntry slotName;
2021-03-30 23:33:19 +00:00
ExprNode* valueExpr;
2012-09-19 15:15:01 +00:00
U32 typeID;
2021-03-30 23:33:19 +00:00
static SlotAssignNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName, ExprNode* valueExpr, U32 typeID = -1);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(SlotAssignNode);
};
struct SlotAssignOpNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* objectExpr, * arrayExpr;
2012-09-19 15:15:01 +00:00
StringTableEntry slotName;
S32 op;
2021-03-30 23:33:19 +00:00
ExprNode* valueExpr;
2012-09-19 15:15:01 +00:00
U32 operand;
TypeReq subType;
2021-03-30 23:33:19 +00:00
static SlotAssignOpNode* alloc(S32 lineNumber, ExprNode* objectExpr, StringTableEntry slotName, ExprNode* arrayExpr, S32 op, ExprNode* valueExpr);
2017-11-06 04:33:32 +00:00
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(SlotAssignOpNode);
};
struct ObjectDeclNode : ExprNode
{
2021-03-30 23:33:19 +00:00
ExprNode* classNameExpr;
2012-09-19 15:15:01 +00:00
StringTableEntry parentObject;
2021-03-30 23:33:19 +00:00
ExprNode* objectNameExpr;
ExprNode* argList;
SlotAssignNode* slotDecls;
ObjectDeclNode* subObjects;
2012-09-19 15:15:01 +00:00
bool isDatablock;
U32 failOffset;
bool isClassNameInternal;
bool isSingleton;
2021-03-30 23:33:19 +00:00
static ObjectDeclNode* alloc(S32 lineNumber, ExprNode* classNameExpr, ExprNode* objectNameExpr, ExprNode* argList, StringTableEntry parentObject, SlotAssignNode* slotDecls, ObjectDeclNode* subObjects, bool isDatablock, bool classNameInternal, bool isSingleton);
2017-11-06 04:33:32 +00:00
2012-09-19 15:15:01 +00:00
U32 precompileSubObject(bool);
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) override;
2021-03-30 23:33:19 +00:00
U32 compileSubObject(CodeStream& codeStream, U32 ip, bool);
TypeReq getPreferredType() override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(ObjectDeclNode);
};
struct ObjectBlockDecl
{
2021-03-30 23:33:19 +00:00
SlotAssignNode* slots;
ObjectDeclNode* decls;
2012-09-19 15:15:01 +00:00
};
struct FunctionDeclStmtNode : StmtNode
{
StringTableEntry fnName;
2021-03-30 23:33:19 +00:00
VarNode* args;
StmtNode* stmts;
2012-09-19 15:15:01 +00:00
StringTableEntry nameSpace;
StringTableEntry package;
U32 endOffset;
U32 argc;
2021-03-30 23:33:19 +00:00
static FunctionDeclStmtNode* alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode* args, StmtNode* stmts);
2017-11-06 04:33:32 +00:00
U32 compileStmt(CodeStream& codeStream, U32 ip) override;
void setPackage(StringTableEntry packageName) override;
2012-09-19 15:15:01 +00:00
DBG_STMT_TYPE(FunctionDeclStmtNode);
};
2023-04-23 08:39:54 +00:00
namespace Script
{
inline ExprEvalState gEvalState;
inline StmtNode *gStatementList;
inline StmtNode *gAnonFunctionList;
inline U32 gAnonFunctionID = 0;
}
2012-09-19 15:15:01 +00:00
#endif