|
@@ -134,6 +134,8 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
|
|
|
return OP_STR_TO_FLT;
|
|
|
case TypeReqNone:
|
|
|
return OP_STR_TO_NONE;
|
|
|
+ case TypeReqVar:
|
|
|
+ return OP_SAVEVAR_STR;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -148,6 +150,8 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
|
|
|
return OP_FLT_TO_STR;
|
|
|
case TypeReqNone:
|
|
|
return OP_FLT_TO_NONE;
|
|
|
+ case TypeReqVar:
|
|
|
+ return OP_SAVEVAR_FLT;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -162,6 +166,24 @@ static U32 conversionOp(TypeReq src, TypeReq dst)
|
|
|
return OP_UINT_TO_STR;
|
|
|
case TypeReqNone:
|
|
|
return OP_UINT_TO_NONE;
|
|
|
+ case TypeReqVar:
|
|
|
+ return OP_SAVEVAR_UINT;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if(src == TypeReqVar)
|
|
|
+ {
|
|
|
+ switch(dst)
|
|
|
+ {
|
|
|
+ case TypeReqUInt:
|
|
|
+ return OP_LOADVAR_UINT;
|
|
|
+ case TypeReqFloat:
|
|
|
+ return OP_LOADVAR_FLT;
|
|
|
+ case TypeReqString:
|
|
|
+ return OP_LOADVAR_STR;
|
|
|
+ case TypeReqNone:
|
|
|
+ return OP_COPYVAR_TO_NONE;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
@@ -872,6 +894,7 @@ U32 VarNode::precompile(TypeReq type)
|
|
|
return (arrayIndex ? arrayIndex->precompile(TypeReqString) + 6 : 3);
|
|
|
}
|
|
|
|
|
|
+// Puts value of VarNode onto StringStack/intStack/fltStack
|
|
|
U32 VarNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|
|
{
|
|
|
if(type == TypeReqNone)
|
|
@@ -882,10 +905,11 @@ U32 VarNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|
|
ip++;
|
|
|
if(arrayIndex)
|
|
|
{
|
|
|
+ // NOTE: in this case we have the start value loaded into STR
|
|
|
codeStream[ip++] = OP_ADVANCE_STR;
|
|
|
- ip = arrayIndex->compile(codeStream, ip, TypeReqString);
|
|
|
- codeStream[ip++] = OP_REWIND_STR;
|
|
|
- codeStream[ip++] = OP_SETCURVAR_ARRAY;
|
|
|
+ ip = arrayIndex->compile(codeStream, ip, TypeReqString); // Add on extra bits
|
|
|
+ codeStream[ip++] = OP_REWIND_STR; // Go back to start
|
|
|
+ codeStream[ip++] = OP_SETCURVAR_ARRAY; // Set variable name
|
|
|
}
|
|
|
switch(type)
|
|
|
{
|
|
@@ -898,8 +922,13 @@ U32 VarNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|
|
case TypeReqString:
|
|
|
codeStream[ip++] = OP_LOADVAR_STR;
|
|
|
break;
|
|
|
+ case TypeReqVar:
|
|
|
+ codeStream[ip++] = OP_LOADVAR_VAR;
|
|
|
+ break;
|
|
|
case TypeReqNone:
|
|
|
break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
return ip;
|
|
|
}
|
|
@@ -1105,8 +1134,15 @@ U32 AssignExprNode::precompile(TypeReq type)
|
|
|
subType = expr->getPreferredType();
|
|
|
if(subType == TypeReqNone)
|
|
|
subType = type;
|
|
|
- if(subType == TypeReqNone)
|
|
|
- subType = TypeReqString;
|
|
|
+ if(subType == TypeReqNone) {
|
|
|
+ // jamesu - what we need to do in this case is turn it into a VarNode reference
|
|
|
+ if (dynamic_cast<VarNode*>(expr) != NULL) {
|
|
|
+ // Sanity check passed
|
|
|
+ subType = TypeReqVar;
|
|
|
+ } else {
|
|
|
+ subType = TypeReqString;
|
|
|
+ }
|
|
|
+ }
|
|
|
// if it's an array expr, the formula is:
|
|
|
// eval expr
|
|
|
// (push and pop if it's TypeReqString) OP_ADVANCE_STR
|
|
@@ -1139,7 +1175,7 @@ U32 AssignExprNode::precompile(TypeReq type)
|
|
|
|
|
|
U32 AssignExprNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|
|
{
|
|
|
- ip = expr->compile(codeStream, ip, subType);
|
|
|
+ ip = expr->compile(codeStream, ip, subType); // this is the value of VarNode
|
|
|
if(arrayIndex)
|
|
|
{
|
|
|
if(subType == TypeReqString)
|
|
@@ -1172,6 +1208,9 @@ U32 AssignExprNode::compile(U32 *codeStream, U32 ip, TypeReq type)
|
|
|
case TypeReqFloat:
|
|
|
codeStream[ip++] = OP_SAVEVAR_FLT;
|
|
|
break;
|
|
|
+ case TypeReqVar:
|
|
|
+ codeStream[ip++] = OP_SAVEVAR_VAR;
|
|
|
+ break;
|
|
|
case TypeReqNone:
|
|
|
break;
|
|
|
}
|