mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 22:53:47 +00:00
initial port of the new interpreter
This commit is contained in:
parent
5d2654b1ba
commit
35500a87c6
47 changed files with 3675 additions and 5839 deletions
|
|
@ -331,7 +331,7 @@ DefineEngineStringlyVariadicMethod(GameConnection, setConnectArgs, void, 3, 17,
|
|||
|
||||
"@see GameConnection::onConnect()\n\n")
|
||||
{
|
||||
StringStackWrapper args(argc - 2, argv + 2);
|
||||
ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2);
|
||||
object->setConnectArgs(args.count(), args);
|
||||
}
|
||||
|
||||
|
|
@ -494,11 +494,17 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
|
|||
*errorString = "CR_INVALID_ARGS";
|
||||
return false;
|
||||
}
|
||||
ConsoleValueRef connectArgv[MaxConnectArgs + 3];
|
||||
ConsoleValue connectArgv[MaxConnectArgs + 3];
|
||||
ConsoleValue connectArgvValue[MaxConnectArgs + 3];
|
||||
|
||||
// TODO(JTH): Fix pls.
|
||||
AssertISV(false, "TODO: FIX CONSOLE VALUE");
|
||||
return false;
|
||||
|
||||
/*
|
||||
for(U32 i = 0; i < mConnectArgc+3; i++)
|
||||
{
|
||||
|
||||
connectArgv[i].value = &connectArgvValue[i];
|
||||
connectArgvValue[i].init();
|
||||
}
|
||||
|
|
@ -524,6 +530,7 @@ bool GameConnection::readConnectRequest(BitStream *stream, const char **errorStr
|
|||
return false;
|
||||
}
|
||||
return true;
|
||||
*/
|
||||
}
|
||||
//----------------------------------------------------------------------------
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
@ -1088,7 +1095,7 @@ bool GameConnection::readDemoStartBlock(BitStream *stream)
|
|||
void GameConnection::demoPlaybackComplete()
|
||||
{
|
||||
static const char* demoPlaybackArgv[1] = { "demoPlaybackComplete" };
|
||||
static StringStackConsoleWrapper demoPlaybackCmd(1, demoPlaybackArgv);
|
||||
static StringArrayToConsoleValueWrapper demoPlaybackCmd(1, demoPlaybackArgv);
|
||||
|
||||
Sim::postCurrentEvent(Sim::getRootGroup(), new SimConsoleEvent(demoPlaybackCmd.argc, demoPlaybackCmd.argv, false));
|
||||
Parent::demoPlaybackComplete();
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ DefineEngineStringlyVariadicFunction( commandToServer, void, 2, RemoteCommandEve
|
|||
NetConnection *conn = NetConnection::getConnectionToServer();
|
||||
if(!conn)
|
||||
return;
|
||||
StringStackWrapper args(argc - 1, argv + 1);
|
||||
ConsoleValueToStringArrayWrapper args(argc - 1, argv + 1);
|
||||
RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args);
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ DefineEngineStringlyVariadicFunction( commandToClient, void, 3, RemoteCommandEve
|
|||
NetConnection *conn;
|
||||
if(!Sim::findObject(argv[1], conn))
|
||||
return;
|
||||
StringStackWrapper args(argc - 2, argv + 2);
|
||||
ConsoleValueToStringArrayWrapper args(argc - 2, argv + 2);
|
||||
RemoteCommandEvent::sendRemoteCommand(conn, args.count(), args);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -236,13 +236,13 @@ TCPObject::~TCPObject()
|
|||
}
|
||||
}
|
||||
|
||||
bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
|
||||
bool TCPObject::processArguments(S32 argc, ConsoleValue *argv)
|
||||
{
|
||||
if(argc == 0)
|
||||
return true;
|
||||
else if(argc == 1)
|
||||
{
|
||||
addToTable(NetSocket::fromHandle(dAtoi(argv[0])));
|
||||
addToTable(NetSocket::fromHandle(argv[0].getInt()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
void disconnect();
|
||||
State getState() { return mState; }
|
||||
|
||||
bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
bool processArguments(S32 argc, ConsoleValue *argv);
|
||||
void send(const U8 *buffer, U32 bufferLen);
|
||||
|
||||
///Send an entire file over tcp
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ SimXMLDocument::~SimXMLDocument()
|
|||
// -----------------------------------------------------------------------------
|
||||
// Included for completeness.
|
||||
// -----------------------------------------------------------------------------
|
||||
bool SimXMLDocument::processArguments(S32 argc, ConsoleValueRef *argv)
|
||||
bool SimXMLDocument::processArguments(S32 argc, ConsoleValue *argv)
|
||||
{
|
||||
return argc == 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class SimXMLDocument: public SimObject
|
|||
// tie in to the script language. The .cc file has more in depth
|
||||
// comments on these.
|
||||
//-----------------------------------------------------------------------
|
||||
bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
bool processArguments(S32 argc, ConsoleValue *argv);
|
||||
bool onAdd();
|
||||
void onRemove();
|
||||
static void initPersistFields();
|
||||
|
|
|
|||
|
|
@ -39,8 +39,15 @@ enum TypeReq
|
|||
TypeReqNone,
|
||||
TypeReqUInt,
|
||||
TypeReqFloat,
|
||||
TypeReqString,
|
||||
TypeReqVar
|
||||
TypeReqString
|
||||
};
|
||||
|
||||
enum ExprNodeName
|
||||
{
|
||||
NameExprNode,
|
||||
NameFloatNode,
|
||||
NameIntNode,
|
||||
NameVarNode
|
||||
};
|
||||
|
||||
/// Representation of a node for the scripting language parser.
|
||||
|
|
@ -52,7 +59,7 @@ enum TypeReq
|
|||
/// each representing a different language construct.
|
||||
struct StmtNode
|
||||
{
|
||||
StmtNode *mNext; ///< Next entry in parse tree.
|
||||
StmtNode* next; ///< Next entry in parse tree.
|
||||
|
||||
StmtNode();
|
||||
virtual ~StmtNode() {}
|
||||
|
|
@ -61,8 +68,8 @@ struct StmtNode
|
|||
/// @{
|
||||
|
||||
///
|
||||
void append(StmtNode *next);
|
||||
StmtNode *getNext() const { return mNext; }
|
||||
void append(StmtNode* next);
|
||||
StmtNode* getNext() const { return next; }
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
@ -79,93 +86,95 @@ struct StmtNode
|
|||
/// @name Breaking
|
||||
/// @{
|
||||
|
||||
void addBreakLine(CodeStream &codeStream);
|
||||
void addBreakLine(CodeStream& codeStream);
|
||||
/// @}
|
||||
|
||||
/// @name Compilation
|
||||
/// @{
|
||||
|
||||
virtual U32 compileStmt(CodeStream &codeStream, U32 ip) = 0;
|
||||
virtual U32 compileStmt(CodeStream& codeStream, U32 ip) = 0;
|
||||
virtual void setPackage(StringTableEntry packageName);
|
||||
/// @}
|
||||
};
|
||||
|
||||
/// Helper macro
|
||||
#ifndef DEBUG_AST_NODES
|
||||
# define DBG_STMT_TYPE(s) virtual String dbgStmtType() const { return String(#s); }
|
||||
# define DBG_STMT_TYPE(s) virtual const char* dbgStmtType() const { return "#s"; }
|
||||
#else
|
||||
# define DBG_STMT_TYPE(s)
|
||||
#endif
|
||||
|
||||
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);
|
||||
DBG_STMT_TYPE(BreakStmtNode);
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
/// A mathematical expression.
|
||||
struct ExprNode : StmtNode
|
||||
{
|
||||
ExprNode* optimizedNode;
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
U32 compileStmt(CodeStream& codeStream, U32 ip);
|
||||
|
||||
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type) = 0;
|
||||
virtual U32 compile(CodeStream& codeStream, U32 ip, TypeReq type) = 0;
|
||||
virtual TypeReq getPreferredType() = 0;
|
||||
virtual ExprNodeName getExprNodeNameEnum() const { return NameExprNode; }
|
||||
};
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
struct IfStmtNode : StmtNode
|
||||
{
|
||||
ExprNode *testExpr;
|
||||
StmtNode *ifBlock, *elseBlock;
|
||||
ExprNode* testExpr;
|
||||
StmtNode* ifBlock, * elseBlock;
|
||||
U32 endifOffset;
|
||||
U32 elseOffset;
|
||||
bool integer;
|
||||
bool propagate;
|
||||
|
||||
static IfStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBlock, StmtNode *elseBlock, bool propagateThrough);
|
||||
void propagateSwitchExpr(ExprNode *left, bool string);
|
||||
ExprNode *getSwitchOR(ExprNode *left, ExprNode *list, bool string);
|
||||
static IfStmtNode* alloc(S32 lineNumber, ExprNode* testExpr, StmtNode* ifBlock, StmtNode* elseBlock, bool propagateThrough);
|
||||
void propagateSwitchExpr(ExprNode* left, bool string);
|
||||
ExprNode* getSwitchOR(ExprNode* left, ExprNode* list, bool string);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
U32 compileStmt(CodeStream& codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(IfStmtNode);
|
||||
};
|
||||
|
||||
struct LoopStmtNode : StmtNode
|
||||
{
|
||||
ExprNode *testExpr;
|
||||
ExprNode *initExpr;
|
||||
ExprNode *endLoopExpr;
|
||||
StmtNode *loopBlock;
|
||||
ExprNode* testExpr;
|
||||
ExprNode* initExpr;
|
||||
ExprNode* endLoopExpr;
|
||||
StmtNode* loopBlock;
|
||||
bool isDoLoop;
|
||||
U32 breakOffset;
|
||||
U32 continueOffset;
|
||||
U32 loopBlockStartOffset;
|
||||
bool integer;
|
||||
|
||||
static LoopStmtNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *initExpr, ExprNode *endLoopExpr, StmtNode *loopBlock, bool isDoLoop);
|
||||
static LoopStmtNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* initExpr, ExprNode* endLoopExpr, StmtNode* loopBlock, bool isDoLoop);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
U32 compileStmt(CodeStream& codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(LoopStmtNode);
|
||||
};
|
||||
|
||||
|
|
@ -189,35 +198,38 @@ struct IterStmtNode : StmtNode
|
|||
|
||||
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).
|
||||
struct BinaryExprNode : ExprNode
|
||||
{
|
||||
S32 op;
|
||||
ExprNode *left;
|
||||
ExprNode *right;
|
||||
ExprNode* left;
|
||||
ExprNode* right;
|
||||
};
|
||||
|
||||
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);
|
||||
|
||||
bool optimize();
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FloatBinaryExprNode);
|
||||
};
|
||||
|
||||
struct ConditionalExprNode : ExprNode
|
||||
{
|
||||
ExprNode *testExpr;
|
||||
ExprNode *trueExpr;
|
||||
ExprNode *falseExpr;
|
||||
ExprNode* testExpr;
|
||||
ExprNode* trueExpr;
|
||||
ExprNode* falseExpr;
|
||||
bool integer;
|
||||
static ConditionalExprNode *alloc(S32 lineNumber, ExprNode *testExpr, ExprNode *trueExpr, ExprNode *falseExpr);
|
||||
static ConditionalExprNode* alloc(S32 lineNumber, ExprNode* testExpr, ExprNode* trueExpr, ExprNode* falseExpr);
|
||||
|
||||
virtual U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
virtual U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
virtual TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ConditionalExprNode);
|
||||
};
|
||||
|
|
@ -227,11 +239,13 @@ struct IntBinaryExprNode : BinaryExprNode
|
|||
TypeReq subType;
|
||||
U32 operand;
|
||||
|
||||
static IntBinaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *left, ExprNode *right);
|
||||
static IntBinaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* left, ExprNode* right);
|
||||
|
||||
void getSubTypeOperand();
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
bool optimize();
|
||||
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(IntBinaryExprNode);
|
||||
};
|
||||
|
|
@ -239,9 +253,9 @@ struct IntBinaryExprNode : BinaryExprNode
|
|||
struct StreqExprNode : BinaryExprNode
|
||||
{
|
||||
bool eq;
|
||||
static StreqExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, bool eq);
|
||||
static StreqExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, bool eq);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StreqExprNode);
|
||||
};
|
||||
|
|
@ -249,19 +263,19 @@ struct StreqExprNode : BinaryExprNode
|
|||
struct StrcatExprNode : BinaryExprNode
|
||||
{
|
||||
S32 appendChar;
|
||||
static StrcatExprNode *alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar);
|
||||
static StrcatExprNode* alloc(S32 lineNumber, ExprNode* left, ExprNode* right, S32 appendChar);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StrcatExprNode);
|
||||
};
|
||||
|
||||
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);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(CommaCatExprNode);
|
||||
};
|
||||
|
|
@ -269,12 +283,12 @@ struct CommaCatExprNode : BinaryExprNode
|
|||
struct IntUnaryExprNode : ExprNode
|
||||
{
|
||||
S32 op;
|
||||
ExprNode *expr;
|
||||
ExprNode* expr;
|
||||
bool integer;
|
||||
|
||||
static IntUnaryExprNode *alloc(S32 lineNumber, S32 op, ExprNode *expr);
|
||||
static IntUnaryExprNode* alloc(S32 lineNumber, S32 op, ExprNode* expr);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(IntUnaryExprNode);
|
||||
};
|
||||
|
|
@ -282,11 +296,11 @@ struct IntUnaryExprNode : ExprNode
|
|||
struct FloatUnaryExprNode : ExprNode
|
||||
{
|
||||
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();
|
||||
DBG_STMT_TYPE(FloatUnaryExprNode);
|
||||
};
|
||||
|
|
@ -294,12 +308,13 @@ struct FloatUnaryExprNode : ExprNode
|
|||
struct VarNode : ExprNode
|
||||
{
|
||||
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();
|
||||
virtual ExprNodeName getExprNodeNameEnum() const { return NameVarNode; }
|
||||
DBG_STMT_TYPE(VarNode);
|
||||
};
|
||||
|
||||
|
|
@ -308,10 +323,11 @@ struct IntNode : ExprNode
|
|||
S32 value;
|
||||
U32 index; // if it's converted to float/string
|
||||
|
||||
static IntNode *alloc(S32 lineNumber, S32 value);
|
||||
static IntNode* alloc(S32 lineNumber, S32 value);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
virtual ExprNodeName getExprNodeNameEnum() const { return NameIntNode; }
|
||||
DBG_STMT_TYPE(IntNode);
|
||||
};
|
||||
|
||||
|
|
@ -320,24 +336,25 @@ struct FloatNode : ExprNode
|
|||
F64 value;
|
||||
U32 index;
|
||||
|
||||
static FloatNode *alloc(S32 lineNumber, F64 value);
|
||||
static FloatNode* alloc(S32 lineNumber, F64 value);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
virtual ExprNodeName getExprNodeNameEnum() const { return NameFloatNode; }
|
||||
DBG_STMT_TYPE(FloatNode);
|
||||
};
|
||||
|
||||
struct StrConstNode : ExprNode
|
||||
{
|
||||
char *str;
|
||||
char* str;
|
||||
F64 fVal;
|
||||
U32 index;
|
||||
bool tag;
|
||||
bool doc; // Specifies that this string is a documentation block.
|
||||
|
||||
static StrConstNode *alloc(S32 lineNumber, char *str, bool tag, bool doc = false);
|
||||
static StrConstNode* alloc(S32 lineNumber, char* str, bool tag, bool doc = false);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(StrConstNode);
|
||||
};
|
||||
|
|
@ -348,9 +365,9 @@ struct ConstantNode : ExprNode
|
|||
F64 fVal;
|
||||
U32 index;
|
||||
|
||||
static ConstantNode *alloc(S32 lineNumber, StringTableEntry value);
|
||||
static ConstantNode* alloc(S32 lineNumber, StringTableEntry value);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ConstantNode);
|
||||
};
|
||||
|
|
@ -358,13 +375,13 @@ struct ConstantNode : ExprNode
|
|||
struct AssignExprNode : ExprNode
|
||||
{
|
||||
StringTableEntry varName;
|
||||
ExprNode *expr;
|
||||
ExprNode *arrayIndex;
|
||||
ExprNode* expr;
|
||||
ExprNode* arrayIndex;
|
||||
TypeReq subType;
|
||||
|
||||
static AssignExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr);
|
||||
static AssignExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssignExprNode);
|
||||
};
|
||||
|
|
@ -373,22 +390,22 @@ struct AssignDecl
|
|||
{
|
||||
S32 lineNumber;
|
||||
S32 token;
|
||||
ExprNode *expr;
|
||||
ExprNode* expr;
|
||||
bool integer;
|
||||
};
|
||||
|
||||
struct AssignOpExprNode : ExprNode
|
||||
{
|
||||
StringTableEntry varName;
|
||||
ExprNode *expr;
|
||||
ExprNode *arrayIndex;
|
||||
ExprNode* expr;
|
||||
ExprNode* arrayIndex;
|
||||
S32 op;
|
||||
U32 operand;
|
||||
TypeReq subType;
|
||||
|
||||
static AssignOpExprNode *alloc(S32 lineNumber, StringTableEntry varName, ExprNode *arrayIndex, ExprNode *expr, S32 op);
|
||||
static AssignOpExprNode* alloc(S32 lineNumber, StringTableEntry varName, ExprNode* arrayIndex, ExprNode* expr, S32 op);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssignOpExprNode);
|
||||
};
|
||||
|
|
@ -396,22 +413,22 @@ struct AssignOpExprNode : ExprNode
|
|||
struct TTagSetStmtNode : StmtNode
|
||||
{
|
||||
StringTableEntry tag;
|
||||
ExprNode *valueExpr;
|
||||
ExprNode *stringExpr;
|
||||
ExprNode* valueExpr;
|
||||
ExprNode* stringExpr;
|
||||
|
||||
static TTagSetStmtNode *alloc(S32 lineNumber, StringTableEntry tag, ExprNode *valueExpr, ExprNode *stringExpr);
|
||||
static TTagSetStmtNode* alloc(S32 lineNumber, StringTableEntry tag, ExprNode* valueExpr, ExprNode* stringExpr);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
U32 compileStmt(CodeStream& codeStream, U32 ip);
|
||||
DBG_STMT_TYPE(TTagSetStmtNode);
|
||||
};
|
||||
|
||||
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();
|
||||
DBG_STMT_TYPE(TTagDerefNode);
|
||||
};
|
||||
|
|
@ -420,9 +437,9 @@ struct TTagExprNode : ExprNode
|
|||
{
|
||||
StringTableEntry tag;
|
||||
|
||||
static TTagExprNode *alloc(S32 lineNumber, StringTableEntry tag);
|
||||
static TTagExprNode* alloc(S32 lineNumber, StringTableEntry tag);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(TTagExprNode);
|
||||
};
|
||||
|
|
@ -431,42 +448,31 @@ struct FuncCallExprNode : ExprNode
|
|||
{
|
||||
StringTableEntry funcName;
|
||||
StringTableEntry nameSpace;
|
||||
ExprNode *args;
|
||||
ExprNode* args;
|
||||
U32 callType;
|
||||
enum {
|
||||
FunctionCall,
|
||||
StaticCall,
|
||||
MethodCall,
|
||||
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();
|
||||
DBG_STMT_TYPE(FuncCallExprNode);
|
||||
};
|
||||
|
||||
struct FuncPointerCallExprNode : ExprNode
|
||||
{
|
||||
ExprNode *funcPointer;
|
||||
ExprNode *args;
|
||||
|
||||
static FuncPointerCallExprNode *alloc(S32 lineNumber, ExprNode *stmt, ExprNode *args);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(FuncPointerCallExprNode);
|
||||
};
|
||||
|
||||
struct AssertCallExprNode : ExprNode
|
||||
{
|
||||
ExprNode *testExpr;
|
||||
const char *message;
|
||||
ExprNode* testExpr;
|
||||
const char* message;
|
||||
U32 messageIndex;
|
||||
|
||||
static AssertCallExprNode *alloc(S32 lineNumber, ExprNode *testExpr, const char *message);
|
||||
static AssertCallExprNode* alloc(S32 lineNumber, ExprNode* testExpr, const char* message);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(AssertCallExprNode);
|
||||
};
|
||||
|
|
@ -474,19 +480,19 @@ struct AssertCallExprNode : ExprNode
|
|||
struct SlotDecl
|
||||
{
|
||||
S32 lineNumber;
|
||||
ExprNode *object;
|
||||
ExprNode* object;
|
||||
StringTableEntry slotName;
|
||||
ExprNode *array;
|
||||
ExprNode* array;
|
||||
};
|
||||
|
||||
struct SlotAccessNode : ExprNode
|
||||
{
|
||||
ExprNode *objectExpr, *arrayExpr;
|
||||
ExprNode* objectExpr, * arrayExpr;
|
||||
StringTableEntry slotName;
|
||||
|
||||
static SlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName);
|
||||
static SlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAccessNode);
|
||||
};
|
||||
|
|
@ -494,101 +500,99 @@ struct SlotAccessNode : ExprNode
|
|||
struct InternalSlotDecl
|
||||
{
|
||||
S32 lineNumber;
|
||||
ExprNode *object;
|
||||
ExprNode *slotExpr;
|
||||
ExprNode* object;
|
||||
ExprNode* slotExpr;
|
||||
bool recurse;
|
||||
};
|
||||
|
||||
struct InternalSlotAccessNode : ExprNode
|
||||
{
|
||||
ExprNode *objectExpr, *slotExpr;
|
||||
ExprNode* objectExpr, * slotExpr;
|
||||
bool recurse;
|
||||
|
||||
static InternalSlotAccessNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *slotExpr, bool recurse);
|
||||
static InternalSlotAccessNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* slotExpr, bool recurse);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(InternalSlotAccessNode);
|
||||
};
|
||||
|
||||
struct SlotAssignNode : ExprNode
|
||||
{
|
||||
ExprNode *objectExpr, *arrayExpr;
|
||||
ExprNode* objectExpr, * arrayExpr;
|
||||
StringTableEntry slotName;
|
||||
ExprNode *valueExpr;
|
||||
ExprNode* valueExpr;
|
||||
U32 typeID;
|
||||
|
||||
static SlotAssignNode *alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName, ExprNode *valueExpr, U32 typeID = -1);
|
||||
static SlotAssignNode* alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName, ExprNode* valueExpr, U32 typeID = -1);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAssignNode);
|
||||
};
|
||||
|
||||
struct SlotAssignOpNode : ExprNode
|
||||
{
|
||||
ExprNode *objectExpr, *arrayExpr;
|
||||
ExprNode* objectExpr, * arrayExpr;
|
||||
StringTableEntry slotName;
|
||||
S32 op;
|
||||
ExprNode *valueExpr;
|
||||
ExprNode* valueExpr;
|
||||
U32 operand;
|
||||
TypeReq subType;
|
||||
|
||||
static SlotAssignOpNode *alloc(S32 lineNumber, ExprNode *objectExpr, StringTableEntry slotName, ExprNode *arrayExpr, S32 op, ExprNode *valueExpr);
|
||||
static SlotAssignOpNode* alloc(S32 lineNumber, ExprNode* objectExpr, StringTableEntry slotName, ExprNode* arrayExpr, S32 op, ExprNode* valueExpr);
|
||||
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(SlotAssignOpNode);
|
||||
};
|
||||
|
||||
struct ObjectDeclNode : ExprNode
|
||||
{
|
||||
ExprNode *classNameExpr;
|
||||
ExprNode* classNameExpr;
|
||||
StringTableEntry parentObject;
|
||||
ExprNode *objectNameExpr;
|
||||
ExprNode *argList;
|
||||
SlotAssignNode *slotDecls;
|
||||
ObjectDeclNode *subObjects;
|
||||
ExprNode* objectNameExpr;
|
||||
ExprNode* argList;
|
||||
SlotAssignNode* slotDecls;
|
||||
ObjectDeclNode* subObjects;
|
||||
bool isDatablock;
|
||||
U32 failOffset;
|
||||
bool isClassNameInternal;
|
||||
bool isSingleton;
|
||||
|
||||
static ObjectDeclNode *alloc(S32 lineNumber, ExprNode *classNameExpr, ExprNode *objectNameExpr, ExprNode *argList, StringTableEntry parentObject, SlotAssignNode *slotDecls, ObjectDeclNode *subObjects, bool isDatablock, bool classNameInternal, bool isSingleton);
|
||||
static ObjectDeclNode* alloc(S32 lineNumber, ExprNode* classNameExpr, ExprNode* objectNameExpr, ExprNode* argList, StringTableEntry parentObject, SlotAssignNode* slotDecls, ObjectDeclNode* subObjects, bool isDatablock, bool classNameInternal, bool isSingleton);
|
||||
|
||||
U32 precompileSubObject(bool);
|
||||
U32 compile(CodeStream &codeStream, U32 ip, TypeReq type);
|
||||
U32 compileSubObject(CodeStream &codeStream, U32 ip, bool);
|
||||
U32 compile(CodeStream& codeStream, U32 ip, TypeReq type);
|
||||
U32 compileSubObject(CodeStream& codeStream, U32 ip, bool);
|
||||
TypeReq getPreferredType();
|
||||
DBG_STMT_TYPE(ObjectDeclNode);
|
||||
};
|
||||
|
||||
struct ObjectBlockDecl
|
||||
{
|
||||
SlotAssignNode *slots;
|
||||
ObjectDeclNode *decls;
|
||||
SlotAssignNode* slots;
|
||||
ObjectDeclNode* decls;
|
||||
};
|
||||
|
||||
struct FunctionDeclStmtNode : StmtNode
|
||||
{
|
||||
StringTableEntry fnName;
|
||||
VarNode *args;
|
||||
StmtNode *stmts;
|
||||
VarNode* args;
|
||||
StmtNode* stmts;
|
||||
StringTableEntry nameSpace;
|
||||
StringTableEntry package;
|
||||
U32 endOffset;
|
||||
U32 argc;
|
||||
|
||||
static FunctionDeclStmtNode *alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode *args, StmtNode *stmts);
|
||||
static FunctionDeclStmtNode* alloc(S32 lineNumber, StringTableEntry fnName, StringTableEntry nameSpace, VarNode* args, StmtNode* stmts);
|
||||
|
||||
U32 compileStmt(CodeStream &codeStream, U32 ip);
|
||||
U32 compileStmt(CodeStream& codeStream, U32 ip);
|
||||
void setPackage(StringTableEntry packageName);
|
||||
DBG_STMT_TYPE(FunctionDeclStmtNode);
|
||||
};
|
||||
|
||||
extern StmtNode *gStatementList;
|
||||
extern StmtNode *gAnonFunctionList;
|
||||
extern U32 gAnonFunctionID;
|
||||
extern StmtNode* gStatementList;
|
||||
extern ExprEvalState gEvalState;
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2012 GarageGames, LLC
|
||||
// Copyright (c) 2013 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
|
||||
|
|
@ -20,7 +20,6 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "platform/platform.h"
|
||||
#include "console/console.h"
|
||||
#include "console/compiler.h"
|
||||
#include "console/consoleInternal.h"
|
||||
|
|
@ -38,25 +37,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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
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);
|
||||
ret->expr = expr;
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
|
|
@ -64,9 +63,9 @@ ReturnStmtNode *ReturnStmtNode::alloc(S32 lineNumber, ExprNode *expr)
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
|
||||
|
|
@ -78,9 +77,9 @@ IfStmtNode *IfStmtNode::alloc(S32 lineNumber, ExprNode *testExpr, StmtNode *ifBl
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->testExpr = testExpr;
|
||||
|
|
@ -111,11 +110,12 @@ IterStmtNode* IterStmtNode::alloc(S32 lineNumber, StringTableEntry varName, Expr
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
|
||||
ret->op = op;
|
||||
ret->left = left;
|
||||
|
|
@ -124,11 +124,12 @@ FloatBinaryExprNode *FloatBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
|
||||
ret->op = op;
|
||||
ret->left = left;
|
||||
|
|
@ -137,11 +138,12 @@ IntBinaryExprNode *IntBinaryExprNode::alloc(S32 lineNumber, S32 op, ExprNode *le
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->left = left;
|
||||
ret->right = right;
|
||||
ret->eq = eq;
|
||||
|
|
@ -149,11 +151,12 @@ StreqExprNode *StreqExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *ri
|
|||
return ret;
|
||||
}
|
||||
|
||||
StrcatExprNode *StrcatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *right, S32 appendChar)
|
||||
StrcatExprNode* StrcatExprNode::alloc(S32 lineNumber, ExprNode* left, ExprNode* right, int appendChar)
|
||||
{
|
||||
StrcatExprNode *ret = (StrcatExprNode *)consoleAlloc(sizeof(StrcatExprNode));
|
||||
StrcatExprNode* ret = (StrcatExprNode*)consoleAlloc(sizeof(StrcatExprNode));
|
||||
constructInPlace(ret);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->left = left;
|
||||
ret->right = right;
|
||||
ret->appendChar = appendChar;
|
||||
|
|
@ -161,61 +164,67 @@ StrcatExprNode *StrcatExprNode::alloc(S32 lineNumber, ExprNode *left, ExprNode *
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->left = left;
|
||||
ret->right = right;
|
||||
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->op = op;
|
||||
ret->expr = expr;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->op = op;
|
||||
ret->expr = expr;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->varName = varName;
|
||||
ret->arrayIndex = arrayIndex;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->value = value;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->testExpr = testExpr;
|
||||
ret->trueExpr = trueExpr;
|
||||
ret->falseExpr = falseExpr;
|
||||
|
|
@ -223,44 +232,50 @@ ConditionalExprNode *ConditionalExprNode::alloc(S32 lineNumber, ExprNode *testEx
|
|||
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);
|
||||
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->value = value;
|
||||
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);
|
||||
S32 len = dStrlen(str);
|
||||
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
dsize_t retStrLen = dStrlen(str) + 1;
|
||||
ret->str = (char *)consoleAlloc(retStrLen);
|
||||
ret->optimizedNode = NULL;
|
||||
ret->str = (char*)consoleAlloc(len + 1);
|
||||
ret->tag = tag;
|
||||
ret->doc = doc;
|
||||
dStrcpy(ret->str, str, retStrLen);
|
||||
dStrcpy(ret->str, str, len);
|
||||
ret->str[len] = '\0';
|
||||
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->value = value;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->varName = varName;
|
||||
ret->expr = expr;
|
||||
ret->arrayIndex = arrayIndex;
|
||||
|
|
@ -268,11 +283,12 @@ AssignExprNode *AssignExprNode::alloc(S32 lineNumber, StringTableEntry varName,
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->varName = varName;
|
||||
ret->expr = expr;
|
||||
ret->arrayIndex = arrayIndex;
|
||||
|
|
@ -280,9 +296,9 @@ AssignOpExprNode *AssignOpExprNode::alloc(S32 lineNumber, StringTableEntry varNa
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->tag = tag;
|
||||
|
|
@ -291,59 +307,54 @@ TTagSetStmtNode *TTagSetStmtNode::alloc(S32 lineNumber, StringTableEntry tag, Ex
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->expr = expr;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->tag = tag;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->funcName = funcName;
|
||||
ret->nameSpace = nameSpace;
|
||||
ret->args = args;
|
||||
if (dot)
|
||||
ret->callType = MethodCall;
|
||||
else
|
||||
else if (nameSpace != NULL)
|
||||
{
|
||||
if (nameSpace && !dStricmp(nameSpace, "Parent"))
|
||||
if (dStricmp(nameSpace, "Parent") == 0)
|
||||
ret->callType = ParentCall;
|
||||
else
|
||||
ret->callType = FunctionCall;
|
||||
ret->callType = StaticCall;
|
||||
}
|
||||
else
|
||||
ret->callType = FunctionCall;
|
||||
return ret;
|
||||
}
|
||||
|
||||
FuncPointerCallExprNode *FuncPointerCallExprNode::alloc(S32 lineNumber, ExprNode *funcPointer, ExprNode *args)
|
||||
AssertCallExprNode* AssertCallExprNode::alloc(S32 lineNumber, ExprNode* testExpr, const char* message)
|
||||
{
|
||||
FuncPointerCallExprNode *ret = (FuncPointerCallExprNode *)consoleAlloc(sizeof(FuncPointerCallExprNode));
|
||||
constructInPlace(ret);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->funcPointer = funcPointer;
|
||||
ret->args = args;
|
||||
return ret;
|
||||
}
|
||||
#ifdef TORQUE_ENABLE_SCRIPTASSERTS
|
||||
|
||||
AssertCallExprNode *AssertCallExprNode::alloc(S32 lineNumber, ExprNode *testExpr, const char *message)
|
||||
{
|
||||
#ifdef TORQUE_ENABLE_SCRIPTASSERTS
|
||||
|
||||
AssertCallExprNode *ret = (AssertCallExprNode *)consoleAlloc(sizeof(FuncCallExprNode));
|
||||
AssertCallExprNode* ret = (AssertCallExprNode*)consoleAlloc(sizeof(FuncCallExprNode));
|
||||
constructInPlace(ret);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->testExpr = testExpr;
|
||||
|
|
@ -357,10 +368,11 @@ AssertCallExprNode *AssertCallExprNode::alloc(S32 lineNumber, ExprNode *testExpr
|
|||
#endif
|
||||
}
|
||||
|
||||
SlotAccessNode *SlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, ExprNode *arrayExpr, StringTableEntry slotName)
|
||||
SlotAccessNode* SlotAccessNode::alloc(S32 lineNumber, ExprNode* objectExpr, ExprNode* arrayExpr, StringTableEntry slotName)
|
||||
{
|
||||
SlotAccessNode *ret = (SlotAccessNode *)consoleAlloc(sizeof(SlotAccessNode));
|
||||
SlotAccessNode* ret = (SlotAccessNode*)consoleAlloc(sizeof(SlotAccessNode));
|
||||
constructInPlace(ret);
|
||||
ret->optimizedNode = NULL;
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->objectExpr = objectExpr;
|
||||
ret->arrayExpr = arrayExpr;
|
||||
|
|
@ -368,22 +380,24 @@ SlotAccessNode *SlotAccessNode::alloc(S32 lineNumber, ExprNode *objectExpr, Expr
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->objectExpr = objectExpr;
|
||||
ret->slotExpr = slotExpr;
|
||||
ret->recurse = recurse;
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->objectExpr = objectExpr;
|
||||
ret->arrayExpr = arrayExpr;
|
||||
ret->slotName = slotName;
|
||||
|
|
@ -392,11 +406,12 @@ SlotAssignNode *SlotAssignNode::alloc(S32 lineNumber, ExprNode *objectExpr, Expr
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->objectExpr = objectExpr;
|
||||
ret->arrayExpr = arrayExpr;
|
||||
ret->slotName = slotName;
|
||||
|
|
@ -405,11 +420,12 @@ SlotAssignOpNode *SlotAssignOpNode::alloc(S32 lineNumber, ExprNode *objectExpr,
|
|||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->optimizedNode = NULL;
|
||||
ret->classNameExpr = classNameExpr;
|
||||
ret->objectNameExpr = objectNameExpr;
|
||||
ret->argList = argList;
|
||||
|
|
@ -422,13 +438,13 @@ ObjectDeclNode *ObjectDeclNode::alloc(S32 lineNumber, ExprNode *classNameExpr, E
|
|||
if (parentObject)
|
||||
ret->parentObject = parentObject;
|
||||
else
|
||||
ret->parentObject = StringTable->EmptyString();
|
||||
ret->parentObject = StringTable->insert("");
|
||||
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);
|
||||
ret->dbgLineNumber = lineNumber;
|
||||
ret->fnName = fnName;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,262 +0,0 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// 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
|
|
@ -93,26 +93,28 @@ namespace Compiler
|
|||
OP_MUL,
|
||||
OP_DIV,
|
||||
OP_NEG,
|
||||
|
||||
OP_INC,
|
||||
OP_DEC,
|
||||
|
||||
OP_SETCURVAR,
|
||||
OP_SETCURVAR_CREATE,
|
||||
OP_SETCURVAR_ARRAY,
|
||||
OP_SETCURVAR_ARRAY_VARLOOKUP,
|
||||
OP_SETCURVAR_ARRAY_CREATE,
|
||||
OP_SETCURVAR_ARRAY_CREATE_VARLOOKUP,
|
||||
|
||||
OP_LOADVAR_UINT,// 40
|
||||
OP_LOADVAR_FLT,
|
||||
OP_LOADVAR_STR,
|
||||
OP_LOADVAR_VAR,
|
||||
|
||||
OP_SAVEVAR_UINT,
|
||||
OP_SAVEVAR_FLT,
|
||||
OP_SAVEVAR_STR,
|
||||
OP_SAVEVAR_VAR,
|
||||
|
||||
OP_LOAD_LOCAL_VAR_UINT,
|
||||
OP_LOAD_LOCAL_VAR_FLT,
|
||||
OP_LOAD_LOCAL_VAR_STR,
|
||||
|
||||
OP_SAVE_LOCAL_VAR_UINT,
|
||||
OP_SAVE_LOCAL_VAR_FLT,
|
||||
OP_SAVE_LOCAL_VAR_STR,
|
||||
|
||||
OP_SETCUROBJECT,
|
||||
OP_SETCUROBJECT_NEW,
|
||||
|
|
@ -121,8 +123,6 @@ namespace Compiler
|
|||
OP_SETCURFIELD,
|
||||
OP_SETCURFIELD_ARRAY, // 50
|
||||
OP_SETCURFIELD_TYPE,
|
||||
OP_SETCURFIELD_ARRAY_VAR,
|
||||
OP_SETCURFIELD_THIS,
|
||||
|
||||
OP_LOADFIELD_UINT,
|
||||
OP_LOADFIELD_FLT,
|
||||
|
|
@ -141,19 +141,15 @@ namespace Compiler
|
|||
OP_UINT_TO_FLT,
|
||||
OP_UINT_TO_STR,
|
||||
OP_UINT_TO_NONE,
|
||||
OP_COPYVAR_TO_NONE,
|
||||
|
||||
OP_LOADIMMED_UINT,
|
||||
OP_LOADIMMED_FLT,
|
||||
OP_TAG_TO_STR,
|
||||
OP_LOADIMMED_STR, // 70
|
||||
OP_DOCBLOCK_STR,
|
||||
OP_DOCBLOCK_STR, // 76
|
||||
OP_LOADIMMED_IDENT,
|
||||
|
||||
OP_CALLFUNC_RESOLVE,
|
||||
OP_CALLFUNC,
|
||||
OP_CALLFUNC_POINTER,
|
||||
OP_CALLFUNC_THIS,
|
||||
|
||||
OP_ADVANCE_STR,
|
||||
OP_ADVANCE_STR_APPENDCHAR,
|
||||
|
|
@ -166,8 +162,6 @@ namespace Compiler
|
|||
OP_PUSH, // String
|
||||
OP_PUSH_UINT, // Integer
|
||||
OP_PUSH_FLT, // Float
|
||||
OP_PUSH_VAR, // Variable
|
||||
OP_PUSH_THIS, // This pointer
|
||||
OP_PUSH_FRAME, // Frame
|
||||
|
||||
OP_ASSERT,
|
||||
|
|
|
|||
|
|
@ -271,8 +271,6 @@ StringTableEntry gCurrentFile;
|
|||
StringTableEntry gCurrentRoot;
|
||||
/// @}
|
||||
|
||||
S32 gObjectCopyFailures = -1;
|
||||
|
||||
bool alwaysUseDebugOutput = true;
|
||||
bool useTimestamp = false;
|
||||
bool useRealTimestamp = false;
|
||||
|
|
@ -327,6 +325,7 @@ void init()
|
|||
|
||||
// Setup the console types.
|
||||
ConsoleBaseType::initialize();
|
||||
ConsoleValue::init();
|
||||
|
||||
// And finally, the ACR...
|
||||
AbstractClassRep::initialize();
|
||||
|
|
@ -344,10 +343,6 @@ void init()
|
|||
addVariable( "instantGroup", TypeRealString, &gInstantGroup, "The group that objects will be added to when they are created.\n"
|
||||
"@ingroup Console\n");
|
||||
|
||||
addVariable("Con::objectCopyFailures", TypeS32, &gObjectCopyFailures, "If greater than zero then it counts the number of object creation "
|
||||
"failures based on a missing copy object and does not report an error..\n"
|
||||
"@ingroup Console\n");
|
||||
|
||||
// Current script file name and root
|
||||
addVariable( "Con::File", TypeString, &gCurrentFile, "The currently executing script file.\n"
|
||||
"@ingroup FileSystem\n");
|
||||
|
|
@ -1590,11 +1585,9 @@ ConsoleValueRef _internalExecute(SimObject *object, S32 argc, ConsoleValueRef ar
|
|||
ICallMethod *com = dynamic_cast<ICallMethod *>(object);
|
||||
if(com)
|
||||
{
|
||||
STR.pushFrame();
|
||||
CSTK.pushFrame();
|
||||
gCallStack.pushFrame(0);
|
||||
com->callMethodArgList(argc, argv, false);
|
||||
STR.popFrame();
|
||||
CSTK.popFrame();
|
||||
gCallStack.popFrame();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2523,70 +2516,20 @@ DefineEngineFunction( logWarning, void, ( const char* message ),,
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern ConsoleValueStack CSTK;
|
||||
|
||||
ConsoleValueRef::ConsoleValueRef(const ConsoleValueRef &ref)
|
||||
{
|
||||
value = ref.value;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(const ConsoleValueRef &newValue)
|
||||
{
|
||||
value = newValue.value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(const char *newValue)
|
||||
{
|
||||
AssertFatal(value, "value should not be NULL");
|
||||
value->setStringValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(S32 newValue)
|
||||
{
|
||||
AssertFatal(value, "value should not be NULL");
|
||||
value->setIntValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(U32 newValue)
|
||||
{
|
||||
AssertFatal(value, "value should not be NULL");
|
||||
value->setIntValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(F32 newValue)
|
||||
{
|
||||
AssertFatal(value, "value should not be NULL");
|
||||
value->setFloatValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
ConsoleValueRef& ConsoleValueRef::operator=(F64 newValue)
|
||||
{
|
||||
AssertFatal(value, "value should not be NULL");
|
||||
value->setFloatValue(newValue);
|
||||
return *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
StringStackWrapper::StringStackWrapper(int targc, ConsoleValueRef targv[])
|
||||
ConsoleValueToStringArrayWrapper::ConsoleValueToStringArrayWrapper(int targc, ConsoleValue *targv)
|
||||
{
|
||||
argv = new const char*[targc];
|
||||
argc = targc;
|
||||
|
||||
for (int i=0; i<targc; i++)
|
||||
for (S32 i = 0; i < targc; i++)
|
||||
{
|
||||
argv[i] = dStrdup(targv[i]);
|
||||
argv[i] = dStrdup(targv[i].getString());
|
||||
}
|
||||
}
|
||||
|
||||
StringStackWrapper::~StringStackWrapper()
|
||||
ConsoleValueToStringArrayWrapper::~ConsoleValueToStringArrayWrapper()
|
||||
{
|
||||
for (int i=0; i<argc; i++)
|
||||
for (S32 i = 0; i< argc; i++)
|
||||
{
|
||||
dFree(argv[i]);
|
||||
}
|
||||
|
|
@ -2594,164 +2537,20 @@ StringStackWrapper::~StringStackWrapper()
|
|||
}
|
||||
|
||||
|
||||
StringStackConsoleWrapper::StringStackConsoleWrapper(int targc, const char** targ)
|
||||
StringArrayToConsoleValueWrapper::StringArrayToConsoleValueWrapper(int targc, const char** targv)
|
||||
{
|
||||
argv = new ConsoleValueRef[targc];
|
||||
argvValue = new ConsoleValue[targc];
|
||||
argv = new ConsoleValue[targc];
|
||||
argc = targc;
|
||||
|
||||
for (int i=0; i<targc; i++) {
|
||||
argvValue[i].init();
|
||||
argv[i].value = &argvValue[i];
|
||||
argvValue[i].setStackStringValue(targ[i]);
|
||||
for (int i=0; i<targc; i++)
|
||||
{
|
||||
argv[i].setString(targv[i], dStrlen(targv[i]));
|
||||
}
|
||||
}
|
||||
|
||||
StringStackConsoleWrapper::~StringStackConsoleWrapper()
|
||||
StringArrayToConsoleValueWrapper::~StringArrayToConsoleValueWrapper()
|
||||
{
|
||||
for (int i=0; i<argc; i++)
|
||||
{
|
||||
argv[i] = 0;
|
||||
}
|
||||
delete[] argv;
|
||||
delete[] argvValue;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
S32 ConsoleValue::getSignedIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return (S32)fval;
|
||||
else
|
||||
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
U32 ConsoleValue::getIntValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return ival;
|
||||
else
|
||||
return dAtoi(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
F32 ConsoleValue::getFloatValue()
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
return fval;
|
||||
else
|
||||
return dAtof(Con::getData(type, dataPtr, 0, enumTable));
|
||||
}
|
||||
|
||||
const char *ConsoleValue::getStringValue()
|
||||
{
|
||||
if(type == TypeInternalString || type == TypeInternalStackString)
|
||||
return sval;
|
||||
else if (type == TypeInternalStringStackPtr)
|
||||
return STR.mBuffer + (uintptr_t)sval;
|
||||
else
|
||||
{
|
||||
// We need a string representation, so lets create one
|
||||
const char *internalValue = NULL;
|
||||
|
||||
if(type == TypeInternalFloat)
|
||||
internalValue = Con::getData(TypeF32, &fval, 0);
|
||||
else if(type == TypeInternalInt)
|
||||
internalValue = Con::getData(TypeS32, &ival, 0);
|
||||
else
|
||||
return Con::getData(type, dataPtr, 0, enumTable); // We can't save sval here since it is the same as dataPtr
|
||||
|
||||
if (!internalValue)
|
||||
return "";
|
||||
|
||||
U32 stringLen = dStrlen(internalValue);
|
||||
U32 newLen = ((stringLen + 1) + 15) & ~15; // pad upto next cache line
|
||||
|
||||
if (bufferLen == 0)
|
||||
sval = (char *) dMalloc(newLen);
|
||||
else if(newLen > bufferLen)
|
||||
sval = (char *) dRealloc(sval, newLen);
|
||||
|
||||
dStrcpy(sval, internalValue, newLen);
|
||||
bufferLen = newLen;
|
||||
|
||||
return sval;
|
||||
}
|
||||
}
|
||||
|
||||
StringStackPtr ConsoleValue::getStringStackPtr()
|
||||
{
|
||||
if (type == TypeInternalStringStackPtr)
|
||||
return (uintptr_t)sval;
|
||||
else
|
||||
return (uintptr_t)-1;
|
||||
}
|
||||
|
||||
bool ConsoleValue::getBoolValue()
|
||||
{
|
||||
if(type == TypeInternalString || type == TypeInternalStackString || type == TypeInternalStringStackPtr)
|
||||
return dAtob(getStringValue());
|
||||
if(type == TypeInternalFloat)
|
||||
return fval > 0;
|
||||
else if(type == TypeInternalInt)
|
||||
return ival > 0;
|
||||
else {
|
||||
const char *value = Con::getData(type, dataPtr, 0, enumTable);
|
||||
return dAtob(value);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValue::setIntValue(S32 val)
|
||||
{
|
||||
setFloatValue(val);
|
||||
}
|
||||
|
||||
void ConsoleValue::setIntValue(U32 val)
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = (F32)val;
|
||||
ival = val;
|
||||
if(bufferLen > 0)
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
sval = typeValueEmpty;
|
||||
type = TypeInternalInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeS32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValue::setBoolValue(bool val)
|
||||
{
|
||||
return setIntValue(val ? 1 : 0);
|
||||
}
|
||||
|
||||
void ConsoleValue::setFloatValue(F32 val)
|
||||
{
|
||||
if(type <= TypeInternalString)
|
||||
{
|
||||
fval = val;
|
||||
ival = static_cast<U32>(val);
|
||||
if(bufferLen > 0)
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
sval = typeValueEmpty;
|
||||
type = TypeInternalFloat;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *dptr = Con::getData(TypeF32, &val, 0);
|
||||
Con::setData(type, dataPtr, 0, 1, &dptr, enumTable);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -183,13 +183,13 @@ void Dictionary::exportVariables(const char *varString, const char *fileName, bo
|
|||
|
||||
for (s = sortList.begin(); s != sortList.end(); s++)
|
||||
{
|
||||
switch ((*s)->value.type)
|
||||
switch ((*s)->value.getType())
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->value.ival, cat);
|
||||
case ConsoleValueType::cvInteger:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %d;%s", (*s)->name, (*s)->value.getInt(), cat);
|
||||
break;
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->value.fval, cat);
|
||||
case ConsoleValueType::cvFloat:
|
||||
dSprintf(buffer, sizeof(buffer), "%s = %g;%s", (*s)->name, (*s)->value.getFloat(), cat);
|
||||
break;
|
||||
default:
|
||||
expandEscape(expandBuffer, (*s)->getStringValue());
|
||||
|
|
@ -243,13 +243,11 @@ void Dictionary::exportVariables(const char *varString, Vector<String> *names, V
|
|||
|
||||
if (values)
|
||||
{
|
||||
switch ((*s)->value.type)
|
||||
switch ((*s)->value.getType())
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
values->push_back(String::ToString((*s)->value.ival));
|
||||
break;
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
values->push_back(String::ToString((*s)->value.fval));
|
||||
case ConsoleValueType::cvInteger:
|
||||
case ConsoleValueType::cvFloat:
|
||||
values->push_back(String((*s)->value.getString()));
|
||||
break;
|
||||
default:
|
||||
expandEscape(expandBuffer, (*s)->getStringValue());
|
||||
|
|
@ -470,7 +468,6 @@ char *typeValueEmpty = "";
|
|||
Dictionary::Entry::Entry(StringTableEntry in_name)
|
||||
{
|
||||
name = in_name;
|
||||
value.type = ConsoleValue::TypeInternalString;
|
||||
notify = NULL;
|
||||
nextEntry = NULL;
|
||||
mUsage = NULL;
|
||||
|
|
@ -508,150 +505,6 @@ const char *Dictionary::getVariable(StringTableEntry name, bool *entValid)
|
|||
return "";
|
||||
}
|
||||
|
||||
void ConsoleValue::setStringValue(const char * value)
|
||||
{
|
||||
if (value == NULL) value = typeValueEmpty;
|
||||
|
||||
if (type <= ConsoleValue::TypeInternalString)
|
||||
{
|
||||
// Let's not remove empty-string-valued global vars from the dict.
|
||||
// If we remove them, then they won't be exported, and sometimes
|
||||
// it could be necessary to export such a global. There are very
|
||||
// few empty-string global vars so there's no performance-related
|
||||
// need to remove them from the dict.
|
||||
/*
|
||||
if(!value[0] && name[0] == '$')
|
||||
{
|
||||
gEvalState.globalVars.remove(this);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
if (value == typeValueEmpty)
|
||||
{
|
||||
if (bufferLen > 0)
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
sval = typeValueEmpty;
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
type = TypeInternalString;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 stringLen = dStrlen(value);
|
||||
|
||||
// If it's longer than 256 bytes, it's certainly not a number.
|
||||
//
|
||||
// (This decision may come back to haunt you. Shame on you if it
|
||||
// does.)
|
||||
if (stringLen < 256)
|
||||
{
|
||||
fval = dAtof(value);
|
||||
ival = dAtoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
}
|
||||
|
||||
// may as well pad to the next cache line
|
||||
U32 newLen = ((stringLen + 1) + 15) & ~15;
|
||||
|
||||
if (bufferLen == 0)
|
||||
sval = (char *)dMalloc(newLen);
|
||||
else if (newLen > bufferLen)
|
||||
sval = (char *)dRealloc(sval, newLen);
|
||||
|
||||
type = TypeInternalString;
|
||||
|
||||
bufferLen = newLen;
|
||||
dStrcpy(sval, value, newLen);
|
||||
}
|
||||
else
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
}
|
||||
|
||||
|
||||
void ConsoleValue::setStackStringValue(const char *value)
|
||||
{
|
||||
if (value == NULL) value = typeValueEmpty;
|
||||
|
||||
if (type <= ConsoleValue::TypeInternalString)
|
||||
{
|
||||
// sval might still be temporarily present so we need to check and free it
|
||||
if (bufferLen > 0)
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
if (value == typeValueEmpty)
|
||||
{
|
||||
sval = typeValueEmpty;
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
type = TypeInternalString;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 stringLen = dStrlen(value);
|
||||
if (stringLen < 256)
|
||||
{
|
||||
fval = dAtof(value);
|
||||
ival = dAtoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
}
|
||||
|
||||
type = TypeInternalStackString;
|
||||
sval = (char*)value;
|
||||
bufferLen = 0;
|
||||
}
|
||||
else
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
}
|
||||
|
||||
void ConsoleValue::setStringStackPtrValue(StringStackPtr ptrValue)
|
||||
{
|
||||
if (type <= ConsoleValue::TypeInternalString)
|
||||
{
|
||||
const char *value = StringStackPtrRef(ptrValue).getPtr(&STR);
|
||||
if (bufferLen > 0)
|
||||
{
|
||||
dFree(sval);
|
||||
bufferLen = 0;
|
||||
}
|
||||
|
||||
U32 stringLen = dStrlen(value);
|
||||
if (stringLen < 256)
|
||||
{
|
||||
fval = dAtof(value);
|
||||
ival = dAtoi(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
fval = 0.f;
|
||||
ival = 0;
|
||||
}
|
||||
|
||||
type = TypeInternalStringStackPtr;
|
||||
sval = (char*)(value - STR.mBuffer);
|
||||
bufferLen = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *value = StringStackPtrRef(ptrValue).getPtr(&STR);
|
||||
Con::setData(type, dataPtr, 0, 1, &value, enumTable);
|
||||
}
|
||||
}
|
||||
|
||||
S32 Dictionary::getIntVariable(StringTableEntry name, bool *entValid)
|
||||
{
|
||||
Entry *ent = lookup(name);
|
||||
|
|
|
|||
|
|
@ -324,17 +324,17 @@ public:
|
|||
|
||||
inline U32 getIntValue()
|
||||
{
|
||||
return value.getIntValue();
|
||||
return value.getInt();
|
||||
}
|
||||
|
||||
inline F32 getFloatValue()
|
||||
{
|
||||
return value.getFloatValue();
|
||||
return value.getFloat();
|
||||
}
|
||||
|
||||
inline const char *getStringValue()
|
||||
{
|
||||
return value.getStringValue();
|
||||
return value.getString();
|
||||
}
|
||||
|
||||
void setIntValue(U32 val)
|
||||
|
|
@ -345,7 +345,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
value.setIntValue(val);
|
||||
value.setInt(val);
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if (notify)
|
||||
|
|
@ -360,23 +360,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
value.setFloatValue(val);
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if (notify)
|
||||
notify->trigger();
|
||||
}
|
||||
|
||||
void setStringStackPtrValue(StringStackPtr newValue)
|
||||
{
|
||||
if (mIsConstant)
|
||||
{
|
||||
Con::errorf("Cannot assign value to constant '%s'.", name);
|
||||
return;
|
||||
}
|
||||
|
||||
value.setStringStackPtrValue(newValue);
|
||||
|
||||
value.setFloat(val);
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if (notify)
|
||||
|
|
@ -391,8 +375,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
value.setStringValue(newValue);
|
||||
|
||||
value.setString(newValue, dStrlen(newValue));
|
||||
|
||||
// Fire off the notification if we have one.
|
||||
if (notify)
|
||||
|
|
@ -471,6 +454,18 @@ public:
|
|||
void validate();
|
||||
};
|
||||
|
||||
struct ConsoleValueFrame
|
||||
{
|
||||
ConsoleValue* values;
|
||||
bool isReference;
|
||||
|
||||
ConsoleValueFrame(ConsoleValue* vals, bool isRef)
|
||||
{
|
||||
values = vals;
|
||||
isReference = isRef;
|
||||
}
|
||||
};
|
||||
|
||||
class ExprEvalState
|
||||
{
|
||||
public:
|
||||
|
|
@ -499,6 +494,9 @@ public:
|
|||
/// an interior pointer that will become invalid when the object changes address.
|
||||
Vector< Dictionary* > stack;
|
||||
|
||||
Vector< ConsoleValueFrame > localStack;
|
||||
ConsoleValueFrame* currentRegisterArray; // contains array at to top of localStack
|
||||
|
||||
///
|
||||
Dictionary globalVars;
|
||||
|
||||
|
|
@ -511,10 +509,43 @@ public:
|
|||
void setIntVariable(S32 val);
|
||||
void setFloatVariable(F64 val);
|
||||
void setStringVariable(const char *str);
|
||||
void setStringStackPtrVariable(StringStackPtr str);
|
||||
void setCopyVariable();
|
||||
|
||||
void pushFrame(StringTableEntry frameName, Namespace *ns);
|
||||
TORQUE_FORCEINLINE S32 getLocalIntVariable(S32 reg)
|
||||
{
|
||||
return currentRegisterArray->values[reg].getInt();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE F64 getLocalFloatVariable(S32 reg)
|
||||
{
|
||||
return currentRegisterArray->values[reg].getFloat();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE const char* getLocalStringVariable(S32 reg)
|
||||
{
|
||||
return currentRegisterArray->values[reg].getString();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setLocalIntVariable(S32 reg, S64 val)
|
||||
{
|
||||
currentRegisterArray->values[reg].setInt(val);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setLocalFloatVariable(S32 reg, F64 val)
|
||||
{
|
||||
currentRegisterArray->values[reg].setFloat(val);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setLocalStringVariable(S32 reg, const char* val, S32 len)
|
||||
{
|
||||
currentRegisterArray->values[reg].setString(val, len);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void setLocalStringTableEntryVariable(S32 reg, StringTableEntry val)
|
||||
{
|
||||
currentRegisterArray->values[reg].setStringTableEntry(val);
|
||||
}
|
||||
|
||||
void pushFrame(StringTableEntry frameName, Namespace *ns, S32 regCount);
|
||||
void popFrame();
|
||||
|
||||
/// Puts a reference to an existing stack frame
|
||||
|
|
|
|||
|
|
@ -79,18 +79,18 @@ void ConsoleLogger::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool ConsoleLogger::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
bool ConsoleLogger::processArguments( S32 argc, ConsoleValue *argv )
|
||||
{
|
||||
if( argc == 0 )
|
||||
return false;
|
||||
|
||||
bool append = false;
|
||||
|
||||
if( argc == 2 )
|
||||
append = dAtob( argv[1] );
|
||||
if (argc == 2)
|
||||
append = argv[1].getBool();
|
||||
|
||||
mAppend = append;
|
||||
mFilename = StringTable->insert( argv[0] );
|
||||
mFilename = StringTable->insert( argv[0].getString() );
|
||||
|
||||
if( init() )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class ConsoleLogger : public SimObject
|
|||
/// // Example script constructor usage.
|
||||
/// %obj = new ConsoleLogger( objName, logFileName, [append = false] );
|
||||
/// @endcode
|
||||
bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
bool processArguments( S32 argc, ConsoleValue *argv );
|
||||
|
||||
/// Default constructor, make sure to initalize
|
||||
ConsoleLogger();
|
||||
|
|
|
|||
121
Engine/source/console/consoleValueStack.h
Normal file
121
Engine/source/console/consoleValueStack.h
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
// Copyright (c) 2013 GarageGames, LLC
|
||||
// Copyright (c) 2021 TGEMIT Authors & Contributors
|
||||
//
|
||||
// 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 _CONSOLE_CONSOLE_VALUE_STACK_H_
|
||||
#define _CONSOLE_CONSOLE_VALUE_STACK_H_
|
||||
|
||||
template<S32 StackSize>
|
||||
class ConsoleValueStack
|
||||
{
|
||||
constexpr static S32 allocatorSize = sizeof(ConsoleValue) * StackSize;
|
||||
|
||||
struct Frame
|
||||
{
|
||||
ConsoleValue* values;
|
||||
S32 count;
|
||||
S32 internalCounter;
|
||||
};
|
||||
|
||||
Vector<Frame> stack;
|
||||
char* memory;
|
||||
S32 sp;
|
||||
|
||||
TORQUE_FORCEINLINE Frame alloc(S32 count)
|
||||
{
|
||||
AssertFatal(sp + count * sizeof(ConsoleValue) < allocatorSize, "ConsoleValueStack overflow");
|
||||
|
||||
ConsoleValue* ret = reinterpret_cast<ConsoleValue*>(memory + sp);
|
||||
sp += count * sizeof(ConsoleValue);
|
||||
|
||||
return { ret, count, 1 };
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void deAlloc(S32 count)
|
||||
{
|
||||
sp -= count * sizeof(ConsoleValue);
|
||||
AssertFatal(sp >= 0, "Popped ConsoleValueStack too far, underflow");
|
||||
}
|
||||
|
||||
public:
|
||||
ConsoleValueStack()
|
||||
{
|
||||
memory = (char*)dMalloc(allocatorSize);
|
||||
for (S32 i = 0; i < allocatorSize; i += sizeof(ConsoleValue))
|
||||
{
|
||||
constructInPlace<ConsoleValue>(reinterpret_cast<ConsoleValue*>(memory + i));
|
||||
}
|
||||
sp = 0;
|
||||
}
|
||||
|
||||
~ConsoleValueStack()
|
||||
{
|
||||
dFree(memory);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void pushFrame(S32 count)
|
||||
{
|
||||
AssertISV(count >= 0, "Must be >= 0 when pushing stack frame");
|
||||
|
||||
// +1 for function name in argv[0]
|
||||
const Frame& frame = alloc(count + 1);
|
||||
stack.push_back(frame);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void popFrame()
|
||||
{
|
||||
AssertISV(stack.size() > 0, "Stack Underflow");
|
||||
|
||||
deAlloc(stack.last().count);
|
||||
stack.pop_back();
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void pushInt(S64 value)
|
||||
{
|
||||
Frame& frame = stack.last();
|
||||
frame.values[frame.internalCounter++].setInt(value);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void pushFloat(F64 value)
|
||||
{
|
||||
Frame& frame = stack.last();
|
||||
frame.values[frame.internalCounter++].setFloat(value);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void pushString(const char* value, S32 len)
|
||||
{
|
||||
Frame& frame = stack.last();
|
||||
frame.values[frame.internalCounter++].setString(value, len);
|
||||
}
|
||||
|
||||
TORQUE_FORCEINLINE void argvc(StringTableEntry fn, S32& argc, ConsoleValue** argv)
|
||||
{
|
||||
Frame& frame = stack.last();
|
||||
argc = frame.count;
|
||||
|
||||
// First param is always function name
|
||||
frame.values[0].setStringTableEntry(fn);
|
||||
*argv = frame.values;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -125,15 +125,12 @@ namespace Sim
|
|||
SimDataBlockGroup *getDataBlockGroup();
|
||||
SimGroup* getRootGroup();
|
||||
|
||||
SimObject* findObject(ConsoleValueRef&);
|
||||
SimObject* findObject(SimObjectId);
|
||||
SimObject* findObject(const ConsoleValue&);
|
||||
SimObject* findObject(ConsoleValue*);
|
||||
SimObject* findObject(const char* name);
|
||||
SimObject* findObject(const char* fileName, S32 declarationLine);
|
||||
template<class T> inline bool findObject(ConsoleValueRef &ref,T*&t)
|
||||
{
|
||||
t = dynamic_cast<T*>(findObject(ref));
|
||||
return t != NULL;
|
||||
}
|
||||
|
||||
template<class T> inline bool findObject(SimObjectId iD,T*&t)
|
||||
{
|
||||
t = dynamic_cast<T*>(findObject(iD));
|
||||
|
|
|
|||
|
|
@ -328,11 +328,6 @@ SimObject* findObject(const char* fileName, S32 declarationLine)
|
|||
return gRootGroup->findObjectByLineNumber(fileName, declarationLine, true);
|
||||
}
|
||||
|
||||
SimObject* findObject(ConsoleValueRef &ref)
|
||||
{
|
||||
return findObject((const char*)ref);
|
||||
}
|
||||
|
||||
SimObject* findObject(const char* name)
|
||||
{
|
||||
PROFILE_SCOPE(SimFindObject);
|
||||
|
|
@ -391,6 +386,24 @@ SimObject* findObject(const char* name)
|
|||
return obj->findObject(name + len + 1);
|
||||
}
|
||||
|
||||
SimObject* findObject(const ConsoleValue &val)
|
||||
{
|
||||
if (val.getType() == ConsoleValueType::cvNone)
|
||||
return NULL;
|
||||
if (val.getType() == ConsoleValueType::cvInteger)
|
||||
return findObject((SimObjectId)val.getInt());
|
||||
return findObject(val.getString());
|
||||
}
|
||||
|
||||
SimObject* findObject(ConsoleValue* val)
|
||||
{
|
||||
if (val->getType() == ConsoleValueType::cvNone)
|
||||
return NULL;
|
||||
if (val->getType() == ConsoleValueType::cvInteger)
|
||||
return findObject((SimObjectId)val->getInt());
|
||||
return findObject(val->getString());
|
||||
}
|
||||
|
||||
SimObject* findObject(SimObjectId id)
|
||||
{
|
||||
return gIdDictionary->find(id);
|
||||
|
|
|
|||
|
|
@ -229,11 +229,16 @@ void SimSet::scriptSort( const String &scriptCallbackFn )
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups )
|
||||
void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValue argv[], bool executeOnChildGroups )
|
||||
{
|
||||
// TODO(JTH): Implement
|
||||
AssertISV(false, "TODO Implement");
|
||||
return;
|
||||
|
||||
/*
|
||||
// Prep the arguments for the console exec...
|
||||
// Make sure and leave args[1] empty.
|
||||
ConsoleValueRef args[21] = { };
|
||||
ConsoleValue args[21] = { };
|
||||
ConsoleValue name_method;
|
||||
name_method.setStackStringValue(method.c_str());
|
||||
args[0] = ConsoleValueRef::fromValue(&name_method);
|
||||
|
|
@ -255,6 +260,7 @@ void SimSet::callOnChildren( const String &method, S32 argc, ConsoleValueRef arg
|
|||
childSet->callOnChildren( method, argc, argv, executeOnChildGroups );
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
@ -838,7 +844,7 @@ SimGroup* SimGroup::deepClone()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SimGroup::processArguments(S32, ConsoleValueRef *argv)
|
||||
bool SimGroup::processArguments(S32, ConsoleValue *argv)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -218,7 +218,7 @@ class SimSet : public SimObject, public TamlChildren
|
|||
|
||||
/// @}
|
||||
|
||||
void callOnChildren( const String &method, S32 argc, ConsoleValueRef argv[], bool executeOnChildGroups = true );
|
||||
void callOnChildren( const String &method, S32 argc, ConsoleValue argv[], bool executeOnChildGroups = true );
|
||||
|
||||
/// Return the number of objects in this set as well as all sets that are contained
|
||||
/// in this set and its children.
|
||||
|
|
@ -464,7 +464,7 @@ class SimGroup: public SimSet
|
|||
virtual SimObject* findObject(const char* name);
|
||||
virtual void onRemove();
|
||||
|
||||
virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
virtual bool processArguments( S32 argc, ConsoleValue *argv );
|
||||
|
||||
virtual SimObject* getObject(const S32& index);
|
||||
|
||||
|
|
|
|||
|
|
@ -207,228 +207,3 @@ void StringStack::clearFrames()
|
|||
mStartStackSize = 0;
|
||||
mFunctionOffset = 0;
|
||||
}
|
||||
|
||||
|
||||
void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame /* = false */)
|
||||
{
|
||||
U32 startStack = mStackFrames[mFrame-1];
|
||||
U32 argCount = getMin(mStackPos - startStack, (U32)MaxArgs - 1);
|
||||
|
||||
*in_argv = mArgv;
|
||||
mArgv[0].value = CSTK.pushStackString(name);
|
||||
|
||||
for(U32 i = 0; i < argCount; i++) {
|
||||
ConsoleValueRef *ref = &mArgv[i+1];
|
||||
ref->value = &mStack[startStack + i];
|
||||
}
|
||||
argCount++;
|
||||
|
||||
*argc = argCount;
|
||||
|
||||
if(popStackFrame)
|
||||
popFrame();
|
||||
}
|
||||
|
||||
ConsoleValueStack::ConsoleValueStack() :
|
||||
mFrame(0),
|
||||
mStackPos(0)
|
||||
{
|
||||
for (int i=0; i<ConsoleValueStack::MaxStackDepth; i++) {
|
||||
mStack[i].init();
|
||||
mStack[i].type = ConsoleValue::TypeInternalString;
|
||||
}
|
||||
dMemset(mStackFrames, 0, sizeof(mStackFrames));
|
||||
}
|
||||
|
||||
ConsoleValueStack::~ConsoleValueStack()
|
||||
{
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushVar(ConsoleValue *variable)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (variable->type)
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
mStack[mStackPos++].setIntValue((S32)variable->getIntValue());
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
mStack[mStackPos++].setFloatValue((F32)variable->getFloatValue());
|
||||
default:
|
||||
mStack[mStackPos++].setStackStringValue(variable->getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushValue(ConsoleValue &variable)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (variable.type)
|
||||
{
|
||||
case ConsoleValue::TypeInternalInt:
|
||||
mStack[mStackPos++].setIntValue((S32)variable.getIntValue());
|
||||
case ConsoleValue::TypeInternalFloat:
|
||||
mStack[mStackPos++].setFloatValue((F32)variable.getFloatValue());
|
||||
case ConsoleValue::TypeInternalStringStackPtr:
|
||||
mStack[mStackPos++].setStringStackPtrValue(variable.getStringStackPtr());
|
||||
default:
|
||||
mStack[mStackPos++].setStringValue(variable.getStringValue());
|
||||
}
|
||||
}
|
||||
|
||||
ConsoleValue* ConsoleValueStack::reserveValues(U32 count)
|
||||
{
|
||||
U32 startPos = mStackPos;
|
||||
if (startPos+count >= ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK reserveValues %i", mStackPos, count);
|
||||
mStackPos += count;
|
||||
return &mStack[startPos];
|
||||
}
|
||||
|
||||
bool ConsoleValueStack::reserveValues(U32 count, ConsoleValueRef *outValues)
|
||||
{
|
||||
U32 startPos = mStackPos;
|
||||
if (startPos+count >= ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK reserveValues %i", mStackPos, count);
|
||||
for (U32 i=0; i<count; i++)
|
||||
{
|
||||
outValues[i].value = &mStack[mStackPos+i];
|
||||
}
|
||||
mStackPos += count;
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushString(const char *value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushString %s", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setStringValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushStackString(const char *value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushString %s", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setStackStringValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushStringStackPtr(StringStackPtr value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushStringStackPtr %s", mStackPos, StringStackPtrRef(value).getPtr(&STR));
|
||||
|
||||
mStack[mStackPos++].setStringStackPtrValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushUINT(U32 value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushUINT %i", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setIntValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushFLT(float value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK pushFLT %f", mStackPos, value);
|
||||
|
||||
mStack[mStackPos++].setFloatValue(value);
|
||||
return &mStack[mStackPos-1];
|
||||
}
|
||||
|
||||
static ConsoleValue gNothing;
|
||||
|
||||
ConsoleValue* ConsoleValueStack::pop()
|
||||
{
|
||||
if (mStackPos == 0) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return &gNothing;
|
||||
}
|
||||
|
||||
return &mStack[--mStackPos];
|
||||
}
|
||||
|
||||
void ConsoleValueStack::pushFrame()
|
||||
{
|
||||
//Con::printf("CSTK pushFrame[%i] (%i)", mFrame, mStackPos);
|
||||
mStackFrames[mFrame++] = mStackPos;
|
||||
}
|
||||
|
||||
void ConsoleValueStack::resetFrame()
|
||||
{
|
||||
if (mFrame == 0) {
|
||||
mStackPos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 start = mStackFrames[mFrame-1];
|
||||
//for (U32 i=start; i<mStackPos; i++) {
|
||||
//mStack[i].clear();
|
||||
//}
|
||||
mStackPos = start;
|
||||
//Con::printf("CSTK resetFrame to %i", mStackPos);
|
||||
}
|
||||
|
||||
void ConsoleValueStack::clearFrames()
|
||||
{
|
||||
mStackPos = 0;
|
||||
mFrame = 0;
|
||||
}
|
||||
|
||||
void ConsoleValueStack::popFrame()
|
||||
{
|
||||
//Con::printf("CSTK popFrame");
|
||||
if (mFrame == 0) {
|
||||
// Go back to start
|
||||
mStackPos = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
U32 start = mStackFrames[mFrame-1];
|
||||
//for (U32 i=start; i<mStackPos; i++) {
|
||||
//mStack[i].clear();
|
||||
//}
|
||||
mStackPos = start;
|
||||
mFrame--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,51 +189,7 @@ struct StringStack
|
|||
void getArgcArgv(StringTableEntry name, U32 *argc, const char ***in_argv, bool popStackFrame = false);
|
||||
};
|
||||
|
||||
|
||||
// New console value stack
|
||||
class ConsoleValueStack
|
||||
{
|
||||
enum {
|
||||
MaxStackDepth = 1024,
|
||||
MaxArgs = 20,
|
||||
ReturnBufferSpace = 512
|
||||
};
|
||||
|
||||
public:
|
||||
ConsoleValueStack();
|
||||
~ConsoleValueStack();
|
||||
|
||||
void pushVar(ConsoleValue *variable);
|
||||
void pushValue(ConsoleValue &value);
|
||||
ConsoleValue* reserveValues(U32 numValues);
|
||||
bool reserveValues(U32 numValues, ConsoleValueRef *values);
|
||||
ConsoleValue* pop();
|
||||
|
||||
ConsoleValue *pushString(const char *value);
|
||||
ConsoleValue *pushStackString(const char *value);
|
||||
ConsoleValue *pushStringStackPtr(StringStackPtr ptr);
|
||||
ConsoleValue *pushUINT(U32 value);
|
||||
ConsoleValue *pushFLT(float value);
|
||||
|
||||
void pushFrame();
|
||||
void popFrame();
|
||||
|
||||
void resetFrame();
|
||||
void clearFrames();
|
||||
|
||||
void getArgcArgv(StringTableEntry name, U32 *argc, ConsoleValueRef **in_argv, bool popStackFrame = false);
|
||||
|
||||
ConsoleValue mStack[MaxStackDepth];
|
||||
U32 mStackFrames[MaxStackDepth];
|
||||
|
||||
U32 mFrame;
|
||||
U32 mStackPos;
|
||||
|
||||
ConsoleValueRef mArgv[MaxArgs];
|
||||
};
|
||||
|
||||
extern StringStack STR;
|
||||
extern ConsoleValueStack CSTK;
|
||||
|
||||
inline char* StringStackPtrRef::getPtr(StringStack *stk) { return stk->mBuffer + mOffset; }
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
// IN THE SOFTWARE.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifdef 0
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "platform/platform.h"
|
||||
|
|
@ -393,3 +394,4 @@ TEST(Script, Basic_Package)
|
|||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#ifdef 0
|
||||
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "platform/platform.h"
|
||||
|
|
@ -253,3 +255,4 @@ TEST(Con, execute)
|
|||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
#if 0
|
||||
#ifdef TORQUE_TESTS_ENABLED
|
||||
#include "testing/unitTesting.h"
|
||||
#include "platform/platform.h"
|
||||
|
|
@ -147,4 +148,5 @@ TEST(EngineAPI, _EngineConsoleExecCallbackHelper)
|
|||
"All values should be printed in the correct order";
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -200,6 +200,11 @@ inline F64 dAtod(const char *str)
|
|||
return strtod(str, NULL);
|
||||
}
|
||||
|
||||
inline S64 dAtol(const char* str)
|
||||
{
|
||||
return strtol(str, NULL, 10);
|
||||
}
|
||||
|
||||
inline char dToupper(const char c)
|
||||
{
|
||||
return toupper( c );
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ void WaterObject::inspectPostApply()
|
|||
setMaskBits( UpdateMask | WaveMask | TextureMask | SoundMask );
|
||||
}
|
||||
|
||||
bool WaterObject::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
bool WaterObject::processArguments( S32 argc, ConsoleValue *argv )
|
||||
{
|
||||
if( typeid( *this ) == typeid( WaterObject ) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ public:
|
|||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
virtual void inspectPostApply();
|
||||
virtual bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
virtual bool processArguments(S32 argc, ConsoleValue *argv);
|
||||
|
||||
// NetObject
|
||||
virtual U32 packUpdate( NetConnection * conn, U32 mask, BitStream *stream );
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ void GuiControl::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool GuiControl::processArguments(S32 argc, ConsoleValueRef *argv)
|
||||
bool GuiControl::processArguments(S32 argc, ConsoleValue *argv)
|
||||
{
|
||||
// argv[0] - The GuiGroup to add this control to when it's created.
|
||||
// this is an optional parameter that may be specified at
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ class GuiControl : public SimGroup
|
|||
|
||||
GuiControl();
|
||||
virtual ~GuiControl();
|
||||
virtual bool processArguments(S32 argc, ConsoleValueRef *argv);
|
||||
virtual bool processArguments(S32 argc, ConsoleValue *argv);
|
||||
|
||||
static void initPersistFields();
|
||||
static void consoleInit();
|
||||
|
|
|
|||
|
|
@ -2858,17 +2858,17 @@ void WorldEditor::initPersistFields()
|
|||
//------------------------------------------------------------------------------
|
||||
// These methods are needed for the console interfaces.
|
||||
|
||||
void WorldEditor::ignoreObjClass( U32 argc, ConsoleValueRef *argv )
|
||||
void WorldEditor::ignoreObjClass( U32 argc, ConsoleValue *argv )
|
||||
{
|
||||
for(S32 i = 2; i < argc; i++)
|
||||
{
|
||||
ClassInfo::Entry * entry = getClassEntry(argv[i]);
|
||||
ClassInfo::Entry * entry = getClassEntry(argv[i].getString());
|
||||
if(entry)
|
||||
entry->mIgnoreCollision = true;
|
||||
else
|
||||
{
|
||||
entry = new ClassInfo::Entry;
|
||||
entry->mName = StringTable->insert(argv[i]);
|
||||
entry->mName = StringTable->insert(argv[i].getString());
|
||||
entry->mIgnoreCollision = true;
|
||||
if(!addClassEntry(entry))
|
||||
delete entry;
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class WorldEditor : public EditTSCtrl
|
|||
Point3F p2;
|
||||
};
|
||||
|
||||
void ignoreObjClass(U32 argc, ConsoleValueRef* argv);
|
||||
void ignoreObjClass(U32 argc, ConsoleValue* argv);
|
||||
void clearIgnoreList();
|
||||
|
||||
static bool setObjectsUseBoxCenter( void *object, const char *index, const char *data ) { static_cast<WorldEditor*>(object)->setObjectsUseBoxCenter( dAtob( data ) ); return false; };
|
||||
|
|
|
|||
|
|
@ -55,31 +55,36 @@ DefineEngineStringlyVariadicFunction( mathInit, void, 1, 10, "( ... )"
|
|||
}
|
||||
for (argc--, argv++; argc; argc--, argv++)
|
||||
{
|
||||
if (dStricmp(*argv, "DETECT") == 0) {
|
||||
const char* str = (*argv).getString();
|
||||
if (dStricmp(str, "DETECT") == 0) {
|
||||
Math::init(0);
|
||||
return;
|
||||
}
|
||||
if (dStricmp(*argv, "C") == 0) {
|
||||
if (dStricmp(str, "C") == 0) {
|
||||
properties |= CPU_PROP_C;
|
||||
continue;
|
||||
}
|
||||
if (dStricmp(*argv, "FPU") == 0) {
|
||||
if (dStricmp(str, "FPU") == 0) {
|
||||
properties |= CPU_PROP_FPU;
|
||||
continue;
|
||||
}
|
||||
if (dStricmp(*argv, "MMX") == 0) {
|
||||
if (dStricmp(str, "MMX") == 0) {
|
||||
properties |= CPU_PROP_MMX;
|
||||
continue;
|
||||
}
|
||||
if (dStricmp(*argv, "3DNOW") == 0) {
|
||||
if (dStricmp(str, "3DNOW") == 0) {
|
||||
properties |= CPU_PROP_3DNOW;
|
||||
continue;
|
||||
}
|
||||
if (dStricmp(*argv, "SSE") == 0) {
|
||||
if (dStricmp(str, "SSE") == 0) {
|
||||
properties |= CPU_PROP_SSE;
|
||||
continue;
|
||||
}
|
||||
Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", argv->getStringValue());
|
||||
if (dStricmp(str, "SSE2") == 0) {
|
||||
properties |= CPU_PROP_SSE2;
|
||||
continue;
|
||||
}
|
||||
Con::printf("Error: MathInit(): ignoring unknown math extension '%s'", str);
|
||||
}
|
||||
Math::init(properties);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -316,7 +316,7 @@ void SFXSource::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SFXSource::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
bool SFXSource::processArguments( S32 argc, ConsoleValue *argv )
|
||||
{
|
||||
// Don't allow subclasses of this to be created via script. Force
|
||||
// usage of the SFXSystem functions.
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ class SFXSource : public SimGroup
|
|||
|
||||
/// We overload this to disable creation of
|
||||
/// a source via script 'new'.
|
||||
virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
virtual bool processArguments( S32 argc, ConsoleValue *argv );
|
||||
|
||||
// Console getters/setters.
|
||||
static bool _setDescription( void *obj, const char *index, const char *data );
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ void SFXTrack::initPersistFields()
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool SFXTrack::processArguments( S32 argc, ConsoleValueRef *argv )
|
||||
bool SFXTrack::processArguments( S32 argc, ConsoleValue *argv )
|
||||
{
|
||||
if( typeid( *this ) == typeid( SFXTrack ) )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class SFXTrack : public SimDataBlock
|
|||
StringTableEntry mParameters[ MaxNumParameters ];
|
||||
|
||||
/// Overload this to disable direct instantiation of this class via script 'new'.
|
||||
virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
|
||||
virtual bool processArguments( S32 argc, ConsoleValue *argv );
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@ void CustomFeatureGLSL::addVertTexCoord(String name)
|
|||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
|
||||
void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValue * argv)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Vector<Var*> varList;
|
||||
|
|
@ -246,7 +246,7 @@ void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg
|
|||
|
||||
for (U32 i = 0; i < argc; i++)
|
||||
{
|
||||
String varName = argv[i].getStringValue();
|
||||
String varName = argv[i].getString();
|
||||
Var* newVar = (Var*)LangElement::find(varName.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
|
|
@ -304,7 +304,7 @@ void CustomFeatureGLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg
|
|||
if (!newVar)
|
||||
{
|
||||
//couldn't find that variable, bail out
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,5 +128,5 @@ public:
|
|||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String type, String elementName);
|
||||
void addVertTexCoord(String name);
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef* argv);
|
||||
void writeLine(String format, S32 argc, ConsoleValue* argv);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ void CustomFeatureHLSL::addVertTexCoord(String name)
|
|||
mVars.push_back(newVarHolder);
|
||||
}
|
||||
|
||||
void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * argv)
|
||||
void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValue *argv)
|
||||
{
|
||||
//do the var/arg fetching here
|
||||
Vector<Var*> varList;
|
||||
|
|
@ -393,7 +393,7 @@ void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg
|
|||
|
||||
for (U32 i = 0; i < argc; i++)
|
||||
{
|
||||
String varName = argv[i].getStringValue();
|
||||
String varName = argv[i].getString();
|
||||
Var* newVar = (Var*)LangElement::find(varName.c_str());
|
||||
if (!newVar)
|
||||
{
|
||||
|
|
@ -451,7 +451,7 @@ void CustomFeatureHLSL::writeLine(String format, S32 argc, ConsoleValueRef * arg
|
|||
if (!newVar)
|
||||
{
|
||||
//couldn't find that variable, bail out
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getStringValue());
|
||||
Con::errorf("CustomShaderFeature::writeLine: unable to find variable %s, meaning it was not declared before being used!", argv[i].getString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,5 +128,5 @@ public:
|
|||
void addTexture(String name, String type, String samplerState, U32 arraySize);
|
||||
void addConnector(String name, String type, String elementName);
|
||||
void addVertTexCoord(String name);
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef* argv);
|
||||
void writeLine(String format, S32 argc, ConsoleValue* argv);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ bool CustomShaderFeatureData::hasFeature(String name)
|
|||
return false;
|
||||
}
|
||||
|
||||
void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValueRef* argv)
|
||||
void CustomShaderFeatureData::writeLine(String format, S32 argc, ConsoleValue* argv)
|
||||
{
|
||||
#ifdef TORQUE_D3D11
|
||||
if (GFX->getAdapterType() == GFXAdapterType::Direct3D11)
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public:
|
|||
void addVertTexCoord(String name);
|
||||
bool hasFeature(String name);
|
||||
|
||||
void writeLine(String format, S32 argc, ConsoleValueRef *argv);
|
||||
void writeLine(String format, S32 argc, ConsoleValue *argv);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue