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