diff --git a/cmdLine/rabbit.cpp b/cmdLine/rabbit.cpp index fe94aa1..2da51d5 100644 --- a/cmdLine/rabbit.cpp +++ b/cmdLine/rabbit.cpp @@ -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; } diff --git a/doc/source/conf.py b/doc/source/conf.py index d673b79..d270adb 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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 diff --git a/rabbit-std/sqstdio.cpp b/rabbit-std/sqstdio.cpp index df032bb..f796fba 100644 --- a/rabbit-std/sqstdio.cpp +++ b/rabbit-std/sqstdio.cpp @@ -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; } diff --git a/rabbit/Array.hpp b/rabbit/Array.hpp index 6d98259..00aa9fb 100644 --- a/rabbit/Array.hpp +++ b/rabbit/Array.hpp @@ -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() { diff --git a/rabbit/sqapi.cpp b/rabbit/sqapi.cpp index 795f6af..86ffaaa 100644 --- a/rabbit/sqapi.cpp +++ b/rabbit/sqapi.cpp @@ -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_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) diff --git a/rabbit/sqbaselib.cpp b/rabbit/sqbaselib.cpp index 9db380f..10deaec 100644 --- a/rabbit/sqbaselib.cpp +++ b/rabbit/sqbaselib.cpp @@ -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;iPush(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;iPush((*aparams)[i]); + v->push(stack_get(v,1)); + for(int64_t i=0;ipush((*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))) { diff --git a/rabbit/sqclass.cpp b/rabbit/sqclass.cpp index b113764..1aaccfd 100644 --- a/rabbit/sqclass.cpp +++ b/rabbit/sqclass.cpp @@ -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) { diff --git a/rabbit/sqclass.hpp b/rabbit/sqclass.hpp index 8684b6d..e1fea94 100644 --- a/rabbit/sqclass.hpp +++ b/rabbit/sqclass.hpp @@ -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; diff --git a/rabbit/sqclosure.hpp b/rabbit/sqclosure.hpp index 8c55e5b..a789be2 100644 --- a/rabbit/sqclosure.hpp +++ b/rabbit/sqclosure.hpp @@ -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); diff --git a/rabbit/sqcompiler.cpp b/rabbit/sqcompiler.cpp index c1964af..6b8ff4e 100644 --- a/rabbit/sqcompiler.cpp +++ b/rabbit/sqcompiler.cpp @@ -43,7 +43,7 @@ struct SQScope { #define RESOLVE_OUTERS() if(_fs->getStacksize() != _scope.stacksize) { \ if(_fs->CountOuters(_scope.stacksize)) { \ - _fs->AddInstruction(_OP_CLOSE,0,_scope.stacksize); \ + _fs->addInstruction(_OP_CLOSE,0,_scope.stacksize); \ } \ } @@ -57,7 +57,7 @@ struct SQScope { if(_fs->getStacksize() != _scope.stacksize) { \ _fs->setStacksize(_scope.stacksize); \ if(oldouters != _fs->_outers) { \ - _fs->AddInstruction(_OP_CLOSE,0,_scope.stacksize); \ + _fs->addInstruction(_OP_CLOSE,0,_scope.stacksize); \ } \ } \ _scope = __oldscope__; \ @@ -73,24 +73,24 @@ struct SQScope { if(__nbreaks__>0)ResolveBreaks(_fs,__nbreaks__); \ _fs->_breaktargets.pop_back();_fs->_continuetargets.pop_back();} -class SQCompiler +class SQcompiler { public: - SQCompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) + SQcompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo) { _vm=v; - _lex.Init(_ss(v), rg, up,ThrowError,this); + _lex.init(_ss(v), rg, up,Throwerror,this); _sourcename = SQString::create(_ss(v), sourcename); _lineinfo = lineinfo;_raiseerror = raiseerror; _scope.outers = 0; _scope.stacksize = 0; _compilererror[0] = _SC('\0'); } - static void ThrowError(void *ud, const SQChar *s) { - SQCompiler *c = (SQCompiler *)ud; - c->Error(s); + static void Throwerror(void *ud, const SQChar *s) { + SQcompiler *c = (SQcompiler *)ud; + c->error(s); } - void Error(const SQChar *s, ...) + void error(const SQChar *s, ...) { va_list vl; va_start(vl, s); @@ -124,11 +124,11 @@ public: etypename = _SC("FLOAT"); break; default: - etypename = _lex.Tok2Str(tok); + etypename = _lex.tok2Str(tok); } - Error(_SC("expected '%s'"), etypename); + error(_SC("expected '%s'"), etypename); } - Error(_SC("expected '%c'"), tok); + error(_SC("expected '%c'"), tok); } } SQObjectPtr ret; @@ -155,26 +155,26 @@ public: { if(_token == _SC(';')) { Lex(); return; } if(!IsEndOfStatement()) { - Error(_SC("end of statement expected (; or lf)")); + error(_SC("end of statement expected (; or lf)")); } } - void MoveIfCurrentTargetIsLocal() { + void MoveIfCurrentTargetisLocal() { int64_t trg = _fs->topTarget(); - if(_fs->IsLocal(trg)) { - trg = _fs->PopTarget(); //pops the target and moves it - _fs->AddInstruction(_OP_MOVE, _fs->PushTarget(), trg); + if(_fs->isLocal(trg)) { + trg = _fs->popTarget(); //pops the target and moves it + _fs->addInstruction(_OP_MOVE, _fs->pushTarget(), trg); } } - bool Compile(SQObjectPtr &o) + bool compile(SQObjectPtr &o) { _debugline = 1; _debugop = 0; - SQFuncState funcstate(_ss(_vm), NULL,ThrowError,this); + SQFuncState funcstate(_ss(_vm), NULL,Throwerror,this); funcstate._name = SQString::create(_ss(_vm), _SC("main")); _fs = &funcstate; - _fs->AddParameter(_fs->createString(_SC("this"))); - _fs->AddParameter(_fs->createString(_SC("vargv"))); + _fs->addParameter(_fs->createString(_SC("this"))); + _fs->addParameter(_fs->createString(_SC("vargv"))); _fs->_varparams = true; _fs->_sourcename = _sourcename; int64_t stacksize = _fs->getStacksize(); @@ -185,12 +185,12 @@ public: if(_lex._prevtoken != _SC('}') && _lex._prevtoken != _SC(';')) OptionalSemicolon(); } _fs->setStacksize(stacksize); - _fs->AddLineInfos(_lex._currentline, _lineinfo, true); - _fs->AddInstruction(_OP_RETURN, 0xFF); + _fs->addLineInfos(_lex._currentline, _lineinfo, true); + _fs->addInstruction(_OP_RETURN, 0xFF); _fs->setStacksize(0); - o =_fs->BuildProto(); + o =_fs->buildProto(); #ifdef _DEBUG_DUMP - _fs->Dump(_funcproto(o)); + _fs->dump(_funcproto(o)); #endif } else { @@ -212,7 +212,7 @@ public: } void Statement(bool closeframe = true) { - _fs->AddLineInfos(_lex._currentline, _lineinfo); + _fs->addLineInfos(_lex._currentline, _lineinfo); switch(_token){ case _SC(';'): Lex(); break; case TK_IF: IfStatement(); break; @@ -237,34 +237,34 @@ public: int64_t retexp = _fs->getCurrentPos()+1; CommaExpr(); if(op == _OP_RETURN && _fs->_traps > 0) - _fs->AddInstruction(_OP_POPTRAP, _fs->_traps, 0); + _fs->addInstruction(_OP_POPTRAP, _fs->_traps, 0); _fs->_returnexp = retexp; - _fs->AddInstruction(op, 1, _fs->PopTarget(),_fs->getStacksize()); + _fs->addInstruction(op, 1, _fs->popTarget(),_fs->getStacksize()); } else{ if(op == _OP_RETURN && _fs->_traps > 0) - _fs->AddInstruction(_OP_POPTRAP, _fs->_traps ,0); + _fs->addInstruction(_OP_POPTRAP, _fs->_traps ,0); _fs->_returnexp = -1; - _fs->AddInstruction(op, 0xFF,0,_fs->getStacksize()); + _fs->addInstruction(op, 0xFF,0,_fs->getStacksize()); } break;} case TK_BREAK: - if(_fs->_breaktargets.size() <= 0)Error(_SC("'break' has to be in a loop block")); + if(_fs->_breaktargets.size() <= 0)error(_SC("'break' has to be in a loop block")); if(_fs->_breaktargets.top() > 0){ - _fs->AddInstruction(_OP_POPTRAP, _fs->_breaktargets.top(), 0); + _fs->addInstruction(_OP_POPTRAP, _fs->_breaktargets.top(), 0); } RESOLVE_OUTERS(); - _fs->AddInstruction(_OP_JMP, 0, -1234); + _fs->addInstruction(_OP_JMP, 0, -1234); _fs->_unresolvedbreaks.push_back(_fs->getCurrentPos()); Lex(); break; case TK_CONTINUE: - if(_fs->_continuetargets.size() <= 0)Error(_SC("'continue' has to be in a loop block")); + if(_fs->_continuetargets.size() <= 0)error(_SC("'continue' has to be in a loop block")); if(_fs->_continuetargets.top() > 0) { - _fs->AddInstruction(_OP_POPTRAP, _fs->_continuetargets.top(), 0); + _fs->addInstruction(_OP_POPTRAP, _fs->_continuetargets.top(), 0); } RESOLVE_OUTERS(); - _fs->AddInstruction(_OP_JMP, 0, -1234); + _fs->addInstruction(_OP_JMP, 0, -1234); _fs->_unresolvedcontinues.push_back(_fs->getCurrentPos()); Lex(); break; @@ -296,7 +296,7 @@ public: case TK_THROW: Lex(); CommaExpr(); - _fs->AddInstruction(_OP_THROW, _fs->PopTarget()); + _fs->addInstruction(_OP_THROW, _fs->popTarget()); break; case TK_CONST: { @@ -307,70 +307,70 @@ public: OptionalSemicolon(); SQTable *enums = _table(_ss(_vm)->_consts); SQObjectPtr strongid = id; - enums->NewSlot(strongid,SQObjectPtr(val)); + enums->newSlot(strongid,SQObjectPtr(val)); strongid.Null(); } break; default: CommaExpr(); - _fs->DiscardTarget(); - //_fs->PopTarget(); + _fs->discardTarget(); + //_fs->popTarget(); break; } - _fs->SnoozeOpt(); + _fs->snoozeOpt(); } void EmitDerefOp(SQOpcode op) { - int64_t val = _fs->PopTarget(); - int64_t key = _fs->PopTarget(); - int64_t src = _fs->PopTarget(); - _fs->AddInstruction(op,_fs->PushTarget(),src,key,val); + int64_t val = _fs->popTarget(); + int64_t key = _fs->popTarget(); + int64_t src = _fs->popTarget(); + _fs->addInstruction(op,_fs->pushTarget(),src,key,val); } void Emit2ArgsOP(SQOpcode op, int64_t p3 = 0) { - int64_t p2 = _fs->PopTarget(); //src in OP_GET - int64_t p1 = _fs->PopTarget(); //key in OP_GET - _fs->AddInstruction(op,_fs->PushTarget(), p1, p2, p3); + int64_t p2 = _fs->popTarget(); //src in OP_GET + int64_t p1 = _fs->popTarget(); //key in OP_GET + _fs->addInstruction(op,_fs->pushTarget(), p1, p2, p3); } void EmitCompoundArith(int64_t tok, int64_t etype, int64_t pos) { /* Generate code depending on the expression type */ switch(etype) { case LOCAL:{ - int64_t p2 = _fs->PopTarget(); //src in OP_GET - int64_t p1 = _fs->PopTarget(); //key in OP_GET - _fs->PushTarget(p1); + int64_t p2 = _fs->popTarget(); //src in OP_GET + int64_t p1 = _fs->popTarget(); //key in OP_GET + _fs->pushTarget(p1); //EmitCompArithLocal(tok, p1, p1, p2); - _fs->AddInstruction(ChooseArithOpByToken(tok),p1, p2, p1, 0); - _fs->SnoozeOpt(); + _fs->addInstruction(ChooseArithOpByToken(tok),p1, p2, p1, 0); + _fs->snoozeOpt(); } break; case OBJECT: case BASE: { - int64_t val = _fs->PopTarget(); - int64_t key = _fs->PopTarget(); - int64_t src = _fs->PopTarget(); + int64_t val = _fs->popTarget(); + int64_t key = _fs->popTarget(); + int64_t src = _fs->popTarget(); /* _OP_COMPARITH mixes dest obj and source val in the arg1 */ - _fs->AddInstruction(_OP_COMPARITH, _fs->PushTarget(), (src<<16)|val, key, ChooseCompArithCharByToken(tok)); + _fs->addInstruction(_OP_COMPARITH, _fs->pushTarget(), (src<<16)|val, key, ChooseCompArithCharByToken(tok)); } break; case OUTER: { int64_t val = _fs->topTarget(); - int64_t tmp = _fs->PushTarget(); - _fs->AddInstruction(_OP_GETOUTER, tmp, pos); - _fs->AddInstruction(ChooseArithOpByToken(tok), tmp, val, tmp, 0); - _fs->PopTarget(); - _fs->PopTarget(); - _fs->AddInstruction(_OP_SETOUTER, _fs->PushTarget(), pos, tmp); + int64_t tmp = _fs->pushTarget(); + _fs->addInstruction(_OP_GETOUTER, tmp, pos); + _fs->addInstruction(ChooseArithOpByToken(tok), tmp, val, tmp, 0); + _fs->popTarget(); + _fs->popTarget(); + _fs->addInstruction(_OP_SETOUTER, _fs->pushTarget(), pos, tmp); } break; } } void CommaExpr() { - for(Expression();_token == ',';_fs->PopTarget(), Lex(), CommaExpr()); + for(Expression();_token == ',';_fs->popTarget(), Lex(), CommaExpr()); } void Expression() { @@ -390,8 +390,8 @@ public: int64_t op = _token; int64_t ds = _es.etype; int64_t pos = _es.epos; - if(ds == EXPR) Error(_SC("can't assign expression")); - else if(ds == BASE) Error(_SC("'base' cannot be modified")); + if(ds == EXPR) error(_SC("can't assign expression")); + else if(ds == BASE) error(_SC("'base' cannot be modified")); Lex(); Expression(); switch(op){ @@ -399,15 +399,15 @@ public: if(ds == OBJECT || ds == BASE) EmitDerefOp(_OP_NEWSLOT); else //if _derefstate != DEREF_NO_DEREF && DEREF_FIELD so is the index of a local - Error(_SC("can't 'create' a local slot")); + error(_SC("can't 'create' a local slot")); break; case _SC('='): //ASSIGN switch(ds) { case LOCAL: { - int64_t src = _fs->PopTarget(); + int64_t src = _fs->popTarget(); int64_t dst = _fs->topTarget(); - _fs->AddInstruction(_OP_MOVE, dst, src); + _fs->addInstruction(_OP_MOVE, dst, src); } break; case OBJECT: @@ -416,9 +416,9 @@ public: break; case OUTER: { - int64_t src = _fs->PopTarget(); - int64_t dst = _fs->PushTarget(); - _fs->AddInstruction(_OP_SETOUTER, dst, pos, src); + int64_t src = _fs->popTarget(); + int64_t dst = _fs->pushTarget(); + _fs->addInstruction(_OP_SETOUTER, dst, pos, src); } } break; @@ -434,22 +434,22 @@ public: break; case _SC('?'): { Lex(); - _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); + _fs->addInstruction(_OP_JZ, _fs->popTarget()); int64_t jzpos = _fs->getCurrentPos(); - int64_t trg = _fs->PushTarget(); + int64_t trg = _fs->pushTarget(); Expression(); - int64_t first_exp = _fs->PopTarget(); - if(trg != first_exp) _fs->AddInstruction(_OP_MOVE, trg, first_exp); + int64_t first_exp = _fs->popTarget(); + if(trg != first_exp) _fs->addInstruction(_OP_MOVE, trg, first_exp); int64_t endfirstexp = _fs->getCurrentPos(); - _fs->AddInstruction(_OP_JMP, 0, 0); + _fs->addInstruction(_OP_JMP, 0, 0); Expect(_SC(':')); int64_t jmppos = _fs->getCurrentPos(); Expression(); - int64_t second_exp = _fs->PopTarget(); - if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); + int64_t second_exp = _fs->popTarget(); + if(trg != second_exp) _fs->addInstruction(_OP_MOVE, trg, second_exp); _fs->setIntructionParam(jmppos, 1, _fs->getCurrentPos() - jmppos); _fs->setIntructionParam(jzpos, 1, endfirstexp - jzpos + 1); - _fs->SnoozeOpt(); + _fs->snoozeOpt(); } break; } @@ -468,24 +468,24 @@ public: { Lex(); INVOKE_EXP(f); - int64_t op1 = _fs->PopTarget();int64_t op2 = _fs->PopTarget(); - _fs->AddInstruction(op, _fs->PushTarget(), op1, op2, op3); + int64_t op1 = _fs->popTarget();int64_t op2 = _fs->popTarget(); + _fs->addInstruction(op, _fs->pushTarget(), op1, op2, op3); _es.etype = EXPR; } void LogicalOrExp() { LogicalAndExp(); for(;;) if(_token == TK_OR) { - int64_t first_exp = _fs->PopTarget(); - int64_t trg = _fs->PushTarget(); - _fs->AddInstruction(_OP_OR, trg, 0, first_exp, 0); + int64_t first_exp = _fs->popTarget(); + int64_t trg = _fs->pushTarget(); + _fs->addInstruction(_OP_OR, trg, 0, first_exp, 0); int64_t jpos = _fs->getCurrentPos(); - if(trg != first_exp) _fs->AddInstruction(_OP_MOVE, trg, first_exp); - Lex(); INVOKE_EXP(&SQCompiler::LogicalOrExp); - _fs->SnoozeOpt(); - int64_t second_exp = _fs->PopTarget(); - if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); - _fs->SnoozeOpt(); + if(trg != first_exp) _fs->addInstruction(_OP_MOVE, trg, first_exp); + Lex(); INVOKE_EXP(&SQcompiler::LogicalOrExp); + _fs->snoozeOpt(); + int64_t second_exp = _fs->popTarget(); + if(trg != second_exp) _fs->addInstruction(_OP_MOVE, trg, second_exp); + _fs->snoozeOpt(); _fs->setIntructionParam(jpos, 1, (_fs->getCurrentPos() - jpos)); _es.etype = EXPR; break; @@ -496,16 +496,16 @@ public: BitwiseOrExp(); for(;;) switch(_token) { case TK_AND: { - int64_t first_exp = _fs->PopTarget(); - int64_t trg = _fs->PushTarget(); - _fs->AddInstruction(_OP_AND, trg, 0, first_exp, 0); + int64_t first_exp = _fs->popTarget(); + int64_t trg = _fs->pushTarget(); + _fs->addInstruction(_OP_AND, trg, 0, first_exp, 0); int64_t jpos = _fs->getCurrentPos(); - if(trg != first_exp) _fs->AddInstruction(_OP_MOVE, trg, first_exp); - Lex(); INVOKE_EXP(&SQCompiler::LogicalAndExp); - _fs->SnoozeOpt(); - int64_t second_exp = _fs->PopTarget(); - if(trg != second_exp) _fs->AddInstruction(_OP_MOVE, trg, second_exp); - _fs->SnoozeOpt(); + if(trg != first_exp) _fs->addInstruction(_OP_MOVE, trg, first_exp); + Lex(); INVOKE_EXP(&SQcompiler::LogicalAndExp); + _fs->snoozeOpt(); + int64_t second_exp = _fs->popTarget(); + if(trg != second_exp) _fs->addInstruction(_OP_MOVE, trg, second_exp); + _fs->snoozeOpt(); _fs->setIntructionParam(jpos, 1, (_fs->getCurrentPos() - jpos)); _es.etype = EXPR; break; @@ -519,30 +519,30 @@ public: { BitwiseXorExp(); for(;;) if(_token == _SC('|')) - {BIN_EXP(_OP_BITW, &SQCompiler::BitwiseXorExp,BW_OR); + {BIN_EXP(_OP_BITW, &SQcompiler::BitwiseXorExp,BW_OR); }else return; } void BitwiseXorExp() { BitwiseAndExp(); for(;;) if(_token == _SC('^')) - {BIN_EXP(_OP_BITW, &SQCompiler::BitwiseAndExp,BW_XOR); + {BIN_EXP(_OP_BITW, &SQcompiler::BitwiseAndExp,BW_XOR); }else return; } void BitwiseAndExp() { EqExp(); for(;;) if(_token == _SC('&')) - {BIN_EXP(_OP_BITW, &SQCompiler::EqExp,BW_AND); + {BIN_EXP(_OP_BITW, &SQcompiler::EqExp,BW_AND); }else return; } void EqExp() { CompExp(); for(;;) switch(_token) { - case TK_EQ: BIN_EXP(_OP_EQ, &SQCompiler::CompExp); break; - case TK_NE: BIN_EXP(_OP_NE, &SQCompiler::CompExp); break; - case TK_3WAYSCMP: BIN_EXP(_OP_CMP, &SQCompiler::CompExp,CMP_3W); break; + case TK_EQ: BIN_EXP(_OP_EQ, &SQcompiler::CompExp); break; + case TK_NE: BIN_EXP(_OP_NE, &SQcompiler::CompExp); break; + case TK_3WAYSCMP: BIN_EXP(_OP_CMP, &SQcompiler::CompExp,CMP_3W); break; default: return; } } @@ -550,12 +550,12 @@ public: { ShiftExp(); for(;;) switch(_token) { - case _SC('>'): BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_G); break; - case _SC('<'): BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_L); break; - case TK_GE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_GE); break; - case TK_LE: BIN_EXP(_OP_CMP, &SQCompiler::ShiftExp,CMP_LE); break; - case TK_IN: BIN_EXP(_OP_EXISTS, &SQCompiler::ShiftExp); break; - case TK_INSTANCEOF: BIN_EXP(_OP_INSTANCEOF, &SQCompiler::ShiftExp); break; + case _SC('>'): BIN_EXP(_OP_CMP, &SQcompiler::ShiftExp,CMP_G); break; + case _SC('<'): BIN_EXP(_OP_CMP, &SQcompiler::ShiftExp,CMP_L); break; + case TK_GE: BIN_EXP(_OP_CMP, &SQcompiler::ShiftExp,CMP_GE); break; + case TK_LE: BIN_EXP(_OP_CMP, &SQcompiler::ShiftExp,CMP_LE); break; + case TK_IN: BIN_EXP(_OP_EXISTS, &SQcompiler::ShiftExp); break; + case TK_INSTANCEOF: BIN_EXP(_OP_INSTANCEOF, &SQcompiler::ShiftExp); break; default: return; } } @@ -563,9 +563,9 @@ public: { PlusExp(); for(;;) switch(_token) { - case TK_USHIFTR: BIN_EXP(_OP_BITW, &SQCompiler::PlusExp,BW_USHIFTR); break; - case TK_SHIFTL: BIN_EXP(_OP_BITW, &SQCompiler::PlusExp,BW_SHIFTL); break; - case TK_SHIFTR: BIN_EXP(_OP_BITW, &SQCompiler::PlusExp,BW_SHIFTR); break; + case TK_USHIFTR: BIN_EXP(_OP_BITW, &SQcompiler::PlusExp,BW_USHIFTR); break; + case TK_SHIFTL: BIN_EXP(_OP_BITW, &SQcompiler::PlusExp,BW_SHIFTL); break; + case TK_SHIFTR: BIN_EXP(_OP_BITW, &SQcompiler::PlusExp,BW_SHIFTR); break; default: return; } } @@ -600,7 +600,7 @@ public: MultExp(); for(;;) switch(_token) { case _SC('+'): case _SC('-'): - BIN_EXP(ChooseArithOpByToken(_token), &SQCompiler::MultExp); break; + BIN_EXP(ChooseArithOpByToken(_token), &SQcompiler::MultExp); break; default: return; } } @@ -610,7 +610,7 @@ public: PrefixedExpr(); for(;;) switch(_token) { case _SC('*'): case _SC('/'): case _SC('%'): - BIN_EXP(ChooseArithOpByToken(_token), &SQCompiler::PrefixedExpr); break; + BIN_EXP(ChooseArithOpByToken(_token), &SQcompiler::PrefixedExpr); break; default: return; } } @@ -624,7 +624,7 @@ public: pos = -1; Lex(); - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(Expect(TK_IDENTIFIER))); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(Expect(TK_IDENTIFIER))); if(_es.etype==BASE) { Emit2ArgsOP(_OP_GET); pos = _fs->topTarget(); @@ -639,7 +639,7 @@ public: } break; case _SC('['): - if(_lex._prevtoken == _SC('\n')) Error(_SC("cannot brake deref/or comma needed after [exp]=exp slot declaration")); + if(_lex._prevtoken == _SC('\n')) error(_SC("cannot brake deref/or comma needed after [exp]=exp slot declaration")); Lex(); Expression(); Expect(_SC(']')); pos = -1; if(_es.etype==BASE) { @@ -663,24 +663,24 @@ public: Lex(); switch(_es.etype) { - case EXPR: Error(_SC("can't '++' or '--' an expression")); break; + case EXPR: error(_SC("can't '++' or '--' an expression")); break; case OBJECT: case BASE: - if(_es.donot_get == true) { Error(_SC("can't '++' or '--' an expression")); break; } //mmh dor this make sense? + if(_es.donot_get == true) { error(_SC("can't '++' or '--' an expression")); break; } //mmh dor this make sense? Emit2ArgsOP(_OP_PINC, diff); break; case LOCAL: { - int64_t src = _fs->PopTarget(); - _fs->AddInstruction(_OP_PINCL, _fs->PushTarget(), src, 0, diff); + int64_t src = _fs->popTarget(); + _fs->addInstruction(_OP_PINCL, _fs->pushTarget(), src, 0, diff); } break; case OUTER: { - int64_t tmp1 = _fs->PushTarget(); - int64_t tmp2 = _fs->PushTarget(); - _fs->AddInstruction(_OP_GETOUTER, tmp2, _es.epos); - _fs->AddInstruction(_OP_PINCL, tmp1, tmp2, 0, diff); - _fs->AddInstruction(_OP_SETOUTER, tmp2, _es.epos, tmp2); - _fs->PopTarget(); + int64_t tmp1 = _fs->pushTarget(); + int64_t tmp2 = _fs->pushTarget(); + _fs->addInstruction(_OP_GETOUTER, tmp2, _es.epos); + _fs->addInstruction(_OP_PINCL, tmp1, tmp2, 0, diff); + _fs->addInstruction(_OP_SETOUTER, tmp2, _es.epos, tmp2); + _fs->popTarget(); } } } @@ -689,27 +689,27 @@ public: case _SC('('): switch(_es.etype) { case OBJECT: { - int64_t key = _fs->PopTarget(); /* location of the key */ - int64_t table = _fs->PopTarget(); /* location of the object */ - int64_t closure = _fs->PushTarget(); /* location for the closure */ - int64_t ttarget = _fs->PushTarget(); /* location for 'this' pointer */ - _fs->AddInstruction(_OP_PREPCALL, closure, key, table, ttarget); + int64_t key = _fs->popTarget(); /* location of the key */ + int64_t table = _fs->popTarget(); /* location of the object */ + int64_t closure = _fs->pushTarget(); /* location for the closure */ + int64_t ttarget = _fs->pushTarget(); /* location for 'this' pointer */ + _fs->addInstruction(_OP_PREPCALL, closure, key, table, ttarget); } break; case BASE: //Emit2ArgsOP(_OP_GET); - _fs->AddInstruction(_OP_MOVE, _fs->PushTarget(), 0); + _fs->addInstruction(_OP_MOVE, _fs->pushTarget(), 0); break; case OUTER: - _fs->AddInstruction(_OP_GETOUTER, _fs->PushTarget(), _es.epos); - _fs->AddInstruction(_OP_MOVE, _fs->PushTarget(), 0); + _fs->addInstruction(_OP_GETOUTER, _fs->pushTarget(), _es.epos); + _fs->addInstruction(_OP_MOVE, _fs->pushTarget(), 0); break; default: - _fs->AddInstruction(_OP_MOVE, _fs->PushTarget(), 0); + _fs->addInstruction(_OP_MOVE, _fs->pushTarget(), 0); } _es.etype = EXPR; Lex(); - FunctionCallArgs(); + FunctioncallArgs(); break; default: return; } @@ -721,12 +721,12 @@ public: switch(_token) { case TK_STRING_LITERAL: - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(_fs->createString(_lex._svalue,_lex._longstr.size()-1))); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(_fs->createString(_lex._svalue,_lex._longstr.size()-1))); Lex(); break; case TK_BASE: Lex(); - _fs->AddInstruction(_OP_GETBASE, _fs->PushTarget()); + _fs->addInstruction(_OP_GETBASE, _fs->pushTarget()); _es.etype = BASE; _es.epos = _fs->topTarget(); return (_es.epos); @@ -747,7 +747,7 @@ public: Lex(); if((pos = _fs->getLocalVariable(id)) != -1) { /* Handle a local variable (includes 'this') */ - _fs->PushTarget(pos); + _fs->pushTarget(pos); _es.etype = LOCAL; _es.epos = pos; } @@ -755,8 +755,8 @@ public: else if((pos = _fs->getOuterVariable(id)) != -1) { /* Handle a free var */ if(Needget()) { - _es.epos = _fs->PushTarget(); - _fs->AddInstruction(_OP_GETOUTER, _es.epos, pos); + _es.epos = _fs->pushTarget(); + _fs->addInstruction(_OP_GETOUTER, _es.epos, pos); /* _es.etype = EXPR; already default value */ } else { @@ -765,7 +765,7 @@ public: } } - else if(_fs->IsConstant(id, constant)) { + else if(_fs->isConstant(id, constant)) { /* Handle named constant */ SQObjectPtr constval; SQObject constid; @@ -774,33 +774,33 @@ public: constid = Expect(TK_IDENTIFIER); if(!_table(constant)->get(constid, constval)) { constval.Null(); - Error(_SC("invalid constant [%s.%s]"), _stringval(id), _stringval(constid)); + error(_SC("invalid constant [%s.%s]"), _stringval(id), _stringval(constid)); } } else { constval = constant; } - _es.epos = _fs->PushTarget(); + _es.epos = _fs->pushTarget(); /* generate direct or literal function depending on size */ SQObjectType ctype = sq_type(constval); switch(ctype) { - case OT_INTEGER: EmitLoadConstInt(_integer(constval),_es.epos); break; - case OT_FLOAT: EmitLoadConstFloat(_float(constval),_es.epos); break; - case OT_BOOL: _fs->AddInstruction(_OP_LOADBOOL, _es.epos, _integer(constval)); break; - default: _fs->AddInstruction(_OP_LOAD,_es.epos,_fs->getConstant(constval)); break; + case OT_INTEGER: EmitloadConstInt(_integer(constval),_es.epos); break; + case OT_FLOAT: EmitloadConstFloat(_float(constval),_es.epos); break; + case OT_BOOL: _fs->addInstruction(_OP_LOADBOOL, _es.epos, _integer(constval)); break; + default: _fs->addInstruction(_OP_LOAD,_es.epos,_fs->getConstant(constval)); break; } _es.etype = EXPR; } else { - /* Handle a non-local variable, aka a field. Push the 'this' pointer on + /* Handle a non-local variable, aka a field. push the 'this' pointer on * the virtual stack (always found in offset 0, so no instruction needs to * be generated), and push the key next. Generate an _OP_LOAD instruction * for the latter. If we are not using the variable as a dref expr, generate * the _OP_GET instruction. */ - _fs->PushTarget(0); - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(id)); + _fs->pushTarget(0); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(id)); if(Needget()) { Emit2ArgsOP(_OP_GET); } @@ -810,32 +810,32 @@ public: } break; case TK_DOUBLE_COLON: // "::" - _fs->AddInstruction(_OP_LOADROOT, _fs->PushTarget()); + _fs->addInstruction(_OP_LOADROOT, _fs->pushTarget()); _es.etype = OBJECT; _token = _SC('.'); /* hack: drop into PrefixExpr, case '.'*/ _es.epos = -1; return _es.epos; break; case TK_NULL: - _fs->AddInstruction(_OP_LOADNULLS, _fs->PushTarget(),1); + _fs->addInstruction(_OP_LOADNULLS, _fs->pushTarget(),1); Lex(); break; - case TK_INTEGER: EmitLoadConstInt(_lex._nvalue,-1); Lex(); break; - case TK_FLOAT: EmitLoadConstFloat(_lex._fvalue,-1); Lex(); break; + case TK_INTEGER: EmitloadConstInt(_lex._nvalue,-1); Lex(); break; + case TK_FLOAT: EmitloadConstFloat(_lex._fvalue,-1); Lex(); break; case TK_TRUE: case TK_FALSE: - _fs->AddInstruction(_OP_LOADBOOL, _fs->PushTarget(),_token == TK_TRUE?1:0); + _fs->addInstruction(_OP_LOADBOOL, _fs->pushTarget(),_token == TK_TRUE?1:0); Lex(); break; case _SC('['): { - _fs->AddInstruction(_OP_NEWOBJ, _fs->PushTarget(),0,0,NOT_ARRAY); + _fs->addInstruction(_OP_NEWOBJ, _fs->pushTarget(),0,0,NOT_ARRAY); int64_t apos = _fs->getCurrentPos(),key = 0; Lex(); while(_token != _SC(']')) { Expression(); if(_token == _SC(',')) Lex(); - int64_t val = _fs->PopTarget(); + int64_t val = _fs->popTarget(); int64_t array = _fs->topTarget(); - _fs->AddInstruction(_OP_APPENDARRAY, array, val, AAT_STACK); + _fs->addInstruction(_OP_APPENDARRAY, array, val, AAT_STACK); key++; } _fs->setIntructionParam(apos, 1, key); @@ -843,7 +843,7 @@ public: } break; case _SC('{'): - _fs->AddInstruction(_OP_NEWOBJ, _fs->PushTarget(),0,NOT_TABLE); + _fs->addInstruction(_OP_NEWOBJ, _fs->pushTarget(),0,NOT_TABLE); Lex();ParseTableOrClass(_SC(','),_SC('}')); break; case TK_FUNCTION: FunctionExp(_token);break; @@ -852,62 +852,62 @@ public: case _SC('-'): Lex(); switch(_token) { - case TK_INTEGER: EmitLoadConstInt(-_lex._nvalue,-1); Lex(); break; - case TK_FLOAT: EmitLoadConstFloat(-_lex._fvalue,-1); Lex(); break; + case TK_INTEGER: EmitloadConstInt(-_lex._nvalue,-1); Lex(); break; + case TK_FLOAT: EmitloadConstFloat(-_lex._fvalue,-1); Lex(); break; default: UnaryOP(_OP_NEG); } break; case _SC('!'): Lex(); UnaryOP(_OP_NOT); break; case _SC('~'): Lex(); - if(_token == TK_INTEGER) { EmitLoadConstInt(~_lex._nvalue,-1); Lex(); break; } + if(_token == TK_INTEGER) { EmitloadConstInt(~_lex._nvalue,-1); Lex(); break; } UnaryOP(_OP_BWNOT); break; case TK_TYPEOF : Lex() ;UnaryOP(_OP_TYPEOF); break; case TK_RESUME : Lex(); UnaryOP(_OP_RESUME); break; case TK_CLONE : Lex(); UnaryOP(_OP_CLONE); break; - case TK_RAWCALL: Lex(); Expect('('); FunctionCallArgs(true); break; + case TK_RAWCALL: Lex(); Expect('('); FunctioncallArgs(true); break; case TK_MINUSMINUS : case TK_PLUSPLUS :PrefixIncDec(_token); break; case TK_DELETE : DeleteExpr(); break; case _SC('('): Lex(); CommaExpr(); Expect(_SC(')')); break; - case TK___LINE__: EmitLoadConstInt(_lex._currentline,-1); Lex(); break; - case TK___FILE__: _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(_sourcename)); Lex(); break; - default: Error(_SC("expression expected")); + case TK___LINE__: EmitloadConstInt(_lex._currentline,-1); Lex(); break; + case TK___FILE__: _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(_sourcename)); Lex(); break; + default: error(_SC("expression expected")); } _es.etype = EXPR; return -1; } - void EmitLoadConstInt(int64_t value,int64_t target) + void EmitloadConstInt(int64_t value,int64_t target) { if(target < 0) { - target = _fs->PushTarget(); + target = _fs->pushTarget(); } if(value <= INT_MAX && value > INT_MIN) { //does it fit in 32 bits? - _fs->AddInstruction(_OP_LOADINT, target,value); + _fs->addInstruction(_OP_LOADINT, target,value); } else { - _fs->AddInstruction(_OP_LOAD, target, _fs->getNumericConstant(value)); + _fs->addInstruction(_OP_LOAD, target, _fs->getNumericConstant(value)); } } - void EmitLoadConstFloat(float_t value,int64_t target) + void EmitloadConstFloat(float_t value,int64_t target) { if(target < 0) { - target = _fs->PushTarget(); + target = _fs->pushTarget(); } if(sizeof(float_t) == sizeof(int32_t)) { - _fs->AddInstruction(_OP_LOADFLOAT, target,*((int32_t *)&value)); + _fs->addInstruction(_OP_LOADFLOAT, target,*((int32_t *)&value)); } else { - _fs->AddInstruction(_OP_LOAD, target, _fs->getNumericConstant(value)); + _fs->addInstruction(_OP_LOAD, target, _fs->getNumericConstant(value)); } } void UnaryOP(SQOpcode op) { PrefixedExpr(); - int64_t src = _fs->PopTarget(); - _fs->AddInstruction(op, _fs->PushTarget(), src); + int64_t src = _fs->popTarget(); + _fs->addInstruction(op, _fs->pushTarget(), src); } bool Needget() { @@ -923,27 +923,27 @@ public: } return (!_es.donot_get || ( _es.donot_get && (_token == _SC('.') || _token == _SC('[')))); } - void FunctionCallArgs(bool rawcall = false) + void FunctioncallArgs(bool rawcall = false) { int64_t nargs = 1;//this while(_token != _SC(')')) { Expression(); - MoveIfCurrentTargetIsLocal(); + MoveIfCurrentTargetisLocal(); nargs++; if(_token == _SC(',')){ Lex(); - if(_token == ')') Error(_SC("expression expected, found ')'")); + if(_token == ')') error(_SC("expression expected, found ')'")); } } Lex(); if (rawcall) { - if (nargs < 3) Error(_SC("rawcall requires at least 2 parameters (callee and this)")); + if (nargs < 3) error(_SC("rawcall requires at least 2 parameters (callee and this)")); nargs -= 2; //removes callee and this from count } - for(int64_t i = 0; i < (nargs - 1); i++) _fs->PopTarget(); - int64_t stackbase = _fs->PopTarget(); - int64_t closure = _fs->PopTarget(); - _fs->AddInstruction(_OP_CALL, _fs->PushTarget(), closure, stackbase, nargs); + for(int64_t i = 0; i < (nargs - 1); i++) _fs->popTarget(); + int64_t stackbase = _fs->popTarget(); + int64_t closure = _fs->popTarget(); + _fs->addInstruction(_OP_CALL, _fs->pushTarget(), closure, stackbase, nargs); } void ParseTableOrClass(int64_t separator,int64_t terminator) { @@ -954,7 +954,7 @@ public: //check if is an attribute if(separator == ';') { if(_token == TK_ATTR_OPEN) { - _fs->AddInstruction(_OP_NEWOBJ, _fs->PushTarget(),0,NOT_TABLE); Lex(); + _fs->addInstruction(_OP_NEWOBJ, _fs->pushTarget(),0,NOT_TABLE); Lex(); ParseTableOrClass(',',TK_ATTR_CLOSE); hasattrs = true; } @@ -970,9 +970,9 @@ public: Lex(); SQObject id = tk == TK_FUNCTION ? Expect(TK_IDENTIFIER) : _fs->createString(_SC("constructor")); Expect(_SC('(')); - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(id)); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(id)); createFunction(id); - _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0); + _fs->addInstruction(_OP_CLOSURE, _fs->pushTarget(), _fs->_functions.size() - 1, 0); } break; case _SC('['): @@ -981,28 +981,28 @@ public: break; case TK_STRING_LITERAL: //JSON if(separator == ',') { //only works for tables - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(Expect(TK_STRING_LITERAL))); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(Expect(TK_STRING_LITERAL))); Expect(_SC(':')); Expression(); break; } default : - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(Expect(TK_IDENTIFIER))); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(Expect(TK_IDENTIFIER))); Expect(_SC('=')); Expression(); } if(_token == separator) Lex();//optional comma/semicolon nkeys++; - int64_t val = _fs->PopTarget(); - int64_t key = _fs->PopTarget(); - int64_t attrs = hasattrs ? _fs->PopTarget():-1; + int64_t val = _fs->popTarget(); + int64_t key = _fs->popTarget(); + int64_t attrs = hasattrs ? _fs->popTarget():-1; ((void)attrs); assert((hasattrs && (attrs == key-1)) || !hasattrs); unsigned char flags = (hasattrs?NEW_SLOT_ATTRIBUTES_FLAG:0)|(isstatic?NEW_SLOT_STATIC_FLAG:0); int64_t table = _fs->topTarget(); //<AddInstruction(_OP_NEWSLOT, 0xFF, table, key, val); + _fs->addInstruction(_OP_NEWSLOT, 0xFF, table, key, val); } else { - _fs->AddInstruction(_OP_NEWSLOTA, flags, table, key, val); //this for classes only as it invokes _newmember + _fs->addInstruction(_OP_NEWSLOTA, flags, table, key, val); //this for classes only as it invokes _newmember } } if(separator == _SC(',')) //hack recognizes a table from the separator @@ -1018,9 +1018,9 @@ public: varname = Expect(TK_IDENTIFIER); Expect(_SC('(')); createFunction(varname,false); - _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0); - _fs->PopTarget(); - _fs->PushLocalVariable(varname); + _fs->addInstruction(_OP_CLOSURE, _fs->pushTarget(), _fs->_functions.size() - 1, 0); + _fs->popTarget(); + _fs->pushLocalVariable(varname); return; } @@ -1028,15 +1028,15 @@ public: varname = Expect(TK_IDENTIFIER); if(_token == _SC('=')) { Lex(); Expression(); - int64_t src = _fs->PopTarget(); - int64_t dest = _fs->PushTarget(); - if(dest != src) _fs->AddInstruction(_OP_MOVE, dest, src); + int64_t src = _fs->popTarget(); + int64_t dest = _fs->pushTarget(); + if(dest != src) _fs->addInstruction(_OP_MOVE, dest, src); } else{ - _fs->AddInstruction(_OP_LOADNULLS, _fs->PushTarget(),1); + _fs->addInstruction(_OP_LOADNULLS, _fs->pushTarget(),1); } - _fs->PopTarget(); - _fs->PushLocalVariable(varname); + _fs->popTarget(); + _fs->pushLocalVariable(varname); if(_token == _SC(',')) Lex(); else break; } while(1); } @@ -1067,7 +1067,7 @@ public: int64_t jmppos; bool haselse = false; Lex(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')')); - _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); + _fs->addInstruction(_OP_JZ, _fs->popTarget()); int64_t jnepos = _fs->getCurrentPos(); @@ -1090,7 +1090,7 @@ public: if(_token == TK_ELSE){ haselse = true; //BEGIN_SCOPE(); - _fs->AddInstruction(_OP_JMP); + _fs->addInstruction(_OP_JMP); jmppos = _fs->getCurrentPos(); Lex(); //Statement(); if(_lex._prevtoken != _SC('}')) OptionalSemicolon(); @@ -1107,14 +1107,14 @@ public: Lex(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')')); BEGIN_BREAKBLE_BLOCK(); - _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); + _fs->addInstruction(_OP_JZ, _fs->popTarget()); jzpos = _fs->getCurrentPos(); BEGIN_SCOPE(); Statement(); END_SCOPE(); - _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1); + _fs->addInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1); _fs->setIntructionParam(jzpos, 1, _fs->getCurrentPos() - jzpos); END_BREAKBLE_BLOCK(jmppos); @@ -1130,8 +1130,8 @@ public: Expect(TK_WHILE); int64_t continuetrg = _fs->getCurrentPos(); Expect(_SC('(')); CommaExpr(); Expect(_SC(')')); - _fs->AddInstruction(_OP_JZ, _fs->PopTarget(), 1); - _fs->AddInstruction(_OP_JMP, 0, jmptrg - _fs->getCurrentPos() - 1); + _fs->addInstruction(_OP_JZ, _fs->popTarget(), 1); + _fs->addInstruction(_OP_JMP, 0, jmptrg - _fs->getCurrentPos() - 1); END_BREAKBLE_BLOCK(continuetrg); } void ForStatement() @@ -1142,38 +1142,38 @@ public: if(_token == TK_LOCAL) LocalDeclStatement(); else if(_token != _SC(';')){ CommaExpr(); - _fs->PopTarget(); + _fs->popTarget(); } Expect(_SC(';')); - _fs->SnoozeOpt(); + _fs->snoozeOpt(); int64_t jmppos = _fs->getCurrentPos(); int64_t jzpos = -1; - if(_token != _SC(';')) { CommaExpr(); _fs->AddInstruction(_OP_JZ, _fs->PopTarget()); jzpos = _fs->getCurrentPos(); } + if(_token != _SC(';')) { CommaExpr(); _fs->addInstruction(_OP_JZ, _fs->popTarget()); jzpos = _fs->getCurrentPos(); } Expect(_SC(';')); - _fs->SnoozeOpt(); + _fs->snoozeOpt(); int64_t expstart = _fs->getCurrentPos() + 1; if(_token != _SC(')')) { CommaExpr(); - _fs->PopTarget(); + _fs->popTarget(); } Expect(_SC(')')); - _fs->SnoozeOpt(); + _fs->snoozeOpt(); int64_t expend = _fs->getCurrentPos(); int64_t expsize = (expend - expstart) + 1; SQInstructionVec exp; if(expsize > 0) { for(int64_t i = 0; i < expsize; i++) exp.push_back(_fs->getInstruction(expstart + i)); - _fs->PopInstructions(expsize); + _fs->popInstructions(expsize); } BEGIN_BREAKBLE_BLOCK() Statement(); int64_t continuetrg = _fs->getCurrentPos(); if(expsize > 0) { for(int64_t i = 0; i < expsize; i++) - _fs->AddInstruction(exp[i]); + _fs->addInstruction(exp[i]); } - _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1, 0); + _fs->addInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1, 0); if(jzpos> 0) _fs->setIntructionParam(jzpos, 1, _fs->getCurrentPos() - jzpos); END_BREAKBLE_BLOCK(continuetrg); @@ -1199,27 +1199,27 @@ public: Expression(); Expect(_SC(')')); int64_t container = _fs->topTarget(); //push the index local var - int64_t indexpos = _fs->PushLocalVariable(idxname); - _fs->AddInstruction(_OP_LOADNULLS, indexpos,1); + int64_t indexpos = _fs->pushLocalVariable(idxname); + _fs->addInstruction(_OP_LOADNULLS, indexpos,1); //push the value local var - int64_t valuepos = _fs->PushLocalVariable(valname); - _fs->AddInstruction(_OP_LOADNULLS, valuepos,1); + int64_t valuepos = _fs->pushLocalVariable(valname); + _fs->addInstruction(_OP_LOADNULLS, valuepos,1); //push reference index - int64_t itrpos = _fs->PushLocalVariable(_fs->createString(_SC("@ITERATOR@"))); //use invalid id to make it inaccessible - _fs->AddInstruction(_OP_LOADNULLS, itrpos,1); + int64_t itrpos = _fs->pushLocalVariable(_fs->createString(_SC("@ITERATOR@"))); //use invalid id to make it inaccessible + _fs->addInstruction(_OP_LOADNULLS, itrpos,1); int64_t jmppos = _fs->getCurrentPos(); - _fs->AddInstruction(_OP_FOREACH, container, 0, indexpos); + _fs->addInstruction(_OP_FOREACH, container, 0, indexpos); int64_t foreachpos = _fs->getCurrentPos(); - _fs->AddInstruction(_OP_POSTFOREACH, container, 0, indexpos); + _fs->addInstruction(_OP_POSTFOREACH, container, 0, indexpos); //generate the statement code BEGIN_BREAKBLE_BLOCK() Statement(); - _fs->AddInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1); + _fs->addInstruction(_OP_JMP, 0, jmppos - _fs->getCurrentPos() - 1); _fs->setIntructionParam(foreachpos, 1, _fs->getCurrentPos() - foreachpos); _fs->setIntructionParam(foreachpos + 1, 1, _fs->getCurrentPos() - foreachpos); END_BREAKBLE_BLOCK(foreachpos - 1); //restore the local variable stack(remove index,val and ref idx) - _fs->PopTarget(); + _fs->popTarget(); END_SCOPE(); } void SwitchStatement() @@ -1234,22 +1234,22 @@ public: _fs->_breaktargets.push_back(0); while(_token == TK_CASE) { if(!bfirst) { - _fs->AddInstruction(_OP_JMP, 0, 0); + _fs->addInstruction(_OP_JMP, 0, 0); skipcondjmp = _fs->getCurrentPos(); _fs->setIntructionParam(tonextcondjmp, 1, _fs->getCurrentPos() - tonextcondjmp); } //condition Lex(); Expression(); Expect(_SC(':')); - int64_t trg = _fs->PopTarget(); + int64_t trg = _fs->popTarget(); int64_t eqtarget = trg; - bool local = _fs->IsLocal(trg); + bool local = _fs->isLocal(trg); if(local) { - eqtarget = _fs->PushTarget(); //we need to allocate a extra reg + eqtarget = _fs->pushTarget(); //we need to allocate a extra reg } - _fs->AddInstruction(_OP_EQ, eqtarget, trg, expr); - _fs->AddInstruction(_OP_JZ, eqtarget, 0); + _fs->addInstruction(_OP_EQ, eqtarget, trg, expr); + _fs->addInstruction(_OP_JZ, eqtarget, 0); if(local) { - _fs->PopTarget(); + _fs->popTarget(); } //end condition @@ -1271,7 +1271,7 @@ public: END_SCOPE(); } Expect(_SC('}')); - _fs->PopTarget(); + _fs->popTarget(); __nbreaks__ = _fs->_unresolvedbreaks.size() - __nbreaks__; if(__nbreaks__ > 0)ResolveBreaks(_fs, __nbreaks__); _fs->_breaktargets.pop_back(); @@ -1280,21 +1280,21 @@ public: { SQObject id; Lex(); id = Expect(TK_IDENTIFIER); - _fs->PushTarget(0); - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(id)); + _fs->pushTarget(0); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(id)); if(_token == TK_DOUBLE_COLON) Emit2ArgsOP(_OP_GET); while(_token == TK_DOUBLE_COLON) { Lex(); id = Expect(TK_IDENTIFIER); - _fs->AddInstruction(_OP_LOAD, _fs->PushTarget(), _fs->getConstant(id)); + _fs->addInstruction(_OP_LOAD, _fs->pushTarget(), _fs->getConstant(id)); if(_token == TK_DOUBLE_COLON) Emit2ArgsOP(_OP_GET); } Expect(_SC('(')); createFunction(id); - _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, 0); + _fs->addInstruction(_OP_CLOSURE, _fs->pushTarget(), _fs->_functions.size() - 1, 0); EmitDerefOp(_OP_NEWSLOT); - _fs->PopTarget(); + _fs->popTarget(); } void ClassStatement() { @@ -1304,15 +1304,15 @@ public: _es.donot_get = true; PrefixedExpr(); if(_es.etype == EXPR) { - Error(_SC("invalid class name")); + error(_SC("invalid class name")); } else if(_es.etype == OBJECT || _es.etype == BASE) { ClassExp(); EmitDerefOp(_OP_NEWSLOT); - _fs->PopTarget(); + _fs->popTarget(); } else { - Error(_SC("cannot create a class in a local with the syntax(class )")); + error(_SC("cannot create a class in a local with the syntax(class )")); } _es = es; } @@ -1350,11 +1350,11 @@ public: val._unVal.fFloat = -_lex._fvalue; break; default: - Error(_SC("scalar expected : integer, float")); + error(_SC("scalar expected : integer, float")); } break; default: - Error(_SC("scalar expected : integer, float, or string")); + error(_SC("scalar expected : integer, float, or string")); } Lex(); return val; @@ -1378,12 +1378,12 @@ public: val._type = OT_INTEGER; val._unVal.nInteger = nval++; } - _table(table)->NewSlot(SQObjectPtr(key),SQObjectPtr(val)); + _table(table)->newSlot(SQObjectPtr(key),SQObjectPtr(val)); if(_token == ',') Lex(); } SQTable *enums = _table(_ss(_vm)->_consts); SQObjectPtr strongid = id; - enums->NewSlot(SQObjectPtr(strongid),SQObjectPtr(table)); + enums->newSlot(SQObjectPtr(strongid),SQObjectPtr(table)); strongid.Null(); Lex(); } @@ -1391,7 +1391,7 @@ public: { SQObject exid; Lex(); - _fs->AddInstruction(_OP_PUSHTRAP,0,0); + _fs->addInstruction(_OP_PUSHTRAP,0,0); _fs->_traps++; if(_fs->_breaktargets.size()) _fs->_breaktargets.top()++; if(_fs->_continuetargets.size()) _fs->_continuetargets.top()++; @@ -1402,16 +1402,16 @@ public: END_SCOPE(); } _fs->_traps--; - _fs->AddInstruction(_OP_POPTRAP, 1, 0); + _fs->addInstruction(_OP_POPTRAP, 1, 0); if(_fs->_breaktargets.size()) _fs->_breaktargets.top()--; if(_fs->_continuetargets.size()) _fs->_continuetargets.top()--; - _fs->AddInstruction(_OP_JMP, 0, 0); + _fs->addInstruction(_OP_JMP, 0, 0); int64_t jmppos = _fs->getCurrentPos(); _fs->setIntructionParam(trappos, 1, (_fs->getCurrentPos() - trappos)); Expect(TK_CATCH); Expect(_SC('(')); exid = Expect(TK_IDENTIFIER); Expect(_SC(')')); { BEGIN_SCOPE(); - int64_t ex_target = _fs->PushLocalVariable(exid); + int64_t ex_target = _fs->pushLocalVariable(exid); _fs->setIntructionParam(trappos, 0, ex_target); Statement(); _fs->setIntructionParams(jmppos, 0, (_fs->getCurrentPos() - jmppos), 0); @@ -1423,7 +1423,7 @@ public: Lex(); Expect(_SC('(')); SQObjectPtr dummy; createFunction(dummy,lambda); - _fs->AddInstruction(_OP_CLOSURE, _fs->PushTarget(), _fs->_functions.size() - 1, ftype == TK_FUNCTION?0:1); + _fs->addInstruction(_OP_CLOSURE, _fs->pushTarget(), _fs->_functions.size() - 1, ftype == TK_FUNCTION?0:1); } void ClassExp() { @@ -1435,14 +1435,14 @@ public: } if(_token == TK_ATTR_OPEN) { Lex(); - _fs->AddInstruction(_OP_NEWOBJ, _fs->PushTarget(),0,NOT_TABLE); + _fs->addInstruction(_OP_NEWOBJ, _fs->pushTarget(),0,NOT_TABLE); ParseTableOrClass(_SC(','),TK_ATTR_CLOSE); attrs = _fs->topTarget(); } Expect(_SC('{')); - if(attrs != -1) _fs->PopTarget(); - if(base != -1) _fs->PopTarget(); - _fs->AddInstruction(_OP_NEWOBJ, _fs->PushTarget(), base, attrs,NOT_CLASS); + if(attrs != -1) _fs->popTarget(); + if(base != -1) _fs->popTarget(); + _fs->addInstruction(_OP_NEWOBJ, _fs->pushTarget(), base, attrs,NOT_CLASS); ParseTableOrClass(_SC(';'),_SC('}')); } void DeleteExpr() @@ -1452,12 +1452,12 @@ public: es = _es; _es.donot_get = true; PrefixedExpr(); - if(_es.etype==EXPR) Error(_SC("can't delete an expression")); + if(_es.etype==EXPR) error(_SC("can't delete an expression")); if(_es.etype==OBJECT || _es.etype==BASE) { Emit2ArgsOP(_OP_DELETE); } else { - Error(_SC("cannot delete an (outer) local")); + error(_SC("cannot delete an (outer) local")); } _es = es; } @@ -1470,81 +1470,81 @@ public: _es.donot_get = true; PrefixedExpr(); if(_es.etype==EXPR) { - Error(_SC("can't '++' or '--' an expression")); + error(_SC("can't '++' or '--' an expression")); } else if(_es.etype==OBJECT || _es.etype==BASE) { Emit2ArgsOP(_OP_INC, diff); } else if(_es.etype==LOCAL) { int64_t src = _fs->topTarget(); - _fs->AddInstruction(_OP_INCL, src, src, 0, diff); + _fs->addInstruction(_OP_INCL, src, src, 0, diff); } else if(_es.etype==OUTER) { - int64_t tmp = _fs->PushTarget(); - _fs->AddInstruction(_OP_GETOUTER, tmp, _es.epos); - _fs->AddInstruction(_OP_INCL, tmp, tmp, 0, diff); - _fs->AddInstruction(_OP_SETOUTER, tmp, _es.epos, tmp); + int64_t tmp = _fs->pushTarget(); + _fs->addInstruction(_OP_GETOUTER, tmp, _es.epos); + _fs->addInstruction(_OP_INCL, tmp, tmp, 0, diff); + _fs->addInstruction(_OP_SETOUTER, tmp, _es.epos, tmp); } _es = es; } void createFunction(SQObject &name,bool lambda = false) { - SQFuncState *funcstate = _fs->PushChildState(_ss(_vm)); + SQFuncState *funcstate = _fs->pushChildState(_ss(_vm)); funcstate->_name = name; SQObject paramname; - funcstate->AddParameter(_fs->createString(_SC("this"))); + funcstate->addParameter(_fs->createString(_SC("this"))); funcstate->_sourcename = _sourcename; int64_t defparams = 0; while(_token!=_SC(')')) { if(_token == TK_VARPARAMS) { - if(defparams > 0) Error(_SC("function with default parameters cannot have variable number of parameters")); - funcstate->AddParameter(_fs->createString(_SC("vargv"))); + if(defparams > 0) error(_SC("function with default parameters cannot have variable number of parameters")); + funcstate->addParameter(_fs->createString(_SC("vargv"))); funcstate->_varparams = true; Lex(); - if(_token != _SC(')')) Error(_SC("expected ')'")); + if(_token != _SC(')')) error(_SC("expected ')'")); break; } else { paramname = Expect(TK_IDENTIFIER); - funcstate->AddParameter(paramname); + funcstate->addParameter(paramname); if(_token == _SC('=')) { Lex(); Expression(); - funcstate->AddDefaultParam(_fs->topTarget()); + funcstate->addDefaultParam(_fs->topTarget()); defparams++; } else { - if(defparams > 0) Error(_SC("expected '='")); + if(defparams > 0) error(_SC("expected '='")); } if(_token == _SC(',')) Lex(); - else if(_token != _SC(')')) Error(_SC("expected ')' or ','")); + else if(_token != _SC(')')) error(_SC("expected ')' or ','")); } } Expect(_SC(')')); for(int64_t n = 0; n < defparams; n++) { - _fs->PopTarget(); + _fs->popTarget(); } SQFuncState *currchunk = _fs; _fs = funcstate; if(lambda) { Expression(); - _fs->AddInstruction(_OP_RETURN, 1, _fs->PopTarget());} + _fs->addInstruction(_OP_RETURN, 1, _fs->popTarget());} else { Statement(false); } - funcstate->AddLineInfos(_lex._prevtoken == _SC('\n')?_lex._lasttokenline:_lex._currentline, _lineinfo, true); - funcstate->AddInstruction(_OP_RETURN, -1); + funcstate->addLineInfos(_lex._prevtoken == _SC('\n')?_lex._lasttokenline:_lex._currentline, _lineinfo, true); + funcstate->addInstruction(_OP_RETURN, -1); funcstate->setStacksize(0); - SQFunctionProto *func = funcstate->BuildProto(); + SQFunctionProto *func = funcstate->buildProto(); #ifdef _DEBUG_DUMP - funcstate->Dump(func); + funcstate->dump(func); #endif _fs = currchunk; _fs->_functions.push_back(func); - _fs->PopChildState(); + _fs->popChildState(); } void ResolveBreaks(SQFuncState *funcstate, int64_t ntoresolve) { @@ -1582,10 +1582,10 @@ private: SQVM *_vm; }; -bool Compile(SQVM *vm,SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo) +bool compile(SQVM *vm,SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo) { - SQCompiler p(vm, rg, up, sourcename, raiseerror, lineinfo); - return p.Compile(out); + SQcompiler p(vm, rg, up, sourcename, raiseerror, lineinfo); + return p.compile(out); } #endif diff --git a/rabbit/sqcompiler.hpp b/rabbit/sqcompiler.hpp index b63d825..cf9bbb8 100644 --- a/rabbit/sqcompiler.hpp +++ b/rabbit/sqcompiler.hpp @@ -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); diff --git a/rabbit/sqdebug.cpp b/rabbit/sqdebug.cpp index 2eba343..e1cd025 100644 --- a/rabbit/sqdebug.cpp +++ b/rabbit/sqdebug.cpp @@ -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)); } diff --git a/rabbit/sqfuncproto.hpp b/rabbit/sqfuncproto.hpp index 73f631c..6f958af 100644 --- a/rabbit/sqfuncproto.hpp +++ b/rabbit/sqfuncproto.hpp @@ -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; diff --git a/rabbit/sqfuncstate.cpp b/rabbit/sqfuncstate.cpp index 0678a59..ba8f514 100644 --- a/rabbit/sqfuncstate.cpp +++ b/rabbit/sqfuncstate.cpp @@ -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;inext(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(); } } diff --git a/rabbit/sqfuncstate.hpp b/rabbit/sqfuncstate.hpp index 2f39d92..08ef24e 100644 --- a/rabbit/sqfuncstate.hpp +++ b/rabbit/sqfuncstate.hpp @@ -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 _childstates; int64_t getConstant(const SQObject &cons); private: - CompilerErrorFunc _errfunc; + compilererrorFunc _errfunc; void *_errtarget; SQSharedState *_ss; }; diff --git a/rabbit/sqlexer.cpp b/rabbit/sqlexer.cpp index c6df1b9..6cb6b1e 100644 --- a/rabbit/sqlexer.cpp +++ b/rabbit/sqlexer.cpp @@ -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(); diff --git a/rabbit/sqlexer.hpp b/rabbit/sqlexer.hpp index 41d52a2..9d7cf48 100644 --- a/rabbit/sqlexer.hpp +++ b/rabbit/sqlexer.hpp @@ -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 _longstr; - CompilerErrorFunc _errfunc; + compilererrorFunc _errfunc; void *_errtarget; }; diff --git a/rabbit/sqobject.cpp b/rabbit/sqobject.cpp index ea65863..d4071f1 100644 --- a/rabbit/sqobject.cpp +++ b/rabbit/sqobject.cpp @@ -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;iSave(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))); diff --git a/rabbit/sqobject.hpp b/rabbit/sqobject.hpp index 6ab20a2..ec9942e 100644 --- a/rabbit/sqobject.hpp +++ b/rabbit/sqobject.hpp @@ -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; } diff --git a/rabbit/sqopcodes.hpp b/rabbit/sqopcodes.hpp index 8c0d732..d3c0fdc 100644 --- a/rabbit/sqopcodes.hpp +++ b/rabbit/sqopcodes.hpp @@ -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 { diff --git a/rabbit/sqstate.cpp b/rabbit/sqstate.cpp index 06ecef7..0eb8a0b 100644 --- a/rabbit/sqstate.cpp +++ b/rabbit/sqstate.cpp @@ -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_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); diff --git a/rabbit/sqtable.cpp b/rabbit/sqtable.cpp index 934d9b5..910dd1c 100644 --- a/rabbit/sqtable.cpp +++ b/rabbit/sqtable.cpp @@ -12,11 +12,11 @@ #include #include -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= 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; ikey) != OT_NULL) - NewSlot(old->key,old->val); + newSlot(old->key,old->val); } for(int64_t k=0;kNewSlot(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); } diff --git a/rabbit/sqtable.hpp b/rabbit/sqtable.hpp index 111818e..f37a3ec 100644 --- a/rabbit/sqtable.hpp +++ b/rabbit/sqtable.hpp @@ -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); diff --git a/rabbit/sqvm.cpp b/rabbit/sqvm.cpp index 73fc62a..a1ca856 100644 --- a/rabbit/sqvm.cpp +++ b/rabbit/sqvm.cpp @@ -35,10 +35,10 @@ bool SQVM::BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObje case BW_SHIFTL: res = i1 << i2; break; case BW_SHIFTR: res = i1 >> i2; break; case BW_USHIFTR:res = (int64_t)(*((uint64_t*)&i1) >> i2); break; - default: { Raise_Error(_SC("internal vm error bitwise op failed")); return false; } + default: { raise_error(_SC("internal vm error bitwise op failed")); return false; } } } - else { Raise_Error(_SC("bitwise op between '%s' and '%s'"),getTypeName(o1),getTypeName(o2)); return false;} + else { raise_error(_SC("bitwise op between '%s' and '%s'"),getTypeName(o1),getTypeName(o2)); return false;} trg = res; return true; } @@ -58,7 +58,7 @@ bool SQVM::BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObje { \ int64_t tmask = sq_type(o1)|sq_type(o2); \ switch(tmask) { \ - case OT_INTEGER: { int64_t i2 = _integer(o2); if(i2 == 0) { Raise_Error(err); SQ_THROW(); } trg = _integer(o1) op i2; } break;\ + case OT_INTEGER: { int64_t i2 = _integer(o2); if(i2 == 0) { raise_error(err); SQ_THROW(); } trg = _integer(o1) op i2; } break;\ case (OT_FLOAT|OT_INTEGER): \ case (OT_FLOAT): trg = tofloat(o1) op tofloat(o2); break;\ default: _GUARD(ARITH_OP((#op)[0],trg,o1,o2)); break;\ @@ -74,12 +74,12 @@ bool SQVM::ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQO switch(op) { case '+': res = i1 + i2; break; case '-': res = i1 - i2; break; - case '/': if (i2 == 0) { Raise_Error(_SC("division by zero")); return false; } - else if (i2 == -1 && i1 == INT_MIN) { Raise_Error(_SC("integer overflow")); return false; } + case '/': if (i2 == 0) { raise_error(_SC("division by zero")); return false; } + else if (i2 == -1 && i1 == INT_MIN) { raise_error(_SC("integer overflow")); return false; } res = i1 / i2; break; case '*': res = i1 * i2; break; - case '%': if (i2 == 0) { Raise_Error(_SC("modulo by zero")); return false; } + case '%': if (i2 == 0) { raise_error(_SC("modulo by zero")); return false; } else if (i2 == -1 && i1 == INT_MIN) { res = 0; break; } res = i1 % i2; break; @@ -102,9 +102,9 @@ bool SQVM::ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQO break; default: if(op == '+' && (tmask & _RT_STRING)){ - if(!StringCat(o1, o2, trg)) return false; + if(!stringCat(o1, o2, trg)) return false; } - else if(!ArithMetaMethod(op,o1,o2,trg)) { + else if(!arithMetaMethod(op,o1,o2,trg)) { return false; } } @@ -131,10 +131,10 @@ SQVM::SQVM(SQSharedState *ss) _releasehook = NULL; } -void SQVM::Finalize() +void SQVM::finalize() { if(_releasehook) { _releasehook(_foreignptr,0); _releasehook = NULL; } - if(_openouters) CloseOuters(&_stack._vals[0]); + if(_openouters) closeOuters(&_stack._vals[0]); _roottable.Null(); _lasterror.Null(); _errorhandler.Null(); @@ -150,10 +150,10 @@ void SQVM::Finalize() SQVM::~SQVM() { - Finalize(); + finalize(); } -bool SQVM::ArithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &dest) +bool SQVM::arithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &dest) { SQMetaMethod mm; switch(op){ @@ -168,11 +168,12 @@ bool SQVM::ArithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o SQObjectPtr closure; if(_delegable(o1)->getMetaMethod(this, mm, closure)) { - Push(o1);Push(o2); - return CallMetaMethod(closure,mm,2,dest); + push(o1); + push(o2); + return callMetaMethod(closure,mm,2,dest); } } - Raise_Error(_SC("arith op %c on between '%s' and '%s'"),op,getTypeName(o1),getTypeName(o2)); + raise_error(_SC("arith op %c on between '%s' and '%s'"),op,getTypeName(o1),getTypeName(o2)); return false; } @@ -192,8 +193,8 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o) if(_delegable(o)->_delegate) { SQObjectPtr closure; if(_delegable(o)->getMetaMethod(this, MT_UNM, closure)) { - Push(o); - if(!CallMetaMethod(closure, MT_UNM, 1, temp_reg)) return false; + push(o); + if(!callMetaMethod(closure, MT_UNM, 1, temp_reg)) return false; _Swap(trg,temp_reg); return true; @@ -201,12 +202,12 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o) } default:break; //shutup compiler } - Raise_Error(_SC("attempt to negate a %s"), getTypeName(o)); + raise_error(_SC("attempt to negate a %s"), getTypeName(o)); return false; } #define _RET_SUCCEED(exp) { result = (exp); return true; } -bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) +bool SQVM::objCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) { SQObjectType t1 = sq_type(o1), t2 = sq_type(o2); if(t1 == t2) { @@ -225,10 +226,10 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) if(_delegable(o1)->_delegate) { SQObjectPtr closure; if(_delegable(o1)->getMetaMethod(this, MT_CMP, closure)) { - Push(o1);Push(o2); - if(CallMetaMethod(closure,MT_CMP,2,res)) { + push(o1);push(o2); + if(callMetaMethod(closure,MT_CMP,2,res)) { if(sq_type(res) != OT_INTEGER) { - Raise_Error(_SC("_cmp must return an integer")); + raise_error(_SC("_cmp must return an integer")); return false; } _RET_SUCCEED(_integer(res)) @@ -241,7 +242,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) _RET_SUCCEED( _userpointer(o1) < _userpointer(o2)?-1:1 ); } assert(0); - //if(type(res)!=OT_INTEGER) { Raise_CompareError(o1,o2); return false; } + //if(type(res)!=OT_INTEGER) { raise_Compareerror(o1,o2); return false; } // _RET_SUCCEED(_integer(res)); } @@ -260,7 +261,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) } else if(t1==OT_NULL) {_RET_SUCCEED(-1);} else if(t2==OT_NULL) {_RET_SUCCEED(1);} - else { Raise_CompareError(o1,o2); return false; } + else { raise_Compareerror(o1,o2); return false; } } assert(0); @@ -270,7 +271,7 @@ bool SQVM::ObjCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result) bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res) { int64_t r; - if(ObjCmp(o1,o2,r)) { + if(objCmp(o1,o2,r)) { switch(op) { case CMP_G: res = (r > 0); return true; case CMP_GE: res = (r >= 0); return true; @@ -283,7 +284,7 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject return false; } -bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) +bool SQVM::toString(const SQObjectPtr &o,SQObjectPtr &res) { switch(sq_type(o)) { case OT_STRING: @@ -304,8 +305,8 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) if(_delegable(o)->_delegate) { SQObjectPtr closure; if(_delegable(o)->getMetaMethod(this, MT_TOSTRING, closure)) { - Push(o); - if(CallMetaMethod(closure,MT_TOSTRING,1,res)) { + push(o); + if(callMetaMethod(closure,MT_TOSTRING,1,res)) { if(sq_type(res) == OT_STRING) return true; } @@ -322,11 +323,11 @@ bool SQVM::ToString(const SQObjectPtr &o,SQObjectPtr &res) } -bool SQVM::StringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &dest) +bool SQVM::stringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &dest) { SQObjectPtr a, b; - if(!ToString(str, a)) return false; - if(!ToString(obj, b)) return false; + if(!toString(str, a)) return false; + if(!toString(obj, b)) return false; int64_t l = _string(a)->_len , ol = _string(b)->_len; SQChar *s = _sp(sq_rsl(l + ol + 1)); memcpy(s, _stringval(a), sq_rsl(l)); @@ -335,20 +336,20 @@ bool SQVM::StringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr & return true; } -bool SQVM::TypeOf(const SQObjectPtr &obj1,SQObjectPtr &dest) +bool SQVM::typeOf(const SQObjectPtr &obj1,SQObjectPtr &dest) { if(is_delegable(obj1) && _delegable(obj1)->_delegate) { SQObjectPtr closure; if(_delegable(obj1)->getMetaMethod(this, MT_TYPEOF, closure)) { - Push(obj1); - return CallMetaMethod(closure,MT_TYPEOF,1,dest); + push(obj1); + return callMetaMethod(closure,MT_TYPEOF,1,dest); } } dest = SQString::create(_ss(this),getTypeName(obj1)); return true; } -bool SQVM::Init(SQVM *friendvm, int64_t stacksize) +bool SQVM::init(SQVM *friendvm, int64_t stacksize) { _stack.resize(stacksize); _alloccallsstacksize = 4; @@ -374,7 +375,7 @@ bool SQVM::Init(SQVM *friendvm, int64_t stacksize) } -bool SQVM::StartCall(SQClosure *closure,int64_t target,int64_t args,int64_t stackbase,bool tailcall) +bool SQVM::startcall(SQClosure *closure,int64_t target,int64_t args,int64_t stackbase,bool tailcall) { SQFunctionProto *func = closure->_function; @@ -385,7 +386,7 @@ bool SQVM::StartCall(SQClosure *closure,int64_t target,int64_t args,int64_t stac { paramssize--; if (nargs < paramssize) { - Raise_Error(_SC("wrong number of parameters")); + raise_error(_SC("wrong number of parameters")); return false; } @@ -411,7 +412,7 @@ bool SQVM::StartCall(SQClosure *closure,int64_t target,int64_t args,int64_t stac } } else { - Raise_Error(_SC("wrong number of parameters")); + raise_error(_SC("wrong number of parameters")); return false; } } @@ -420,7 +421,7 @@ bool SQVM::StartCall(SQClosure *closure,int64_t target,int64_t args,int64_t stac _stack._vals[stackbase] = closure->_env->_obj; } - if(!EnterFrame(stackbase, newtop, tailcall)) return false; + if(!enterFrame(stackbase, newtop, tailcall)) return false; ci->_closure = closure; ci->_literals = func->_literals; @@ -428,13 +429,13 @@ bool SQVM::StartCall(SQClosure *closure,int64_t target,int64_t args,int64_t stac ci->_target = (int32_t)target; if (_debughook) { - CallDebugHook(_SC('c')); + callDebugHook(_SC('c')); } if (closure->_function->_bgenerator) { SQFunctionProto *f = closure->_function; SQGenerator *gen = SQGenerator::create(_ss(this), closure); - if(!gen->Yield(this,f->_stacksize)) + if(!gen->yield(this,f->_stacksize)) return false; SQObjectPtr temp; Return(1, target, temp); @@ -452,7 +453,7 @@ bool SQVM::Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval) if (_debughook) { for(int64_t i=0; i_ncalls; i++) { - CallDebugHook(_SC('r')); + callDebugHook(_SC('r')); } } @@ -473,7 +474,7 @@ bool SQVM::Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval) } //*dest = (_arg0 != 0xFF) ? _stack._vals[_stackbase+_arg1] : _null_; } - LeaveFrame(); + leaveFrame(); return _isroot ? true : false; } @@ -488,7 +489,7 @@ bool SQVM::PLOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPt return true; } -bool SQVM::DerefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t selfidx) +bool SQVM::derefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t selfidx) { SQObjectPtr tmp, tself = self, tkey = key; if (!get(tself, tkey, tmp, 0, selfidx)) { return false; } @@ -540,13 +541,13 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr SQObjectPtr itr; SQObjectPtr closure; if(_delegable(o1)->getMetaMethod(this, MT_NEXTI, closure)) { - Push(o1); - Push(o4); - if(CallMetaMethod(closure, MT_NEXTI, 2, itr)) { + push(o1); + push(o4); + if(callMetaMethod(closure, MT_NEXTI, 2, itr)) { o4 = o2 = itr; if(sq_type(itr) == OT_NULL) _FINISH(exitpos); if(!get(o1, itr, o3, 0, DONT_FALL_BACK)) { - Raise_Error(_SC("_nexti returned an invalid idx")); // cloud be changed + raise_error(_SC("_nexti returned an invalid idx")); // cloud be changed return false; } _FINISH(1); @@ -555,7 +556,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr return false; } } - Raise_Error(_SC("_nexti failed")); + raise_error(_SC("_nexti failed")); return false; } break; @@ -568,11 +569,11 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr } o2 = idx; o4 = idx; - _generator(o1)->Resume(this, o3); + _generator(o1)->resume(this, o3); _FINISH(0); } default: - Raise_Error(_SC("cannot iterate %s"), getTypeName(o1)); + raise_error(_SC("cannot iterate %s"), getTypeName(o1)); } return false; //cannot be hit(just to avoid warnings) } @@ -592,7 +593,7 @@ bool SQVM::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func) SQOuterVar &v = func->_outervalues[i]; switch(v._type){ case otLOCAL: - FindOuter(closure->_outervalues[i], &STK(_integer(v._src))); + findOuter(closure->_outervalues[i], &STK(_integer(v._src))); break; case otOUTER: closure->_outervalues[i] = _closure(ci->_closure)->_outervalues[_integer(v._src)]; @@ -618,7 +619,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,int64_t baseclass,int64_t attributes) SQClass *base = NULL; SQObjectPtr attrs; if(baseclass != -1) { - if(sq_type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { Raise_Error(_SC("trying to inherit from a %s"),getTypeName(_stack._vals[_stackbase+baseclass])); return false; } + if(sq_type(_stack._vals[_stackbase+baseclass]) != OT_CLASS) { raise_error(_SC("trying to inherit from a %s"),getTypeName(_stack._vals[_stackbase+baseclass])); return false; } base = _class(_stack._vals[_stackbase + baseclass]); } if(attributes != MAX_FUNC_STACKSIZE) { @@ -628,18 +629,18 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,int64_t baseclass,int64_t attributes) if(sq_type(_class(target)->_metamethods[MT_INHERITED]) != OT_NULL) { int nparams = 2; SQObjectPtr ret; - Push(target); Push(attrs); - if(!Call(_class(target)->_metamethods[MT_INHERITED],nparams,_top - nparams, ret, false)) { - Pop(nparams); + push(target); push(attrs); + if(!call(_class(target)->_metamethods[MT_INHERITED],nparams,_top - nparams, ret, false)) { + pop(nparams); return false; } - Pop(nparams); + pop(nparams); } _class(target)->_attributes = attrs; return true; } -bool SQVM::IsEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res) +bool SQVM::isEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res) { if(sq_type(o1) == sq_type(o2)) { res = (_rawval(o1) == _rawval(o2)); @@ -670,20 +671,20 @@ bool SQVM::IsFalse(SQObjectPtr &o) return false; } extern SQInstructionDesc g_InstrDesc[]; -bool SQVM::Execute(SQObjectPtr &closure, int64_t nargs, int64_t stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et) +bool SQVM::execute(SQObjectPtr &closure, int64_t nargs, int64_t stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et) { - if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { Raise_Error(_SC("Native stack overflow")); return false; } + if ((_nnativecalls + 1) > MAX_NATIVE_CALLS) { raise_error(_SC("Native stack overflow")); return false; } _nnativecalls++; AutoDec ad(&_nnativecalls); int64_t traps = 0; - CallInfo *prevci = ci; + callInfo *prevci = ci; switch(et) { case ET_CALL: { temp_reg = closure; - if(!StartCall(_closure(temp_reg), _top - nargs, nargs, stackbase, false)) { + if(!startcall(_closure(temp_reg), _top - nargs, nargs, stackbase, false)) { //call the handler if there are no calls in the stack, if not relies on the previous node - if(ci == NULL) CallErrorHandler(_lasterror); + if(ci == NULL) callerrorHandler(_lasterror); return false; } if(ci == prevci) { @@ -693,7 +694,7 @@ bool SQVM::Execute(SQObjectPtr &closure, int64_t nargs, int64_t stackbase,SQObje ci->_root = SQTrue; } break; - case ET_RESUME_GENERATOR: _generator(closure)->Resume(this, outres); ci->_root = SQTrue; traps += ci->_etraps; break; + case ET_RESUME_GENERATOR: _generator(closure)->resume(this, outres); ci->_root = SQTrue; traps += ci->_etraps; break; case ET_RESUME_VM: case ET_RESUME_THROW_VM: traps = _suspended_traps; @@ -713,7 +714,7 @@ exception_restore: //scprintf("\n[%d] %s %d %d %d %d\n",ci->_ip-_closure(ci->_closure)->_function->_instructions,g_InstrDesc[_i_.op].name,arg0,arg1,arg2,arg3); switch(_i_.op) { - case _OP_LINE: if (_debughook) CallDebugHook(_SC('l'),arg1); continue; + case _OP_LINE: if (_debughook) callDebugHook(_SC('l'),arg1); continue; case _OP_LOAD: TARGET = ci->_literals[arg1]; continue; case _OP_LOADINT: #ifndef _SQ64 @@ -729,9 +730,9 @@ exception_restore: && (!_closure(t)->_function->_bgenerator)){ SQObjectPtr clo = t; int64_t last_top = _top; - if(_openouters) CloseOuters(&(_stack._vals[_stackbase])); + if(_openouters) closeOuters(&(_stack._vals[_stackbase])); for (int64_t i = 0; i < arg3; i++) STK(i) = STK(arg2 + i); - _GUARD(StartCall(_closure(clo), ci->_target, arg3, _stackbase, true)); + _GUARD(startcall(_closure(clo), ci->_target, arg3, _stackbase, true)); if (last_top >= _top) { _top = last_top; } @@ -742,12 +743,12 @@ exception_restore: SQObjectPtr clo = STK(arg1); switch (sq_type(clo)) { case OT_CLOSURE: - _GUARD(StartCall(_closure(clo), sarg0, arg3, _stackbase+arg2, false)); + _GUARD(startcall(_closure(clo), sarg0, arg3, _stackbase+arg2, false)); continue; case OT_NATIVECLOSURE: { bool suspend; bool tailcall; - _GUARD(CallNative(_nativeclosure(clo), arg3, _stackbase+arg2, clo, (int32_t)sarg0, suspend, tailcall)); + _GUARD(callNative(_nativeclosure(clo), arg3, _stackbase+arg2, clo, (int32_t)sarg0, suspend, tailcall)); if(suspend){ _suspended = SQTrue; _suspended_target = sarg0; @@ -772,13 +773,13 @@ exception_restore: case OT_CLOSURE: stkbase = _stackbase+arg2; _stack._vals[stkbase] = inst; - _GUARD(StartCall(_closure(clo), -1, arg3, stkbase, false)); + _GUARD(startcall(_closure(clo), -1, arg3, stkbase, false)); break; case OT_NATIVECLOSURE: bool dummy; stkbase = _stackbase+arg2; _stack._vals[stkbase] = inst; - _GUARD(CallNative(_nativeclosure(clo), arg3, stkbase, clo, -1, dummy, dummy)); + _GUARD(callNative(_nativeclosure(clo), arg3, stkbase, clo, -1, dummy, dummy)); break; default: break; //shutup GCC 4.x } @@ -789,20 +790,20 @@ exception_restore: case OT_INSTANCE:{ SQObjectPtr closure; if(_delegable(clo)->_delegate && _delegable(clo)->getMetaMethod(this,MT_CALL,closure)) { - Push(clo); - for (int64_t i = 0; i < arg3; i++) Push(STK(arg2 + i)); - if(!CallMetaMethod(closure, MT_CALL, arg3+1, clo)) SQ_THROW(); + push(clo); + for (int64_t i = 0; i < arg3; i++) push(STK(arg2 + i)); + if(!callMetaMethod(closure, MT_CALL, arg3+1, clo)) SQ_THROW(); if(sarg0 != -1) { STK(arg0) = clo; } break; } - //Raise_Error(_SC("attempt to call '%s'"), getTypeName(clo)); + //raise_error(_SC("attempt to call '%s'"), getTypeName(clo)); //SQ_THROW(); } default: - Raise_Error(_SC("attempt to call '%s'"), getTypeName(clo)); + raise_error(_SC("attempt to call '%s'"), getTypeName(clo)); SQ_THROW(); } } @@ -824,10 +825,10 @@ exception_restore: continue; case _OP_MOVE: TARGET = STK(arg1); continue; case _OP_NEWSLOT: - _GUARD(NewSlot(STK(arg1), STK(arg2), STK(arg3),false)); + _GUARD(newSlot(STK(arg1), STK(arg2), STK(arg3),false)); if(arg0 != 0xFF) TARGET = STK(arg3); continue; - case _OP_DELETE: _GUARD(DeleteSlot(STK(arg1), STK(arg2), TARGET)); continue; + case _OP_DELETE: _GUARD(deleteSlot(STK(arg1), STK(arg2), TARGET)); continue; case _OP_SET: if (!set(STK(arg1), STK(arg2), STK(arg3),arg1)) { SQ_THROW(); } if (arg0 != 0xFF) TARGET = STK(arg3); @@ -838,12 +839,12 @@ exception_restore: continue; case _OP_EQ:{ bool res; - if(!IsEqual(STK(arg2),COND_LITERAL,res)) { SQ_THROW(); } + if(!isEqual(STK(arg2),COND_LITERAL,res)) { SQ_THROW(); } TARGET = res?true:false; }continue; case _OP_NE:{ bool res; - if(!IsEqual(STK(arg2),COND_LITERAL,res)) { SQ_THROW(); } + if(!isEqual(STK(arg2),COND_LITERAL,res)) { SQ_THROW(); } TARGET = (!res)?true:false; } continue; case _OP_ADD: _ARITH_(+,TARGET,STK(arg2),STK(arg1)); continue; @@ -854,7 +855,7 @@ exception_restore: case _OP_BITW: _GUARD(BW_OP( arg3,TARGET,STK(arg2),STK(arg1))); continue; case _OP_RETURN: if((ci)->_generator) { - (ci)->_generator->Kill(); + (ci)->_generator->kill(); } if(Return(arg0, arg1, temp_reg)){ assert(traps==0); @@ -936,10 +937,10 @@ exception_restore: } case _OP_COMPARITH: { int64_t selfidx = (((uint64_t)arg1&0xFFFF0000)>>16); - _GUARD(DerefInc(arg3, TARGET, STK(selfidx), STK(arg2), STK(arg1&0x0000FFFF), false, selfidx)); + _GUARD(derefInc(arg3, TARGET, STK(selfidx), STK(arg2), STK(arg1&0x0000FFFF), false, selfidx)); } continue; - case _OP_INC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue; + case _OP_INC: {SQObjectPtr o(sarg3); _GUARD(derefInc('+',TARGET, STK(arg1), STK(arg2), o, false, arg1));} continue; case _OP_INCL: { SQObjectPtr &a = STK(arg1); if(sq_type(a) == OT_INTEGER) { @@ -950,7 +951,7 @@ exception_restore: _ARITH_(+,a,a,o); } } continue; - case _OP_PINC: {SQObjectPtr o(sarg3); _GUARD(DerefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue; + case _OP_PINC: {SQObjectPtr o(sarg3); _GUARD(derefInc('+',TARGET, STK(arg1), STK(arg2), o, true, arg1));} continue; case _OP_PINCL: { SQObjectPtr &a = STK(arg1); if(sq_type(a) == OT_INTEGER) { @@ -966,8 +967,8 @@ exception_restore: case _OP_EXISTS: TARGET = get(STK(arg1), STK(arg2), temp_reg, GET_FLAG_DO_NOT_RAISE_ERROR | GET_FLAG_RAW, DONT_FALL_BACK) ? true : false; continue; case _OP_INSTANCEOF: if(sq_type(STK(arg1)) != OT_CLASS) - {Raise_Error(_SC("cannot apply instanceof between a %s and a %s"),getTypeName(STK(arg1)),getTypeName(STK(arg2))); SQ_THROW();} - TARGET = (sq_type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->InstanceOf(_class(STK(arg1)))?true:false) : false; + {raise_error(_SC("cannot apply instanceof between a %s and a %s"),getTypeName(STK(arg1)),getTypeName(STK(arg2))); SQ_THROW();} + TARGET = (sq_type(STK(arg2)) == OT_INSTANCE) ? (_instance(STK(arg2))->instanceOf(_class(STK(arg1)))?true:false) : false; continue; case _OP_AND: if(IsFalse(STK(arg2))) { @@ -989,7 +990,7 @@ exception_restore: TARGET = int64_t(~t); continue; } - Raise_Error(_SC("attempt to perform a bitwise op on a %s"), getTypeName(STK(arg1))); + raise_error(_SC("attempt to perform a bitwise op on a %s"), getTypeName(STK(arg1))); SQ_THROW(); case _OP_CLOSURE: { SQClosure *c = ci->_closure._unVal.pClosure; @@ -1000,11 +1001,11 @@ exception_restore: case _OP_YIELD:{ if(ci->_generator) { if(sarg1 != MAX_FUNC_STACKSIZE) temp_reg = STK(arg1); - _GUARD(ci->_generator->Yield(this,arg2)); + _GUARD(ci->_generator->yield(this,arg2)); traps -= ci->_etraps; if(sarg1 != MAX_FUNC_STACKSIZE) _Swap(STK(arg1),temp_reg);//STK(arg1) = temp_reg; } - else { Raise_Error(_SC("trying to yield a '%s',only genenerator can be yielded"), getTypeName(ci->_generator)); SQ_THROW();} + else { raise_error(_SC("trying to yield a '%s',only genenerator can be yielded"), getTypeName(ci->_generator)); SQ_THROW();} if(Return(arg0, arg1, temp_reg)){ assert(traps == 0); outres = temp_reg; @@ -1014,8 +1015,8 @@ exception_restore: } continue; case _OP_RESUME: - if(sq_type(STK(arg1)) != OT_GENERATOR){ Raise_Error(_SC("trying to resume a '%s',only genenerator can be resumed"), getTypeName(STK(arg1))); SQ_THROW();} - _GUARD(_generator(STK(arg1))->Resume(this, TARGET)); + if(sq_type(STK(arg1)) != OT_GENERATOR){ raise_error(_SC("trying to resume a '%s',only genenerator can be resumed"), getTypeName(STK(arg1))); SQ_THROW();} + _GUARD(_generator(STK(arg1))->resume(this, TARGET)); traps += ci->_etraps; continue; case _OP_FOREACH:{ int tojump; @@ -1028,7 +1029,7 @@ exception_restore: ci->_ip += (sarg1 - 1); continue; case _OP_CLONE: _GUARD(clone(STK(arg1), TARGET)); continue; - case _OP_TYPEOF: _GUARD(TypeOf(STK(arg1), TARGET)) continue; + case _OP_TYPEOF: _GUARD(typeOf(STK(arg1), TARGET)) continue; case _OP_PUSHTRAP:{ SQInstruction *_iv = _closure(ci->_closure)->_function->_instructions; _etraps.push_back(SQExceptionTrap(_top,_stackbase, &_iv[(ci->_ip-_iv)+arg1], arg0)); traps++; @@ -1042,9 +1043,9 @@ exception_restore: } } continue; - case _OP_THROW: Raise_Error(TARGET); SQ_THROW(); continue; + case _OP_THROW: raise_error(TARGET); SQ_THROW(); continue; case _OP_NEWSLOTA: - _GUARD(NewSlotA(STK(arg1),STK(arg2),STK(arg3),(arg0&NEW_SLOT_ATTRIBUTES_FLAG) ? STK(arg2-1) : SQObjectPtr(),(arg0&NEW_SLOT_STATIC_FLAG)?true:false,false)); + _GUARD(newSlotA(STK(arg1),STK(arg2),STK(arg3),(arg0&NEW_SLOT_ATTRIBUTES_FLAG) ? STK(arg2-1) : SQObjectPtr(),(arg0&NEW_SLOT_STATIC_FLAG)?true:false,false)); continue; case _OP_GETBASE:{ SQClosure *clo = _closure(ci->_closure); @@ -1057,7 +1058,7 @@ exception_restore: continue; } case _OP_CLOSE: - if(_openouters) CloseOuters(&(STK(arg1))); + if(_openouters) closeOuters(&(STK(arg1))); continue; } @@ -1070,7 +1071,7 @@ exception_trap: // int64_t n = 0; int64_t last_top = _top; - if(_ss(this)->_notifyallexceptions || (!traps && raiseerror)) CallErrorHandler(currerror); + if(_ss(this)->_notifyallexceptions || (!traps && raiseerror)) callerrorHandler(currerror); while( ci ) { if(ci->_etraps > 0) { @@ -1087,12 +1088,12 @@ exception_trap: //notify debugger of a "return" //even if it really an exception unwinding the stack for(int64_t i = 0; i < ci->_ncalls; i++) { - CallDebugHook(_SC('r')); + callDebugHook(_SC('r')); } } - if(ci->_generator) ci->_generator->Kill(); + if(ci->_generator) ci->_generator->kill(); bool mustbreak = ci && ci->_root; - LeaveFrame(); + leaveFrame(); if(mustbreak) break; } @@ -1111,18 +1112,18 @@ bool SQVM::createClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr return true; } -void SQVM::CallErrorHandler(SQObjectPtr &error) +void SQVM::callerrorHandler(SQObjectPtr &error) { if(sq_type(_errorhandler) != OT_NULL) { SQObjectPtr out; - Push(_roottable); Push(error); - Call(_errorhandler, 2, _top-2, out,SQFalse); - Pop(2); + push(_roottable); push(error); + call(_errorhandler, 2, _top-2, out,SQFalse); + pop(2); } } -void SQVM::CallDebugHook(int64_t type,int64_t forcedline) +void SQVM::callDebugHook(int64_t type,int64_t forcedline) { _debughook = false; SQFunctionProto *func=_closure(ci->_closure)->_function; @@ -1135,27 +1136,31 @@ void SQVM::CallDebugHook(int64_t type,int64_t forcedline) else { SQObjectPtr temp_reg; int64_t nparams=5; - Push(_roottable); Push(type); Push(func->_sourcename); Push(forcedline?forcedline:func->getLine(ci->_ip)); Push(func->_name); - Call(_debughook_closure,nparams,_top-nparams,temp_reg,SQFalse); - Pop(nparams); + push(_roottable); + push(type); + push(func->_sourcename); + push(forcedline?forcedline:func->getLine(ci->_ip)); + push(func->_name); + call(_debughook_closure,nparams,_top-nparams,temp_reg,SQFalse); + pop(nparams); } _debughook = true; } -bool SQVM::CallNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, SQObjectPtr &retval, int32_t target,bool &suspend, bool &tailcall) +bool SQVM::callNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, SQObjectPtr &retval, int32_t target,bool &suspend, bool &tailcall) { int64_t nparamscheck = nclosure->_nparamscheck; int64_t newtop = newbase + nargs + nclosure->_noutervalues; if (_nnativecalls + 1 > MAX_NATIVE_CALLS) { - Raise_Error(_SC("Native stack overflow")); + raise_error(_SC("Native stack overflow")); return false; } if(nparamscheck && (((nparamscheck > 0) && (nparamscheck != nargs)) || ((nparamscheck < 0) && (nargs < (-nparamscheck))))) { - Raise_Error(_SC("wrong number of parameters")); + raise_error(_SC("wrong number of parameters")); return false; } @@ -1164,13 +1169,13 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, if((tcs = tc.size())) { for(int64_t i = 0; i < nargs && i < tcs; i++) { if((tc._vals[i] != -1) && !(sq_type(_stack._vals[newbase+i]) & tc._vals[i])) { - Raise_ParamTypeError(i,tc._vals[i], sq_type(_stack._vals[newbase+i])); + raise_ParamTypeerror(i,tc._vals[i], sq_type(_stack._vals[newbase+i])); return false; } } } - if(!EnterFrame(newbase, newtop, false)) return false; + if(!enterFrame(newbase, newtop, false)) return false; ci->_closure = nclosure; ci->_target = target; @@ -1196,8 +1201,8 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, suspend = true; } else if (ret < 0) { - LeaveFrame(); - Raise_Error(_lasterror); + leaveFrame(); + raise_error(_lasterror); return false; } if(ret) { @@ -1207,21 +1212,21 @@ bool SQVM::CallNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, retval.Null(); } //retval = ret ? _stack._vals[_top-1] : _null_; - LeaveFrame(); + leaveFrame(); return true; } -bool SQVM::TailCall(SQClosure *closure, int64_t parambase,int64_t nparams) +bool SQVM::tailcall(SQClosure *closure, int64_t parambase,int64_t nparams) { int64_t last_top = _top; SQObjectPtr clo = closure; if (ci->_root) { - Raise_Error("root calls cannot invoke tailcalls"); + raise_error("root calls cannot invoke tailcalls"); return false; } for (int64_t i = 0; i < nparams; i++) STK(i) = STK(parambase + i); - bool ret = StartCall(closure, ci->_target, nparams, _stackbase, true); + bool ret = startcall(closure, ci->_target, nparams, _stackbase, true); if (last_top >= _top) { _top = last_top; } @@ -1239,7 +1244,7 @@ bool SQVM::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des if(_table(self)->get(key,dest))return true; break; case OT_ARRAY: - if (sq_isnumeric(key)) { if (_array(self)->get(tointeger(key), dest)) { return true; } if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) Raise_IdxError(key); return false; } + if (sq_isnumeric(key)) { if (_array(self)->get(tointeger(key), dest)) { return true; } if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) raise_Idxerror(key); return false; } break; case OT_INSTANCE: if(_instance(self)->get(key,dest)) return true; @@ -1256,19 +1261,19 @@ bool SQVM::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des dest = int64_t(_stringval(self)[n]); return true; } - if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) Raise_IdxError(key); + if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) raise_Idxerror(key); return false; } break; default:break; //shut up compiler } if ((getflags & GET_FLAG_RAW) == 0) { - switch(FallBackget(self,key,dest)) { + switch(fallBackGet(self,key,dest)) { case FALLBACK_OK: return true; //okie case FALLBACK_NO_MATCH: break; //keep falling back case FALLBACK_ERROR: return false; // the metamethod failed } - if(InvokeDefaultDelegate(self,key,dest)) { + if(invokeDefaultDelegate(self,key,dest)) { return true; } } @@ -1282,11 +1287,11 @@ bool SQVM::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des } //#endif - if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) Raise_IdxError(key); + if ((getflags & GET_FLAG_DO_NOT_RAISE_ERROR) == 0) raise_Idxerror(key); return false; } -bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest) +bool SQVM::invokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest) { SQTable *ddel = NULL; switch(sq_type(self)) { @@ -1306,7 +1311,7 @@ bool SQVM::InvokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key, } -int64_t SQVM::FallBackget(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest) +int64_t SQVM::fallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest) { switch(sq_type(self)){ case OT_TABLE: @@ -1322,15 +1327,15 @@ int64_t SQVM::FallBackget(const SQObjectPtr &self,const SQObjectPtr &key,SQObjec case OT_INSTANCE: { SQObjectPtr closure; if(_delegable(self)->getMetaMethod(this, MT_GET, closure)) { - Push(self);Push(key); + push(self);push(key); _nmetamethodscall++; AutoDec ad(&_nmetamethodscall); - if(Call(closure, 2, _top - 2, dest, SQFalse)) { - Pop(2); + if(call(closure, 2, _top - 2, dest, SQFalse)) { + pop(2); return FALLBACK_OK; } else { - Pop(2); + pop(2); if(sq_type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found) return FALLBACK_ERROR; } @@ -1354,19 +1359,19 @@ bool SQVM::set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr if(_instance(self)->set(key,val)) return true; break; case OT_ARRAY: - if(!sq_isnumeric(key)) { Raise_Error(_SC("indexing %s with %s"),getTypeName(self),getTypeName(key)); return false; } + if(!sq_isnumeric(key)) { raise_error(_SC("indexing %s with %s"),getTypeName(self),getTypeName(key)); return false; } if(!_array(self)->set(tointeger(key),val)) { - Raise_IdxError(key); + raise_Idxerror(key); return false; } return true; case OT_USERDATA: break; // must fall back default: - Raise_Error(_SC("trying to set '%s'"),getTypeName(self)); + raise_error(_SC("trying to set '%s'"),getTypeName(self)); return false; } - switch(FallBackset(self,key,val)) { + switch(fallBackSet(self,key,val)) { case FALLBACK_OK: return true; //okie case FALLBACK_NO_MATCH: break; //keep falling back case FALLBACK_ERROR: return false; // the metamethod failed @@ -1375,11 +1380,11 @@ bool SQVM::set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr if(_table(_roottable)->set(key,val)) return true; } - Raise_IdxError(key); + raise_Idxerror(key); return false; } -int64_t SQVM::FallBackset(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val) +int64_t SQVM::fallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val) { switch(sq_type(self)) { case OT_TABLE: @@ -1392,15 +1397,15 @@ int64_t SQVM::FallBackset(const SQObjectPtr &self,const SQObjectPtr &key,const S SQObjectPtr closure; SQObjectPtr t; if(_delegable(self)->getMetaMethod(this, MT_SET, closure)) { - Push(self);Push(key);Push(val); + push(self);push(key);push(val); _nmetamethodscall++; AutoDec ad(&_nmetamethodscall); - if(Call(closure, 3, _top - 3, t, SQFalse)) { - Pop(3); + if(call(closure, 3, _top - 3, t, SQFalse)) { + pop(3); return FALLBACK_OK; } else { - Pop(3); + pop(3); if(sq_type(_lasterror) != OT_NULL) { //NULL means "clean failure" (not found) return FALLBACK_ERROR; } @@ -1427,9 +1432,9 @@ bool SQVM::clone(const SQObjectPtr &self,SQObjectPtr &target) cloned_mt: SQObjectPtr closure; if(_delegable(newobj)->_delegate && _delegable(newobj)->getMetaMethod(this,MT_CLONED,closure)) { - Push(newobj); - Push(self); - if(!CallMetaMethod(closure,MT_CLONED,2,temp_reg)) + push(newobj); + push(self); + if(!callMetaMethod(closure,MT_CLONED,2,temp_reg)) return false; } } @@ -1439,28 +1444,28 @@ cloned_mt: target = _array(self)->clone(); return true; default: - Raise_Error(_SC("cloning a %s"), getTypeName(self)); + raise_error(_SC("cloning a %s"), getTypeName(self)); return false; } } -bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw) +bool SQVM::newSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw) { if(sq_type(self) != OT_CLASS) { - Raise_Error(_SC("object must be a class")); + raise_error(_SC("object must be a class")); return false; } SQClass *c = _class(self); if(!raw) { SQObjectPtr &mm = c->_metamethods[MT_NEWMEMBER]; if(sq_type(mm) != OT_NULL ) { - Push(self); Push(key); Push(val); - Push(attrs); - Push(bstatic); - return CallMetaMethod(mm,MT_NEWMEMBER,5,temp_reg); + push(self); push(key); push(val); + push(attrs); + push(bstatic); + return callMetaMethod(mm,MT_NEWMEMBER,5,temp_reg); } } - if(!NewSlot(self, key, val,bstatic)) + if(!newSlot(self, key, val,bstatic)) return false; if(sq_type(attrs) != OT_NULL) { c->setAttributes(key,attrs); @@ -1468,9 +1473,9 @@ bool SQVM::NewSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec return true; } -bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic) +bool SQVM::newSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic) { - if(sq_type(key) == OT_NULL) { Raise_Error(_SC("null cannot be used as index")); return false; } + if(sq_type(key) == OT_NULL) { raise_error(_SC("null cannot be used as index")); return false; } switch(sq_type(self)) { case OT_TABLE: { bool rawcall = true; @@ -1479,8 +1484,8 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject if(!_table(self)->get(key,res)) { SQObjectPtr closure; if(_delegable(self)->_delegate && _delegable(self)->getMetaMethod(this,MT_NEWSLOT,closure)) { - Push(self);Push(key);Push(val); - if(!CallMetaMethod(closure,MT_NEWSLOT,3,res)) { + push(self);push(key);push(val); + if(!callMetaMethod(closure,MT_NEWSLOT,3,res)) { return false; } rawcall = false; @@ -1490,37 +1495,37 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject } } } - if(rawcall) _table(self)->NewSlot(key,val); //cannot fail + if(rawcall) _table(self)->newSlot(key,val); //cannot fail break;} case OT_INSTANCE: { SQObjectPtr res; SQObjectPtr closure; if(_delegable(self)->_delegate && _delegable(self)->getMetaMethod(this,MT_NEWSLOT,closure)) { - Push(self);Push(key);Push(val); - if(!CallMetaMethod(closure,MT_NEWSLOT,3,res)) { + push(self);push(key);push(val); + if(!callMetaMethod(closure,MT_NEWSLOT,3,res)) { return false; } break; } - Raise_Error(_SC("class instances do not support the new slot operator")); + raise_error(_SC("class instances do not support the new slot operator")); return false; break;} case OT_CLASS: - if(!_class(self)->NewSlot(_ss(this),key,val,bstatic)) { + if(!_class(self)->newSlot(_ss(this),key,val,bstatic)) { if(_class(self)->_locked) { - Raise_Error(_SC("trying to modify a class that has already been instantiated")); + raise_error(_SC("trying to modify a class that has already been instantiated")); return false; } else { - SQObjectPtr oval = PrintObjVal(key); - Raise_Error(_SC("the property '%s' already exists"),_stringval(oval)); + SQObjectPtr oval = printObjVal(key); + raise_error(_SC("the property '%s' already exists"),_stringval(oval)); return false; } } break; default: - Raise_Error(_SC("indexing %s with %s"),getTypeName(self),getTypeName(key)); + raise_error(_SC("indexing %s with %s"),getTypeName(self),getTypeName(key)); return false; break; } @@ -1529,7 +1534,7 @@ bool SQVM::NewSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObject -bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res) +bool SQVM::deleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res) { switch(sq_type(self)) { case OT_TABLE: @@ -1539,8 +1544,8 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr //bool handled = false; SQObjectPtr closure; if(_delegable(self)->_delegate && _delegable(self)->getMetaMethod(this,MT_DELSLOT,closure)) { - Push(self);Push(key); - return CallMetaMethod(closure,MT_DELSLOT,2,res); + push(self);push(key); + return callMetaMethod(closure,MT_DELSLOT,2,res); } else { if(sq_type(self) == OT_TABLE) { @@ -1548,12 +1553,12 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr _table(self)->remove(key); } else { - Raise_IdxError((const SQObject &)key); + raise_Idxerror((const SQObject &)key); return false; } } else { - Raise_Error(_SC("cannot delete a slot from %s"),getTypeName(self)); + raise_error(_SC("cannot delete a slot from %s"),getTypeName(self)); return false; } } @@ -1561,24 +1566,24 @@ bool SQVM::DeleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr } break; default: - Raise_Error(_SC("attempt to delete a slot from a %s"),getTypeName(self)); + raise_error(_SC("attempt to delete a slot from a %s"),getTypeName(self)); return false; } return true; } -bool SQVM::Call(SQObjectPtr &closure,int64_t nparams,int64_t stackbase,SQObjectPtr &outres,SQBool raiseerror) +bool SQVM::call(SQObjectPtr &closure,int64_t nparams,int64_t stackbase,SQObjectPtr &outres,SQBool raiseerror) { #ifdef _DEBUG int64_t prevstackbase = _stackbase; #endif switch(sq_type(closure)) { case OT_CLOSURE: - return Execute(closure, nparams, stackbase, outres, raiseerror); + return execute(closure, nparams, stackbase, outres, raiseerror); break; case OT_NATIVECLOSURE:{ bool dummy; - return CallNative(_nativeclosure(closure), nparams, stackbase, outres, -1, dummy, dummy); + return callNative(_nativeclosure(closure), nparams, stackbase, outres, -1, dummy, dummy); } break; @@ -1589,7 +1594,7 @@ int64_t prevstackbase = _stackbase; SQObjectType ctype = sq_type(constr); if (ctype == OT_NATIVECLOSURE || ctype == OT_CLOSURE) { _stack[stackbase] = outres; - return Call(constr,nparams,stackbase,temp,raiseerror); + return call(constr,nparams,stackbase,temp,raiseerror); } return true; } @@ -1605,23 +1610,23 @@ int64_t prevstackbase = _stackbase; return true; } -bool SQVM::CallMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),int64_t nparams,SQObjectPtr &outres) +bool SQVM::callMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),int64_t nparams,SQObjectPtr &outres) { //SQObjectPtr closure; _nmetamethodscall++; - if(Call(closure, nparams, _top - nparams, outres, SQFalse)) { + if(call(closure, nparams, _top - nparams, outres, SQFalse)) { _nmetamethodscall--; - Pop(nparams); + pop(nparams); return true; } _nmetamethodscall--; //} - Pop(nparams); + pop(nparams); return false; } -void SQVM::FindOuter(SQObjectPtr &target, SQObjectPtr *stackindex) +void SQVM::findOuter(SQObjectPtr &target, SQObjectPtr *stackindex) { SQOuter **pp = &_openouters; SQOuter *p; @@ -1637,16 +1642,16 @@ void SQVM::FindOuter(SQObjectPtr &target, SQObjectPtr *stackindex) otr = SQOuter::create(_ss(this), stackindex); otr->_next = *pp; otr->_idx = (stackindex - _stack._vals); - __ObjAddRef(otr); + __ObjaddRef(otr); *pp = otr; target = SQObjectPtr(otr); } -bool SQVM::EnterFrame(int64_t newbase, int64_t newtop, bool tailcall) +bool SQVM::enterFrame(int64_t newbase, int64_t newtop, bool tailcall) { if( !tailcall ) { if( _callsstacksize == _alloccallsstacksize ) { - GrowCallStack(); + GrowcallStack(); } ci = &_callsstack[_callsstacksize++]; ci->_prevstkbase = (int32_t)(newbase - _stackbase); @@ -1664,16 +1669,16 @@ bool SQVM::EnterFrame(int64_t newbase, int64_t newtop, bool tailcall) _top = newtop; if(newtop + MIN_STACK_OVERHEAD > (int64_t)_stack.size()) { if(_nmetamethodscall) { - Raise_Error(_SC("stack overflow, cannot resize stack while in a metamethod")); + raise_error(_SC("stack overflow, cannot resize stack while in a metamethod")); return false; } _stack.resize(newtop + (MIN_STACK_OVERHEAD << 2)); - RelocateOuters(); + relocateOuters(); } return true; } -void SQVM::LeaveFrame() { +void SQVM::leaveFrame() { int64_t last_top = _top; int64_t last_stackbase = _stackbase; int64_t css = --_callsstacksize; @@ -1684,13 +1689,13 @@ void SQVM::LeaveFrame() { _top = _stackbase + ci->_prevtop; ci = (css) ? &_callsstack[css-1] : NULL; - if(_openouters) CloseOuters(&(_stack._vals[last_stackbase])); + if(_openouters) closeOuters(&(_stack._vals[last_stackbase])); while (last_top >= _top) { _stack._vals[last_top--].Null(); } } -void SQVM::RelocateOuters() +void SQVM::relocateOuters() { SQOuter *p = _openouters; while (p) { @@ -1699,7 +1704,7 @@ void SQVM::RelocateOuters() } } -void SQVM::CloseOuters(SQObjectPtr *stackindex) { +void SQVM::closeOuters(SQObjectPtr *stackindex) { SQOuter *p; while ((p = _openouters) != NULL && p->_valptr >= stackindex) { p->_value = *(p->_valptr); @@ -1718,20 +1723,20 @@ void SQVM::remove(int64_t n) { _top--; } -void SQVM::Pop() { +void SQVM::pop() { _stack[--_top].Null(); } -void SQVM::Pop(int64_t n) { +void SQVM::pop(int64_t n) { for(int64_t i = 0; i < n; i++){ _stack[--_top].Null(); } } -void SQVM::PushNull() { _stack[_top++].Null(); } -void SQVM::Push(const SQObjectPtr &o) { _stack[_top++] = o; } +void SQVM::pushNull() { _stack[_top++].Null(); } +void SQVM::push(const SQObjectPtr &o) { _stack[_top++] = o; } SQObjectPtr &SQVM::top() { return _stack[_top-1]; } -SQObjectPtr &SQVM::Popget() { return _stack[--_top]; } +SQObjectPtr &SQVM::popGet() { return _stack[--_top]; } SQObjectPtr &SQVM::getUp(int64_t n) { return _stack[_top+n]; } SQObjectPtr &SQVM::getAt(int64_t n) { return _stack[n]; } @@ -1741,7 +1746,7 @@ void SQVM::dumpstack(int64_t stackbase,bool dumpall) int64_t size=dumpall?_stack.size():_top; int64_t n=0; scprintf(_SC("\n>>>>stack dump<<<<\n")); - CallInfo &ci=_callsstack[_callsstacksize-1]; + callInfo &ci=_callsstack[_callsstacksize-1]; scprintf(_SC("IP: %p\n"),ci._ip); scprintf(_SC("prev stack base: %d\n"),ci._prevstkbase); scprintf(_SC("prev top: %d\n"),ci._prevtop); diff --git a/rabbit/sqvm.hpp b/rabbit/sqvm.hpp index 1dd128d..8be5f65 100644 --- a/rabbit/sqvm.hpp +++ b/rabbit/sqvm.hpp @@ -39,8 +39,8 @@ typedef sqvector 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 CallInfoVec; +typedef sqvector 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 _callstackdata; + sqvector _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; \