From 033150b4f17cac0a3a12f0cd617584822a31e711 Mon Sep 17 00:00:00 2001 From: Sandu Liviu Catalin Date: Thu, 25 May 2017 22:27:33 +0300 Subject: [PATCH] Update squirrel to the latest version straight from the official repository. --- external/Squirrel/Lib/sqstdblob.cpp | 2 +- external/Squirrel/Lib/sqstdio.cpp | 4 ++-- external/Squirrel/Lib/sqstdrex.cpp | 6 +++--- external/Squirrel/Lib/sqstdstream.cpp | 4 ++-- external/Squirrel/Lib/sqstdstring.cpp | 2 +- external/Squirrel/sqapi.cpp | 11 +++++++---- external/Squirrel/sqcompiler.cpp | 3 +++ external/Squirrel/sqdebug.cpp | 2 +- external/Squirrel/sqfuncstate.cpp | 20 ++++++++++---------- external/Squirrel/sqlexer.cpp | 2 +- external/Squirrel/sqvm.cpp | 10 +++++++--- 11 files changed, 38 insertions(+), 28 deletions(-) diff --git a/external/Squirrel/Lib/sqstdblob.cpp b/external/Squirrel/Lib/sqstdblob.cpp index 1db973b9..67e5f3c3 100644 --- a/external/Squirrel/Lib/sqstdblob.cpp +++ b/external/Squirrel/Lib/sqstdblob.cpp @@ -7,7 +7,7 @@ #include "sqstdstream.h" #include "sqstdblobimpl.h" -#define SQSTD_BLOB_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000002) +#define SQSTD_BLOB_TYPE_TAG ((SQUnsignedInteger)(SQSTD_STREAM_TYPE_TAG | 0x00000002)) //Blob diff --git a/external/Squirrel/Lib/sqstdio.cpp b/external/Squirrel/Lib/sqstdio.cpp index 3a862626..52cd5158 100644 --- a/external/Squirrel/Lib/sqstdio.cpp +++ b/external/Squirrel/Lib/sqstdio.cpp @@ -5,7 +5,7 @@ #include #include "sqstdstream.h" -#define SQSTD_FILE_TYPE_TAG (SQSTD_STREAM_TYPE_TAG | 0x00000001) +#define SQSTD_FILE_TYPE_TAG ((SQUnsignedInteger)(SQSTD_STREAM_TYPE_TAG | 0x00000001)) //basic API SQFILE sqstd_fopen(const SQChar *filename ,const SQChar *mode) { @@ -401,7 +401,7 @@ SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool { //at least one entry must exist in order for us to push it as the environment if(sq_gettop(v) == 0) - return sq_throwerror(v,_SC("environment table expected")); + return sq_throwerror(v,_SC("environment table expected")); if(SQ_SUCCEEDED(sqstd_loadfile(v,filename,printerror))) { sq_push(v,-2); diff --git a/external/Squirrel/Lib/sqstdrex.cpp b/external/Squirrel/Lib/sqstdrex.cpp index 38a85085..d0583a6b 100644 --- a/external/Squirrel/Lib/sqstdrex.cpp +++ b/external/Squirrel/Lib/sqstdrex.cpp @@ -155,7 +155,7 @@ static SQInteger sqstd_rex_charnode(SQRex *exp,SQBool isclass) } case 0: sqstd_rex_error(exp,_SC("letter expected for argument of escape sequence")); - break; + break; case 'b': case 'B': if(!isclass) { @@ -578,9 +578,9 @@ SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error) scprintf(_SC("\n")); for(i = 0;i < nsize; i++) { if(exp->_nodes[i].type>MAX_CHAR) - scprintf(_SC("[%02d] %10s "),i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); + scprintf(_SC("[%02d] %10s "), (SQInt32)i,g_nnames[exp->_nodes[i].type-MAX_CHAR]); else - scprintf(_SC("[%02d] %10c "),i,exp->_nodes[i].type); + scprintf(_SC("[%02d] %10c "), (SQInt32)i,exp->_nodes[i].type); scprintf(_SC("left %02d right %02d next %02d\n"), (SQInt32)exp->_nodes[i].left, (SQInt32)exp->_nodes[i].right, (SQInt32)exp->_nodes[i].next); } scprintf(_SC("\n")); diff --git a/external/Squirrel/Lib/sqstdstream.cpp b/external/Squirrel/Lib/sqstdstream.cpp index 406f5611..b5c47cfb 100644 --- a/external/Squirrel/Lib/sqstdstream.cpp +++ b/external/Squirrel/Lib/sqstdstream.cpp @@ -11,7 +11,7 @@ #define SETUP_STREAM(v) \ SQStream *self = NULL; \ - if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_STREAM_TYPE_TAG))) \ + if(SQ_FAILED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)((SQUnsignedInteger)SQSTD_STREAM_TYPE_TAG)))) \ return sq_throwerror(v,_SC("invalid type tag")); \ if(!self || !self->IsValid()) \ return sq_throwerror(v,_SC("the stream is invalid")); @@ -259,7 +259,7 @@ void init_streamclass(HSQUIRRELVM v) if(SQ_FAILED(sq_get(v,-2))) { sq_pushstring(v,_SC("std_stream"),-1); sq_newclass(v,SQFalse); - sq_settypetag(v,-1,(SQUserPointer)SQSTD_STREAM_TYPE_TAG); + sq_settypetag(v,-1,(SQUserPointer)((SQUnsignedInteger)SQSTD_STREAM_TYPE_TAG)); SQInteger i = 0; while(_stream_methods[i].name != 0) { const SQRegFunction &f = _stream_methods[i]; diff --git a/external/Squirrel/Lib/sqstdstring.cpp b/external/Squirrel/Lib/sqstdstring.cpp index bd052331..e624646f 100644 --- a/external/Squirrel/Lib/sqstdstring.cpp +++ b/external/Squirrel/Lib/sqstdstring.cpp @@ -159,7 +159,7 @@ static SQInteger _string_printf(HSQUIRRELVM v) SQInteger length = 0; if(SQ_FAILED(sqstd_format(v,2,&length,&dest))) return -1; - + SQPRINTFUNCTION printfunc = sq_getprintfunc(v); if(printfunc) printfunc(v,dest); diff --git a/external/Squirrel/sqapi.cpp b/external/Squirrel/sqapi.cpp index 855bf674..21039fc5 100644 --- a/external/Squirrel/sqapi.cpp +++ b/external/Squirrel/sqapi.cpp @@ -776,8 +776,8 @@ SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag) SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag) { SQObjectPtr &o = stack_get(v,idx); - if(SQ_FAILED(sq_getobjtypetag(&o,typetag))) - return sq_throwerror(v,_SC("invalid object type")); + if (SQ_FAILED(sq_getobjtypetag(&o, typetag))) + return SQ_ERROR;// this is not an error it should be a bool but would break backward compatibility return SQ_OK; } @@ -971,8 +971,11 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx) switch(type) { case OT_TABLE: if(type(mt) == OT_TABLE) { - if(!_table(self)->SetDelegate(_table(mt))) return sq_throwerror(v, _SC("delagate cycle")); - v->Pop(); } + if(!_table(self)->SetDelegate(_table(mt))) { + return sq_throwerror(v, _SC("delagate cycle")); + } + v->Pop(); + } else if(type(mt)==OT_NULL) { _table(self)->SetDelegate(NULL); v->Pop(); } else return sq_aux_invalidtype(v,type); diff --git a/external/Squirrel/sqcompiler.cpp b/external/Squirrel/sqcompiler.cpp index 9b1c205e..b5805888 100644 --- a/external/Squirrel/sqcompiler.cpp +++ b/external/Squirrel/sqcompiler.cpp @@ -466,6 +466,7 @@ public: INVOKE_EXP(f); SQInteger op1 = _fs->PopTarget();SQInteger op2 = _fs->PopTarget(); _fs->AddInstruction(op, _fs->PushTarget(), op1, op2, op3); + _es.etype = EXPR; } void LogicalOrExp() { @@ -482,6 +483,7 @@ public: if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); _fs->SnoozeOpt(); _fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos)); + _es.etype = EXPR; break; }else return; } @@ -501,6 +503,7 @@ public: if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); _fs->SnoozeOpt(); _fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos)); + _es.etype = EXPR; break; } diff --git a/external/Squirrel/sqdebug.cpp b/external/Squirrel/sqdebug.cpp index 7785f214..7214a2cb 100644 --- a/external/Squirrel/sqdebug.cpp +++ b/external/Squirrel/sqdebug.cpp @@ -107,7 +107,7 @@ void SQVM::Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger ty SQInteger found = 0; for(SQInteger i=0; i<16; i++) { - SQInteger mask = 0x00000001 << i; + SQInteger mask = ((SQInteger)1) << i; if(typemask & (mask)) { if(found>0) StringCat(exptypes,SQString::Create(_ss(this), _SC("|"), -1), exptypes); found ++; diff --git a/external/Squirrel/sqfuncstate.cpp b/external/Squirrel/sqfuncstate.cpp index ce3c7f51..022702c9 100644 --- a/external/Squirrel/sqfuncstate.cpp +++ b/external/Squirrel/sqfuncstate.cpp @@ -117,8 +117,8 @@ void SQFuncState::Dump(SQFunctionProto *func) { SQUnsignedInteger n=0,i; 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("*****FUNCTION [%s]\n"),type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown")); scprintf(_SC("-----LITERALS\n")); @@ -131,7 +131,7 @@ void SQFuncState::Dump(SQFunctionProto *func) templiterals[_integer(val)]=key; } for(i=0;i>\n")); n=0; for(i=0;i<_parameters.size();i++){ - scprintf(_SC("[%d] "),n); + scprintf(_SC("[%d] "), (SQInt32)n); DumpLiteral(_parameters[i]); scprintf(_SC("\n")); n++; @@ -149,13 +149,13 @@ void SQFuncState::Dump(SQFunctionProto *func) scprintf(_SC("-----LOCALS\n")); for(si=0;si_nlocalvarinfos;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++; } scprintf(_SC("-----LINE INFO\n")); for(i=0;i<_lineinfos.size();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++; } scprintf(_SC("-----dump\n")); @@ -165,7 +165,7 @@ void SQFuncState::Dump(SQFunctionProto *func) if(inst.op==_OP_LOAD || inst.op==_OP_DLOAD || inst.op==_OP_PREPCALLK || inst.op==_OP_GETK ){ 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) scprintf(_SC("null")); else { @@ -196,18 +196,18 @@ void SQFuncState::Dump(SQFunctionProto *func) } } 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){ scprintf(_SC("[%03d] %15s %d %d %d %c\n"),n,g_InstrDesc[inst.op].name,inst._arg0,inst._arg1,inst._arg2,inst._arg3); }*/ 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++; } scprintf(_SC("-----\n")); - scprintf(_SC("stack size[%d]\n"),func->_stacksize); + scprintf(_SC("stack size[%d]\n"), (SQInt32)func->_stacksize); scprintf(_SC("--------------------------------------------------------------------\n\n")); } #endif diff --git a/external/Squirrel/sqlexer.cpp b/external/Squirrel/sqlexer.cpp index 10afffb6..63c8f972 100644 --- a/external/Squirrel/sqlexer.cpp +++ b/external/Squirrel/sqlexer.cpp @@ -68,7 +68,7 @@ void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,Compile ADD_KEYWORD(__LINE__,TK___LINE__); ADD_KEYWORD(__FILE__,TK___FILE__); ADD_KEYWORD(rawcall, TK_RAWCALL); - + _readf = rg; _up = up; diff --git a/external/Squirrel/sqvm.cpp b/external/Squirrel/sqvm.cpp index 3881e6ff..b20df9a1 100644 --- a/external/Squirrel/sqvm.cpp +++ b/external/Squirrel/sqvm.cpp @@ -726,9 +726,13 @@ exception_restore: if (type(t) == OT_CLOSURE && (!_closure(t)->_function->_bgenerator)){ SQObjectPtr clo = t; + SQInteger last_top = _top; if(_openouters) CloseOuters(&(_stack._vals[_stackbase])); for (SQInteger i = 0; i < arg3; i++) STK(i) = STK(arg2 + i); _GUARD(StartCall(_closure(clo), ci->_target, arg3, _stackbase, true)); + if (last_top >= _top) { + _top = last_top; + } continue; } } @@ -1093,7 +1097,6 @@ exception_trap: return false; } assert(0); - return false; } bool SQVM::CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor) @@ -1331,6 +1334,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr return false; } return true; + case OT_USERDATA: break; // must fall back default: Raise_Error(_SC("trying to set '%s'"),GetTypeName(self)); return false; @@ -1718,10 +1722,10 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall) for(SQInteger i=0;i"));else scprintf(_SC(" ")); - scprintf(_SC("[%d]:"),n); + scprintf(_SC("[" _PRINT_INT_FMT "]:"),n); switch(type(obj)){ 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_STRING: scprintf(_SC("STRING %s"),_stringval(obj));break; case OT_NULL: scprintf(_SC("NULL")); break;