mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-22 04:37:13 +01:00
Backported latest fixes and improvements from the Squirrel repository.
This commit is contained in:
parent
2b9c8f6550
commit
7cdca09d50
8
external/Squirrel/Lib/sqstdblob.cpp
vendored
8
external/Squirrel/Lib/sqstdblob.cpp
vendored
@ -82,6 +82,12 @@ static SQInteger _blob__get(HSQUIRRELVM v)
|
|||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
SQInteger idx;
|
SQInteger idx;
|
||||||
|
|
||||||
|
if ((sq_gettype(v, 2) & SQOBJECT_NUMERIC) == 0)
|
||||||
|
{
|
||||||
|
sq_pushnull(v);
|
||||||
|
return sq_throwobject(v);
|
||||||
|
}
|
||||||
sq_getinteger(v,2,&idx);
|
sq_getinteger(v,2,&idx);
|
||||||
if(idx < 0 || idx >= self->Len())
|
if(idx < 0 || idx >= self->Len())
|
||||||
return sq_throwerror(v,_SC("index out of range"));
|
return sq_throwerror(v,_SC("index out of range"));
|
||||||
@ -168,7 +174,7 @@ static const SQRegFunction _blob_methods[] = {
|
|||||||
_DECL_BLOB_FUNC(swap2,1,_SC("x")),
|
_DECL_BLOB_FUNC(swap2,1,_SC("x")),
|
||||||
_DECL_BLOB_FUNC(swap4,1,_SC("x")),
|
_DECL_BLOB_FUNC(swap4,1,_SC("x")),
|
||||||
_DECL_BLOB_FUNC(_set,3,_SC("xnn")),
|
_DECL_BLOB_FUNC(_set,3,_SC("xnn")),
|
||||||
_DECL_BLOB_FUNC(_get,2,_SC("xn")),
|
_DECL_BLOB_FUNC(_get,2,_SC("x.")),
|
||||||
_DECL_BLOB_FUNC(_typeof,1,_SC("x")),
|
_DECL_BLOB_FUNC(_typeof,1,_SC("x")),
|
||||||
_DECL_BLOB_FUNC(_nexti,2,_SC("x")),
|
_DECL_BLOB_FUNC(_nexti,2,_SC("x")),
|
||||||
_DECL_BLOB_FUNC(_cloned,2,_SC("xx")),
|
_DECL_BLOB_FUNC(_cloned,2,_SC("xx")),
|
||||||
|
2
external/Squirrel/Lib/sqstdblobimpl.h
vendored
2
external/Squirrel/Lib/sqstdblobimpl.h
vendored
@ -88,7 +88,7 @@ struct SQBlob : public SQStream
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bool IsValid() {
|
bool IsValid() {
|
||||||
return _buf?true:false;
|
return _size == 0 || _buf?true:false;
|
||||||
}
|
}
|
||||||
bool EOS() {
|
bool EOS() {
|
||||||
return _ptr == _size;
|
return _ptr == _size;
|
||||||
|
153
external/Squirrel/sqapi.cpp
vendored
153
external/Squirrel/sqapi.cpp
vendored
@ -16,7 +16,7 @@
|
|||||||
static bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o)
|
static bool sq_aux_gettypedarg(HSQUIRRELVM v,SQInteger idx,SQObjectType type,SQObjectPtr **o)
|
||||||
{
|
{
|
||||||
*o = &stack_get(v,idx);
|
*o = &stack_get(v,idx);
|
||||||
if(type(**o) != type){
|
if(sq_type(**o) != type){
|
||||||
SQObjectPtr oval = v->PrintObjVal(**o);
|
SQObjectPtr oval = v->PrintObjVal(**o);
|
||||||
v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
|
v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
|
||||||
return false;
|
return false;
|
||||||
@ -150,7 +150,7 @@ void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable)
|
|||||||
|
|
||||||
void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
|
void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
|
||||||
{
|
{
|
||||||
if(!ISREFCOUNTED(type(*po))) return;
|
if(!ISREFCOUNTED(sq_type(*po))) return;
|
||||||
#ifdef NO_GARBAGE_COLLECTOR
|
#ifdef NO_GARBAGE_COLLECTOR
|
||||||
__AddRef(po->_type,po->_unVal);
|
__AddRef(po->_type,po->_unVal);
|
||||||
#else
|
#else
|
||||||
@ -160,7 +160,7 @@ void sq_addref(HSQUIRRELVM v,HSQOBJECT *po)
|
|||||||
|
|
||||||
SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
|
SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
|
||||||
{
|
{
|
||||||
if(!ISREFCOUNTED(type(*po))) return 0;
|
if(!ISREFCOUNTED(sq_type(*po))) return 0;
|
||||||
#ifdef NO_GARBAGE_COLLECTOR
|
#ifdef NO_GARBAGE_COLLECTOR
|
||||||
return po->_unVal.pRefCounted->_uiRef;
|
return po->_unVal.pRefCounted->_uiRef;
|
||||||
#else
|
#else
|
||||||
@ -170,7 +170,7 @@ SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po)
|
|||||||
|
|
||||||
SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
|
SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
|
||||||
{
|
{
|
||||||
if(!ISREFCOUNTED(type(*po))) return SQTrue;
|
if(!ISREFCOUNTED(sq_type(*po))) return SQTrue;
|
||||||
#ifdef NO_GARBAGE_COLLECTOR
|
#ifdef NO_GARBAGE_COLLECTOR
|
||||||
bool ret = (po->_unVal.pRefCounted->_uiRef <= 1) ? SQTrue : SQFalse;
|
bool ret = (po->_unVal.pRefCounted->_uiRef <= 1) ? SQTrue : SQFalse;
|
||||||
__Release(po->_type,po->_unVal);
|
__Release(po->_type,po->_unVal);
|
||||||
@ -182,7 +182,7 @@ SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po)
|
|||||||
|
|
||||||
SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po)
|
SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM SQ_UNUSED_ARG(v), const HSQOBJECT *po)
|
||||||
{
|
{
|
||||||
if (!ISREFCOUNTED(type(*po))) return 0;
|
if (!ISREFCOUNTED(sq_type(*po))) return 0;
|
||||||
return po->_unVal.pRefCounted->_uiRef;
|
return po->_unVal.pRefCounted->_uiRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase)
|
|||||||
SQClass *baseclass = NULL;
|
SQClass *baseclass = NULL;
|
||||||
if(hasbase) {
|
if(hasbase) {
|
||||||
SQObjectPtr &base = stack_get(v,-1);
|
SQObjectPtr &base = stack_get(v,-1);
|
||||||
if(type(base) != OT_CLASS)
|
if(sq_type(base) != OT_CLASS)
|
||||||
return sq_throwerror(v,_SC("invalid base type"));
|
return sq_throwerror(v,_SC("invalid base type"));
|
||||||
baseclass = _class(base);
|
baseclass = _class(base);
|
||||||
}
|
}
|
||||||
@ -304,7 +304,7 @@ SQBool sq_instanceof(HSQUIRRELVM v)
|
|||||||
{
|
{
|
||||||
SQObjectPtr &inst = stack_get(v,-1);
|
SQObjectPtr &inst = stack_get(v,-1);
|
||||||
SQObjectPtr &cl = stack_get(v,-2);
|
SQObjectPtr &cl = stack_get(v,-2);
|
||||||
if(type(inst) != OT_INSTANCE || type(cl) != OT_CLASS)
|
if(sq_type(inst) != OT_INSTANCE || sq_type(cl) != OT_CLASS)
|
||||||
return sq_throwerror(v,_SC("invalid param type"));
|
return sq_throwerror(v,_SC("invalid param type"));
|
||||||
return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
|
return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
|
||||||
}
|
}
|
||||||
@ -394,21 +394,21 @@ void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars)
|
|||||||
v->Push(SQObjectPtr(nc));
|
v->Push(SQObjectPtr(nc));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars)
|
SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars)
|
||||||
{
|
{
|
||||||
SQObject o = stack_get(v, idx);
|
SQObject o = stack_get(v, idx);
|
||||||
if(type(o) == OT_CLOSURE) {
|
if(sq_type(o) == OT_CLOSURE) {
|
||||||
SQClosure *c = _closure(o);
|
SQClosure *c = _closure(o);
|
||||||
SQFunctionProto *proto = c->_function;
|
SQFunctionProto *proto = c->_function;
|
||||||
*nparams = (SQUnsignedInteger)proto->_nparameters;
|
*nparams = proto->_nparameters;
|
||||||
*nfreevars = (SQUnsignedInteger)proto->_noutervalues;
|
*nfreevars = proto->_noutervalues;
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
else if(type(o) == OT_NATIVECLOSURE)
|
else if(sq_type(o) == OT_NATIVECLOSURE)
|
||||||
{
|
{
|
||||||
SQNativeClosure *c = _nativeclosure(o);
|
SQNativeClosure *c = _nativeclosure(o);
|
||||||
*nparams = (SQUnsignedInteger)c->_nparamscheck;
|
*nparams = c->_nparamscheck;
|
||||||
*nfreevars = c->_noutervalues;
|
*nfreevars = (SQInteger)c->_noutervalues;
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
return sq_throwerror(v,_SC("the object is not a closure"));
|
return sq_throwerror(v,_SC("the object is not a closure"));
|
||||||
@ -459,7 +459,7 @@ SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx)
|
|||||||
!sq_isclass(env) &&
|
!sq_isclass(env) &&
|
||||||
!sq_isinstance(env))
|
!sq_isinstance(env))
|
||||||
return sq_throwerror(v,_SC("invalid environment"));
|
return sq_throwerror(v,_SC("invalid environment"));
|
||||||
SQWeakRef *w = _refcounted(env)->GetWeakRef(type(env));
|
SQWeakRef *w = _refcounted(env)->GetWeakRef(sq_type(env));
|
||||||
SQObjectPtr ret;
|
SQObjectPtr ret;
|
||||||
if(sq_isclosure(o)) {
|
if(sq_isclosure(o)) {
|
||||||
SQClosure *c = _closure(o)->Clone();
|
SQClosure *c = _closure(o)->Clone();
|
||||||
@ -524,7 +524,7 @@ SQRESULT sq_getclosureroot(HSQUIRRELVM v,SQInteger idx)
|
|||||||
SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx)
|
SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,idx);
|
SQObject &o=stack_get(v,idx);
|
||||||
switch(type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_TABLE: _table(o)->Clear(); break;
|
case OT_TABLE: _table(o)->Clear(); break;
|
||||||
case OT_ARRAY: _array(o)->Resize(0); break;
|
case OT_ARRAY: _array(o)->Resize(0); break;
|
||||||
default:
|
default:
|
||||||
@ -619,7 +619,7 @@ void sq_push(HSQUIRRELVM v,SQInteger idx)
|
|||||||
|
|
||||||
SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx)
|
SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
return type(stack_get(v, idx));
|
return sq_type(stack_get(v, idx));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx)
|
SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx)
|
||||||
@ -723,7 +723,7 @@ SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx)
|
|||||||
SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
|
SQInteger sq_getsize(HSQUIRRELVM v, SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v, idx);
|
SQObjectPtr &o = stack_get(v, idx);
|
||||||
SQObjectType type = type(o);
|
SQObjectType type = sq_type(o);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case OT_STRING: return _string(o)->_len;
|
case OT_STRING: return _string(o)->_len;
|
||||||
case OT_TABLE: return _table(o)->CountUsed();
|
case OT_TABLE: return _table(o)->CountUsed();
|
||||||
@ -754,7 +754,7 @@ SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPoint
|
|||||||
SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
|
SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,idx);
|
SQObjectPtr &o = stack_get(v,idx);
|
||||||
switch(type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_USERDATA: _userdata(o)->_typetag = typetag; break;
|
case OT_USERDATA: _userdata(o)->_typetag = typetag; break;
|
||||||
case OT_CLASS: _class(o)->_typetag = typetag; break;
|
case OT_CLASS: _class(o)->_typetag = typetag; break;
|
||||||
default: return sq_throwerror(v,_SC("invalid object type"));
|
default: return sq_throwerror(v,_SC("invalid object type"));
|
||||||
@ -764,7 +764,7 @@ SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag)
|
|||||||
|
|
||||||
SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag)
|
SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag)
|
||||||
{
|
{
|
||||||
switch(type(*o)) {
|
switch(sq_type(*o)) {
|
||||||
case OT_INSTANCE: *typetag = _instance(*o)->_class->_typetag; break;
|
case OT_INSTANCE: *typetag = _instance(*o)->_class->_typetag; break;
|
||||||
case OT_USERDATA: *typetag = _userdata(*o)->_typetag; break;
|
case OT_USERDATA: *typetag = _userdata(*o)->_typetag; break;
|
||||||
case OT_CLASS: *typetag = _class(*o)->_typetag; break;
|
case OT_CLASS: *typetag = _class(*o)->_typetag; break;
|
||||||
@ -792,7 +792,7 @@ SQRESULT sq_getuserpointer(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p)
|
|||||||
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
|
SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,idx);
|
SQObjectPtr &o = stack_get(v,idx);
|
||||||
if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
|
if(sq_type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
|
||||||
_instance(o)->_userpointer = p;
|
_instance(o)->_userpointer = p;
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
@ -800,7 +800,7 @@ SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p)
|
|||||||
SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
|
SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,idx);
|
SQObjectPtr &o = stack_get(v,idx);
|
||||||
if(type(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
|
if(sq_type(o) != OT_CLASS) return sq_throwerror(v,_SC("the object is not a class"));
|
||||||
if(_class(o)->_locked) return sq_throwerror(v,_SC("the class is locked"));
|
if(_class(o)->_locked) return sq_throwerror(v,_SC("the class is locked"));
|
||||||
_class(o)->_udsize = udsize;
|
_class(o)->_udsize = udsize;
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
@ -810,7 +810,7 @@ SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize)
|
|||||||
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
|
SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,idx);
|
SQObjectPtr &o = stack_get(v,idx);
|
||||||
if(type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
|
if(sq_type(o) != OT_INSTANCE) return sq_throwerror(v,_SC("the object is not a class instance"));
|
||||||
(*p) = _instance(o)->_userpointer;
|
(*p) = _instance(o)->_userpointer;
|
||||||
if(typetag != 0) {
|
if(typetag != 0) {
|
||||||
SQClass *cl = _instance(o)->_class;
|
SQClass *cl = _instance(o)->_class;
|
||||||
@ -867,9 +867,9 @@ SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic)
|
|||||||
{
|
{
|
||||||
sq_aux_paramscheck(v, 3);
|
sq_aux_paramscheck(v, 3);
|
||||||
SQObjectPtr &self = stack_get(v, idx);
|
SQObjectPtr &self = stack_get(v, idx);
|
||||||
if(type(self) == OT_TABLE || type(self) == OT_CLASS) {
|
if(sq_type(self) == OT_TABLE || sq_type(self) == OT_CLASS) {
|
||||||
SQObjectPtr &key = v->GetUp(-2);
|
SQObjectPtr &key = v->GetUp(-2);
|
||||||
if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
|
if(sq_type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
|
||||||
v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
|
v->NewSlot(self, key, v->GetUp(-1),bstatic?true:false);
|
||||||
v->Pop(2);
|
v->Pop(2);
|
||||||
}
|
}
|
||||||
@ -882,7 +882,7 @@ SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
|
|||||||
SQObjectPtr *self;
|
SQObjectPtr *self;
|
||||||
_GETSAFE_OBJ(v, idx, OT_TABLE,self);
|
_GETSAFE_OBJ(v, idx, OT_TABLE,self);
|
||||||
SQObjectPtr &key = v->GetUp(-1);
|
SQObjectPtr &key = v->GetUp(-1);
|
||||||
if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
|
if(sq_type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
|
||||||
SQObjectPtr res;
|
SQObjectPtr res;
|
||||||
if(!v->DeleteSlot(*self, key, res)){
|
if(!v->DeleteSlot(*self, key, res)){
|
||||||
v->Pop();
|
v->Pop();
|
||||||
@ -907,11 +907,11 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
|
|||||||
{
|
{
|
||||||
SQObjectPtr &self = stack_get(v, idx);
|
SQObjectPtr &self = stack_get(v, idx);
|
||||||
SQObjectPtr &key = v->GetUp(-2);
|
SQObjectPtr &key = v->GetUp(-2);
|
||||||
if(type(key) == OT_NULL) {
|
if(sq_type(key) == OT_NULL) {
|
||||||
v->Pop(2);
|
v->Pop(2);
|
||||||
return sq_throwerror(v, _SC("null key"));
|
return sq_throwerror(v, _SC("null key"));
|
||||||
}
|
}
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
_table(self)->NewSlot(key, v->GetUp(-1));
|
_table(self)->NewSlot(key, v->GetUp(-1));
|
||||||
v->Pop(2);
|
v->Pop(2);
|
||||||
@ -944,22 +944,28 @@ SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx)
|
|||||||
SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
|
SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
|
||||||
{
|
{
|
||||||
SQObjectPtr &self = stack_get(v, idx);
|
SQObjectPtr &self = stack_get(v, idx);
|
||||||
if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
|
if(sq_type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
|
||||||
SQObjectPtr &key = v->GetUp(-3);
|
SQObjectPtr &key = v->GetUp(-3);
|
||||||
if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
|
if(sq_type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
|
||||||
if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,false))
|
if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,false)) {
|
||||||
|
v->Pop(3);
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
|
}
|
||||||
|
v->Pop(3);
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
|
SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic)
|
||||||
{
|
{
|
||||||
SQObjectPtr &self = stack_get(v, idx);
|
SQObjectPtr &self = stack_get(v, idx);
|
||||||
if(type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
|
if(sq_type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
|
||||||
SQObjectPtr &key = v->GetUp(-3);
|
SQObjectPtr &key = v->GetUp(-3);
|
||||||
if(type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
|
if(sq_type(key) == OT_NULL) return sq_throwerror(v, _SC("null key"));
|
||||||
if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,true))
|
if(!v->NewSlotA(self,key,v->GetUp(-2),v->GetUp(-1),bstatic?true:false,true)) {
|
||||||
|
v->Pop(3);
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
|
}
|
||||||
|
v->Pop(3);
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -967,23 +973,23 @@ SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx)
|
|||||||
{
|
{
|
||||||
SQObjectPtr &self = stack_get(v, idx);
|
SQObjectPtr &self = stack_get(v, idx);
|
||||||
SQObjectPtr &mt = v->GetUp(-1);
|
SQObjectPtr &mt = v->GetUp(-1);
|
||||||
SQObjectType type = type(self);
|
SQObjectType type = sq_type(self);
|
||||||
switch(type) {
|
switch(type) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if(type(mt) == OT_TABLE) {
|
if(sq_type(mt) == OT_TABLE) {
|
||||||
if(!_table(self)->SetDelegate(_table(mt))) {
|
if(!_table(self)->SetDelegate(_table(mt))) {
|
||||||
return sq_throwerror(v, _SC("delagate cycle"));
|
return sq_throwerror(v, _SC("delagate cycle"));
|
||||||
}
|
}
|
||||||
v->Pop();
|
v->Pop();
|
||||||
}
|
}
|
||||||
else if(type(mt)==OT_NULL) {
|
else if(sq_type(mt)==OT_NULL) {
|
||||||
_table(self)->SetDelegate(NULL); v->Pop(); }
|
_table(self)->SetDelegate(NULL); v->Pop(); }
|
||||||
else return sq_aux_invalidtype(v,type);
|
else return sq_aux_invalidtype(v,type);
|
||||||
break;
|
break;
|
||||||
case OT_USERDATA:
|
case OT_USERDATA:
|
||||||
if(type(mt)==OT_TABLE) {
|
if(sq_type(mt)==OT_TABLE) {
|
||||||
_userdata(self)->SetDelegate(_table(mt)); v->Pop(); }
|
_userdata(self)->SetDelegate(_table(mt)); v->Pop(); }
|
||||||
else if(type(mt)==OT_NULL) {
|
else if(sq_type(mt)==OT_NULL) {
|
||||||
_userdata(self)->SetDelegate(NULL); v->Pop(); }
|
_userdata(self)->SetDelegate(NULL); v->Pop(); }
|
||||||
else return sq_aux_invalidtype(v, type);
|
else return sq_aux_invalidtype(v, type);
|
||||||
break;
|
break;
|
||||||
@ -1014,7 +1020,7 @@ SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval)
|
|||||||
SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx)
|
SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObjectPtr &self=stack_get(v,idx);
|
SQObjectPtr &self=stack_get(v,idx);
|
||||||
switch(type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
case OT_USERDATA:
|
case OT_USERDATA:
|
||||||
if(!_delegable(self)->_delegate){
|
if(!_delegable(self)->_delegate){
|
||||||
@ -1043,7 +1049,7 @@ SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx)
|
|||||||
{
|
{
|
||||||
SQObjectPtr &self=stack_get(v,idx);
|
SQObjectPtr &self=stack_get(v,idx);
|
||||||
SQObjectPtr &obj = v->GetUp(-1);
|
SQObjectPtr &obj = v->GetUp(-1);
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if(_table(self)->Get(obj,obj))
|
if(_table(self)->Get(obj,obj))
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
@ -1093,7 +1099,7 @@ const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedIntege
|
|||||||
stackbase-=ci._prevstkbase;
|
stackbase-=ci._prevstkbase;
|
||||||
}
|
}
|
||||||
SQVM::CallInfo &ci=v->_callsstack[lvl];
|
SQVM::CallInfo &ci=v->_callsstack[lvl];
|
||||||
if(type(ci._closure)!=OT_CLOSURE)
|
if(sq_type(ci._closure)!=OT_CLOSURE)
|
||||||
return NULL;
|
return NULL;
|
||||||
SQClosure *c=_closure(ci._closure);
|
SQClosure *c=_closure(ci._closure);
|
||||||
SQFunctionProto *func=c->_function;
|
SQFunctionProto *func=c->_function;
|
||||||
@ -1154,7 +1160,7 @@ SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize)
|
|||||||
|
|
||||||
SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
|
SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
|
||||||
{
|
{
|
||||||
if (type(v->GetUp(-1)) == OT_GENERATOR)
|
if (sq_type(v->GetUp(-1)) == OT_GENERATOR)
|
||||||
{
|
{
|
||||||
v->PushNull(); //retval
|
v->PushNull(); //retval
|
||||||
if (!v->Execute(v->GetUp(-2), 0, v->_top, v->GetUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
|
if (!v->Execute(v->GetUp(-2), 0, v->_top, v->GetUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
|
||||||
@ -1169,23 +1175,34 @@ SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror)
|
|||||||
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror)
|
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror)
|
||||||
{
|
{
|
||||||
SQObjectPtr res;
|
SQObjectPtr res;
|
||||||
if(v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror?true:false)){
|
if(!v->Call(v->GetUp(-(params+1)),params,v->_top-params,res,raiseerror?true:false)){
|
||||||
|
|
||||||
if(!v->_suspended) {
|
|
||||||
v->Pop(params); //pop args
|
v->Pop(params); //pop args
|
||||||
}
|
|
||||||
if(retval){
|
|
||||||
v->Push(res); return SQ_OK;
|
|
||||||
}
|
|
||||||
return SQ_OK;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v->Pop(params);
|
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
if(!v->_suspended)
|
if(!v->_suspended)
|
||||||
v->Pop(params);
|
v->Pop(params); //pop args
|
||||||
return sq_throwerror(v,_SC("call failed"));
|
if(retval)
|
||||||
|
v->Push(res); // push result
|
||||||
|
return SQ_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
SQRESULT sq_tailcall(HSQUIRRELVM v, SQInteger nparams)
|
||||||
|
{
|
||||||
|
SQObjectPtr &res = v->GetUp(-(nparams + 1));
|
||||||
|
if (sq_type(res) != OT_CLOSURE) {
|
||||||
|
return sq_throwerror(v, _SC("only closure can be tail called"));
|
||||||
|
}
|
||||||
|
SQClosure *clo = _closure(res);
|
||||||
|
if (clo->_function->_bgenerator)
|
||||||
|
{
|
||||||
|
return sq_throwerror(v, _SC("generators cannot be tail called"));
|
||||||
|
}
|
||||||
|
|
||||||
|
SQInteger stackbase = (v->_top - nparams) - v->_stackbase;
|
||||||
|
if (!v->TailCall(clo, stackbase, nparams)) {
|
||||||
|
return SQ_ERROR;
|
||||||
|
}
|
||||||
|
return SQ_TAILCALL_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sq_suspendvm(HSQUIRRELVM v)
|
SQRESULT sq_suspendvm(HSQUIRRELVM v)
|
||||||
@ -1217,7 +1234,7 @@ SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool wakeupret,SQBool retval,SQBool raiseer
|
|||||||
void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
|
void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
|
||||||
{
|
{
|
||||||
SQObjectPtr &ud=stack_get(v,idx);
|
SQObjectPtr &ud=stack_get(v,idx);
|
||||||
switch( type(ud) ) {
|
switch(sq_type(ud) ) {
|
||||||
case OT_USERDATA: _userdata(ud)->_hook = hook; break;
|
case OT_USERDATA: _userdata(ud)->_hook = hook; break;
|
||||||
case OT_INSTANCE: _instance(ud)->_hook = hook; break;
|
case OT_INSTANCE: _instance(ud)->_hook = hook; break;
|
||||||
case OT_CLASS: _class(ud)->_hook = hook; break;
|
case OT_CLASS: _class(ud)->_hook = hook; break;
|
||||||
@ -1228,7 +1245,7 @@ void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook)
|
|||||||
SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx)
|
SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObjectPtr &ud=stack_get(v,idx);
|
SQObjectPtr &ud=stack_get(v,idx);
|
||||||
switch( type(ud) ) {
|
switch(sq_type(ud) ) {
|
||||||
case OT_USERDATA: return _userdata(ud)->_hook; break;
|
case OT_USERDATA: return _userdata(ud)->_hook; break;
|
||||||
case OT_INSTANCE: return _instance(ud)->_hook; break;
|
case OT_INSTANCE: return _instance(ud)->_hook; break;
|
||||||
case OT_CLASS: return _class(ud)->_hook; break;
|
case OT_CLASS: return _class(ud)->_hook; break;
|
||||||
@ -1308,7 +1325,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger n
|
|||||||
{
|
{
|
||||||
SQObjectPtr &self=stack_get(v,idx);
|
SQObjectPtr &self=stack_get(v,idx);
|
||||||
const SQChar *name = NULL;
|
const SQChar *name = NULL;
|
||||||
switch(type(self))
|
switch(sq_type(self))
|
||||||
{
|
{
|
||||||
case OT_CLOSURE:{
|
case OT_CLOSURE:{
|
||||||
SQClosure *clo = _closure(self);
|
SQClosure *clo = _closure(self);
|
||||||
@ -1336,7 +1353,7 @@ const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger n
|
|||||||
SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
|
SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
|
||||||
{
|
{
|
||||||
SQObjectPtr &self=stack_get(v,idx);
|
SQObjectPtr &self=stack_get(v,idx);
|
||||||
switch(type(self))
|
switch(sq_type(self))
|
||||||
{
|
{
|
||||||
case OT_CLOSURE:{
|
case OT_CLOSURE:{
|
||||||
SQFunctionProto *fp = _closure(self)->_function;
|
SQFunctionProto *fp = _closure(self)->_function;
|
||||||
@ -1353,7 +1370,7 @@ SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval)
|
|||||||
else return sq_throwerror(v,_SC("invalid free var index"));
|
else return sq_throwerror(v,_SC("invalid free var index"));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return sq_aux_invalidtype(v,type(self));
|
return sq_aux_invalidtype(v, sq_type(self));
|
||||||
}
|
}
|
||||||
v->Pop();
|
v->Pop();
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
@ -1366,7 +1383,7 @@ SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx)
|
|||||||
SQObjectPtr &key = stack_get(v,-2);
|
SQObjectPtr &key = stack_get(v,-2);
|
||||||
SQObjectPtr &val = stack_get(v,-1);
|
SQObjectPtr &val = stack_get(v,-1);
|
||||||
SQObjectPtr attrs;
|
SQObjectPtr attrs;
|
||||||
if(type(key) == OT_NULL) {
|
if(sq_type(key) == OT_NULL) {
|
||||||
attrs = _class(*o)->_attributes;
|
attrs = _class(*o)->_attributes;
|
||||||
_class(*o)->_attributes = val;
|
_class(*o)->_attributes = val;
|
||||||
v->Pop(2);
|
v->Pop(2);
|
||||||
@ -1387,7 +1404,7 @@ SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx)
|
|||||||
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
|
||||||
SQObjectPtr &key = stack_get(v,-1);
|
SQObjectPtr &key = stack_get(v,-1);
|
||||||
SQObjectPtr attrs;
|
SQObjectPtr attrs;
|
||||||
if(type(key) == OT_NULL) {
|
if(sq_type(key) == OT_NULL) {
|
||||||
attrs = _class(*o)->_attributes;
|
attrs = _class(*o)->_attributes;
|
||||||
v->Pop();
|
v->Pop();
|
||||||
v->Push(attrs);
|
v->Push(attrs);
|
||||||
@ -1419,7 +1436,7 @@ SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle)
|
|||||||
|
|
||||||
SQRESULT _getmemberbyhandle(HSQUIRRELVM v,SQObjectPtr &self,const HSQMEMBERHANDLE *handle,SQObjectPtr *&val)
|
SQRESULT _getmemberbyhandle(HSQUIRRELVM v,SQObjectPtr &self,const HSQMEMBERHANDLE *handle,SQObjectPtr *&val)
|
||||||
{
|
{
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_INSTANCE: {
|
case OT_INSTANCE: {
|
||||||
SQInstance *i = _instance(self);
|
SQInstance *i = _instance(self);
|
||||||
if(handle->_static) {
|
if(handle->_static) {
|
||||||
@ -1502,8 +1519,8 @@ SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx)
|
|||||||
void sq_weakref(HSQUIRRELVM v,SQInteger idx)
|
void sq_weakref(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,idx);
|
SQObject &o=stack_get(v,idx);
|
||||||
if(ISREFCOUNTED(type(o))) {
|
if(ISREFCOUNTED(sq_type(o))) {
|
||||||
v->Push(_refcounted(o)->GetWeakRef(type(o)));
|
v->Push(_refcounted(o)->GetWeakRef(sq_type(o)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
v->Push(o);
|
v->Push(o);
|
||||||
@ -1512,7 +1529,7 @@ void sq_weakref(HSQUIRRELVM v,SQInteger idx)
|
|||||||
SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx)
|
SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,idx);
|
SQObjectPtr &o = stack_get(v,idx);
|
||||||
if(type(o) != OT_WEAKREF) {
|
if(sq_type(o) != OT_WEAKREF) {
|
||||||
return sq_throwerror(v,_SC("the object must be a weakref"));
|
return sq_throwerror(v,_SC("the object must be a weakref"));
|
||||||
}
|
}
|
||||||
v->Push(_weakref(o)->_obj);
|
v->Push(_weakref(o)->_obj);
|
||||||
@ -1541,7 +1558,7 @@ SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t)
|
|||||||
SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx)
|
SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx)
|
||||||
{
|
{
|
||||||
SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
|
SQObjectPtr o=stack_get(v,idx),&refpos = stack_get(v,-1),realkey,val;
|
||||||
if(type(o) == OT_GENERATOR) {
|
if(sq_type(o) == OT_GENERATOR) {
|
||||||
return sq_throwerror(v,_SC("cannot iterate a generator"));
|
return sq_throwerror(v,_SC("cannot iterate a generator"));
|
||||||
}
|
}
|
||||||
int faketojump;
|
int faketojump;
|
||||||
|
90
external/Squirrel/sqbaselib.cpp
vendored
90
external/Squirrel/sqbaselib.cpp
vendored
@ -156,6 +156,13 @@ static SQInteger base_getstackinfos(HSQUIRRELVM v)
|
|||||||
static SQInteger base_assert(HSQUIRRELVM v)
|
static SQInteger base_assert(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
if(SQVM::IsFalse(stack_get(v,2))){
|
if(SQVM::IsFalse(stack_get(v,2))){
|
||||||
|
SQInteger top = sq_gettop(v);
|
||||||
|
if (top>2 && SQ_SUCCEEDED(sq_tostring(v,3))) {
|
||||||
|
const SQChar *str = 0;
|
||||||
|
if (SQ_SUCCEEDED(sq_getstring(v,-1,&str))) {
|
||||||
|
return sq_throwerror(v, str);
|
||||||
|
}
|
||||||
|
}
|
||||||
return sq_throwerror(v, _SC("assertion failed"));
|
return sq_throwerror(v, _SC("assertion failed"));
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -169,7 +176,7 @@ static SQInteger get_slice_params(HSQUIRRELVM v,SQInteger &sidx,SQInteger &eidx,
|
|||||||
o=stack_get(v,1);
|
o=stack_get(v,1);
|
||||||
if(top>1){
|
if(top>1){
|
||||||
SQObjectPtr &start=stack_get(v,2);
|
SQObjectPtr &start=stack_get(v,2);
|
||||||
if(type(start)!=OT_NULL && sq_isnumeric(start)){
|
if(sq_type(start)!=OT_NULL && sq_isnumeric(start)){
|
||||||
sidx=tointeger(start);
|
sidx=tointeger(start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,7 +290,7 @@ static const SQRegFunction base_funcs[]={
|
|||||||
{_SC("setroottable"),base_setroottable,2, NULL},
|
{_SC("setroottable"),base_setroottable,2, NULL},
|
||||||
{_SC("getconsttable"),base_getconsttable,1, NULL},
|
{_SC("getconsttable"),base_getconsttable,1, NULL},
|
||||||
{_SC("setconsttable"),base_setconsttable,2, NULL},
|
{_SC("setconsttable"),base_setconsttable,2, NULL},
|
||||||
{_SC("assert"),base_assert,2, NULL},
|
{_SC("assert"),base_assert,-2, NULL},
|
||||||
{_SC("print"),base_print,2, NULL},
|
{_SC("print"),base_print,2, NULL},
|
||||||
{_SC("error"),base_error,2, NULL},
|
{_SC("error"),base_error,2, NULL},
|
||||||
{_SC("compilestring"),base_compilestring,-2, _SC(".ss")},
|
{_SC("compilestring"),base_compilestring,-2, _SC(".ss")},
|
||||||
@ -340,7 +347,7 @@ static SQInteger default_delegate_len(HSQUIRRELVM v)
|
|||||||
static SQInteger default_delegate_tofloat(HSQUIRRELVM v)
|
static SQInteger default_delegate_tofloat(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o=stack_get(v,1);
|
SQObjectPtr &o=stack_get(v,1);
|
||||||
switch(type(o)){
|
switch(sq_type(o)){
|
||||||
case OT_STRING:{
|
case OT_STRING:{
|
||||||
SQObjectPtr res;
|
SQObjectPtr res;
|
||||||
if(str2num(_stringval(o),res,10)){
|
if(str2num(_stringval(o),res,10)){
|
||||||
@ -369,7 +376,7 @@ static SQInteger default_delegate_tointeger(HSQUIRRELVM v)
|
|||||||
if(sq_gettop(v) > 1) {
|
if(sq_gettop(v) > 1) {
|
||||||
sq_getinteger(v,2,&base);
|
sq_getinteger(v,2,&base);
|
||||||
}
|
}
|
||||||
switch(type(o)){
|
switch(sq_type(o)){
|
||||||
case OT_STRING:{
|
case OT_STRING:{
|
||||||
SQObjectPtr res;
|
SQObjectPtr res;
|
||||||
if(str2num(_stringval(o),res,base)){
|
if(str2num(_stringval(o),res,base)){
|
||||||
@ -406,7 +413,7 @@ static SQInteger obj_delegate_weakref(HSQUIRRELVM v)
|
|||||||
|
|
||||||
static SQInteger obj_clear(HSQUIRRELVM v)
|
static SQInteger obj_clear(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
return sq_clear(v,-1);
|
return SQ_SUCCEEDED(sq_clear(v,-1)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -443,7 +450,7 @@ static SQInteger container_rawexists(HSQUIRRELVM v)
|
|||||||
|
|
||||||
static SQInteger container_rawset(HSQUIRRELVM v)
|
static SQInteger container_rawset(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
return sq_rawset(v,-3);
|
return SQ_SUCCEEDED(sq_rawset(v,-3)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -465,6 +472,34 @@ static SQInteger table_getdelegate(HSQUIRRELVM v)
|
|||||||
return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static SQInteger table_filter(HSQUIRRELVM v)
|
||||||
|
{
|
||||||
|
SQObject &o = stack_get(v,1);
|
||||||
|
SQTable *tbl = _table(o);
|
||||||
|
SQObjectPtr ret = SQTable::Create(_ss(v),0);
|
||||||
|
|
||||||
|
SQObjectPtr itr, key, val;
|
||||||
|
SQInteger nitr;
|
||||||
|
while((nitr = tbl->Next(false, itr, key, val)) != -1) {
|
||||||
|
itr = (SQInteger)nitr;
|
||||||
|
|
||||||
|
v->Push(o);
|
||||||
|
v->Push(key);
|
||||||
|
v->Push(val);
|
||||||
|
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
|
||||||
|
return SQ_ERROR;
|
||||||
|
}
|
||||||
|
if(!SQVM::IsFalse(v->GetUp(-1))) {
|
||||||
|
_table(ret)->NewSlot(key, val);
|
||||||
|
}
|
||||||
|
v->Pop();
|
||||||
|
}
|
||||||
|
|
||||||
|
v->Push(ret);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
||||||
{_SC("len"),default_delegate_len,1, _SC("t")},
|
{_SC("len"),default_delegate_len,1, _SC("t")},
|
||||||
{_SC("rawget"),container_rawget,2, _SC("t")},
|
{_SC("rawget"),container_rawget,2, _SC("t")},
|
||||||
@ -476,6 +511,7 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
|||||||
{_SC("clear"),obj_clear,1, _SC(".")},
|
{_SC("clear"),obj_clear,1, _SC(".")},
|
||||||
{_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")},
|
{_SC("setdelegate"),table_setdelegate,2, _SC(".t|o")},
|
||||||
{_SC("getdelegate"),table_getdelegate,1, _SC(".")},
|
{_SC("getdelegate"),table_getdelegate,1, _SC(".")},
|
||||||
|
{_SC("filter"),table_filter,2, _SC("tc")},
|
||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -483,18 +519,19 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
|||||||
|
|
||||||
static SQInteger array_append(HSQUIRRELVM v)
|
static SQInteger array_append(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
return sq_arrayappend(v,-2);
|
return SQ_SUCCEEDED(sq_arrayappend(v,-2)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_extend(HSQUIRRELVM v)
|
static SQInteger array_extend(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
_array(stack_get(v,1))->Extend(_array(stack_get(v,2)));
|
_array(stack_get(v,1))->Extend(_array(stack_get(v,2)));
|
||||||
return 0;
|
sq_pop(v,1);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_reverse(HSQUIRRELVM v)
|
static SQInteger array_reverse(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
return sq_arrayreverse(v,-1);
|
return SQ_SUCCEEDED(sq_arrayreverse(v,-1)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_pop(HSQUIRRELVM v)
|
static SQInteger array_pop(HSQUIRRELVM v)
|
||||||
@ -519,7 +556,8 @@ static SQInteger array_insert(HSQUIRRELVM v)
|
|||||||
SQObject &val=stack_get(v,3);
|
SQObject &val=stack_get(v,3);
|
||||||
if(!_array(o)->Insert(tointeger(idx),val))
|
if(!_array(o)->Insert(tointeger(idx),val))
|
||||||
return sq_throwerror(v,_SC("index out of range"));
|
return sq_throwerror(v,_SC("index out of range"));
|
||||||
return 0;
|
sq_pop(v,2);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_remove(HSQUIRRELVM v)
|
static SQInteger array_remove(HSQUIRRELVM v)
|
||||||
@ -542,10 +580,15 @@ static SQInteger array_resize(HSQUIRRELVM v)
|
|||||||
SQObject &nsize = stack_get(v, 2);
|
SQObject &nsize = stack_get(v, 2);
|
||||||
SQObjectPtr fill;
|
SQObjectPtr fill;
|
||||||
if(sq_isnumeric(nsize)) {
|
if(sq_isnumeric(nsize)) {
|
||||||
|
SQInteger sz = tointeger(nsize);
|
||||||
|
if (sz<0)
|
||||||
|
return sq_throwerror(v, _SC("resizing to negative length"));
|
||||||
|
|
||||||
if(sq_gettop(v) > 2)
|
if(sq_gettop(v) > 2)
|
||||||
fill = stack_get(v, 3);
|
fill = stack_get(v, 3);
|
||||||
_array(o)->Resize(tointeger(nsize),fill);
|
_array(o)->Resize(sz,fill);
|
||||||
return 0;
|
sq_settop(v, 1);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return sq_throwerror(v, _SC("size must be a number"));
|
return sq_throwerror(v, _SC("size must be a number"));
|
||||||
}
|
}
|
||||||
@ -582,7 +625,8 @@ static SQInteger array_apply(HSQUIRRELVM v)
|
|||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
if(SQ_FAILED(__map_array(_array(o),_array(o),v)))
|
if(SQ_FAILED(__map_array(_array(o),_array(o),v)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
return 0;
|
sq_pop(v,1);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_reduce(HSQUIRRELVM v)
|
static SQInteger array_reduce(HSQUIRRELVM v)
|
||||||
@ -749,7 +793,8 @@ static SQInteger array_sort(HSQUIRRELVM v)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
sq_settop(v,1);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SQInteger array_slice(HSQUIRRELVM v)
|
static SQInteger array_slice(HSQUIRRELVM v)
|
||||||
@ -885,6 +930,11 @@ static SQInteger closure_pcall(HSQUIRRELVM v)
|
|||||||
|
|
||||||
static SQInteger closure_call(HSQUIRRELVM v)
|
static SQInteger closure_call(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
|
SQObjectPtr &c = stack_get(v, -1);
|
||||||
|
if (sq_type(c) == OT_CLOSURE && (_closure(c)->_function->_bgenerator == false))
|
||||||
|
{
|
||||||
|
return sq_tailcall(v, sq_gettop(v) - 1);
|
||||||
|
}
|
||||||
return SQ_SUCCEEDED(sq_call(v, sq_gettop(v) - 1, SQTrue, SQTrue)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_call(v, sq_gettop(v) - 1, SQTrue, SQTrue)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,7 +981,7 @@ static SQInteger closure_setroot(HSQUIRRELVM v)
|
|||||||
static SQInteger closure_getinfos(HSQUIRRELVM v) {
|
static SQInteger closure_getinfos(HSQUIRRELVM v) {
|
||||||
SQObject o = stack_get(v,1);
|
SQObject o = stack_get(v,1);
|
||||||
SQTable *res = SQTable::Create(_ss(v),4);
|
SQTable *res = SQTable::Create(_ss(v),4);
|
||||||
if(type(o) == OT_CLOSURE) {
|
if(sq_type(o) == OT_CLOSURE) {
|
||||||
SQFunctionProto *f = _closure(o)->_function;
|
SQFunctionProto *f = _closure(o)->_function;
|
||||||
SQInteger nparams = f->_nparameters + (f->_varparams?1:0);
|
SQInteger nparams = f->_nparameters + (f->_varparams?1:0);
|
||||||
SQObjectPtr params = SQArray::Create(_ss(v),nparams);
|
SQObjectPtr params = SQArray::Create(_ss(v),nparams);
|
||||||
@ -1010,7 +1060,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
|
|||||||
static SQInteger thread_call(HSQUIRRELVM v)
|
static SQInteger thread_call(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQInteger nparams = sq_gettop(v);
|
SQInteger nparams = sq_gettop(v);
|
||||||
_thread(o)->Push(_thread(o)->_roottable);
|
_thread(o)->Push(_thread(o)->_roottable);
|
||||||
for(SQInteger i = 2; i<(nparams+1); i++)
|
for(SQInteger i = 2; i<(nparams+1); i++)
|
||||||
@ -1029,7 +1079,7 @@ static SQInteger thread_call(HSQUIRRELVM v)
|
|||||||
static SQInteger thread_wakeup(HSQUIRRELVM v)
|
static SQInteger thread_wakeup(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
SQVM *thread = _thread(o);
|
||||||
SQInteger state = sq_getvmstate(thread);
|
SQInteger state = sq_getvmstate(thread);
|
||||||
if(state != SQ_VMSTATE_SUSPENDED) {
|
if(state != SQ_VMSTATE_SUSPENDED) {
|
||||||
@ -1065,7 +1115,7 @@ static SQInteger thread_wakeup(HSQUIRRELVM v)
|
|||||||
static SQInteger thread_wakeupthrow(HSQUIRRELVM v)
|
static SQInteger thread_wakeupthrow(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
SQVM *thread = _thread(o);
|
||||||
SQInteger state = sq_getvmstate(thread);
|
SQInteger state = sq_getvmstate(thread);
|
||||||
if(state != SQ_VMSTATE_SUSPENDED) {
|
if(state != SQ_VMSTATE_SUSPENDED) {
|
||||||
@ -1125,7 +1175,7 @@ static SQInteger thread_getstatus(HSQUIRRELVM v)
|
|||||||
static SQInteger thread_getstackinfos(HSQUIRRELVM v)
|
static SQInteger thread_getstackinfos(HSQUIRRELVM v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
SQVM *thread = _thread(o);
|
||||||
SQInteger threadtop = sq_gettop(thread);
|
SQInteger threadtop = sq_gettop(thread);
|
||||||
SQInteger level;
|
SQInteger level;
|
||||||
@ -1134,7 +1184,7 @@ static SQInteger thread_getstackinfos(HSQUIRRELVM v)
|
|||||||
if(SQ_FAILED(res))
|
if(SQ_FAILED(res))
|
||||||
{
|
{
|
||||||
sq_settop(thread,threadtop);
|
sq_settop(thread,threadtop);
|
||||||
if(type(thread->_lasterror) == OT_STRING) {
|
if(sq_type(thread->_lasterror) == OT_STRING) {
|
||||||
sq_throwerror(v,_stringval(thread->_lasterror));
|
sq_throwerror(v,_stringval(thread->_lasterror));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
10
external/Squirrel/sqclass.cpp
vendored
10
external/Squirrel/sqclass.cpp
vendored
@ -53,7 +53,7 @@ SQClass::~SQClass()
|
|||||||
bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
|
bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
|
||||||
{
|
{
|
||||||
SQObjectPtr temp;
|
SQObjectPtr temp;
|
||||||
bool belongs_to_static_table = type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE || bstatic;
|
bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;
|
||||||
if(_locked && !belongs_to_static_table)
|
if(_locked && !belongs_to_static_table)
|
||||||
return false; //the class already has an instance so cannot be modified
|
return false; //the class already has an instance so cannot be modified
|
||||||
if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
|
if(_members->Get(key,temp) && _isfield(temp)) //overrides the default value
|
||||||
@ -63,18 +63,18 @@ bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr
|
|||||||
}
|
}
|
||||||
if(belongs_to_static_table) {
|
if(belongs_to_static_table) {
|
||||||
SQInteger mmidx;
|
SQInteger mmidx;
|
||||||
if((type(val) == OT_CLOSURE || type(val) == OT_NATIVECLOSURE) &&
|
if((sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE) &&
|
||||||
(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
|
(mmidx = ss->GetMetaMethodIdxByName(key)) != -1) {
|
||||||
_metamethods[mmidx] = val;
|
_metamethods[mmidx] = val;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SQObjectPtr theval = val;
|
SQObjectPtr theval = val;
|
||||||
if(_base && type(val) == OT_CLOSURE) {
|
if(_base && sq_type(val) == OT_CLOSURE) {
|
||||||
theval = _closure(val)->Clone();
|
theval = _closure(val)->Clone();
|
||||||
_closure(theval)->_base = _base;
|
_closure(theval)->_base = _base;
|
||||||
__ObjAddRef(_base); //ref for the closure
|
__ObjAddRef(_base); //ref for the closure
|
||||||
}
|
}
|
||||||
if(type(temp) == OT_NULL) {
|
if(sq_type(temp) == OT_NULL) {
|
||||||
bool isconstructor;
|
bool isconstructor;
|
||||||
SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
|
SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
|
||||||
if(isconstructor) {
|
if(isconstructor) {
|
||||||
@ -191,7 +191,7 @@ SQInstance::~SQInstance()
|
|||||||
|
|
||||||
bool SQInstance::GetMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res)
|
bool SQInstance::GetMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
if(type(_class->_metamethods[mm]) != OT_NULL) {
|
if(sq_type(_class->_metamethods[mm]) != OT_NULL) {
|
||||||
res = _class->_metamethods[mm];
|
res = _class->_metamethods[mm];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
49
external/Squirrel/sqcompiler.cpp
vendored
49
external/Squirrel/sqcompiler.cpp
vendored
@ -191,7 +191,7 @@ public:
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
|
if(_raiseerror && _ss(_vm)->_compilererrorhandler) {
|
||||||
_ss(_vm)->_compilererrorhandler(_vm, _compilererror, type(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
|
_ss(_vm)->_compilererrorhandler(_vm, _compilererror, sq_type(_sourcename) == OT_STRING?_stringval(_sourcename):_SC("unknown"),
|
||||||
_lex._currentline, _lex._currentcolumn);
|
_lex._currentline, _lex._currentcolumn);
|
||||||
}
|
}
|
||||||
_vm->_lasterror = SQString::Create(_ss(_vm), _compilererror, -1);
|
_vm->_lasterror = SQString::Create(_ss(_vm), _compilererror, -1);
|
||||||
@ -443,8 +443,8 @@ public:
|
|||||||
Expression();
|
Expression();
|
||||||
SQInteger second_exp = _fs->PopTarget();
|
SQInteger second_exp = _fs->PopTarget();
|
||||||
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
||||||
_fs->SetIntructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
|
_fs->SetInstructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
|
||||||
_fs->SetIntructionParam(jzpos, 1, endfirstexp - jzpos + 1);
|
_fs->SetInstructionParam(jzpos, 1, endfirstexp - jzpos + 1);
|
||||||
_fs->SnoozeOpt();
|
_fs->SnoozeOpt();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -482,7 +482,7 @@ public:
|
|||||||
SQInteger second_exp = _fs->PopTarget();
|
SQInteger second_exp = _fs->PopTarget();
|
||||||
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
||||||
_fs->SnoozeOpt();
|
_fs->SnoozeOpt();
|
||||||
_fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
|
_fs->SetInstructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
|
||||||
_es.etype = EXPR;
|
_es.etype = EXPR;
|
||||||
break;
|
break;
|
||||||
}else return;
|
}else return;
|
||||||
@ -502,7 +502,7 @@ public:
|
|||||||
SQInteger second_exp = _fs->PopTarget();
|
SQInteger second_exp = _fs->PopTarget();
|
||||||
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp);
|
||||||
_fs->SnoozeOpt();
|
_fs->SnoozeOpt();
|
||||||
_fs->SetIntructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
|
_fs->SetInstructionParam(jpos, 1, (_fs->GetCurrentPos() - jpos));
|
||||||
_es.etype = EXPR;
|
_es.etype = EXPR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -765,7 +765,7 @@ public:
|
|||||||
/* Handle named constant */
|
/* Handle named constant */
|
||||||
SQObjectPtr constval;
|
SQObjectPtr constval;
|
||||||
SQObject constid;
|
SQObject constid;
|
||||||
if(type(constant) == OT_TABLE) {
|
if(sq_type(constant) == OT_TABLE) {
|
||||||
Expect('.');
|
Expect('.');
|
||||||
constid = Expect(TK_IDENTIFIER);
|
constid = Expect(TK_IDENTIFIER);
|
||||||
if(!_table(constant)->Get(constid, constval)) {
|
if(!_table(constant)->Get(constid, constval)) {
|
||||||
@ -779,7 +779,7 @@ public:
|
|||||||
_es.epos = _fs->PushTarget();
|
_es.epos = _fs->PushTarget();
|
||||||
|
|
||||||
/* generate direct or literal function depending on size */
|
/* generate direct or literal function depending on size */
|
||||||
SQObjectType ctype = type(constval);
|
SQObjectType ctype = sq_type(constval);
|
||||||
switch(ctype) {
|
switch(ctype) {
|
||||||
case OT_INTEGER: EmitLoadConstInt(_integer(constval),_es.epos); break;
|
case OT_INTEGER: EmitLoadConstInt(_integer(constval),_es.epos); break;
|
||||||
case OT_FLOAT: EmitLoadConstFloat(_float(constval),_es.epos); break;
|
case OT_FLOAT: EmitLoadConstFloat(_float(constval),_es.epos); break;
|
||||||
@ -834,7 +834,7 @@ public:
|
|||||||
_fs->AddInstruction(_OP_APPENDARRAY, array, val, AAT_STACK);
|
_fs->AddInstruction(_OP_APPENDARRAY, array, val, AAT_STACK);
|
||||||
key++;
|
key++;
|
||||||
}
|
}
|
||||||
_fs->SetIntructionParam(apos, 1, key);
|
_fs->SetInstructionParam(apos, 1, key);
|
||||||
Lex();
|
Lex();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1002,7 +1002,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(separator == _SC(',')) //hack recognizes a table from the separator
|
if(separator == _SC(',')) //hack recognizes a table from the separator
|
||||||
_fs->SetIntructionParam(tpos, 1, nkeys);
|
_fs->SetInstructionParam(tpos, 1, nkeys);
|
||||||
Lex();
|
Lex();
|
||||||
}
|
}
|
||||||
void LocalDeclStatement()
|
void LocalDeclStatement()
|
||||||
@ -1092,9 +1092,9 @@ public:
|
|||||||
//Statement(); if(_lex._prevtoken != _SC('}')) OptionalSemicolon();
|
//Statement(); if(_lex._prevtoken != _SC('}')) OptionalSemicolon();
|
||||||
IfBlock();
|
IfBlock();
|
||||||
//END_SCOPE();
|
//END_SCOPE();
|
||||||
_fs->SetIntructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
|
_fs->SetInstructionParam(jmppos, 1, _fs->GetCurrentPos() - jmppos);
|
||||||
}
|
}
|
||||||
_fs->SetIntructionParam(jnepos, 1, endifblock - jnepos + (haselse?1:0));
|
_fs->SetInstructionParam(jnepos, 1, endifblock - jnepos + (haselse?1:0));
|
||||||
}
|
}
|
||||||
void WhileStatement()
|
void WhileStatement()
|
||||||
{
|
{
|
||||||
@ -1111,7 +1111,7 @@ public:
|
|||||||
|
|
||||||
END_SCOPE();
|
END_SCOPE();
|
||||||
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
|
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
|
||||||
_fs->SetIntructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
|
_fs->SetInstructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
|
||||||
|
|
||||||
END_BREAKBLE_BLOCK(jmppos);
|
END_BREAKBLE_BLOCK(jmppos);
|
||||||
}
|
}
|
||||||
@ -1170,10 +1170,11 @@ public:
|
|||||||
_fs->AddInstruction(exp[i]);
|
_fs->AddInstruction(exp[i]);
|
||||||
}
|
}
|
||||||
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1, 0);
|
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1, 0);
|
||||||
if(jzpos> 0) _fs->SetIntructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
|
if(jzpos> 0) _fs->SetInstructionParam(jzpos, 1, _fs->GetCurrentPos() - jzpos);
|
||||||
END_SCOPE();
|
|
||||||
|
|
||||||
END_BREAKBLE_BLOCK(continuetrg);
|
END_BREAKBLE_BLOCK(continuetrg);
|
||||||
|
|
||||||
|
END_SCOPE();
|
||||||
}
|
}
|
||||||
void ForEachStatement()
|
void ForEachStatement()
|
||||||
{
|
{
|
||||||
@ -1210,8 +1211,8 @@ public:
|
|||||||
BEGIN_BREAKBLE_BLOCK()
|
BEGIN_BREAKBLE_BLOCK()
|
||||||
Statement();
|
Statement();
|
||||||
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
|
_fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->GetCurrentPos() - 1);
|
||||||
_fs->SetIntructionParam(foreachpos, 1, _fs->GetCurrentPos() - foreachpos);
|
_fs->SetInstructionParam(foreachpos, 1, _fs->GetCurrentPos() - foreachpos);
|
||||||
_fs->SetIntructionParam(foreachpos + 1, 1, _fs->GetCurrentPos() - foreachpos);
|
_fs->SetInstructionParam(foreachpos + 1, 1, _fs->GetCurrentPos() - foreachpos);
|
||||||
END_BREAKBLE_BLOCK(foreachpos - 1);
|
END_BREAKBLE_BLOCK(foreachpos - 1);
|
||||||
//restore the local variable stack(remove index,val and ref idx)
|
//restore the local variable stack(remove index,val and ref idx)
|
||||||
_fs->PopTarget();
|
_fs->PopTarget();
|
||||||
@ -1231,7 +1232,7 @@ public:
|
|||||||
if(!bfirst) {
|
if(!bfirst) {
|
||||||
_fs->AddInstruction(_OP_JMP, 0, 0);
|
_fs->AddInstruction(_OP_JMP, 0, 0);
|
||||||
skipcondjmp = _fs->GetCurrentPos();
|
skipcondjmp = _fs->GetCurrentPos();
|
||||||
_fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
|
_fs->SetInstructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
|
||||||
}
|
}
|
||||||
//condition
|
//condition
|
||||||
Lex(); Expression(); Expect(_SC(':'));
|
Lex(); Expression(); Expect(_SC(':'));
|
||||||
@ -1249,7 +1250,7 @@ public:
|
|||||||
|
|
||||||
//end condition
|
//end condition
|
||||||
if(skipcondjmp != -1) {
|
if(skipcondjmp != -1) {
|
||||||
_fs->SetIntructionParam(skipcondjmp, 1, (_fs->GetCurrentPos() - skipcondjmp));
|
_fs->SetInstructionParam(skipcondjmp, 1, (_fs->GetCurrentPos() - skipcondjmp));
|
||||||
}
|
}
|
||||||
tonextcondjmp = _fs->GetCurrentPos();
|
tonextcondjmp = _fs->GetCurrentPos();
|
||||||
BEGIN_SCOPE();
|
BEGIN_SCOPE();
|
||||||
@ -1258,7 +1259,7 @@ public:
|
|||||||
bfirst = false;
|
bfirst = false;
|
||||||
}
|
}
|
||||||
if(tonextcondjmp != -1)
|
if(tonextcondjmp != -1)
|
||||||
_fs->SetIntructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
|
_fs->SetInstructionParam(tonextcondjmp, 1, _fs->GetCurrentPos() - tonextcondjmp);
|
||||||
if(_token == TK_DEFAULT) {
|
if(_token == TK_DEFAULT) {
|
||||||
Lex(); Expect(_SC(':'));
|
Lex(); Expect(_SC(':'));
|
||||||
BEGIN_SCOPE();
|
BEGIN_SCOPE();
|
||||||
@ -1402,14 +1403,14 @@ public:
|
|||||||
if(_fs->_continuetargets.size()) _fs->_continuetargets.top()--;
|
if(_fs->_continuetargets.size()) _fs->_continuetargets.top()--;
|
||||||
_fs->AddInstruction(_OP_JMP, 0, 0);
|
_fs->AddInstruction(_OP_JMP, 0, 0);
|
||||||
SQInteger jmppos = _fs->GetCurrentPos();
|
SQInteger jmppos = _fs->GetCurrentPos();
|
||||||
_fs->SetIntructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos));
|
_fs->SetInstructionParam(trappos, 1, (_fs->GetCurrentPos() - trappos));
|
||||||
Expect(TK_CATCH); Expect(_SC('(')); exid = Expect(TK_IDENTIFIER); Expect(_SC(')'));
|
Expect(TK_CATCH); Expect(_SC('(')); exid = Expect(TK_IDENTIFIER); Expect(_SC(')'));
|
||||||
{
|
{
|
||||||
BEGIN_SCOPE();
|
BEGIN_SCOPE();
|
||||||
SQInteger ex_target = _fs->PushLocalVariable(exid);
|
SQInteger ex_target = _fs->PushLocalVariable(exid);
|
||||||
_fs->SetIntructionParam(trappos, 0, ex_target);
|
_fs->SetInstructionParam(trappos, 0, ex_target);
|
||||||
Statement();
|
Statement();
|
||||||
_fs->SetIntructionParams(jmppos, 0, (_fs->GetCurrentPos() - jmppos), 0);
|
_fs->SetInstructionParams(jmppos, 0, (_fs->GetCurrentPos() - jmppos), 0);
|
||||||
END_SCOPE();
|
END_SCOPE();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1547,7 +1548,7 @@ public:
|
|||||||
SQInteger pos = funcstate->_unresolvedbreaks.back();
|
SQInteger pos = funcstate->_unresolvedbreaks.back();
|
||||||
funcstate->_unresolvedbreaks.pop_back();
|
funcstate->_unresolvedbreaks.pop_back();
|
||||||
//set the jmp instruction
|
//set the jmp instruction
|
||||||
funcstate->SetIntructionParams(pos, 0, funcstate->GetCurrentPos() - pos, 0);
|
funcstate->SetInstructionParams(pos, 0, funcstate->GetCurrentPos() - pos, 0);
|
||||||
ntoresolve--;
|
ntoresolve--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1557,7 +1558,7 @@ public:
|
|||||||
SQInteger pos = funcstate->_unresolvedcontinues.back();
|
SQInteger pos = funcstate->_unresolvedcontinues.back();
|
||||||
funcstate->_unresolvedcontinues.pop_back();
|
funcstate->_unresolvedcontinues.pop_back();
|
||||||
//set the jmp instruction
|
//set the jmp instruction
|
||||||
funcstate->SetIntructionParams(pos, 0, targetpos - pos, 0);
|
funcstate->SetInstructionParams(pos, 0, targetpos - pos, 0);
|
||||||
ntoresolve--;
|
ntoresolve--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
external/Squirrel/sqdebug.cpp
vendored
14
external/Squirrel/sqdebug.cpp
vendored
@ -17,8 +17,8 @@ SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi)
|
|||||||
SQClosure *c = _closure(ci._closure);
|
SQClosure *c = _closure(ci._closure);
|
||||||
SQFunctionProto *proto = c->_function;
|
SQFunctionProto *proto = c->_function;
|
||||||
fi->funcid = proto;
|
fi->funcid = proto;
|
||||||
fi->name = type(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
|
fi->name = sq_type(proto->_name) == OT_STRING?_stringval(proto->_name):_SC("unknown");
|
||||||
fi->source = type(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
|
fi->source = sq_type(proto->_sourcename) == OT_STRING?_stringval(proto->_sourcename):_SC("unknown");
|
||||||
fi->line = proto->_lineinfos[0]._line;
|
fi->line = proto->_lineinfos[0]._line;
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
@ -32,12 +32,12 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
|
|||||||
if (cssize > level) {
|
if (cssize > level) {
|
||||||
memset(si, 0, sizeof(SQStackInfos));
|
memset(si, 0, sizeof(SQStackInfos));
|
||||||
SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
|
SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
|
||||||
switch (type(ci._closure)) {
|
switch (sq_type(ci._closure)) {
|
||||||
case OT_CLOSURE:{
|
case OT_CLOSURE:{
|
||||||
SQFunctionProto *func = _closure(ci._closure)->_function;
|
SQFunctionProto *func = _closure(ci._closure)->_function;
|
||||||
if (type(func->_name) == OT_STRING)
|
if (sq_type(func->_name) == OT_STRING)
|
||||||
si->funcname = _stringval(func->_name);
|
si->funcname = _stringval(func->_name);
|
||||||
if (type(func->_sourcename) == OT_STRING)
|
if (sq_type(func->_sourcename) == OT_STRING)
|
||||||
si->source = _stringval(func->_sourcename);
|
si->source = _stringval(func->_sourcename);
|
||||||
si->line = func->GetLine(ci._ip);
|
si->line = func->GetLine(ci._ip);
|
||||||
}
|
}
|
||||||
@ -45,7 +45,7 @@ SQRESULT sq_stackinfos(HSQUIRRELVM v, SQInteger level, SQStackInfos *si)
|
|||||||
case OT_NATIVECLOSURE:
|
case OT_NATIVECLOSURE:
|
||||||
si->source = _SC("NATIVE");
|
si->source = _SC("NATIVE");
|
||||||
si->funcname = _SC("unknown");
|
si->funcname = _SC("unknown");
|
||||||
if(type(_nativeclosure(ci._closure)->_name) == OT_STRING)
|
if(sq_type(_nativeclosure(ci._closure)->_name) == OT_STRING)
|
||||||
si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
|
si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
|
||||||
si->line = -1;
|
si->line = -1;
|
||||||
break;
|
break;
|
||||||
@ -73,7 +73,7 @@ void SQVM::Raise_Error(const SQObjectPtr &desc)
|
|||||||
|
|
||||||
SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
|
SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
switch(type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_STRING: return _string(o);
|
case OT_STRING: return _string(o);
|
||||||
case OT_INTEGER:
|
case OT_INTEGER:
|
||||||
scsprintf(_sp(sq_rsl(NUMBER_MAX_CHAR+1)),sq_rsl(NUMBER_MAX_CHAR), _PRINT_INT_FMT, _integer(o));
|
scsprintf(_sp(sq_rsl(NUMBER_MAX_CHAR+1)),sq_rsl(NUMBER_MAX_CHAR), _PRINT_INT_FMT, _integer(o));
|
||||||
|
16
external/Squirrel/sqfuncstate.cpp
vendored
16
external/Squirrel/sqfuncstate.cpp
vendored
@ -77,7 +77,7 @@ SQInstructionDesc g_InstrDesc[]={
|
|||||||
#endif
|
#endif
|
||||||
void DumpLiteral(SQObjectPtr &o)
|
void DumpLiteral(SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
switch(type(o)){
|
switch(sq_type(o)){
|
||||||
case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
|
case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
|
||||||
case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
|
case OT_FLOAT: scprintf(_SC("{%f}"),_float(o));break;
|
||||||
case OT_INTEGER: scprintf(_SC("{") _PRINT_INT_FMT _SC("}"),_integer(o));break;
|
case OT_INTEGER: scprintf(_SC("{") _PRINT_INT_FMT _SC("}"),_integer(o));break;
|
||||||
@ -120,7 +120,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
|
|||||||
scprintf(_SC("SQInstruction sizeof %d\n"),(SQInt32)sizeof(SQInstruction));
|
scprintf(_SC("SQInstruction sizeof %d\n"),(SQInt32)sizeof(SQInstruction));
|
||||||
scprintf(_SC("SQObject sizeof %d\n"), (SQInt32)sizeof(SQObject));
|
scprintf(_SC("SQObject sizeof %d\n"), (SQInt32)sizeof(SQObject));
|
||||||
scprintf(_SC("--------------------------------------------------------------------\n"));
|
scprintf(_SC("--------------------------------------------------------------------\n"));
|
||||||
scprintf(_SC("*****FUNCTION [%s]\n"),type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
|
scprintf(_SC("*****FUNCTION [%s]\n"),sq_type(func->_name)==OT_STRING?_stringval(func->_name):_SC("unknown"));
|
||||||
scprintf(_SC("-----LITERALS\n"));
|
scprintf(_SC("-----LITERALS\n"));
|
||||||
SQObjectPtr refidx,key,val;
|
SQObjectPtr refidx,key,val;
|
||||||
SQInteger idx;
|
SQInteger idx;
|
||||||
@ -238,7 +238,7 @@ SQInteger SQFuncState::GetConstant(const SQObject &cons)
|
|||||||
return _integer(val);
|
return _integer(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQFuncState::SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2,SQInteger arg3)
|
void SQFuncState::SetInstructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2,SQInteger arg3)
|
||||||
{
|
{
|
||||||
_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&arg0);
|
_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&arg0);
|
||||||
_instructions[pos]._arg1=(SQInt32)*((SQUnsignedInteger *)&arg1);
|
_instructions[pos]._arg1=(SQInt32)*((SQUnsignedInteger *)&arg1);
|
||||||
@ -246,7 +246,7 @@ void SQFuncState::SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg
|
|||||||
_instructions[pos]._arg3=(unsigned char)*((SQUnsignedInteger *)&arg3);
|
_instructions[pos]._arg3=(unsigned char)*((SQUnsignedInteger *)&arg3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQFuncState::SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val)
|
void SQFuncState::SetInstructionParam(SQInteger pos,SQInteger arg,SQInteger val)
|
||||||
{
|
{
|
||||||
switch(arg){
|
switch(arg){
|
||||||
case 0:_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&val);break;
|
case 0:_instructions[pos]._arg0=(unsigned char)*((SQUnsignedInteger *)&val);break;
|
||||||
@ -290,7 +290,7 @@ SQInteger SQFuncState::PopTarget()
|
|||||||
SQUnsignedInteger npos=_targetstack.back();
|
SQUnsignedInteger npos=_targetstack.back();
|
||||||
assert(npos < _vlocals.size());
|
assert(npos < _vlocals.size());
|
||||||
SQLocalVarInfo &t = _vlocals[npos];
|
SQLocalVarInfo &t = _vlocals[npos];
|
||||||
if(type(t._name)==OT_NULL){
|
if(sq_type(t._name)==OT_NULL){
|
||||||
_vlocals.pop_back();
|
_vlocals.pop_back();
|
||||||
}
|
}
|
||||||
_targetstack.pop_back();
|
_targetstack.pop_back();
|
||||||
@ -322,7 +322,7 @@ void SQFuncState::SetStackSize(SQInteger n)
|
|||||||
while(size>n){
|
while(size>n){
|
||||||
size--;
|
size--;
|
||||||
SQLocalVarInfo lvi = _vlocals.back();
|
SQLocalVarInfo lvi = _vlocals.back();
|
||||||
if(type(lvi._name)!=OT_NULL){
|
if(sq_type(lvi._name)!=OT_NULL){
|
||||||
if(lvi._end_op == UINT_MINUS_ONE) { //this means is an outer
|
if(lvi._end_op == UINT_MINUS_ONE) { //this means is an outer
|
||||||
_outers--;
|
_outers--;
|
||||||
}
|
}
|
||||||
@ -346,7 +346,7 @@ bool SQFuncState::IsConstant(const SQObject &name,SQObject &e)
|
|||||||
bool SQFuncState::IsLocal(SQUnsignedInteger stkpos)
|
bool SQFuncState::IsLocal(SQUnsignedInteger stkpos)
|
||||||
{
|
{
|
||||||
if(stkpos>=_vlocals.size())return false;
|
if(stkpos>=_vlocals.size())return false;
|
||||||
else if(type(_vlocals[stkpos]._name)!=OT_NULL)return true;
|
else if(sq_type(_vlocals[stkpos]._name)!=OT_NULL)return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,7 +369,7 @@ SQInteger SQFuncState::GetLocalVariable(const SQObject &name)
|
|||||||
SQInteger locals=_vlocals.size();
|
SQInteger locals=_vlocals.size();
|
||||||
while(locals>=1){
|
while(locals>=1){
|
||||||
SQLocalVarInfo &lvi = _vlocals[locals-1];
|
SQLocalVarInfo &lvi = _vlocals[locals-1];
|
||||||
if(type(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
|
if(sq_type(lvi._name)==OT_STRING && _string(lvi._name)==_string(name)){
|
||||||
return locals-1;
|
return locals-1;
|
||||||
}
|
}
|
||||||
locals--;
|
locals--;
|
||||||
|
4
external/Squirrel/sqfuncstate.h
vendored
4
external/Squirrel/sqfuncstate.h
vendored
@ -16,8 +16,8 @@ struct SQFuncState
|
|||||||
void PopChildState();
|
void PopChildState();
|
||||||
void AddInstruction(SQOpcode _op,SQInteger arg0=0,SQInteger arg1=0,SQInteger arg2=0,SQInteger arg3=0){SQInstruction i(_op,arg0,arg1,arg2,arg3);AddInstruction(i);}
|
void AddInstruction(SQOpcode _op,SQInteger arg0=0,SQInteger arg1=0,SQInteger arg2=0,SQInteger arg3=0){SQInstruction i(_op,arg0,arg1,arg2,arg3);AddInstruction(i);}
|
||||||
void AddInstruction(SQInstruction &i);
|
void AddInstruction(SQInstruction &i);
|
||||||
void SetIntructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
|
void SetInstructionParams(SQInteger pos,SQInteger arg0,SQInteger arg1,SQInteger arg2=0,SQInteger arg3=0);
|
||||||
void SetIntructionParam(SQInteger pos,SQInteger arg,SQInteger val);
|
void SetInstructionParam(SQInteger pos,SQInteger arg,SQInteger val);
|
||||||
SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
|
SQInstruction &GetInstruction(SQInteger pos){return _instructions[pos];}
|
||||||
void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
|
void PopInstructions(SQInteger size){for(SQInteger i=0;i<size;i++)_instructions.pop_back();}
|
||||||
void SetStackSize(SQInteger n);
|
void SetStackSize(SQInteger n);
|
||||||
|
2
external/Squirrel/sqlexer.cpp
vendored
2
external/Squirrel/sqlexer.cpp
vendored
@ -383,7 +383,7 @@ SQInteger SQLexer::ReadString(SQInteger ndelim,bool verbatim)
|
|||||||
break;
|
break;
|
||||||
case _SC('U'):
|
case _SC('U'):
|
||||||
case _SC('u'): {
|
case _SC('u'): {
|
||||||
const SQInteger maxdigits = x == 'u' ? 4 : 8;
|
const SQInteger maxdigits = CUR_CHAR == 'u' ? 4 : 8;
|
||||||
SQChar temp[8 + 1];
|
SQChar temp[8 + 1];
|
||||||
ProcessStringHexEscape(temp, maxdigits);
|
ProcessStringHexEscape(temp, maxdigits);
|
||||||
SQChar *stemp;
|
SQChar *stemp;
|
||||||
|
16
external/Squirrel/sqobject.cpp
vendored
16
external/Squirrel/sqobject.cpp
vendored
@ -43,7 +43,7 @@ const SQChar *IdType2Name(SQObjectType type)
|
|||||||
|
|
||||||
const SQChar *GetTypeName(const SQObjectPtr &obj1)
|
const SQChar *GetTypeName(const SQObjectPtr &obj1)
|
||||||
{
|
{
|
||||||
return IdType2Name(type(obj1));
|
return IdType2Name(sq_type(obj1));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQString *SQString::Create(SQSharedState *ss,const SQChar *s,SQInteger len)
|
SQString *SQString::Create(SQSharedState *ss,const SQChar *s,SQInteger len)
|
||||||
@ -72,7 +72,7 @@ SQInteger SQString::Next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjec
|
|||||||
|
|
||||||
SQUnsignedInteger TranslateIndex(const SQObjectPtr &idx)
|
SQUnsignedInteger TranslateIndex(const SQObjectPtr &idx)
|
||||||
{
|
{
|
||||||
switch(type(idx)){
|
switch(sq_type(idx)){
|
||||||
case OT_NULL:
|
case OT_NULL:
|
||||||
return 0;
|
return 0;
|
||||||
case OT_INTEGER:
|
case OT_INTEGER:
|
||||||
@ -139,7 +139,7 @@ bool SQGenerator::Yield(SQVM *v,SQInteger target)
|
|||||||
|
|
||||||
_stack.resize(size);
|
_stack.resize(size);
|
||||||
SQObject _this = v->_stack[v->_stackbase];
|
SQObject _this = v->_stack[v->_stackbase];
|
||||||
_stack._vals[0] = ISREFCOUNTED(type(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(type(_this))) : _this;
|
_stack._vals[0] = ISREFCOUNTED(sq_type(_this)) ? SQObjectPtr(_refcounted(_this)->GetWeakRef(sq_type(_this))) : _this;
|
||||||
for(SQInteger n =1; n<target; n++) {
|
for(SQInteger n =1; n<target; n++) {
|
||||||
_stack._vals[n] = v->_stack[v->_stackbase+n];
|
_stack._vals[n] = v->_stack[v->_stackbase+n];
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ bool SQGenerator::Resume(SQVM *v,SQObjectPtr &dest)
|
|||||||
et._stacksize += newbase;
|
et._stacksize += newbase;
|
||||||
}
|
}
|
||||||
SQObject _this = _stack._vals[0];
|
SQObject _this = _stack._vals[0];
|
||||||
v->_stack[v->_stackbase] = type(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
|
v->_stack[v->_stackbase] = sq_type(_this) == OT_WEAKREF ? _weakref(_this)->_obj : _this;
|
||||||
|
|
||||||
for(SQInteger n = 1; n<size; n++) {
|
for(SQInteger n = 1; n<size; n++) {
|
||||||
v->_stack[v->_stackbase+n] = _stack._vals[n];
|
v->_stack[v->_stackbase+n] = _stack._vals[n];
|
||||||
@ -285,7 +285,7 @@ bool SafeWrite(HSQUIRRELVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer de
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SafeRead(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,SQInteger size)
|
bool SafeRead(HSQUIRRELVM v,SQREADFUNC read,SQUserPointer up,SQUserPointer dest,SQInteger size)
|
||||||
{
|
{
|
||||||
if(size && read(up,dest,size) != size) {
|
if(size && read(up,dest,size) != size) {
|
||||||
v->Raise_Error(_SC("io error, read function failure, the origin stream could be corrupted/trucated"));
|
v->Raise_Error(_SC("io error, read function failure, the origin stream could be corrupted/trucated"));
|
||||||
@ -299,7 +299,7 @@ bool WriteTag(HSQUIRRELVM v,SQWRITEFUNC write,SQUserPointer up,SQUnsignedInteger
|
|||||||
return SafeWrite(v,write,up,&tag,sizeof(tag));
|
return SafeWrite(v,write,up,&tag,sizeof(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckTag(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQUnsignedInteger32 tag)
|
bool CheckTag(HSQUIRRELVM v,SQREADFUNC read,SQUserPointer up,SQUnsignedInteger32 tag)
|
||||||
{
|
{
|
||||||
SQUnsignedInteger32 t;
|
SQUnsignedInteger32 t;
|
||||||
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
|
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
|
||||||
@ -312,9 +312,9 @@ bool CheckTag(HSQUIRRELVM v,SQWRITEFUNC read,SQUserPointer up,SQUnsignedInteger3
|
|||||||
|
|
||||||
bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
|
bool WriteObject(HSQUIRRELVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
SQUnsignedInteger32 _type = (SQUnsignedInteger32)type(o);
|
SQUnsignedInteger32 _type = (SQUnsignedInteger32)sq_type(o);
|
||||||
_CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
|
_CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
|
||||||
switch(type(o)){
|
switch(sq_type(o)){
|
||||||
case OT_STRING:
|
case OT_STRING:
|
||||||
_CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger)));
|
_CHECK_IO(SafeWrite(v,write,up,&_string(o)->_len,sizeof(SQInteger)));
|
||||||
_CHECK_IO(SafeWrite(v,write,up,_stringval(o),sq_rsl(_string(o)->_len)));
|
_CHECK_IO(SafeWrite(v,write,up,_stringval(o),sq_rsl(_string(o)->_len)));
|
||||||
|
9
external/Squirrel/sqobject.h
vendored
9
external/Squirrel/sqobject.h
vendored
@ -101,7 +101,7 @@ struct SQWeakRef : SQRefCounted
|
|||||||
SQObject _obj;
|
SQObject _obj;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define _realval(o) (type((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
|
#define _realval(o) (sq_type((o)) != OT_WEAKREF?(SQObject)o:_weakref(o)->_obj)
|
||||||
|
|
||||||
struct SQObjectPtr;
|
struct SQObjectPtr;
|
||||||
|
|
||||||
@ -128,8 +128,7 @@ struct SQObjectPtr;
|
|||||||
(obj)->_uiRef++; \
|
(obj)->_uiRef++; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define type(obj) ((obj)._type)
|
#define is_delegable(t) (sq_type(t)&SQOBJECT_DELEGABLE)
|
||||||
#define is_delegable(t) (type(t)&SQOBJECT_DELEGABLE)
|
|
||||||
#define raw_type(obj) _RAW_TYPE((obj)._type)
|
#define raw_type(obj) _RAW_TYPE((obj)._type)
|
||||||
|
|
||||||
#define _integer(obj) ((obj)._unVal.nInteger)
|
#define _integer(obj) ((obj)._unVal.nInteger)
|
||||||
@ -155,8 +154,8 @@ struct SQObjectPtr;
|
|||||||
#define _stringval(obj) (obj)._unVal.pString->_val
|
#define _stringval(obj) (obj)._unVal.pString->_val
|
||||||
#define _userdataval(obj) ((SQUserPointer)sq_aligning((obj)._unVal.pUserData + 1))
|
#define _userdataval(obj) ((SQUserPointer)sq_aligning((obj)._unVal.pUserData + 1))
|
||||||
|
|
||||||
#define tofloat(num) ((type(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
|
#define tofloat(num) ((sq_type(num)==OT_INTEGER)?(SQFloat)_integer(num):_float(num))
|
||||||
#define tointeger(num) ((type(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
|
#define tointeger(num) ((sq_type(num)==OT_FLOAT)?(SQInteger)_float(num):_integer(num))
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
#if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
|
#if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
|
||||||
|
10
external/Squirrel/sqstate.cpp
vendored
10
external/Squirrel/sqstate.cpp
vendored
@ -212,7 +212,7 @@ SQSharedState::~SQSharedState()
|
|||||||
|
|
||||||
SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
|
SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
|
||||||
{
|
{
|
||||||
if(type(name) != OT_STRING)
|
if(sq_type(name) != OT_STRING)
|
||||||
return -1;
|
return -1;
|
||||||
SQObjectPtr ret;
|
SQObjectPtr ret;
|
||||||
if(_table(_metamethodsmap)->Get(name,ret)) {
|
if(_table(_metamethodsmap)->Get(name,ret)) {
|
||||||
@ -225,7 +225,7 @@ SQInteger SQSharedState::GetMetaMethodIdxByName(const SQObjectPtr &name)
|
|||||||
|
|
||||||
void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
|
void SQSharedState::MarkObject(SQObjectPtr &o,SQCollectable **chain)
|
||||||
{
|
{
|
||||||
switch(type(o)){
|
switch(sq_type(o)){
|
||||||
case OT_TABLE:_table(o)->Mark(chain);break;
|
case OT_TABLE:_table(o)->Mark(chain);break;
|
||||||
case OT_ARRAY:_array(o)->Mark(chain);break;
|
case OT_ARRAY:_array(o)->Mark(chain);break;
|
||||||
case OT_USERDATA:_userdata(o)->Mark(chain);break;
|
case OT_USERDATA:_userdata(o)->Mark(chain);break;
|
||||||
@ -413,7 +413,7 @@ void RefTable::Mark(SQCollectable **chain)
|
|||||||
{
|
{
|
||||||
RefNode *nodes = (RefNode *)_nodes;
|
RefNode *nodes = (RefNode *)_nodes;
|
||||||
for(SQUnsignedInteger n = 0; n < _numofslots; n++) {
|
for(SQUnsignedInteger n = 0; n < _numofslots; n++) {
|
||||||
if(type(nodes->obj) != OT_NULL) {
|
if(sq_type(nodes->obj) != OT_NULL) {
|
||||||
SQSharedState::MarkObject(nodes->obj,chain);
|
SQSharedState::MarkObject(nodes->obj,chain);
|
||||||
}
|
}
|
||||||
nodes++;
|
nodes++;
|
||||||
@ -475,7 +475,7 @@ void RefTable::Resize(SQUnsignedInteger size)
|
|||||||
//rehash
|
//rehash
|
||||||
SQUnsignedInteger nfound = 0;
|
SQUnsignedInteger nfound = 0;
|
||||||
for(SQUnsignedInteger n = 0; n < oldnumofslots; n++) {
|
for(SQUnsignedInteger n = 0; n < oldnumofslots; n++) {
|
||||||
if(type(t->obj) != OT_NULL) {
|
if(sq_type(t->obj) != OT_NULL) {
|
||||||
//add back;
|
//add back;
|
||||||
assert(t->refs != 0);
|
assert(t->refs != 0);
|
||||||
RefNode *nn = Add(::HashObj(t->obj)&(_numofslots-1),t->obj);
|
RefNode *nn = Add(::HashObj(t->obj)&(_numofslots-1),t->obj);
|
||||||
@ -508,7 +508,7 @@ RefTable::RefNode *RefTable::Get(SQObject &obj,SQHash &mainpos,RefNode **prev,bo
|
|||||||
mainpos = ::HashObj(obj)&(_numofslots-1);
|
mainpos = ::HashObj(obj)&(_numofslots-1);
|
||||||
*prev = NULL;
|
*prev = NULL;
|
||||||
for (ref = _buckets[mainpos]; ref; ) {
|
for (ref = _buckets[mainpos]; ref; ) {
|
||||||
if(_rawval(ref->obj) == _rawval(obj) && type(ref->obj) == type(obj))
|
if(_rawval(ref->obj) == _rawval(obj) && sq_type(ref->obj) == sq_type(obj))
|
||||||
break;
|
break;
|
||||||
*prev = ref;
|
*prev = ref;
|
||||||
ref = ref->next;
|
ref = ref->next;
|
||||||
|
12
external/Squirrel/sqtable.cpp
vendored
12
external/Squirrel/sqtable.cpp
vendored
@ -62,7 +62,7 @@ void SQTable::Rehash(bool force)
|
|||||||
_usednodes = 0;
|
_usednodes = 0;
|
||||||
for (SQInteger i=0; i<oldsize; i++) {
|
for (SQInteger i=0; i<oldsize; i++) {
|
||||||
_HashNode *old = nold+i;
|
_HashNode *old = nold+i;
|
||||||
if (type(old->key) != OT_NULL)
|
if (sq_type(old->key) != OT_NULL)
|
||||||
NewSlot(old->key,old->val);
|
NewSlot(old->key,old->val);
|
||||||
}
|
}
|
||||||
for(SQInteger k=0;k<oldsize;k++)
|
for(SQInteger k=0;k<oldsize;k++)
|
||||||
@ -107,7 +107,7 @@ SQTable *SQTable::Clone()
|
|||||||
|
|
||||||
bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
|
bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
|
||||||
{
|
{
|
||||||
if(type(key) == OT_NULL)
|
if(sq_type(key) == OT_NULL)
|
||||||
return false;
|
return false;
|
||||||
_HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1));
|
_HashNode *n = _Get(key, HashObj(key) & (_numofnodes - 1));
|
||||||
if (n) {
|
if (n) {
|
||||||
@ -118,7 +118,7 @@ bool SQTable::Get(const SQObjectPtr &key,SQObjectPtr &val)
|
|||||||
}
|
}
|
||||||
bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
||||||
{
|
{
|
||||||
assert(type(key) != OT_NULL);
|
assert(sq_type(key) != OT_NULL);
|
||||||
SQHash h = HashObj(key) & (_numofnodes - 1);
|
SQHash h = HashObj(key) & (_numofnodes - 1);
|
||||||
_HashNode *n = _Get(key, h);
|
_HashNode *n = _Get(key, h);
|
||||||
if (n) {
|
if (n) {
|
||||||
@ -132,7 +132,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
|||||||
//key not found I'll insert it
|
//key not found I'll insert it
|
||||||
//main pos is not free
|
//main pos is not free
|
||||||
|
|
||||||
if(type(mp->key) != OT_NULL) {
|
if(sq_type(mp->key) != OT_NULL) {
|
||||||
n = _firstfree; /* get a free place */
|
n = _firstfree; /* get a free place */
|
||||||
SQHash mph = HashObj(mp->key) & (_numofnodes - 1);
|
SQHash mph = HashObj(mp->key) & (_numofnodes - 1);
|
||||||
_HashNode *othern; /* main position of colliding node */
|
_HashNode *othern; /* main position of colliding node */
|
||||||
@ -161,7 +161,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
|
|||||||
mp->key = key;
|
mp->key = key;
|
||||||
|
|
||||||
for (;;) { /* correct `firstfree' */
|
for (;;) { /* correct `firstfree' */
|
||||||
if (type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
|
if (sq_type(_firstfree->key) == OT_NULL && _firstfree->next == NULL) {
|
||||||
mp->val = val;
|
mp->val = val;
|
||||||
_usednodes++;
|
_usednodes++;
|
||||||
return true; /* OK; table still has a free place */
|
return true; /* OK; table still has a free place */
|
||||||
@ -177,7 +177,7 @@ SQInteger SQTable::Next(bool getweakrefs,const SQObjectPtr &refpos, SQObjectPtr
|
|||||||
{
|
{
|
||||||
SQInteger idx = (SQInteger)TranslateIndex(refpos);
|
SQInteger idx = (SQInteger)TranslateIndex(refpos);
|
||||||
while (idx < _numofnodes) {
|
while (idx < _numofnodes) {
|
||||||
if(type(_nodes[idx].key) != OT_NULL) {
|
if(sq_type(_nodes[idx].key) != OT_NULL) {
|
||||||
//first found
|
//first found
|
||||||
_HashNode &n = _nodes[idx];
|
_HashNode &n = _nodes[idx];
|
||||||
outkey = n.key;
|
outkey = n.key;
|
||||||
|
6
external/Squirrel/sqtable.h
vendored
6
external/Squirrel/sqtable.h
vendored
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
inline SQHash HashObj(const SQObjectPtr &key)
|
inline SQHash HashObj(const SQObjectPtr &key)
|
||||||
{
|
{
|
||||||
switch(type(key)) {
|
switch(sq_type(key)) {
|
||||||
case OT_STRING: return _string(key)->_hash;
|
case OT_STRING: return _string(key)->_hash;
|
||||||
case OT_FLOAT: return (SQHash)((SQInteger)_float(key));
|
case OT_FLOAT: return (SQHash)((SQInteger)_float(key));
|
||||||
case OT_BOOL: case OT_INTEGER: return (SQHash)((SQInteger)_integer(key));
|
case OT_BOOL: case OT_INTEGER: return (SQHash)((SQInteger)_integer(key));
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
{
|
{
|
||||||
_HashNode *n = &_nodes[hash];
|
_HashNode *n = &_nodes[hash];
|
||||||
do{
|
do{
|
||||||
if(_rawval(n->key) == _rawval(key) && type(n->key) == type(key)){
|
if(_rawval(n->key) == _rawval(key) && sq_type(n->key) == sq_type(key)){
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
}while((n = n->next));
|
}while((n = n->next));
|
||||||
@ -80,7 +80,7 @@ public:
|
|||||||
_HashNode *n = &_nodes[hash & (_numofnodes - 1)];
|
_HashNode *n = &_nodes[hash & (_numofnodes - 1)];
|
||||||
_HashNode *res = NULL;
|
_HashNode *res = NULL;
|
||||||
do{
|
do{
|
||||||
if(type(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
|
if(sq_type(n->key) == OT_STRING && (scstrcmp(_stringval(n->key),key) == 0)){
|
||||||
res = n;
|
res = n;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
150
external/Squirrel/sqvm.cpp
vendored
150
external/Squirrel/sqvm.cpp
vendored
@ -21,7 +21,7 @@
|
|||||||
bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
||||||
{
|
{
|
||||||
SQInteger res;
|
SQInteger res;
|
||||||
if((type(o1)|type(o2)) == OT_INTEGER)
|
if((sq_type(o1)| sq_type(o2)) == OT_INTEGER)
|
||||||
{
|
{
|
||||||
SQInteger i1 = _integer(o1), i2 = _integer(o2);
|
SQInteger i1 = _integer(o1), i2 = _integer(o2);
|
||||||
switch(op) {
|
switch(op) {
|
||||||
@ -41,7 +41,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
|
|||||||
|
|
||||||
#define _ARITH_(op,trg,o1,o2) \
|
#define _ARITH_(op,trg,o1,o2) \
|
||||||
{ \
|
{ \
|
||||||
SQInteger tmask = type(o1)|type(o2); \
|
SQInteger tmask = sq_type(o1)|sq_type(o2); \
|
||||||
switch(tmask) { \
|
switch(tmask) { \
|
||||||
case OT_INTEGER: trg = _integer(o1) op _integer(o2);break; \
|
case OT_INTEGER: trg = _integer(o1) op _integer(o2);break; \
|
||||||
case (OT_FLOAT|OT_INTEGER): \
|
case (OT_FLOAT|OT_INTEGER): \
|
||||||
@ -52,7 +52,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
|
|||||||
|
|
||||||
#define _ARITH_NOZERO(op,trg,o1,o2,err) \
|
#define _ARITH_NOZERO(op,trg,o1,o2,err) \
|
||||||
{ \
|
{ \
|
||||||
SQInteger tmask = type(o1)|type(o2); \
|
SQInteger tmask = sq_type(o1)|sq_type(o2); \
|
||||||
switch(tmask) { \
|
switch(tmask) { \
|
||||||
case OT_INTEGER: { SQInteger i2 = _integer(o2); if(i2 == 0) { Raise_Error(err); SQ_THROW(); } trg = _integer(o1) op i2; } break;\
|
case OT_INTEGER: { SQInteger i2 = _integer(o2); if(i2 == 0) { Raise_Error(err); SQ_THROW(); } trg = _integer(o1) op i2; } break;\
|
||||||
case (OT_FLOAT|OT_INTEGER): \
|
case (OT_FLOAT|OT_INTEGER): \
|
||||||
@ -63,7 +63,7 @@ bool SQVM::BW_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,con
|
|||||||
|
|
||||||
bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
bool SQVM::ARITH_OP(SQUnsignedInteger op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
||||||
{
|
{
|
||||||
SQInteger tmask = type(o1)|type(o2);
|
SQInteger tmask = sq_type(o1)| sq_type(o2);
|
||||||
switch(tmask) {
|
switch(tmask) {
|
||||||
case OT_INTEGER:{
|
case OT_INTEGER:{
|
||||||
SQInteger res, i1 = _integer(o1), i2 = _integer(o2);
|
SQInteger res, i1 = _integer(o1), i2 = _integer(o2);
|
||||||
@ -177,7 +177,7 @@ bool SQVM::ArithMetaMethod(SQInteger op,const SQObjectPtr &o1,const SQObjectPtr
|
|||||||
bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch(type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_INTEGER:
|
case OT_INTEGER:
|
||||||
trg = -_integer(o);
|
trg = -_integer(o);
|
||||||
return true;
|
return true;
|
||||||
@ -206,7 +206,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
|||||||
#define _RET_SUCCEED(exp) { result = (exp); return true; }
|
#define _RET_SUCCEED(exp) { result = (exp); return true; }
|
||||||
bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
|
bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
|
||||||
{
|
{
|
||||||
SQObjectType t1 = type(o1), t2 = type(o2);
|
SQObjectType t1 = sq_type(o1), t2 = sq_type(o2);
|
||||||
if(t1 == t2) {
|
if(t1 == t2) {
|
||||||
if(_rawval(o1) == _rawval(o2))_RET_SUCCEED(0);
|
if(_rawval(o1) == _rawval(o2))_RET_SUCCEED(0);
|
||||||
SQObjectPtr res;
|
SQObjectPtr res;
|
||||||
@ -225,7 +225,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,SQInteger &result)
|
|||||||
if(_delegable(o1)->GetMetaMethod(this, MT_CMP, closure)) {
|
if(_delegable(o1)->GetMetaMethod(this, MT_CMP, closure)) {
|
||||||
Push(o1);Push(o2);
|
Push(o1);Push(o2);
|
||||||
if(CallMetaMethod(closure,MT_CMP,2,res)) {
|
if(CallMetaMethod(closure,MT_CMP,2,res)) {
|
||||||
if(type(res) != OT_INTEGER) {
|
if(sq_type(res) != OT_INTEGER) {
|
||||||
Raise_Error(_SC("_cmp must return an integer"));
|
Raise_Error(_SC("_cmp must return an integer"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -283,7 +283,7 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject
|
|||||||
|
|
||||||
bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
switch(type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_STRING:
|
case OT_STRING:
|
||||||
res = o;
|
res = o;
|
||||||
return true;
|
return true;
|
||||||
@ -304,7 +304,7 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res)
|
|||||||
if(_delegable(o)->GetMetaMethod(this, MT_TOSTRING, closure)) {
|
if(_delegable(o)->GetMetaMethod(this, MT_TOSTRING, closure)) {
|
||||||
Push(o);
|
Push(o);
|
||||||
if(CallMetaMethod(closure,MT_TOSTRING,1,res)) {
|
if(CallMetaMethod(closure,MT_TOSTRING,1,res)) {
|
||||||
if(type(res) == OT_STRING)
|
if(sq_type(res) == OT_STRING)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -383,7 +383,8 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
|
|||||||
{
|
{
|
||||||
paramssize--;
|
paramssize--;
|
||||||
if (nargs < paramssize) {
|
if (nargs < paramssize) {
|
||||||
Raise_Error(_SC("wrong number of parameters"));
|
Raise_Error(_SC("wrong number of parameters (%d passed, at least %d required)"),
|
||||||
|
(int)nargs, (int)paramssize);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +410,8 @@ bool SQVM::StartCall(SQClosure *closure,SQInteger target,SQInteger args,SQIntege
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Raise_Error(_SC("wrong number of parameters"));
|
Raise_Error(_SC("wrong number of parameters (%d passed, %d required)"),
|
||||||
|
(int)nargs, (int)paramssize);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -519,7 +521,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
|||||||
&o3,SQObjectPtr &o4,SQInteger SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
|
&o3,SQObjectPtr &o4,SQInteger SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
|
||||||
{
|
{
|
||||||
SQInteger nrefidx;
|
SQInteger nrefidx;
|
||||||
switch(type(o1)) {
|
switch(sq_type(o1)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if((nrefidx = _table(o1)->Next(false,o4, o2, o3)) == -1) _FINISH(exitpos);
|
if((nrefidx = _table(o1)->Next(false,o4, o2, o3)) == -1) _FINISH(exitpos);
|
||||||
o4 = (SQInteger)nrefidx; _FINISH(1);
|
o4 = (SQInteger)nrefidx; _FINISH(1);
|
||||||
@ -542,7 +544,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
|||||||
Push(o4);
|
Push(o4);
|
||||||
if(CallMetaMethod(closure, MT_NEXTI, 2, itr)) {
|
if(CallMetaMethod(closure, MT_NEXTI, 2, itr)) {
|
||||||
o4 = o2 = itr;
|
o4 = o2 = itr;
|
||||||
if(type(itr) == OT_NULL) _FINISH(exitpos);
|
if(sq_type(itr) == OT_NULL) _FINISH(exitpos);
|
||||||
if(!Get(o1, itr, o3, 0, DONT_FALL_BACK)) {
|
if(!Get(o1, itr, o3, 0, DONT_FALL_BACK)) {
|
||||||
Raise_Error(_SC("_nexti returned an invalid idx")); // cloud be changed
|
Raise_Error(_SC("_nexti returned an invalid idx")); // cloud be changed
|
||||||
return false;
|
return false;
|
||||||
@ -561,7 +563,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
|||||||
if(_generator(o1)->_state == SQGenerator::eDead) _FINISH(exitpos);
|
if(_generator(o1)->_state == SQGenerator::eDead) _FINISH(exitpos);
|
||||||
if(_generator(o1)->_state == SQGenerator::eSuspended) {
|
if(_generator(o1)->_state == SQGenerator::eSuspended) {
|
||||||
SQInteger idx = 0;
|
SQInteger idx = 0;
|
||||||
if(type(o4) == OT_INTEGER) {
|
if(sq_type(o4) == OT_INTEGER) {
|
||||||
idx = _integer(o4) + 1;
|
idx = _integer(o4) + 1;
|
||||||
}
|
}
|
||||||
o2 = idx;
|
o2 = idx;
|
||||||
@ -616,14 +618,14 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
|
|||||||
SQClass *base = NULL;
|
SQClass *base = NULL;
|
||||||
SQObjectPtr attrs;
|
SQObjectPtr attrs;
|
||||||
if(baseclass != -1) {
|
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(sq_type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),GetTypeName(_stack._vals[_stackbase+baseclass])); return false; }
|
||||||
base = _class(_stack._vals[_stackbase + baseclass]);
|
base = _class(_stack._vals[_stackbase + baseclass]);
|
||||||
}
|
}
|
||||||
if(attributes != MAX_FUNC_STACKSIZE) {
|
if(attributes != MAX_FUNC_STACKSIZE) {
|
||||||
attrs = _stack._vals[_stackbase+attributes];
|
attrs = _stack._vals[_stackbase+attributes];
|
||||||
}
|
}
|
||||||
target = SQClass::Create(_ss(this),base);
|
target = SQClass::Create(_ss(this),base);
|
||||||
if(type(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
|
if(sq_type(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) {
|
||||||
int nparams = 2;
|
int nparams = 2;
|
||||||
SQObjectPtr ret;
|
SQObjectPtr ret;
|
||||||
Push(target); Push(attrs);
|
Push(target); Push(attrs);
|
||||||
@ -639,7 +641,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,SQInteger baseclass,SQInteger attributes
|
|||||||
|
|
||||||
bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
||||||
{
|
{
|
||||||
if(type(o1) == type(o2)) {
|
if(sq_type(o1) == sq_type(o2)) {
|
||||||
res = (_rawval(o1) == _rawval(o2));
|
res = (_rawval(o1) == _rawval(o2));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -655,8 +657,8 @@ bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
|||||||
|
|
||||||
bool SQVM::IsFalse(SQObjectPtr &o)
|
bool SQVM::IsFalse(SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
if(((type(o) & SQOBJECT_CANBEFALSE)
|
if(((sq_type(o) & SQOBJECT_CANBEFALSE)
|
||||||
&& ( ((type(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
|
&& ( ((sq_type(o) == OT_FLOAT) && (_float(o) == SQFloat(0.0))) ))
|
||||||
#if !defined(SQUSEDOUBLE) || (defined(SQUSEDOUBLE) && defined(_SQ64))
|
#if !defined(SQUSEDOUBLE) || (defined(SQUSEDOUBLE) && defined(_SQ64))
|
||||||
|| (_integer(o) == 0) ) //OT_NULL|OT_INTEGER|OT_BOOL
|
|| (_integer(o) == 0) ) //OT_NULL|OT_INTEGER|OT_BOOL
|
||||||
#else
|
#else
|
||||||
@ -723,7 +725,7 @@ exception_restore:
|
|||||||
case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;
|
case _OP_DLOAD: TARGET = ci->_literals[arg1]; STK(arg2) = ci->_literals[arg3];continue;
|
||||||
case _OP_TAILCALL:{
|
case _OP_TAILCALL:{
|
||||||
SQObjectPtr &t = STK(arg1);
|
SQObjectPtr &t = STK(arg1);
|
||||||
if (type(t) == OT_CLOSURE
|
if (sq_type(t) == OT_CLOSURE
|
||||||
&& (!_closure(t)->_function->_bgenerator)){
|
&& (!_closure(t)->_function->_bgenerator)){
|
||||||
SQObjectPtr clo = t;
|
SQObjectPtr clo = t;
|
||||||
SQInteger last_top = _top;
|
SQInteger last_top = _top;
|
||||||
@ -738,13 +740,14 @@ exception_restore:
|
|||||||
}
|
}
|
||||||
case _OP_CALL: {
|
case _OP_CALL: {
|
||||||
SQObjectPtr clo = STK(arg1);
|
SQObjectPtr clo = STK(arg1);
|
||||||
switch (type(clo)) {
|
switch (sq_type(clo)) {
|
||||||
case OT_CLOSURE:
|
case OT_CLOSURE:
|
||||||
_GUARD(StartCall(_closure(clo), sarg0, arg3, _stackbase+arg2, false));
|
_GUARD(StartCall(_closure(clo), sarg0, arg3, _stackbase+arg2, false));
|
||||||
continue;
|
continue;
|
||||||
case OT_NATIVECLOSURE: {
|
case OT_NATIVECLOSURE: {
|
||||||
bool suspend;
|
bool suspend;
|
||||||
_GUARD(CallNative(_nativeclosure(clo), arg3, _stackbase+arg2, clo,suspend));
|
bool tailcall;
|
||||||
|
_GUARD(CallNative(_nativeclosure(clo), arg3, _stackbase+arg2, clo, (SQInt32)sarg0, suspend, tailcall));
|
||||||
if(suspend){
|
if(suspend){
|
||||||
_suspended = SQTrue;
|
_suspended = SQTrue;
|
||||||
_suspended_target = sarg0;
|
_suspended_target = sarg0;
|
||||||
@ -753,7 +756,7 @@ exception_restore:
|
|||||||
outres = clo;
|
outres = clo;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if(sarg0 != -1) {
|
if(sarg0 != -1 && !tailcall) {
|
||||||
STK(arg0) = clo;
|
STK(arg0) = clo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -765,17 +768,17 @@ exception_restore:
|
|||||||
STK(arg0) = inst;
|
STK(arg0) = inst;
|
||||||
}
|
}
|
||||||
SQInteger stkbase;
|
SQInteger stkbase;
|
||||||
switch(type(clo)) {
|
switch(sq_type(clo)) {
|
||||||
case OT_CLOSURE:
|
case OT_CLOSURE:
|
||||||
stkbase = _stackbase+arg2;
|
stkbase = _stackbase+arg2;
|
||||||
_stack._vals[stkbase] = inst;
|
_stack._vals[stkbase] = inst;
|
||||||
_GUARD(StartCall(_closure(clo), -1, arg3, stkbase, false));
|
_GUARD(StartCall(_closure(clo), -1, arg3, stkbase, false));
|
||||||
break;
|
break;
|
||||||
case OT_NATIVECLOSURE:
|
case OT_NATIVECLOSURE:
|
||||||
bool suspend;
|
bool dummy;
|
||||||
stkbase = _stackbase+arg2;
|
stkbase = _stackbase+arg2;
|
||||||
_stack._vals[stkbase] = inst;
|
_stack._vals[stkbase] = inst;
|
||||||
_GUARD(CallNative(_nativeclosure(clo), arg3, stkbase, clo,suspend));
|
_GUARD(CallNative(_nativeclosure(clo), arg3, stkbase, clo, -1, dummy, dummy));
|
||||||
break;
|
break;
|
||||||
default: break; //shutup GCC 4.x
|
default: break; //shutup GCC 4.x
|
||||||
}
|
}
|
||||||
@ -863,7 +866,7 @@ exception_restore:
|
|||||||
case _OP_LOADNULLS:{ for(SQInt32 n=0; n < arg1; n++) STK(arg0+n).Null(); }continue;
|
case _OP_LOADNULLS:{ for(SQInt32 n=0; n < arg1; n++) STK(arg0+n).Null(); }continue;
|
||||||
case _OP_LOADROOT: {
|
case _OP_LOADROOT: {
|
||||||
SQWeakRef *w = _closure(ci->_closure)->_root;
|
SQWeakRef *w = _closure(ci->_closure)->_root;
|
||||||
if(type(w->_obj) != OT_NULL) {
|
if(sq_type(w->_obj) != OT_NULL) {
|
||||||
TARGET = w->_obj;
|
TARGET = w->_obj;
|
||||||
} else {
|
} else {
|
||||||
TARGET = _roottable; //shoud this be like this? or null
|
TARGET = _roottable; //shoud this be like this? or null
|
||||||
@ -939,7 +942,7 @@ exception_restore:
|
|||||||
case _OP_INC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue;
|
case _OP_INC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue;
|
||||||
case _OP_INCL: {
|
case _OP_INCL: {
|
||||||
SQObjectPtr &a = STK(arg1);
|
SQObjectPtr &a = STK(arg1);
|
||||||
if(type(a) == OT_INTEGER) {
|
if(sq_type(a) == OT_INTEGER) {
|
||||||
a._unVal.nInteger = _integer(a) + sarg3;
|
a._unVal.nInteger = _integer(a) + sarg3;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -950,7 +953,7 @@ exception_restore:
|
|||||||
case _OP_PINC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue;
|
case _OP_PINC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue;
|
||||||
case _OP_PINCL: {
|
case _OP_PINCL: {
|
||||||
SQObjectPtr &a = STK(arg1);
|
SQObjectPtr &a = STK(arg1);
|
||||||
if(type(a) == OT_INTEGER) {
|
if(sq_type(a) == OT_INTEGER) {
|
||||||
TARGET = a;
|
TARGET = a;
|
||||||
a._unVal.nInteger = _integer(a) + sarg3;
|
a._unVal.nInteger = _integer(a) + sarg3;
|
||||||
}
|
}
|
||||||
@ -962,9 +965,9 @@ exception_restore:
|
|||||||
case _OP_CMP: _GUARD(CMP_OP((CmpOP)arg3,STK(arg2),STK(arg1),TARGET)) continue;
|
case _OP_CMP: _GUARD(CMP_OP((CmpOP)arg3,STK(arg2),STK(arg1),TARGET)) continue;
|
||||||
case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, GET_FLAG_DO_NOT_RAISE_ERROR | GET_FLAG_RAW, DONT_FALL_BACK) ? true : false; continue;
|
case _OP_EXISTS: TARGET = Get(STK(arg1), STK(arg2), temp_reg, GET_FLAG_DO_NOT_RAISE_ERROR | GET_FLAG_RAW, DONT_FALL_BACK) ? true : false; continue;
|
||||||
case _OP_INSTANCEOF:
|
case _OP_INSTANCEOF:
|
||||||
if(type(STK(arg1)) != OT_CLASS)
|
if(sq_type(STK(arg1)) != OT_CLASS)
|
||||||
{Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();}
|
{Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),GetTypeName(STK(arg1)),GetTypeName(STK(arg2))); SQ_THROW();}
|
||||||
TARGET = (type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
|
TARGET = (sq_type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false;
|
||||||
continue;
|
continue;
|
||||||
case _OP_AND:
|
case _OP_AND:
|
||||||
if(IsFalse(STK(arg2))) {
|
if(IsFalse(STK(arg2))) {
|
||||||
@ -981,7 +984,7 @@ exception_restore:
|
|||||||
case _OP_NEG: _GUARD(NEG_OP(TARGET,STK(arg1))); continue;
|
case _OP_NEG: _GUARD(NEG_OP(TARGET,STK(arg1))); continue;
|
||||||
case _OP_NOT: TARGET = IsFalse(STK(arg1)); continue;
|
case _OP_NOT: TARGET = IsFalse(STK(arg1)); continue;
|
||||||
case _OP_BWNOT:
|
case _OP_BWNOT:
|
||||||
if(type(STK(arg1)) == OT_INTEGER) {
|
if(sq_type(STK(arg1)) == OT_INTEGER) {
|
||||||
SQInteger t = _integer(STK(arg1));
|
SQInteger t = _integer(STK(arg1));
|
||||||
TARGET = SQInteger(~t);
|
TARGET = SQInteger(~t);
|
||||||
continue;
|
continue;
|
||||||
@ -1011,7 +1014,7 @@ exception_restore:
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case _OP_RESUME:
|
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(sq_type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), GetTypeName(STK(arg1))); SQ_THROW();}
|
||||||
_GUARD(_generator(STK(arg1))->Resume(this, TARGET));
|
_GUARD(_generator(STK(arg1))->Resume(this, TARGET));
|
||||||
traps += ci->_etraps;
|
traps += ci->_etraps;
|
||||||
continue;
|
continue;
|
||||||
@ -1020,7 +1023,7 @@ exception_restore:
|
|||||||
ci->_ip += tojump; }
|
ci->_ip += tojump; }
|
||||||
continue;
|
continue;
|
||||||
case _OP_POSTFOREACH:
|
case _OP_POSTFOREACH:
|
||||||
assert(type(STK(arg0)) == OT_GENERATOR);
|
assert(sq_type(STK(arg0)) == OT_GENERATOR);
|
||||||
if(_generator(STK(arg0))->_state == SQGenerator::eDead)
|
if(_generator(STK(arg0))->_state == SQGenerator::eDead)
|
||||||
ci->_ip += (sarg1 - 1);
|
ci->_ip += (sarg1 - 1);
|
||||||
continue;
|
continue;
|
||||||
@ -1110,7 +1113,7 @@ bool SQVM::CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr
|
|||||||
|
|
||||||
void SQVM::CallErrorHandler(SQObjectPtr &error)
|
void SQVM::CallErrorHandler(SQObjectPtr &error)
|
||||||
{
|
{
|
||||||
if(type(_errorhandler) != OT_NULL) {
|
if(sq_type(_errorhandler) != OT_NULL) {
|
||||||
SQObjectPtr out;
|
SQObjectPtr out;
|
||||||
Push(_roottable); Push(error);
|
Push(_roottable); Push(error);
|
||||||
Call(_errorhandler, 2, _top-2, out,SQFalse);
|
Call(_errorhandler, 2, _top-2, out,SQFalse);
|
||||||
@ -1124,8 +1127,8 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline)
|
|||||||
_debughook = false;
|
_debughook = false;
|
||||||
SQFunctionProto *func=_closure(ci->_closure)->_function;
|
SQFunctionProto *func=_closure(ci->_closure)->_function;
|
||||||
if(_debughook_native) {
|
if(_debughook_native) {
|
||||||
const SQChar *src = type(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
|
const SQChar *src = sq_type(func->_sourcename) == OT_STRING?_stringval(func->_sourcename):NULL;
|
||||||
const SQChar *fname = type(func->_name) == OT_STRING?_stringval(func->_name):NULL;
|
const SQChar *fname = sq_type(func->_name) == OT_STRING?_stringval(func->_name):NULL;
|
||||||
SQInteger line = forcedline?forcedline:func->GetLine(ci->_ip);
|
SQInteger line = forcedline?forcedline:func->GetLine(ci->_ip);
|
||||||
_debughook_native(this,type,src,line,fname);
|
_debughook_native(this,type,src,line,fname);
|
||||||
}
|
}
|
||||||
@ -1139,7 +1142,7 @@ void SQVM::CallDebugHook(SQInteger type,SQInteger forcedline)
|
|||||||
_debughook = true;
|
_debughook = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newbase, SQObjectPtr &retval, bool &suspend)
|
bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newbase, SQObjectPtr &retval, SQInt32 target,bool &suspend, bool &tailcall)
|
||||||
{
|
{
|
||||||
SQInteger nparamscheck = nclosure->_nparamscheck;
|
SQInteger nparamscheck = nclosure->_nparamscheck;
|
||||||
SQInteger newtop = newbase + nargs + nclosure->_noutervalues;
|
SQInteger newtop = newbase + nargs + nclosure->_noutervalues;
|
||||||
@ -1160,8 +1163,8 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
|
|||||||
SQIntVec &tc = nclosure->_typecheck;
|
SQIntVec &tc = nclosure->_typecheck;
|
||||||
if((tcs = tc.size())) {
|
if((tcs = tc.size())) {
|
||||||
for(SQInteger i = 0; i < nargs && i < tcs; i++) {
|
for(SQInteger i = 0; i < nargs && i < tcs; i++) {
|
||||||
if((tc._vals[i] != -1) && !(type(_stack._vals[newbase+i]) & tc._vals[i])) {
|
if((tc._vals[i] != -1) && !(sq_type(_stack._vals[newbase+i]) & tc._vals[i])) {
|
||||||
Raise_ParamTypeError(i,tc._vals[i],type(_stack._vals[newbase+i]));
|
Raise_ParamTypeError(i,tc._vals[i], sq_type(_stack._vals[newbase+i]));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1169,6 +1172,7 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
|
|||||||
|
|
||||||
if(!EnterFrame(newbase, newtop, false)) return false;
|
if(!EnterFrame(newbase, newtop, false)) return false;
|
||||||
ci->_closure = nclosure;
|
ci->_closure = nclosure;
|
||||||
|
ci->_target = target;
|
||||||
|
|
||||||
SQInteger outers = nclosure->_noutervalues;
|
SQInteger outers = nclosure->_noutervalues;
|
||||||
for (SQInteger i = 0; i < outers; i++) {
|
for (SQInteger i = 0; i < outers; i++) {
|
||||||
@ -1183,7 +1187,12 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
|
|||||||
_nnativecalls--;
|
_nnativecalls--;
|
||||||
|
|
||||||
suspend = false;
|
suspend = false;
|
||||||
if (ret == SQ_SUSPEND_FLAG) {
|
tailcall = false;
|
||||||
|
if (ret == SQ_TAILCALL_FLAG) {
|
||||||
|
tailcall = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (ret == SQ_SUSPEND_FLAG) {
|
||||||
suspend = true;
|
suspend = true;
|
||||||
}
|
}
|
||||||
else if (ret < 0) {
|
else if (ret < 0) {
|
||||||
@ -1202,13 +1211,30 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newb
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SQVM::TailCall(SQClosure *closure, SQInteger parambase,SQInteger nparams)
|
||||||
|
{
|
||||||
|
SQInteger last_top = _top;
|
||||||
|
SQObjectPtr clo = closure;
|
||||||
|
if (ci->_root)
|
||||||
|
{
|
||||||
|
Raise_Error("root calls cannot invoke tailcalls");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for (SQInteger i = 0; i < nparams; i++) STK(i) = STK(parambase + i);
|
||||||
|
bool ret = StartCall(closure, ci->_target, nparams, _stackbase, true);
|
||||||
|
if (last_top >= _top) {
|
||||||
|
_top = last_top;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#define FALLBACK_OK 0
|
#define FALLBACK_OK 0
|
||||||
#define FALLBACK_NO_MATCH 1
|
#define FALLBACK_NO_MATCH 1
|
||||||
#define FALLBACK_ERROR 2
|
#define FALLBACK_ERROR 2
|
||||||
|
|
||||||
bool SQVM::Get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, SQUnsignedInteger getflags, SQInteger selfidx)
|
bool SQVM::Get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, SQUnsignedInteger getflags, SQInteger selfidx)
|
||||||
{
|
{
|
||||||
switch(type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if(_table(self)->Get(key,dest))return true;
|
if(_table(self)->Get(key,dest))return true;
|
||||||
break;
|
break;
|
||||||
@ -1249,7 +1275,7 @@ bool SQVM::Get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des
|
|||||||
//#ifdef ROOT_FALLBACK
|
//#ifdef ROOT_FALLBACK
|
||||||
if(selfidx == 0) {
|
if(selfidx == 0) {
|
||||||
SQWeakRef *w = _closure(ci->_closure)->_root;
|
SQWeakRef *w = _closure(ci->_closure)->_root;
|
||||||
if(type(w->_obj) != OT_NULL)
|
if(sq_type(w->_obj) != OT_NULL)
|
||||||
{
|
{
|
||||||
if(Get(*((const SQObjectPtr *)&w->_obj),key,dest,0,DONT_FALL_BACK)) return true;
|
if(Get(*((const SQObjectPtr *)&w->_obj),key,dest,0,DONT_FALL_BACK)) return true;
|
||||||
}
|
}
|
||||||
@ -1263,7 +1289,7 @@ bool SQVM::Get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des
|
|||||||
bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
SQTable *ddel = NULL;
|
SQTable *ddel = NULL;
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_CLASS: ddel = _class_ddel; break;
|
case OT_CLASS: ddel = _class_ddel; break;
|
||||||
case OT_TABLE: ddel = _table_ddel; break;
|
case OT_TABLE: ddel = _table_ddel; break;
|
||||||
case OT_ARRAY: ddel = _array_ddel; break;
|
case OT_ARRAY: ddel = _array_ddel; break;
|
||||||
@ -1282,7 +1308,7 @@ bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,
|
|||||||
|
|
||||||
SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
switch(type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
case OT_USERDATA:
|
case OT_USERDATA:
|
||||||
//delegation
|
//delegation
|
||||||
@ -1305,7 +1331,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObj
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Pop(2);
|
Pop(2);
|
||||||
if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
if(sq_type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
||||||
return FALLBACK_ERROR;
|
return FALLBACK_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1320,7 +1346,7 @@ SQInteger SQVM::FallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObj
|
|||||||
|
|
||||||
bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,SQInteger selfidx)
|
bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,SQInteger selfidx)
|
||||||
{
|
{
|
||||||
switch(type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if(_table(self)->Set(key,val)) return true;
|
if(_table(self)->Set(key,val)) return true;
|
||||||
break;
|
break;
|
||||||
@ -1355,7 +1381,7 @@ bool SQVM::Set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
|
|||||||
|
|
||||||
SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
|
SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
|
||||||
{
|
{
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
if(_table(self)->_delegate) {
|
if(_table(self)->_delegate) {
|
||||||
if(Set(_table(self)->_delegate,key,val,DONT_FALL_BACK)) return FALLBACK_OK;
|
if(Set(_table(self)->_delegate,key,val,DONT_FALL_BACK)) return FALLBACK_OK;
|
||||||
@ -1375,7 +1401,7 @@ SQInteger SQVM::FallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Pop(3);
|
Pop(3);
|
||||||
if(type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
if(sq_type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found)
|
||||||
return FALLBACK_ERROR;
|
return FALLBACK_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1392,7 +1418,7 @@ bool SQVM::Clone(const SQObjectPtr &self,SQObjectPtr &target)
|
|||||||
{
|
{
|
||||||
SQObjectPtr temp_reg;
|
SQObjectPtr temp_reg;
|
||||||
SQObjectPtr newobj;
|
SQObjectPtr newobj;
|
||||||
switch(type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
newobj = _table(self)->Clone();
|
newobj = _table(self)->Clone();
|
||||||
goto cloned_mt;
|
goto cloned_mt;
|
||||||
@ -1420,14 +1446,14 @@ cloned_mt:
|
|||||||
|
|
||||||
bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
|
bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
|
||||||
{
|
{
|
||||||
if(type(self) != OT_CLASS) {
|
if(sq_type(self) != OT_CLASS) {
|
||||||
Raise_Error(_SC("object must be a class"));
|
Raise_Error(_SC("object must be a class"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
SQClass *c = _class(self);
|
SQClass *c = _class(self);
|
||||||
if(!raw) {
|
if(!raw) {
|
||||||
SQObjectPtr &mm = c->_metamethods[MT_NEWMEMBER];
|
SQObjectPtr &mm = c->_metamethods[MT_NEWMEMBER];
|
||||||
if(type(mm) != OT_NULL ) {
|
if(sq_type(mm) != OT_NULL ) {
|
||||||
Push(self); Push(key); Push(val);
|
Push(self); Push(key); Push(val);
|
||||||
Push(attrs);
|
Push(attrs);
|
||||||
Push(bstatic);
|
Push(bstatic);
|
||||||
@ -1436,7 +1462,7 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec
|
|||||||
}
|
}
|
||||||
if(!NewSlot(self, key, val,bstatic))
|
if(!NewSlot(self, key, val,bstatic))
|
||||||
return false;
|
return false;
|
||||||
if(type(attrs) != OT_NULL) {
|
if(sq_type(attrs) != OT_NULL) {
|
||||||
c->SetAttributes(key,attrs);
|
c->SetAttributes(key,attrs);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1444,8 +1470,8 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec
|
|||||||
|
|
||||||
bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
|
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(sq_type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; }
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE: {
|
case OT_TABLE: {
|
||||||
bool rawcall = true;
|
bool rawcall = true;
|
||||||
if(_table(self)->_delegate) {
|
if(_table(self)->_delegate) {
|
||||||
@ -1505,7 +1531,7 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject
|
|||||||
|
|
||||||
bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res)
|
bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
switch(type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
case OT_INSTANCE:
|
case OT_INSTANCE:
|
||||||
case OT_USERDATA: {
|
case OT_USERDATA: {
|
||||||
@ -1517,7 +1543,7 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
|
|||||||
return CallMetaMethod(closure,MT_DELSLOT,2,res);
|
return CallMetaMethod(closure,MT_DELSLOT,2,res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(type(self) == OT_TABLE) {
|
if(sq_type(self) == OT_TABLE) {
|
||||||
if(_table(self)->Get(key,t)) {
|
if(_table(self)->Get(key,t)) {
|
||||||
_table(self)->Remove(key);
|
_table(self)->Remove(key);
|
||||||
}
|
}
|
||||||
@ -1546,13 +1572,13 @@ bool SQVM::Call(SQObjectPtr &closure,SQInteger nparams,SQInteger stackbase,SQObj
|
|||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
SQInteger prevstackbase = _stackbase;
|
SQInteger prevstackbase = _stackbase;
|
||||||
#endif
|
#endif
|
||||||
switch(type(closure)) {
|
switch(sq_type(closure)) {
|
||||||
case OT_CLOSURE:
|
case OT_CLOSURE:
|
||||||
return Execute(closure, nparams, stackbase, outres, raiseerror);
|
return Execute(closure, nparams, stackbase, outres, raiseerror);
|
||||||
break;
|
break;
|
||||||
case OT_NATIVECLOSURE:{
|
case OT_NATIVECLOSURE:{
|
||||||
bool suspend;
|
bool dummy;
|
||||||
return CallNative(_nativeclosure(closure), nparams, stackbase, outres,suspend);
|
return CallNative(_nativeclosure(closure), nparams, stackbase, outres, -1, dummy, dummy);
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1560,7 +1586,7 @@ SQInteger prevstackbase = _stackbase;
|
|||||||
SQObjectPtr constr;
|
SQObjectPtr constr;
|
||||||
SQObjectPtr temp;
|
SQObjectPtr temp;
|
||||||
CreateClassInstance(_class(closure),outres,constr);
|
CreateClassInstance(_class(closure),outres,constr);
|
||||||
SQObjectType ctype = type(constr);
|
SQObjectType ctype = sq_type(constr);
|
||||||
if (ctype == OT_NATIVECLOSURE || ctype == OT_CLOSURE) {
|
if (ctype == OT_NATIVECLOSURE || ctype == OT_CLOSURE) {
|
||||||
_stack[stackbase] = outres;
|
_stack[stackbase] = outres;
|
||||||
return Call(constr,nparams,stackbase,temp,raiseerror);
|
return Call(constr,nparams,stackbase,temp,raiseerror);
|
||||||
@ -1723,7 +1749,7 @@ void SQVM::dumpstack(SQInteger stackbase,bool dumpall)
|
|||||||
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("[" _PRINT_INT_FMT "]:"),n);
|
scprintf(_SC("[" _PRINT_INT_FMT "]:"),n);
|
||||||
switch(type(obj)){
|
switch(sq_type(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 " _PRINT_INT_FMT),_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;
|
||||||
|
4
external/Squirrel/sqvm.h
vendored
4
external/Squirrel/sqvm.h
vendored
@ -8,6 +8,7 @@
|
|||||||
#define MIN_STACK_OVERHEAD 15
|
#define MIN_STACK_OVERHEAD 15
|
||||||
|
|
||||||
#define SQ_SUSPEND_FLAG -666
|
#define SQ_SUSPEND_FLAG -666
|
||||||
|
#define SQ_TAILCALL_FLAG -777
|
||||||
#define DONT_FALL_BACK 666
|
#define DONT_FALL_BACK 666
|
||||||
//#define EXISTS_FALL_BACK -1
|
//#define EXISTS_FALL_BACK -1
|
||||||
|
|
||||||
@ -56,7 +57,8 @@ public:
|
|||||||
bool Init(SQVM *friendvm, SQInteger stacksize);
|
bool Init(SQVM *friendvm, SQInteger stacksize);
|
||||||
bool Execute(SQObjectPtr &func, SQInteger nargs, SQInteger stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
|
bool Execute(SQObjectPtr &func, SQInteger nargs, SQInteger stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
|
||||||
//starts a native call return when the NATIVE closure returns
|
//starts a native call return when the NATIVE closure returns
|
||||||
bool CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newbase, SQObjectPtr &retval,bool &suspend);
|
bool CallNative(SQNativeClosure *nclosure, SQInteger nargs, SQInteger newbase, SQObjectPtr &retval, SQInt32 target, bool &suspend,bool &tailcall);
|
||||||
|
bool TailCall(SQClosure *closure, SQInteger firstparam, SQInteger nparams);
|
||||||
//starts a SQUIRREL call in the same "Execution loop"
|
//starts a SQUIRREL call in the same "Execution loop"
|
||||||
bool StartCall(SQClosure *closure, SQInteger target, SQInteger nargs, SQInteger stackbase, bool tailcall);
|
bool StartCall(SQClosure *closure, SQInteger target, SQInteger nargs, SQInteger stackbase, bool tailcall);
|
||||||
bool CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor);
|
bool CreateClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
Copyright (c) 2003-2016 Alberto Demichelis
|
Copyright (c) 2003-2017 Alberto Demichelis
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -66,7 +66,7 @@ struct SQOuter;
|
|||||||
#include "sqconfig.h"
|
#include "sqconfig.h"
|
||||||
|
|
||||||
#define SQUIRREL_VERSION _SC("Squirrel 3.1 stable")
|
#define SQUIRREL_VERSION _SC("Squirrel 3.1 stable")
|
||||||
#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2016 Alberto Demichelis")
|
#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2017 Alberto Demichelis")
|
||||||
#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
|
#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
|
||||||
#define SQUIRREL_VERSION_NUMBER 310
|
#define SQUIRREL_VERSION_NUMBER 310
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK ho
|
|||||||
SQUIRREL_API SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx);
|
SQUIRREL_API SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx);
|
||||||
SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
|
SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
|
||||||
SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi);
|
SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi);
|
||||||
SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger *nparams,SQUnsignedInteger *nfreevars);
|
SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars);
|
||||||
SQUIRREL_API SQRESULT sq_getclosurename(HSQUIRRELVM v,SQInteger idx);
|
SQUIRREL_API SQRESULT sq_getclosurename(HSQUIRRELVM v,SQInteger idx);
|
||||||
SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
|
SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
|
||||||
SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
|
SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
|
||||||
@ -334,6 +334,7 @@ SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
|
|||||||
SQUIRREL_API SQRESULT sq_throwobject(HSQUIRRELVM v);
|
SQUIRREL_API SQRESULT sq_throwobject(HSQUIRRELVM v);
|
||||||
SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
|
SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
|
||||||
SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
|
SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
|
||||||
|
SQUIRREL_API SQRESULT sq_tailcall(HSQUIRRELVM v, SQInteger nparams);
|
||||||
|
|
||||||
/*raw object handling*/
|
/*raw object handling*/
|
||||||
SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
|
SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
|
||||||
@ -402,7 +403,7 @@ SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
|
|||||||
#define SQ_SUCCEEDED(res) (res>=0)
|
#define SQ_SUCCEEDED(res) (res>=0)
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define SQ_UNUSED_ARG(x) __attribute__((unused)) x
|
# define SQ_UNUSED_ARG(x) x __attribute__((__unused__))
|
||||||
#else
|
#else
|
||||||
# define SQ_UNUSED_ARG(x) x
|
# define SQ_UNUSED_ARG(x) x
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user