diff options
Diffstat (limited to 'src/3rdparty/squirrel/squirrel/sqvm.cpp')
-rw-r--r-- | src/3rdparty/squirrel/squirrel/sqvm.cpp | 150 |
1 files changed, 75 insertions, 75 deletions
diff --git a/src/3rdparty/squirrel/squirrel/sqvm.cpp b/src/3rdparty/squirrel/squirrel/sqvm.cpp index 6f2894774..b1ff8e5f5 100644 --- a/src/3rdparty/squirrel/squirrel/sqvm.cpp +++ b/src/3rdparty/squirrel/squirrel/sqvm.cpp @@ -45,10 +45,10 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con case BW_SHIFTL: res = i1 << i2; break; case BW_SHIFTR: res = i1 >> i2; break; case BW_USHIFTR:res = (SQInteger)(*((SQUnsignedInteger*)&i1) >> i2); break; - default: { Raise_Error(_SC("internal vm error bitwise op failed")); return false; } + default: { Raise_Error("internal vm error bitwise op failed"); return false; } } } - else { Raise_Error(_SC("bitwise op between '%s' and '%s'"),GetTypeName(o1),GetTypeName(o2)); return false;} + else { Raise_Error("bitwise op between '%s' and '%s'",GetTypeName(o1),GetTypeName(o2)); return false;} trg = res; return true; } @@ -61,11 +61,11 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1, switch(op) { case '+': res = i1 + i2; break; case '-': res = i1 - i2; break; - case '/': if(i2 == 0) { Raise_Error(_SC("division by zero")); return false; } + case '/': if(i2 == 0) { Raise_Error("division by zero"); return false; } res = i1 / i2; break; case '*': res = i1 * i2; break; - case '%': if(i2 == 0) { Raise_Error(_SC("modulo by zero")); return false; } + case '%': if(i2 == 0) { Raise_Error("modulo by zero"); return false; } res = i1 % i2; break; default: res = 0xDEADBEEF; @@ -88,7 +88,7 @@ bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1, if(!StringCat(o1, o2, trg)) return false; } else if(!ArithMetaMethod(op,o1,o2,trg)) { - Raise_Error(_SC("arith op %c on between '%s' and '%s'"),op,GetTypeName(o1),GetTypeName(o2)); return false; + Raise_Error("arith op %c on between '%s' and '%s'",op,GetTypeName(o1),GetTypeName(o2)); return false; } } return true; @@ -137,11 +137,11 @@ bool SQVM::ArithMetaMethod(SQInteger op,const SQObjectPtr &o1,const SQObjectPtr { SQMetaMethod mm; switch(op){ - case _SC('+'): mm=MT_ADD; break; - case _SC('-'): mm=MT_SUB; break; - case _SC('/'): mm=MT_DIV; break; - case _SC('*'): mm=MT_MUL; break; - case _SC('%'): mm=MT_MODULO; break; + case '+': mm=MT_ADD; break; + case '-': mm=MT_SUB; break; + case '/': mm=MT_DIV; break; + case '*': mm=MT_MUL; break; + case '%': mm=MT_MODULO; break; default: mm = MT_ADD; assert(0); break; //shutup compiler } if(is_delegable(o1) && _delegable(o1)->_delegate) { @@ -173,7 +173,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o) } default:break; //shutup compiler } - Raise_Error(_SC("attempt to negate a %s"), GetTypeName(o)); + Raise_Error("attempt to negate a %s", GetTypeName(o)); return false; } @@ -198,7 +198,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result) Push(o1);Push(o2); if(CallMetaMethod(_delegable(o1),MT_CMP,2,res)) { if(type(res) != OT_INTEGER) { - Raise_Error(_SC("_cmp must return an integer")); + Raise_Error("_cmp must return an integer"); return false; } _RET_SUCCEED(_integer(res)) @@ -256,13 +256,13 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) res = o; return; case OT_FLOAT: - scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),_SC("%g"),_float(o)); + scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),"%g",_float(o)); break; case OT_INTEGER: scsprintf(_sp(rsl(NUMBER_MAX_CHAR+1)),SQ_PRINTF64,_integer(o)); break; case OT_BOOL: - scsprintf(_sp(rsl(6)),_integer(o)?_SC("true"):_SC("false")); + scsprintf(_sp(rsl(6)),_integer(o)?"true":"false"); break; case OT_TABLE: case OT_USERDATA: @@ -276,7 +276,7 @@ void SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) } } default: - scsprintf(_sp(rsl(sizeof(void*)+20)),_SC("(%s : 0x%p)"),GetTypeName(o),(void*)_rawval(o)); + scsprintf(_sp(rsl(sizeof(void*)+20)),"(%s : 0x%p)",GetTypeName(o),(void*)_rawval(o)); } res = SQString::Create(_ss(this),_spval); } @@ -346,7 +346,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege else if(func->_varparams) { if (nargs < paramssize) { - Raise_Error(_SC("wrong number of parameters")); + Raise_Error("wrong number of parameters"); return false; } for(SQInteger n = 0; n < nargs - paramssize; n++) { @@ -355,7 +355,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege } } else { - Raise_Error(_SC("wrong number of parameters")); + Raise_Error("wrong number of parameters"); return false; } } @@ -392,7 +392,7 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege _top = newtop; _stackbase = stackbase; if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) - CallDebugHook(_SC('c')); + CallDebugHook('c'); return true; } @@ -400,7 +400,7 @@ bool SQVM::Return(SQInteger _arg0, SQInteger _arg1, SQObjectPtr &retval) { if (type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) for(SQInteger i=0;i<ci->_ncalls;i++) - CallDebugHook(_SC('r')); + CallDebugHook('r'); SQBool broot = ci->_root; SQInteger last_top = _top; @@ -466,9 +466,9 @@ bool SQVM::DerefInc(SQInteger op,SQObjectPtr &target, SQObjectPtr &self, SQObjec SQRESULT SQVM::Suspend() { if (_suspended) - return sq_throwerror(this, _SC("cannot suspend an already suspended vm")); + return sq_throwerror(this, "cannot suspend an already suspended vm"); if (_nnativecalls!=2) - return sq_throwerror(this, _SC("cannot suspend through native calls/metamethods")); + return sq_throwerror(this, "cannot suspend through native calls/metamethods"); return SQ_SUSPEND_FLAG; } @@ -506,12 +506,12 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr o4 = o2 = itr; if(type(itr) == OT_NULL) _FINISH(exitpos); if(!Get(o1, itr, o3, false,false)) { - Raise_Error(_SC("_nexti returned an invalid idx")); + Raise_Error("_nexti returned an invalid idx"); return false; } _FINISH(1); } - Raise_Error(_SC("_nexti failed")); + Raise_Error("_nexti failed"); return false; } break; @@ -528,18 +528,18 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr _FINISH(0); } default: - Raise_Error(_SC("cannot iterate %s"), GetTypeName(o1)); + Raise_Error("cannot iterate %s", GetTypeName(o1)); } return false; //cannot be hit(just to avoid warnings) } bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2) { - if(type(o1) != OT_TABLE) { Raise_Error(_SC("delegating a '%s'"), GetTypeName(o1)); return false; } + if(type(o1) != OT_TABLE) { Raise_Error("delegating a '%s'", GetTypeName(o1)); return false; } switch(type(o2)) { case OT_TABLE: if(!_table(o1)->SetDelegate(_table(o2))){ - Raise_Error(_SC("delegate cycle detected")); + Raise_Error("delegate cycle detected"); return false; } break; @@ -547,7 +547,7 @@ bool SQVM::DELEGATE_OP(SQObjectPtr &trg,SQObjectPtr &o1,SQObjectPtr &o2) _table(o1)->SetDelegate(NULL); break; default: - Raise_Error(_SC("using '%s' as delegate"), GetTypeName(o2)); + Raise_Error("using '%s' as delegate", GetTypeName(o2)); return false; break; } @@ -599,15 +599,15 @@ bool SQVM::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func) bool SQVM::GETVARGV_OP(SQObjectPtr &target,SQObjectPtr &index,CallInfo *ci) { if(ci->_vargs.size == 0) { - Raise_Error(_SC("the function doesn't have var args")); + Raise_Error("the function doesn't have var args"); return false; } if(!sq_isnumeric(index)){ - Raise_Error(_SC("indexing 'vargv' with %s"),GetTypeName(index)); + Raise_Error("indexing 'vargv' with %s",GetTypeName(index)); return false; } SQInteger idx = tointeger(index); - if(idx < 0 || idx >= ci->_vargs.size){ Raise_Error(_SC("vargv index out of range")); return false; } + if(idx < 0 || idx >= ci->_vargs.size){ Raise_Error("vargv index out of range"); return false; } target = _vargsstack[ci->_vargs.base+idx]; return true; } @@ -617,7 +617,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes SQClass *base = NULL; SQObjectPtr attrs; if(baseclass != -1) { - if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; } + if(type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error("trying to inherit from a %s",GetTypeName(_stack._vals[_stackbase+baseclass])); return false; } base = _class(_stack._vals[_stackbase + baseclass]); } if(attributes != MAX_FUNC_STACKSIZE) { @@ -672,7 +672,7 @@ bool SQVM::GETPARENT_OP(SQObjectPtr &o,SQObjectPtr &target) case OT_CLASS: target = _class(o)->_base?_class(o)->_base:_null_; break; default: - Raise_Error(_SC("the %s type doesn't have a parent slot"), GetTypeName(o)); + Raise_Error("the %s type doesn't have a parent slot", GetTypeName(o)); return false; } return true; @@ -680,7 +680,7 @@ bool SQVM::GETPARENT_OP(SQObjectPtr &o,SQObjectPtr &target) bool SQVM::Execute(SQObjectPtr &closure, SQInteger target, SQInteger nargs, SQInteger stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et) { - if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { Raise_Error(_SC("Native stack overflow")); return false; } + if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { Raise_Error("Native stack overflow"); return false; } _nnativecalls++; AutoDec ad(&_nnativecalls); SQInteger traps = 0; @@ -740,7 +740,7 @@ exception_restore: { case _OP_LINE: if(type(_debughook) != OT_NULL && _rawval(_debughook) != _rawval(ci->_closure)) - CallDebugHook(_SC('l'),arg1); + CallDebugHook('l',arg1); continue; case _OP_LOAD: TARGET = ci->_literals[arg1]; continue; case _OP_LOADINT: TARGET = (SQInteger)arg1; continue; @@ -825,11 +825,11 @@ common_call: STK(ct_target) = clo; break; } - Raise_Error(_SC("attempt to call '%s'"), GetTypeName(clo)); + Raise_Error("attempt to call '%s'", GetTypeName(clo)); SQ_THROW(); } default: - Raise_Error(_SC("attempt to call '%s'"), GetTypeName(clo)); + Raise_Error("attempt to call '%s'", GetTypeName(clo)); SQ_THROW(); } } @@ -931,7 +931,7 @@ common_call: case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, true,false)?_true_:_false_;continue; case _OP_INSTANCEOF: if(type(STK(arg1)) != OT_CLASS || type(STK(arg2)) != OT_INSTANCE) - {Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();} + {Raise_Error("cannot apply instanceof between a %s and a %s",GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();} TARGET = _instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?_true_:_false_; continue; case _OP_AND: @@ -954,7 +954,7 @@ common_call: TARGET = SQInteger(~t); continue; } - Raise_Error(_SC("attempt to perform a bitwise op on a %s"), GetTypeName(STK(arg1))); + Raise_Error("attempt to perform a bitwise op on a %s", GetTypeName(STK(arg1))); SQ_THROW(); case _OP_CLOSURE: { SQClosure *c = ci->_closure._unVal.pClosure; @@ -969,7 +969,7 @@ common_call: traps -= ci->_etraps; if(sarg1 != MAX_FUNC_STACKSIZE) STK(arg1) = temp_reg; } - else { Raise_Error(_SC("trying to yield a '%s',only genenerator can be yielded"), GetTypeName(ci->_closure)); SQ_THROW();} + else { Raise_Error("trying to yield a '%s',only genenerator can be yielded", GetTypeName(ci->_closure)); SQ_THROW();} if(Return(arg0, arg1, temp_reg)){ assert(traps == 0); outres = temp_reg; @@ -979,7 +979,7 @@ common_call: } continue; case _OP_RESUME: - if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();} + if(type(STK(arg1)) != OT_GENERATOR){ Raise_Error("trying to resume a '%s',only genenerator can be resumed", GetTypeName(STK(arg1))); SQ_THROW();} _GUARD(_generator(STK(arg1))->Resume(this, arg0)); traps += ci->_etraps; continue; @@ -995,7 +995,7 @@ common_call: case _OP_DELEGATE: _GUARD(DELEGATE_OP(TARGET,STK(arg1),STK(arg2))); continue; case _OP_CLONE: if(!Clone(STK(arg1), TARGET)) - { Raise_Error(_SC("cloning a %s"), GetTypeName(STK(arg1))); SQ_THROW();} + { Raise_Error("cloning a %s", GetTypeName(STK(arg1))); SQ_THROW();} continue; case _OP_TYPEOF: TypeOf(STK(arg1), TARGET); continue; case _OP_PUSHTRAP:{ @@ -1121,11 +1121,11 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline) bool SQVM::CallNative(SQNativeClosure *nclosure,SQInteger nargs,SQInteger stackbase,SQObjectPtr &retval,bool &suspend) { - if (_nnativecalls + 1 > MAX_NATIVE_CALLS) { Raise_Error(_SC("Native stack overflow")); return false; } + if (_nnativecalls + 1 > MAX_NATIVE_CALLS) { Raise_Error("Native stack overflow"); return false; } SQInteger nparamscheck = nclosure->_nparamscheck; if(((nparamscheck > 0) && (nparamscheck != nargs)) || ((nparamscheck < 0) && (nargs < (-nparamscheck)))) { - Raise_Error(_SC("wrong number of parameters")); + Raise_Error("wrong number of parameters"); return false; } @@ -1333,10 +1333,10 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr } break; case OT_ARRAY: - if(!sq_isnumeric(key)) {Raise_Error(_SC("indexing %s with %s"),GetTypeName(self),GetTypeName(key)); return false; } + if(!sq_isnumeric(key)) {Raise_Error("indexing %s with %s",GetTypeName(self),GetTypeName(key)); return false; } return _array(self)->Set(tointeger(key),val); default: - Raise_Error(_SC("trying to set '%s'"),GetTypeName(self)); + Raise_Error("trying to set '%s'",GetTypeName(self)); return false; } if(fetchroot) { @@ -1375,7 +1375,7 @@ cloned_mt: bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic) { - if(type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; } + if(type(key) == OT_NULL) { Raise_Error("null cannot be used as index"); return false; } switch(type(self)) { case OT_TABLE: { bool rawcall = true; @@ -1393,25 +1393,25 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject SQObjectPtr res; Push(self);Push(key);Push(val); if(!CallMetaMethod(_instance(self),MT_NEWSLOT,3,res)) { - Raise_Error(_SC("class instances do not support the new slot operator")); + Raise_Error("class instances do not support the new slot operator"); return false; } break;} case OT_CLASS: if(!_class(self)->NewSlot(_ss(this),key,val,bstatic)) { if(_class(self)->_locked) { - Raise_Error(_SC("trying to modify a class that has already been instantiated")); + Raise_Error("trying to modify a class that has already been instantiated"); return false; } else { SQObjectPtr oval = PrintObjVal(key); - Raise_Error(_SC("the property '%s' already exists"),_stringval(oval)); + Raise_Error("the property '%s' already exists",_stringval(oval)); return false; } } break; default: - Raise_Error(_SC("indexing %s with %s"),GetTypeName(self),GetTypeName(key)); + Raise_Error("indexing %s with %s",GetTypeName(self),GetTypeName(key)); return false; break; } @@ -1442,7 +1442,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr } } else { - Raise_Error(_SC("cannot delete a slot from %s"),GetTypeName(self)); + Raise_Error("cannot delete a slot from %s",GetTypeName(self)); return false; } } @@ -1450,7 +1450,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr } break; default: - Raise_Error(_SC("attempt to delete a slot from a %s"),GetTypeName(self)); + Raise_Error("attempt to delete a slot from a %s",GetTypeName(self)); return false; } return true; @@ -1554,37 +1554,37 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall) { SQInteger size=dumpall?_stack.size():_top; SQInteger n=0; - scprintf(_SC("\n>>>>stack dump<<<<\n")); + scprintf("\n>>>>stack dump<<<<\n"); CallInfo &ci=_callsstack[_callsstacksize-1]; - scprintf(_SC("IP: %p\n"),ci._ip); - scprintf(_SC("prev stack base: %d\n"),ci._prevstkbase); - scprintf(_SC("prev top: %d\n"),ci._prevtop); + scprintf("IP: %p\n",ci._ip); + scprintf("prev stack base: %d\n",ci._prevstkbase); + scprintf("prev top: %d\n",ci._prevtop); for(SQInteger i=0;i<size;i++){ SQObjectPtr &obj=_stack[i]; - if(stackbase==i)scprintf(_SC(">"));else scprintf(_SC(" ")); - scprintf(_SC("[%d]:"),n); + if(stackbase==i)scprintf(">");else scprintf(" "); + scprintf("[%d]:",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_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; - case OT_TABLE: scprintf(_SC("TABLE %p[%p]"),_table(obj),_table(obj)->_delegate);break; - case OT_ARRAY: scprintf(_SC("ARRAY %p"),_array(obj));break; - case OT_CLOSURE: scprintf(_SC("CLOSURE [%p]"),_closure(obj));break; - case OT_NATIVECLOSURE: scprintf(_SC("NATIVECLOSURE"));break; - case OT_USERDATA: scprintf(_SC("USERDATA %p[%p]"),_userdataval(obj),_userdata(obj)->_delegate);break; - case OT_GENERATOR: scprintf(_SC("GENERATOR %p"),_generator(obj));break; - case OT_THREAD: scprintf(_SC("THREAD [%p]"),_thread(obj));break; - case OT_USERPOINTER: scprintf(_SC("USERPOINTER %p"),_userpointer(obj));break; - case OT_CLASS: scprintf(_SC("CLASS %p"),_class(obj));break; - case OT_INSTANCE: scprintf(_SC("INSTANCE %p"),_instance(obj));break; - case OT_WEAKREF: scprintf(_SC("WEAKERF %p"),_weakref(obj));break; + case OT_FLOAT: scprintf("FLOAT %.3f",_float(obj));break; + case OT_INTEGER: scprintf("INTEGER %d",_integer(obj));break; + case OT_BOOL: scprintf("BOOL %s",_integer(obj)?"true":"false");break; + case OT_STRING: scprintf("STRING %s",_stringval(obj));break; + case OT_NULL: scprintf("NULL"); break; + case OT_TABLE: scprintf("TABLE %p[%p]",_table(obj),_table(obj)->_delegate);break; + case OT_ARRAY: scprintf("ARRAY %p",_array(obj));break; + case OT_CLOSURE: scprintf("CLOSURE [%p]",_closure(obj));break; + case OT_NATIVECLOSURE: scprintf("NATIVECLOSURE");break; + case OT_USERDATA: scprintf("USERDATA %p[%p]",_userdataval(obj),_userdata(obj)->_delegate);break; + case OT_GENERATOR: scprintf("GENERATOR %p",_generator(obj));break; + case OT_THREAD: scprintf("THREAD [%p]",_thread(obj));break; + case OT_USERPOINTER: scprintf("USERPOINTER %p",_userpointer(obj));break; + case OT_CLASS: scprintf("CLASS %p",_class(obj));break; + case OT_INSTANCE: scprintf("INSTANCE %p",_instance(obj));break; + case OT_WEAKREF: scprintf("WEAKERF %p",_weakref(obj));break; default: assert(0); break; }; - scprintf(_SC("\n")); + scprintf("\n"); ++n; } } |