Sfoglia il codice sorgente

Fix handling parameters passed to printf

mingodad 8 anni fa
parent
commit
b79f7cb955
3 ha cambiato i file con 15 aggiunte e 14 eliminazioni
  1. 1 1
      SquiLu/squirrel/sqdebug.cpp
  2. 11 11
      SquiLu/squirrel/sqfuncstate.cpp
  3. 3 2
      SquiLu/squirrel/sqvm.cpp

+ 1 - 1
SquiLu/squirrel/sqdebug.cpp

@@ -107,7 +107,7 @@ void SQVM::Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger ty
 	SQInteger found = 0;
 	SQInteger found = 0;
 	for(SQInteger i=0; i<16; i++)
 	for(SQInteger i=0; i<16; i++)
 	{
 	{
-		SQInteger mask = 0x00000001 << i;
+		SQInteger mask = ((SQInteger)1) << i;
 		if(typemask & (mask)) {
 		if(typemask & (mask)) {
 			if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes);
 			if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes);
 			found ++;
 			found ++;

+ 11 - 11
SquiLu/squirrel/sqfuncstate.cpp

@@ -47,8 +47,8 @@ void SQFuncState::Dump(SQFunctionProto *func)
 {
 {
 	SQUnsignedInteger n=0,i;
 	SQUnsignedInteger n=0,i;
 	SQInteger si;
 	SQInteger si;
-	scprintf(_SC("SQInstruction sizeof %d\n"),sizeof(SQInstruction));
-	scprintf(_SC("SQObject sizeof %d\n"),sizeof(SQObject));
+	scprintf(_SC("SQInstruction sizeof %d\n"),(SQInt32)sizeof(SQInstruction));
+	scprintf(_SC("SQObject sizeof %d\n"),(SQInt32)sizeof(SQObject));
 	scprintf(_SC("--------------------------------------------------------------------\n"));
 	scprintf(_SC("--------------------------------------------------------------------\n"));
 	scprintf(_SC("*****FUNCTION [%s]\n"),sqtype(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
 	scprintf(_SC("*****FUNCTION [%s]\n"),sqtype(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
 	scprintf(_SC("-----LITERALS\n"));
 	scprintf(_SC("-----LITERALS\n"));
@@ -61,7 +61,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
 		templiterals[_integer(val)]=key;
 		templiterals[_integer(val)]=key;
 	}
 	}
 	for(i=0;i<templiterals.size();i++){
 	for(i=0;i<templiterals.size();i++){
-		scprintf(_SC("[%d] "),n);
+		scprintf(_SC("[%d] "),(SQInt32)n);
 		DumpLiteral(templiterals[i]);
 		DumpLiteral(templiterals[i]);
 		scprintf(_SC("\n"));
 		scprintf(_SC("\n"));
 		n++;
 		n++;
@@ -71,7 +71,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
 		scprintf(_SC("<<VARPARAMS>>\n"));
 		scprintf(_SC("<<VARPARAMS>>\n"));
 	n=0;
 	n=0;
 	for(i=0;i<_parameters.size();i++){
 	for(i=0;i<_parameters.size();i++){
-		scprintf(_SC("[%d] "),n);
+		scprintf(_SC("[%d] "),(SQInt32)n);
 		DumpLiteral(_parameters[i]);
 		DumpLiteral(_parameters[i]);
 		scprintf(_SC("\n"));
 		scprintf(_SC("\n"));
 		n++;
 		n++;
@@ -79,13 +79,13 @@ void SQFuncState::Dump(SQFunctionProto *func)
 	scprintf(_SC("-----LOCALS\n"));
 	scprintf(_SC("-----LOCALS\n"));
 	for(si=0;si<func->_nlocalvarinfos;si++){
 	for(si=0;si<func->_nlocalvarinfos;si++){
 		SQLocalVarInfo lvi=func->_localvarinfos[si];
 		SQLocalVarInfo lvi=func->_localvarinfos[si];
-		scprintf(_SC("[%d] %s \t%d %d\n"),lvi._pos,_stringval(lvi._name),lvi._start_op,lvi._end_op);
+		scprintf(_SC("[%d] %s \t%d %d\n"),(SQInt32)lvi._pos,_stringval(lvi._name),(SQInt32)lvi._start_op,(SQInt32)lvi._end_op);
 		n++;
 		n++;
 	}
 	}
 	scprintf(_SC("-----LINE INFO\n"));
 	scprintf(_SC("-----LINE INFO\n"));
 	for(i=0;i<_lineinfos.size();i++){
 	for(i=0;i<_lineinfos.size();i++){
 		SQLineInfo li=_lineinfos[i];
 		SQLineInfo li=_lineinfos[i];
-		scprintf(_SC("op [%d] line [%d] \n"),li._op,li._line);
+		scprintf(_SC("op [%d] line [%d] \n"),(SQInt32)li._op,(SQInt32)li._line);
 		n++;
 		n++;
 	}
 	}
 	scprintf(_SC("-----dump\n"));
 	scprintf(_SC("-----dump\n"));
@@ -95,7 +95,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
 		if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){
 		if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){
 
 
 			SQInteger lidx = inst._arg1;
 			SQInteger lidx = inst._arg1;
-			scprintf(_SC("[%03d] %15s %d "),n,g_InstrDesc[inst.op].name,inst._arg0);
+			scprintf(_SC("[%03d] %15s %d "),(SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0);
 			if(lidx >= 0xFFFFFFFF)
 			if(lidx >= 0xFFFFFFFF)
 				scprintf(_SC("null"));
 				scprintf(_SC("null"));
 			else {
 			else {
@@ -126,18 +126,18 @@ void SQFuncState::Dump(SQFunctionProto *func)
 			}
 			}
 		}
 		}
 		else if(inst.op==_OP_LOADFLOAT) {
 		else if(inst.op==_OP_LOADFLOAT) {
-			scprintf(_SC("[%03d] %15s %d %f %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
+			scprintf(_SC("[%03d] %15s %d %f %d %d\n"),(SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0,*((SQFloat*)&inst._arg1),inst._arg2,inst._arg3);
 		}
 		}
 	/*	else if(inst.op==_OP_ARITH){
 	/*	else if(inst.op==_OP_ARITH){
-			scprintf(_SC("[%03d] %15s %d %d %d %c\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
+			scprintf(_SC("[%03d] %15s %d %d %d %c\n"),(SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
 		}*/
 		}*/
 		else {
 		else {
-			scprintf(_SC("[%03d] %15s %d %d %d %d\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
+			scprintf(_SC("[%03d] %15s %d %d %d %d\n"),(SQInt32)n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3);
 		}
 		}
 		n++;
 		n++;
 	}
 	}
 	scprintf(_SC("-----\n"));
 	scprintf(_SC("-----\n"));
-	scprintf(_SC("stack size[%d]\n"),func->_stacksize);
+	scprintf(_SC("stack size[%d]\n"),(SQInt32)func->_stacksize);
 	scprintf(_SC("--------------------------------------------------------------------\n\n"));
 	scprintf(_SC("--------------------------------------------------------------------\n\n"));
 }
 }
 #endif
 #endif

+ 3 - 2
SquiLu/squirrel/sqvm.cpp

@@ -1553,6 +1553,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
 			return false;
 			return false;
 		}
 		}
 		return true;
 		return true;
+    case OT_USERDATA: break; // must fall back
 	default:
 	default:
 		Raise_Error(_SC("trying to set '%s'"),GetTypeName(self));
 		Raise_Error(_SC("trying to set '%s'"),GetTypeName(self));
 		return false;
 		return false;
@@ -2006,10 +2007,10 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
 	for(SQInteger i=0;i<size;i++){
 	for(SQInteger i=0;i<size;i++){
 		SQObjectPtr &obj=_stack[i];
 		SQObjectPtr &obj=_stack[i];
 		if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
 		if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" "));
-		scprintf(_SC("[%d]:"),n);
+		scprintf(_SC("[" _PRINT_INT_FMT "]:"),n);
 		switch(sqtype(obj)){
 		switch(sqtype(obj)){
 		case OT_FLOAT:			scprintf(_SC("FLOAT %.3f"),_float(obj));break;
 		case OT_FLOAT:			scprintf(_SC("FLOAT %.3f"),_float(obj));break;
-		case OT_INTEGER:		scprintf(_SC("INTEGER %d"),_integer(obj));break;
+		case OT_INTEGER:		scprintf(_SC("INTEGER " _PRINT_INT_FMT),_integer(obj));break;
 		case OT_BOOL:			scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;
 		case OT_BOOL:			scprintf(_SC("BOOL %s"),_integer(obj)?"true":"false");break;
 		case OT_STRING:			scprintf(_SC("STRING %s"),_stringval(obj));break;
 		case OT_STRING:			scprintf(_SC("STRING %s"),_stringval(obj));break;
 		case OT_NULL:			scprintf(_SC("NULL"));	break;
 		case OT_NULL:			scprintf(_SC("NULL"));	break;