[DEV] change global function naming lowerCamelCase

This commit is contained in:
Edouard DUPIN 2018-06-27 02:15:43 +02:00
parent 68295a1431
commit 5e372fdbfa
26 changed files with 1080 additions and 1075 deletions

View File

@ -219,7 +219,7 @@ int getargs(HRABBITVM v,int argc, char* argv[],int64_t *retval)
const SQChar *err;
sq_getlasterror(v);
if(SQ_SUCCEEDED(sq_getstring(v,-1,&err))) {
scprintf(_SC("Error [%s]\n"),err);
scprintf(_SC("error [%s]\n"),err);
*retval = -2;
return _ERROR;
}
@ -352,7 +352,7 @@ int main(int argc, char* argv[])
#if defined(_MSC_VER) && defined(_DEBUG)
_getch();
_CrtMemDumpAllObjectsSince( NULL );
_CrtMemdumpAllObjectsSince( NULL );
#endif
return retval;
}

View File

@ -26,14 +26,14 @@ import time
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.pngmath',
]
# Add any paths that contain templates here, relative to this directory.
# add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
@ -117,7 +117,7 @@ html_theme = 'sphinx_rtd_theme'
# documentation.
#html_theme_options = {}
# Add any paths that contain custom themes here, relative to this directory.
# add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# The name for this set of Sphinx documents. If None, it defaults to
@ -136,12 +136,12 @@ html_logo = 'simple_nut.png'
# pixels large.
html_favicon = 'nut.ico'
# Add any paths that contain custom static files (such as style sheets) here,
# add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# Add any extra paths that contain custom files (such as robots.txt or
# add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
# directly to the root of the documentation.
#html_extra_path = []
@ -157,7 +157,7 @@ html_static_path = ['_static']
# Custom sidebar templates, maps document names to template names.
#html_sidebars = {}
# Additional templates that should be rendered to pages, maps page names to
# additional templates that should be rendered to pages, maps page names to
# template names.
#html_additional_pages = {}
@ -213,7 +213,7 @@ latex_elements = {
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
# additional stuff for the LaTeX preamble.
#'preamble': '',
# Latex figure (float) alignment

View File

@ -70,16 +70,16 @@ int64_t sqstd_feof(SQFILE file)
struct SQFile : public SQStream {
SQFile() { _handle = NULL; _owns = false;}
SQFile(SQFILE file, bool owns) { _handle = file; _owns = owns;}
virtual ~SQFile() { Close(); }
virtual ~SQFile() { close(); }
bool Open(const SQChar *filename ,const SQChar *mode) {
Close();
close();
if( (_handle = sqstd_fopen(filename,mode)) ) {
_owns = true;
return true;
}
return false;
}
void Close() {
void close() {
if(_handle && _owns) {
sqstd_fclose(_handle);
_handle = NULL;
@ -164,7 +164,7 @@ static int64_t _file_close(HRABBITVM v)
if(SQ_SUCCEEDED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_FILE_TYPE_TAG))
&& self != NULL)
{
self->Close();
self->close();
}
return 0;
}

View File

@ -21,9 +21,9 @@ namespace rabbit {
public:
// TODO : remove this ETK_ALLOC can do it natively ...
static Array* create(SQSharedState* _ss,
int64_t _nInitialsize) {
int64_t _ninitialsize) {
Array *newarray=(Array*)SQ_MALLOC(sizeof(Array));
new (newarray) Array(_ss, _nInitialsize);
new (newarray) Array(_ss, _ninitialsize);
return newarray;
}
void finalize() {

View File

@ -21,8 +21,8 @@ static bool sq_aux_gettypedarg(HRABBITVM v,int64_t idx,SQObjectType type,SQObjec
{
*o = &stack_get(v,idx);
if(sq_type(**o) != type){
SQObjectPtr oval = v->PrintObjVal(**o);
v->Raise_Error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
SQObjectPtr oval = v->printObjVal(**o);
v->raise_error(_SC("wrong argument type, expected '%s' got '%.50s'"),IdType2Name(type),_stringval(oval));
return false;
}
return true;
@ -32,7 +32,7 @@ static bool sq_aux_gettypedarg(HRABBITVM v,int64_t idx,SQObjectType type,SQObjec
#define sq_aux_paramscheck(v,count) \
{ \
if(sq_gettop(v) < count){ v->Raise_Error(_SC("not enough params in the stack")); return SQ_ERROR; }\
if(sq_gettop(v) < count){ v->raise_error(_SC("not enough params in the stack")); return SQ_ERROR; }\
}
@ -48,11 +48,11 @@ HRABBITVM sq_open(int64_t initialstacksize)
SQSharedState *ss;
SQVM *v;
sq_new(ss, SQSharedState);
ss->Init();
ss->init();
v = (SQVM *)SQ_MALLOC(sizeof(SQVM));
new (v) SQVM(ss);
ss->_root_vm = v;
if(v->Init(NULL, initialstacksize)) {
if(v->init(NULL, initialstacksize)) {
return v;
} else {
sq_delete(v, SQVM);
@ -70,8 +70,8 @@ HRABBITVM sq_newthread(HRABBITVM friendvm, int64_t initialstacksize)
v= (SQVM *)SQ_MALLOC(sizeof(SQVM));
new (v) SQVM(ss);
if(v->Init(friendvm, initialstacksize)) {
friendvm->Push(v);
if(v->init(friendvm, initialstacksize)) {
friendvm->push(v);
return v;
} else {
sq_delete(v, SQVM);
@ -94,7 +94,7 @@ void sq_seterrorhandler(HRABBITVM v)
SQObject o = stack_get(v, -1);
if(sq_isclosure(o) || sq_isnativeclosure(o) || sq_isnull(o)) {
v->_errorhandler = o;
v->Pop();
v->pop();
}
}
@ -112,14 +112,14 @@ void sq_setdebughook(HRABBITVM v)
v->_debughook_closure = o;
v->_debughook_native = NULL;
v->_debughook = !sq_isnull(o);
v->Pop();
v->pop();
}
}
void sq_close(HRABBITVM v)
{
SQSharedState *ss = _ss(v);
_thread(ss->_root_vm)->Finalize();
_thread(ss->_root_vm)->finalize();
sq_delete(ss, SQSharedState);
}
@ -132,8 +132,8 @@ SQRESULT sq_compile(HRABBITVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar
{
SQObjectPtr o;
#ifndef NO_COMPILER
if(Compile(v, read, p, sourcename, o, raiseerror?true:false, _ss(v)->_debuginfo)) {
v->Push(SQClosure::create(_ss(v), _funcproto(o), _table(v->_roottable)->getWeakRef(OT_TABLE)));
if(compile(v, read, p, sourcename, o, raiseerror?true:false, _ss(v)->_debuginfo)) {
v->push(SQClosure::create(_ss(v), _funcproto(o), _table(v->_roottable)->getWeakRef(OT_TABLE)));
return SQ_OK;
}
return SQ_ERROR;
@ -155,7 +155,7 @@ void sq_notifyallexceptions(HRABBITVM v, SQBool enable)
void sq_addref(HRABBITVM v,HSQOBJECT *po)
{
if(!ISREFCOUNTED(sq_type(*po))) return;
__AddRef(po->_type,po->_unVal);
__addRef(po->_type,po->_unVal);
}
uint64_t sq_getrefcount(HRABBITVM v,HSQOBJECT *po)
@ -220,61 +220,61 @@ SQUserPointer sq_objtouserpointer(const HSQOBJECT *o)
void sq_pushnull(HRABBITVM v)
{
v->PushNull();
v->pushNull();
}
void sq_pushstring(HRABBITVM v,const SQChar *s,int64_t len)
{
if(s)
v->Push(SQObjectPtr(SQString::create(_ss(v), s, len)));
else v->PushNull();
v->push(SQObjectPtr(SQString::create(_ss(v), s, len)));
else v->pushNull();
}
void sq_pushinteger(HRABBITVM v,int64_t n)
{
v->Push(n);
v->push(n);
}
void sq_pushbool(HRABBITVM v,SQBool b)
{
v->Push(b?true:false);
v->push(b?true:false);
}
void sq_pushfloat(HRABBITVM v,float_t n)
{
v->Push(n);
v->push(n);
}
void sq_pushuserpointer(HRABBITVM v,SQUserPointer p)
{
v->Push(p);
v->push(p);
}
void sq_pushthread(HRABBITVM v, HRABBITVM thread)
{
v->Push(thread);
v->push(thread);
}
SQUserPointer sq_newuserdata(HRABBITVM v,uint64_t size)
{
rabbit::UserData *ud = rabbit::UserData::create(_ss(v), size + SQ_ALIGNMENT);
v->Push(ud);
v->push(ud);
return (SQUserPointer)sq_aligning(ud + 1);
}
void sq_newtable(HRABBITVM v)
{
v->Push(SQTable::create(_ss(v), 0));
v->push(SQTable::create(_ss(v), 0));
}
void sq_newtableex(HRABBITVM v,int64_t initialcapacity)
{
v->Push(SQTable::create(_ss(v), initialcapacity));
v->push(SQTable::create(_ss(v), initialcapacity));
}
void sq_newarray(HRABBITVM v,int64_t size)
{
v->Push(rabbit::Array::create(_ss(v), size));
v->push(rabbit::Array::create(_ss(v), size));
}
SQRESULT sq_newclass(HRABBITVM v,SQBool hasbase)
@ -287,8 +287,8 @@ SQRESULT sq_newclass(HRABBITVM v,SQBool hasbase)
baseclass = _class(base);
}
SQClass *newclass = SQClass::create(_ss(v), baseclass);
if(baseclass) v->Pop();
v->Push(newclass);
if(baseclass) v->pop();
v->push(newclass);
return SQ_OK;
}
@ -298,7 +298,7 @@ SQBool sq_instanceof(HRABBITVM v)
SQObjectPtr &cl = stack_get(v,-2);
if(sq_type(inst) != OT_INSTANCE || sq_type(cl) != OT_CLASS)
return sq_throwerror(v,_SC("invalid param type"));
return _instance(inst)->InstanceOf(_class(cl))?SQTrue:SQFalse;
return _instance(inst)->instanceOf(_class(cl))?SQTrue:SQFalse;
}
SQRESULT sq_arrayappend(HRABBITVM v,int64_t idx)
@ -307,7 +307,7 @@ SQRESULT sq_arrayappend(HRABBITVM v,int64_t idx)
SQObjectPtr *arr;
_GETSAFE_OBJ(v, idx, OT_ARRAY,arr);
_array(*arr)->append(v->getUp(-1));
v->Pop();
v->pop();
return SQ_OK;
}
@ -318,7 +318,7 @@ SQRESULT sq_arraypop(HRABBITVM v,int64_t idx,SQBool pushval)
_GETSAFE_OBJ(v, idx, OT_ARRAY,arr);
if(_array(*arr)->size() > 0) {
if(pushval != 0){
v->Push(_array(*arr)->top());
v->push(_array(*arr)->top());
}
_array(*arr)->pop();
return SQ_OK;
@ -374,7 +374,7 @@ SQRESULT sq_arrayinsert(HRABBITVM v,int64_t idx,int64_t destpos)
SQObjectPtr *arr;
_GETSAFE_OBJ(v, idx, OT_ARRAY,arr);
SQRESULT ret = _array(*arr)->insert(destpos, v->getUp(-1)) ? SQ_OK : sq_throwerror(v,_SC("index out of range"));
v->Pop();
v->pop();
return ret;
}
@ -384,9 +384,9 @@ void sq_newclosure(HRABBITVM v,SQFUNCTION func,uint64_t nfreevars)
nc->_nparamscheck = 0;
for(uint64_t i = 0; i < nfreevars; i++) {
nc->_outervalues[i] = v->top();
v->Pop();
v->pop();
}
v->Push(SQObjectPtr(nc));
v->push(SQObjectPtr(nc));
}
SQRESULT sq_getclosureinfo(HRABBITVM v,int64_t idx,uint64_t *nparams,uint64_t *nfreevars)
@ -429,7 +429,7 @@ SQRESULT sq_setparamscheck(HRABBITVM v,int64_t nparamscheck,const SQChar *typema
nc->_nparamscheck = nparamscheck;
if(typemask) {
SQIntVec res;
if(!CompileTypemask(res, typemask))
if(!compileTypemask(res, typemask))
return sq_throwerror(v, _SC("invalid typemask"));
nc->_typecheck.copy(res);
}
@ -460,10 +460,10 @@ SQRESULT sq_bindenv(HRABBITVM v,int64_t idx)
SQClosure *c = _closure(o)->clone();
__Objrelease(c->_env);
c->_env = w;
__ObjAddRef(c->_env);
__ObjaddRef(c->_env);
if(_closure(o)->_base) {
c->_base = _closure(o)->_base;
__ObjAddRef(c->_base);
__ObjaddRef(c->_base);
}
ret = c;
}
@ -471,11 +471,11 @@ SQRESULT sq_bindenv(HRABBITVM v,int64_t idx)
SQNativeClosure *c = _nativeclosure(o)->clone();
__Objrelease(c->_env);
c->_env = w;
__ObjAddRef(c->_env);
__ObjaddRef(c->_env);
ret = c;
}
v->Pop();
v->Push(ret);
v->pop();
v->push(ret);
return SQ_OK;
}
@ -487,10 +487,10 @@ SQRESULT sq_getclosurename(HRABBITVM v,int64_t idx)
return sq_throwerror(v,_SC("the target is not a closure"));
if(sq_isnativeclosure(o))
{
v->Push(_nativeclosure(o)->_name);
v->push(_nativeclosure(o)->_name);
}
else { //closure
v->Push(_closure(o)->_function->_name);
v->push(_closure(o)->_function->_name);
}
return SQ_OK;
}
@ -502,7 +502,7 @@ SQRESULT sq_setclosureroot(HRABBITVM v,int64_t idx)
if(!sq_isclosure(c)) return sq_throwerror(v, _SC("closure expected"));
if(sq_istable(o)) {
_closure(c)->setRoot(_table(o)->getWeakRef(OT_TABLE));
v->Pop();
v->pop();
return SQ_OK;
}
return sq_throwerror(v, _SC("invalid type"));
@ -512,7 +512,7 @@ SQRESULT sq_getclosureroot(HRABBITVM v,int64_t idx)
{
SQObjectPtr &c = stack_get(v,idx);
if(!sq_isclosure(c)) return sq_throwerror(v, _SC("closure expected"));
v->Push(_closure(c)->_root->_obj);
v->push(_closure(c)->_root->_obj);
return SQ_OK;
}
@ -520,7 +520,7 @@ SQRESULT sq_clear(HRABBITVM v,int64_t idx)
{
SQObject &o=stack_get(v,idx);
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;
default:
return sq_throwerror(v, _SC("clear only works on table and array"));
@ -532,17 +532,17 @@ SQRESULT sq_clear(HRABBITVM v,int64_t idx)
void sq_pushroottable(HRABBITVM v)
{
v->Push(v->_roottable);
v->push(v->_roottable);
}
void sq_pushregistrytable(HRABBITVM v)
{
v->Push(_ss(v)->_registry);
v->push(_ss(v)->_registry);
}
void sq_pushconsttable(HRABBITVM v)
{
v->Push(_ss(v)->_consts);
v->push(_ss(v)->_consts);
}
SQRESULT sq_setroottable(HRABBITVM v)
@ -550,7 +550,7 @@ SQRESULT sq_setroottable(HRABBITVM v)
SQObject o = stack_get(v, -1);
if(sq_istable(o) || sq_isnull(o)) {
v->_roottable = o;
v->Pop();
v->pop();
return SQ_OK;
}
return sq_throwerror(v, _SC("invalid type"));
@ -561,7 +561,7 @@ SQRESULT sq_setconsttable(HRABBITVM v)
SQObject o = stack_get(v, -1);
if(sq_istable(o)) {
_ss(v)->_consts = o;
v->Pop();
v->pop();
return SQ_OK;
}
return sq_throwerror(v, _SC("invalid type, expected table"));
@ -609,7 +609,7 @@ SQRELEASEHOOK sq_getsharedreleasehook(HRABBITVM v)
void sq_push(HRABBITVM v,int64_t idx)
{
v->Push(stack_get(v, idx));
v->push(stack_get(v, idx));
}
SQObjectType sq_gettype(HRABBITVM v,int64_t idx)
@ -621,10 +621,10 @@ SQRESULT sq_typeof(HRABBITVM v,int64_t idx)
{
SQObjectPtr &o = stack_get(v, idx);
SQObjectPtr res;
if(!v->TypeOf(o,res)) {
if(!v->typeOf(o,res)) {
return SQ_ERROR;
}
v->Push(res);
v->push(res);
return SQ_OK;
}
@ -632,10 +632,10 @@ SQRESULT sq_tostring(HRABBITVM v,int64_t idx)
{
SQObjectPtr &o = stack_get(v, idx);
SQObjectPtr res;
if(!v->ToString(o,res)) {
if(!v->toString(o,res)) {
return SQ_ERROR;
}
v->Push(res);
v->push(res);
return SQ_OK;
}
@ -707,9 +707,9 @@ SQRESULT sq_getthread(HRABBITVM v,int64_t idx,HRABBITVM *thread)
SQRESULT sq_clone(HRABBITVM v,int64_t idx)
{
SQObjectPtr &o = stack_get(v,idx);
v->PushNull();
v->pushNull();
if(!v->clone(o, stack_get(v, -1))){
v->Pop();
v->pop();
return SQ_ERROR;
}
return SQ_OK;
@ -721,7 +721,7 @@ int64_t sq_getsize(HRABBITVM v, int64_t idx)
SQObjectType type = sq_type(o);
switch(type) {
case OT_STRING: return _string(o)->_len;
case OT_TABLE: return _table(o)->CountUsed();
case OT_TABLE: return _table(o)->countUsed();
case OT_ARRAY: return _array(o)->size();
case OT_USERDATA: return _userdata(o)->getsize();
case OT_INSTANCE: return _instance(o)->_class->_udsize;
@ -843,13 +843,13 @@ void sq_settop(HRABBITVM v, int64_t newtop)
void sq_pop(HRABBITVM v, int64_t nelemstopop)
{
assert(v->_top >= nelemstopop);
v->Pop(nelemstopop);
v->pop(nelemstopop);
}
void sq_poptop(HRABBITVM v)
{
assert(v->_top >= 1);
v->Pop();
v->pop();
}
@ -861,7 +861,7 @@ void sq_remove(HRABBITVM v, int64_t idx)
int64_t sq_cmp(HRABBITVM v)
{
int64_t res;
v->ObjCmp(stack_get(v, -1), stack_get(v, -2),res);
v->objCmp(stack_get(v, -1), stack_get(v, -2),res);
return res;
}
@ -872,8 +872,8 @@ SQRESULT sq_newslot(HRABBITVM v, int64_t idx, SQBool bstatic)
if(sq_type(self) == OT_TABLE || sq_type(self) == OT_CLASS) {
SQObjectPtr &key = v->getUp(-2);
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->Pop(2);
v->newSlot(self, key, v->getUp(-1),bstatic?true:false);
v->pop(2);
}
return SQ_OK;
}
@ -886,12 +886,12 @@ SQRESULT sq_deleteslot(HRABBITVM v,int64_t idx,SQBool pushval)
SQObjectPtr &key = v->getUp(-1);
if(sq_type(key) == OT_NULL) return sq_throwerror(v, _SC("null is not a valid key"));
SQObjectPtr res;
if(!v->DeleteSlot(*self, key, res)){
v->Pop();
if(!v->deleteSlot(*self, key, res)){
v->pop();
return SQ_ERROR;
}
if(pushval) v->getUp(-1) = res;
else v->Pop();
else v->pop();
return SQ_OK;
}
@ -899,7 +899,7 @@ SQRESULT sq_set(HRABBITVM v,int64_t idx)
{
SQObjectPtr &self = stack_get(v, idx);
if(v->set(self, v->getUp(-2), v->getUp(-1),DONT_FALL_BACK)) {
v->Pop(2);
v->pop(2);
return SQ_OK;
}
return SQ_ERROR;
@ -910,37 +910,37 @@ SQRESULT sq_rawset(HRABBITVM v,int64_t idx)
SQObjectPtr &self = stack_get(v, idx);
SQObjectPtr &key = v->getUp(-2);
if(sq_type(key) == OT_NULL) {
v->Pop(2);
v->pop(2);
return sq_throwerror(v, _SC("null key"));
}
switch(sq_type(self)) {
case OT_TABLE:
_table(self)->NewSlot(key, v->getUp(-1));
v->Pop(2);
_table(self)->newSlot(key, v->getUp(-1));
v->pop(2);
return SQ_OK;
break;
case OT_CLASS:
_class(self)->NewSlot(_ss(v), key, v->getUp(-1),false);
v->Pop(2);
_class(self)->newSlot(_ss(v), key, v->getUp(-1),false);
v->pop(2);
return SQ_OK;
break;
case OT_INSTANCE:
if(_instance(self)->set(key, v->getUp(-1))) {
v->Pop(2);
v->pop(2);
return SQ_OK;
}
break;
case OT_ARRAY:
if(v->set(self, key, v->getUp(-1),false)) {
v->Pop(2);
v->pop(2);
return SQ_OK;
}
break;
default:
v->Pop(2);
v->pop(2);
return sq_throwerror(v, _SC("rawset works only on array/table/class and instance"));
}
v->Raise_IdxError(v->getUp(-2));return SQ_ERROR;
v->raise_Idxerror(v->getUp(-2));return SQ_ERROR;
}
SQRESULT sq_newmember(HRABBITVM v,int64_t idx,SQBool bstatic)
@ -949,11 +949,11 @@ SQRESULT sq_newmember(HRABBITVM v,int64_t idx,SQBool bstatic)
if(sq_type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
SQObjectPtr &key = v->getUp(-3);
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)) {
v->Pop(3);
if(!v->newSlotA(self,key,v->getUp(-2),v->getUp(-1),bstatic?true:false,false)) {
v->pop(3);
return SQ_ERROR;
}
v->Pop(3);
v->pop(3);
return SQ_OK;
}
@ -963,11 +963,11 @@ SQRESULT sq_rawnewmember(HRABBITVM v,int64_t idx,SQBool bstatic)
if(sq_type(self) != OT_CLASS) return sq_throwerror(v, _SC("new member only works with classes"));
SQObjectPtr &key = v->getUp(-3);
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)) {
v->Pop(3);
if(!v->newSlotA(self,key,v->getUp(-2),v->getUp(-1),bstatic?true:false,true)) {
v->pop(3);
return SQ_ERROR;
}
v->Pop(3);
v->pop(3);
return SQ_OK;
}
@ -982,17 +982,17 @@ SQRESULT sq_setdelegate(HRABBITVM v,int64_t idx)
if(!_table(self)->setDelegate(_table(mt))) {
return sq_throwerror(v, _SC("delagate cycle"));
}
v->Pop();
v->pop();
}
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);
break;
case OT_USERDATA:
if(sq_type(mt)==OT_TABLE) {
_userdata(self)->setDelegate(_table(mt)); v->Pop(); }
_userdata(self)->setDelegate(_table(mt)); v->pop(); }
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);
break;
default:
@ -1015,7 +1015,7 @@ SQRESULT sq_rawdeleteslot(HRABBITVM v,int64_t idx,SQBool pushval)
if(pushval != 0)
v->getUp(-1) = t;
else
v->Pop();
v->pop();
return SQ_OK;
}
@ -1026,10 +1026,10 @@ SQRESULT sq_getdelegate(HRABBITVM v,int64_t idx)
case OT_TABLE:
case OT_USERDATA:
if(!_delegable(self)->_delegate){
v->PushNull();
v->pushNull();
break;
}
v->Push(SQObjectPtr(_delegable(self)->_delegate));
v->push(SQObjectPtr(_delegable(self)->_delegate));
break;
default: return sq_throwerror(v,_SC("wrong type")); break;
}
@ -1043,7 +1043,7 @@ SQRESULT sq_get(HRABBITVM v,int64_t idx)
SQObjectPtr &obj = v->getUp(-1);
if(v->get(self,obj,obj,false,DONT_FALL_BACK))
return SQ_OK;
v->Pop();
v->pop();
return SQ_ERROR;
}
@ -1071,16 +1071,16 @@ SQRESULT sq_rawget(HRABBITVM v,int64_t idx)
}
}
else {
v->Pop();
v->pop();
return sq_throwerror(v,_SC("invalid index type for an array"));
}
}
break;
default:
v->Pop();
v->pop();
return sq_throwerror(v,_SC("rawget works only on array/table/instance and class"));
}
v->Pop();
v->pop();
return sq_throwerror(v,_SC("the index doesn't exist"));
}
@ -1097,16 +1097,16 @@ const SQChar *sq_getlocal(HRABBITVM v,uint64_t level,uint64_t idx)
int64_t stackbase=v->_stackbase;
if(lvl<cstksize){
for(uint64_t i=0;i<level;i++){
SQVM::CallInfo &ci=v->_callsstack[(cstksize-i)-1];
SQVM::callInfo &ci=v->_callsstack[(cstksize-i)-1];
stackbase-=ci._prevstkbase;
}
SQVM::CallInfo &ci=v->_callsstack[lvl];
SQVM::callInfo &ci=v->_callsstack[lvl];
if(sq_type(ci._closure)!=OT_CLOSURE)
return NULL;
SQClosure *c=_closure(ci._closure);
SQFunctionProto *func=c->_function;
if(func->_noutervalues > (int64_t)idx) {
v->Push(*_outer(c->_outervalues[idx])->_valptr);
v->push(*_outer(c->_outervalues[idx])->_valptr);
return _stringval(func->_outervalues[idx]._name);
}
idx -= func->_noutervalues;
@ -1117,7 +1117,7 @@ const SQChar *sq_getlocal(HRABBITVM v,uint64_t level,uint64_t idx)
void sq_pushobject(HRABBITVM v,HSQOBJECT obj)
{
v->Push(SQObjectPtr(obj));
v->push(SQObjectPtr(obj));
}
void sq_resetobject(HSQOBJECT *po)
@ -1134,7 +1134,7 @@ SQRESULT sq_throwerror(HRABBITVM v,const SQChar *err)
SQRESULT sq_throwobject(HRABBITVM v)
{
v->_lasterror = v->getUp(-1);
v->Pop();
v->pop();
return SQ_ERROR;
}
@ -1146,7 +1146,7 @@ void sq_reseterror(HRABBITVM v)
void sq_getlasterror(HRABBITVM v)
{
v->Push(v->_lasterror);
v->push(v->_lasterror);
}
SQRESULT sq_reservestack(HRABBITVM v,int64_t nsize)
@ -1164,11 +1164,11 @@ SQRESULT sq_resume(HRABBITVM v,SQBool retval,SQBool raiseerror)
{
if (sq_type(v->getUp(-1)) == OT_GENERATOR)
{
v->PushNull(); //retval
if (!v->Execute(v->getUp(-2), 0, v->_top, v->getUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
{v->Raise_Error(v->_lasterror); return SQ_ERROR;}
v->pushNull(); //retval
if (!v->execute(v->getUp(-2), 0, v->_top, v->getUp(-1), raiseerror, SQVM::ET_RESUME_GENERATOR))
{v->raise_error(v->_lasterror); return SQ_ERROR;}
if(!retval)
v->Pop();
v->pop();
return SQ_OK;
}
return sq_throwerror(v,_SC("only generators can be resumed"));
@ -1177,22 +1177,22 @@ SQRESULT sq_resume(HRABBITVM v,SQBool retval,SQBool raiseerror)
SQRESULT sq_call(HRABBITVM v,int64_t params,SQBool retval,SQBool raiseerror)
{
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;
v->push(res); return SQ_OK;
}
return SQ_OK;
}
else {
v->Pop(params);
v->pop(params);
return SQ_ERROR;
}
if(!v->_suspended)
v->Pop(params);
v->pop(params);
return sq_throwerror(v,_SC("call failed"));
}
@ -1209,7 +1209,7 @@ SQRESULT sq_tailcall(HRABBITVM v, int64_t nparams)
}
int64_t stackbase = (v->_top - nparams) - v->_stackbase;
if (!v->TailCall(clo, stackbase, nparams)) {
if (!v->tailcall(clo, stackbase, nparams)) {
return SQ_ERROR;
}
return SQ_TAILCALL_FLAG;
@ -1230,14 +1230,14 @@ SQRESULT sq_wakeupvm(HRABBITVM v,SQBool wakeupret,SQBool retval,SQBool raiseerro
if(target != -1) {
v->getAt(v->_stackbase+v->_suspended_target)=v->getUp(-1); //retval
}
v->Pop();
v->pop();
} else if(target != -1) { v->getAt(v->_stackbase+v->_suspended_target).Null(); }
SQObjectPtr dummy;
if(!v->Execute(dummy,-1,-1,ret,raiseerror,throwerror?SQVM::ET_RESUME_THROW_VM : SQVM::ET_RESUME_VM)) {
if(!v->execute(dummy,-1,-1,ret,raiseerror,throwerror?SQVM::ET_RESUME_THROW_VM : SQVM::ET_RESUME_VM)) {
return SQ_ERROR;
}
if(retval) {
v->Push(ret);
v->push(ret);
}
return SQ_OK;
}
@ -1292,7 +1292,7 @@ SQRESULT sq_writeclosure(HRABBITVM v,SQWRITEFUNC w,SQUserPointer up)
return sq_throwerror(v,_SC("a closure with free variables bound cannot be serialized"));
if(w(up,&tag,2) != 2)
return sq_throwerror(v,_SC("io error"));
if(!_closure(*o)->Save(v,up,w))
if(!_closure(*o)->save(v,up,w))
return SQ_ERROR;
return SQ_OK;
}
@ -1306,9 +1306,9 @@ SQRESULT sq_readclosure(HRABBITVM v,SQREADFUNC r,SQUserPointer up)
return sq_throwerror(v,_SC("io error"));
if(tag != SQ_BYTECODE_STREAM_TAG)
return sq_throwerror(v,_SC("invalid stream"));
if(!SQClosure::Load(v,up,r,closure))
if(!SQClosure::load(v,up,r,closure))
return SQ_ERROR;
v->Push(closure);
v->push(closure);
return SQ_OK;
}
@ -1332,7 +1332,7 @@ SQRESULT sq_getcallee(HRABBITVM v)
{
if(v->_callsstacksize > 1)
{
v->Push(v->_callsstack[v->_callsstacksize - 2]._closure);
v->push(v->_callsstack[v->_callsstacksize - 2]._closure);
return SQ_OK;
}
return sq_throwerror(v,_SC("no closure in the calls stack"));
@ -1348,7 +1348,7 @@ const SQChar *sq_getfreevariable(HRABBITVM v,int64_t idx,uint64_t nval)
SQClosure *clo = _closure(self);
SQFunctionProto *fp = clo->_function;
if(((uint64_t)fp->_noutervalues) > nval) {
v->Push(*(_outer(clo->_outervalues[nval])->_valptr));
v->push(*(_outer(clo->_outervalues[nval])->_valptr));
SQOuterVar &ov = fp->_outervalues[nval];
name = _stringval(ov._name);
}
@ -1357,7 +1357,7 @@ const SQChar *sq_getfreevariable(HRABBITVM v,int64_t idx,uint64_t nval)
case OT_NATIVECLOSURE:{
SQNativeClosure *clo = _nativeclosure(self);
if(clo->_noutervalues > nval) {
v->Push(clo->_outervalues[nval]);
v->push(clo->_outervalues[nval]);
name = _SC("@NATIVE");
}
}
@ -1389,7 +1389,7 @@ SQRESULT sq_setfreevariable(HRABBITVM v,int64_t idx,uint64_t nval)
default:
return sq_aux_invalidtype(v, sq_type(self));
}
v->Pop();
v->pop();
return SQ_OK;
}
@ -1403,13 +1403,13 @@ SQRESULT sq_setattributes(HRABBITVM v,int64_t idx)
if(sq_type(key) == OT_NULL) {
attrs = _class(*o)->_attributes;
_class(*o)->_attributes = val;
v->Pop(2);
v->Push(attrs);
v->pop(2);
v->push(attrs);
return SQ_OK;
}else if(_class(*o)->getAttributes(key,attrs)) {
_class(*o)->setAttributes(key,val);
v->Pop(2);
v->Push(attrs);
v->pop(2);
v->push(attrs);
return SQ_OK;
}
return sq_throwerror(v,_SC("wrong index"));
@ -1423,13 +1423,13 @@ SQRESULT sq_getattributes(HRABBITVM v,int64_t idx)
SQObjectPtr attrs;
if(sq_type(key) == OT_NULL) {
attrs = _class(*o)->_attributes;
v->Pop();
v->Push(attrs);
v->pop();
v->push(attrs);
return SQ_OK;
}
else if(_class(*o)->getAttributes(key,attrs)) {
v->Pop();
v->Push(attrs);
v->pop();
v->push(attrs);
return SQ_OK;
}
return sq_throwerror(v,_SC("wrong index"));
@ -1445,7 +1445,7 @@ SQRESULT sq_getmemberhandle(HRABBITVM v,int64_t idx,HSQMEMBERHANDLE *handle)
if(m->get(key,val)) {
handle->_static = _isfield(val) ? SQFalse : SQTrue;
handle->_index = _member_idx(val);
v->Pop();
v->pop();
return SQ_OK;
}
return sq_throwerror(v,_SC("wrong index"));
@ -1489,7 +1489,7 @@ SQRESULT sq_getbyhandle(HRABBITVM v,int64_t idx,const HSQMEMBERHANDLE *handle)
if(SQ_FAILED(_getmemberbyhandle(v,self,handle,val))) {
return SQ_ERROR;
}
v->Push(_realval(*val));
v->push(_realval(*val));
return SQ_OK;
}
@ -1502,7 +1502,7 @@ SQRESULT sq_setbyhandle(HRABBITVM v,int64_t idx,const HSQMEMBERHANDLE *handle)
return SQ_ERROR;
}
*val = newval;
v->Pop();
v->pop();
return SQ_OK;
}
@ -1511,9 +1511,9 @@ SQRESULT sq_getbase(HRABBITVM v,int64_t idx)
SQObjectPtr *o = NULL;
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
if(_class(*o)->_base)
v->Push(SQObjectPtr(_class(*o)->_base));
v->push(SQObjectPtr(_class(*o)->_base));
else
v->PushNull();
v->pushNull();
return SQ_OK;
}
@ -1521,7 +1521,7 @@ SQRESULT sq_getclass(HRABBITVM v,int64_t idx)
{
SQObjectPtr *o = NULL;
_GETSAFE_OBJ(v, idx, OT_INSTANCE,o);
v->Push(SQObjectPtr(_instance(*o)->_class));
v->push(SQObjectPtr(_instance(*o)->_class));
return SQ_OK;
}
@ -1529,7 +1529,7 @@ SQRESULT sq_createinstance(HRABBITVM v,int64_t idx)
{
SQObjectPtr *o = NULL;
_GETSAFE_OBJ(v, idx, OT_CLASS,o);
v->Push(_class(*o)->createInstance());
v->push(_class(*o)->createInstance());
return SQ_OK;
}
@ -1537,10 +1537,10 @@ void sq_weakref(HRABBITVM v,int64_t idx)
{
SQObject &o=stack_get(v,idx);
if(ISREFCOUNTED(sq_type(o))) {
v->Push(_refcounted(o)->getWeakRef(sq_type(o)));
v->push(_refcounted(o)->getWeakRef(sq_type(o)));
return;
}
v->Push(o);
v->push(o);
}
SQRESULT sq_getweakrefval(HRABBITVM v,int64_t idx)
@ -1549,7 +1549,7 @@ SQRESULT sq_getweakrefval(HRABBITVM v,int64_t idx)
if(sq_type(o) != OT_WEAKREF) {
return sq_throwerror(v,_SC("the object must be a weakref"));
}
v->Push(_weakref(o)->_obj);
v->push(_weakref(o)->_obj);
return SQ_OK;
}
@ -1557,16 +1557,16 @@ SQRESULT sq_getdefaultdelegate(HRABBITVM v,SQObjectType t)
{
SQSharedState *ss = _ss(v);
switch(t) {
case OT_TABLE: v->Push(ss->_table_default_delegate); break;
case OT_ARRAY: v->Push(ss->_array_default_delegate); break;
case OT_STRING: v->Push(ss->_string_default_delegate); break;
case OT_INTEGER: case OT_FLOAT: v->Push(ss->_number_default_delegate); break;
case OT_GENERATOR: v->Push(ss->_generator_default_delegate); break;
case OT_CLOSURE: case OT_NATIVECLOSURE: v->Push(ss->_closure_default_delegate); break;
case OT_THREAD: v->Push(ss->_thread_default_delegate); break;
case OT_CLASS: v->Push(ss->_class_default_delegate); break;
case OT_INSTANCE: v->Push(ss->_instance_default_delegate); break;
case OT_WEAKREF: v->Push(ss->_weakref_default_delegate); break;
case OT_TABLE: v->push(ss->_table_default_delegate); break;
case OT_ARRAY: v->push(ss->_array_default_delegate); break;
case OT_STRING: v->push(ss->_string_default_delegate); break;
case OT_INTEGER: case OT_FLOAT: v->push(ss->_number_default_delegate); break;
case OT_GENERATOR: v->push(ss->_generator_default_delegate); break;
case OT_CLOSURE: case OT_NATIVECLOSURE: v->push(ss->_closure_default_delegate); break;
case OT_THREAD: v->push(ss->_thread_default_delegate); break;
case OT_CLASS: v->push(ss->_class_default_delegate); break;
case OT_INSTANCE: v->push(ss->_instance_default_delegate); break;
case OT_WEAKREF: v->push(ss->_weakref_default_delegate); break;
default: return sq_throwerror(v,_SC("the type doesn't have a default delegate"));
}
return SQ_OK;
@ -1582,8 +1582,8 @@ SQRESULT sq_next(HRABBITVM v,int64_t idx)
if(!v->FOREACH_OP(o,realkey,val,refpos,0,666,faketojump))
return SQ_ERROR;
if(faketojump != 666) {
v->Push(realkey);
v->Push(val);
v->push(realkey);
v->push(val);
return SQ_OK;
}
return SQ_ERROR;
@ -1613,7 +1613,7 @@ SQRESULT sq_compilebuffer(HRABBITVM v,const SQChar *s,int64_t size,const SQChar
void sq_move(HRABBITVM dest,HRABBITVM src,int64_t idx)
{
dest->Push(stack_get(src,idx));
dest->push(stack_get(src,idx));
}
void sq_setprintfunc(HRABBITVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc)

View File

@ -52,13 +52,13 @@ static int64_t base_dummy(HRABBITVM SQ_UNUSED_ARG(v))
static int64_t base_getroottable(HRABBITVM v)
{
v->Push(v->_roottable);
v->push(v->_roottable);
return 1;
}
static int64_t base_getconsttable(HRABBITVM v)
{
v->Push(_ss(v)->_consts);
v->push(_ss(v)->_consts);
return 1;
}
@ -67,7 +67,7 @@ static int64_t base_setroottable(HRABBITVM v)
{
SQObjectPtr o = v->_roottable;
if(SQ_FAILED(sq_setroottable(v))) return SQ_ERROR;
v->Push(o);
v->push(o);
return 1;
}
@ -75,7 +75,7 @@ static int64_t base_setconsttable(HRABBITVM v)
{
SQObjectPtr o = _ss(v)->_consts;
if(SQ_FAILED(sq_setconsttable(v))) return SQ_ERROR;
v->Push(o);
v->push(o);
return 1;
}
@ -250,14 +250,14 @@ static int64_t base_array(HRABBITVM v)
else {
a = rabbit::Array::create(_ss(v),tointeger(size));
}
v->Push(a);
v->push(a);
return 1;
}
static int64_t base_type(HRABBITVM v)
{
SQObjectPtr &o = stack_get(v,2);
v->Push(SQString::create(_ss(v),getTypeName(o),-1));
v->push(SQString::create(_ss(v),getTypeName(o),-1));
return 1;
}
@ -265,7 +265,7 @@ static int64_t base_callee(HRABBITVM v)
{
if(v->_callsstacksize > 1)
{
v->Push(v->_callsstack[v->_callsstacksize - 2]._closure);
v->push(v->_callsstack[v->_callsstacksize - 2]._closure);
return 1;
}
return sq_throwerror(v,_SC("no closure in the calls stack"));
@ -327,7 +327,7 @@ void sq_base_register(HRABBITVM v)
static int64_t default_delegate_len(HRABBITVM v)
{
v->Push(int64_t(sq_getsize(v,1)));
v->push(int64_t(sq_getsize(v,1)));
return 1;
}
@ -338,19 +338,19 @@ static int64_t default_delegate_tofloat(HRABBITVM v)
case OT_STRING:{
SQObjectPtr res;
if(str2num(_stringval(o),res,10)){
v->Push(SQObjectPtr(tofloat(res)));
v->push(SQObjectPtr(tofloat(res)));
break;
}}
return sq_throwerror(v, _SC("cannot convert the string"));
break;
case OT_INTEGER:case OT_FLOAT:
v->Push(SQObjectPtr(tofloat(o)));
v->push(SQObjectPtr(tofloat(o)));
break;
case OT_BOOL:
v->Push(SQObjectPtr((float_t)(_integer(o)?1:0)));
v->push(SQObjectPtr((float_t)(_integer(o)?1:0)));
break;
default:
v->PushNull();
v->pushNull();
break;
}
return 1;
@ -367,19 +367,19 @@ static int64_t default_delegate_tointeger(HRABBITVM v)
case OT_STRING:{
SQObjectPtr res;
if(str2num(_stringval(o),res,base)){
v->Push(SQObjectPtr(tointeger(res)));
v->push(SQObjectPtr(tointeger(res)));
break;
}}
return sq_throwerror(v, _SC("cannot convert the string"));
break;
case OT_INTEGER:case OT_FLOAT:
v->Push(SQObjectPtr(tointeger(o)));
v->push(SQObjectPtr(tointeger(o)));
break;
case OT_BOOL:
v->Push(SQObjectPtr(_integer(o)?(int64_t)1:(int64_t)0));
v->push(SQObjectPtr(_integer(o)?(int64_t)1:(int64_t)0));
break;
default:
v->PushNull();
v->pushNull();
break;
}
return 1;
@ -408,7 +408,7 @@ static int64_t number_delegate_tochar(HRABBITVM v)
{
SQObject &o=stack_get(v,1);
SQChar c = (SQChar)tointeger(o);
v->Push(SQString::create(_ss(v),(const SQChar *)&c,1));
v->push(SQString::create(_ss(v),(const SQChar *)&c,1));
return 1;
}
@ -470,19 +470,19 @@ static int64_t table_filter(HRABBITVM v)
while((nitr = tbl->next(false, itr, key, val)) != -1) {
itr = (int64_t)nitr;
v->Push(o);
v->Push(key);
v->Push(val);
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);
_table(ret)->newSlot(key, val);
}
v->Pop();
v->pop();
}
v->Push(ret);
v->push(ret);
return 1;
}
@ -530,7 +530,7 @@ static int64_t array_top(HRABBITVM v)
{
SQObject &o=stack_get(v,1);
if(_array(o)->size()>0){
v->Push(_array(o)->top());
v->push(_array(o)->top());
return 1;
}
else return sq_throwerror(v,_SC("top() on a empty array"));
@ -555,7 +555,7 @@ static int64_t array_remove(HRABBITVM v)
SQObjectPtr val;
if(_array(o)->get(tointeger(idx), val)) {
_array(o)->remove(tointeger(idx));
v->Push(val);
v->push(val);
return 1;
}
return sq_throwerror(v, _SC("idx out of range"));
@ -585,13 +585,13 @@ static int64_t __map_array(rabbit::Array *dest,rabbit::Array *src,HRABBITVM v) {
int64_t size = src->size();
for(int64_t n = 0; n < size; n++) {
src->get(n,temp);
v->Push(src);
v->Push(temp);
v->push(src);
v->push(temp);
if(SQ_FAILED(sq_call(v,2,SQTrue,SQFalse))) {
return SQ_ERROR;
}
dest->set(n,v->getUp(-1));
v->Pop();
v->pop();
}
return 0;
}
@ -603,7 +603,7 @@ static int64_t array_map(HRABBITVM v)
SQObjectPtr ret = rabbit::Array::create(_ss(v),size);
if(SQ_FAILED(__map_array(_array(ret),_array(o),v)))
return SQ_ERROR;
v->Push(ret);
v->push(ret);
return 1;
}
@ -630,17 +630,17 @@ static int64_t array_reduce(HRABBITVM v)
SQObjectPtr other;
for(int64_t n = 1; n < size; n++) {
a->get(n,other);
v->Push(o);
v->Push(res);
v->Push(other);
v->push(o);
v->push(res);
v->push(other);
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
return SQ_ERROR;
}
res = v->getUp(-1);
v->Pop();
v->pop();
}
}
v->Push(res);
v->push(res);
return 1;
}
@ -653,18 +653,18 @@ static int64_t array_filter(HRABBITVM v)
SQObjectPtr val;
for(int64_t n = 0; n < size; n++) {
a->get(n,val);
v->Push(o);
v->Push(n);
v->Push(val);
v->push(o);
v->push(n);
v->push(val);
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
return SQ_ERROR;
}
if(!SQVM::IsFalse(v->getUp(-1))) {
_array(ret)->append(val);
}
v->Pop();
v->pop();
}
v->Push(ret);
v->push(ret);
return 1;
}
@ -678,8 +678,8 @@ static int64_t array_find(HRABBITVM v)
for(int64_t n = 0; n < size; n++) {
bool res = false;
a->get(n,temp);
if(SQVM::IsEqual(temp,val,res) && res) {
v->Push(n);
if(SQVM::isEqual(temp,val,res) && res) {
v->push(n);
return 1;
}
}
@ -690,21 +690,21 @@ static int64_t array_find(HRABBITVM v)
static bool _sort_compare(HRABBITVM v,SQObjectPtr &a,SQObjectPtr &b,int64_t func,int64_t &ret)
{
if(func < 0) {
if(!v->ObjCmp(a,b,ret)) return false;
if(!v->objCmp(a,b,ret)) return false;
}
else {
int64_t top = sq_gettop(v);
sq_push(v, func);
sq_pushroottable(v);
v->Push(a);
v->Push(b);
v->push(a);
v->push(b);
if(SQ_FAILED(sq_call(v, 3, SQTrue, SQFalse))) {
if(!sq_isstring( v->_lasterror))
v->Raise_Error(_SC("compare func failed"));
v->raise_error(_SC("compare func failed"));
return false;
}
if(SQ_FAILED(sq_getinteger(v, -1, &ret))) {
v->Raise_Error(_SC("numeric value expected as return value of the compare function"));
v->raise_error(_SC("numeric value expected as return value of the compare function"));
return false;
}
sq_settop(v, top);
@ -739,7 +739,7 @@ static bool _hsort_sift_down(HRABBITVM v,rabbit::Array *arr, int64_t root, int64
return false;
if (ret < 0) {
if (root == maxChild) {
v->Raise_Error(_SC("inconsistent compare function"));
v->raise_error(_SC("inconsistent compare function"));
return false; // We'd be swapping ourselve. The compare function is incorrect
}
@ -801,7 +801,7 @@ static int64_t array_slice(HRABBITVM v)
_array(o)->get(i,t);
arr->set(count++,t);
}
v->Push(arr);
v->push(arr);
return 1;
}
@ -841,7 +841,7 @@ static int64_t string_slice(HRABBITVM v)
if(eidx < 0)eidx = slen + eidx;
if(eidx < sidx) return sq_throwerror(v,_SC("wrong indexes"));
if(eidx > slen || sidx < 0) return sq_throwerror(v, _SC("slice out of range"));
v->Push(SQString::create(_ss(v),&_stringval(o)[sidx],eidx-sidx));
v->push(SQString::create(_ss(v),&_stringval(o)[sidx],eidx-sidx));
return 1;
}
@ -878,7 +878,7 @@ static int64_t string_find(HRABBITVM v)
SQChar *snew=(_ss(v)->getScratchPad(sq_rsl(len))); \
memcpy(snew,sthis,sq_rsl(len));\
for(int64_t i=sidx;i<eidx;i++) snew[i] = func(sthis[i]); \
v->Push(SQString::create(_ss(v),snew,len)); \
v->push(SQString::create(_ss(v),snew,len)); \
return 1; \
}
@ -929,8 +929,8 @@ static int64_t _closure_acall(HRABBITVM v,SQBool raiseerror)
{
rabbit::Array *aparams=_array(stack_get(v,2));
int64_t nparams=aparams->size();
v->Push(stack_get(v,1));
for(int64_t i=0;i<nparams;i++)v->Push((*aparams)[i]);
v->push(stack_get(v,1));
for(int64_t i=0;i<nparams;i++)v->push((*aparams)[i]);
return SQ_SUCCEEDED(sq_call(v,nparams,SQTrue,raiseerror))?1:SQ_ERROR;
}
@ -982,18 +982,18 @@ static int64_t closure_getinfos(HRABBITVM v) {
if(f->_varparams) {
_array(params)->set(nparams-1,SQString::create(_ss(v),_SC("..."),-1));
}
res->NewSlot(SQString::create(_ss(v),_SC("native"),-1),false);
res->NewSlot(SQString::create(_ss(v),_SC("name"),-1),f->_name);
res->NewSlot(SQString::create(_ss(v),_SC("src"),-1),f->_sourcename);
res->NewSlot(SQString::create(_ss(v),_SC("parameters"),-1),params);
res->NewSlot(SQString::create(_ss(v),_SC("varargs"),-1),f->_varparams);
res->NewSlot(SQString::create(_ss(v),_SC("defparams"),-1),defparams);
res->newSlot(SQString::create(_ss(v),_SC("native"),-1),false);
res->newSlot(SQString::create(_ss(v),_SC("name"),-1),f->_name);
res->newSlot(SQString::create(_ss(v),_SC("src"),-1),f->_sourcename);
res->newSlot(SQString::create(_ss(v),_SC("parameters"),-1),params);
res->newSlot(SQString::create(_ss(v),_SC("varargs"),-1),f->_varparams);
res->newSlot(SQString::create(_ss(v),_SC("defparams"),-1),defparams);
}
else { //OT_NATIVECLOSURE
SQNativeClosure *nc = _nativeclosure(o);
res->NewSlot(SQString::create(_ss(v),_SC("native"),-1),true);
res->NewSlot(SQString::create(_ss(v),_SC("name"),-1),nc->_name);
res->NewSlot(SQString::create(_ss(v),_SC("paramscheck"),-1),nc->_nparamscheck);
res->newSlot(SQString::create(_ss(v),_SC("native"),-1),true);
res->newSlot(SQString::create(_ss(v),_SC("name"),-1),nc->_name);
res->newSlot(SQString::create(_ss(v),_SC("paramscheck"),-1),nc->_nparamscheck);
SQObjectPtr typecheck;
if(nc->_typecheck.size() > 0) {
typecheck =
@ -1002,9 +1002,9 @@ static int64_t closure_getinfos(HRABBITVM v) {
_array(typecheck)->set((int64_t)n,nc->_typecheck[n]);
}
}
res->NewSlot(SQString::create(_ss(v),_SC("typecheck"),-1),typecheck);
res->newSlot(SQString::create(_ss(v),_SC("typecheck"),-1),typecheck);
}
v->Push(res);
v->push(res);
return 1;
}
@ -1029,9 +1029,9 @@ static int64_t generator_getstatus(HRABBITVM v)
{
SQObject &o=stack_get(v,1);
switch(_generator(o)->_state){
case SQGenerator::eSuspended:v->Push(SQString::create(_ss(v),_SC("suspended")));break;
case SQGenerator::eRunning:v->Push(SQString::create(_ss(v),_SC("running")));break;
case SQGenerator::eDead:v->Push(SQString::create(_ss(v),_SC("dead")));break;
case SQGenerator::eSuspended:v->push(SQString::create(_ss(v),_SC("suspended")));break;
case SQGenerator::eRunning:v->push(SQString::create(_ss(v),_SC("running")));break;
case SQGenerator::eDead:v->push(SQString::create(_ss(v),_SC("dead")));break;
}
return 1;
}
@ -1049,7 +1049,7 @@ static int64_t thread_call(HRABBITVM v)
SQObjectPtr o = stack_get(v,1);
if(sq_type(o) == OT_THREAD) {
int64_t nparams = sq_gettop(v);
_thread(o)->Push(_thread(o)->_roottable);
_thread(o)->push(_thread(o)->_roottable);
for(int64_t i = 2; i<(nparams+1); i++)
sq_move(_thread(o),v,i);
if(SQ_SUCCEEDED(sq_call(_thread(o),nparams,SQTrue,SQTrue))) {

View File

@ -28,13 +28,13 @@ SQClass::SQClass(SQSharedState *ss,SQClass *base)
_defaultvalues.copy(base->_defaultvalues);
_methods.copy(base->_methods);
_COPY_VECTOR(_metamethods,base->_metamethods,MT_LAST);
__ObjAddRef(_base);
__ObjaddRef(_base);
}
_members = base?base->_members->clone() : SQTable::create(ss,0);
__ObjAddRef(_members);
__ObjaddRef(_members);
}
void SQClass::Finalize() {
void SQClass::finalize() {
_attributes.Null();
_NULL_SQOBJECT_VECTOR(_defaultvalues,_defaultvalues.size());
_methods.resize(0);
@ -47,10 +47,10 @@ void SQClass::Finalize() {
SQClass::~SQClass()
{
Finalize();
finalize();
}
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;
bool belongs_to_static_table = sq_type(val) == OT_CLOSURE || sq_type(val) == OT_NATIVECLOSURE || bstatic;
@ -72,17 +72,17 @@ bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr
if(_base && sq_type(val) == OT_CLOSURE) {
theval = _closure(val)->clone();
_closure(theval)->_base = _base;
__ObjAddRef(_base); //ref for the closure
__ObjaddRef(_base); //ref for the closure
}
if(sq_type(temp) == OT_NULL) {
bool isconstructor;
SQVM::IsEqual(ss->_constructoridx, key, isconstructor);
SQVM::isEqual(ss->_constructoridx, key, isconstructor);
if(isconstructor) {
_constructoridx = (int64_t)_methods.size();
}
SQClassMember m;
m.val = theval;
_members->NewSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));
_members->newSlot(key,SQObjectPtr(_make_method_idx(_methods.size())));
_methods.push_back(m);
}
else {
@ -93,14 +93,14 @@ bool SQClass::NewSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr
}
SQClassMember m;
m.val = val;
_members->NewSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));
_members->newSlot(key,SQObjectPtr(_make_field_idx(_defaultvalues.size())));
_defaultvalues.push_back(m);
return true;
}
SQInstance *SQClass::createInstance()
{
if(!_locked) Lock();
if(!_locked) lock();
return SQInstance::create(NULL,this);
}
@ -144,11 +144,11 @@ bool SQClass::getAttributes(const SQObjectPtr &key,SQObjectPtr &outval)
}
///////////////////////////////////////////////////////////////////////
void SQInstance::Init(SQSharedState *ss)
void SQInstance::init(SQSharedState *ss)
{
_userpointer = NULL;
_hook = NULL;
__ObjAddRef(_class);
__ObjaddRef(_class);
_delegate = _class->_members;
}
@ -160,7 +160,7 @@ SQInstance::SQInstance(SQSharedState *ss, SQClass *c, int64_t memsize)
for(uint64_t n = 0; n < nvalues; n++) {
new (&_values[n]) SQObjectPtr(_class->_defaultvalues[n].val);
}
Init(ss);
init(ss);
}
SQInstance::SQInstance(SQSharedState *ss, SQInstance *i, int64_t memsize)
@ -171,10 +171,10 @@ SQInstance::SQInstance(SQSharedState *ss, SQInstance *i, int64_t memsize)
for(uint64_t n = 0; n < nvalues; n++) {
new (&_values[n]) SQObjectPtr(i->_values[n]);
}
Init(ss);
init(ss);
}
void SQInstance::Finalize()
void SQInstance::finalize()
{
uint64_t nvalues = _class->_defaultvalues.size();
__Objrelease(_class);
@ -183,7 +183,7 @@ void SQInstance::Finalize()
SQInstance::~SQInstance()
{
if(_class){ Finalize(); } //if _class is null it was already finalized by the GC
if(_class){ finalize(); } //if _class is null it was already finalized by the GC
}
bool SQInstance::getMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res)
@ -195,7 +195,7 @@ bool SQInstance::getMetaMethod(SQVM* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPt
return false;
}
bool SQInstance::InstanceOf(SQClass *trg)
bool SQInstance::instanceOf(SQClass *trg)
{
SQClass *parent = _class;
while(parent != NULL) {

View File

@ -40,7 +40,7 @@ public:
return newclass;
}
~SQClass();
bool NewSlot(SQSharedState *ss, const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic);
bool newSlot(SQSharedState *ss, const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic);
bool get(const SQObjectPtr &key,SQObjectPtr &val) {
if(_members->get(key,val)) {
if(_isfield(val)) {
@ -64,12 +64,12 @@ public:
}
bool setAttributes(const SQObjectPtr &key,const SQObjectPtr &val);
bool getAttributes(const SQObjectPtr &key,SQObjectPtr &outval);
void Lock() { _locked = true; if(_base) _base->Lock(); }
void lock() { _locked = true; if(_base) _base->lock(); }
void release() {
if (_hook) { _hook(_typetag,0);}
sq_delete(this, SQClass);
}
void Finalize();
void finalize();
int64_t next(const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
SQInstance *createInstance();
SQTable *_members;
@ -90,7 +90,7 @@ public:
struct SQInstance : public SQDelegable
{
void Init(SQSharedState *ss);
void init(SQSharedState *ss);
SQInstance(SQSharedState *ss, SQClass *c, int64_t memsize);
SQInstance(SQSharedState *ss, SQInstance *c, int64_t memsize);
public:
@ -145,8 +145,8 @@ public:
this->~SQInstance();
SQ_FREE(this, size);
}
void Finalize();
bool InstanceOf(SQClass *trg);
void finalize();
bool instanceOf(SQClass *trg);
bool getMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res);
SQClass *_class;

View File

@ -16,7 +16,7 @@ struct SQClosure : public rabbit::RefCounted
private:
SQClosure(SQSharedState *ss,SQFunctionProto *func){
_function = func;
__ObjAddRef(_function); _base = NULL;
__ObjaddRef(_function); _base = NULL;
_env = NULL;
_root=NULL;
}
@ -28,7 +28,7 @@ public:
nc->_outervalues = (SQObjectPtr *)(nc + 1);
nc->_defaultparams = &nc->_outervalues[func->_noutervalues];
nc->_root = root;
__ObjAddRef(nc->_root);
__ObjaddRef(nc->_root);
_CONSTRUCT_VECTOR(SQObjectPtr,func->_noutervalues,nc->_outervalues);
_CONSTRUCT_VECTOR(SQObjectPtr,func->_ndefaultparams,nc->_defaultparams);
return nc;
@ -46,22 +46,22 @@ public:
{
__Objrelease(_root);
_root = r;
__ObjAddRef(_root);
__ObjaddRef(_root);
}
SQClosure *clone()
{
SQFunctionProto *f = _function;
SQClosure * ret = SQClosure::create(NULL,f,_root);
ret->_env = _env;
if(ret->_env) __ObjAddRef(ret->_env);
if(ret->_env) __ObjaddRef(ret->_env);
_COPY_VECTOR(ret->_outervalues,_outervalues,f->_noutervalues);
_COPY_VECTOR(ret->_defaultparams,_defaultparams,f->_ndefaultparams);
return ret;
}
~SQClosure();
bool Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
static bool Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
bool save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
static bool load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
rabbit::WeakRef *_env;
rabbit::WeakRef *_root;
SQClass *_base;
@ -123,7 +123,7 @@ public:
{
}
void Kill(){
void kill(){
_state=eDead;
_stack.resize(0);
_closure.Null();}
@ -131,11 +131,11 @@ public:
sq_delete(this,SQGenerator);
}
bool Yield(SQVM *v,int64_t target);
bool Resume(SQVM *v,SQObjectPtr &dest);
bool yield(SQVM *v,int64_t target);
bool resume(SQVM *v,SQObjectPtr &dest);
SQObjectPtr _closure;
SQObjectPtrVec _stack;
SQVM::CallInfo _ci;
SQVM::callInfo _ci;
ExceptionsTraps _etraps;
SQGeneratorState _state;
};
@ -164,7 +164,7 @@ public:
{
SQNativeClosure * ret = SQNativeClosure::create(NULL,_function,_noutervalues);
ret->_env = _env;
if(ret->_env) __ObjAddRef(ret->_env);
if(ret->_env) __ObjaddRef(ret->_env);
ret->_name = _name;
_COPY_VECTOR(ret->_outervalues,_outervalues,_noutervalues);
ret->_typecheck.copy(_typecheck);

File diff suppressed because it is too large Load Diff

View File

@ -79,5 +79,5 @@ struct SQVM;
typedef void(*CompilerErrorFunc)(void *ud, const SQChar *s);
bool Compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo);
typedef void(*compilererrorFunc)(void *ud, const SQChar *s);
bool compile(SQVM *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo);

View File

@ -17,7 +17,7 @@ SQRESULT sq_getfunctioninfo(HRABBITVM v,int64_t level,SQFunctionInfo *fi)
{
int64_t cssize = v->_callsstacksize;
if (cssize > level) {
SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
SQVM::callInfo &ci = v->_callsstack[cssize-level-1];
if(sq_isclosure(ci._closure)) {
SQClosure *c = _closure(ci._closure);
SQFunctionProto *proto = c->_function;
@ -36,7 +36,7 @@ SQRESULT sq_stackinfos(HRABBITVM v, int64_t level, SQStackInfos *si)
int64_t cssize = v->_callsstacksize;
if (cssize > level) {
memset(si, 0, sizeof(SQStackInfos));
SQVM::CallInfo &ci = v->_callsstack[cssize-level-1];
SQVM::callInfo &ci = v->_callsstack[cssize-level-1];
switch (sq_type(ci._closure)) {
case OT_CLOSURE:{
SQFunctionProto *func = _closure(ci._closure)->_function;
@ -61,7 +61,7 @@ SQRESULT sq_stackinfos(HRABBITVM v, int64_t level, SQStackInfos *si)
return SQ_ERROR;
}
void SQVM::Raise_Error(const SQChar *s, ...)
void SQVM::raise_error(const SQChar *s, ...)
{
va_list vl;
va_start(vl, s);
@ -71,12 +71,12 @@ void SQVM::Raise_Error(const SQChar *s, ...)
_lasterror = SQString::create(_ss(this),_spval,-1);
}
void SQVM::Raise_Error(const SQObjectPtr &desc)
void SQVM::raise_error(const SQObjectPtr &desc)
{
_lasterror = desc;
}
SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
SQString *SQVM::printObjVal(const SQObjectPtr &o)
{
switch(sq_type(o)) {
case OT_STRING: return _string(o);
@ -93,20 +93,20 @@ SQString *SQVM::PrintObjVal(const SQObjectPtr &o)
}
}
void SQVM::Raise_IdxError(const SQObjectPtr &o)
void SQVM::raise_Idxerror(const SQObjectPtr &o)
{
SQObjectPtr oval = PrintObjVal(o);
Raise_Error(_SC("the index '%.50s' does not exist"), _stringval(oval));
SQObjectPtr oval = printObjVal(o);
raise_error(_SC("the index '%.50s' does not exist"), _stringval(oval));
}
void SQVM::Raise_CompareError(const SQObject &o1, const SQObject &o2)
void SQVM::raise_Compareerror(const SQObject &o1, const SQObject &o2)
{
SQObjectPtr oval1 = PrintObjVal(o1), oval2 = PrintObjVal(o2);
Raise_Error(_SC("comparison between '%.50s' and '%.50s'"), _stringval(oval1), _stringval(oval2));
SQObjectPtr oval1 = printObjVal(o1), oval2 = printObjVal(o2);
raise_error(_SC("comparison between '%.50s' and '%.50s'"), _stringval(oval1), _stringval(oval2));
}
void SQVM::Raise_ParamTypeError(int64_t nparam,int64_t typemask,int64_t type)
void SQVM::raise_ParamTypeerror(int64_t nparam,int64_t typemask,int64_t type)
{
SQObjectPtr exptypes = SQString::create(_ss(this), _SC(""), -1);
int64_t found = 0;
@ -114,10 +114,10 @@ void SQVM::Raise_ParamTypeError(int64_t nparam,int64_t typemask,int64_t type)
{
int64_t mask = ((int64_t)1) << i;
if(typemask & (mask)) {
if(found>0) StringCat(exptypes,SQString::create(_ss(this), _SC("|"), -1), exptypes);
if(found>0) stringCat(exptypes,SQString::create(_ss(this), _SC("|"), -1), exptypes);
found ++;
StringCat(exptypes,SQString::create(_ss(this), IdType2Name((SQObjectType)mask), -1), exptypes);
stringCat(exptypes,SQString::create(_ss(this), IdType2Name((SQObjectType)mask), -1), exptypes);
}
}
Raise_Error(_SC("parameter %d has an invalid type '%s' ; expected: '%s'"), nparam, IdType2Name((SQObjectType)type), _stringval(exptypes));
raise_error(_SC("parameter %d has an invalid type '%s' ; expected: '%s'"), nparam, IdType2Name((SQObjectType)type), _stringval(exptypes));
}

View File

@ -118,8 +118,8 @@ public:
const SQChar* getLocal(SQVM *v,uint64_t stackbase,uint64_t nseq,uint64_t nop);
int64_t getLine(SQInstruction *curr);
bool Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
static bool Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
bool save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
static bool load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
SQObjectPtr _sourcename;
SQObjectPtr _name;
int64_t _stacksize;

View File

@ -80,7 +80,7 @@ SQInstructionDesc g_InstrDesc[]={
{_SC("_OP_CLOSE")},
};
#endif
void DumpLiteral(SQObjectPtr &o)
void dumpLiteral(SQObjectPtr &o)
{
switch(sq_type(o)){
case OT_STRING: scprintf(_SC("\"%s\""),_stringval(o));break;
@ -91,7 +91,7 @@ void DumpLiteral(SQObjectPtr &o)
}
}
SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed)
SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,compilererrorFunc efunc,void *ed)
{
_nliterals = 0;
_literals = SQTable::create(ss,0);
@ -112,13 +112,13 @@ SQFuncState::SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc
}
void SQFuncState::Error(const SQChar *err)
void SQFuncState::error(const SQChar *err)
{
_errfunc(_errtarget,err);
}
#ifdef _DEBUG_DUMP
void SQFuncState::Dump(SQFunctionProto *func)
void SQFuncState::dump(SQFunctionProto *func)
{
uint64_t n=0,i;
int64_t si;
@ -137,7 +137,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
}
for(i=0;i<templiterals.size();i++){
scprintf(_SC("[%d] "), (int32_t)n);
DumpLiteral(templiterals[i]);
dumpLiteral(templiterals[i]);
scprintf(_SC("\n"));
n++;
}
@ -147,7 +147,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
n=0;
for(i=0;i<_parameters.size();i++){
scprintf(_SC("[%d] "), (int32_t)n);
DumpLiteral(_parameters[i]);
dumpLiteral(_parameters[i]);
scprintf(_SC("\n"));
n++;
}
@ -179,7 +179,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
while(((refidx=_table(_literals)->next(false,refo,key,val))!= -1) && (_integer(val) != lidx)) {
refo = refidx;
}
DumpLiteral(key);
dumpLiteral(key);
}
if(inst.op != _OP_DLOAD) {
scprintf(_SC(" %d %d \n"),inst._arg2,inst._arg3);
@ -195,7 +195,7 @@ void SQFuncState::Dump(SQFunctionProto *func)
while(((refidx=_table(_literals)->next(false,refo,key,val))!= -1) && (_integer(val) != lidx)) {
refo = refidx;
}
DumpLiteral(key);
dumpLiteral(key);
scprintf(_SC("\n"));
}
}
@ -233,11 +233,11 @@ int64_t SQFuncState::getConstant(const SQObject &cons)
if(!_table(_literals)->get(cons,val))
{
val = _nliterals;
_table(_literals)->NewSlot(cons,val);
_table(_literals)->newSlot(cons,val);
_nliterals++;
if(_nliterals > MAX_LITERALS) {
val.Null();
Error(_SC("internal compiler error: too many literals"));
error(_SC("internal compiler error: too many literals"));
}
}
return _integer(val);
@ -261,24 +261,24 @@ void SQFuncState::setIntructionParam(int64_t pos,int64_t arg,int64_t val)
};
}
int64_t SQFuncState::AllocStackPos()
int64_t SQFuncState::allocStackPos()
{
int64_t npos=_vlocals.size();
_vlocals.push_back(SQLocalVarInfo());
if(_vlocals.size()>((uint64_t)_stacksize)) {
if(_stacksize>MAX_FUNC_STACKSIZE) Error(_SC("internal compiler error: too many locals"));
if(_stacksize>MAX_FUNC_STACKSIZE) error(_SC("internal compiler error: too many locals"));
_stacksize=_vlocals.size();
}
return npos;
}
int64_t SQFuncState::PushTarget(int64_t n)
int64_t SQFuncState::pushTarget(int64_t n)
{
if(n!=-1){
_targetstack.push_back(n);
return n;
}
n=AllocStackPos();
n=allocStackPos();
_targetstack.push_back(n);
return n;
}
@ -290,7 +290,7 @@ int64_t SQFuncState::getUpTarget(int64_t n){
int64_t SQFuncState::topTarget(){
return _targetstack.back();
}
int64_t SQFuncState::PopTarget()
int64_t SQFuncState::popTarget()
{
uint64_t npos=_targetstack.back();
assert(npos < _vlocals.size());
@ -338,7 +338,7 @@ void SQFuncState::setStacksize(int64_t n)
}
}
bool SQFuncState::IsConstant(const SQObject &name,SQObject &e)
bool SQFuncState::isConstant(const SQObject &name,SQObject &e)
{
SQObjectPtr val;
if(_table(_sharedstate->_consts)->get(name,val)) {
@ -348,14 +348,14 @@ bool SQFuncState::IsConstant(const SQObject &name,SQObject &e)
return false;
}
bool SQFuncState::IsLocal(uint64_t stkpos)
bool SQFuncState::isLocal(uint64_t stkpos)
{
if(stkpos>=_vlocals.size())return false;
else if(sq_type(_vlocals[stkpos]._name)!=OT_NULL)return true;
return false;
}
int64_t SQFuncState::PushLocalVariable(const SQObject &name)
int64_t SQFuncState::pushLocalVariable(const SQObject &name)
{
int64_t pos=_vlocals.size();
SQLocalVarInfo lvi;
@ -382,7 +382,7 @@ int64_t SQFuncState::getLocalVariable(const SQObject &name)
return -1;
}
void SQFuncState::MarkLocalAsOuter(int64_t pos)
void SQFuncState::markLocalAsOuter(int64_t pos)
{
SQLocalVarInfo &lvi = _vlocals[pos];
lvi._end_op = UINT_MINUS_ONE;
@ -407,7 +407,7 @@ int64_t SQFuncState::getOuterVariable(const SQObject &name)
}
}
else {
_parent->MarkLocalAsOuter(pos);
_parent->markLocalAsOuter(pos);
_outervalues.push_back(SQOuterVar(name,SQObjectPtr(int64_t(pos)),otLOCAL)); //local
return _outervalues.size() - 1;
@ -417,18 +417,18 @@ int64_t SQFuncState::getOuterVariable(const SQObject &name)
return -1;
}
void SQFuncState::AddParameter(const SQObject &name)
void SQFuncState::addParameter(const SQObject &name)
{
PushLocalVariable(name);
pushLocalVariable(name);
_parameters.push_back(name);
}
void SQFuncState::AddLineInfos(int64_t line,bool lineop,bool force)
void SQFuncState::addLineInfos(int64_t line,bool lineop,bool force)
{
if(_lastline!=line || force){
SQLineInfo li;
li._line=line;li._op=(getCurrentPos()+1);
if(lineop)AddInstruction(_OP_LINE,0,line);
if(lineop)addInstruction(_OP_LINE,0,line);
if(_lastline!=line) {
_lineinfos.push_back(li);
}
@ -436,9 +436,9 @@ void SQFuncState::AddLineInfos(int64_t line,bool lineop,bool force)
}
}
void SQFuncState::DiscardTarget()
void SQFuncState::discardTarget()
{
int64_t discardedtarget = PopTarget();
int64_t discardedtarget = popTarget();
int64_t size = _instructions.size();
if(size > 0 && _optimization){
SQInstruction &pi = _instructions[size-1];//previous instruction
@ -451,7 +451,7 @@ void SQFuncState::DiscardTarget()
}
}
void SQFuncState::AddInstruction(SQInstruction &i)
void SQFuncState::addInstruction(SQInstruction &i)
{
int64_t size = _instructions.size();
if(size > 0 && _optimization){ //simple optimizer
@ -485,7 +485,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
}
break;
case _OP_GET:
if( pi.op == _OP_LOAD && pi._arg0 == i._arg2 && (!IsLocal(pi._arg0))){
if( pi.op == _OP_LOAD && pi._arg0 == i._arg2 && (!isLocal(pi._arg0))){
pi._arg1 = pi._arg1;
pi._arg2 = (unsigned char)i._arg1;
pi.op = _OP_GETK;
@ -495,7 +495,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
}
break;
case _OP_PREPCALL:
if( pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
if( pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!isLocal(pi._arg0))){
pi.op = _OP_PREPCALLK;
pi._arg0 = i._arg0;
pi._arg1 = pi._arg1;
@ -513,7 +513,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
case _OP_LOADFLOAT: aat = AAT_FLOAT; break;
default: break;
}
if(aat != -1 && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0))){
if(aat != -1 && pi._arg0 == i._arg1 && (!isLocal(pi._arg0))){
pi.op = _OP_APPENDARRAY;
pi._arg0 = i._arg0;
pi._arg1 = pi._arg1;
@ -554,7 +554,7 @@ void SQFuncState::AddInstruction(SQInstruction &i)
}
break;
case _OP_EQ:case _OP_NE:
if(pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!IsLocal(pi._arg0) ))
if(pi.op == _OP_LOAD && pi._arg0 == i._arg1 && (!isLocal(pi._arg0) ))
{
pi.op = i.op;
pi._arg0 = i._arg0;
@ -587,18 +587,18 @@ void SQFuncState::AddInstruction(SQInstruction &i)
SQObject SQFuncState::createString(const SQChar *s,int64_t len)
{
SQObjectPtr ns(SQString::create(_sharedstate,s,len));
_table(_strings)->NewSlot(ns,(int64_t)1);
_table(_strings)->newSlot(ns,(int64_t)1);
return ns;
}
SQObject SQFuncState::createTable()
{
SQObjectPtr nt(SQTable::create(_sharedstate,0));
_table(_strings)->NewSlot(nt,(int64_t)1);
_table(_strings)->newSlot(nt,(int64_t)1);
return nt;
}
SQFunctionProto *SQFuncState::BuildProto()
SQFunctionProto *SQFuncState::buildProto()
{
SQFunctionProto *f=SQFunctionProto::create(_ss,_instructions.size(),
@ -632,7 +632,7 @@ SQFunctionProto *SQFuncState::BuildProto()
return f;
}
SQFuncState *SQFuncState::PushChildState(SQSharedState *ss)
SQFuncState *SQFuncState::pushChildState(SQSharedState *ss)
{
SQFuncState *child = (SQFuncState *)sq_malloc(sizeof(SQFuncState));
new (child) SQFuncState(ss,this,_errfunc,_errtarget);
@ -640,7 +640,7 @@ SQFuncState *SQFuncState::PushChildState(SQSharedState *ss)
return child;
}
void SQFuncState::PopChildState()
void SQFuncState::popChildState()
{
SQFuncState *child = _childstates.back();
sq_delete(child,SQFuncState);
@ -651,7 +651,7 @@ SQFuncState::~SQFuncState()
{
while(_childstates.size() > 0)
{
PopChildState();
popChildState();
}
}

View File

@ -11,49 +11,49 @@
struct SQFuncState
{
SQFuncState(SQSharedState *ss,SQFuncState *parent,CompilerErrorFunc efunc,void *ed);
SQFuncState(SQSharedState *ss,SQFuncState *parent,compilererrorFunc efunc,void *ed);
~SQFuncState();
#ifdef _DEBUG_DUMP
void Dump(SQFunctionProto *func);
void dump(SQFunctionProto *func);
#endif
void Error(const SQChar *err);
SQFuncState *PushChildState(SQSharedState *ss);
void PopChildState();
void AddInstruction(SQOpcode _op,int64_t arg0=0,int64_t arg1=0,int64_t arg2=0,int64_t arg3=0){SQInstruction i(_op,arg0,arg1,arg2,arg3);AddInstruction(i);}
void AddInstruction(SQInstruction &i);
void error(const SQChar *err);
SQFuncState *pushChildState(SQSharedState *ss);
void popChildState();
void addInstruction(SQOpcode _op,int64_t arg0=0,int64_t arg1=0,int64_t arg2=0,int64_t arg3=0){SQInstruction i(_op,arg0,arg1,arg2,arg3);addInstruction(i);}
void addInstruction(SQInstruction &i);
void setIntructionParams(int64_t pos,int64_t arg0,int64_t arg1,int64_t arg2=0,int64_t arg3=0);
void setIntructionParam(int64_t pos,int64_t arg,int64_t val);
SQInstruction &getInstruction(int64_t pos){return _instructions[pos];}
void PopInstructions(int64_t size){for(int64_t i=0;i<size;i++)_instructions.pop_back();}
void popInstructions(int64_t size){for(int64_t i=0;i<size;i++)_instructions.pop_back();}
void setStacksize(int64_t n);
int64_t CountOuters(int64_t stacksize);
void SnoozeOpt(){_optimization=false;}
void AddDefaultParam(int64_t trg) { _defaultparams.push_back(trg); }
void snoozeOpt(){_optimization=false;}
void addDefaultParam(int64_t trg) { _defaultparams.push_back(trg); }
int64_t getDefaultParamCount() { return _defaultparams.size(); }
int64_t getCurrentPos(){return _instructions.size()-1;}
int64_t getNumericConstant(const int64_t cons);
int64_t getNumericConstant(const float_t cons);
int64_t PushLocalVariable(const SQObject &name);
void AddParameter(const SQObject &name);
//void AddOuterValue(const SQObject &name);
int64_t pushLocalVariable(const SQObject &name);
void addParameter(const SQObject &name);
//void addOuterValue(const SQObject &name);
int64_t getLocalVariable(const SQObject &name);
void MarkLocalAsOuter(int64_t pos);
void markLocalAsOuter(int64_t pos);
int64_t getOuterVariable(const SQObject &name);
int64_t GenerateCode();
int64_t generateCode();
int64_t getStacksize();
int64_t CalcStackFramesize();
void AddLineInfos(int64_t line,bool lineop,bool force=false);
SQFunctionProto *BuildProto();
int64_t AllocStackPos();
int64_t PushTarget(int64_t n=-1);
int64_t PopTarget();
int64_t calcStackFramesize();
void addLineInfos(int64_t line,bool lineop,bool force=false);
SQFunctionProto *buildProto();
int64_t allocStackPos();
int64_t pushTarget(int64_t n=-1);
int64_t popTarget();
int64_t topTarget();
int64_t getUpTarget(int64_t n);
void DiscardTarget();
bool IsLocal(uint64_t stkpos);
void discardTarget();
bool isLocal(uint64_t stkpos);
SQObject createString(const SQChar *s,int64_t len = -1);
SQObject createTable();
bool IsConstant(const SQObject &name,SQObject &e);
bool isConstant(const SQObject &name,SQObject &e);
int64_t _returnexp;
SQLocalVarInfoVec _vlocals;
SQIntVec _targetstack;
@ -86,7 +86,7 @@ struct SQFuncState
sqvector<SQFuncState*> _childstates;
int64_t getConstant(const SQObject &cons);
private:
CompilerErrorFunc _errfunc;
compilererrorFunc _errfunc;
void *_errtarget;
SQSharedState *_ss;
};

View File

@ -21,7 +21,7 @@
#define INIT_TEMP_STRING() { _longstr.resize(0);}
#define APPEND_CHAR(c) { _longstr.push_back(c);}
#define TERMINATE_BUFFER() {_longstr.push_back(_SC('\0'));}
#define ADD_KEYWORD(key,id) _keywords->NewSlot( SQString::create(ss, _SC(#key)) ,int64_t(id))
#define ADD_KEYWORD(key,id) _keywords->newSlot( SQString::create(ss, _SC(#key)) ,int64_t(id))
SQLexer::SQLexer(){}
SQLexer::~SQLexer()
@ -29,7 +29,7 @@ SQLexer::~SQLexer()
_keywords->release();
}
void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,CompilerErrorFunc efunc,void *ed)
void SQLexer::init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,compilererrorFunc efunc,void *ed)
{
_errfunc = efunc;
_errtarget = ed;
@ -84,7 +84,7 @@ void SQLexer::Init(SQSharedState *ss, SQLEXREADFUNC rg, SQUserPointer up,Compile
next();
}
void SQLexer::Error(const SQChar *err)
void SQLexer::error(const SQChar *err)
{
_errfunc(_errtarget,err);
}
@ -92,7 +92,7 @@ void SQLexer::Error(const SQChar *err)
void SQLexer::next()
{
int64_t t = _readf(_up);
if(t > MAX_CHAR) Error(_SC("Invalid character"));
if(t > MAX_CHAR) error(_SC("Invalid character"));
if(t != 0) {
_currdata = (LexChar)t;
return;
@ -101,7 +101,7 @@ void SQLexer::next()
_reached_eof = SQTrue;
}
const SQChar *SQLexer::Tok2Str(int64_t tok)
const SQChar *SQLexer::tok2Str(int64_t tok)
{
SQObjectPtr itr, key, val;
int64_t nitr;
@ -113,19 +113,19 @@ const SQChar *SQLexer::Tok2Str(int64_t tok)
return NULL;
}
void SQLexer::LexBlockComment()
void SQLexer::lexBlockComment()
{
bool done = false;
while(!done) {
switch(CUR_CHAR) {
case _SC('*'): { NEXT(); if(CUR_CHAR == _SC('/')) { done = true; NEXT(); }}; continue;
case _SC('\n'): _currentline++; NEXT(); continue;
case RABBIT_EOB: Error(_SC("missing \"*/\" in comment"));
case RABBIT_EOB: error(_SC("missing \"*/\" in comment"));
default: NEXT();
}
}
}
void SQLexer::LexLineComment()
void SQLexer::lexLineComment()
{
do { NEXT(); } while (CUR_CHAR != _SC('\n') && (!IS_EOB()));
}
@ -143,16 +143,16 @@ int64_t SQLexer::Lex()
NEXT();
_currentcolumn=1;
continue;
case _SC('#'): LexLineComment(); continue;
case _SC('#'): lexLineComment(); continue;
case _SC('/'):
NEXT();
switch(CUR_CHAR){
case _SC('*'):
NEXT();
LexBlockComment();
lexBlockComment();
continue;
case _SC('/'):
LexLineComment();
lexLineComment();
continue;
case _SC('='):
NEXT();
@ -207,18 +207,18 @@ int64_t SQLexer::Lex()
if(CUR_CHAR != _SC('"')) {
RETURN_TOKEN('@');
}
if((stype=ReadString('"',true))!=-1) {
if((stype=readString('"',true))!=-1) {
RETURN_TOKEN(stype);
}
Error(_SC("error parsing the string"));
error(_SC("error parsing the string"));
}
case _SC('"'):
case _SC('\''): {
int64_t stype;
if((stype=ReadString(CUR_CHAR,false))!=-1){
if((stype=readString(CUR_CHAR,false))!=-1){
RETURN_TOKEN(stype);
}
Error(_SC("error parsing the string"));
error(_SC("error parsing the string"));
}
case _SC('{'): case _SC('}'): case _SC('('): case _SC(')'): case _SC('['): case _SC(']'):
case _SC(';'): case _SC(','): case _SC('?'): case _SC('^'): case _SC('~'):
@ -228,7 +228,7 @@ int64_t SQLexer::Lex()
NEXT();
if (CUR_CHAR != _SC('.')){ RETURN_TOKEN('.') }
NEXT();
if (CUR_CHAR != _SC('.')){ Error(_SC("invalid token '..'")); }
if (CUR_CHAR != _SC('.')){ error(_SC("invalid token '..'")); }
NEXT();
RETURN_TOKEN(TK_VARPARAMS);
case _SC('&'):
@ -265,16 +265,16 @@ int64_t SQLexer::Lex()
return 0;
default:{
if (scisdigit(CUR_CHAR)) {
int64_t ret = ReadNumber();
int64_t ret = readNumber();
RETURN_TOKEN(ret);
}
else if (scisalpha(CUR_CHAR) || CUR_CHAR == _SC('_')) {
int64_t t = ReadID();
int64_t t = readId();
RETURN_TOKEN(t);
}
else {
int64_t c = CUR_CHAR;
if (sciscntrl((int)c)) Error(_SC("unexpected character(control)"));
if (sciscntrl((int)c)) error(_SC("unexpected character(control)"));
NEXT();
RETURN_TOKEN(c);
}
@ -296,7 +296,7 @@ int64_t SQLexer::getIDType(const SQChar *s,int64_t len)
#ifdef SQUNICODE
#if WCHAR_SIZE == 2
int64_t SQLexer::AddUTF16(uint64_t ch)
int64_t SQLexer::addUTF16(uint64_t ch)
{
if (ch >= 0x10000)
{
@ -312,7 +312,7 @@ int64_t SQLexer::AddUTF16(uint64_t ch)
}
#endif
#else
int64_t SQLexer::AddUTF8(uint64_t ch)
int64_t SQLexer::addUTF8(uint64_t ch)
{
if (ch < 0x80) {
APPEND_CHAR((char)ch);
@ -340,10 +340,10 @@ int64_t SQLexer::AddUTF8(uint64_t ch)
}
#endif
int64_t SQLexer::ProcessStringHexEscape(SQChar *dest, int64_t maxdigits)
int64_t SQLexer::processStringHexEscape(SQChar *dest, int64_t maxdigits)
{
NEXT();
if (!isxdigit(CUR_CHAR)) Error(_SC("hexadecimal number expected"));
if (!isxdigit(CUR_CHAR)) error(_SC("hexadecimal number expected"));
int64_t n = 0;
while (isxdigit(CUR_CHAR) && n < maxdigits) {
dest[n] = CUR_CHAR;
@ -354,7 +354,7 @@ int64_t SQLexer::ProcessStringHexEscape(SQChar *dest, int64_t maxdigits)
return n;
}
int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
int64_t SQLexer::readString(int64_t ndelim,bool verbatim)
{
INIT_TEMP_STRING();
NEXT();
@ -364,10 +364,10 @@ int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
int64_t x = CUR_CHAR;
switch (x) {
case RABBIT_EOB:
Error(_SC("unfinished string"));
error(_SC("unfinished string"));
return -1;
case _SC('\n'):
if(!verbatim) Error(_SC("newline in a constant"));
if(!verbatim) error(_SC("newline in a constant"));
APPEND_CHAR(CUR_CHAR); NEXT();
_currentline++;
break;
@ -381,7 +381,7 @@ int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
case _SC('x'): {
const int64_t maxdigits = sizeof(SQChar) * 2;
SQChar temp[maxdigits + 1];
ProcessStringHexEscape(temp, maxdigits);
processStringHexEscape(temp, maxdigits);
SQChar *stemp;
APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16));
}
@ -390,16 +390,16 @@ int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
case _SC('u'): {
const int64_t maxdigits = CUR_CHAR == 'u' ? 4 : 8;
SQChar temp[8 + 1];
ProcessStringHexEscape(temp, maxdigits);
processStringHexEscape(temp, maxdigits);
SQChar *stemp;
#ifdef SQUNICODE
#if WCHAR_SIZE == 2
AddUTF16(scstrtoul(temp, &stemp, 16));
addUTF16(scstrtoul(temp, &stemp, 16));
#else
APPEND_CHAR((SQChar)scstrtoul(temp, &stemp, 16));
#endif
#else
AddUTF8(scstrtoul(temp, &stemp, 16));
addUTF8(scstrtoul(temp, &stemp, 16));
#endif
}
break;
@ -415,7 +415,7 @@ int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
case _SC('"'): APPEND_CHAR(_SC('"')); NEXT(); break;
case _SC('\''): APPEND_CHAR(_SC('\'')); NEXT(); break;
default:
Error(_SC("unrecognised escaper char"));
error(_SC("unrecognised escaper char"));
break;
}
}
@ -437,8 +437,8 @@ int64_t SQLexer::ReadString(int64_t ndelim,bool verbatim)
TERMINATE_BUFFER();
int64_t len = _longstr.size()-1;
if(ndelim == _SC('\'')) {
if(len == 0) Error(_SC("empty constant"));
if(len > 1) Error(_SC("constant too long"));
if(len == 0) error(_SC("empty constant"));
if(len > 1) error(_SC("constant too long"));
_nvalue = _longstr[0];
return TK_INTEGER;
}
@ -482,7 +482,7 @@ int64_t isexponent(int64_t c) { return c == 'e' || c=='E'; }
#define MAX_HEX_DIGITS (sizeof(int64_t)*2)
int64_t SQLexer::ReadNumber()
int64_t SQLexer::readNumber()
{
#define TINT 1
#define TFLOAT 2
@ -500,7 +500,7 @@ int64_t SQLexer::ReadNumber()
APPEND_CHAR(CUR_CHAR);
NEXT();
}
if(scisdigit(CUR_CHAR)) Error(_SC("invalid octal number"));
if(scisdigit(CUR_CHAR)) error(_SC("invalid octal number"));
}
else {
NEXT();
@ -509,7 +509,7 @@ int64_t SQLexer::ReadNumber()
APPEND_CHAR(CUR_CHAR);
NEXT();
}
if(_longstr.size() > MAX_HEX_DIGITS) Error(_SC("too many digits for an Hex number"));
if(_longstr.size() > MAX_HEX_DIGITS) error(_SC("too many digits for an Hex number"));
}
}
else {
@ -517,7 +517,7 @@ int64_t SQLexer::ReadNumber()
while (CUR_CHAR == _SC('.') || scisdigit(CUR_CHAR) || isexponent(CUR_CHAR)) {
if(CUR_CHAR == _SC('.') || isexponent(CUR_CHAR)) type = TFLOAT;
if(isexponent(CUR_CHAR)) {
if(type != TFLOAT) Error(_SC("invalid numeric format"));
if(type != TFLOAT) error(_SC("invalid numeric format"));
type = TSCIENTIFIC;
APPEND_CHAR(CUR_CHAR);
NEXT();
@ -525,7 +525,7 @@ int64_t SQLexer::ReadNumber()
APPEND_CHAR(CUR_CHAR);
NEXT();
}
if(!scisdigit(CUR_CHAR)) Error(_SC("exponent expected"));
if(!scisdigit(CUR_CHAR)) error(_SC("exponent expected"));
}
APPEND_CHAR(CUR_CHAR);
@ -551,7 +551,7 @@ int64_t SQLexer::ReadNumber()
return 0;
}
int64_t SQLexer::ReadID()
int64_t SQLexer::readId()
{
int64_t res;
INIT_TEMP_STRING();

View File

@ -17,26 +17,26 @@ struct SQLexer
{
SQLexer();
~SQLexer();
void Init(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up,CompilerErrorFunc efunc,void *ed);
void Error(const SQChar *err);
void init(SQSharedState *ss,SQLEXREADFUNC rg,SQUserPointer up,compilererrorFunc efunc,void *ed);
void error(const SQChar *err);
int64_t Lex();
const SQChar *Tok2Str(int64_t tok);
const SQChar *tok2Str(int64_t tok);
private:
int64_t getIDType(const SQChar *s,int64_t len);
int64_t ReadString(int64_t ndelim,bool verbatim);
int64_t ReadNumber();
void LexBlockComment();
void LexLineComment();
int64_t ReadID();
int64_t readString(int64_t ndelim,bool verbatim);
int64_t readNumber();
void lexBlockComment();
void lexLineComment();
int64_t readId();
void next();
#ifdef SQUNICODE
#if WCHAR_SIZE == 2
int64_t AddUTF16(uint64_t ch);
int64_t addUTF16(uint64_t ch);
#endif
#else
int64_t AddUTF8(uint64_t ch);
int64_t addUTF8(uint64_t ch);
#endif
int64_t ProcessStringHexEscape(SQChar *dest, int64_t maxdigits);
int64_t processStringHexEscape(SQChar *dest, int64_t maxdigits);
int64_t _curtoken;
SQTable *_keywords;
SQBool _reached_eof;
@ -53,7 +53,7 @@ public:
LexChar _currdata;
SQSharedState *_sharedstate;
sqvector<SQChar> _longstr;
CompilerErrorFunc _errfunc;
compilererrorFunc _errfunc;
void *_errtarget;
};

View File

@ -103,16 +103,16 @@ bool SQDelegable::setDelegate(SQTable *mt)
if (temp->_delegate == this) return false; //cycle detected
temp = temp->_delegate;
}
if (mt) __ObjAddRef(mt);
if (mt) __ObjaddRef(mt);
__Objrelease(_delegate);
_delegate = mt;
return true;
}
bool SQGenerator::Yield(SQVM *v,int64_t target)
bool SQGenerator::yield(SQVM *v,int64_t target)
{
if(_state==eSuspended) { v->Raise_Error(_SC("internal vm error, yielding dead generator")); return false;}
if(_state==eDead) { v->Raise_Error(_SC("internal vm error, yielding a dead generator")); return false; }
if(_state==eSuspended) { v->raise_error(_SC("internal vm error, yielding dead generator")); return false;}
if(_state==eDead) { v->raise_error(_SC("internal vm error, yielding a dead generator")); return false; }
int64_t size = v->_top-v->_stackbase;
_stack.resize(size);
@ -140,15 +140,15 @@ bool SQGenerator::Yield(SQVM *v,int64_t target)
return true;
}
bool SQGenerator::Resume(SQVM *v,SQObjectPtr &dest)
bool SQGenerator::resume(SQVM *v,SQObjectPtr &dest)
{
if(_state==eDead){ v->Raise_Error(_SC("resuming dead generator")); return false; }
if(_state==eRunning){ v->Raise_Error(_SC("resuming active generator")); return false; }
if(_state==eDead){ v->raise_error(_SC("resuming dead generator")); return false; }
if(_state==eRunning){ v->raise_error(_SC("resuming active generator")); return false; }
int64_t size = _stack.size();
int64_t target = &dest - &(v->_stack._vals[v->_stackbase]);
assert(target>=0 && target<=255);
int64_t newbase = v->_top;
if(!v->EnterFrame(v->_top, v->_top + size, false))
if(!v->enterFrame(v->_top, v->_top + size, false))
return false;
v->ci->_generator = this;
v->ci->_target = (int32_t)target;
@ -178,7 +178,7 @@ bool SQGenerator::Resume(SQVM *v,SQObjectPtr &dest)
_state=eRunning;
if (v->_debughook)
v->CallDebugHook(_SC('c'));
v->callDebugHook(_SC('c'));
return true;
}
@ -199,7 +199,7 @@ const SQChar* SQFunctionProto::getLocal(SQVM *vm,uint64_t stackbase,uint64_t nse
if(_localvarinfos[i]._start_op<=nop && _localvarinfos[i]._end_op>=nop)
{
if(nseq==0){
vm->Push(vm->_stack[stackbase+_localvarinfos[i]._pos]);
vm->push(vm->_stack[stackbase+_localvarinfos[i]._pos]);
res=_stringval(_localvarinfos[i]._name);
break;
}
@ -256,7 +256,7 @@ SQClosure::~SQClosure()
bool SafeWrite(HRABBITVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest,int64_t size)
{
if(write(up,dest,size) != size) {
v->Raise_Error(_SC("io error (write function failure)"));
v->raise_error(_SC("io error (write function failure)"));
return false;
}
return true;
@ -265,7 +265,7 @@ bool SafeWrite(HRABBITVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest
bool SafeRead(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,int64_t 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"));
return false;
}
return true;
@ -281,7 +281,7 @@ bool CheckTag(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,uint32_t tag)
uint32_t t;
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
if(t != tag){
v->Raise_Error(_SC("invalid or corrupted closure stream"));
v->raise_error(_SC("invalid or corrupted closure stream"));
return false;
}
return true;
@ -304,7 +304,7 @@ bool WriteObject(HRABBITVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
case OT_NULL:
break;
default:
v->Raise_Error(_SC("cannot serialize a %s"),getTypeName(o));
v->raise_error(_SC("cannot serialize a %s"),getTypeName(o));
return false;
}
return true;
@ -339,31 +339,31 @@ bool ReadObject(HRABBITVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
o.Null();
break;
default:
v->Raise_Error(_SC("cannot serialize a %s"),IdType2Name(t));
v->raise_error(_SC("cannot serialize a %s"),IdType2Name(t));
return false;
}
return true;
}
bool SQClosure::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
bool SQClosure::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
{
_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_HEAD));
_CHECK_IO(WriteTag(v,write,up,sizeof(SQChar)));
_CHECK_IO(WriteTag(v,write,up,sizeof(int64_t)));
_CHECK_IO(WriteTag(v,write,up,sizeof(float_t)));
_CHECK_IO(_function->Save(v,up,write));
_CHECK_IO(_function->save(v,up,write));
_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_TAIL));
return true;
}
bool SQClosure::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
bool SQClosure::load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
{
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_HEAD));
_CHECK_IO(CheckTag(v,read,up,sizeof(SQChar)));
_CHECK_IO(CheckTag(v,read,up,sizeof(int64_t)));
_CHECK_IO(CheckTag(v,read,up,sizeof(float_t)));
SQObjectPtr func;
_CHECK_IO(SQFunctionProto::Load(v,up,read,func));
_CHECK_IO(SQFunctionProto::load(v,up,read,func));
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_TAIL));
ret = SQClosure::create(_ss(v),_funcproto(func),_table(v->_roottable)->getWeakRef(OT_TABLE));
//FIXME: load an root for this closure
@ -380,7 +380,7 @@ SQFunctionProto::~SQFunctionProto()
{
}
bool SQFunctionProto::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
bool SQFunctionProto::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
{
int64_t i,nliterals = _nliterals,nparameters = _nparameters;
int64_t noutervalues = _noutervalues,nlocalvarinfos = _nlocalvarinfos;
@ -435,7 +435,7 @@ bool SQFunctionProto::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_PART));
for(i=0;i<nfunctions;i++){
_CHECK_IO(_funcproto(_functions[i])->Save(v,up,write));
_CHECK_IO(_funcproto(_functions[i])->save(v,up,write));
}
_CHECK_IO(SafeWrite(v,write,up,&_stacksize,sizeof(_stacksize)));
_CHECK_IO(SafeWrite(v,write,up,&_bgenerator,sizeof(_bgenerator)));
@ -443,7 +443,7 @@ bool SQFunctionProto::Save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
return true;
}
bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
bool SQFunctionProto::load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
{
int64_t i, nliterals,nparameters;
int64_t noutervalues ,nlocalvarinfos ;
@ -514,7 +514,7 @@ bool SQFunctionProto::Load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_PART));
for(i = 0; i < nfunctions; i++){
_CHECK_IO(_funcproto(o)->Load(v, up, read, o));
_CHECK_IO(_funcproto(o)->load(v, up, read, o));
f->_functions[i] = o;
}
_CHECK_IO(SafeRead(v,read,up, &f->_stacksize, sizeof(f->_stacksize)));

View File

@ -96,7 +96,7 @@ enum SQMetaMethod{
struct SQObjectPtr;
#define __AddRef(type,unval) if(ISREFCOUNTED(type)) \
#define __addRef(type,unval) if(ISREFCOUNTED(type)) \
{ \
unval.pRefCounted->refCountIncrement(); \
}
@ -116,7 +116,7 @@ struct SQObjectPtr;
} \
}
#define __ObjAddRef(obj) { \
#define __ObjaddRef(obj) { \
(obj)->refCountIncrement(); \
}
@ -206,13 +206,13 @@ struct SQObjectPtr : public SQObject
{
_type = o._type;
_unVal = o._unVal;
__AddRef(_type,_unVal);
__addRef(_type,_unVal);
}
SQObjectPtr(const SQObject &o)
{
_type = o._type;
_unVal = o._unVal;
__AddRef(_type,_unVal);
__addRef(_type,_unVal);
}
_REF_TYPE_DECL(OT_TABLE,SQTable,pTable)
_REF_TYPE_DECL(OT_CLASS,SQClass,pClass)
@ -260,7 +260,7 @@ struct SQObjectPtr : public SQObject
unOldVal=_unVal;
_unVal = obj._unVal;
_type = obj._type;
__AddRef(_type,_unVal);
__addRef(_type,_unVal);
__release(tOldType,unOldVal);
return *this;
}
@ -272,7 +272,7 @@ struct SQObjectPtr : public SQObject
unOldVal=_unVal;
_unVal = obj._unVal;
_type = obj._type;
__AddRef(_type,_unVal);
__addRef(_type,_unVal);
__release(tOldType,unOldVal);
return *this;
}

View File

@ -43,68 +43,68 @@ enum appendArrayType {
enum SQOpcode
{
_OP_LINE= 0x00,
_OP_LOAD= 0x01,
_OP_LOADINT= 0x02,
_OP_LOADFLOAT= 0x03,
_OP_DLOAD= 0x04,
_OP_TAILCALL= 0x05,
_OP_CALL= 0x06,
_OP_PREPCALL= 0x07,
_OP_PREPCALLK= 0x08,
_OP_GETK= 0x09,
_OP_MOVE= 0x0A,
_OP_NEWSLOT= 0x0B,
_OP_DELETE= 0x0C,
_OP_SET= 0x0D,
_OP_GET= 0x0E,
_OP_EQ= 0x0F,
_OP_NE= 0x10,
_OP_ADD= 0x11,
_OP_SUB= 0x12,
_OP_MUL= 0x13,
_OP_DIV= 0x14,
_OP_MOD= 0x15,
_OP_BITW= 0x16,
_OP_RETURN= 0x17,
_OP_LOADNULLS= 0x18,
_OP_LOADROOT= 0x19,
_OP_LOADBOOL= 0x1A,
_OP_DMOVE= 0x1B,
_OP_JMP= 0x1C,
//_OP_JNZ= 0x1D,
_OP_JCMP= 0x1D,
_OP_JZ= 0x1E,
_OP_SETOUTER= 0x1F,
_OP_GETOUTER= 0x20,
_OP_NEWOBJ= 0x21,
_OP_APPENDARRAY= 0x22,
_OP_COMPARITH= 0x23,
_OP_INC= 0x24,
_OP_INCL= 0x25,
_OP_PINC= 0x26,
_OP_PINCL= 0x27,
_OP_CMP= 0x28,
_OP_EXISTS= 0x29,
_OP_INSTANCEOF= 0x2A,
_OP_AND= 0x2B,
_OP_OR= 0x2C,
_OP_NEG= 0x2D,
_OP_NOT= 0x2E,
_OP_BWNOT= 0x2F,
_OP_CLOSURE= 0x30,
_OP_YIELD= 0x31,
_OP_RESUME= 0x32,
_OP_FOREACH= 0x33,
_OP_POSTFOREACH= 0x34,
_OP_CLONE= 0x35,
_OP_TYPEOF= 0x36,
_OP_PUSHTRAP= 0x37,
_OP_POPTRAP= 0x38,
_OP_THROW= 0x39,
_OP_NEWSLOTA= 0x3A,
_OP_GETBASE= 0x3B,
_OP_CLOSE= 0x3C
_OP_LINE= 0x00,
_OP_LOAD= 0x01,
_OP_LOADINT= 0x02,
_OP_LOADFLOAT= 0x03,
_OP_DLOAD= 0x04,
_OP_TAILCALL= 0x05,
_OP_CALL= 0x06,
_OP_PREPCALL= 0x07,
_OP_PREPCALLK= 0x08,
_OP_GETK= 0x09,
_OP_MOVE= 0x0A,
_OP_NEWSLOT= 0x0B,
_OP_DELETE= 0x0C,
_OP_SET= 0x0D,
_OP_GET= 0x0E,
_OP_EQ= 0x0F,
_OP_NE= 0x10,
_OP_ADD= 0x11,
_OP_SUB= 0x12,
_OP_MUL= 0x13,
_OP_DIV= 0x14,
_OP_MOD= 0x15,
_OP_BITW= 0x16,
_OP_RETURN= 0x17,
_OP_LOADNULLS= 0x18,
_OP_LOADROOT= 0x19,
_OP_LOADBOOL= 0x1A,
_OP_DMOVE= 0x1B,
_OP_JMP= 0x1C,
//_OP_JNZ= 0x1D,
_OP_JCMP= 0x1D,
_OP_JZ= 0x1E,
_OP_SETOUTER= 0x1F,
_OP_GETOUTER= 0x20,
_OP_NEWOBJ= 0x21,
_OP_APPENDARRAY= 0x22,
_OP_COMPARITH= 0x23,
_OP_INC= 0x24,
_OP_INCL= 0x25,
_OP_PINC= 0x26,
_OP_PINCL= 0x27,
_OP_CMP= 0x28,
_OP_EXISTS= 0x29,
_OP_INSTANCEOF= 0x2A,
_OP_AND= 0x2B,
_OP_OR= 0x2C,
_OP_NEG= 0x2D,
_OP_NOT= 0x2E,
_OP_BWNOT= 0x2F,
_OP_CLOSURE= 0x30,
_OP_YIELD= 0x31,
_OP_RESUME= 0x32,
_OP_FOREACH= 0x33,
_OP_POSTFOREACH= 0x34,
_OP_CLONE= 0x35,
_OP_TYPEOF= 0x36,
_OP_PUSHTRAP= 0x37,
_OP_POPTRAP= 0x38,
_OP_THROW= 0x39,
_OP_NEWSLOTA= 0x3A,
_OP_GETBASE= 0x3B,
_OP_CLOSE= 0x3C
};
struct SQInstructionDesc {

View File

@ -33,10 +33,10 @@ SQSharedState::SQSharedState()
#define newmetamethod(s) { \
_metamethods->push_back(SQString::create(this,s)); \
_table(_metamethodsmap)->NewSlot(_metamethods->back(),(int64_t)(_metamethods->size()-1)); \
_table(_metamethodsmap)->newSlot(_metamethods->back(),(int64_t)(_metamethods->size()-1)); \
}
bool CompileTypemask(SQIntVec &res,const SQChar *typemask)
bool compileTypemask(SQIntVec &res,const SQChar *typemask)
{
int64_t i = 0;
int64_t mask = 0;
@ -85,15 +85,15 @@ SQTable *createDefaultDelegate(SQSharedState *ss,const SQRegFunction *funcz)
SQNativeClosure *nc = SQNativeClosure::create(ss,funcz[i].f,0);
nc->_nparamscheck = funcz[i].nparamscheck;
nc->_name = SQString::create(ss,funcz[i].name);
if(funcz[i].typemask && !CompileTypemask(nc->_typecheck,funcz[i].typemask))
if(funcz[i].typemask && !compileTypemask(nc->_typecheck,funcz[i].typemask))
return NULL;
t->NewSlot(SQString::create(ss,funcz[i].name),nc);
t->newSlot(SQString::create(ss,funcz[i].name),nc);
i++;
}
return t;
}
void SQSharedState::Init()
void SQSharedState::init()
{
_scratchpad=NULL;
_scratchpadsize=0;
@ -159,9 +159,9 @@ SQSharedState::~SQSharedState()
{
if(_releasehook) { _releasehook(_foreignptr,0); _releasehook = NULL; }
_constructoridx.Null();
_table(_registry)->Finalize();
_table(_consts)->Finalize();
_table(_metamethodsmap)->Finalize();
_table(_registry)->finalize();
_table(_consts)->finalize();
_table(_metamethodsmap)->finalize();
_registry.Null();
_consts.Null();
_metamethodsmap.Null();
@ -169,7 +169,7 @@ SQSharedState::~SQSharedState()
_systemstrings->back().Null();
_systemstrings->pop_back();
}
_thread(_root_vm)->Finalize();
_thread(_root_vm)->finalize();
_root_vm.Null();
_table_default_delegate.Null();
_array_default_delegate.Null();
@ -181,7 +181,7 @@ SQSharedState::~SQSharedState()
_class_default_delegate.Null();
_instance_default_delegate.Null();
_weakref_default_delegate.Null();
_refs_table.Finalize();
_refs_table.finalize();
sq_delete(_types,SQObjectPtrVec);
sq_delete(_systemstrings,SQObjectPtrVec);
@ -223,10 +223,10 @@ SQChar* SQSharedState::getScratchPad(int64_t size)
RefTable::RefTable()
{
AllocNodes(4);
allocNodes(4);
}
void RefTable::Finalize()
void RefTable::finalize()
{
RefNode *nodes = _nodes;
for(uint64_t n = 0; n < _numofslots; n++) {
@ -241,7 +241,7 @@ RefTable::~RefTable()
}
void RefTable::AddRef(SQObject &obj)
void RefTable::addRef(SQObject &obj)
{
SQHash mainpos;
RefNode *prev;
@ -291,14 +291,14 @@ void RefTable::resize(uint64_t size)
RefNode **oldbucks = _buckets;
RefNode *t = _nodes;
uint64_t oldnumofslots = _numofslots;
AllocNodes(size);
allocNodes(size);
//rehash
uint64_t nfound = 0;
for(uint64_t n = 0; n < oldnumofslots; n++) {
if(sq_type(t->obj) != OT_NULL) {
//add back;
assert(t->refs != 0);
RefNode *nn = Add(::HashObj(t->obj)&(_numofslots-1),t->obj);
RefNode *nn = add(::HashObj(t->obj)&(_numofslots-1),t->obj);
nn->refs = t->refs;
t->obj.Null();
nfound++;
@ -309,7 +309,7 @@ void RefTable::resize(uint64_t size)
SQ_FREE(oldbucks,(oldnumofslots * sizeof(RefNode *)) + (oldnumofslots * sizeof(RefNode)));
}
RefTable::RefNode *RefTable::Add(SQHash mainpos,SQObject &obj)
RefTable::RefNode *RefTable::add(SQHash mainpos,SQObject &obj)
{
RefNode *t = _buckets[mainpos];
RefNode *newnode = _freelist;
@ -322,7 +322,7 @@ RefTable::RefNode *RefTable::Add(SQHash mainpos,SQObject &obj)
return newnode;
}
RefTable::RefNode *RefTable::get(SQObject &obj,SQHash &mainpos,RefNode **prev,bool add)
RefTable::RefNode *RefTable::get(SQObject &obj,SQHash &mainpos,RefNode **prev,bool addIfNeeded)
{
RefNode *ref;
mainpos = ::HashObj(obj)&(_numofslots-1);
@ -333,18 +333,18 @@ RefTable::RefNode *RefTable::get(SQObject &obj,SQHash &mainpos,RefNode **prev,bo
*prev = ref;
ref = ref->next;
}
if(ref == NULL && add) {
if(ref == NULL && addIfNeeded) {
if(_numofslots == _slotused) {
assert(_freelist == 0);
resize(_numofslots*2);
mainpos = ::HashObj(obj)&(_numofslots-1);
}
ref = Add(mainpos,obj);
ref = add(mainpos,obj);
}
return ref;
}
void RefTable::AllocNodes(uint64_t size)
void RefTable::allocNodes(uint64_t size)
{
RefNode **bucks;
RefNode *nodes;
@ -380,7 +380,7 @@ void RefTable::AllocNodes(uint64_t size)
SQStringTable::SQStringTable(SQSharedState *ss)
{
_sharedstate = ss;
AllocNodes(4);
allocNodes(4);
_slotused = 0;
}
@ -390,14 +390,14 @@ SQStringTable::~SQStringTable()
_strings = NULL;
}
void SQStringTable::AllocNodes(int64_t size)
void SQStringTable::allocNodes(int64_t size)
{
_numofslots = size;
_strings = (SQString**)SQ_MALLOC(sizeof(SQString*)*_numofslots);
memset(_strings,0,sizeof(SQString*)*_numofslots);
}
SQString *SQStringTable::Add(const SQChar *news,int64_t len)
SQString *SQStringTable::add(const SQChar *news,int64_t len)
{
if(len<0)
len = (int64_t)scstrlen(news);
@ -428,7 +428,7 @@ void SQStringTable::resize(int64_t size)
{
int64_t oldsize=_numofslots;
SQString **oldtable=_strings;
AllocNodes(size);
allocNodes(size);
for (int64_t i=0; i<oldsize; i++){
SQString *p = oldtable[i];
while(p){

View File

@ -18,11 +18,11 @@ struct SQStringTable
{
SQStringTable(SQSharedState*ss);
~SQStringTable();
SQString *Add(const SQChar *,int64_t len);
SQString *add(const SQChar *,int64_t len);
void remove(SQString *);
private:
void resize(int64_t size);
void AllocNodes(int64_t size);
void allocNodes(int64_t size);
SQString **_strings;
uint64_t _numofslots;
uint64_t _slotused;
@ -37,15 +37,15 @@ struct RefTable {
};
RefTable();
~RefTable();
void AddRef(SQObject &obj);
void addRef(SQObject &obj);
SQBool release(SQObject &obj);
uint64_t getRefCount(SQObject &obj);
void Finalize();
void finalize();
private:
RefNode *get(SQObject &obj,SQHash &mainpos,RefNode **prev,bool add);
RefNode *Add(SQHash mainpos,SQObject &obj);
RefNode *add(SQHash mainpos,SQObject &obj);
void resize(uint64_t size);
void AllocNodes(uint64_t size);
void allocNodes(uint64_t size);
uint64_t _numofslots;
uint64_t _slotused;
RefNode *_nodes;
@ -53,7 +53,7 @@ private:
RefNode **_buckets;
};
#define ADD_STRING(ss,str,len) ss->_stringtable->Add(str,len)
#define ADD_STRING(ss,str,len) ss->_stringtable->add(str,len)
#define REMOVE_STRING(ss,bstr) ss->_stringtable->remove(bstr)
struct SQObjectPtr;
@ -62,7 +62,7 @@ struct SQSharedState
{
SQSharedState();
~SQSharedState();
void Init();
void init();
public:
SQChar* getScratchPad(int64_t size);
int64_t getMetaMethodIdxByName(const SQObjectPtr &name);
@ -123,6 +123,6 @@ private:
#define _instance_ddel _table(_sharedstate->_instance_default_delegate)
#define _weakref_ddel _table(_sharedstate->_weakref_default_delegate)
bool CompileTypemask(SQIntVec &res,const SQChar *typemask);
bool compileTypemask(SQIntVec &res,const SQChar *typemask);

View File

@ -12,11 +12,11 @@
#include <rabbit/sqfuncproto.hpp>
#include <rabbit/sqclosure.hpp>
SQTable::SQTable(SQSharedState *ss,int64_t nInitialsize)
SQTable::SQTable(SQSharedState *ss,int64_t ninitialsize)
{
int64_t pow2size=MINPOWER2;
while(nInitialsize>pow2size)pow2size=pow2size<<1;
AllocNodes(pow2size);
while(ninitialsize>pow2size)pow2size=pow2size<<1;
allocNodes(pow2size);
_usednodes = 0;
_delegate = NULL;
}
@ -33,7 +33,7 @@ void SQTable::remove(const SQObjectPtr &key)
}
}
void SQTable::AllocNodes(int64_t nsize)
void SQTable::allocNodes(int64_t nsize)
{
_HashNode *nodes=(_HashNode *)SQ_MALLOC(sizeof(_HashNode)*nsize);
for(int64_t i=0;i<nsize;i++){
@ -52,21 +52,21 @@ void SQTable::Rehash(bool force)
//prevent problems with the integer division
if(oldsize<4)oldsize=4;
_HashNode *nold=_nodes;
int64_t nelems=CountUsed();
int64_t nelems=countUsed();
if (nelems >= oldsize-oldsize/4) /* using more than 3/4? */
AllocNodes(oldsize*2);
allocNodes(oldsize*2);
else if (nelems <= oldsize/4 && /* less than 1/4? */
oldsize > MINPOWER2)
AllocNodes(oldsize/2);
allocNodes(oldsize/2);
else if(force)
AllocNodes(oldsize);
allocNodes(oldsize);
else
return;
_usednodes = 0;
for (int64_t i=0; i<oldsize; i++) {
_HashNode *old = nold+i;
if (sq_type(old->key) != OT_NULL)
NewSlot(old->key,old->val);
newSlot(old->key,old->val);
}
for(int64_t k=0;k<oldsize;k++)
nold[k].~_HashNode();
@ -101,7 +101,7 @@ SQTable *SQTable::clone()
int64_t ridx=0;
SQObjectPtr key,val;
while((ridx=next(true,ridx,key,val))!=-1){
nt->NewSlot(key,val);
nt->newSlot(key,val);
}
#endif
nt->setDelegate(_delegate);
@ -119,7 +119,7 @@ bool SQTable::get(const SQObjectPtr &key,SQObjectPtr &val)
}
return false;
}
bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
bool SQTable::newSlot(const SQObjectPtr &key,const SQObjectPtr &val)
{
assert(sq_type(key) != OT_NULL);
SQHash h = HashObj(key) & (_numofnodes - 1);
@ -173,7 +173,7 @@ bool SQTable::NewSlot(const SQObjectPtr &key,const SQObjectPtr &val)
else (_firstfree)--;
}
Rehash(true);
return NewSlot(key, val);
return newSlot(key, val);
}
int64_t SQTable::next(bool getweakrefs,const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval)
@ -205,20 +205,20 @@ bool SQTable::set(const SQObjectPtr &key, const SQObjectPtr &val)
return false;
}
void SQTable::_ClearNodes()
void SQTable::_clearNodes()
{
for(int64_t i = 0;i < _numofnodes; i++) { _HashNode &n = _nodes[i]; n.key.Null(); n.val.Null(); }
}
void SQTable::Finalize()
void SQTable::finalize()
{
_ClearNodes();
_clearNodes();
setDelegate(NULL);
}
void SQTable::Clear()
void SQTable::clear()
{
_ClearNodes();
_clearNodes();
_usednodes = 0;
Rehash(true);
}

View File

@ -44,19 +44,19 @@ private:
int64_t _usednodes;
///////////////////////////
void AllocNodes(int64_t nsize);
void allocNodes(int64_t nsize);
void Rehash(bool force);
SQTable(SQSharedState *ss, int64_t nInitialsize);
void _ClearNodes();
SQTable(SQSharedState *ss, int64_t ninitialsize);
void _clearNodes();
public:
static SQTable* create(SQSharedState *ss,int64_t nInitialsize)
static SQTable* create(SQSharedState *ss,int64_t ninitialsize)
{
SQTable *newtable = (SQTable*)SQ_MALLOC(sizeof(SQTable));
new (newtable) SQTable(ss, nInitialsize);
new (newtable) SQTable(ss, ninitialsize);
newtable->_delegate = NULL;
return newtable;
}
void Finalize();
void finalize();
SQTable *clone();
~SQTable()
{
@ -96,11 +96,11 @@ public:
void remove(const SQObjectPtr &key);
bool set(const SQObjectPtr &key, const SQObjectPtr &val);
//returns true if a new slot has been created false if it was already present
bool NewSlot(const SQObjectPtr &key,const SQObjectPtr &val);
bool newSlot(const SQObjectPtr &key,const SQObjectPtr &val);
int64_t next(bool getweakrefs,const SQObjectPtr &refpos, SQObjectPtr &outkey, SQObjectPtr &outval);
int64_t CountUsed(){ return _usednodes;}
void Clear();
int64_t countUsed(){ return _usednodes;}
void clear();
void release()
{
sq_delete(this, SQTable);

File diff suppressed because it is too large Load Diff

View File

@ -39,8 +39,8 @@ typedef sqvector<SQExceptionTrap> ExceptionsTraps;
struct SQVM : public rabbit::RefCounted
{
struct CallInfo{
//CallInfo() { _generator = NULL;}
struct callInfo{
//callInfo() { _generator = NULL;}
SQInstruction *_ip;
SQObjectPtr *_literals;
SQObjectPtr _closure;
@ -53,56 +53,56 @@ struct SQVM : public rabbit::RefCounted
SQBool _root;
};
typedef sqvector<CallInfo> CallInfoVec;
typedef sqvector<callInfo> callInfoVec;
public:
void DebugHookProxy(int64_t type, const SQChar * sourcename, int64_t line, const SQChar * funcname);
static void _DebugHookProxy(HRABBITVM v, int64_t type, const SQChar * sourcename, int64_t line, const SQChar * funcname);
enum ExecutionType { ET_CALL, ET_RESUME_GENERATOR, ET_RESUME_VM,ET_RESUME_THROW_VM };
SQVM(SQSharedState *ss);
~SQVM();
bool Init(SQVM *friendvm, int64_t stacksize);
bool Execute(SQObjectPtr &func, int64_t nargs, int64_t stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
bool init(SQVM *friendvm, int64_t stacksize);
bool execute(SQObjectPtr &func, int64_t nargs, int64_t stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
//starts a native call return when the NATIVE closure returns
bool CallNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, SQObjectPtr &retval, int32_t target, bool &suspend,bool &tailcall);
bool TailCall(SQClosure *closure, int64_t firstparam, int64_t nparams);
bool callNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, SQObjectPtr &retval, int32_t target, bool &suspend,bool &tailcall);
bool tailcall(SQClosure *closure, int64_t firstparam, int64_t nparams);
//starts a RABBIT call in the same "Execution loop"
bool StartCall(SQClosure *closure, int64_t target, int64_t nargs, int64_t stackbase, bool tailcall);
bool startcall(SQClosure *closure, int64_t target, int64_t nargs, int64_t stackbase, bool tailcall);
bool createClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor);
//call a generic closure pure RABBIT or NATIVE
bool Call(SQObjectPtr &closure, int64_t nparams, int64_t stackbase, SQObjectPtr &outres,SQBool raiseerror);
bool call(SQObjectPtr &closure, int64_t nparams, int64_t stackbase, SQObjectPtr &outres,SQBool raiseerror);
SQRESULT Suspend();
void CallDebugHook(int64_t type,int64_t forcedline=0);
void CallErrorHandler(SQObjectPtr &e);
void callDebugHook(int64_t type,int64_t forcedline=0);
void callerrorHandler(SQObjectPtr &e);
bool get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, uint64_t getflags, int64_t selfidx);
int64_t FallBackget(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest);
bool InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest);
int64_t fallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest);
bool invokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest);
bool set(const SQObjectPtr &self, const SQObjectPtr &key, const SQObjectPtr &val, int64_t selfidx);
int64_t FallBackset(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val);
bool NewSlot(const SQObjectPtr &self, const SQObjectPtr &key, const SQObjectPtr &val,bool bstatic);
bool NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw);
bool DeleteSlot(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &res);
int64_t fallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val);
bool newSlot(const SQObjectPtr &self, const SQObjectPtr &key, const SQObjectPtr &val,bool bstatic);
bool newSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw);
bool deleteSlot(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &res);
bool clone(const SQObjectPtr &self, SQObjectPtr &target);
bool ObjCmp(const SQObjectPtr &o1, const SQObjectPtr &o2,int64_t &res);
bool StringCat(const SQObjectPtr &str, const SQObjectPtr &obj, SQObjectPtr &dest);
static bool IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res);
bool ToString(const SQObjectPtr &o,SQObjectPtr &res);
SQString *PrintObjVal(const SQObjectPtr &o);
bool objCmp(const SQObjectPtr &o1, const SQObjectPtr &o2,int64_t &res);
bool stringCat(const SQObjectPtr &str, const SQObjectPtr &obj, SQObjectPtr &dest);
static bool isEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res);
bool toString(const SQObjectPtr &o,SQObjectPtr &res);
SQString *printObjVal(const SQObjectPtr &o);
void Raise_Error(const SQChar *s, ...);
void Raise_Error(const SQObjectPtr &desc);
void Raise_IdxError(const SQObjectPtr &o);
void Raise_CompareError(const SQObject &o1, const SQObject &o2);
void Raise_ParamTypeError(int64_t nparam,int64_t typemask,int64_t type);
void raise_error(const SQChar *s, ...);
void raise_error(const SQObjectPtr &desc);
void raise_Idxerror(const SQObjectPtr &o);
void raise_Compareerror(const SQObject &o1, const SQObject &o2);
void raise_ParamTypeerror(int64_t nparam,int64_t typemask,int64_t type);
void FindOuter(SQObjectPtr &target, SQObjectPtr *stackindex);
void RelocateOuters();
void CloseOuters(SQObjectPtr *stackindex);
void findOuter(SQObjectPtr &target, SQObjectPtr *stackindex);
void relocateOuters();
void closeOuters(SQObjectPtr *stackindex);
bool TypeOf(const SQObjectPtr &obj1, SQObjectPtr &dest);
bool CallMetaMethod(SQObjectPtr &closure, SQMetaMethod mm, int64_t nparams, SQObjectPtr &outres);
bool ArithMetaMethod(int64_t op, const SQObjectPtr &o1, const SQObjectPtr &o2, SQObjectPtr &dest);
bool typeOf(const SQObjectPtr &obj1, SQObjectPtr &dest);
bool callMetaMethod(SQObjectPtr &closure, SQMetaMethod mm, int64_t nparams, SQObjectPtr &outres);
bool arithMetaMethod(int64_t op, const SQObjectPtr &o1, const SQObjectPtr &o2, SQObjectPtr &dest);
bool Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval);
//new stuff
bool ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2);
@ -115,20 +115,20 @@ public:
bool FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr &o3,SQObjectPtr &o4,int64_t arg_2,int exitpos,int &jump);
//bool LOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr);
bool PLOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr);
bool DerefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t arg0);
bool derefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t arg0);
#ifdef _DEBUG_DUMP
void dumpstack(int64_t stackbase=-1, bool dumpall = false);
#endif
void Finalize();
void GrowCallStack() {
void finalize();
void GrowcallStack() {
int64_t newsize = _alloccallsstacksize*2;
_callstackdata.resize(newsize);
_callsstack = &_callstackdata[0];
_alloccallsstacksize = newsize;
}
bool EnterFrame(int64_t newbase, int64_t newtop, bool tailcall);
void LeaveFrame();
bool enterFrame(int64_t newbase, int64_t newtop, bool tailcall);
void leaveFrame();
void release(){ sq_delete(this,SQVM); }
////////////////////////////////////////////////////////////////////////////
//stack functions for the api
@ -136,12 +136,12 @@ public:
static bool IsFalse(SQObjectPtr &o);
void Pop();
void Pop(int64_t n);
void Push(const SQObjectPtr &o);
void PushNull();
void pop();
void pop(int64_t n);
void push(const SQObjectPtr &o);
void pushNull();
SQObjectPtr &top();
SQObjectPtr &Popget();
SQObjectPtr &popGet();
SQObjectPtr &getUp(int64_t n);
SQObjectPtr &getAt(int64_t n);
@ -161,13 +161,13 @@ public:
SQObjectPtr temp_reg;
CallInfo* _callsstack;
callInfo* _callsstack;
int64_t _callsstacksize;
int64_t _alloccallsstacksize;
sqvector<CallInfo> _callstackdata;
sqvector<callInfo> _callstackdata;
ExceptionsTraps _etraps;
CallInfo *ci;
callInfo *ci;
SQUserPointer _foreignptr;
//VMs sharing the same state
SQSharedState *_sharedstate;
@ -194,7 +194,7 @@ inline SQObjectPtr &stack_get(HRABBITVM v,int64_t idx){return ((idx>=0)?(v->getA
#define PUSH_CALLINFO(v,nci){ \
int64_t css = v->_callsstacksize; \
if(css == v->_alloccallsstacksize) { \
v->GrowCallStack(); \
v->GrowcallStack(); \
} \
v->ci = &v->_callsstack[css]; \
*(v->ci) = nci; \