mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 14:44:36 +00:00
Merge pull request #2121 from JeffProgrammer/TSImprovementsDevMerge
TorqueScript Improvements - Faster Interpreter.
This commit is contained in:
commit
4f78143dc8
23 changed files with 10231 additions and 8513 deletions
|
|
@ -45,6 +45,7 @@
|
||||||
#include "console/debugOutputConsumer.h"
|
#include "console/debugOutputConsumer.h"
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#include "console/engineAPI.h"
|
#include "console/engineAPI.h"
|
||||||
|
#include "console/codeInterpreter.h"
|
||||||
|
|
||||||
#include "gfx/bitmap/gBitmap.h"
|
#include "gfx/bitmap/gBitmap.h"
|
||||||
#include "gfx/gFont.h"
|
#include "gfx/gFont.h"
|
||||||
|
|
@ -227,6 +228,9 @@ void StandardMainLoop::init()
|
||||||
ManagedSingleton< ThreadManager >::createSingleton();
|
ManagedSingleton< ThreadManager >::createSingleton();
|
||||||
FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
|
FrameAllocator::init(TORQUE_FRAME_SIZE); // See comments in torqueConfig.h
|
||||||
|
|
||||||
|
// Initialize the TorqueScript interpreter.
|
||||||
|
CodeInterpreter::init();
|
||||||
|
|
||||||
// Yell if we can't initialize the network.
|
// Yell if we can't initialize the network.
|
||||||
if(!Net::init())
|
if(!Net::init())
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -496,9 +496,9 @@ class_name_expr
|
||||||
|
|
||||||
assign_op_struct
|
assign_op_struct
|
||||||
: opPLUSPLUS
|
: opPLUSPLUS
|
||||||
{ $$.lineNumber = $1.lineNumber; $$.token = '+'; $$.expr = FloatNode::alloc( $1.lineNumber, 1 ); }
|
{ $$.lineNumber = $1.lineNumber; $$.token = opPLUSPLUS; $$.expr = FloatNode::alloc( $1.lineNumber, 1 ); }
|
||||||
| opMINUSMINUS
|
| opMINUSMINUS
|
||||||
{ $$.lineNumber = $1.lineNumber; $$.token = '-'; $$.expr = FloatNode::alloc( $1.lineNumber, 1 ); }
|
{ $$.lineNumber = $1.lineNumber; $$.token = opMINUSMINUS; $$.expr = FloatNode::alloc( $1.lineNumber, 1 ); }
|
||||||
| opPLASN expr
|
| opPLASN expr
|
||||||
{ $$.lineNumber = $1.lineNumber; $$.token = '+'; $$.expr = $2; }
|
{ $$.lineNumber = $1.lineNumber; $$.token = '+'; $$.expr = $2; }
|
||||||
| opMIASN expr
|
| opMIASN expr
|
||||||
|
|
@ -551,6 +551,8 @@ funcall_expr
|
||||||
{ $$ = FuncCallExprNode::alloc( $1.lineNumber, $3.value, $1.value, $5, false); }
|
{ $$ = FuncCallExprNode::alloc( $1.lineNumber, $3.value, $1.value, $5, false); }
|
||||||
| expr '.' IDENT '(' expr_list_decl ')'
|
| expr '.' IDENT '(' expr_list_decl ')'
|
||||||
{ $1->append($5); $$ = FuncCallExprNode::alloc( $1->dbgLineNumber, $3.value, NULL, $1, true); }
|
{ $1->append($5); $$ = FuncCallExprNode::alloc( $1->dbgLineNumber, $3.value, NULL, $1, true); }
|
||||||
|
| expr '(' expr_list_decl ')'
|
||||||
|
{ $$ = FuncPointerCallExprNode::alloc( $1->dbgLineNumber, $1, $3); }
|
||||||
;
|
;
|
||||||
|
|
||||||
assert_expr
|
assert_expr
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -99,7 +99,7 @@ struct StmtNode
|
||||||
|
|
||||||
struct BreakStmtNode : StmtNode
|
struct BreakStmtNode : StmtNode
|
||||||
{
|
{
|
||||||
static BreakStmtNode *alloc( S32 lineNumber );
|
static BreakStmtNode *alloc(S32 lineNumber);
|
||||||
|
|
||||||
|
|
||||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
|
|
@ -108,7 +108,7 @@ struct BreakStmtNode : StmtNode
|
||||||
|
|
||||||
struct ContinueStmtNode : StmtNode
|
struct ContinueStmtNode : StmtNode
|
||||||
{
|
{
|
||||||
static ContinueStmtNode *alloc( S32 lineNumber );
|
static ContinueStmtNode *alloc(S32 lineNumber);
|
||||||
|
|
||||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
DBG_STMT_TYPE(ContinueStmtNode);
|
DBG_STMT_TYPE(ContinueStmtNode);
|
||||||
|
|
@ -128,7 +128,7 @@ struct ReturnStmtNode : StmtNode
|
||||||
{
|
{
|
||||||
ExprNode *expr;
|
ExprNode *expr;
|
||||||
|
|
||||||
static ReturnStmtNode *alloc( S32 lineNumber, ExprNode *expr );
|
static ReturnStmtNode *alloc(S32 lineNumber, ExprNode *expr);
|
||||||
|
|
||||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
DBG_STMT_TYPE(ReturnStmtNode);
|
DBG_STMT_TYPE(ReturnStmtNode);
|
||||||
|
|
@ -143,7 +143,7 @@ struct IfStmtNode : StmtNode
|
||||||
bool integer;
|
bool integer;
|
||||||
bool propagate;
|
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);
|
void propagateSwitchExpr(ExprNode *left, bool string);
|
||||||
ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string);
|
ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string);
|
||||||
|
|
||||||
|
|
@ -163,7 +163,7 @@ struct LoopStmtNode : StmtNode
|
||||||
U32 loopBlockStartOffset;
|
U32 loopBlockStartOffset;
|
||||||
bool integer;
|
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);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
DBG_STMT_TYPE(LoopStmtNode);
|
DBG_STMT_TYPE(LoopStmtNode);
|
||||||
|
|
@ -187,9 +187,9 @@ struct IterStmtNode : StmtNode
|
||||||
/// Bytecode size of body statement. Set by precompileStmt.
|
/// Bytecode size of body statement. Set by precompileStmt.
|
||||||
U32 bodySize;
|
U32 bodySize;
|
||||||
|
|
||||||
static IterStmtNode* alloc( S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter );
|
static IterStmtNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter);
|
||||||
|
|
||||||
U32 compileStmt( CodeStream &codeStream, U32 ip );
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A binary mathematical expression (ie, left op right).
|
/// A binary mathematical expression (ie, left op right).
|
||||||
|
|
@ -202,7 +202,7 @@ struct BinaryExprNode : ExprNode
|
||||||
|
|
||||||
struct FloatBinaryExprNode : BinaryExprNode
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -215,7 +215,7 @@ struct ConditionalExprNode : ExprNode
|
||||||
ExprNode *trueExpr;
|
ExprNode *trueExpr;
|
||||||
ExprNode *falseExpr;
|
ExprNode *falseExpr;
|
||||||
bool integer;
|
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 U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
virtual TypeReq getPreferredType();
|
virtual TypeReq getPreferredType();
|
||||||
|
|
@ -227,7 +227,7 @@ struct IntBinaryExprNode : BinaryExprNode
|
||||||
TypeReq subType;
|
TypeReq subType;
|
||||||
U32 operand;
|
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();
|
void getSubTypeOperand();
|
||||||
|
|
||||||
|
|
@ -239,7 +239,7 @@ struct IntBinaryExprNode : BinaryExprNode
|
||||||
struct StreqExprNode : BinaryExprNode
|
struct StreqExprNode : BinaryExprNode
|
||||||
{
|
{
|
||||||
bool eq;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -249,7 +249,7 @@ struct StreqExprNode : BinaryExprNode
|
||||||
struct StrcatExprNode : BinaryExprNode
|
struct StrcatExprNode : BinaryExprNode
|
||||||
{
|
{
|
||||||
S32 appendChar;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -258,7 +258,7 @@ struct StrcatExprNode : BinaryExprNode
|
||||||
|
|
||||||
struct CommaCatExprNode : 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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
|
|
@ -272,7 +272,7 @@ struct IntUnaryExprNode : ExprNode
|
||||||
ExprNode *expr;
|
ExprNode *expr;
|
||||||
bool integer;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -284,7 +284,7 @@ struct FloatUnaryExprNode : ExprNode
|
||||||
S32 op;
|
S32 op;
|
||||||
ExprNode *expr;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -296,7 +296,7 @@ struct VarNode : ExprNode
|
||||||
StringTableEntry varName;
|
StringTableEntry varName;
|
||||||
ExprNode *arrayIndex;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -308,7 +308,7 @@ struct IntNode : ExprNode
|
||||||
S32 value;
|
S32 value;
|
||||||
U32 index; // if it's converted to float/string
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -320,7 +320,7 @@ struct FloatNode : ExprNode
|
||||||
F64 value;
|
F64 value;
|
||||||
U32 index;
|
U32 index;
|
||||||
|
|
||||||
static FloatNode *alloc( S32 lineNumber, F64 value );
|
static FloatNode *alloc(S32 lineNumber, F64 value);
|
||||||
|
|
||||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -335,7 +335,7 @@ struct StrConstNode : ExprNode
|
||||||
bool tag;
|
bool tag;
|
||||||
bool doc; // Specifies that this string is a documentation block.
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -348,7 +348,7 @@ struct ConstantNode : ExprNode
|
||||||
F64 fVal;
|
F64 fVal;
|
||||||
U32 index;
|
U32 index;
|
||||||
|
|
||||||
static ConstantNode *alloc( S32 lineNumber, StringTableEntry value );
|
static ConstantNode *alloc(S32 lineNumber, StringTableEntry value);
|
||||||
|
|
||||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -362,7 +362,7 @@ struct AssignExprNode : ExprNode
|
||||||
ExprNode *arrayIndex;
|
ExprNode *arrayIndex;
|
||||||
TypeReq subType;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -386,7 +386,7 @@ struct AssignOpExprNode : ExprNode
|
||||||
U32 operand;
|
U32 operand;
|
||||||
TypeReq subType;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -399,7 +399,7 @@ struct TTagSetStmtNode : StmtNode
|
||||||
ExprNode *valueExpr;
|
ExprNode *valueExpr;
|
||||||
ExprNode *stringExpr;
|
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);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
DBG_STMT_TYPE(TTagSetStmtNode);
|
DBG_STMT_TYPE(TTagSetStmtNode);
|
||||||
|
|
@ -409,7 +409,7 @@ struct TTagDerefNode : ExprNode
|
||||||
{
|
{
|
||||||
ExprNode *expr;
|
ExprNode *expr;
|
||||||
|
|
||||||
static TTagDerefNode *alloc( S32 lineNumber, ExprNode *expr );
|
static TTagDerefNode *alloc(S32 lineNumber, ExprNode *expr);
|
||||||
|
|
||||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -420,7 +420,7 @@ struct TTagExprNode : ExprNode
|
||||||
{
|
{
|
||||||
StringTableEntry tag;
|
StringTableEntry tag;
|
||||||
|
|
||||||
static TTagExprNode *alloc( S32 lineNumber, StringTableEntry tag );
|
static TTagExprNode *alloc(S32 lineNumber, StringTableEntry tag);
|
||||||
|
|
||||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -439,20 +439,32 @@ struct FuncCallExprNode : ExprNode
|
||||||
ParentCall
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
DBG_STMT_TYPE(FuncCallExprNode);
|
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
|
struct AssertCallExprNode : ExprNode
|
||||||
{
|
{
|
||||||
ExprNode *testExpr;
|
ExprNode *testExpr;
|
||||||
const char *message;
|
const char *message;
|
||||||
U32 messageIndex;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -472,7 +484,7 @@ struct SlotAccessNode : ExprNode
|
||||||
ExprNode *objectExpr, *arrayExpr;
|
ExprNode *objectExpr, *arrayExpr;
|
||||||
StringTableEntry slotName;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -492,7 +504,7 @@ struct InternalSlotAccessNode : ExprNode
|
||||||
ExprNode *objectExpr, *slotExpr;
|
ExprNode *objectExpr, *slotExpr;
|
||||||
bool recurse;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -506,7 +518,7 @@ struct SlotAssignNode : ExprNode
|
||||||
ExprNode *valueExpr;
|
ExprNode *valueExpr;
|
||||||
U32 typeID;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -522,7 +534,7 @@ struct SlotAssignOpNode : ExprNode
|
||||||
U32 operand;
|
U32 operand;
|
||||||
TypeReq subType;
|
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);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
TypeReq getPreferredType();
|
TypeReq getPreferredType();
|
||||||
|
|
@ -542,7 +554,7 @@ struct ObjectDeclNode : ExprNode
|
||||||
bool isClassNameInternal;
|
bool isClassNameInternal;
|
||||||
bool isSingleton;
|
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 precompileSubObject(bool);
|
||||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||||
|
|
@ -567,7 +579,7 @@ struct FunctionDeclStmtNode : StmtNode
|
||||||
U32 endOffset;
|
U32 endOffset;
|
||||||
U32 argc;
|
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);
|
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||||
void setPackage(StringTableEntry packageName);
|
void setPackage(StringTableEntry packageName);
|
||||||
|
|
|
||||||
|
|
@ -38,25 +38,25 @@ using namespace Compiler;
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
BreakStmtNode *BreakStmtNode::alloc( S32 lineNumber )
|
BreakStmtNode *BreakStmtNode::alloc(S32 lineNumber)
|
||||||
{
|
{
|
||||||
BreakStmtNode *ret = (BreakStmtNode *) consoleAlloc(sizeof(BreakStmtNode));
|
BreakStmtNode *ret = (BreakStmtNode *)consoleAlloc(sizeof(BreakStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ContinueStmtNode *ContinueStmtNode::alloc( S32 lineNumber )
|
ContinueStmtNode *ContinueStmtNode::alloc(S32 lineNumber)
|
||||||
{
|
{
|
||||||
ContinueStmtNode *ret = (ContinueStmtNode *) consoleAlloc(sizeof(ContinueStmtNode));
|
ContinueStmtNode *ret = (ContinueStmtNode *)consoleAlloc(sizeof(ContinueStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnStmtNode *ReturnStmtNode::alloc( S32 lineNumber, ExprNode *expr)
|
ReturnStmtNode *ReturnStmtNode::alloc(S32 lineNumber, ExprNode *expr)
|
||||||
{
|
{
|
||||||
ReturnStmtNode *ret = (ReturnStmtNode *) consoleAlloc(sizeof(ReturnStmtNode));
|
ReturnStmtNode *ret = (ReturnStmtNode *)consoleAlloc(sizeof(ReturnStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->expr = expr;
|
ret->expr = expr;
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
|
@ -64,9 +64,9 @@ ReturnStmtNode *ReturnStmtNode::alloc( S32 lineNumber, ExprNode *expr)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IfStmtNode *IfStmtNode::alloc( S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagate )
|
IfStmtNode *IfStmtNode::alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagate)
|
||||||
{
|
{
|
||||||
IfStmtNode *ret = (IfStmtNode *) consoleAlloc(sizeof(IfStmtNode));
|
IfStmtNode *ret = (IfStmtNode *)consoleAlloc(sizeof(IfStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
|
||||||
|
|
@ -78,9 +78,9 @@ IfStmtNode *IfStmtNode::alloc( S32 lineNumber, ExprNode *testExpr, StmtNode *ifB
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopStmtNode *LoopStmtNode::alloc( S32 lineNumber, ExprNode *initExpr, ExprNode *testExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop )
|
LoopStmtNode *LoopStmtNode::alloc(S32 lineNumber, ExprNode *initExpr, ExprNode *testExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop)
|
||||||
{
|
{
|
||||||
LoopStmtNode *ret = (LoopStmtNode *) consoleAlloc(sizeof(LoopStmtNode));
|
LoopStmtNode *ret = (LoopStmtNode *)consoleAlloc(sizeof(LoopStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->testExpr = testExpr;
|
ret->testExpr = testExpr;
|
||||||
|
|
@ -92,15 +92,15 @@ LoopStmtNode *LoopStmtNode::alloc( S32 lineNumber, ExprNode *initExpr, ExprNode
|
||||||
// Deal with setting some dummy constant nodes if we weren't provided with
|
// Deal with setting some dummy constant nodes if we weren't provided with
|
||||||
// info... This allows us to play nice with missing parts of for(;;) for
|
// info... This allows us to play nice with missing parts of for(;;) for
|
||||||
// instance.
|
// instance.
|
||||||
if(!ret->testExpr) ret->testExpr = IntNode::alloc( lineNumber, 1 );
|
if (!ret->testExpr) ret->testExpr = IntNode::alloc(lineNumber, 1);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IterStmtNode* IterStmtNode::alloc( S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter )
|
IterStmtNode* IterStmtNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode* containerExpr, StmtNode* body, bool isStringIter)
|
||||||
{
|
{
|
||||||
IterStmtNode* ret = ( IterStmtNode* ) consoleAlloc( sizeof( IterStmtNode ) );
|
IterStmtNode* ret = (IterStmtNode*)consoleAlloc(sizeof(IterStmtNode));
|
||||||
constructInPlace( ret );
|
constructInPlace(ret);
|
||||||
|
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->varName = varName;
|
ret->varName = varName;
|
||||||
|
|
@ -111,9 +111,9 @@ IterStmtNode* IterStmtNode::alloc( S32 lineNumber, StringTableEntry varName, Exp
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatBinaryExprNode *FloatBinaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right )
|
FloatBinaryExprNode *FloatBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right)
|
||||||
{
|
{
|
||||||
FloatBinaryExprNode *ret = (FloatBinaryExprNode *) consoleAlloc(sizeof(FloatBinaryExprNode));
|
FloatBinaryExprNode *ret = (FloatBinaryExprNode *)consoleAlloc(sizeof(FloatBinaryExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
|
||||||
|
|
@ -124,9 +124,9 @@ FloatBinaryExprNode *FloatBinaryExprNode::alloc( S32 lineNumber, S32 op, ExprNod
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntBinaryExprNode *IntBinaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *left, ExprNode *right )
|
IntBinaryExprNode *IntBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right)
|
||||||
{
|
{
|
||||||
IntBinaryExprNode *ret = (IntBinaryExprNode *) consoleAlloc(sizeof(IntBinaryExprNode));
|
IntBinaryExprNode *ret = (IntBinaryExprNode *)consoleAlloc(sizeof(IntBinaryExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
|
||||||
|
|
@ -137,9 +137,9 @@ IntBinaryExprNode *IntBinaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *l
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
StreqExprNode *StreqExprNode::alloc( S32 lineNumber, ExprNode *left, ExprNode *right, bool eq )
|
StreqExprNode *StreqExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right, bool eq)
|
||||||
{
|
{
|
||||||
StreqExprNode *ret = (StreqExprNode *) consoleAlloc(sizeof(StreqExprNode));
|
StreqExprNode *ret = (StreqExprNode *)consoleAlloc(sizeof(StreqExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->left = left;
|
ret->left = left;
|
||||||
|
|
@ -149,9 +149,9 @@ StreqExprNode *StreqExprNode::alloc( S32 lineNumber, ExprNode *left, ExprNode *r
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrcatExprNode *StrcatExprNode::alloc( S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar )
|
StrcatExprNode *StrcatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar)
|
||||||
{
|
{
|
||||||
StrcatExprNode *ret = (StrcatExprNode *) consoleAlloc(sizeof(StrcatExprNode));
|
StrcatExprNode *ret = (StrcatExprNode *)consoleAlloc(sizeof(StrcatExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->left = left;
|
ret->left = left;
|
||||||
|
|
@ -161,9 +161,9 @@ StrcatExprNode *StrcatExprNode::alloc( S32 lineNumber, ExprNode *left, ExprNode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
CommaCatExprNode *CommaCatExprNode::alloc( S32 lineNumber, ExprNode *left, ExprNode *right )
|
CommaCatExprNode *CommaCatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right)
|
||||||
{
|
{
|
||||||
CommaCatExprNode *ret = (CommaCatExprNode *) consoleAlloc(sizeof(CommaCatExprNode));
|
CommaCatExprNode *ret = (CommaCatExprNode *)consoleAlloc(sizeof(CommaCatExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->left = left;
|
ret->left = left;
|
||||||
|
|
@ -172,9 +172,9 @@ CommaCatExprNode *CommaCatExprNode::alloc( S32 lineNumber, ExprNode *left, ExprN
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntUnaryExprNode *IntUnaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *expr )
|
IntUnaryExprNode *IntUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *expr)
|
||||||
{
|
{
|
||||||
IntUnaryExprNode *ret = (IntUnaryExprNode *) consoleAlloc(sizeof(IntUnaryExprNode));
|
IntUnaryExprNode *ret = (IntUnaryExprNode *)consoleAlloc(sizeof(IntUnaryExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->op = op;
|
ret->op = op;
|
||||||
|
|
@ -182,9 +182,9 @@ IntUnaryExprNode *IntUnaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *exp
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatUnaryExprNode *FloatUnaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode *expr )
|
FloatUnaryExprNode *FloatUnaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *expr)
|
||||||
{
|
{
|
||||||
FloatUnaryExprNode *ret = (FloatUnaryExprNode *) consoleAlloc(sizeof(FloatUnaryExprNode));
|
FloatUnaryExprNode *ret = (FloatUnaryExprNode *)consoleAlloc(sizeof(FloatUnaryExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->op = op;
|
ret->op = op;
|
||||||
|
|
@ -192,9 +192,9 @@ FloatUnaryExprNode *FloatUnaryExprNode::alloc( S32 lineNumber, S32 op, ExprNode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
VarNode *VarNode::alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex )
|
VarNode *VarNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex)
|
||||||
{
|
{
|
||||||
VarNode *ret = (VarNode *) consoleAlloc(sizeof(VarNode));
|
VarNode *ret = (VarNode *)consoleAlloc(sizeof(VarNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->varName = varName;
|
ret->varName = varName;
|
||||||
|
|
@ -202,18 +202,18 @@ VarNode *VarNode::alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arr
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntNode *IntNode::alloc( S32 lineNumber, S32 value )
|
IntNode *IntNode::alloc(S32 lineNumber, S32 value)
|
||||||
{
|
{
|
||||||
IntNode *ret = (IntNode *) consoleAlloc(sizeof(IntNode));
|
IntNode *ret = (IntNode *)consoleAlloc(sizeof(IntNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->value = value;
|
ret->value = value;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConditionalExprNode *ConditionalExprNode::alloc( S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr )
|
ConditionalExprNode *ConditionalExprNode::alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr)
|
||||||
{
|
{
|
||||||
ConditionalExprNode *ret = (ConditionalExprNode *) consoleAlloc(sizeof(ConditionalExprNode));
|
ConditionalExprNode *ret = (ConditionalExprNode *)consoleAlloc(sizeof(ConditionalExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->testExpr = testExpr;
|
ret->testExpr = testExpr;
|
||||||
|
|
@ -223,9 +223,9 @@ ConditionalExprNode *ConditionalExprNode::alloc( S32 lineNumber, ExprNode *testE
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FloatNode *FloatNode::alloc( S32 lineNumber, F64 value )
|
FloatNode *FloatNode::alloc(S32 lineNumber, F64 value)
|
||||||
{
|
{
|
||||||
FloatNode *ret = (FloatNode *) consoleAlloc(sizeof(FloatNode));
|
FloatNode *ret = (FloatNode *)consoleAlloc(sizeof(FloatNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
|
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
|
@ -233,12 +233,12 @@ FloatNode *FloatNode::alloc( S32 lineNumber, F64 value )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
StrConstNode *StrConstNode::alloc( S32 lineNumber, char *str, bool tag, bool doc )
|
StrConstNode *StrConstNode::alloc(S32 lineNumber, char *str, bool tag, bool doc)
|
||||||
{
|
{
|
||||||
StrConstNode *ret = (StrConstNode *) consoleAlloc(sizeof(StrConstNode));
|
StrConstNode *ret = (StrConstNode *)consoleAlloc(sizeof(StrConstNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->str = (char *) consoleAlloc(dStrlen(str) + 1);
|
ret->str = (char *)consoleAlloc(dStrlen(str) + 1);
|
||||||
ret->tag = tag;
|
ret->tag = tag;
|
||||||
ret->doc = doc;
|
ret->doc = doc;
|
||||||
dStrcpy(ret->str, str);
|
dStrcpy(ret->str, str);
|
||||||
|
|
@ -246,18 +246,18 @@ StrConstNode *StrConstNode::alloc( S32 lineNumber, char *str, bool tag, bool doc
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstantNode *ConstantNode::alloc( S32 lineNumber, StringTableEntry value )
|
ConstantNode *ConstantNode::alloc(S32 lineNumber, StringTableEntry value)
|
||||||
{
|
{
|
||||||
ConstantNode *ret = (ConstantNode *) consoleAlloc(sizeof(ConstantNode));
|
ConstantNode *ret = (ConstantNode *)consoleAlloc(sizeof(ConstantNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->value = value;
|
ret->value = value;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignExprNode *AssignExprNode::alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr )
|
AssignExprNode *AssignExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr)
|
||||||
{
|
{
|
||||||
AssignExprNode *ret = (AssignExprNode *) consoleAlloc(sizeof(AssignExprNode));
|
AssignExprNode *ret = (AssignExprNode *)consoleAlloc(sizeof(AssignExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->varName = varName;
|
ret->varName = varName;
|
||||||
|
|
@ -267,9 +267,9 @@ AssignExprNode *AssignExprNode::alloc( S32 lineNumber, StringTableEntry varName,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignOpExprNode *AssignOpExprNode::alloc( S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op )
|
AssignOpExprNode *AssignOpExprNode::alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op)
|
||||||
{
|
{
|
||||||
AssignOpExprNode *ret = (AssignOpExprNode *) consoleAlloc(sizeof(AssignOpExprNode));
|
AssignOpExprNode *ret = (AssignOpExprNode *)consoleAlloc(sizeof(AssignOpExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->varName = varName;
|
ret->varName = varName;
|
||||||
|
|
@ -279,9 +279,9 @@ AssignOpExprNode *AssignOpExprNode::alloc( S32 lineNumber, StringTableEntry varN
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTagSetStmtNode *TTagSetStmtNode::alloc( S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr )
|
TTagSetStmtNode *TTagSetStmtNode::alloc(S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr)
|
||||||
{
|
{
|
||||||
TTagSetStmtNode *ret = (TTagSetStmtNode *) consoleAlloc(sizeof(TTagSetStmtNode));
|
TTagSetStmtNode *ret = (TTagSetStmtNode *)consoleAlloc(sizeof(TTagSetStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->tag = tag;
|
ret->tag = tag;
|
||||||
|
|
@ -290,37 +290,37 @@ TTagSetStmtNode *TTagSetStmtNode::alloc( S32 lineNumber, StringTableEntry tag, E
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTagDerefNode *TTagDerefNode::alloc( S32 lineNumber, ExprNode *expr )
|
TTagDerefNode *TTagDerefNode::alloc(S32 lineNumber, ExprNode *expr)
|
||||||
{
|
{
|
||||||
TTagDerefNode *ret = (TTagDerefNode *) consoleAlloc(sizeof(TTagDerefNode));
|
TTagDerefNode *ret = (TTagDerefNode *)consoleAlloc(sizeof(TTagDerefNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->expr = expr;
|
ret->expr = expr;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
TTagExprNode *TTagExprNode::alloc( S32 lineNumber, StringTableEntry tag )
|
TTagExprNode *TTagExprNode::alloc(S32 lineNumber, StringTableEntry tag)
|
||||||
{
|
{
|
||||||
TTagExprNode *ret = (TTagExprNode *) consoleAlloc(sizeof(TTagExprNode));
|
TTagExprNode *ret = (TTagExprNode *)consoleAlloc(sizeof(TTagExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->tag = tag;
|
ret->tag = tag;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncCallExprNode *FuncCallExprNode::alloc( S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot )
|
FuncCallExprNode *FuncCallExprNode::alloc(S32 lineNumber, StringTableEntry funcName, StringTableEntry nameSpace, ExprNode *args, bool dot)
|
||||||
{
|
{
|
||||||
FuncCallExprNode *ret = (FuncCallExprNode *) consoleAlloc(sizeof(FuncCallExprNode));
|
FuncCallExprNode *ret = (FuncCallExprNode *)consoleAlloc(sizeof(FuncCallExprNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->funcName = funcName;
|
ret->funcName = funcName;
|
||||||
ret->nameSpace = nameSpace;
|
ret->nameSpace = nameSpace;
|
||||||
ret->args = args;
|
ret->args = args;
|
||||||
if(dot)
|
if (dot)
|
||||||
ret->callType = MethodCall;
|
ret->callType = MethodCall;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(nameSpace && !dStricmp(nameSpace, "Parent"))
|
if (nameSpace && !dStricmp(nameSpace, "Parent"))
|
||||||
ret->callType = ParentCall;
|
ret->callType = ParentCall;
|
||||||
else
|
else
|
||||||
ret->callType = FunctionCall;
|
ret->callType = FunctionCall;
|
||||||
|
|
@ -328,27 +328,37 @@ FuncCallExprNode *FuncCallExprNode::alloc( S32 lineNumber, StringTableEntry func
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertCallExprNode *AssertCallExprNode::alloc( S32 lineNumber, ExprNode *testExpr, const char *message )
|
FuncPointerCallExprNode *FuncPointerCallExprNode::alloc(S32 lineNumber, ExprNode *funcPointer, ExprNode *args)
|
||||||
{
|
{
|
||||||
#ifdef TORQUE_ENABLE_SCRIPTASSERTS
|
FuncPointerCallExprNode *ret = (FuncPointerCallExprNode *)consoleAlloc(sizeof(FuncPointerCallExprNode));
|
||||||
|
constructInPlace(ret);
|
||||||
AssertCallExprNode *ret = (AssertCallExprNode *) consoleAlloc(sizeof(FuncCallExprNode));
|
ret->dbgLineNumber = lineNumber;
|
||||||
constructInPlace(ret);
|
ret->funcPointer = funcPointer;
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->args = args;
|
||||||
ret->testExpr = testExpr;
|
return ret;
|
||||||
ret->message = message ? message : "TorqueScript assert!";
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotAccessNode *SlotAccessNode::alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName )
|
AssertCallExprNode *AssertCallExprNode::alloc(S32 lineNumber, ExprNode *testExpr, const char *message)
|
||||||
{
|
{
|
||||||
SlotAccessNode *ret = (SlotAccessNode *) consoleAlloc(sizeof(SlotAccessNode));
|
#ifdef TORQUE_ENABLE_SCRIPTASSERTS
|
||||||
|
|
||||||
|
AssertCallExprNode *ret = (AssertCallExprNode *)consoleAlloc(sizeof(FuncCallExprNode));
|
||||||
|
constructInPlace(ret);
|
||||||
|
ret->dbgLineNumber = lineNumber;
|
||||||
|
ret->testExpr = testExpr;
|
||||||
|
ret->message = message ? message : "TorqueScript assert!";
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
SlotAccessNode *SlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName)
|
||||||
|
{
|
||||||
|
SlotAccessNode *ret = (SlotAccessNode *)consoleAlloc(sizeof(SlotAccessNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->objectExpr = objectExpr;
|
ret->objectExpr = objectExpr;
|
||||||
|
|
@ -357,9 +367,9 @@ SlotAccessNode *SlotAccessNode::alloc( S32 lineNumber, ExprNode *objectExpr, Exp
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalSlotAccessNode *InternalSlotAccessNode::alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse )
|
InternalSlotAccessNode *InternalSlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse)
|
||||||
{
|
{
|
||||||
InternalSlotAccessNode *ret = (InternalSlotAccessNode *) consoleAlloc(sizeof(InternalSlotAccessNode));
|
InternalSlotAccessNode *ret = (InternalSlotAccessNode *)consoleAlloc(sizeof(InternalSlotAccessNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->objectExpr = objectExpr;
|
ret->objectExpr = objectExpr;
|
||||||
|
|
@ -368,9 +378,9 @@ InternalSlotAccessNode *InternalSlotAccessNode::alloc( S32 lineNumber, ExprNode
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotAssignNode *SlotAssignNode::alloc( S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID /* = -1 */ )
|
SlotAssignNode *SlotAssignNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID /* = -1 */)
|
||||||
{
|
{
|
||||||
SlotAssignNode *ret = (SlotAssignNode *) consoleAlloc(sizeof(SlotAssignNode));
|
SlotAssignNode *ret = (SlotAssignNode *)consoleAlloc(sizeof(SlotAssignNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->objectExpr = objectExpr;
|
ret->objectExpr = objectExpr;
|
||||||
|
|
@ -381,9 +391,9 @@ SlotAssignNode *SlotAssignNode::alloc( S32 lineNumber, ExprNode *objectExpr, Exp
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlotAssignOpNode *SlotAssignOpNode::alloc( S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr )
|
SlotAssignOpNode *SlotAssignOpNode::alloc(S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr)
|
||||||
{
|
{
|
||||||
SlotAssignOpNode *ret = (SlotAssignOpNode *) consoleAlloc(sizeof(SlotAssignOpNode));
|
SlotAssignOpNode *ret = (SlotAssignOpNode *)consoleAlloc(sizeof(SlotAssignOpNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->objectExpr = objectExpr;
|
ret->objectExpr = objectExpr;
|
||||||
|
|
@ -394,9 +404,9 @@ SlotAssignOpNode *SlotAssignOpNode::alloc( S32 lineNumber, ExprNode *objectExpr,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectDeclNode *ObjectDeclNode::alloc( S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton )
|
ObjectDeclNode *ObjectDeclNode::alloc(S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton)
|
||||||
{
|
{
|
||||||
ObjectDeclNode *ret = (ObjectDeclNode *) consoleAlloc(sizeof(ObjectDeclNode));
|
ObjectDeclNode *ret = (ObjectDeclNode *)consoleAlloc(sizeof(ObjectDeclNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->classNameExpr = classNameExpr;
|
ret->classNameExpr = classNameExpr;
|
||||||
|
|
@ -408,16 +418,16 @@ ObjectDeclNode *ObjectDeclNode::alloc( S32 lineNumber, ExprNode *classNameExpr,
|
||||||
ret->isClassNameInternal = classNameInternal;
|
ret->isClassNameInternal = classNameInternal;
|
||||||
ret->isSingleton = isSingleton;
|
ret->isSingleton = isSingleton;
|
||||||
ret->failOffset = 0;
|
ret->failOffset = 0;
|
||||||
if(parentObject)
|
if (parentObject)
|
||||||
ret->parentObject = parentObject;
|
ret->parentObject = parentObject;
|
||||||
else
|
else
|
||||||
ret->parentObject = StringTable->EmptyString();
|
ret->parentObject = StringTable->EmptyString();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionDeclStmtNode *FunctionDeclStmtNode::alloc( S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts )
|
FunctionDeclStmtNode *FunctionDeclStmtNode::alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts)
|
||||||
{
|
{
|
||||||
FunctionDeclStmtNode *ret = (FunctionDeclStmtNode *) consoleAlloc(sizeof(FunctionDeclStmtNode));
|
FunctionDeclStmtNode *ret = (FunctionDeclStmtNode *)consoleAlloc(sizeof(FunctionDeclStmtNode));
|
||||||
constructInPlace(ret);
|
constructInPlace(ret);
|
||||||
ret->dbgLineNumber = lineNumber;
|
ret->dbgLineNumber = lineNumber;
|
||||||
ret->fnName = fnName;
|
ret->fnName = fnName;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -15,78 +15,78 @@ typedef union {
|
||||||
AssignDecl asn;
|
AssignDecl asn;
|
||||||
IfStmtNode* ifnode;
|
IfStmtNode* ifnode;
|
||||||
} YYSTYPE;
|
} YYSTYPE;
|
||||||
#define rwDEFINE 258
|
#define rwDEFINE 258
|
||||||
#define rwENDDEF 259
|
#define rwENDDEF 259
|
||||||
#define rwDECLARE 260
|
#define rwDECLARE 260
|
||||||
#define rwDECLARESINGLETON 261
|
#define rwDECLARESINGLETON 261
|
||||||
#define rwBREAK 262
|
#define rwBREAK 262
|
||||||
#define rwELSE 263
|
#define rwELSE 263
|
||||||
#define rwCONTINUE 264
|
#define rwCONTINUE 264
|
||||||
#define rwGLOBAL 265
|
#define rwGLOBAL 265
|
||||||
#define rwIF 266
|
#define rwIF 266
|
||||||
#define rwNIL 267
|
#define rwNIL 267
|
||||||
#define rwRETURN 268
|
#define rwRETURN 268
|
||||||
#define rwWHILE 269
|
#define rwWHILE 269
|
||||||
#define rwDO 270
|
#define rwDO 270
|
||||||
#define rwENDIF 271
|
#define rwENDIF 271
|
||||||
#define rwENDWHILE 272
|
#define rwENDWHILE 272
|
||||||
#define rwENDFOR 273
|
#define rwENDFOR 273
|
||||||
#define rwDEFAULT 274
|
#define rwDEFAULT 274
|
||||||
#define rwFOR 275
|
#define rwFOR 275
|
||||||
#define rwFOREACH 276
|
#define rwFOREACH 276
|
||||||
#define rwFOREACHSTR 277
|
#define rwFOREACHSTR 277
|
||||||
#define rwIN 278
|
#define rwIN 278
|
||||||
#define rwDATABLOCK 279
|
#define rwDATABLOCK 279
|
||||||
#define rwSWITCH 280
|
#define rwSWITCH 280
|
||||||
#define rwCASE 281
|
#define rwCASE 281
|
||||||
#define rwSWITCHSTR 282
|
#define rwSWITCHSTR 282
|
||||||
#define rwCASEOR 283
|
#define rwCASEOR 283
|
||||||
#define rwPACKAGE 284
|
#define rwPACKAGE 284
|
||||||
#define rwNAMESPACE 285
|
#define rwNAMESPACE 285
|
||||||
#define rwCLASS 286
|
#define rwCLASS 286
|
||||||
#define rwASSERT 287
|
#define rwASSERT 287
|
||||||
#define ILLEGAL_TOKEN 288
|
#define ILLEGAL_TOKEN 288
|
||||||
#define CHRCONST 289
|
#define CHRCONST 289
|
||||||
#define INTCONST 290
|
#define INTCONST 290
|
||||||
#define TTAG 291
|
#define TTAG 291
|
||||||
#define VAR 292
|
#define VAR 292
|
||||||
#define IDENT 293
|
#define IDENT 293
|
||||||
#define TYPEIDENT 294
|
#define TYPEIDENT 294
|
||||||
#define DOCBLOCK 295
|
#define DOCBLOCK 295
|
||||||
#define STRATOM 296
|
#define STRATOM 296
|
||||||
#define TAGATOM 297
|
#define TAGATOM 297
|
||||||
#define FLTCONST 298
|
#define FLTCONST 298
|
||||||
#define opINTNAME 299
|
#define opINTNAME 299
|
||||||
#define opINTNAMER 300
|
#define opINTNAMER 300
|
||||||
#define opMINUSMINUS 301
|
#define opMINUSMINUS 301
|
||||||
#define opPLUSPLUS 302
|
#define opPLUSPLUS 302
|
||||||
#define STMT_SEP 303
|
#define STMT_SEP 303
|
||||||
#define opSHL 304
|
#define opSHL 304
|
||||||
#define opSHR 305
|
#define opSHR 305
|
||||||
#define opPLASN 306
|
#define opPLASN 306
|
||||||
#define opMIASN 307
|
#define opMIASN 307
|
||||||
#define opMLASN 308
|
#define opMLASN 308
|
||||||
#define opDVASN 309
|
#define opDVASN 309
|
||||||
#define opMODASN 310
|
#define opMODASN 310
|
||||||
#define opANDASN 311
|
#define opANDASN 311
|
||||||
#define opXORASN 312
|
#define opXORASN 312
|
||||||
#define opORASN 313
|
#define opORASN 313
|
||||||
#define opSLASN 314
|
#define opSLASN 314
|
||||||
#define opSRASN 315
|
#define opSRASN 315
|
||||||
#define opCAT 316
|
#define opCAT 316
|
||||||
#define opEQ 317
|
#define opEQ 317
|
||||||
#define opNE 318
|
#define opNE 318
|
||||||
#define opGE 319
|
#define opGE 319
|
||||||
#define opLE 320
|
#define opLE 320
|
||||||
#define opAND 321
|
#define opAND 321
|
||||||
#define opOR 322
|
#define opOR 322
|
||||||
#define opSTREQ 323
|
#define opSTREQ 323
|
||||||
#define opCOLONCOLON 324
|
#define opCOLONCOLON 324
|
||||||
#define opMDASN 325
|
#define opMDASN 325
|
||||||
#define opNDASN 326
|
#define opNDASN 326
|
||||||
#define opNTASN 327
|
#define opNTASN 327
|
||||||
#define opSTRNE 328
|
#define opSTRNE 328
|
||||||
#define UNARY 329
|
#define UNARY 329
|
||||||
|
|
||||||
|
|
||||||
extern YYSTYPE CMDlval;
|
extern YYSTYPE CMDlval;
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -35,6 +35,7 @@ class ConsoleValueRef;
|
||||||
/// This class represents a block of code, usually mapped directly to a file.
|
/// This class represents a block of code, usually mapped directly to a file.
|
||||||
class CodeBlock
|
class CodeBlock
|
||||||
{
|
{
|
||||||
|
friend class CodeInterpreter;
|
||||||
private:
|
private:
|
||||||
static CodeBlock* smCodeBlockList;
|
static CodeBlock* smCodeBlockList;
|
||||||
static CodeBlock* smCurrentCodeBlock;
|
static CodeBlock* smCurrentCodeBlock;
|
||||||
|
|
@ -89,7 +90,7 @@ public:
|
||||||
void calcBreakList();
|
void calcBreakList();
|
||||||
void clearAllBreaks();
|
void clearAllBreaks();
|
||||||
void setAllBreaks();
|
void setAllBreaks();
|
||||||
void dumpInstructions( U32 startIp = 0, bool upToReturn = false );
|
void dumpInstructions(U32 startIp = 0, bool upToReturn = false);
|
||||||
|
|
||||||
/// Returns the first breakable line or 0 if none was found.
|
/// Returns the first breakable line or 0 if none was found.
|
||||||
/// @param lineNumber The one based line number.
|
/// @param lineNumber The one based line number.
|
||||||
|
|
@ -106,7 +107,7 @@ public:
|
||||||
const char *getFileLine(U32 ip);
|
const char *getFileLine(U32 ip);
|
||||||
|
|
||||||
///
|
///
|
||||||
String getFunctionArgs( U32 offset );
|
String getFunctionArgs(U32 offset);
|
||||||
|
|
||||||
bool read(StringTableEntry fileName, Stream &st);
|
bool read(StringTableEntry fileName, Stream &st);
|
||||||
bool compile(const char *dsoName, StringTableEntry fileName, const char *script, bool overrideNoDso = false);
|
bool compile(const char *dsoName, StringTableEntry fileName, const char *script, bool overrideNoDso = false);
|
||||||
|
|
@ -130,7 +131,7 @@ public:
|
||||||
/// -1 a new frame is created. If the index is out of range the
|
/// -1 a new frame is created. If the index is out of range the
|
||||||
/// top stack frame is used.
|
/// top stack frame is used.
|
||||||
ConsoleValueRef compileExec(StringTableEntry fileName, const char *script,
|
ConsoleValueRef compileExec(StringTableEntry fileName, const char *script,
|
||||||
bool noCalls, S32 setFrame = -1 );
|
bool noCalls, S32 setFrame = -1);
|
||||||
|
|
||||||
/// Executes the existing code in the CodeBlock. The return string is any
|
/// Executes the existing code in the CodeBlock. The return string is any
|
||||||
/// result of the code executed, if any, or an empty string.
|
/// result of the code executed, if any, or an empty string.
|
||||||
|
|
|
||||||
2979
Engine/source/console/codeInterpreter.cpp
Normal file
2979
Engine/source/console/codeInterpreter.cpp
Normal file
File diff suppressed because it is too large
Load diff
262
Engine/source/console/codeInterpreter.h
Normal file
262
Engine/source/console/codeInterpreter.h
Normal file
|
|
@ -0,0 +1,262 @@
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// 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 _CODEINTERPRETER_H_
|
||||||
|
#define _CODEINTERPRETER_H_
|
||||||
|
|
||||||
|
#include "console/codeBlock.h"
|
||||||
|
#include "console/console.h"
|
||||||
|
#include "console/consoleInternal.h"
|
||||||
|
|
||||||
|
/// Frame data for a foreach/foreach$ loop.
|
||||||
|
struct IterStackRecord
|
||||||
|
{
|
||||||
|
/// If true, this is a foreach$ loop; if not, it's a foreach loop.
|
||||||
|
bool mIsStringIter;
|
||||||
|
|
||||||
|
/// The iterator variable.
|
||||||
|
Dictionary::Entry* mVariable;
|
||||||
|
|
||||||
|
/// Information for an object iterator loop.
|
||||||
|
struct ObjectPos
|
||||||
|
{
|
||||||
|
/// The set being iterated over.
|
||||||
|
SimSet* mSet;
|
||||||
|
|
||||||
|
/// Current index in the set.
|
||||||
|
U32 mIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
/// Information for a string iterator loop.
|
||||||
|
struct StringPos
|
||||||
|
{
|
||||||
|
/// The raw string data on the string stack.
|
||||||
|
StringStackPtr mString;
|
||||||
|
|
||||||
|
/// Current parsing position.
|
||||||
|
U32 mIndex;
|
||||||
|
};
|
||||||
|
|
||||||
|
union
|
||||||
|
{
|
||||||
|
ObjectPos mObj;
|
||||||
|
StringPos mStr;
|
||||||
|
} mData;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OPCodeReturn
|
||||||
|
{
|
||||||
|
exitCode = -1,
|
||||||
|
success = 0,
|
||||||
|
breakContinue = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
class CodeInterpreter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CodeInterpreter(CodeBlock *cb);
|
||||||
|
~CodeInterpreter();
|
||||||
|
|
||||||
|
ConsoleValueRef exec(U32 ip,
|
||||||
|
StringTableEntry functionName,
|
||||||
|
Namespace *thisNamespace,
|
||||||
|
U32 argc,
|
||||||
|
ConsoleValueRef *argv,
|
||||||
|
bool noCalls,
|
||||||
|
StringTableEntry packageName,
|
||||||
|
S32 setFrame);
|
||||||
|
|
||||||
|
static void init();
|
||||||
|
|
||||||
|
// Methods
|
||||||
|
private:
|
||||||
|
void parseArgs(U32 &ip);
|
||||||
|
|
||||||
|
/// Group op codes
|
||||||
|
/// @{
|
||||||
|
|
||||||
|
OPCodeReturn op_func_decl(U32 &ip);
|
||||||
|
OPCodeReturn op_create_object(U32 &ip);
|
||||||
|
OPCodeReturn op_add_object(U32 &ip);
|
||||||
|
OPCodeReturn op_end_object(U32 &ip);
|
||||||
|
OPCodeReturn op_finish_object(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpiffnot(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpifnot(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpiff(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpif(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpifnot_np(U32 &ip);
|
||||||
|
OPCodeReturn op_jmpif_np(U32 &ip);
|
||||||
|
OPCodeReturn op_jmp(U32 &ip);
|
||||||
|
OPCodeReturn op_return_void(U32 &ip);
|
||||||
|
OPCodeReturn op_return(U32 &ip);
|
||||||
|
OPCodeReturn op_return_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_return_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_cmpeq(U32 &ip);
|
||||||
|
OPCodeReturn op_cmpgr(U32 &ip);
|
||||||
|
OPCodeReturn op_cmpge(U32 &ip);
|
||||||
|
OPCodeReturn op_cmplt(U32 &ip);
|
||||||
|
OPCodeReturn op_cmple(U32 &ip);
|
||||||
|
OPCodeReturn op_cmpne(U32 &ip);
|
||||||
|
OPCodeReturn op_xor(U32 &ip);
|
||||||
|
OPCodeReturn op_mod(U32 &ip);
|
||||||
|
OPCodeReturn op_bitand(U32 &ip);
|
||||||
|
OPCodeReturn op_bitor(U32 &ip);
|
||||||
|
OPCodeReturn op_not(U32 &ip);
|
||||||
|
OPCodeReturn op_notf(U32 &ip);
|
||||||
|
OPCodeReturn op_onescomplement(U32 &ip);
|
||||||
|
OPCodeReturn op_shr(U32 &ip);
|
||||||
|
OPCodeReturn op_shl(U32 &ip);
|
||||||
|
OPCodeReturn op_and(U32 &ip);
|
||||||
|
OPCodeReturn op_or(U32 &ip);
|
||||||
|
OPCodeReturn op_add(U32 &ip);
|
||||||
|
OPCodeReturn op_sub(U32 &ip);
|
||||||
|
OPCodeReturn op_mul(U32 &ip);
|
||||||
|
OPCodeReturn op_div(U32 &ip);
|
||||||
|
OPCodeReturn op_neg(U32 &ip);
|
||||||
|
OPCodeReturn op_inc(U32 &ip);
|
||||||
|
OPCodeReturn op_dec(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar_create(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar_array(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar_array_varlookup(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar_array_create(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurvar_array_create_varlookup(U32 &ip);
|
||||||
|
OPCodeReturn op_loadvar_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_loadvar_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_loadvar_str(U32 &ip);
|
||||||
|
OPCodeReturn op_loadvar_var(U32 &ip);
|
||||||
|
OPCodeReturn op_savevar_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_savevar_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_savevar_str(U32 &ip);
|
||||||
|
OPCodeReturn op_savevar_var(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurobject(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurobject_internal(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurobject_new(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurfield(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurfield_array(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurfield_type(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurfield_this(U32 &ip);
|
||||||
|
OPCodeReturn op_setcurfield_array_var(U32 &ip);
|
||||||
|
OPCodeReturn op_loadfield_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_loadfield_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_loadfield_str(U32 &ip);
|
||||||
|
OPCodeReturn op_savefield_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_savefield_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_savefield_str(U32 &ip);
|
||||||
|
OPCodeReturn op_str_to_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_str_to_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_str_to_none(U32 &ip);
|
||||||
|
OPCodeReturn op_flt_to_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_flt_to_str(U32 &ip);
|
||||||
|
OPCodeReturn op_flt_to_none(U32 &ip);
|
||||||
|
OPCodeReturn op_uint_to_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_uint_to_str(U32 &ip);
|
||||||
|
OPCodeReturn op_uint_to_none(U32 &ip);
|
||||||
|
OPCodeReturn op_copyvar_to_none(U32 &ip);
|
||||||
|
OPCodeReturn op_loadimmed_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_loadimmed_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_tag_to_str(U32 &ip);
|
||||||
|
OPCodeReturn op_loadimmed_str(U32 &ip);
|
||||||
|
OPCodeReturn op_docblock_str(U32 &ip);
|
||||||
|
OPCodeReturn op_loadimmed_ident(U32 &ip);
|
||||||
|
OPCodeReturn op_callfunc_resolve(U32 &ip);
|
||||||
|
OPCodeReturn op_callfunc(U32 &ip);
|
||||||
|
OPCodeReturn op_callfunc_pointer(U32 &ip);
|
||||||
|
OPCodeReturn op_callfunc_this(U32 &ip);
|
||||||
|
OPCodeReturn op_advance_str(U32 &ip);
|
||||||
|
OPCodeReturn op_advance_str_appendchar(U32 &ip);
|
||||||
|
OPCodeReturn op_advance_str_comma(U32 &ip);
|
||||||
|
OPCodeReturn op_advance_str_nul(U32 &ip);
|
||||||
|
OPCodeReturn op_rewind_str(U32 &ip);
|
||||||
|
OPCodeReturn op_terminate_rewind_str(U32 &ip);
|
||||||
|
OPCodeReturn op_compare_str(U32 &ip);
|
||||||
|
OPCodeReturn op_push(U32 &ip);
|
||||||
|
OPCodeReturn op_push_uint(U32 &ip);
|
||||||
|
OPCodeReturn op_push_flt(U32 &ip);
|
||||||
|
OPCodeReturn op_push_var(U32 &ip);
|
||||||
|
OPCodeReturn op_push_this(U32 &ip);
|
||||||
|
OPCodeReturn op_push_frame(U32 &ip);
|
||||||
|
OPCodeReturn op_assert(U32 &ip);
|
||||||
|
OPCodeReturn op_break(U32 &ip);
|
||||||
|
OPCodeReturn op_iter_begin_str(U32 &ip);
|
||||||
|
OPCodeReturn op_iter_begin(U32 &ip);
|
||||||
|
OPCodeReturn op_iter(U32 &ip);
|
||||||
|
OPCodeReturn op_iter_end(U32 &ip);
|
||||||
|
OPCodeReturn op_invalid(U32 &ip);
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
|
private:
|
||||||
|
CodeBlock *mCodeBlock;
|
||||||
|
|
||||||
|
/// Group exec arguments.
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
StringTableEntry functionName;
|
||||||
|
Namespace *thisNamespace;
|
||||||
|
U32 argc;
|
||||||
|
ConsoleValueRef *argv;
|
||||||
|
bool noCalls;
|
||||||
|
StringTableEntry packageName;
|
||||||
|
S32 setFrame;
|
||||||
|
} mExec;
|
||||||
|
|
||||||
|
U32 mIterDepth;
|
||||||
|
F64 *mCurFloatTable;
|
||||||
|
char *mCurStringTable;
|
||||||
|
StringTableEntry mThisFunctionName;
|
||||||
|
bool mPopFrame;
|
||||||
|
|
||||||
|
// Add local object creation stack [7/9/2007 Black]
|
||||||
|
static const U32 objectCreationStackSize = 32;
|
||||||
|
U32 mObjectCreationStackIndex;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
SimObject *newObject;
|
||||||
|
U32 failJump;
|
||||||
|
} mObjectCreationStack[objectCreationStackSize];
|
||||||
|
|
||||||
|
SimObject *mCurrentNewObject;
|
||||||
|
U32 mFailJump;
|
||||||
|
StringTableEntry mPrevField;
|
||||||
|
StringTableEntry mCurField;
|
||||||
|
SimObject *mPrevObject;
|
||||||
|
SimObject *mCurObject;
|
||||||
|
SimObject *mSaveObject;
|
||||||
|
SimObject *mThisObject;
|
||||||
|
Namespace::Entry *mNSEntry;
|
||||||
|
StringTableEntry mCurFNDocBlock;
|
||||||
|
StringTableEntry mCurNSDocBlock;
|
||||||
|
U32 mCallArgc;
|
||||||
|
ConsoleValueRef *mCallArgv;
|
||||||
|
CodeBlock *mSaveCodeBlock;
|
||||||
|
|
||||||
|
// note: anything returned is pushed to CSTK and will be invalidated on the next exec()
|
||||||
|
ConsoleValueRef mReturnValue;
|
||||||
|
|
||||||
|
U32 mCurrentInstruction;
|
||||||
|
|
||||||
|
static const S32 nsDocLength = 128;
|
||||||
|
char mNSDocBlockClass[nsDocLength];
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -40,13 +40,13 @@ namespace Compiler
|
||||||
F64 consoleStringToNumber(const char *str, StringTableEntry file, U32 line)
|
F64 consoleStringToNumber(const char *str, StringTableEntry file, U32 line)
|
||||||
{
|
{
|
||||||
F64 val = dAtof(str);
|
F64 val = dAtof(str);
|
||||||
if(val != 0)
|
if (val != 0)
|
||||||
return val;
|
return val;
|
||||||
else if(!dStricmp(str, "true"))
|
else if (!dStricmp(str, "true"))
|
||||||
return 1;
|
return 1;
|
||||||
else if(!dStricmp(str, "false"))
|
else if (!dStricmp(str, "false"))
|
||||||
return 0;
|
return 0;
|
||||||
else if(file)
|
else if (file)
|
||||||
{
|
{
|
||||||
Con::warnf(ConsoleLogEntry::General, "%s (%d): string always evaluates to 0.", file, line);
|
Con::warnf(ConsoleLogEntry::General, "%s (%d): string always evaluates to 0.", file, line);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -57,7 +57,7 @@ namespace Compiler
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
CompilerStringTable *gCurrentStringTable, gGlobalStringTable, gFunctionStringTable;
|
CompilerStringTable *gCurrentStringTable, gGlobalStringTable, gFunctionStringTable;
|
||||||
CompilerFloatTable *gCurrentFloatTable, gGlobalFloatTable, gFunctionFloatTable;
|
CompilerFloatTable *gCurrentFloatTable, gGlobalFloatTable, gFunctionFloatTable;
|
||||||
DataChunker gConsoleAllocator;
|
DataChunker gConsoleAllocator;
|
||||||
CompilerIdentTable gIdentTable;
|
CompilerIdentTable gIdentTable;
|
||||||
|
|
||||||
|
|
@ -74,13 +74,13 @@ namespace Compiler
|
||||||
|
|
||||||
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr)
|
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr)
|
||||||
{
|
{
|
||||||
if(ste)
|
if (ste)
|
||||||
getIdentTable().add(ste, ip);
|
getIdentTable().add(ste, ip);
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
*(ptr+1) = 0;
|
*(ptr + 1) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr) = evalSTEtoCode;
|
void(*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr) = evalSTEtoCode;
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -88,23 +88,23 @@ namespace Compiler
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
||||||
CompilerStringTable *getCurrentStringTable() { return gCurrentStringTable; }
|
CompilerStringTable *getCurrentStringTable() { return gCurrentStringTable; }
|
||||||
CompilerStringTable &getGlobalStringTable() { return gGlobalStringTable; }
|
CompilerStringTable &getGlobalStringTable() { return gGlobalStringTable; }
|
||||||
CompilerStringTable &getFunctionStringTable() { return gFunctionStringTable; }
|
CompilerStringTable &getFunctionStringTable() { return gFunctionStringTable; }
|
||||||
|
|
||||||
void setCurrentStringTable (CompilerStringTable* cst) { gCurrentStringTable = cst; }
|
void setCurrentStringTable(CompilerStringTable* cst) { gCurrentStringTable = cst; }
|
||||||
|
|
||||||
CompilerFloatTable *getCurrentFloatTable() { return gCurrentFloatTable; }
|
CompilerFloatTable *getCurrentFloatTable() { return gCurrentFloatTable; }
|
||||||
CompilerFloatTable &getGlobalFloatTable() { return gGlobalFloatTable; }
|
CompilerFloatTable &getGlobalFloatTable() { return gGlobalFloatTable; }
|
||||||
CompilerFloatTable &getFunctionFloatTable() { return gFunctionFloatTable; }
|
CompilerFloatTable &getFunctionFloatTable() { return gFunctionFloatTable; }
|
||||||
|
|
||||||
void setCurrentFloatTable (CompilerFloatTable* cst) { gCurrentFloatTable = cst; }
|
void setCurrentFloatTable(CompilerFloatTable* cst) { gCurrentFloatTable = cst; }
|
||||||
|
|
||||||
CompilerIdentTable &getIdentTable() { return gIdentTable; }
|
CompilerIdentTable &getIdentTable() { return gIdentTable; }
|
||||||
|
|
||||||
void precompileIdent(StringTableEntry ident)
|
void precompileIdent(StringTableEntry ident)
|
||||||
{
|
{
|
||||||
if(ident)
|
if (ident)
|
||||||
gGlobalStringTable.add(ident);
|
gGlobalStringTable.add(ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,8 +119,8 @@ namespace Compiler
|
||||||
getIdentTable().reset();
|
getIdentTable().reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
|
void *consoleAlloc(U32 size) { return gConsoleAllocator.alloc(size); }
|
||||||
void consoleAllocReset() { gConsoleAllocator.freeBlocks(); }
|
void consoleAllocReset() { gConsoleAllocator.freeBlocks(); }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,36 +135,40 @@ U32 CompilerStringTable::add(const char *str, bool caseSens, bool tag)
|
||||||
{
|
{
|
||||||
// Is it already in?
|
// Is it already in?
|
||||||
Entry **walk;
|
Entry **walk;
|
||||||
for(walk = &list; *walk; walk = &((*walk)->next))
|
for (walk = &list; *walk; walk = &((*walk)->next))
|
||||||
{
|
{
|
||||||
if((*walk)->tag != tag)
|
if ((*walk)->tag != tag)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(caseSens)
|
if (caseSens)
|
||||||
{
|
{
|
||||||
if(!dStrcmp((*walk)->string, str))
|
if (!dStrcmp((*walk)->string, str))
|
||||||
return (*walk)->start;
|
return (*walk)->start;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(!dStricmp((*walk)->string, str))
|
if (!dStricmp((*walk)->string, str))
|
||||||
return (*walk)->start;
|
return (*walk)->start;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write it out.
|
// Write it out.
|
||||||
Entry *newStr = (Entry *) consoleAlloc(sizeof(Entry));
|
Entry *newStr = (Entry *)consoleAlloc(sizeof(Entry));
|
||||||
*walk = newStr;
|
*walk = newStr;
|
||||||
newStr->next = NULL;
|
newStr->next = NULL;
|
||||||
newStr->start = totalLen;
|
newStr->start = totalLen;
|
||||||
U32 len = dStrlen(str) + 1;
|
U32 len = dStrlen(str) + 1;
|
||||||
if(tag && len < 7) // alloc space for the numeric tag 1 for tag, 5 for # and 1 for nul
|
if (tag && len < 7) // alloc space for the numeric tag 1 for tag, 5 for # and 1 for nul
|
||||||
len = 7;
|
len = 7;
|
||||||
totalLen += len;
|
totalLen += len;
|
||||||
newStr->string = (char *) consoleAlloc(len);
|
newStr->string = (char *)consoleAlloc(len);
|
||||||
newStr->len = len;
|
newStr->len = len;
|
||||||
newStr->tag = tag;
|
newStr->tag = tag;
|
||||||
dStrcpy(newStr->string, str);
|
dStrcpy(newStr->string, str);
|
||||||
|
|
||||||
|
// Put into the hash table.
|
||||||
|
hashTable[str] = newStr;
|
||||||
|
|
||||||
return newStr->start;
|
return newStr->start;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,7 +193,8 @@ void CompilerStringTable::reset()
|
||||||
char *CompilerStringTable::build()
|
char *CompilerStringTable::build()
|
||||||
{
|
{
|
||||||
char *ret = new char[totalLen];
|
char *ret = new char[totalLen];
|
||||||
for(Entry *walk = list; walk; walk = walk->next)
|
dMemset(ret, 0, totalLen);
|
||||||
|
for (Entry *walk = list; walk; walk = walk->next)
|
||||||
dStrcpy(ret + walk->start, walk->string);
|
dStrcpy(ret + walk->start, walk->string);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -197,7 +202,7 @@ char *CompilerStringTable::build()
|
||||||
void CompilerStringTable::write(Stream &st)
|
void CompilerStringTable::write(Stream &st)
|
||||||
{
|
{
|
||||||
st.write(totalLen);
|
st.write(totalLen);
|
||||||
for(Entry *walk = list; walk; walk = walk->next)
|
for (Entry *walk = list; walk; walk = walk->next)
|
||||||
st.write(walk->len, walk->string);
|
st.write(walk->len, walk->string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -207,15 +212,15 @@ U32 CompilerFloatTable::add(F64 value)
|
||||||
{
|
{
|
||||||
Entry **walk;
|
Entry **walk;
|
||||||
U32 i = 0;
|
U32 i = 0;
|
||||||
for(walk = &list; *walk; walk = &((*walk)->next), i++)
|
for (walk = &list; *walk; walk = &((*walk)->next), i++)
|
||||||
if(value == (*walk)->val)
|
if (value == (*walk)->val)
|
||||||
return i;
|
return i;
|
||||||
Entry *newFloat = (Entry *) consoleAlloc(sizeof(Entry));
|
Entry *newFloat = (Entry *)consoleAlloc(sizeof(Entry));
|
||||||
newFloat->val = value;
|
newFloat->val = value;
|
||||||
newFloat->next = NULL;
|
newFloat->next = NULL;
|
||||||
count++;
|
count++;
|
||||||
*walk = newFloat;
|
*walk = newFloat;
|
||||||
return count-1;
|
return count - 1;
|
||||||
}
|
}
|
||||||
void CompilerFloatTable::reset()
|
void CompilerFloatTable::reset()
|
||||||
{
|
{
|
||||||
|
|
@ -226,7 +231,7 @@ F64 *CompilerFloatTable::build()
|
||||||
{
|
{
|
||||||
F64 *ret = new F64[count];
|
F64 *ret = new F64[count];
|
||||||
U32 i = 0;
|
U32 i = 0;
|
||||||
for(Entry *walk = list; walk; walk = walk->next, i++)
|
for (Entry *walk = list; walk; walk = walk->next, i++)
|
||||||
ret[i] = walk->val;
|
ret[i] = walk->val;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -234,7 +239,7 @@ F64 *CompilerFloatTable::build()
|
||||||
void CompilerFloatTable::write(Stream &st)
|
void CompilerFloatTable::write(Stream &st)
|
||||||
{
|
{
|
||||||
st.write(count);
|
st.write(count);
|
||||||
for(Entry *walk = list; walk; walk = walk->next)
|
for (Entry *walk = list; walk; walk = walk->next)
|
||||||
st.write(walk->val);
|
st.write(walk->val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,12 +253,12 @@ void CompilerIdentTable::reset()
|
||||||
void CompilerIdentTable::add(StringTableEntry ste, U32 ip)
|
void CompilerIdentTable::add(StringTableEntry ste, U32 ip)
|
||||||
{
|
{
|
||||||
U32 index = gGlobalStringTable.add(ste, false);
|
U32 index = gGlobalStringTable.add(ste, false);
|
||||||
Entry *newEntry = (Entry *) consoleAlloc(sizeof(Entry));
|
Entry *newEntry = (Entry *)consoleAlloc(sizeof(Entry));
|
||||||
newEntry->offset = index;
|
newEntry->offset = index;
|
||||||
newEntry->ip = ip;
|
newEntry->ip = ip;
|
||||||
for(Entry *walk = list; walk; walk = walk->next)
|
for (Entry *walk = list; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
if(walk->offset == index)
|
if (walk->offset == index)
|
||||||
{
|
{
|
||||||
newEntry->nextIdent = walk->nextIdent;
|
newEntry->nextIdent = walk->nextIdent;
|
||||||
walk->nextIdent = newEntry;
|
walk->nextIdent = newEntry;
|
||||||
|
|
@ -269,18 +274,18 @@ void CompilerIdentTable::write(Stream &st)
|
||||||
{
|
{
|
||||||
U32 count = 0;
|
U32 count = 0;
|
||||||
Entry * walk;
|
Entry * walk;
|
||||||
for(walk = list; walk; walk = walk->next)
|
for (walk = list; walk; walk = walk->next)
|
||||||
count++;
|
count++;
|
||||||
st.write(count);
|
st.write(count);
|
||||||
for(walk = list; walk; walk = walk->next)
|
for (walk = list; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
U32 ec = 0;
|
U32 ec = 0;
|
||||||
Entry * el;
|
Entry * el;
|
||||||
for(el = walk; el; el = el->nextIdent)
|
for (el = walk; el; el = el->nextIdent)
|
||||||
ec++;
|
ec++;
|
||||||
st.write(walk->offset);
|
st.write(walk->offset);
|
||||||
st.write(ec);
|
st.write(ec);
|
||||||
for(el = walk; el; el = el->nextIdent)
|
for (el = walk; el; el = el->nextIdent)
|
||||||
st.write(el->ip);
|
st.write(el->ip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -320,10 +325,10 @@ void CodeStream::fixLoop(U32 loopBlockStart, U32 breakPoint, U32 continuePoint)
|
||||||
{
|
{
|
||||||
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
||||||
|
|
||||||
U32 fixStart = mFixStack[mFixStack.size()-1];
|
U32 fixStart = mFixStack[mFixStack.size() - 1];
|
||||||
for (U32 i=fixStart; i<mFixList.size(); i += 2)
|
for (U32 i = fixStart; i<mFixList.size(); i += 2)
|
||||||
{
|
{
|
||||||
FixType type = (FixType)mFixList[i+1];
|
FixType type = (FixType)mFixList[i + 1];
|
||||||
|
|
||||||
U32 fixedIp = 0;
|
U32 fixedIp = 0;
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
@ -377,7 +382,7 @@ void CodeStream::emitCodeStream(U32 *size, U32 **stream, U32 **lineBreaks)
|
||||||
dMemcpy(*lineBreaks, mBreakLines.address(), sizeof(U32) * mBreakLines.size());
|
dMemcpy(*lineBreaks, mBreakLines.address(), sizeof(U32) * mBreakLines.size());
|
||||||
|
|
||||||
// Apply patches on top
|
// Apply patches on top
|
||||||
for (U32 i=0; i<mPatchList.size(); i++)
|
for (U32 i = 0; i<mPatchList.size(); i++)
|
||||||
{
|
{
|
||||||
PatchEntry &e = mPatchList[i];
|
PatchEntry &e = mPatchList[i];
|
||||||
(*stream)[e.addr] = e.value;
|
(*stream)[e.addr] = e.value;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,9 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
class Stream;
|
class Stream;
|
||||||
class DataChunker;
|
class DataChunker;
|
||||||
|
|
||||||
|
|
@ -91,10 +94,15 @@ namespace Compiler
|
||||||
OP_DIV,
|
OP_DIV,
|
||||||
OP_NEG,
|
OP_NEG,
|
||||||
|
|
||||||
|
OP_INC,
|
||||||
|
OP_DEC,
|
||||||
|
|
||||||
OP_SETCURVAR,
|
OP_SETCURVAR,
|
||||||
OP_SETCURVAR_CREATE,
|
OP_SETCURVAR_CREATE,
|
||||||
OP_SETCURVAR_ARRAY,
|
OP_SETCURVAR_ARRAY,
|
||||||
|
OP_SETCURVAR_ARRAY_VARLOOKUP,
|
||||||
OP_SETCURVAR_ARRAY_CREATE,
|
OP_SETCURVAR_ARRAY_CREATE,
|
||||||
|
OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP,
|
||||||
|
|
||||||
OP_LOADVAR_UINT,// 40
|
OP_LOADVAR_UINT,// 40
|
||||||
OP_LOADVAR_FLT,
|
OP_LOADVAR_FLT,
|
||||||
|
|
@ -113,6 +121,8 @@ namespace Compiler
|
||||||
OP_SETCURFIELD,
|
OP_SETCURFIELD,
|
||||||
OP_SETCURFIELD_ARRAY, // 50
|
OP_SETCURFIELD_ARRAY, // 50
|
||||||
OP_SETCURFIELD_TYPE,
|
OP_SETCURFIELD_TYPE,
|
||||||
|
OP_SETCURFIELD_ARRAY_VAR,
|
||||||
|
OP_SETCURFIELD_THIS,
|
||||||
|
|
||||||
OP_LOADFIELD_UINT,
|
OP_LOADFIELD_UINT,
|
||||||
OP_LOADFIELD_FLT,
|
OP_LOADFIELD_FLT,
|
||||||
|
|
@ -142,6 +152,8 @@ namespace Compiler
|
||||||
|
|
||||||
OP_CALLFUNC_RESOLVE,
|
OP_CALLFUNC_RESOLVE,
|
||||||
OP_CALLFUNC,
|
OP_CALLFUNC,
|
||||||
|
OP_CALLFUNC_POINTER,
|
||||||
|
OP_CALLFUNC_THIS,
|
||||||
|
|
||||||
OP_ADVANCE_STR,
|
OP_ADVANCE_STR,
|
||||||
OP_ADVANCE_STR_APPENDCHAR,
|
OP_ADVANCE_STR_APPENDCHAR,
|
||||||
|
|
@ -155,6 +167,7 @@ namespace Compiler
|
||||||
OP_PUSH_UINT, // Integer
|
OP_PUSH_UINT, // Integer
|
||||||
OP_PUSH_FLT, // Float
|
OP_PUSH_FLT, // Float
|
||||||
OP_PUSH_VAR, // Variable
|
OP_PUSH_VAR, // Variable
|
||||||
|
OP_PUSH_THIS, // This pointer
|
||||||
OP_PUSH_FRAME, // Frame
|
OP_PUSH_FRAME, // Frame
|
||||||
|
|
||||||
OP_ASSERT,
|
OP_ASSERT,
|
||||||
|
|
@ -165,7 +178,9 @@ namespace Compiler
|
||||||
OP_ITER, ///< Enter foreach loop.
|
OP_ITER, ///< Enter foreach loop.
|
||||||
OP_ITER_END, ///< End foreach loop.
|
OP_ITER_END, ///< End foreach loop.
|
||||||
|
|
||||||
OP_INVALID // 90
|
OP_INVALID, // 90
|
||||||
|
|
||||||
|
MAX_OP_CODELEN ///< The amount of op codes.
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------
|
//------------------------------------------------------------
|
||||||
|
|
@ -207,6 +222,7 @@ namespace Compiler
|
||||||
Entry *list;
|
Entry *list;
|
||||||
|
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
std::unordered_map<std::string, Entry*> hashTable;
|
||||||
|
|
||||||
U32 add(const char *str, bool caseSens = true, bool tag = false);
|
U32 add(const char *str, bool caseSens = true, bool tag = false);
|
||||||
U32 addIntString(U32 value);
|
U32 addIntString(U32 value);
|
||||||
|
|
@ -239,13 +255,13 @@ namespace Compiler
|
||||||
inline StringTableEntry CodeToSTE(U32 *code, U32 ip)
|
inline StringTableEntry CodeToSTE(U32 *code, U32 ip)
|
||||||
{
|
{
|
||||||
#ifdef TORQUE_CPU_X64
|
#ifdef TORQUE_CPU_X64
|
||||||
return (StringTableEntry)(*((U64*)(code+ip)));
|
return (StringTableEntry)(*((U64*)(code + ip)));
|
||||||
#else
|
#else
|
||||||
return (StringTableEntry)(*(code+ip));
|
return (StringTableEntry)(*(code + ip));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void (*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr);
|
extern void(*STEtoCode)(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||||
|
|
||||||
void evalSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
void evalSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||||
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
void compileSTEtoCode(StringTableEntry ste, U32 ip, U32 *ptr);
|
||||||
|
|
@ -254,13 +270,13 @@ namespace Compiler
|
||||||
CompilerStringTable &getGlobalStringTable();
|
CompilerStringTable &getGlobalStringTable();
|
||||||
CompilerStringTable &getFunctionStringTable();
|
CompilerStringTable &getFunctionStringTable();
|
||||||
|
|
||||||
void setCurrentStringTable (CompilerStringTable* cst);
|
void setCurrentStringTable(CompilerStringTable* cst);
|
||||||
|
|
||||||
CompilerFloatTable *getCurrentFloatTable();
|
CompilerFloatTable *getCurrentFloatTable();
|
||||||
CompilerFloatTable &getGlobalFloatTable();
|
CompilerFloatTable &getGlobalFloatTable();
|
||||||
CompilerFloatTable &getFunctionFloatTable();
|
CompilerFloatTable &getFunctionFloatTable();
|
||||||
|
|
||||||
void setCurrentFloatTable (CompilerFloatTable* cst);
|
void setCurrentFloatTable(CompilerFloatTable* cst);
|
||||||
|
|
||||||
CompilerIdentTable &getIdentTable();
|
CompilerIdentTable &getIdentTable();
|
||||||
|
|
||||||
|
|
@ -301,8 +317,8 @@ protected:
|
||||||
U32 addr; ///< Address to patch
|
U32 addr; ///< Address to patch
|
||||||
U32 value; ///< Value to place at addr
|
U32 value; ///< Value to place at addr
|
||||||
|
|
||||||
PatchEntry() {;}
|
PatchEntry() { ; }
|
||||||
PatchEntry(U32 a, U32 v) : addr(a), value(v) {;}
|
PatchEntry(U32 a, U32 v) : addr(a), value(v) { ; }
|
||||||
} PatchEntry;
|
} PatchEntry;
|
||||||
|
|
||||||
typedef struct CodeData
|
typedef struct CodeData
|
||||||
|
|
@ -375,7 +391,7 @@ public:
|
||||||
printf("code[%u] = %s\n", mCodePos, code);
|
printf("code[%u] = %s\n", mCodePos, code);
|
||||||
#endif
|
#endif
|
||||||
mCodePos += 2;
|
mCodePos += 2;
|
||||||
return mCodePos-2;
|
return mCodePos - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline U32 tell()
|
inline U32 tell()
|
||||||
|
|
@ -385,7 +401,7 @@ public:
|
||||||
|
|
||||||
inline bool inLoop()
|
inline bool inLoop()
|
||||||
{
|
{
|
||||||
for (U32 i=0; i<mFixLoopStack.size(); i++)
|
for (U32 i = 0; i<mFixLoopStack.size(); i++)
|
||||||
{
|
{
|
||||||
if (mFixLoopStack[i])
|
if (mFixLoopStack[i])
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -417,7 +433,7 @@ public:
|
||||||
{
|
{
|
||||||
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
AssertFatal(mFixStack.size() > 0, "Fix stack mismatch");
|
||||||
|
|
||||||
U32 newSize = mFixStack[mFixStack.size()-1];
|
U32 newSize = mFixStack[mFixStack.size() - 1];
|
||||||
while (mFixList.size() > newSize)
|
while (mFixList.size() > newSize)
|
||||||
mFixList.pop_back();
|
mFixList.pop_back();
|
||||||
mFixStack.pop_back();
|
mFixStack.pop_back();
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,13 @@
|
||||||
#define _CONSOLE_H_
|
#define _CONSOLE_H_
|
||||||
|
|
||||||
#ifndef _PLATFORM_H_
|
#ifndef _PLATFORM_H_
|
||||||
#include "platform/platform.h"
|
#include "platform/platform.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _BITSET_H_
|
#ifndef _BITSET_H_
|
||||||
#include "core/bitSet.h"
|
#include "core/bitSet.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _REFBASE_H_
|
#ifndef _REFBASE_H_
|
||||||
#include "core/util/refBase.h"
|
#include "core/util/refBase.h"
|
||||||
#endif
|
#endif
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
@ -95,8 +95,8 @@ struct ConsoleLogEntry
|
||||||
Script,
|
Script,
|
||||||
GUI,
|
GUI,
|
||||||
Network,
|
Network,
|
||||||
GGConnect,
|
GGConnect,
|
||||||
NUM_TYPE
|
NUM_TYPE
|
||||||
} mType;
|
} mType;
|
||||||
|
|
||||||
/// Indicates the actual log entry.
|
/// Indicates the actual log entry.
|
||||||
|
|
@ -201,8 +201,8 @@ public:
|
||||||
ival = 0;
|
ival = 0;
|
||||||
fval = 0;
|
fval = 0;
|
||||||
}
|
}
|
||||||
ConsoleValue(){ init(); };
|
ConsoleValue() { init(); };
|
||||||
~ConsoleValue(){ cleanup(); };
|
~ConsoleValue() { cleanup(); };
|
||||||
};
|
};
|
||||||
|
|
||||||
// Proxy class for console variables
|
// Proxy class for console variables
|
||||||
|
|
@ -320,12 +320,12 @@ public:
|
||||||
|
|
||||||
///
|
///
|
||||||
typedef const char * (*StringCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
typedef const char * (*StringCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||||
typedef S32 (*IntCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
typedef S32(*IntCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||||
typedef F32 (*FloatCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
typedef F32(*FloatCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||||
typedef void (*VoidCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); // We have it return a value so things don't break..
|
typedef void(*VoidCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]); // We have it return a value so things don't break..
|
||||||
typedef bool (*BoolCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
typedef bool(*BoolCallback)(SimObject *obj, S32 argc, ConsoleValueRef argv[]);
|
||||||
|
|
||||||
typedef void (*ConsumerCallback)(U32 level, const char *consoleLine);
|
typedef void(*ConsumerCallback)(U32 level, const char *consoleLine);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @defgroup console_types Scripting Engine Type Functions
|
/// @defgroup console_types Scripting Engine Type Functions
|
||||||
|
|
@ -333,7 +333,7 @@ typedef void (*ConsumerCallback)(U32 level, const char *consoleLine);
|
||||||
/// @see Con::registerType
|
/// @see Con::registerType
|
||||||
/// @{
|
/// @{
|
||||||
typedef const char* (*GetDataFunction)(void *dptr, EnumTable *tbl, BitSet32 flag);
|
typedef const char* (*GetDataFunction)(void *dptr, EnumTable *tbl, BitSet32 flag);
|
||||||
typedef void (*SetDataFunction)(void *dptr, S32 argc, const char **argv, EnumTable *tbl, BitSet32 flag);
|
typedef void(*SetDataFunction)(void *dptr, S32 argc, const char **argv, EnumTable *tbl, BitSet32 flag);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// This namespace contains the core of the console functionality.
|
/// This namespace contains the core of the console functionality.
|
||||||
|
|
@ -361,20 +361,22 @@ namespace Con
|
||||||
/// 12/29/04 - BJG - 33->34 Removed some opcodes, part of namespace upgrade.
|
/// 12/29/04 - BJG - 33->34 Removed some opcodes, part of namespace upgrade.
|
||||||
/// 12/30/04 - BJG - 34->35 Reordered some things, further general shuffling.
|
/// 12/30/04 - BJG - 34->35 Reordered some things, further general shuffling.
|
||||||
/// 11/03/05 - BJG - 35->36 Integrated new debugger code.
|
/// 11/03/05 - BJG - 35->36 Integrated new debugger code.
|
||||||
// 09/08/06 - THB - 36->37 New opcode for internal names
|
/// 09/08/06 - THB - 36->37 New opcode for internal names
|
||||||
// 09/15/06 - THB - 37->38 Added unit conversions
|
/// 09/15/06 - THB - 37->38 Added unit conversions
|
||||||
// 11/23/06 - THB - 38->39 Added recursive internal name operator
|
/// 11/23/06 - THB - 38->39 Added recursive internal name operator
|
||||||
// 02/15/07 - THB - 39->40 Bumping to 40 for TGB since the console has been
|
/// 02/15/07 - THB - 39->40 Bumping to 40 for TGB since the console has been
|
||||||
// majorly hacked without the version number being bumped
|
/// majorly hacked without the version number being bumped
|
||||||
// 02/16/07 - THB - 40->41 newmsg operator
|
/// 02/16/07 - THB - 40->41 newmsg operator
|
||||||
// 06/15/07 - THB - 41->42 script types
|
/// 06/15/07 - THB - 41->42 script types
|
||||||
/// 07/31/07 - THB - 42->43 Patch from Andreas Kirsch: Added opcode to support nested new declarations.
|
/// 07/31/07 - THB - 42->43 Patch from Andreas Kirsch: Added opcode to support nested new declarations.
|
||||||
/// 09/12/07 - CAF - 43->44 remove newmsg operator
|
/// 09/12/07 - CAF - 43->44 remove newmsg operator
|
||||||
/// 09/27/07 - RDB - 44->45 Patch from Andreas Kirsch: Added opcode to support correct void return
|
/// 09/27/07 - RDB - 44->45 Patch from Andreas Kirsch: Added opcode to support correct void return
|
||||||
/// 01/13/09 - TMS - 45->46 Added script assert
|
/// 01/13/09 - TMS - 45->46 Added script assert
|
||||||
/// 09/07/14 - jamesu - 46->47 64bit support
|
/// 09/07/14 - jamesu - 46->47 64bit support
|
||||||
/// 10/14/14 - jamesu - 47->48 Added opcodes to reduce reliance on strings in function calls
|
/// 10/14/14 - jamesu - 47->48 Added opcodes to reduce reliance on strings in function calls
|
||||||
DSOVersion = 48,
|
/// 10/07/17 - JTH - 48->49 Added opcode for function pointers and revamp of interpreter
|
||||||
|
/// from switch to function calls.
|
||||||
|
DSOVersion = 49,
|
||||||
|
|
||||||
MaxLineLength = 512, ///< Maximum length of a line of console input.
|
MaxLineLength = 512, ///< Maximum length of a line of console input.
|
||||||
MaxDataTypes = 256 ///< Maximum number of registered data types.
|
MaxDataTypes = 256 ///< Maximum number of registered data types.
|
||||||
|
|
@ -552,10 +554,10 @@ namespace Con
|
||||||
/// @param usage Documentation string.
|
/// @param usage Documentation string.
|
||||||
///
|
///
|
||||||
/// @see ConsoleDynamicTypes
|
/// @see ConsoleDynamicTypes
|
||||||
void addVariable( const char *name,
|
void addVariable(const char *name,
|
||||||
S32 type,
|
S32 type,
|
||||||
void *pointer,
|
void *pointer,
|
||||||
const char* usage = NULL );
|
const char* usage = NULL);
|
||||||
|
|
||||||
/// Add a console constant that references the value of a constant in C++ code.
|
/// Add a console constant that references the value of a constant in C++ code.
|
||||||
///
|
///
|
||||||
|
|
@ -565,10 +567,10 @@ namespace Con
|
||||||
/// @param usage Documentation string.
|
/// @param usage Documentation string.
|
||||||
///
|
///
|
||||||
/// @see ConsoleDynamicTypes
|
/// @see ConsoleDynamicTypes
|
||||||
void addConstant( const char *name,
|
void addConstant(const char *name,
|
||||||
S32 type,
|
S32 type,
|
||||||
const void *pointer,
|
const void *pointer,
|
||||||
const char* usage = NULL );
|
const char* usage = NULL);
|
||||||
|
|
||||||
/// Remove a console variable.
|
/// Remove a console variable.
|
||||||
///
|
///
|
||||||
|
|
@ -582,14 +584,14 @@ namespace Con
|
||||||
/// @param name An existing global console variable name.
|
/// @param name An existing global console variable name.
|
||||||
/// @param callback The notification delegate function.
|
/// @param callback The notification delegate function.
|
||||||
///
|
///
|
||||||
void addVariableNotify( const char *name, const NotifyDelegate &callback );
|
void addVariableNotify(const char *name, const NotifyDelegate &callback);
|
||||||
|
|
||||||
/// Remove an existing variable assignment notification callback.
|
/// Remove an existing variable assignment notification callback.
|
||||||
///
|
///
|
||||||
/// @param name An existing global console variable name.
|
/// @param name An existing global console variable name.
|
||||||
/// @param callback The notification delegate function.
|
/// @param callback The notification delegate function.
|
||||||
///
|
///
|
||||||
void removeVariableNotify( const char *name, const NotifyDelegate &callback );
|
void removeVariableNotify(const char *name, const NotifyDelegate &callback);
|
||||||
|
|
||||||
/// Assign a string value to a locally scoped console variable
|
/// Assign a string value to a locally scoped console variable
|
||||||
///
|
///
|
||||||
|
|
@ -628,31 +630,31 @@ namespace Con
|
||||||
const char* getObjectField(const char* name);
|
const char* getObjectField(const char* name);
|
||||||
|
|
||||||
/// Same as setVariable(), but for bools.
|
/// Same as setVariable(), but for bools.
|
||||||
void setBoolVariable (const char* name,bool var);
|
void setBoolVariable(const char* name, bool var);
|
||||||
|
|
||||||
/// Same as getVariable(), but for bools.
|
/// Same as getVariable(), but for bools.
|
||||||
///
|
///
|
||||||
/// @param name Name of the variable.
|
/// @param name Name of the variable.
|
||||||
/// @param def Default value to supply if no matching variable is found.
|
/// @param def Default value to supply if no matching variable is found.
|
||||||
bool getBoolVariable (const char* name,bool def = false);
|
bool getBoolVariable(const char* name, bool def = false);
|
||||||
|
|
||||||
/// Same as setVariable(), but for ints.
|
/// Same as setVariable(), but for ints.
|
||||||
void setIntVariable (const char* name,S32 var);
|
void setIntVariable(const char* name, S32 var);
|
||||||
|
|
||||||
/// Same as getVariable(), but for ints.
|
/// Same as getVariable(), but for ints.
|
||||||
///
|
///
|
||||||
/// @param name Name of the variable.
|
/// @param name Name of the variable.
|
||||||
/// @param def Default value to supply if no matching variable is found.
|
/// @param def Default value to supply if no matching variable is found.
|
||||||
S32 getIntVariable (const char* name,S32 def = 0);
|
S32 getIntVariable(const char* name, S32 def = 0);
|
||||||
|
|
||||||
/// Same as setVariable(), but for floats.
|
/// Same as setVariable(), but for floats.
|
||||||
void setFloatVariable(const char* name,F32 var);
|
void setFloatVariable(const char* name, F32 var);
|
||||||
|
|
||||||
/// Same as getVariable(), but for floats.
|
/// Same as getVariable(), but for floats.
|
||||||
///
|
///
|
||||||
/// @param name Name of the variable.
|
/// @param name Name of the variable.
|
||||||
/// @param def Default value to supply if no matching variable is found.
|
/// @param def Default value to supply if no matching variable is found.
|
||||||
F32 getFloatVariable(const char* name,F32 def = .0f);
|
F32 getFloatVariable(const char* name, F32 def = .0f);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
@ -668,52 +670,52 @@ namespace Con
|
||||||
/// @param maxArgs Maximum number of arguments this function accepts
|
/// @param maxArgs Maximum number of arguments this function accepts
|
||||||
/// @param toolOnly Wether this is a TORQUE_TOOLS only function.
|
/// @param toolOnly Wether this is a TORQUE_TOOLS only function.
|
||||||
/// @param header The extended function header.
|
/// @param header The extended function header.
|
||||||
void addCommand( const char* name, StringCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
void addCommand(const char* name, StringCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
void addCommand( const char* name, IntCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char* name, IntCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand( const char* name, FloatCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char* name, FloatCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand( const char* name, VoidCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char* name, VoidCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand( const char* name, BoolCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char* name, BoolCallback cb, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @name Namespace Function Registration
|
/// @name Namespace Function Registration
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
/// Register a C++ function with the console making it callable
|
/// Register a C++ function with the console making it callable
|
||||||
/// as a method of the given namespace from the scripting engine.
|
/// as a method of the given namespace from the scripting engine.
|
||||||
///
|
///
|
||||||
/// @param nameSpace Name of the namespace to associate the new function with; this is usually the name of a class.
|
/// @param nameSpace Name of the namespace to associate the new function with; this is usually the name of a class.
|
||||||
/// @param name Name of the new function.
|
/// @param name Name of the new function.
|
||||||
/// @param cb Pointer to the function implementing the scripting call; a console callback function returning a specific type value.
|
/// @param cb Pointer to the function implementing the scripting call; a console callback function returning a specific type value.
|
||||||
/// @param usage Documentation for this function. @ref console_autodoc
|
/// @param usage Documentation for this function. @ref console_autodoc
|
||||||
/// @param minArgs Minimum number of arguments this function accepts
|
/// @param minArgs Minimum number of arguments this function accepts
|
||||||
/// @param maxArgs Maximum number of arguments this function accepts
|
/// @param maxArgs Maximum number of arguments this function accepts
|
||||||
/// @param toolOnly Wether this is a TORQUE_TOOLS only function.
|
/// @param toolOnly Wether this is a TORQUE_TOOLS only function.
|
||||||
/// @param header The extended function header.
|
/// @param header The extended function header.
|
||||||
void addCommand(const char *nameSpace, const char *name,StringCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
void addCommand(const char *nameSpace, const char *name, StringCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
void addCommand(const char *nameSpace, const char *name,IntCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char *nameSpace, const char *name, IntCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand(const char *nameSpace, const char *name,FloatCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char *nameSpace, const char *name, FloatCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand(const char *nameSpace, const char *name,VoidCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char *nameSpace, const char *name, VoidCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
void addCommand(const char *nameSpace, const char *name,BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL ); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
void addCommand(const char *nameSpace, const char *name, BoolCallback cb, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL); ///< @copydoc addCommand( const char*, const char *, StringCallback, const char *, S32, S32, bool, ConsoleFunctionHeader* )
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @name Special Purpose Registration
|
/// @name Special Purpose Registration
|
||||||
///
|
///
|
||||||
/// These are special-purpose functions that exist to allow commands to be grouped, so
|
/// These are special-purpose functions that exist to allow commands to be grouped, so
|
||||||
/// that when we generate console docs, they can be more meaningfully presented.
|
/// that when we generate console docs, they can be more meaningfully presented.
|
||||||
///
|
///
|
||||||
/// @ref console_autodoc "Click here for more information about console docs and grouping."
|
/// @ref console_autodoc "Click here for more information about console docs and grouping."
|
||||||
///
|
///
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
void markCommandGroup (const char * nsName, const char *name, const char* usage=NULL);
|
void markCommandGroup(const char * nsName, const char *name, const char* usage = NULL);
|
||||||
void beginCommandGroup(const char * nsName, const char *name, const char* usage);
|
void beginCommandGroup(const char * nsName, const char *name, const char* usage);
|
||||||
void endCommandGroup (const char * nsName, const char *name);
|
void endCommandGroup(const char * nsName, const char *name);
|
||||||
|
|
||||||
void noteScriptCallback( const char *className, const char *funcName, const char *usage, ConsoleFunctionHeader* header = NULL );
|
void noteScriptCallback(const char *className, const char *funcName, const char *usage, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
@ -841,15 +843,15 @@ namespace Con
|
||||||
///
|
///
|
||||||
char* getReturnBuffer(U32 bufferSize);
|
char* getReturnBuffer(U32 bufferSize);
|
||||||
char* getReturnBuffer(const char *stringToCopy);
|
char* getReturnBuffer(const char *stringToCopy);
|
||||||
char* getReturnBuffer( const String& str );
|
char* getReturnBuffer(const String& str);
|
||||||
char* getReturnBuffer( const StringBuilder& str );
|
char* getReturnBuffer(const StringBuilder& str);
|
||||||
|
|
||||||
char* getArgBuffer(U32 bufferSize);
|
char* getArgBuffer(U32 bufferSize);
|
||||||
char* getFloatArg(F64 arg);
|
char* getFloatArg(F64 arg);
|
||||||
char* getIntArg (S32 arg);
|
char* getIntArg(S32 arg);
|
||||||
char* getBoolArg(bool arg);
|
char* getBoolArg(bool arg);
|
||||||
char* getStringArg( const char* arg );
|
char* getStringArg(const char* arg);
|
||||||
char* getStringArg( const String& arg );
|
char* getStringArg(const String& arg);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// @name Namespaces
|
/// @name Namespaces
|
||||||
|
|
@ -877,7 +879,7 @@ namespace Con
|
||||||
/// @name Instant Group
|
/// @name Instant Group
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
void pushInstantGroup( String name = String() );
|
void pushInstantGroup(String name = String());
|
||||||
void popInstantGroup();
|
void popInstantGroup();
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
@ -915,7 +917,7 @@ namespace Con
|
||||||
template<typename R, typename ...ArgTs>
|
template<typename R, typename ...ArgTs>
|
||||||
ConsoleValueRef executef(R r, ArgTs ...argTs)
|
ConsoleValueRef executef(R r, ArgTs ...argTs)
|
||||||
{
|
{
|
||||||
_EngineConsoleExecCallbackHelper<R> callback( r );
|
_EngineConsoleExecCallbackHelper<R> callback(r);
|
||||||
return callback.template call<ConsoleValueRef>(argTs...);
|
return callback.template call<ConsoleValueRef>(argTs...);
|
||||||
}
|
}
|
||||||
/// }
|
/// }
|
||||||
|
|
@ -945,11 +947,11 @@ struct ConsoleFunctionHeader
|
||||||
const char* returnString,
|
const char* returnString,
|
||||||
const char* argString,
|
const char* argString,
|
||||||
const char* defaultArgString,
|
const char* defaultArgString,
|
||||||
bool isStatic = false )
|
bool isStatic = false)
|
||||||
: mReturnString( returnString ),
|
: mReturnString(returnString),
|
||||||
mArgString( argString ),
|
mArgString(argString),
|
||||||
mDefaultArgString( defaultArgString ),
|
mDefaultArgString(defaultArgString),
|
||||||
mIsStatic( isStatic ) {}
|
mIsStatic(isStatic) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -980,9 +982,9 @@ public:
|
||||||
/// @deprecated Unused.
|
/// @deprecated Unused.
|
||||||
bool callback; ///< Is this a callback into script?
|
bool callback; ///< Is this a callback into script?
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
/// Minimum number of arguments expected by the function.
|
/// Minimum number of arguments expected by the function.
|
||||||
S32 mina;
|
S32 mina;
|
||||||
|
|
||||||
/// Maximum number of arguments accepted by the funtion. Zero for varargs.
|
/// Maximum number of arguments accepted by the funtion. Zero for varargs.
|
||||||
|
|
@ -1067,7 +1069,7 @@ public:
|
||||||
ConsoleConstructor *next;
|
ConsoleConstructor *next;
|
||||||
static ConsoleConstructor *first;
|
static ConsoleConstructor *first;
|
||||||
|
|
||||||
void init( const char* cName, const char* fName, const char *usg, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
void init(const char* cName, const char* fName, const char *usg, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
static void setup();
|
static void setup();
|
||||||
|
|
||||||
|
|
@ -1079,11 +1081,11 @@ public:
|
||||||
/// @name Basic Console Constructors
|
/// @name Basic Console Constructors
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
ConsoleConstructor( const char* className, const char* funcName, StringCallback sfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
ConsoleConstructor(const char* className, const char* funcName, StringCallback sfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
ConsoleConstructor( const char* className, const char* funcName, IntCallback ifunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
ConsoleConstructor(const char* className, const char* funcName, IntCallback ifunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
ConsoleConstructor( const char* className, const char* funcName, FloatCallback ffunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
ConsoleConstructor(const char* className, const char* funcName, FloatCallback ffunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
ConsoleConstructor( const char* className, const char* funcName, VoidCallback vfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
ConsoleConstructor(const char* className, const char* funcName, VoidCallback vfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
ConsoleConstructor( const char* className, const char* funcName, BoolCallback bfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
ConsoleConstructor(const char* className, const char* funcName, BoolCallback bfunc, const char* usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
@ -1097,10 +1099,10 @@ public:
|
||||||
///
|
///
|
||||||
/// @see Con::markCommandGroup
|
/// @see Con::markCommandGroup
|
||||||
/// @ref console_autodoc
|
/// @ref console_autodoc
|
||||||
ConsoleConstructor( const char *className, const char *groupName, const char* usage );
|
ConsoleConstructor(const char *className, const char *groupName, const char* usage);
|
||||||
|
|
||||||
/// Indicates a callback declared with the DECLARE_SCRIPT_CALLBACK macro and friends.
|
/// Indicates a callback declared with the DECLARE_SCRIPT_CALLBACK macro and friends.
|
||||||
ConsoleConstructor( const char *className, const char *callbackName, const char *usage, ConsoleFunctionHeader* header );
|
ConsoleConstructor(const char *className, const char *callbackName, const char *usage, ConsoleFunctionHeader* header);
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
};
|
};
|
||||||
|
|
@ -1126,11 +1128,11 @@ struct ConsoleDocFragment
|
||||||
/// First fragment in the global link chain.
|
/// First fragment in the global link chain.
|
||||||
static ConsoleDocFragment* smFirst;
|
static ConsoleDocFragment* smFirst;
|
||||||
|
|
||||||
ConsoleDocFragment( const char* text, const char* inClass = NULL, const char* definition = NULL )
|
ConsoleDocFragment(const char* text, const char* inClass = NULL, const char* definition = NULL)
|
||||||
: mClass( inClass ),
|
: mClass(inClass),
|
||||||
mDefinition( definition ),
|
mDefinition(definition),
|
||||||
mText( text ),
|
mText(text),
|
||||||
mNext( smFirst )
|
mNext(smFirst)
|
||||||
{
|
{
|
||||||
smFirst = this;
|
smFirst = this;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -24,22 +24,21 @@
|
||||||
#define _CONSOLEINTERNAL_H_
|
#define _CONSOLEINTERNAL_H_
|
||||||
|
|
||||||
#ifndef _STRINGFUNCTIONS_H_
|
#ifndef _STRINGFUNCTIONS_H_
|
||||||
#include "core/strings/stringFunctions.h"
|
#include "core/strings/stringFunctions.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _STRINGTABLE_H_
|
#ifndef _STRINGTABLE_H_
|
||||||
#include "core/stringTable.h"
|
#include "core/stringTable.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _CONSOLETYPES_H
|
#ifndef _CONSOLETYPES_H
|
||||||
#include "console/consoleTypes.h"
|
#include "console/consoleTypes.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _CONSOLEOBJECT_H_
|
#ifndef _CONSOLEOBJECT_H_
|
||||||
#include "console/simObject.h"
|
#include "console/simObject.h"
|
||||||
#endif
|
#endif
|
||||||
#ifndef _DATACHUNKER_H_
|
#ifndef _DATACHUNKER_H_
|
||||||
#include "core/dataChunker.h"
|
#include "core/dataChunker.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/// @ingroup console_system Console System
|
/// @ingroup console_system Console System
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
|
@ -55,222 +54,222 @@ class AbstractClassRep;
|
||||||
/// Namespaces are used for dispatching calls in the console system.
|
/// Namespaces are used for dispatching calls in the console system.
|
||||||
class Namespace
|
class Namespace
|
||||||
{
|
{
|
||||||
enum {
|
enum {
|
||||||
MaxActivePackages = 512,
|
MaxActivePackages = 512,
|
||||||
|
};
|
||||||
|
|
||||||
|
static U32 mNumActivePackages;
|
||||||
|
static U32 mOldNumActivePackages;
|
||||||
|
static StringTableEntry mActivePackages[MaxActivePackages];
|
||||||
|
|
||||||
|
public:
|
||||||
|
StringTableEntry mName;
|
||||||
|
StringTableEntry mPackage;
|
||||||
|
|
||||||
|
Namespace *mParent;
|
||||||
|
Namespace *mNext;
|
||||||
|
AbstractClassRep *mClassRep;
|
||||||
|
U32 mRefCountToParent;
|
||||||
|
|
||||||
|
const char* mUsage;
|
||||||
|
|
||||||
|
/// Script defined usage strings need to be cleaned up. This
|
||||||
|
/// field indicates whether or not the usage was set from script.
|
||||||
|
bool mCleanUpUsage;
|
||||||
|
|
||||||
|
/// A function entry in the namespace.
|
||||||
|
struct Entry
|
||||||
|
{
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
ScriptCallbackType = -3,
|
||||||
|
GroupMarker = -2,
|
||||||
|
InvalidFunctionType = -1,
|
||||||
|
ConsoleFunctionType,
|
||||||
|
StringCallbackType,
|
||||||
|
IntCallbackType,
|
||||||
|
FloatCallbackType,
|
||||||
|
VoidCallbackType,
|
||||||
|
BoolCallbackType
|
||||||
};
|
};
|
||||||
|
|
||||||
static U32 mNumActivePackages;
|
/// Link back to the namespace to which the entry belongs.
|
||||||
static U32 mOldNumActivePackages;
|
Namespace* mNamespace;
|
||||||
static StringTableEntry mActivePackages[MaxActivePackages];
|
|
||||||
|
|
||||||
public:
|
/// Next function entry in the hashtable link chain of the namespace.
|
||||||
StringTableEntry mName;
|
Entry* mNext;
|
||||||
|
|
||||||
|
/// Name of this function.
|
||||||
|
StringTableEntry mFunctionName;
|
||||||
|
|
||||||
|
///
|
||||||
|
S32 mType;
|
||||||
|
|
||||||
|
/// Min number of arguments expected by this function.
|
||||||
|
S32 mMinArgs;
|
||||||
|
|
||||||
|
/// Max number of arguments expected by this function. If zero,
|
||||||
|
/// function takes an arbitrary number of arguments.
|
||||||
|
S32 mMaxArgs;
|
||||||
|
|
||||||
|
/// Name of the package to which this function belongs.
|
||||||
StringTableEntry mPackage;
|
StringTableEntry mPackage;
|
||||||
|
|
||||||
Namespace *mParent;
|
/// Whether this function is included only in TORQUE_TOOLS builds.
|
||||||
Namespace *mNext;
|
bool mToolOnly;
|
||||||
AbstractClassRep *mClassRep;
|
|
||||||
U32 mRefCountToParent;
|
|
||||||
|
|
||||||
|
/// Usage string for documentation.
|
||||||
const char* mUsage;
|
const char* mUsage;
|
||||||
|
|
||||||
/// Script defined usage strings need to be cleaned up. This
|
/// Extended console function information.
|
||||||
/// field indicates whether or not the usage was set from script.
|
ConsoleFunctionHeader* mHeader;
|
||||||
bool mCleanUpUsage;
|
|
||||||
|
|
||||||
/// A function entry in the namespace.
|
/// The compiled script code if this is a script function.
|
||||||
struct Entry
|
CodeBlock* mCode;
|
||||||
{
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
ScriptCallbackType = -3,
|
|
||||||
GroupMarker = -2,
|
|
||||||
InvalidFunctionType = -1,
|
|
||||||
ConsoleFunctionType,
|
|
||||||
StringCallbackType,
|
|
||||||
IntCallbackType,
|
|
||||||
FloatCallbackType,
|
|
||||||
VoidCallbackType,
|
|
||||||
BoolCallbackType
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Link back to the namespace to which the entry belongs.
|
/// The offset in the compiled script code at which this function begins.
|
||||||
Namespace* mNamespace;
|
U32 mFunctionOffset;
|
||||||
|
|
||||||
/// Next function entry in the hashtable link chain of the namespace.
|
/// If it's a script function, this is the line of the declaration in code.
|
||||||
Entry* mNext;
|
/// @note 0 for functions read from legacy DSOs that have no line number information.
|
||||||
|
U32 mFunctionLineNumber;
|
||||||
|
|
||||||
/// Name of this function.
|
union CallbackUnion {
|
||||||
StringTableEntry mFunctionName;
|
StringCallback mStringCallbackFunc;
|
||||||
|
IntCallback mIntCallbackFunc;
|
||||||
|
VoidCallback mVoidCallbackFunc;
|
||||||
|
FloatCallback mFloatCallbackFunc;
|
||||||
|
BoolCallback mBoolCallbackFunc;
|
||||||
|
const char *mGroupName;
|
||||||
|
const char *mCallbackName;
|
||||||
|
} cb;
|
||||||
|
|
||||||
///
|
Entry();
|
||||||
S32 mType;
|
|
||||||
|
|
||||||
/// Min number of arguments expected by this function.
|
///
|
||||||
S32 mMinArgs;
|
void clear();
|
||||||
|
|
||||||
/// Max number of arguments expected by this function. If zero,
|
///
|
||||||
/// function takes an arbitrary number of arguments.
|
ConsoleValueRef execute(S32 argc, ConsoleValueRef* argv, ExprEvalState* state);
|
||||||
S32 mMaxArgs;
|
|
||||||
|
|
||||||
/// Name of the package to which this function belongs.
|
/// Return a one-line documentation text string for the function.
|
||||||
StringTableEntry mPackage;
|
String getBriefDescription(String* outRemainingDocText = NULL) const;
|
||||||
|
|
||||||
/// Whether this function is included only in TORQUE_TOOLS builds.
|
/// Get the auto-doc string for this function. This string does not included prototype information.
|
||||||
bool mToolOnly;
|
String getDocString() const;
|
||||||
|
|
||||||
/// Usage string for documentation.
|
/// Return a string describing the arguments the function takes including default argument values.
|
||||||
const char* mUsage;
|
String getArgumentsString() const;
|
||||||
|
|
||||||
/// Extended console function information.
|
/// Return a full prototype string for the function including return type, function name,
|
||||||
ConsoleFunctionHeader* mHeader;
|
/// and arguments.
|
||||||
|
String getPrototypeString() const;
|
||||||
|
};
|
||||||
|
|
||||||
/// The compiled script code if this is a script function.
|
Entry* mEntryList;
|
||||||
CodeBlock* mCode;
|
|
||||||
|
|
||||||
/// The offset in the compiled script code at which this function begins.
|
Entry** mHashTable;
|
||||||
U32 mFunctionOffset;
|
|
||||||
|
|
||||||
/// If it's a script function, this is the line of the declaration in code.
|
U32 mHashSize;
|
||||||
/// @note 0 for functions read from legacy DSOs that have no line number information.
|
U32 mHashSequence; ///< @note The hash sequence is used by the autodoc console facility
|
||||||
U32 mFunctionLineNumber;
|
/// as a means of testing reference state.
|
||||||
|
|
||||||
union CallbackUnion {
|
Namespace();
|
||||||
StringCallback mStringCallbackFunc;
|
~Namespace();
|
||||||
IntCallback mIntCallbackFunc;
|
|
||||||
VoidCallback mVoidCallbackFunc;
|
|
||||||
FloatCallback mFloatCallbackFunc;
|
|
||||||
BoolCallback mBoolCallbackFunc;
|
|
||||||
const char *mGroupName;
|
|
||||||
const char *mCallbackName;
|
|
||||||
} cb;
|
|
||||||
|
|
||||||
Entry();
|
void addFunction(StringTableEntry name, CodeBlock* cb, U32 functionOffset, const char* usage = NULL, U32 lineNumber = 0);
|
||||||
|
void addCommand(StringTableEntry name, StringCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
void addCommand(StringTableEntry name, IntCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
void addCommand(StringTableEntry name, FloatCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
void addCommand(StringTableEntry name, VoidCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
void addCommand(StringTableEntry name, BoolCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL);
|
||||||
|
|
||||||
///
|
void addScriptCallback(const char *funcName, const char *usage, ConsoleFunctionHeader* header = NULL);
|
||||||
void clear();
|
|
||||||
|
|
||||||
///
|
void markGroup(const char* name, const char* usage);
|
||||||
ConsoleValueRef execute( S32 argc, ConsoleValueRef* argv, ExprEvalState* state );
|
char * lastUsage;
|
||||||
|
|
||||||
/// Return a one-line documentation text string for the function.
|
/// Returns true if this namespace represents an engine defined
|
||||||
String getBriefDescription( String* outRemainingDocText = NULL ) const;
|
/// class and is not just a script defined class namespace.
|
||||||
|
bool isClass() const { return mClassRep && mClassRep->getNameSpace() == this; }
|
||||||
|
|
||||||
/// Get the auto-doc string for this function. This string does not included prototype information.
|
void getEntryList(VectorPtr<Entry *> *);
|
||||||
String getDocString() const;
|
|
||||||
|
|
||||||
/// Return a string describing the arguments the function takes including default argument values.
|
/// Return the name of this namespace.
|
||||||
String getArgumentsString() const;
|
StringTableEntry getName() const { return mName; }
|
||||||
|
|
||||||
/// Return a full prototype string for the function including return type, function name,
|
/// Return the superordinate namespace to this namespace. Symbols are inherited from
|
||||||
/// and arguments.
|
/// this namespace.
|
||||||
String getPrototypeString() const;
|
Namespace* getParent() const { return mParent; }
|
||||||
};
|
|
||||||
|
|
||||||
Entry* mEntryList;
|
/// Return the topmost package in the parent hierarchy of this namespace
|
||||||
|
/// that still refers to the same namespace. If packages are active and
|
||||||
|
/// adding to this namespace, then they will be linked in-between the namespace
|
||||||
|
/// they are adding to and its real parent namespace.
|
||||||
|
Namespace* getPackageRoot()
|
||||||
|
{
|
||||||
|
Namespace* walk = this;
|
||||||
|
while (walk->mParent && walk->mParent->mName == mName)
|
||||||
|
walk = walk->mParent;
|
||||||
|
|
||||||
Entry** mHashTable;
|
return walk;
|
||||||
|
}
|
||||||
|
|
||||||
U32 mHashSize;
|
/// Return the package in which this namespace is defined.
|
||||||
U32 mHashSequence; ///< @note The hash sequence is used by the autodoc console facility
|
StringTableEntry getPackage() const { return mPackage; }
|
||||||
/// as a means of testing reference state.
|
|
||||||
|
|
||||||
Namespace();
|
/// Increase the count on the reference that this namespace
|
||||||
~Namespace();
|
/// holds to its parent.
|
||||||
|
/// @note Must not be called on namespaces coming from packages.
|
||||||
|
void incRefCountToParent()
|
||||||
|
{
|
||||||
|
AssertFatal(mPackage == NULL, "Namespace::incRefCountToParent - Must not be called on a namespace coming from a package!");
|
||||||
|
mRefCountToParent++;
|
||||||
|
}
|
||||||
|
|
||||||
void addFunction( StringTableEntry name, CodeBlock* cb, U32 functionOffset, const char* usage = NULL, U32 lineNumber = 0 );
|
/// Decrease the count on the reference that this namespace
|
||||||
void addCommand( StringTableEntry name, StringCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
/// holds to its parent.
|
||||||
void addCommand( StringTableEntry name, IntCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
/// @note Must not be called on namespaces coming from packages.
|
||||||
void addCommand( StringTableEntry name, FloatCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
void decRefCountToParent()
|
||||||
void addCommand( StringTableEntry name, VoidCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
{
|
||||||
void addCommand( StringTableEntry name, BoolCallback, const char *usage, S32 minArgs, S32 maxArgs, bool toolOnly = false, ConsoleFunctionHeader* header = NULL );
|
unlinkClass(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void addScriptCallback( const char *funcName, const char *usage, ConsoleFunctionHeader* header = NULL );
|
Entry *lookup(StringTableEntry name);
|
||||||
|
Entry *lookupRecursive(StringTableEntry name);
|
||||||
|
Entry *createLocalEntry(StringTableEntry name);
|
||||||
|
void buildHashTable();
|
||||||
|
void clearEntries();
|
||||||
|
bool classLinkTo(Namespace *parent);
|
||||||
|
bool unlinkClass(Namespace *parent);
|
||||||
|
void getUniqueEntryLists(Namespace *other, VectorPtr<Entry *> *outThisList, VectorPtr<Entry *> *outOtherList);
|
||||||
|
|
||||||
void markGroup(const char* name, const char* usage);
|
const char *tabComplete(const char *prevText, S32 baseLen, bool fForward);
|
||||||
char * lastUsage;
|
|
||||||
|
|
||||||
/// Returns true if this namespace represents an engine defined
|
static U32 mCacheSequence;
|
||||||
/// class and is not just a script defined class namespace.
|
static DataChunker mCacheAllocator;
|
||||||
bool isClass() const { return mClassRep && mClassRep->getNameSpace() == this; }
|
static DataChunker mAllocator;
|
||||||
|
static void trashCache();
|
||||||
|
static Namespace *mNamespaceList;
|
||||||
|
static Namespace *mGlobalNamespace;
|
||||||
|
|
||||||
void getEntryList(VectorPtr<Entry *> *);
|
static void init();
|
||||||
|
static void shutdown();
|
||||||
|
static Namespace *global();
|
||||||
|
|
||||||
/// Return the name of this namespace.
|
static Namespace *find(StringTableEntry name, StringTableEntry package = NULL);
|
||||||
StringTableEntry getName() const { return mName; }
|
|
||||||
|
|
||||||
/// Return the superordinate namespace to this namespace. Symbols are inherited from
|
static void activatePackage(StringTableEntry name);
|
||||||
/// this namespace.
|
static void deactivatePackage(StringTableEntry name);
|
||||||
Namespace* getParent() const { return mParent; }
|
static void deactivatePackageStack(StringTableEntry name);
|
||||||
|
static void dumpClasses(bool dumpScript = true, bool dumpEngine = true);
|
||||||
/// Return the topmost package in the parent hierarchy of this namespace
|
static void dumpFunctions(bool dumpScript = true, bool dumpEngine = true);
|
||||||
/// that still refers to the same namespace. If packages are active and
|
static void printNamespaceEntries(Namespace * g, bool dumpScript = true, bool dumpEngine = true);
|
||||||
/// adding to this namespace, then they will be linked in-between the namespace
|
static void unlinkPackages();
|
||||||
/// they are adding to and its real parent namespace.
|
static void relinkPackages();
|
||||||
Namespace* getPackageRoot()
|
static bool isPackage(StringTableEntry name);
|
||||||
{
|
static U32 getActivePackagesCount();
|
||||||
Namespace* walk = this;
|
static StringTableEntry getActivePackage(U32 index);
|
||||||
while( walk->mParent && walk->mParent->mName == mName )
|
|
||||||
walk = walk->mParent;
|
|
||||||
|
|
||||||
return walk;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Return the package in which this namespace is defined.
|
|
||||||
StringTableEntry getPackage() const { return mPackage; }
|
|
||||||
|
|
||||||
/// Increase the count on the reference that this namespace
|
|
||||||
/// holds to its parent.
|
|
||||||
/// @note Must not be called on namespaces coming from packages.
|
|
||||||
void incRefCountToParent()
|
|
||||||
{
|
|
||||||
AssertFatal( mPackage == NULL, "Namespace::incRefCountToParent - Must not be called on a namespace coming from a package!" );
|
|
||||||
mRefCountToParent ++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Decrease the count on the reference that this namespace
|
|
||||||
/// holds to its parent.
|
|
||||||
/// @note Must not be called on namespaces coming from packages.
|
|
||||||
void decRefCountToParent()
|
|
||||||
{
|
|
||||||
unlinkClass( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
Entry *lookup(StringTableEntry name);
|
|
||||||
Entry *lookupRecursive(StringTableEntry name);
|
|
||||||
Entry *createLocalEntry(StringTableEntry name);
|
|
||||||
void buildHashTable();
|
|
||||||
void clearEntries();
|
|
||||||
bool classLinkTo(Namespace *parent);
|
|
||||||
bool unlinkClass(Namespace *parent);
|
|
||||||
void getUniqueEntryLists( Namespace *other, VectorPtr<Entry *> *outThisList, VectorPtr<Entry *> *outOtherList );
|
|
||||||
|
|
||||||
const char *tabComplete(const char *prevText, S32 baseLen, bool fForward);
|
|
||||||
|
|
||||||
static U32 mCacheSequence;
|
|
||||||
static DataChunker mCacheAllocator;
|
|
||||||
static DataChunker mAllocator;
|
|
||||||
static void trashCache();
|
|
||||||
static Namespace *mNamespaceList;
|
|
||||||
static Namespace *mGlobalNamespace;
|
|
||||||
|
|
||||||
static void init();
|
|
||||||
static void shutdown();
|
|
||||||
static Namespace *global();
|
|
||||||
|
|
||||||
static Namespace *find(StringTableEntry name, StringTableEntry package=NULL);
|
|
||||||
|
|
||||||
static void activatePackage(StringTableEntry name);
|
|
||||||
static void deactivatePackage(StringTableEntry name);
|
|
||||||
static void deactivatePackageStack(StringTableEntry name);
|
|
||||||
static void dumpClasses( bool dumpScript = true, bool dumpEngine = true );
|
|
||||||
static void dumpFunctions( bool dumpScript = true, bool dumpEngine = true );
|
|
||||||
static void printNamespaceEntries(Namespace * g, bool dumpScript = true, bool dumpEngine = true);
|
|
||||||
static void unlinkPackages();
|
|
||||||
static void relinkPackages();
|
|
||||||
static bool isPackage(StringTableEntry name);
|
|
||||||
static U32 getActivePackagesCount();
|
|
||||||
static StringTableEntry getActivePackage(U32 index);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
typedef VectorPtr<Namespace::Entry *>::iterator NamespaceEntryListIterator;
|
||||||
|
|
@ -318,7 +317,7 @@ public:
|
||||||
void reset() {
|
void reset() {
|
||||||
name = NULL;
|
name = NULL;
|
||||||
value.cleanup();
|
value.cleanup();
|
||||||
if ( notify )
|
if (notify)
|
||||||
delete notify;
|
delete notify;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -339,39 +338,39 @@ public:
|
||||||
|
|
||||||
void setIntValue(U32 val)
|
void setIntValue(U32 val)
|
||||||
{
|
{
|
||||||
if( mIsConstant )
|
if (mIsConstant)
|
||||||
{
|
{
|
||||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
Con::errorf("Cannot assign value to constant '%s'.", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value.setIntValue(val);
|
value.setIntValue(val);
|
||||||
|
|
||||||
// Fire off the notification if we have one.
|
// Fire off the notification if we have one.
|
||||||
if ( notify )
|
if (notify)
|
||||||
notify->trigger();
|
notify->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setFloatValue(F32 val)
|
void setFloatValue(F32 val)
|
||||||
{
|
{
|
||||||
if( mIsConstant )
|
if (mIsConstant)
|
||||||
{
|
{
|
||||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
Con::errorf("Cannot assign value to constant '%s'.", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
value.setFloatValue(val);
|
value.setFloatValue(val);
|
||||||
|
|
||||||
// Fire off the notification if we have one.
|
// Fire off the notification if we have one.
|
||||||
if ( notify )
|
if (notify)
|
||||||
notify->trigger();
|
notify->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStringStackPtrValue(StringStackPtr newValue)
|
void setStringStackPtrValue(StringStackPtr newValue)
|
||||||
{
|
{
|
||||||
if( mIsConstant )
|
if (mIsConstant)
|
||||||
{
|
{
|
||||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
Con::errorf("Cannot assign value to constant '%s'.", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -379,15 +378,15 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Fire off the notification if we have one.
|
// Fire off the notification if we have one.
|
||||||
if ( notify )
|
if (notify)
|
||||||
notify->trigger();
|
notify->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
void setStringValue(const char *newValue)
|
void setStringValue(const char *newValue)
|
||||||
{
|
{
|
||||||
if( mIsConstant )
|
if (mIsConstant)
|
||||||
{
|
{
|
||||||
Con::errorf( "Cannot assign value to constant '%s'.", name );
|
Con::errorf("Cannot assign value to constant '%s'.", name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -395,7 +394,7 @@ public:
|
||||||
|
|
||||||
|
|
||||||
// Fire off the notification if we have one.
|
// Fire off the notification if we have one.
|
||||||
if ( notify )
|
if (notify)
|
||||||
notify->trigger();
|
notify->trigger();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -408,8 +407,8 @@ public:
|
||||||
Entry **data;
|
Entry **data;
|
||||||
FreeListChunker< Entry > mChunker;
|
FreeListChunker< Entry > mChunker;
|
||||||
|
|
||||||
HashTableData( Dictionary* owner )
|
HashTableData(Dictionary* owner)
|
||||||
: owner( owner ), size( 0 ), count( 0 ), data( NULL ) {}
|
: owner(owner), size(0), count(0), data(NULL) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
HashTableData* hashTable;
|
HashTableData* hashTable;
|
||||||
|
|
@ -426,13 +425,13 @@ public:
|
||||||
|
|
||||||
Entry *lookup(StringTableEntry name);
|
Entry *lookup(StringTableEntry name);
|
||||||
Entry *add(StringTableEntry name);
|
Entry *add(StringTableEntry name);
|
||||||
void setState(ExprEvalState *state, Dictionary* ref=NULL);
|
void setState(ExprEvalState *state, Dictionary* ref = NULL);
|
||||||
void remove(Entry *);
|
void remove(Entry *);
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
void exportVariables( const char *varString, const char *fileName, bool append );
|
void exportVariables(const char *varString, const char *fileName, bool append);
|
||||||
void exportVariables( const char *varString, Vector<String> *names, Vector<String> *values );
|
void exportVariables(const char *varString, Vector<String> *names, Vector<String> *values);
|
||||||
void deleteVariables( const char *varString );
|
void deleteVariables(const char *varString);
|
||||||
|
|
||||||
void setVariable(StringTableEntry name, const char *value);
|
void setVariable(StringTableEntry name, const char *value);
|
||||||
const char *getVariable(StringTableEntry name, bool *valid = NULL);
|
const char *getVariable(StringTableEntry name, bool *valid = NULL);
|
||||||
|
|
@ -449,19 +448,19 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @see Con::addVariable
|
/// @see Con::addVariable
|
||||||
Entry* addVariable( const char *name,
|
Entry* addVariable(const char *name,
|
||||||
S32 type,
|
S32 type,
|
||||||
void *dataPtr,
|
void *dataPtr,
|
||||||
const char* usage );
|
const char* usage);
|
||||||
|
|
||||||
/// @see Con::removeVariable
|
/// @see Con::removeVariable
|
||||||
bool removeVariable(StringTableEntry name);
|
bool removeVariable(StringTableEntry name);
|
||||||
|
|
||||||
/// @see Con::addVariableNotify
|
/// @see Con::addVariableNotify
|
||||||
void addVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
void addVariableNotify(const char *name, const Con::NotifyDelegate &callback);
|
||||||
|
|
||||||
/// @see Con::removeVariableNotify
|
/// @see Con::removeVariableNotify
|
||||||
void removeVariableNotify( const char *name, const Con::NotifyDelegate &callback );
|
void removeVariableNotify(const char *name, const Con::NotifyDelegate &callback);
|
||||||
|
|
||||||
/// Return the best tab completion for prevText, with the length
|
/// Return the best tab completion for prevText, with the length
|
||||||
/// of the pre-tab string in baseLen.
|
/// of the pre-tab string in baseLen.
|
||||||
|
|
@ -528,7 +527,7 @@ public:
|
||||||
|
|
||||||
Dictionary& getCurrentFrame()
|
Dictionary& getCurrentFrame()
|
||||||
{
|
{
|
||||||
return *( stack[ mStackDepth - 1 ] );
|
return *(stack[mStackDepth - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ SimNameDictionary::~SimNameDictionary()
|
||||||
|
|
||||||
void SimNameDictionary::insert(SimObject* obj)
|
void SimNameDictionary::insert(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj || !obj->objectName)
|
if (!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SimObject* checkForDup = find(obj->objectName);
|
SimObject* checkForDup = find(obj->objectName);
|
||||||
|
|
@ -55,13 +55,13 @@ void SimNameDictionary::insert(SimObject* obj)
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
if(!hashTable)
|
if (!hashTable)
|
||||||
{
|
{
|
||||||
hashTable = new SimObject *[DefaultTableSize];
|
hashTable = new SimObject *[DefaultTableSize];
|
||||||
hashTableSize = DefaultTableSize;
|
hashTableSize = DefaultTableSize;
|
||||||
hashEntryCount = 0;
|
hashEntryCount = 0;
|
||||||
|
|
||||||
dMemset( hashTable, 0, sizeof( *hashTable ) * DefaultTableSize );
|
dMemset(hashTable, 0, sizeof(*hashTable) * DefaultTableSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
S32 idx = HashPointer(obj->objectName) % hashTableSize;
|
S32 idx = HashPointer(obj->objectName) % hashTableSize;
|
||||||
|
|
@ -71,31 +71,31 @@ void SimNameDictionary::insert(SimObject* obj)
|
||||||
|
|
||||||
// Rehash if necessary.
|
// Rehash if necessary.
|
||||||
|
|
||||||
if( hashEntryCount > hashTableSize )
|
if (hashEntryCount > hashTableSize)
|
||||||
{
|
{
|
||||||
// Allocate new table.
|
// Allocate new table.
|
||||||
|
|
||||||
U32 newHashTableSize = hashTableSize * 2 + 1;
|
U32 newHashTableSize = hashTableSize * 2 + 1;
|
||||||
SimObject** newHashTable = new SimObject *[ newHashTableSize ];
|
SimObject** newHashTable = new SimObject *[newHashTableSize];
|
||||||
dMemset( newHashTable, 0, sizeof( newHashTable[ 0 ] ) * newHashTableSize );
|
dMemset(newHashTable, 0, sizeof(newHashTable[0]) * newHashTableSize);
|
||||||
|
|
||||||
// Move entries over.
|
// Move entries over.
|
||||||
|
|
||||||
for( U32 i = 0; i < hashTableSize; ++ i )
|
for (U32 i = 0; i < hashTableSize; ++i)
|
||||||
for( SimObject* object = hashTable[ i ]; object != NULL; )
|
for (SimObject* object = hashTable[i]; object != NULL; )
|
||||||
{
|
{
|
||||||
SimObject* next = object->nextNameObject;
|
SimObject* next = object->nextNameObject;
|
||||||
|
|
||||||
idx = HashPointer( object->objectName ) % newHashTableSize;
|
idx = HashPointer(object->objectName) % newHashTableSize;
|
||||||
object->nextNameObject = newHashTable[ idx ];
|
object->nextNameObject = newHashTable[idx];
|
||||||
newHashTable[ idx ] = object;
|
newHashTable[idx] = object;
|
||||||
|
|
||||||
object = next;
|
object = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch tables.
|
// Switch tables.
|
||||||
|
|
||||||
delete [] hashTable;
|
delete[] hashTable;
|
||||||
hashTable = newHashTable;
|
hashTable = newHashTable;
|
||||||
hashTableSize = newHashTableSize;
|
hashTableSize = newHashTableSize;
|
||||||
}
|
}
|
||||||
|
|
@ -109,16 +109,16 @@ SimObject* SimNameDictionary::find(StringTableEntry name)
|
||||||
{
|
{
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
// NULL is a valid lookup - it will always return NULL
|
// NULL is a valid lookup - it will always return NULL
|
||||||
if(!hashTable)
|
if (!hashTable)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
|
|
||||||
S32 idx = HashPointer(name) % hashTableSize;
|
S32 idx = HashPointer(name) % hashTableSize;
|
||||||
SimObject *walk = hashTable[idx];
|
SimObject *walk = hashTable[idx];
|
||||||
while(walk)
|
while (walk)
|
||||||
{
|
{
|
||||||
if(walk->objectName == name)
|
if (walk->objectName == name)
|
||||||
{
|
{
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
return walk;
|
return walk;
|
||||||
|
|
@ -129,28 +129,28 @@ SimObject* SimNameDictionary::find(StringTableEntry name)
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
StringDictDef::iterator it = root.find(name);
|
StringDictDef::iterator it = root.find(name);
|
||||||
SimObject* f = (it == root.end() ? NULL : it->second);
|
SimObject* f = (it == root.end() ? NULL : it->second);
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
return f;
|
return f;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimNameDictionary::remove(SimObject* obj)
|
void SimNameDictionary::remove(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj || !obj->objectName)
|
if (!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
||||||
while(*walk)
|
while (*walk)
|
||||||
{
|
{
|
||||||
if(*walk == obj)
|
if (*walk == obj)
|
||||||
{
|
{
|
||||||
*walk = obj->nextNameObject;
|
*walk = obj->nextNameObject;
|
||||||
obj->nextNameObject = (SimObject*)-1;
|
obj->nextNameObject = nullptr;
|
||||||
hashEntryCount--;
|
hashEntryCount--;
|
||||||
|
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
|
|
@ -175,7 +175,7 @@ SimManagerNameDictionary::SimManagerNameDictionary()
|
||||||
hashTableSize = DefaultTableSize;
|
hashTableSize = DefaultTableSize;
|
||||||
hashEntryCount = 0;
|
hashEntryCount = 0;
|
||||||
|
|
||||||
dMemset( hashTable, 0, sizeof( hashTable[ 0 ] ) * hashTableSize );
|
dMemset(hashTable, 0, sizeof(hashTable[0]) * hashTableSize);
|
||||||
#endif
|
#endif
|
||||||
mutex = Mutex::createMutex();
|
mutex = Mutex::createMutex();
|
||||||
}
|
}
|
||||||
|
|
@ -190,7 +190,7 @@ SimManagerNameDictionary::~SimManagerNameDictionary()
|
||||||
|
|
||||||
void SimManagerNameDictionary::insert(SimObject* obj)
|
void SimManagerNameDictionary::insert(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj || !obj->objectName)
|
if (!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
|
|
@ -202,31 +202,31 @@ void SimManagerNameDictionary::insert(SimObject* obj)
|
||||||
|
|
||||||
// Rehash if necessary.
|
// Rehash if necessary.
|
||||||
|
|
||||||
if( hashEntryCount > hashTableSize )
|
if (hashEntryCount > hashTableSize)
|
||||||
{
|
{
|
||||||
// Allocate new table.
|
// Allocate new table.
|
||||||
|
|
||||||
U32 newHashTableSize = hashTableSize * 2 + 1;
|
U32 newHashTableSize = hashTableSize * 2 + 1;
|
||||||
SimObject** newHashTable = new SimObject *[ newHashTableSize ];
|
SimObject** newHashTable = new SimObject *[newHashTableSize];
|
||||||
dMemset( newHashTable, 0, sizeof( newHashTable[ 0 ] ) * newHashTableSize );
|
dMemset(newHashTable, 0, sizeof(newHashTable[0]) * newHashTableSize);
|
||||||
|
|
||||||
// Move entries over.
|
// Move entries over.
|
||||||
|
|
||||||
for( U32 i = 0; i < hashTableSize; ++ i )
|
for (U32 i = 0; i < hashTableSize; ++i)
|
||||||
for( SimObject* object = hashTable[ i ]; object != NULL; )
|
for (SimObject* object = hashTable[i]; object != NULL; )
|
||||||
{
|
{
|
||||||
SimObject* next = object->nextManagerNameObject;
|
SimObject* next = object->nextManagerNameObject;
|
||||||
|
|
||||||
idx = HashPointer( object->objectName ) % newHashTableSize;
|
idx = HashPointer(object->objectName) % newHashTableSize;
|
||||||
object->nextManagerNameObject = newHashTable[ idx ];
|
object->nextManagerNameObject = newHashTable[idx];
|
||||||
newHashTable[ idx ] = object;
|
newHashTable[idx] = object;
|
||||||
|
|
||||||
object = next;
|
object = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch tables.
|
// Switch tables.
|
||||||
|
|
||||||
delete [] hashTable;
|
delete[] hashTable;
|
||||||
hashTable = newHashTable;
|
hashTable = newHashTable;
|
||||||
hashTableSize = newHashTableSize;
|
hashTableSize = newHashTableSize;
|
||||||
}
|
}
|
||||||
|
|
@ -245,9 +245,9 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name)
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
S32 idx = HashPointer(name) % hashTableSize;
|
S32 idx = HashPointer(name) % hashTableSize;
|
||||||
SimObject *walk = hashTable[idx];
|
SimObject *walk = hashTable[idx];
|
||||||
while(walk)
|
while (walk)
|
||||||
{
|
{
|
||||||
if(walk->objectName == name)
|
if (walk->objectName == name)
|
||||||
{
|
{
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
return walk;
|
return walk;
|
||||||
|
|
@ -267,19 +267,19 @@ SimObject* SimManagerNameDictionary::find(StringTableEntry name)
|
||||||
|
|
||||||
void SimManagerNameDictionary::remove(SimObject* obj)
|
void SimManagerNameDictionary::remove(SimObject* obj)
|
||||||
{
|
{
|
||||||
if(!obj || !obj->objectName)
|
if (!obj || !obj->objectName)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
|
|
||||||
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
SimObject **walk = &hashTable[HashPointer(obj->objectName) % hashTableSize];
|
||||||
while(*walk)
|
while (*walk)
|
||||||
{
|
{
|
||||||
if(*walk == obj)
|
if (*walk == obj)
|
||||||
{
|
{
|
||||||
*walk = obj->nextManagerNameObject;
|
*walk = obj->nextManagerNameObject;
|
||||||
obj->nextManagerNameObject = (SimObject*)-1;
|
obj->nextManagerNameObject = nullptr;
|
||||||
hashEntryCount--;
|
hashEntryCount--;
|
||||||
|
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
|
|
@ -301,7 +301,7 @@ void SimManagerNameDictionary::remove(SimObject* obj)
|
||||||
SimIdDictionary::SimIdDictionary()
|
SimIdDictionary::SimIdDictionary()
|
||||||
{
|
{
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
dMemset( table, 0, sizeof( table[ 0 ] ) * DefaultTableSize );
|
dMemset(table, 0, sizeof(table[0]) * DefaultTableSize);
|
||||||
#endif
|
#endif
|
||||||
mutex = Mutex::createMutex();
|
mutex = Mutex::createMutex();
|
||||||
}
|
}
|
||||||
|
|
@ -322,7 +322,7 @@ void SimIdDictionary::insert(SimObject* obj)
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
S32 idx = obj->getId() & TableBitMask;
|
S32 idx = obj->getId() & TableBitMask;
|
||||||
obj->nextIdObject = table[idx];
|
obj->nextIdObject = table[idx];
|
||||||
AssertFatal( obj->nextIdObject != obj, "SimIdDictionary::insert - Creating Infinite Loop linking to self!" );
|
AssertFatal(obj->nextIdObject != obj, "SimIdDictionary::insert - Creating Infinite Loop linking to self!");
|
||||||
table[idx] = obj;
|
table[idx] = obj;
|
||||||
#else
|
#else
|
||||||
root[obj->getId()] = obj;
|
root[obj->getId()] = obj;
|
||||||
|
|
@ -336,9 +336,9 @@ SimObject* SimIdDictionary::find(S32 id)
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
S32 idx = id & TableBitMask;
|
S32 idx = id & TableBitMask;
|
||||||
SimObject *walk = table[idx];
|
SimObject *walk = table[idx];
|
||||||
while(walk)
|
while (walk)
|
||||||
{
|
{
|
||||||
if(walk->getId() == U32(id))
|
if (walk->getId() == U32(id))
|
||||||
{
|
{
|
||||||
Mutex::unlockMutex(mutex);
|
Mutex::unlockMutex(mutex);
|
||||||
return walk;
|
return walk;
|
||||||
|
|
@ -364,9 +364,9 @@ void SimIdDictionary::remove(SimObject* obj)
|
||||||
Mutex::lockMutex(mutex);
|
Mutex::lockMutex(mutex);
|
||||||
#ifndef USE_NEW_SIMDICTIONARY
|
#ifndef USE_NEW_SIMDICTIONARY
|
||||||
SimObject **walk = &table[obj->getId() & TableBitMask];
|
SimObject **walk = &table[obj->getId() & TableBitMask];
|
||||||
while(*walk && *walk != obj)
|
while (*walk && *walk != obj)
|
||||||
walk = &((*walk)->nextIdObject);
|
walk = &((*walk)->nextIdObject);
|
||||||
if(*walk)
|
if (*walk)
|
||||||
*walk = obj->nextIdObject;
|
*walk = obj->nextIdObject;
|
||||||
#else
|
#else
|
||||||
root.erase(obj->getId());
|
root.erase(obj->getId());
|
||||||
|
|
|
||||||
|
|
@ -36,20 +36,20 @@ SimFieldDictionary::Entry *SimFieldDictionary::smFreeList = NULL;
|
||||||
|
|
||||||
static Chunker<SimFieldDictionary::Entry> fieldChunker;
|
static Chunker<SimFieldDictionary::Entry> fieldChunker;
|
||||||
|
|
||||||
U32 SimFieldDictionary::getHashValue( StringTableEntry slotName )
|
U32 SimFieldDictionary::getHashValue(StringTableEntry slotName)
|
||||||
{
|
{
|
||||||
return HashPointer( slotName ) % HashTableSize;
|
return HashPointer(slotName) % HashTableSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 SimFieldDictionary::getHashValue( const String& fieldName )
|
U32 SimFieldDictionary::getHashValue(const String& fieldName)
|
||||||
{
|
{
|
||||||
return getHashValue( StringTable->insert( fieldName ) );
|
return getHashValue(StringTable->insert(fieldName));
|
||||||
}
|
}
|
||||||
|
|
||||||
SimFieldDictionary::Entry *SimFieldDictionary::addEntry( U32 bucket, StringTableEntry slotName, ConsoleBaseType* type, char* value )
|
SimFieldDictionary::Entry *SimFieldDictionary::addEntry(U32 bucket, StringTableEntry slotName, ConsoleBaseType* type, char* value)
|
||||||
{
|
{
|
||||||
Entry* ret;
|
Entry* ret;
|
||||||
if(smFreeList)
|
if (smFreeList)
|
||||||
{
|
{
|
||||||
ret = smFreeList;
|
ret = smFreeList;
|
||||||
smFreeList = ret->next;
|
smFreeList = ret->next;
|
||||||
|
|
@ -57,14 +57,14 @@ SimFieldDictionary::Entry *SimFieldDictionary::addEntry( U32 bucket, StringTable
|
||||||
else
|
else
|
||||||
ret = fieldChunker.alloc();
|
ret = fieldChunker.alloc();
|
||||||
|
|
||||||
ret->next = mHashTable[ bucket ];
|
ret->next = mHashTable[bucket];
|
||||||
ret->slotName = slotName;
|
ret->slotName = slotName;
|
||||||
ret->type = type;
|
ret->type = type;
|
||||||
ret->value = value;
|
ret->value = value;
|
||||||
|
|
||||||
mHashTable[ bucket ] = ret;
|
mHashTable[bucket] = ret;
|
||||||
mNumFields ++;
|
mNumFields++;
|
||||||
mVersion ++;
|
mVersion++;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
@ -74,37 +74,37 @@ void SimFieldDictionary::freeEntry(SimFieldDictionary::Entry *ent)
|
||||||
ent->next = smFreeList;
|
ent->next = smFreeList;
|
||||||
smFreeList = ent;
|
smFreeList = ent;
|
||||||
|
|
||||||
mNumFields --;
|
mNumFields--;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimFieldDictionary::SimFieldDictionary()
|
SimFieldDictionary::SimFieldDictionary()
|
||||||
: mNumFields( 0 ),
|
: mNumFields(0),
|
||||||
mVersion( 0 )
|
mVersion(0)
|
||||||
{
|
{
|
||||||
dMemset( mHashTable, 0, sizeof( mHashTable ) );
|
dMemset(mHashTable, 0, sizeof(mHashTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
SimFieldDictionary::~SimFieldDictionary()
|
SimFieldDictionary::~SimFieldDictionary()
|
||||||
{
|
{
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
{
|
{
|
||||||
for(Entry *walk = mHashTable[i]; walk;)
|
for (Entry *walk = mHashTable[i]; walk;)
|
||||||
{
|
{
|
||||||
Entry *temp = walk;
|
Entry *temp = walk;
|
||||||
walk = temp->next;
|
walk = temp->next;
|
||||||
|
|
||||||
if( temp->value )
|
if (temp->value)
|
||||||
dFree(temp->value);
|
dFree(temp->value);
|
||||||
freeEntry(temp);
|
freeEntry(temp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AssertFatal( mNumFields == 0, "Incorrect count on field dictionary" );
|
AssertFatal(mNumFields == 0, "Incorrect count on field dictionary");
|
||||||
}
|
}
|
||||||
|
|
||||||
void SimFieldDictionary::setFieldType(StringTableEntry slotName, const char *typeString)
|
void SimFieldDictionary::setFieldType(StringTableEntry slotName, const char *typeString)
|
||||||
{
|
{
|
||||||
ConsoleBaseType *cbt = ConsoleBaseType::getTypeByName( typeString );
|
ConsoleBaseType *cbt = ConsoleBaseType::getTypeByName(typeString);
|
||||||
setFieldType(slotName, cbt);
|
setFieldType(slotName, cbt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,11 +117,11 @@ void SimFieldDictionary::setFieldType(StringTableEntry slotName, const U32 typeI
|
||||||
void SimFieldDictionary::setFieldType(StringTableEntry slotName, ConsoleBaseType *type)
|
void SimFieldDictionary::setFieldType(StringTableEntry slotName, ConsoleBaseType *type)
|
||||||
{
|
{
|
||||||
// If the field exists on the object, set the type
|
// If the field exists on the object, set the type
|
||||||
U32 bucket = getHashValue( slotName );
|
U32 bucket = getHashValue(slotName);
|
||||||
|
|
||||||
for( Entry *walk = mHashTable[bucket]; walk; walk = walk->next )
|
for (Entry *walk = mHashTable[bucket]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
if( walk->slotName == slotName )
|
if (walk->slotName == slotName)
|
||||||
{
|
{
|
||||||
// Found and type assigned, let's bail
|
// Found and type assigned, let's bail
|
||||||
walk->type = type;
|
walk->type = type;
|
||||||
|
|
@ -130,15 +130,15 @@ void SimFieldDictionary::setFieldType(StringTableEntry slotName, ConsoleBaseType
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise create the field, and set the type. Assign a null value.
|
// Otherwise create the field, and set the type. Assign a null value.
|
||||||
addEntry( bucket, slotName, type );
|
addEntry(bucket, slotName, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
U32 SimFieldDictionary::getFieldType(StringTableEntry slotName) const
|
U32 SimFieldDictionary::getFieldType(StringTableEntry slotName) const
|
||||||
{
|
{
|
||||||
U32 bucket = getHashValue( slotName );
|
U32 bucket = getHashValue(slotName);
|
||||||
|
|
||||||
for( Entry *walk = mHashTable[bucket]; walk; walk = walk->next )
|
for (Entry *walk = mHashTable[bucket]; walk; walk = walk->next)
|
||||||
if( walk->slotName == slotName )
|
if (walk->slotName == slotName)
|
||||||
return walk->type ? walk->type->getTypeID() : TypeString;
|
return walk->type ? walk->type->getTypeID() : TypeString;
|
||||||
|
|
||||||
return TypeString;
|
return TypeString;
|
||||||
|
|
@ -146,27 +146,27 @@ U32 SimFieldDictionary::getFieldType(StringTableEntry slotName) const
|
||||||
|
|
||||||
SimFieldDictionary::Entry *SimFieldDictionary::findDynamicField(const String &fieldName) const
|
SimFieldDictionary::Entry *SimFieldDictionary::findDynamicField(const String &fieldName) const
|
||||||
{
|
{
|
||||||
U32 bucket = getHashValue( fieldName );
|
U32 bucket = getHashValue(fieldName);
|
||||||
|
|
||||||
for( Entry *walk = mHashTable[bucket]; walk; walk = walk->next )
|
for (Entry *walk = mHashTable[bucket]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
if( fieldName.equal(walk->slotName, String::NoCase) )
|
if (fieldName.equal(walk->slotName, String::NoCase))
|
||||||
return walk;
|
return walk;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimFieldDictionary::Entry *SimFieldDictionary::findDynamicField( StringTableEntry fieldName) const
|
SimFieldDictionary::Entry *SimFieldDictionary::findDynamicField(StringTableEntry fieldName) const
|
||||||
{
|
{
|
||||||
U32 bucket = getHashValue( fieldName );
|
U32 bucket = getHashValue(fieldName);
|
||||||
|
|
||||||
for( Entry *walk = mHashTable[bucket]; walk; walk = walk->next )
|
for (Entry *walk = mHashTable[bucket]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
if( walk->slotName == fieldName )
|
if (walk->slotName == fieldName)
|
||||||
{
|
{
|
||||||
return walk;
|
return walk;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -177,17 +177,17 @@ void SimFieldDictionary::setFieldValue(StringTableEntry slotName, const char *va
|
||||||
{
|
{
|
||||||
U32 bucket = getHashValue(slotName);
|
U32 bucket = getHashValue(slotName);
|
||||||
Entry **walk = &mHashTable[bucket];
|
Entry **walk = &mHashTable[bucket];
|
||||||
while(*walk && (*walk)->slotName != slotName)
|
while (*walk && (*walk)->slotName != slotName)
|
||||||
walk = &((*walk)->next);
|
walk = &((*walk)->next);
|
||||||
|
|
||||||
Entry *field = *walk;
|
Entry *field = *walk;
|
||||||
if( !value || !*value )
|
if (!value || !*value)
|
||||||
{
|
{
|
||||||
if(field)
|
if (field)
|
||||||
{
|
{
|
||||||
mVersion++;
|
mVersion++;
|
||||||
|
|
||||||
if( field->value )
|
if (field->value)
|
||||||
dFree(field->value);
|
dFree(field->value);
|
||||||
|
|
||||||
*walk = field->next;
|
*walk = field->next;
|
||||||
|
|
@ -196,15 +196,15 @@ void SimFieldDictionary::setFieldValue(StringTableEntry slotName, const char *va
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(field)
|
if (field)
|
||||||
{
|
{
|
||||||
if( field->value )
|
if (field->value)
|
||||||
dFree(field->value);
|
dFree(field->value);
|
||||||
|
|
||||||
field->value = dStrdup(value);
|
field->value = dStrdup(value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
addEntry( bucket, slotName, 0, dStrdup( value ) );
|
addEntry(bucket, slotName, 0, dStrdup(value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -212,8 +212,8 @@ const char *SimFieldDictionary::getFieldValue(StringTableEntry slotName)
|
||||||
{
|
{
|
||||||
U32 bucket = getHashValue(slotName);
|
U32 bucket = getHashValue(slotName);
|
||||||
|
|
||||||
for(Entry *walk = mHashTable[bucket];walk;walk = walk->next)
|
for (Entry *walk = mHashTable[bucket]; walk; walk = walk->next)
|
||||||
if(walk->slotName == slotName)
|
if (walk->slotName == slotName)
|
||||||
return walk->value;
|
return walk->value;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -223,9 +223,9 @@ void SimFieldDictionary::assignFrom(SimFieldDictionary *dict)
|
||||||
{
|
{
|
||||||
mVersion++;
|
mVersion++;
|
||||||
|
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
{
|
{
|
||||||
for(Entry *walk = dict->mHashTable[i];walk; walk = walk->next)
|
for (Entry *walk = dict->mHashTable[i]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
setFieldValue(walk->slotName, walk->value);
|
setFieldValue(walk->slotName, walk->value);
|
||||||
setFieldType(walk->slotName, walk->type);
|
setFieldType(walk->slotName, walk->type);
|
||||||
|
|
@ -233,7 +233,7 @@ void SimFieldDictionary::assignFrom(SimFieldDictionary *dict)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static S32 QSORT_CALLBACK compareEntries(const void* a,const void* b)
|
static S32 QSORT_CALLBACK compareEntries(const void* a, const void* b)
|
||||||
{
|
{
|
||||||
SimFieldDictionary::Entry *fa = *((SimFieldDictionary::Entry **)a);
|
SimFieldDictionary::Entry *fa = *((SimFieldDictionary::Entry **)a);
|
||||||
SimFieldDictionary::Entry *fb = *((SimFieldDictionary::Entry **)b);
|
SimFieldDictionary::Entry *fb = *((SimFieldDictionary::Entry **)b);
|
||||||
|
|
@ -245,17 +245,17 @@ void SimFieldDictionary::writeFields(SimObject *obj, Stream &stream, U32 tabStop
|
||||||
const AbstractClassRep::FieldList &list = obj->getFieldList();
|
const AbstractClassRep::FieldList &list = obj->getFieldList();
|
||||||
Vector<Entry *> flist(__FILE__, __LINE__);
|
Vector<Entry *> flist(__FILE__, __LINE__);
|
||||||
|
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
{
|
{
|
||||||
for(Entry *walk = mHashTable[i];walk; walk = walk->next)
|
for (Entry *walk = mHashTable[i]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
// make sure we haven't written this out yet:
|
// make sure we haven't written this out yet:
|
||||||
U32 i;
|
U32 i;
|
||||||
for(i = 0; i < list.size(); i++)
|
for (i = 0; i < list.size(); i++)
|
||||||
if(list[i].pFieldname == walk->slotName)
|
if (list[i].pFieldname == walk->slotName)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(i != list.size())
|
if (i != list.size())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -267,23 +267,23 @@ void SimFieldDictionary::writeFields(SimObject *obj, Stream &stream, U32 tabStop
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort Entries to prevent version control conflicts
|
// Sort Entries to prevent version control conflicts
|
||||||
dQsort(flist.address(),flist.size(),sizeof(Entry *),compareEntries);
|
dQsort(flist.address(), flist.size(), sizeof(Entry *), compareEntries);
|
||||||
|
|
||||||
// Save them out
|
// Save them out
|
||||||
for(Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
|
for (Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
|
||||||
{
|
{
|
||||||
U32 nBufferSize = (dStrlen( (*itr)->value ) * 2) + dStrlen( (*itr)->slotName ) + 16;
|
U32 nBufferSize = (dStrlen((*itr)->value) * 2) + dStrlen((*itr)->slotName) + 16;
|
||||||
FrameTemp<char> expandedBuffer( nBufferSize );
|
FrameTemp<char> expandedBuffer(nBufferSize);
|
||||||
|
|
||||||
stream.writeTabs(tabStop+1);
|
stream.writeTabs(tabStop + 1);
|
||||||
|
|
||||||
const char *typeName = (*itr)->type && (*itr)->type->getTypeID() != TypeString ? (*itr)->type->getTypeName() : "";
|
const char *typeName = (*itr)->type && (*itr)->type->getTypeID() != TypeString ? (*itr)->type->getTypeName() : "";
|
||||||
dSprintf(expandedBuffer, nBufferSize, "%s%s%s = \"", typeName, *typeName ? " " : "", (*itr)->slotName);
|
dSprintf(expandedBuffer, nBufferSize, "%s%s%s = \"", typeName, *typeName ? " " : "", (*itr)->slotName);
|
||||||
if ( (*itr)->value )
|
if ((*itr)->value)
|
||||||
expandEscape((char*)expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
|
expandEscape((char*)expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
|
||||||
dStrcat(expandedBuffer, "\";\r\n");
|
dStrcat(expandedBuffer, "\";\r\n");
|
||||||
|
|
||||||
stream.write(dStrlen(expandedBuffer),expandedBuffer);
|
stream.write(dStrlen(expandedBuffer), expandedBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -293,32 +293,32 @@ void SimFieldDictionary::printFields(SimObject *obj)
|
||||||
char expandedBuffer[4096];
|
char expandedBuffer[4096];
|
||||||
Vector<Entry *> flist(__FILE__, __LINE__);
|
Vector<Entry *> flist(__FILE__, __LINE__);
|
||||||
|
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
{
|
{
|
||||||
for(Entry *walk = mHashTable[i];walk; walk = walk->next)
|
for (Entry *walk = mHashTable[i]; walk; walk = walk->next)
|
||||||
{
|
{
|
||||||
// make sure we haven't written this out yet:
|
// make sure we haven't written this out yet:
|
||||||
U32 i;
|
U32 i;
|
||||||
for(i = 0; i < list.size(); i++)
|
for (i = 0; i < list.size(); i++)
|
||||||
if(list[i].pFieldname == walk->slotName)
|
if (list[i].pFieldname == walk->slotName)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if(i != list.size())
|
if (i != list.size())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
flist.push_back(walk);
|
flist.push_back(walk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dQsort(flist.address(),flist.size(),sizeof(Entry *),compareEntries);
|
dQsort(flist.address(), flist.size(), sizeof(Entry *), compareEntries);
|
||||||
|
|
||||||
for(Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
|
for (Vector<Entry *>::iterator itr = flist.begin(); itr != flist.end(); itr++)
|
||||||
{
|
{
|
||||||
const char* type = "string";
|
const char* type = "string";
|
||||||
if( ( *itr )->type )
|
if ((*itr)->type)
|
||||||
type = ( *itr )->type->getTypeClassName();
|
type = (*itr)->type->getTypeClassName();
|
||||||
|
|
||||||
dSprintf( expandedBuffer, sizeof( expandedBuffer ), " %s %s = \"", type, ( *itr )->slotName );
|
dSprintf(expandedBuffer, sizeof(expandedBuffer), " %s %s = \"", type, (*itr)->slotName);
|
||||||
if ( (*itr)->value )
|
if ((*itr)->value)
|
||||||
expandEscape(expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
|
expandEscape(expandedBuffer + dStrlen(expandedBuffer), (*itr)->value);
|
||||||
Con::printf("%s\"", expandedBuffer);
|
Con::printf("%s\"", expandedBuffer);
|
||||||
}
|
}
|
||||||
|
|
@ -326,9 +326,9 @@ void SimFieldDictionary::printFields(SimObject *obj)
|
||||||
|
|
||||||
SimFieldDictionary::Entry *SimFieldDictionary::operator[](U32 index)
|
SimFieldDictionary::Entry *SimFieldDictionary::operator[](U32 index)
|
||||||
{
|
{
|
||||||
AssertFatal ( index < mNumFields, "out of range" );
|
AssertFatal(index < mNumFields, "out of range");
|
||||||
|
|
||||||
if ( index > mNumFields )
|
if (index > mNumFields)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
SimFieldDictionaryIterator itr(this);
|
SimFieldDictionaryIterator itr(this);
|
||||||
|
|
@ -350,13 +350,13 @@ SimFieldDictionaryIterator::SimFieldDictionaryIterator(SimFieldDictionary * dict
|
||||||
|
|
||||||
SimFieldDictionary::Entry* SimFieldDictionaryIterator::operator++()
|
SimFieldDictionary::Entry* SimFieldDictionaryIterator::operator++()
|
||||||
{
|
{
|
||||||
if(!mDictionary)
|
if (!mDictionary)
|
||||||
return(mEntry);
|
return(mEntry);
|
||||||
|
|
||||||
if(mEntry)
|
if (mEntry)
|
||||||
mEntry = mEntry->next;
|
mEntry = mEntry->next;
|
||||||
|
|
||||||
while(!mEntry && (mHashIndex < (SimFieldDictionary::HashTableSize-1)))
|
while (!mEntry && (mHashIndex < (SimFieldDictionary::HashTableSize - 1)))
|
||||||
mEntry = mDictionary->mHashTable[++mHashIndex];
|
mEntry = mDictionary->mHashTable[++mHashIndex];
|
||||||
|
|
||||||
return(mEntry);
|
return(mEntry);
|
||||||
|
|
@ -386,14 +386,14 @@ void SimFieldDictionary::setFieldValue(StringTableEntry slotName, const char *va
|
||||||
|
|
||||||
U32 bucket = getHashValue(slotName);
|
U32 bucket = getHashValue(slotName);
|
||||||
Entry **walk = &mHashTable[bucket];
|
Entry **walk = &mHashTable[bucket];
|
||||||
while(*walk && (*walk)->slotName != slotName)
|
while (*walk && (*walk)->slotName != slotName)
|
||||||
walk = &((*walk)->next);
|
walk = &((*walk)->next);
|
||||||
|
|
||||||
Entry *field = *walk;
|
Entry *field = *walk;
|
||||||
if (field)
|
if (field)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
addEntry( bucket, slotName, type, dStrdup( value ) );
|
addEntry(bucket, slotName, type, dStrdup(value));
|
||||||
}
|
}
|
||||||
// A variation of the stock SimFieldDictionary::assignFrom(), this method adds <no_replace>
|
// A variation of the stock SimFieldDictionary::assignFrom(), this method adds <no_replace>
|
||||||
// and <filter> arguments. When true, <no_replace> prohibits the replacement of fields that already
|
// and <filter> arguments. When true, <no_replace> prohibits the replacement of fields that already
|
||||||
|
|
@ -412,14 +412,14 @@ void SimFieldDictionary::assignFrom(SimFieldDictionary *dict, const char* filter
|
||||||
|
|
||||||
if (filter_len == 0)
|
if (filter_len == 0)
|
||||||
{
|
{
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
for(Entry *walk = dict->mHashTable[i];walk; walk = walk->next)
|
for (Entry *walk = dict->mHashTable[i]; walk; walk = walk->next)
|
||||||
setFieldValue(walk->slotName, walk->value, walk->type, no_replace);
|
setFieldValue(walk->slotName, walk->value, walk->type, no_replace);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for(U32 i = 0; i < HashTableSize; i++)
|
for (U32 i = 0; i < HashTableSize; i++)
|
||||||
for(Entry *walk = dict->mHashTable[i];walk; walk = walk->next)
|
for (Entry *walk = dict->mHashTable[i]; walk; walk = walk->next)
|
||||||
if (dStrncmp(walk->slotName, filter, filter_len) == 0)
|
if (dStrncmp(walk->slotName, filter, filter_len) == 0)
|
||||||
setFieldValue(walk->slotName, walk->value, walk->type, no_replace);
|
setFieldValue(walk->slotName, walk->value, walk->type, no_replace);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ class SimFieldDictionary
|
||||||
public:
|
public:
|
||||||
struct Entry
|
struct Entry
|
||||||
{
|
{
|
||||||
Entry() : type( NULL ) {};
|
Entry() : type(NULL) {};
|
||||||
|
|
||||||
StringTableEntry slotName;
|
StringTableEntry slotName;
|
||||||
char *value;
|
char *value;
|
||||||
|
|
@ -64,10 +64,10 @@ private:
|
||||||
static Entry *smFreeList;
|
static Entry *smFreeList;
|
||||||
|
|
||||||
void freeEntry(Entry *entry);
|
void freeEntry(Entry *entry);
|
||||||
Entry* addEntry( U32 bucket, StringTableEntry slotName, ConsoleBaseType* type, char* value = 0 );
|
Entry* addEntry(U32 bucket, StringTableEntry slotName, ConsoleBaseType* type, char* value = 0);
|
||||||
|
|
||||||
static U32 getHashValue( StringTableEntry slotName );
|
static U32 getHashValue(StringTableEntry slotName);
|
||||||
static U32 getHashValue( const String& fieldName );
|
static U32 getHashValue(const String& fieldName);
|
||||||
|
|
||||||
U32 mNumFields;
|
U32 mNumFields;
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ public:
|
||||||
const char *getFieldValue(StringTableEntry slotName);
|
const char *getFieldValue(StringTableEntry slotName);
|
||||||
U32 getFieldType(StringTableEntry slotName) const;
|
U32 getFieldType(StringTableEntry slotName) const;
|
||||||
Entry *findDynamicField(const String &fieldName) const;
|
Entry *findDynamicField(const String &fieldName) const;
|
||||||
Entry *findDynamicField( StringTableEntry fieldName) const;
|
Entry *findDynamicField(StringTableEntry fieldName) const;
|
||||||
void writeFields(SimObject *obj, Stream &strem, U32 tabStop);
|
void writeFields(SimObject *obj, Stream &strem, U32 tabStop);
|
||||||
void printFields(SimObject *obj);
|
void printFields(SimObject *obj);
|
||||||
void assignFrom(SimFieldDictionary *dict);
|
void assignFrom(SimFieldDictionary *dict);
|
||||||
|
|
|
||||||
|
|
@ -72,8 +72,8 @@ SimObject::SimObject()
|
||||||
objectName = NULL;
|
objectName = NULL;
|
||||||
mOriginalName = NULL;
|
mOriginalName = NULL;
|
||||||
mInternalName = NULL;
|
mInternalName = NULL;
|
||||||
nextNameObject = (SimObject*)-1;
|
nextNameObject = nullptr;
|
||||||
nextManagerNameObject = (SimObject*)-1;
|
nextManagerNameObject = nullptr;
|
||||||
nextIdObject = NULL;
|
nextIdObject = NULL;
|
||||||
|
|
||||||
mFilename = NULL;
|
mFilename = NULL;
|
||||||
|
|
@ -86,6 +86,8 @@ SimObject::SimObject()
|
||||||
mNotifyList = NULL;
|
mNotifyList = NULL;
|
||||||
mFlags.set( ModStaticFields | ModDynamicFields );
|
mFlags.set( ModStaticFields | ModDynamicFields );
|
||||||
|
|
||||||
|
mProgenitorFile = StringTable->EmptyString();
|
||||||
|
|
||||||
mFieldDictionary = NULL;
|
mFieldDictionary = NULL;
|
||||||
mCanSaveFieldDictionary = true;
|
mCanSaveFieldDictionary = true;
|
||||||
|
|
||||||
|
|
@ -122,10 +124,10 @@ SimObject::~SimObject()
|
||||||
if( mCopySource )
|
if( mCopySource )
|
||||||
mCopySource->unregisterReference( &mCopySource );
|
mCopySource->unregisterReference( &mCopySource );
|
||||||
|
|
||||||
AssertFatal(nextNameObject == (SimObject*)-1,avar(
|
AssertFatal(nextNameObject == nullptr,avar(
|
||||||
"SimObject::~SimObject: Not removed from dictionary: name %s, id %i",
|
"SimObject::~SimObject: Not removed from dictionary: name %s, id %i",
|
||||||
objectName, mId));
|
objectName, mId));
|
||||||
AssertFatal(nextManagerNameObject == (SimObject*)-1,avar(
|
AssertFatal(nextManagerNameObject == nullptr,avar(
|
||||||
"SimObject::~SimObject: Not removed from manager dictionary: name %s, id %i",
|
"SimObject::~SimObject: Not removed from manager dictionary: name %s, id %i",
|
||||||
objectName,mId));
|
objectName,mId));
|
||||||
AssertFatal(mFlags.test(Added) == 0, "SimObject::object "
|
AssertFatal(mFlags.test(Added) == 0, "SimObject::object "
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue