mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 19:53:48 +00:00
Beginnings of the "pass everything using a native type wrapper" console code.
- ConsoleValue class is now the base value class. - ConsoleValueRef is now used to supply function parameters. Values are disposable. - Script functions return values instead of just strings where possible. - Variables can be disposable strings - Bytecode changed Fix the issues with console method parameters and fields which prevented missions from loading.
This commit is contained in:
parent
394d87cd54
commit
38c8e52c1d
68 changed files with 1511 additions and 529 deletions
|
|
@ -236,7 +236,14 @@ U32 ExprNode::compileStmt(U32 *codeStream, U32 ip, U32, U32)
|
|||
U32 ReturnStmtNode::precompileStmt(U32)
|
||||
{
|
||||
addBreakCount();
|
||||
return 1 + (expr ? expr->precompile(TypeReqString) : 0);
|
||||
U32 size = 0;
|
||||
if (expr) {
|
||||
TypeReq walkType = expr->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
size = expr->precompile(walkType);
|
||||
}
|
||||
|
||||
return 1 + size;
|
||||
}
|
||||
|
||||
U32 ReturnStmtNode::compileStmt(U32 *codeStream, U32 ip, U32, U32)
|
||||
|
|
@ -246,8 +253,22 @@ U32 ReturnStmtNode::compileStmt(U32 *codeStream, U32 ip, U32, U32)
|
|||
codeStream[ip++] = OP_RETURN_VOID;
|
||||
else
|
||||
{
|
||||
ip = expr->compile(codeStream, ip, TypeReqString);
|
||||
codeStream[ip++] = OP_RETURN;
|
||||
TypeReq walkType = expr->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
ip = expr->compile(codeStream, ip, walkType);
|
||||
|
||||
// Return the correct type
|
||||
switch (walkType) {
|
||||
case TypeReqUInt:
|
||||
codeStream[ip++] = OP_RETURN_UINT;
|
||||
break;
|
||||
case TypeReqFloat:
|
||||
codeStream[ip++] = OP_RETURN_FLT;
|
||||
break;
|
||||
default:
|
||||
codeStream[ip++] = OP_RETURN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return ip;
|
||||
}
|
||||
|
|
@ -1347,8 +1368,11 @@ U32 FuncCallExprNode::precompile(TypeReq type)
|
|||
size++;
|
||||
precompileIdent(funcName);
|
||||
precompileIdent(nameSpace);
|
||||
for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext())
|
||||
size += walk->precompile(TypeReqString) + 1;
|
||||
for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext()) {
|
||||
TypeReq walkType = walk->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
size += walk->precompile(walkType) + 1;
|
||||
}
|
||||
return size + 5;
|
||||
}
|
||||
|
||||
|
|
@ -1357,8 +1381,20 @@ U32 FuncCallExprNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|||
codeStream[ip++] = OP_PUSH_FRAME;
|
||||
for(ExprNode *walk = args; walk; walk = (ExprNode *) walk->getNext())
|
||||
{
|
||||
ip = walk->compile(codeStream, ip, TypeReqString);
|
||||
codeStream[ip++] = OP_PUSH;
|
||||
TypeReq walkType = walk->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
ip = walk->compile(codeStream, ip, walkType);
|
||||
switch (walk->getPreferredType()) {
|
||||
case TypeReqFloat:
|
||||
codeStream[ip++] = OP_PUSH_FLT;
|
||||
break;
|
||||
case TypeReqUInt:
|
||||
codeStream[ip++] = OP_PUSH_UINT;
|
||||
break;
|
||||
default:
|
||||
codeStream[ip++] = OP_PUSH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(callType == MethodCall || callType == ParentCall)
|
||||
codeStream[ip++] = OP_CALLFUNC;
|
||||
|
|
@ -1729,8 +1765,11 @@ U32 ObjectDeclNode::precompileSubObject(bool)
|
|||
|
||||
U32 argSize = 0;
|
||||
precompileIdent(parentObject);
|
||||
for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext())
|
||||
argSize += exprWalk->precompile(TypeReqString) + 1;
|
||||
for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext()) {
|
||||
TypeReq walkType = exprWalk->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
argSize += exprWalk->precompile(walkType) + 1;
|
||||
}
|
||||
argSize += classNameExpr->precompile(TypeReqString) + 1;
|
||||
|
||||
U32 nameSize = objectNameExpr->precompile(TypeReqString) + 1;
|
||||
|
|
@ -1775,8 +1814,20 @@ U32 ObjectDeclNode::compileSubObject(U32 *codeStream, U32 ip, bool root)
|
|||
codeStream[ip++] = OP_PUSH;
|
||||
for(ExprNode *exprWalk = argList; exprWalk; exprWalk = (ExprNode *) exprWalk->getNext())
|
||||
{
|
||||
ip = exprWalk->compile(codeStream, ip, TypeReqString);
|
||||
codeStream[ip++] = OP_PUSH;
|
||||
TypeReq walkType = exprWalk->getPreferredType();
|
||||
if (walkType == TypeReqNone) walkType = TypeReqString;
|
||||
ip = exprWalk->compile(codeStream, ip, walkType);
|
||||
switch (exprWalk->getPreferredType()) {
|
||||
case TypeReqFloat:
|
||||
codeStream[ip++] = OP_PUSH_FLT;
|
||||
break;
|
||||
case TypeReqUInt:
|
||||
codeStream[ip++] = OP_PUSH_UINT;
|
||||
break;
|
||||
default:
|
||||
codeStream[ip++] = OP_PUSH;
|
||||
break;
|
||||
}
|
||||
}
|
||||
codeStream[ip++] = OP_CREATE_OBJECT;
|
||||
codeStream[ip] = STEtoU32(parentObject, ip);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue