[DEV] remote _nativeclosure()
This commit is contained in:
parent
056190e60b
commit
d80ea723cb
@ -149,7 +149,6 @@ namespace rabbit {
|
||||
#define is_delegable(t) (sq_type(t)&SQOBJECT_DELEGABLE)
|
||||
#define raw_type(obj) _RAW_TYPE((obj)._type)
|
||||
|
||||
#define _nativeclosure(obj) ((obj)._unVal.pNativeClosure)
|
||||
#define _userdata(obj) ((obj)._unVal.pUserData)
|
||||
#define _userpointer(obj) ((obj)._unVal.pUserPointer)
|
||||
#define _thread(obj) ((obj)._unVal.pThread)
|
||||
|
@ -756,7 +756,7 @@ exception_restore:
|
||||
case rabbit::OT_NATIVECLOSURE: {
|
||||
bool suspend;
|
||||
bool tailcall;
|
||||
_GUARD(callNative(_nativeclosure(clo), arg3, _stackbase+arg2, clo, (int32_t)sarg0, suspend, tailcall));
|
||||
_GUARD(callNative(clo.toNativeClosure(), arg3, _stackbase+arg2, clo, (int32_t)sarg0, suspend, tailcall));
|
||||
if(suspend){
|
||||
_suspended = SQTrue;
|
||||
_suspended_target = sarg0;
|
||||
@ -787,7 +787,7 @@ exception_restore:
|
||||
bool dummy;
|
||||
stkbase = _stackbase+arg2;
|
||||
_stack[stkbase] = inst;
|
||||
_GUARD(callNative(_nativeclosure(clo), arg3, stkbase, clo, -1, dummy, dummy));
|
||||
_GUARD(callNative(clo.toNativeClosure(), arg3, stkbase, clo, -1, dummy, dummy));
|
||||
break;
|
||||
default: break; //shutup GCC 4.x
|
||||
}
|
||||
@ -1607,7 +1607,7 @@ int64_t prevstackbase = _stackbase;
|
||||
break;
|
||||
case rabbit::OT_NATIVECLOSURE:{
|
||||
bool dummy;
|
||||
return callNative(_nativeclosure(closure), nparams, stackbase, outres, -1, dummy, dummy);
|
||||
return callNative(closure.toNativeClosure(), nparams, stackbase, outres, -1, dummy, dummy);
|
||||
|
||||
}
|
||||
break;
|
||||
|
@ -418,7 +418,7 @@ rabbit::Result rabbit::sq_getclosureinfo(rabbit::VirtualMachine* v,int64_t idx,u
|
||||
}
|
||||
else if(sq_type(o) == rabbit::OT_NATIVECLOSURE)
|
||||
{
|
||||
rabbit::NativeClosure *c = _nativeclosure(o);
|
||||
rabbit::NativeClosure *c = o.toNativeClosure();
|
||||
*nparams = (uint64_t)c->_nparamscheck;
|
||||
*nfreevars = c->_noutervalues;
|
||||
return SQ_OK;
|
||||
@ -430,7 +430,7 @@ rabbit::Result rabbit::sq_setnativeclosurename(rabbit::VirtualMachine* v,int64_t
|
||||
{
|
||||
rabbit::Object o = stack_get(v, idx);
|
||||
if(sq_isnativeclosure(o)) {
|
||||
rabbit::NativeClosure *nc = _nativeclosure(o);
|
||||
rabbit::NativeClosure *nc = o.toNativeClosure();
|
||||
nc->_name = rabbit::String::create(_get_shared_state(v),name);
|
||||
return SQ_OK;
|
||||
}
|
||||
@ -442,7 +442,7 @@ rabbit::Result rabbit::sq_setparamscheck(rabbit::VirtualMachine* v,int64_t npara
|
||||
rabbit::Object o = stack_get(v, -1);
|
||||
if(!sq_isnativeclosure(o))
|
||||
return sq_throwerror(v, "native closure expected");
|
||||
rabbit::NativeClosure *nc = _nativeclosure(o);
|
||||
rabbit::NativeClosure *nc = o.toNativeClosure();
|
||||
nc->_nparamscheck = nparamscheck;
|
||||
if(typemask) {
|
||||
etk::Vector<int64_t> res;
|
||||
@ -485,7 +485,7 @@ rabbit::Result rabbit::sq_bindenv(rabbit::VirtualMachine* v,int64_t idx)
|
||||
ret = c;
|
||||
}
|
||||
else { //then must be a native closure
|
||||
rabbit::NativeClosure *c = _nativeclosure(o)->clone();
|
||||
rabbit::NativeClosure *c = o.toNativeClosure()->clone();
|
||||
__Objrelease(c->_env);
|
||||
c->_env = w;
|
||||
__ObjaddRef(c->_env);
|
||||
@ -504,7 +504,7 @@ rabbit::Result rabbit::sq_getclosurename(rabbit::VirtualMachine* v,int64_t idx)
|
||||
return sq_throwerror(v,"the target is not a closure");
|
||||
if(sq_isnativeclosure(o))
|
||||
{
|
||||
v->push(_nativeclosure(o)->_name);
|
||||
v->push(o.toNativeClosure()->_name);
|
||||
}
|
||||
else { //closure
|
||||
v->push(o.toClosure()->_function->_name);
|
||||
@ -1372,7 +1372,7 @@ const char * rabbit::sq_getfreevariable(rabbit::VirtualMachine* v,int64_t idx,ui
|
||||
}
|
||||
break;
|
||||
case rabbit::OT_NATIVECLOSURE:{
|
||||
rabbit::NativeClosure *clo = _nativeclosure(self);
|
||||
rabbit::NativeClosure *clo = self.toNativeClosure();
|
||||
if(clo->_noutervalues > nval) {
|
||||
v->push(clo->_outervalues[nval]);
|
||||
name = "@NATIVE";
|
||||
@ -1398,8 +1398,8 @@ rabbit::Result rabbit::sq_setfreevariable(rabbit::VirtualMachine* v,int64_t idx,
|
||||
}
|
||||
break;
|
||||
case rabbit::OT_NATIVECLOSURE:
|
||||
if(_nativeclosure(self)->_noutervalues > nval){
|
||||
_nativeclosure(self)->_outervalues[nval] = stack_get(v,-1);
|
||||
if(self.toNativeClosure()->_noutervalues > nval){
|
||||
self.toNativeClosure()->_outervalues[nval] = stack_get(v,-1);
|
||||
}
|
||||
else return sq_throwerror(v,"invalid free var index");
|
||||
break;
|
||||
|
@ -1001,7 +1001,7 @@ static int64_t closure_getinfos(rabbit::VirtualMachine* v) {
|
||||
res->newSlot(rabbit::String::create(_get_shared_state(v),"defparams",-1),defparams);
|
||||
}
|
||||
else { //rabbit::OT_NATIVECLOSURE
|
||||
rabbit::NativeClosure *nc = _nativeclosure(o);
|
||||
rabbit::NativeClosure *nc = o.toNativeClosure();
|
||||
res->newSlot(rabbit::String::create(_get_shared_state(v),"native",-1),true);
|
||||
res->newSlot(rabbit::String::create(_get_shared_state(v),"name",-1),nc->_name);
|
||||
res->newSlot(rabbit::String::create(_get_shared_state(v),"paramscheck",-1),nc->_nparamscheck);
|
||||
|
@ -59,8 +59,8 @@ rabbit::Result rabbit::sq_stackinfos(rabbit::VirtualMachine* v, int64_t level, r
|
||||
case rabbit::OT_NATIVECLOSURE:
|
||||
si->source = "NATIVE";
|
||||
si->funcname = "unknown";
|
||||
if(sq_type(_nativeclosure(ci._closure)->_name) == rabbit::OT_STRING)
|
||||
si->funcname = _stringval(_nativeclosure(ci._closure)->_name);
|
||||
if(sq_type(ci._closure.toNativeClosure()->_name) == rabbit::OT_STRING)
|
||||
si->funcname = _stringval(ci._closure.toNativeClosure()->_name);
|
||||
si->line = -1;
|
||||
break;
|
||||
default: break; //shutup compiler
|
||||
|
Loading…
x
Reference in New Issue
Block a user