[DEV] remove __Swap()
This commit is contained in:
parent
e62f3074cb
commit
6ec3f05c5d
@ -12,7 +12,6 @@
|
|||||||
#include <rabbit/ObjectValue.hpp>
|
#include <rabbit/ObjectValue.hpp>
|
||||||
|
|
||||||
namespace rabbit {
|
namespace rabbit {
|
||||||
|
|
||||||
class Object {
|
class Object {
|
||||||
public:
|
public:
|
||||||
rabbit::ObjectType _type;
|
rabbit::ObjectType _type;
|
||||||
@ -228,14 +227,4 @@ namespace rabbit {
|
|||||||
void releaseRef();
|
void releaseRef();
|
||||||
void swap(rabbit::Object& _obj);
|
void swap(rabbit::Object& _obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void _Swap(rabbit::Object &a,rabbit::Object &b)
|
|
||||||
{
|
|
||||||
rabbit::ObjectType tOldType = a._type;
|
|
||||||
rabbit::ObjectValue unOldVal = a._unVal;
|
|
||||||
a._type = b._type;
|
|
||||||
a._unVal = b._unVal;
|
|
||||||
b._type = tOldType;
|
|
||||||
b._unVal = unOldVal;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,11 @@
|
|||||||
#include <rabbit/Object.hpp>
|
#include <rabbit/Object.hpp>
|
||||||
|
|
||||||
namespace rabbit {
|
namespace rabbit {
|
||||||
#define RABBIT_OBJ_REF_TYPE_DECLARE(type,_class,sym) \
|
#define RABBIT_OBJ_REF_TYPE_DECLARE(type,_class) \
|
||||||
ObjectPtr(_class * x); \
|
ObjectPtr(_class * x); \
|
||||||
ObjectPtr& operator=(_class *x);
|
ObjectPtr& operator=(_class *x);
|
||||||
|
|
||||||
#define RABBIT_SCALAR_TYPE_DECLARE(type,_class,sym) \
|
#define RABBIT_SCALAR_TYPE_DECLARE(type,_class) \
|
||||||
ObjectPtr(_class x); \
|
ObjectPtr(_class x); \
|
||||||
ObjectPtr& operator=(_class x);
|
ObjectPtr& operator=(_class x);
|
||||||
|
|
||||||
@ -28,23 +28,23 @@ namespace rabbit {
|
|||||||
ObjectPtr(const ObjectPtr& _obj);
|
ObjectPtr(const ObjectPtr& _obj);
|
||||||
ObjectPtr(const Object& _obj);
|
ObjectPtr(const Object& _obj);
|
||||||
|
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_TABLE, rabbit::Table, pTable)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_TABLE, rabbit::Table)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_CLASS, rabbit::Class, pClass)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_CLASS, rabbit::Class)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_INSTANCE, rabbit::Instance, pInstance)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_INSTANCE, rabbit::Instance)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_ARRAY, rabbit::Array, pArray)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_ARRAY, rabbit::Array)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_CLOSURE, rabbit::Closure, pClosure)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_CLOSURE, rabbit::Closure)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_NATIVECLOSURE, rabbit::NativeClosure, pNativeClosure)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_NATIVECLOSURE, rabbit::NativeClosure)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_OUTER, rabbit::Outer, pOuter)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_OUTER, rabbit::Outer)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_GENERATOR, rabbit::Generator, pGenerator)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_GENERATOR, rabbit::Generator)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_STRING, rabbit::String, pString)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_STRING, rabbit::String)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_USERDATA, UserData, pUserData)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_USERDATA, UserData)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_WEAKREF, WeakRef, pWeakRef)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_WEAKREF, WeakRef)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_THREAD, VirtualMachine, pThread)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_THREAD, VirtualMachine)
|
||||||
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_FUNCPROTO, rabbit::FunctionProto, pFunctionProto)
|
RABBIT_OBJ_REF_TYPE_DECLARE(rabbit::OT_FUNCPROTO, rabbit::FunctionProto)
|
||||||
|
|
||||||
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_INTEGER, int64_t, nInteger)
|
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_INTEGER, int64_t)
|
||||||
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_FLOAT, float_t, fFloat)
|
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_FLOAT, float_t)
|
||||||
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_USERPOINTER, UserPointer, pUserPointer)
|
RABBIT_SCALAR_TYPE_DECLARE(rabbit::OT_USERPOINTER, UserPointer)
|
||||||
|
|
||||||
ObjectPtr(bool _value);
|
ObjectPtr(bool _value);
|
||||||
ObjectPtr& operator=(bool _value);
|
ObjectPtr& operator=(bool _value);
|
||||||
|
@ -225,7 +225,7 @@ bool rabbit::VirtualMachine::NEG_OP(rabbit::ObjectPtr &trg,const rabbit::ObjectP
|
|||||||
if(callMetaMethod(closure, MT_UNM, 1, temp_reg) == false) {
|
if(callMetaMethod(closure, MT_UNM, 1, temp_reg) == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_Swap(trg,temp_reg);
|
trg.swap(temp_reg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -868,17 +868,21 @@ exception_restore:
|
|||||||
SQ_THROW();
|
SQ_THROW();
|
||||||
}
|
}
|
||||||
STK(arg3) = o;
|
STK(arg3) = o;
|
||||||
_Swap(TARGET,temp_reg);//TARGET = temp_reg;
|
TARGET.swap(temp_reg);
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
case _OP_GETK:
|
case _OP_GETK:
|
||||||
if (!get(STK(arg2), ci->_literals[arg1], temp_reg, 0,arg2)) { SQ_THROW();}
|
if (!get(STK(arg2), ci->_literals[arg1], temp_reg, 0,arg2)) {
|
||||||
_Swap(TARGET,temp_reg);//TARGET = temp_reg;
|
SQ_THROW();
|
||||||
|
}
|
||||||
|
TARGET.swap(temp_reg);
|
||||||
continue;
|
continue;
|
||||||
case _OP_MOVE: TARGET = STK(arg1); continue;
|
case _OP_MOVE: TARGET = STK(arg1); continue;
|
||||||
case _OP_NEWSLOT:
|
case _OP_NEWSLOT:
|
||||||
_GUARD(newSlot(STK(arg1), STK(arg2), STK(arg3),false));
|
_GUARD(newSlot(STK(arg1), STK(arg2), STK(arg3),false));
|
||||||
if(arg0 != 0xFF) TARGET = STK(arg3);
|
if(arg0 != 0xFF) {
|
||||||
|
TARGET = STK(arg3);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
case _OP_DELETE: _GUARD(deleteSlot(STK(arg1), STK(arg2), TARGET)); continue;
|
case _OP_DELETE: _GUARD(deleteSlot(STK(arg1), STK(arg2), TARGET)); continue;
|
||||||
case _OP_SET:
|
case _OP_SET:
|
||||||
@ -887,7 +891,7 @@ exception_restore:
|
|||||||
continue;
|
continue;
|
||||||
case _OP_GET:
|
case _OP_GET:
|
||||||
if (!get(STK(arg1), STK(arg2), temp_reg, 0,arg1)) { SQ_THROW(); }
|
if (!get(STK(arg1), STK(arg2), temp_reg, 0,arg1)) { SQ_THROW(); }
|
||||||
_Swap(TARGET,temp_reg);//TARGET = temp_reg;
|
TARGET.swap(temp_reg);
|
||||||
continue;
|
continue;
|
||||||
case _OP_EQ:{
|
case _OP_EQ:{
|
||||||
bool res;
|
bool res;
|
||||||
@ -912,7 +916,7 @@ exception_restore:
|
|||||||
if(Return(arg0, arg1, temp_reg)){
|
if(Return(arg0, arg1, temp_reg)){
|
||||||
assert(traps==0);
|
assert(traps==0);
|
||||||
//outres = temp_reg;
|
//outres = temp_reg;
|
||||||
_Swap(outres,temp_reg);
|
outres.swap(temp_reg);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
@ -1053,7 +1057,9 @@ exception_restore:
|
|||||||
if(sarg1 != MAX_FUNC_STACKSIZE) temp_reg = STK(arg1);
|
if(sarg1 != MAX_FUNC_STACKSIZE) temp_reg = STK(arg1);
|
||||||
_GUARD(ci->_generator->yield(this,arg2));
|
_GUARD(ci->_generator->yield(this,arg2));
|
||||||
traps -= ci->_etraps;
|
traps -= ci->_etraps;
|
||||||
if(sarg1 != MAX_FUNC_STACKSIZE) _Swap(STK(arg1),temp_reg);//STK(arg1) = temp_reg;
|
if(sarg1 != MAX_FUNC_STACKSIZE) {
|
||||||
|
STK(arg1).swap(temp_reg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else { raise_error("trying to yield a '%s',only genenerator can be yielded", getTypeName(ci->_generator)); SQ_THROW();}
|
else { raise_error("trying to yield a '%s',only genenerator can be yielded", getTypeName(ci->_generator)); SQ_THROW();}
|
||||||
if(Return(arg0, arg1, temp_reg)){
|
if(Return(arg0, arg1, temp_reg)){
|
||||||
|
@ -758,7 +758,7 @@ static bool _hsort_sift_down(rabbit::VirtualMachine* v,rabbit::Array *arr, int64
|
|||||||
return false; // We'd be swapping ourselve. The compare function is incorrect
|
return false; // We'd be swapping ourselve. The compare function is incorrect
|
||||||
}
|
}
|
||||||
|
|
||||||
_Swap((*arr)[root], (*arr)[maxChild]);
|
(*arr)[root].swap((*arr)[maxChild]);
|
||||||
root = maxChild;
|
root = maxChild;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -779,7 +779,7 @@ static bool _hsort(rabbit::VirtualMachine* v,rabbit::ObjectPtr &arr, int64_t SQ_
|
|||||||
|
|
||||||
for (i = array_size-1; i >= 1; i--)
|
for (i = array_size-1; i >= 1; i--)
|
||||||
{
|
{
|
||||||
_Swap((*a)[0],(*a)[i]);
|
(*a)[0].swap((*a)[i]);
|
||||||
if(!_hsort_sift_down(v,a, 0, i-1,func)) return false;
|
if(!_hsort_sift_down(v,a, 0, i-1,func)) return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user