@@ -405,7 +405,6 @@ U32 VectorIndexNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
405405 ip = innerVec->compile (codeStream, ip, TypeReqVector);
406406 else
407407 ip = base->compile (codeStream, ip, TypeReqVector);
408-
409408 // Compile index
410409 ip = index->compile (codeStream, ip, TypeReqUInt);
411410
@@ -752,22 +751,29 @@ U32 VarNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
752751 }
753752 else
754753 {
754+ // Compile the index expression
755+ ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
756+
757+ // Load the base vector
755758 if (isGlobal)
756759 {
757760 codeStream.emit (OP_SETCURVAR);
758761 codeStream.emitSTE (varName);
759- codeStream.emit (OP_LOADVAR_VECTOR);
762+ }
763+
764+ // Emit the correct vector member load opcode
765+ if (isGlobal)
766+ {
767+ codeStream.emit (OP_LOADVAR_VECTOR_MEMBER_GLOBAL);
768+ codeStream.emit (type);
760769 }
761770 else
762771 {
763- codeStream.emit (OP_LOAD_LOCAL_VAR_VECTOR);
772+ codeStream.emit (OP_LOADVAR_VECTOR_MEMBER_LOCAL);
773+ codeStream.emit (type);
764774 codeStream.emit (getFuncVars (dbgLineNumber)->lookup (varName, dbgLineNumber, TypeReqVector));
765775 }
766776
767- ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
768- codeStream.emit (OP_LOADVAR_VECTOR_MEMBER);
769- codeStream.emit (type);
770-
771777 return codeStream.tell ();
772778 }
773779 }
@@ -1089,6 +1095,8 @@ U32 AssignExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
10891095 return ip;
10901096 }
10911097
1098+ ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1099+
10921100 if (isGlobal)
10931101 {
10941102 codeStream.emit (OP_SETCURVAR_CREATE);
@@ -1097,10 +1105,10 @@ U32 AssignExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
10971105 if (!ent)
10981106 {
10991107 ent = Con::gGlobalVars .add (varName);
1100- ent->setVectorValue (new Vector<ConsoleValue>() );
1108+ ent->setVectorValue (NULL );
11011109 }
11021110
1103- codeStream.emit (OP_LOADVAR_VECTOR );
1111+ codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER_GLOBAL );
11041112 }
11051113 else // the issue with locals is that the framestack only exists after the op_ codes are run.
11061114 {
@@ -1109,12 +1117,10 @@ U32 AssignExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
11091117 getFuncVars (dbgLineNumber)->assign (varName, TypeReqVector, dbgLineNumber);
11101118 }
11111119
1112- codeStream.emit (OP_LOAD_LOCAL_VAR_VECTOR );
1120+ codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER_LOCAL );
11131121 codeStream.emit (getFuncVars (dbgLineNumber)->lookup (varName, dbgLineNumber, TypeReqVector));
11141122 }
11151123
1116- ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1117- codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER);
11181124 return ip;
11191125 }
11201126 }
@@ -1308,6 +1314,8 @@ U32 AssignOpExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
13081314 }
13091315 else
13101316 {
1317+ ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1318+
13111319 if (isGlobal)
13121320 {
13131321 codeStream.emit (OP_SETCURVAR_CREATE);
@@ -1316,10 +1324,11 @@ U32 AssignOpExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
13161324 if (!ent)
13171325 {
13181326 ent = Con::gGlobalVars .add (varName);
1319- ent->setVectorValue (new Vector<ConsoleValue>() );
1327+ ent->setVectorValue (NULL );
13201328 }
13211329
1322- codeStream.emit (OP_LOADVAR_VECTOR);
1330+ codeStream.emit (OP_LOADVAR_VECTOR_MEMBER_GLOBAL);
1331+ codeStream.emit (subType);
13231332 }
13241333 else // the issue with locals is that the framestack only exists after the op_ codes are run.
13251334 {
@@ -1332,32 +1341,29 @@ U32 AssignOpExprNode::compile(CodeStream& codeStream, U32 ip, TypeReq type)
13321341 getFuncVars (dbgLineNumber)->assign (varName, TypeReqVector, dbgLineNumber);
13331342 }
13341343
1335- codeStream.emit (OP_LOAD_LOCAL_VAR_VECTOR);
1344+ codeStream.emit (OP_LOADVAR_VECTOR_MEMBER_LOCAL);
1345+ codeStream.emit (subType);
13361346 codeStream.emit (getFuncVars (dbgLineNumber)->lookup (varName, dbgLineNumber, TypeReqVector));
13371347 }
13381348
1339- ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1340- // Load element at index
1341- codeStream.emit (OP_LOADVAR_VECTOR_MEMBER);
1342- codeStream.emit (subType);
13431349 ip = expr->compile (codeStream, ip, subType);
13441350 codeStream.emit (operand);
13451351 codeStream.emit ((subType == TypeReqFloat) ? OP_LOADVAR_FLT : OP_LOADVAR_UINT);
13461352
1353+ ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1354+
13471355 if (isGlobal)
13481356 {
1349- codeStream.emit (OP_LOADVAR_VECTOR);
1357+ codeStream.emit (OP_SETCURVAR_CREATE);
1358+ codeStream.emitSTE (varName);
1359+ codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER_GLOBAL);
13501360 }
1351- else
1361+ else // the issue with locals is that the framestack only exists after the op_ codes are run.
13521362 {
1353- codeStream.emit (OP_LOAD_LOCAL_VAR_VECTOR );
1363+ codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER_LOCAL );
13541364 codeStream.emit (getFuncVars (dbgLineNumber)->lookup (varName, dbgLineNumber, TypeReqVector));
13551365 }
13561366
1357- ip = arrayIndex->compile (codeStream, ip, TypeReqUInt);
1358-
1359- codeStream.emit (OP_SETCURVAR_VECTOR_MEMBER);
1360-
13611367 if (type == TypeReqNone)
13621368 codeStream.emit (OP_POP_STK);
13631369
0 commit comments