[DEV] rename sqvm.hpp -> VirtualMachine.hpp
This commit is contained in:
parent
5377f4b891
commit
2fb1234972
@ -48,7 +48,7 @@ int MemAllocHook(int allocType,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int64_t quit(HRABBITVM v)
|
int64_t quit(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int *done;
|
int *done;
|
||||||
sq_getuserpointer(v,-1,(SQUserPointer*)&done);
|
sq_getuserpointer(v,-1,(SQUserPointer*)&done);
|
||||||
@ -56,7 +56,7 @@ int64_t quit(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void printfunc(HRABBITVM SQ_UNUSED_ARG(v),const SQChar *s,...)
|
void printfunc(rabbit::VirtualMachine* SQ_UNUSED_ARG(v),const SQChar *s,...)
|
||||||
{
|
{
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, s);
|
va_start(vl, s);
|
||||||
@ -64,7 +64,7 @@ void printfunc(HRABBITVM SQ_UNUSED_ARG(v),const SQChar *s,...)
|
|||||||
va_end(vl);
|
va_end(vl);
|
||||||
}
|
}
|
||||||
|
|
||||||
void errorfunc(HRABBITVM SQ_UNUSED_ARG(v),const SQChar *s,...)
|
void errorfunc(rabbit::VirtualMachine* SQ_UNUSED_ARG(v),const SQChar *s,...)
|
||||||
{
|
{
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, s);
|
va_start(vl, s);
|
||||||
@ -93,7 +93,7 @@ void PrintUsage()
|
|||||||
#define _DONE 2
|
#define _DONE 2
|
||||||
#define _ERROR 3
|
#define _ERROR 3
|
||||||
//<<FIXME>> this func is a mess
|
//<<FIXME>> this func is a mess
|
||||||
int getargs(HRABBITVM v,int argc, char* argv[],int64_t *retval)
|
int getargs(rabbit::VirtualMachine* v,int argc, char* argv[],int64_t *retval)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int compiles_only = 0;
|
int compiles_only = 0;
|
||||||
@ -231,7 +231,7 @@ int getargs(HRABBITVM v,int argc, char* argv[],int64_t *retval)
|
|||||||
return _INTERACTIVE;
|
return _INTERACTIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Interactive(HRABBITVM v)
|
void Interactive(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
|
|
||||||
#define MAXINPUT 1024
|
#define MAXINPUT 1024
|
||||||
@ -315,7 +315,7 @@ void Interactive(HRABBITVM v)
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
HRABBITVM v;
|
rabbit::VirtualMachine* v;
|
||||||
int64_t retval = 0;
|
int64_t retval = 0;
|
||||||
#if defined(_MSC_VER) && defined(_DEBUG)
|
#if defined(_MSC_VER) && defined(_DEBUG)
|
||||||
_CrtsetAllocHook(MemAllocHook);
|
_CrtsetAllocHook(MemAllocHook);
|
||||||
|
@ -32,7 +32,7 @@ def configure(target, my_module):
|
|||||||
'rabbit/sqapi.cpp',
|
'rabbit/sqapi.cpp',
|
||||||
'rabbit/sqlexer.cpp',
|
'rabbit/sqlexer.cpp',
|
||||||
'rabbit/sqclass.cpp',
|
'rabbit/sqclass.cpp',
|
||||||
'rabbit/sqvm.cpp',
|
'rabbit/VirtualMachine.cpp',
|
||||||
'rabbit/sqtable.cpp',
|
'rabbit/sqtable.cpp',
|
||||||
'rabbit/sqstate.cpp',
|
'rabbit/sqstate.cpp',
|
||||||
'rabbit/sqobject.cpp',
|
'rabbit/sqobject.cpp',
|
||||||
@ -51,7 +51,7 @@ def configure(target, my_module):
|
|||||||
])
|
])
|
||||||
my_module.add_header_file([
|
my_module.add_header_file([
|
||||||
'rabbit/sqclass.hpp',
|
'rabbit/sqclass.hpp',
|
||||||
'rabbit/sqvm.hpp',
|
'rabbit/VirtualMachine.hpp',
|
||||||
'rabbit/sqstate.hpp',
|
'rabbit/sqstate.hpp',
|
||||||
'rabbit/rabbit.hpp',
|
'rabbit/rabbit.hpp',
|
||||||
'rabbit/sqobject.hpp',
|
'rabbit/sqobject.hpp',
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <rabbit-std/sqstdaux.hpp>
|
#include <rabbit-std/sqstdaux.hpp>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
void sqstd_printcallstack(HRABBITVM v)
|
void sqstd_printcallstack(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
||||||
if(pf) {
|
if(pf) {
|
||||||
@ -103,7 +103,7 @@ void sqstd_printcallstack(HRABBITVM v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _sqstd_aux_printerror(HRABBITVM v)
|
static int64_t _sqstd_aux_printerror(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
||||||
if(pf) {
|
if(pf) {
|
||||||
@ -121,7 +121,7 @@ static int64_t _sqstd_aux_printerror(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _sqstd_compiler_error(HRABBITVM v,const SQChar *sErr,const SQChar *sSource,int64_t line,int64_t column)
|
void _sqstd_compiler_error(rabbit::VirtualMachine* v,const SQChar *sErr,const SQChar *sSource,int64_t line,int64_t column)
|
||||||
{
|
{
|
||||||
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
SQPRINTFUNCTION pf = sq_geterrorfunc(v);
|
||||||
if(pf) {
|
if(pf) {
|
||||||
@ -129,7 +129,7 @@ void _sqstd_compiler_error(HRABBITVM v,const SQChar *sErr,const SQChar *sSource,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sqstd_seterrorhandlers(HRABBITVM v)
|
void sqstd_seterrorhandlers(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_setcompilererrorhandler(v,_sqstd_compiler_error);
|
sq_setcompilererrorhandler(v,_sqstd_compiler_error);
|
||||||
sq_newclosure(v,_sqstd_aux_printerror,0);
|
sq_newclosure(v,_sqstd_aux_printerror,0);
|
||||||
|
@ -7,5 +7,5 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
RABBIT_API void sqstd_seterrorhandlers(HRABBITVM v);
|
RABBIT_API void sqstd_seterrorhandlers(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sqstd_printcallstack(HRABBITVM v);
|
RABBIT_API void sqstd_printcallstack(rabbit::VirtualMachine* v);
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
return sq_throwerror(v,_SC("the blob is invalid"));
|
return sq_throwerror(v,_SC("the blob is invalid"));
|
||||||
|
|
||||||
|
|
||||||
static int64_t _blob_resize(HRABBITVM v)
|
static int64_t _blob_resize(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
int64_t size;
|
int64_t size;
|
||||||
@ -43,7 +43,7 @@ static void __swap_word(unsigned short *n)
|
|||||||
*n=(unsigned short)((*n>>8)&0x00FF)| ((*n<<8)&0xFF00);
|
*n=(unsigned short)((*n>>8)&0x00FF)| ((*n<<8)&0xFF00);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob_swap4(HRABBITVM v)
|
static int64_t _blob_swap4(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
int64_t num=(self->Len()-(self->Len()%4))>>2;
|
int64_t num=(self->Len()-(self->Len()%4))>>2;
|
||||||
@ -54,7 +54,7 @@ static int64_t _blob_swap4(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob_swap2(HRABBITVM v)
|
static int64_t _blob_swap2(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
int64_t num=(self->Len()-(self->Len()%2))>>1;
|
int64_t num=(self->Len()-(self->Len()%2))>>1;
|
||||||
@ -65,7 +65,7 @@ static int64_t _blob_swap2(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob__set(HRABBITVM v)
|
static int64_t _blob__set(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
int64_t idx,val;
|
int64_t idx,val;
|
||||||
@ -78,7 +78,7 @@ static int64_t _blob__set(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob__get(HRABBITVM v)
|
static int64_t _blob__get(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
int64_t idx;
|
int64_t idx;
|
||||||
@ -95,7 +95,7 @@ static int64_t _blob__get(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob__nexti(HRABBITVM v)
|
static int64_t _blob__nexti(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_BLOB(v);
|
SETUP_BLOB(v);
|
||||||
if(sq_gettype(v,2) == OT_NULL) {
|
if(sq_gettype(v,2) == OT_NULL) {
|
||||||
@ -114,7 +114,7 @@ static int64_t _blob__nexti(HRABBITVM v)
|
|||||||
return sq_throwerror(v,_SC("internal error (_nexti) wrong argument type"));
|
return sq_throwerror(v,_SC("internal error (_nexti) wrong argument type"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob__typeof(HRABBITVM v)
|
static int64_t _blob__typeof(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushstring(v,_SC("blob"),-1);
|
sq_pushstring(v,_SC("blob"),-1);
|
||||||
return 1;
|
return 1;
|
||||||
@ -128,7 +128,7 @@ static int64_t _blob_releasehook(SQUserPointer p, int64_t SQ_UNUSED_ARG(size))
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob_constructor(HRABBITVM v)
|
static int64_t _blob_constructor(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t nparam = sq_gettop(v);
|
int64_t nparam = sq_gettop(v);
|
||||||
int64_t size = 0;
|
int64_t size = 0;
|
||||||
@ -148,7 +148,7 @@ static int64_t _blob_constructor(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _blob__cloned(HRABBITVM v)
|
static int64_t _blob__cloned(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQBlob *other = NULL;
|
SQBlob *other = NULL;
|
||||||
{
|
{
|
||||||
@ -185,7 +185,7 @@ static const SQRegFunction _blob_methods[] = {
|
|||||||
|
|
||||||
//GLOBAL FUNCTIONS
|
//GLOBAL FUNCTIONS
|
||||||
|
|
||||||
static int64_t _g_blob_casti2f(HRABBITVM v)
|
static int64_t _g_blob_casti2f(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i;
|
int64_t i;
|
||||||
sq_getinteger(v,2,&i);
|
sq_getinteger(v,2,&i);
|
||||||
@ -193,7 +193,7 @@ static int64_t _g_blob_casti2f(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _g_blob_castf2i(HRABBITVM v)
|
static int64_t _g_blob_castf2i(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
float_t f;
|
float_t f;
|
||||||
sq_getfloat(v,2,&f);
|
sq_getfloat(v,2,&f);
|
||||||
@ -201,7 +201,7 @@ static int64_t _g_blob_castf2i(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _g_blob_swap2(HRABBITVM v)
|
static int64_t _g_blob_swap2(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i;
|
int64_t i;
|
||||||
sq_getinteger(v,2,&i);
|
sq_getinteger(v,2,&i);
|
||||||
@ -210,7 +210,7 @@ static int64_t _g_blob_swap2(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _g_blob_swap4(HRABBITVM v)
|
static int64_t _g_blob_swap4(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i;
|
int64_t i;
|
||||||
sq_getinteger(v,2,&i);
|
sq_getinteger(v,2,&i);
|
||||||
@ -220,7 +220,7 @@ static int64_t _g_blob_swap4(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _g_blob_swapfloat(HRABBITVM v)
|
static int64_t _g_blob_swapfloat(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
float_t f;
|
float_t f;
|
||||||
sq_getfloat(v,2,&f);
|
sq_getfloat(v,2,&f);
|
||||||
@ -239,7 +239,7 @@ static const SQRegFunction bloblib_funcs[]={
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
SQRESULT sqstd_getblob(HRABBITVM v,int64_t idx,SQUserPointer *ptr)
|
SQRESULT sqstd_getblob(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer *ptr)
|
||||||
{
|
{
|
||||||
SQBlob *blob;
|
SQBlob *blob;
|
||||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
||||||
@ -248,7 +248,7 @@ SQRESULT sqstd_getblob(HRABBITVM v,int64_t idx,SQUserPointer *ptr)
|
|||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t sqstd_getblobsize(HRABBITVM v,int64_t idx)
|
int64_t sqstd_getblobsize(rabbit::VirtualMachine* v,int64_t idx)
|
||||||
{
|
{
|
||||||
SQBlob *blob;
|
SQBlob *blob;
|
||||||
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
if(SQ_FAILED(sq_getinstanceup(v,idx,(SQUserPointer *)&blob,(SQUserPointer)SQSTD_BLOB_TYPE_TAG)))
|
||||||
@ -256,7 +256,7 @@ int64_t sqstd_getblobsize(HRABBITVM v,int64_t idx)
|
|||||||
return blob->Len();
|
return blob->Len();
|
||||||
}
|
}
|
||||||
|
|
||||||
SQUserPointer sqstd_createblob(HRABBITVM v, int64_t size)
|
SQUserPointer sqstd_createblob(rabbit::VirtualMachine* v, int64_t size)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
sq_pushregistrytable(v);
|
sq_pushregistrytable(v);
|
||||||
@ -276,7 +276,7 @@ SQUserPointer sqstd_createblob(HRABBITVM v, int64_t size)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_register_bloblib(HRABBITVM v)
|
SQRESULT sqstd_register_bloblib(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return declare_stream(v,_SC("blob"),(SQUserPointer)SQSTD_BLOB_TYPE_TAG,_SC("std_blob"),_blob_methods,bloblib_funcs);
|
return declare_stream(v,_SC("blob"),(SQUserPointer)SQSTD_BLOB_TYPE_TAG,_SC("std_blob"),_blob_methods,bloblib_funcs);
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
RABBIT_API SQUserPointer sqstd_createblob(HRABBITVM v, int64_t size);
|
RABBIT_API SQUserPointer sqstd_createblob(rabbit::VirtualMachine* v, int64_t size);
|
||||||
RABBIT_API SQRESULT sqstd_getblob(HRABBITVM v,int64_t idx,SQUserPointer *ptr);
|
RABBIT_API SQRESULT sqstd_getblob(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer *ptr);
|
||||||
RABBIT_API int64_t sqstd_getblobsize(HRABBITVM v,int64_t idx);
|
RABBIT_API int64_t sqstd_getblobsize(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_register_bloblib(HRABBITVM v);
|
RABBIT_API SQRESULT sqstd_register_bloblib(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ private:
|
|||||||
bool _owns;
|
bool _owns;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int64_t _file__typeof(HRABBITVM v)
|
static int64_t _file__typeof(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushstring(v,_SC("file"),-1);
|
sq_pushstring(v,_SC("file"),-1);
|
||||||
return 1;
|
return 1;
|
||||||
@ -130,7 +130,7 @@ static int64_t _file_releasehook(SQUserPointer p, int64_t SQ_UNUSED_ARG(size))
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _file_constructor(HRABBITVM v)
|
static int64_t _file_constructor(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *filename,*mode;
|
const SQChar *filename,*mode;
|
||||||
bool owns = true;
|
bool owns = true;
|
||||||
@ -158,7 +158,7 @@ static int64_t _file_constructor(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _file_close(HRABBITVM v)
|
static int64_t _file_close(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQFile *self = NULL;
|
SQFile *self = NULL;
|
||||||
if(SQ_SUCCEEDED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_FILE_TYPE_TAG))
|
if(SQ_SUCCEEDED(sq_getinstanceup(v,1,(SQUserPointer*)&self,(SQUserPointer)SQSTD_FILE_TYPE_TAG))
|
||||||
@ -180,7 +180,7 @@ static const SQRegFunction _file_methods[] = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
SQRESULT sqstd_createfile(HRABBITVM v, SQFILE file,SQBool own)
|
SQRESULT sqstd_createfile(rabbit::VirtualMachine* v, SQFILE file,SQBool own)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
sq_pushregistrytable(v);
|
sq_pushregistrytable(v);
|
||||||
@ -204,7 +204,7 @@ SQRESULT sqstd_createfile(HRABBITVM v, SQFILE file,SQBool own)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_getfile(HRABBITVM v, int64_t idx, SQFILE *file)
|
SQRESULT sqstd_getfile(rabbit::VirtualMachine* v, int64_t idx, SQFILE *file)
|
||||||
{
|
{
|
||||||
SQFile *fileobj = NULL;
|
SQFile *fileobj = NULL;
|
||||||
if(SQ_SUCCEEDED(sq_getinstanceup(v,idx,(SQUserPointer*)&fileobj,(SQUserPointer)SQSTD_FILE_TYPE_TAG))) {
|
if(SQ_SUCCEEDED(sq_getinstanceup(v,idx,(SQUserPointer*)&fileobj,(SQUserPointer)SQSTD_FILE_TYPE_TAG))) {
|
||||||
@ -344,7 +344,7 @@ int64_t file_write(SQUserPointer file,SQUserPointer p,int64_t size)
|
|||||||
return sqstd_fwrite(p,1,size,(SQFILE)file);
|
return sqstd_fwrite(p,1,size,(SQFILE)file);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_loadfile(HRABBITVM v,const SQChar *filename,SQBool printerror)
|
SQRESULT sqstd_loadfile(rabbit::VirtualMachine* v,const SQChar *filename,SQBool printerror)
|
||||||
{
|
{
|
||||||
SQFILE file = sqstd_fopen(filename,_SC("rb"));
|
SQFILE file = sqstd_fopen(filename,_SC("rb"));
|
||||||
|
|
||||||
@ -404,7 +404,7 @@ SQRESULT sqstd_loadfile(HRABBITVM v,const SQChar *filename,SQBool printerror)
|
|||||||
return sq_throwerror(v,_SC("cannot open the file"));
|
return sq_throwerror(v,_SC("cannot open the file"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_dofile(HRABBITVM v,const SQChar *filename,SQBool retval,SQBool printerror)
|
SQRESULT sqstd_dofile(rabbit::VirtualMachine* v,const SQChar *filename,SQBool retval,SQBool printerror)
|
||||||
{
|
{
|
||||||
//at least one entry must exist in order for us to push it as the environment
|
//at least one entry must exist in order for us to push it as the environment
|
||||||
if(sq_gettop(v) == 0)
|
if(sq_gettop(v) == 0)
|
||||||
@ -421,7 +421,7 @@ SQRESULT sqstd_dofile(HRABBITVM v,const SQChar *filename,SQBool retval,SQBool pr
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_writeclosuretofile(HRABBITVM v,const SQChar *filename)
|
SQRESULT sqstd_writeclosuretofile(rabbit::VirtualMachine* v,const SQChar *filename)
|
||||||
{
|
{
|
||||||
SQFILE file = sqstd_fopen(filename,_SC("wb+"));
|
SQFILE file = sqstd_fopen(filename,_SC("wb+"));
|
||||||
if(!file) return sq_throwerror(v,_SC("cannot open the file"));
|
if(!file) return sq_throwerror(v,_SC("cannot open the file"));
|
||||||
@ -433,7 +433,7 @@ SQRESULT sqstd_writeclosuretofile(HRABBITVM v,const SQChar *filename)
|
|||||||
return SQ_ERROR; //forward the error
|
return SQ_ERROR; //forward the error
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _g_io_loadfile(HRABBITVM v)
|
int64_t _g_io_loadfile(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *filename;
|
const SQChar *filename;
|
||||||
SQBool printerror = SQFalse;
|
SQBool printerror = SQFalse;
|
||||||
@ -446,7 +446,7 @@ int64_t _g_io_loadfile(HRABBITVM v)
|
|||||||
return SQ_ERROR; //propagates the error
|
return SQ_ERROR; //propagates the error
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _g_io_writeclosuretofile(HRABBITVM v)
|
int64_t _g_io_writeclosuretofile(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *filename;
|
const SQChar *filename;
|
||||||
sq_getstring(v,2,&filename);
|
sq_getstring(v,2,&filename);
|
||||||
@ -455,7 +455,7 @@ int64_t _g_io_writeclosuretofile(HRABBITVM v)
|
|||||||
return SQ_ERROR; //propagates the error
|
return SQ_ERROR; //propagates the error
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _g_io_dofile(HRABBITVM v)
|
int64_t _g_io_dofile(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *filename;
|
const SQChar *filename;
|
||||||
SQBool printerror = SQFalse;
|
SQBool printerror = SQFalse;
|
||||||
@ -477,7 +477,7 @@ static const SQRegFunction iolib_funcs[]={
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
SQRESULT sqstd_register_iolib(HRABBITVM v)
|
SQRESULT sqstd_register_iolib(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
//create delegate
|
//create delegate
|
||||||
|
@ -36,13 +36,13 @@ RABBIT_API int64_t sqstd_fflush(SQFILE);
|
|||||||
RABBIT_API int64_t sqstd_fclose(SQFILE);
|
RABBIT_API int64_t sqstd_fclose(SQFILE);
|
||||||
RABBIT_API int64_t sqstd_feof(SQFILE);
|
RABBIT_API int64_t sqstd_feof(SQFILE);
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_createfile(HRABBITVM v, SQFILE file,SQBool own);
|
RABBIT_API SQRESULT sqstd_createfile(rabbit::VirtualMachine* v, SQFILE file,SQBool own);
|
||||||
RABBIT_API SQRESULT sqstd_getfile(HRABBITVM v, int64_t idx, SQFILE *file);
|
RABBIT_API SQRESULT sqstd_getfile(rabbit::VirtualMachine* v, int64_t idx, SQFILE *file);
|
||||||
|
|
||||||
//compiler helpers
|
//compiler helpers
|
||||||
RABBIT_API SQRESULT sqstd_loadfile(HRABBITVM v,const SQChar *filename,SQBool printerror);
|
RABBIT_API SQRESULT sqstd_loadfile(rabbit::VirtualMachine* v,const SQChar *filename,SQBool printerror);
|
||||||
RABBIT_API SQRESULT sqstd_dofile(HRABBITVM v,const SQChar *filename,SQBool retval,SQBool printerror);
|
RABBIT_API SQRESULT sqstd_dofile(rabbit::VirtualMachine* v,const SQChar *filename,SQBool retval,SQBool printerror);
|
||||||
RABBIT_API SQRESULT sqstd_writeclosuretofile(HRABBITVM v,const SQChar *filename);
|
RABBIT_API SQRESULT sqstd_writeclosuretofile(rabbit::VirtualMachine* v,const SQChar *filename);
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_register_iolib(HRABBITVM v);
|
RABBIT_API SQRESULT sqstd_register_iolib(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
|
@ -11,14 +11,14 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rabbit-std/sqstdmath.hpp>
|
#include <rabbit-std/sqstdmath.hpp>
|
||||||
|
|
||||||
#define SINGLE_ARG_FUNC(_funcname) static int64_t math_##_funcname(HRABBITVM v){ \
|
#define SINGLE_ARG_FUNC(_funcname) static int64_t math_##_funcname(rabbit::VirtualMachine* v){ \
|
||||||
float_t f; \
|
float_t f; \
|
||||||
sq_getfloat(v,2,&f); \
|
sq_getfloat(v,2,&f); \
|
||||||
sq_pushfloat(v,(float_t)_funcname(f)); \
|
sq_pushfloat(v,(float_t)_funcname(f)); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TWO_ARGS_FUNC(_funcname) static int64_t math_##_funcname(HRABBITVM v){ \
|
#define TWO_ARGS_FUNC(_funcname) static int64_t math_##_funcname(rabbit::VirtualMachine* v){ \
|
||||||
float_t p1,p2; \
|
float_t p1,p2; \
|
||||||
sq_getfloat(v,2,&p1); \
|
sq_getfloat(v,2,&p1); \
|
||||||
sq_getfloat(v,3,&p2); \
|
sq_getfloat(v,3,&p2); \
|
||||||
@ -26,7 +26,7 @@
|
|||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t math_srand(HRABBITVM v)
|
static int64_t math_srand(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i;
|
int64_t i;
|
||||||
if(SQ_FAILED(sq_getinteger(v,2,&i)))
|
if(SQ_FAILED(sq_getinteger(v,2,&i)))
|
||||||
@ -35,13 +35,13 @@ static int64_t math_srand(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t math_rand(HRABBITVM v)
|
static int64_t math_rand(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushinteger(v,rand());
|
sq_pushinteger(v,rand());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t math_abs(HRABBITVM v)
|
static int64_t math_abs(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t n;
|
int64_t n;
|
||||||
sq_getinteger(v,2,&n);
|
sq_getinteger(v,2,&n);
|
||||||
@ -93,7 +93,7 @@ static const SQRegFunction mathlib_funcs[] = {
|
|||||||
#define M_PI (3.14159265358979323846)
|
#define M_PI (3.14159265358979323846)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SQRESULT sqstd_register_mathlib(HRABBITVM v)
|
SQRESULT sqstd_register_mathlib(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i=0;
|
int64_t i=0;
|
||||||
while(mathlib_funcs[i].name!=0) {
|
while(mathlib_funcs[i].name!=0) {
|
||||||
|
@ -9,5 +9,5 @@
|
|||||||
|
|
||||||
#include <rabbit/rabbit.hpp>
|
#include <rabbit/rabbit.hpp>
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_register_mathlib(HRABBITVM v);
|
RABBIT_API SQRESULT sqstd_register_mathlib(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
if(!self || !self->IsValid()) \
|
if(!self || !self->IsValid()) \
|
||||||
return sq_throwerror(v,_SC("the stream is invalid"));
|
return sq_throwerror(v,_SC("the stream is invalid"));
|
||||||
|
|
||||||
int64_t _stream_readblob(HRABBITVM v)
|
int64_t _stream_readblob(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
SQUserPointer data,blobp;
|
SQUserPointer data,blobp;
|
||||||
@ -44,7 +44,7 @@ int64_t _stream_readblob(HRABBITVM v)
|
|||||||
#define SAFE_READN(ptr,len) { \
|
#define SAFE_READN(ptr,len) { \
|
||||||
if(self->Read(ptr,len) != len) return sq_throwerror(v,_SC("io error")); \
|
if(self->Read(ptr,len) != len) return sq_throwerror(v,_SC("io error")); \
|
||||||
}
|
}
|
||||||
int64_t _stream_readn(HRABBITVM v)
|
int64_t _stream_readn(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
int64_t format;
|
int64_t format;
|
||||||
@ -104,7 +104,7 @@ int64_t _stream_readn(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_writeblob(HRABBITVM v)
|
int64_t _stream_writeblob(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQUserPointer data;
|
SQUserPointer data;
|
||||||
int64_t size;
|
int64_t size;
|
||||||
@ -118,7 +118,7 @@ int64_t _stream_writeblob(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_writen(HRABBITVM v)
|
int64_t _stream_writen(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
int64_t format, ti;
|
int64_t format, ti;
|
||||||
@ -187,7 +187,7 @@ int64_t _stream_writen(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_seek(HRABBITVM v)
|
int64_t _stream_seek(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
int64_t offset, origin = SQ_SEEK_SET;
|
int64_t offset, origin = SQ_SEEK_SET;
|
||||||
@ -206,21 +206,21 @@ int64_t _stream_seek(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_tell(HRABBITVM v)
|
int64_t _stream_tell(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
sq_pushinteger(v, self->Tell());
|
sq_pushinteger(v, self->Tell());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_len(HRABBITVM v)
|
int64_t _stream_len(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
sq_pushinteger(v, self->Len());
|
sq_pushinteger(v, self->Len());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_flush(HRABBITVM v)
|
int64_t _stream_flush(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
if(!self->Flush())
|
if(!self->Flush())
|
||||||
@ -230,7 +230,7 @@ int64_t _stream_flush(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream_eos(HRABBITVM v)
|
int64_t _stream_eos(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_STREAM(v);
|
SETUP_STREAM(v);
|
||||||
if(self->EOS())
|
if(self->EOS())
|
||||||
@ -240,7 +240,7 @@ int64_t _stream_eos(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t _stream__cloned(HRABBITVM v)
|
int64_t _stream__cloned(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return sq_throwerror(v,_SC("this object cannot be cloned"));
|
return sq_throwerror(v,_SC("this object cannot be cloned"));
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ static const SQRegFunction _stream_methods[] = {
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
void init_streamclass(HRABBITVM v)
|
void init_streamclass(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushregistrytable(v);
|
sq_pushregistrytable(v);
|
||||||
sq_pushstring(v,_SC("std_stream"),-1);
|
sq_pushstring(v,_SC("std_stream"),-1);
|
||||||
@ -290,7 +290,7 @@ void init_streamclass(HRABBITVM v)
|
|||||||
sq_pop(v,1);
|
sq_pop(v,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT declare_stream(HRABBITVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,const SQRegFunction *methods,const SQRegFunction *globals)
|
SQRESULT declare_stream(rabbit::VirtualMachine* v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,const SQRegFunction *methods,const SQRegFunction *globals)
|
||||||
{
|
{
|
||||||
if(sq_gettype(v,-1) != OT_TABLE)
|
if(sq_gettype(v,-1) != OT_TABLE)
|
||||||
return sq_throwerror(v,_SC("table expected"));
|
return sq_throwerror(v,_SC("table expected"));
|
||||||
|
@ -7,16 +7,16 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
int64_t _stream_readblob(HRABBITVM v);
|
int64_t _stream_readblob(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_readline(HRABBITVM v);
|
int64_t _stream_readline(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_readn(HRABBITVM v);
|
int64_t _stream_readn(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_writeblob(HRABBITVM v);
|
int64_t _stream_writeblob(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_writen(HRABBITVM v);
|
int64_t _stream_writen(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_seek(HRABBITVM v);
|
int64_t _stream_seek(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_tell(HRABBITVM v);
|
int64_t _stream_tell(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_len(HRABBITVM v);
|
int64_t _stream_len(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_eos(HRABBITVM v);
|
int64_t _stream_eos(rabbit::VirtualMachine* v);
|
||||||
int64_t _stream_flush(HRABBITVM v);
|
int64_t _stream_flush(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
#define _DECL_STREAM_FUNC(name,nparams,typecheck) {_SC(#name),_stream_##name,nparams,typecheck}
|
#define _DECL_STREAM_FUNC(name,nparams,typecheck) {_SC(#name),_stream_##name,nparams,typecheck}
|
||||||
SQRESULT declare_stream(HRABBITVM v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,const SQRegFunction *methods,const SQRegFunction *globals);
|
SQRESULT declare_stream(rabbit::VirtualMachine* v,const SQChar* name,SQUserPointer typetag,const SQChar* reg_name,const SQRegFunction *methods,const SQRegFunction *globals);
|
||||||
|
@ -26,7 +26,7 @@ static SQBool isfmtchr(SQChar ch)
|
|||||||
return SQFalse;
|
return SQFalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t validate_format(HRABBITVM v, SQChar *fmt, const SQChar *src, int64_t n,int64_t &width)
|
static int64_t validate_format(rabbit::VirtualMachine* v, SQChar *fmt, const SQChar *src, int64_t n,int64_t &width)
|
||||||
{
|
{
|
||||||
SQChar *dummy;
|
SQChar *dummy;
|
||||||
SQChar swidth[MAX_WFORMAT_LEN];
|
SQChar swidth[MAX_WFORMAT_LEN];
|
||||||
@ -71,7 +71,7 @@ static int64_t validate_format(HRABBITVM v, SQChar *fmt, const SQChar *src, int6
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sqstd_format(HRABBITVM v,int64_t nformatstringidx,int64_t *outlen,SQChar **output)
|
SQRESULT sqstd_format(rabbit::VirtualMachine* v,int64_t nformatstringidx,int64_t *outlen,SQChar **output)
|
||||||
{
|
{
|
||||||
const SQChar *format;
|
const SQChar *format;
|
||||||
SQChar *dest;
|
SQChar *dest;
|
||||||
@ -160,7 +160,7 @@ SQRESULT sqstd_format(HRABBITVM v,int64_t nformatstringidx,int64_t *outlen,SQCha
|
|||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_printf(HRABBITVM v)
|
static int64_t _string_printf(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQChar *dest = NULL;
|
SQChar *dest = NULL;
|
||||||
int64_t length = 0;
|
int64_t length = 0;
|
||||||
@ -173,7 +173,7 @@ static int64_t _string_printf(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_format(HRABBITVM v)
|
static int64_t _string_format(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQChar *dest = NULL;
|
SQChar *dest = NULL;
|
||||||
int64_t length = 0;
|
int64_t length = 0;
|
||||||
@ -201,7 +201,7 @@ static void __strip_r(const SQChar *str,int64_t len,const SQChar **end)
|
|||||||
*end = t + 1;
|
*end = t + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_strip(HRABBITVM v)
|
static int64_t _string_strip(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*start,*end;
|
const SQChar *str,*start,*end;
|
||||||
sq_getstring(v,2,&str);
|
sq_getstring(v,2,&str);
|
||||||
@ -212,7 +212,7 @@ static int64_t _string_strip(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_lstrip(HRABBITVM v)
|
static int64_t _string_lstrip(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*start;
|
const SQChar *str,*start;
|
||||||
sq_getstring(v,2,&str);
|
sq_getstring(v,2,&str);
|
||||||
@ -221,7 +221,7 @@ static int64_t _string_lstrip(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_rstrip(HRABBITVM v)
|
static int64_t _string_rstrip(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*end;
|
const SQChar *str,*end;
|
||||||
sq_getstring(v,2,&str);
|
sq_getstring(v,2,&str);
|
||||||
@ -231,7 +231,7 @@ static int64_t _string_rstrip(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_split(HRABBITVM v)
|
static int64_t _string_split(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*seps;
|
const SQChar *str,*seps;
|
||||||
SQChar *stemp;
|
SQChar *stemp;
|
||||||
@ -269,7 +269,7 @@ static int64_t _string_split(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_escape(HRABBITVM v)
|
static int64_t _string_escape(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str;
|
const SQChar *str;
|
||||||
SQChar *dest,*resstr;
|
SQChar *dest,*resstr;
|
||||||
@ -339,7 +339,7 @@ static int64_t _string_escape(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_startswith(HRABBITVM v)
|
static int64_t _string_startswith(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*cmp;
|
const SQChar *str,*cmp;
|
||||||
sq_getstring(v,2,&str);
|
sq_getstring(v,2,&str);
|
||||||
@ -354,7 +354,7 @@ static int64_t _string_startswith(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _string_endswith(HRABBITVM v)
|
static int64_t _string_endswith(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str,*cmp;
|
const SQChar *str,*cmp;
|
||||||
sq_getstring(v,2,&str);
|
sq_getstring(v,2,&str);
|
||||||
@ -380,7 +380,7 @@ static int64_t _rexobj_releasehook(SQUserPointer p, int64_t SQ_UNUSED_ARG(size))
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp_match(HRABBITVM v)
|
static int64_t _regexp_match(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_REX(v);
|
SETUP_REX(v);
|
||||||
const SQChar *str;
|
const SQChar *str;
|
||||||
@ -394,7 +394,7 @@ static int64_t _regexp_match(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _addrexmatch(HRABBITVM v,const SQChar *str,const SQChar *begin,const SQChar *end)
|
static void _addrexmatch(rabbit::VirtualMachine* v,const SQChar *str,const SQChar *begin,const SQChar *end)
|
||||||
{
|
{
|
||||||
sq_newtable(v);
|
sq_newtable(v);
|
||||||
sq_pushstring(v,_SC("begin"),-1);
|
sq_pushstring(v,_SC("begin"),-1);
|
||||||
@ -405,7 +405,7 @@ static void _addrexmatch(HRABBITVM v,const SQChar *str,const SQChar *begin,const
|
|||||||
sq_rawset(v,-3);
|
sq_rawset(v,-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp_search(HRABBITVM v)
|
static int64_t _regexp_search(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_REX(v);
|
SETUP_REX(v);
|
||||||
const SQChar *str,*begin,*end;
|
const SQChar *str,*begin,*end;
|
||||||
@ -419,7 +419,7 @@ static int64_t _regexp_search(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp_capture(HRABBITVM v)
|
static int64_t _regexp_capture(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_REX(v);
|
SETUP_REX(v);
|
||||||
const SQChar *str,*begin,*end;
|
const SQChar *str,*begin,*end;
|
||||||
@ -443,14 +443,14 @@ static int64_t _regexp_capture(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp_subexpcount(HRABBITVM v)
|
static int64_t _regexp_subexpcount(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SETUP_REX(v);
|
SETUP_REX(v);
|
||||||
sq_pushinteger(v,sqstd_rex_getsubexpcount(self));
|
sq_pushinteger(v,sqstd_rex_getsubexpcount(self));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp_constructor(HRABBITVM v)
|
static int64_t _regexp_constructor(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *error,*pattern;
|
const SQChar *error,*pattern;
|
||||||
sq_getstring(v,2,&pattern);
|
sq_getstring(v,2,&pattern);
|
||||||
@ -461,7 +461,7 @@ static int64_t _regexp_constructor(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _regexp__typeof(HRABBITVM v)
|
static int64_t _regexp__typeof(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushstring(v,_SC("regexp"),-1);
|
sq_pushstring(v,_SC("regexp"),-1);
|
||||||
return 1;
|
return 1;
|
||||||
@ -495,7 +495,7 @@ static const SQRegFunction stringlib_funcs[]={
|
|||||||
#undef _DECL_FUNC
|
#undef _DECL_FUNC
|
||||||
|
|
||||||
|
|
||||||
int64_t sqstd_register_stringlib(HRABBITVM v)
|
int64_t sqstd_register_stringlib(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushstring(v,_SC("regexp"),-1);
|
sq_pushstring(v,_SC("regexp"),-1);
|
||||||
sq_newclass(v,SQFalse);
|
sq_newclass(v,SQFalse);
|
||||||
|
@ -23,7 +23,7 @@ RABBIT_API SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,cons
|
|||||||
RABBIT_API int64_t sqstd_rex_getsubexpcount(SQRex* exp);
|
RABBIT_API int64_t sqstd_rex_getsubexpcount(SQRex* exp);
|
||||||
RABBIT_API SQBool sqstd_rex_getsubexp(SQRex* exp, int64_t n, SQRexMatch *subexp);
|
RABBIT_API SQBool sqstd_rex_getsubexp(SQRex* exp, int64_t n, SQRexMatch *subexp);
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_format(HRABBITVM v,int64_t nformatstringidx,int64_t *outlen,SQChar **output);
|
RABBIT_API SQRESULT sqstd_format(rabbit::VirtualMachine* v,int64_t nformatstringidx,int64_t *outlen,SQChar **output);
|
||||||
|
|
||||||
RABBIT_API SQRESULT sqstd_register_stringlib(HRABBITVM v);
|
RABBIT_API SQRESULT sqstd_register_stringlib(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
#define screname rename
|
#define screname rename
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int64_t _system_getenv(HRABBITVM v)
|
static int64_t _system_getenv(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *s;
|
const SQChar *s;
|
||||||
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
||||||
@ -38,7 +38,7 @@ static int64_t _system_getenv(HRABBITVM v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t _system_system(HRABBITVM v)
|
static int64_t _system_system(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *s;
|
const SQChar *s;
|
||||||
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
if(SQ_SUCCEEDED(sq_getstring(v,2,&s))){
|
||||||
@ -49,20 +49,20 @@ static int64_t _system_system(HRABBITVM v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t _system_clock(HRABBITVM v)
|
static int64_t _system_clock(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_pushfloat(v,((float_t)clock())/(float_t)CLOCKS_PER_SEC);
|
sq_pushfloat(v,((float_t)clock())/(float_t)CLOCKS_PER_SEC);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _system_time(HRABBITVM v)
|
static int64_t _system_time(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t t = (int64_t)time(NULL);
|
int64_t t = (int64_t)time(NULL);
|
||||||
sq_pushinteger(v,t);
|
sq_pushinteger(v,t);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _system_remove(HRABBITVM v)
|
static int64_t _system_remove(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *s;
|
const SQChar *s;
|
||||||
sq_getstring(v,2,&s);
|
sq_getstring(v,2,&s);
|
||||||
@ -71,7 +71,7 @@ static int64_t _system_remove(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _system_rename(HRABBITVM v)
|
static int64_t _system_rename(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *oldn,*newn;
|
const SQChar *oldn,*newn;
|
||||||
sq_getstring(v,2,&oldn);
|
sq_getstring(v,2,&oldn);
|
||||||
@ -81,14 +81,14 @@ static int64_t _system_rename(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _set_integer_slot(HRABBITVM v,const SQChar *name,int64_t val)
|
static void _set_integer_slot(rabbit::VirtualMachine* v,const SQChar *name,int64_t val)
|
||||||
{
|
{
|
||||||
sq_pushstring(v,name,-1);
|
sq_pushstring(v,name,-1);
|
||||||
sq_pushinteger(v,val);
|
sq_pushinteger(v,val);
|
||||||
sq_rawset(v,-3);
|
sq_rawset(v,-3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _system_date(HRABBITVM v)
|
static int64_t _system_date(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
time_t t;
|
time_t t;
|
||||||
int64_t it;
|
int64_t it;
|
||||||
@ -137,7 +137,7 @@ static const SQRegFunction systemlib_funcs[]={
|
|||||||
};
|
};
|
||||||
#undef _DECL_FUNC
|
#undef _DECL_FUNC
|
||||||
|
|
||||||
int64_t sqstd_register_systemlib(HRABBITVM v)
|
int64_t sqstd_register_systemlib(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i=0;
|
int64_t i=0;
|
||||||
while(systemlib_funcs[i].name!=0)
|
while(systemlib_funcs[i].name!=0)
|
||||||
|
@ -7,4 +7,4 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
RABBIT_API int64_t sqstd_register_systemlib(HRABBITVM v);
|
RABBIT_API int64_t sqstd_register_systemlib(rabbit::VirtualMachine* v);
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <rabbit/sqopcodes.hpp>
|
#include <rabbit/sqopcodes.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqfuncproto.hpp>
|
#include <rabbit/sqfuncproto.hpp>
|
||||||
#include <rabbit/sqclosure.hpp>
|
#include <rabbit/sqclosure.hpp>
|
||||||
#include <rabbit/sqstring.hpp>
|
#include <rabbit/sqstring.hpp>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
#define TARGET _stack[_stackbase+arg0]
|
#define TARGET _stack[_stackbase+arg0]
|
||||||
#define STK(a) _stack[_stackbase+(a)]
|
#define STK(a) _stack[_stackbase+(a)]
|
||||||
|
|
||||||
bool SQVM::BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
bool rabbit::VirtualMachine::BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
||||||
{
|
{
|
||||||
int64_t res;
|
int64_t res;
|
||||||
if((sq_type(o1)| sq_type(o2)) == OT_INTEGER)
|
if((sq_type(o1)| sq_type(o2)) == OT_INTEGER)
|
||||||
@ -65,7 +65,7 @@ bool SQVM::BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObje
|
|||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
bool rabbit::VirtualMachine::ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2)
|
||||||
{
|
{
|
||||||
int64_t tmask = sq_type(o1)| sq_type(o2);
|
int64_t tmask = sq_type(o1)| sq_type(o2);
|
||||||
switch(tmask) {
|
switch(tmask) {
|
||||||
@ -111,7 +111,7 @@ bool SQVM::ARITH_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQO
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQVM::SQVM(SQSharedState *ss)
|
rabbit::VirtualMachine::VirtualMachine(SQSharedState *ss)
|
||||||
{
|
{
|
||||||
_sharedstate=ss;
|
_sharedstate=ss;
|
||||||
_suspended = SQFalse;
|
_suspended = SQFalse;
|
||||||
@ -131,7 +131,7 @@ SQVM::SQVM(SQSharedState *ss)
|
|||||||
_releasehook = NULL;
|
_releasehook = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::finalize()
|
void rabbit::VirtualMachine::finalize()
|
||||||
{
|
{
|
||||||
if(_releasehook) { _releasehook(_foreignptr,0); _releasehook = NULL; }
|
if(_releasehook) { _releasehook(_foreignptr,0); _releasehook = NULL; }
|
||||||
if(_openouters) closeOuters(&_stack[0]);
|
if(_openouters) closeOuters(&_stack[0]);
|
||||||
@ -148,12 +148,12 @@ void SQVM::finalize()
|
|||||||
_stack[i].Null();
|
_stack[i].Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
SQVM::~SQVM()
|
rabbit::VirtualMachine::~VirtualMachine()
|
||||||
{
|
{
|
||||||
finalize();
|
finalize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::arithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &dest)
|
bool rabbit::VirtualMachine::arithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
SQMetaMethod mm;
|
SQMetaMethod mm;
|
||||||
switch(op){
|
switch(op){
|
||||||
@ -177,7 +177,7 @@ bool SQVM::arithMetaMethod(int64_t op,const SQObjectPtr &o1,const SQObjectPtr &o
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
bool rabbit::VirtualMachine::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch(sq_type(o)) {
|
switch(sq_type(o)) {
|
||||||
@ -207,7 +207,7 @@ bool SQVM::NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define _RET_SUCCEED(exp) { result = (exp); return true; }
|
#define _RET_SUCCEED(exp) { result = (exp); return true; }
|
||||||
bool SQVM::objCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result)
|
bool rabbit::VirtualMachine::objCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result)
|
||||||
{
|
{
|
||||||
SQObjectType t1 = sq_type(o1), t2 = sq_type(o2);
|
SQObjectType t1 = sq_type(o1), t2 = sq_type(o2);
|
||||||
if(t1 == t2) {
|
if(t1 == t2) {
|
||||||
@ -268,7 +268,7 @@ bool SQVM::objCmp(const SQObjectPtr &o1,const SQObjectPtr &o2,int64_t &result)
|
|||||||
_RET_SUCCEED(0); //cannot happen
|
_RET_SUCCEED(0); //cannot happen
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res)
|
bool rabbit::VirtualMachine::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
int64_t r;
|
int64_t r;
|
||||||
if(objCmp(o1,o2,r)) {
|
if(objCmp(o1,o2,r)) {
|
||||||
@ -284,7 +284,7 @@ bool SQVM::CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObject
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::toString(const SQObjectPtr &o,SQObjectPtr &res)
|
bool rabbit::VirtualMachine::toString(const SQObjectPtr &o,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
switch(sq_type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_STRING:
|
case OT_STRING:
|
||||||
@ -323,7 +323,7 @@ bool SQVM::toString(const SQObjectPtr &o,SQObjectPtr &res)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SQVM::stringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &dest)
|
bool rabbit::VirtualMachine::stringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
SQObjectPtr a, b;
|
SQObjectPtr a, b;
|
||||||
if(!toString(str, a)) return false;
|
if(!toString(str, a)) return false;
|
||||||
@ -336,7 +336,7 @@ bool SQVM::stringCat(const SQObjectPtr &str,const SQObjectPtr &obj,SQObjectPtr &
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::typeOf(const SQObjectPtr &obj1,SQObjectPtr &dest)
|
bool rabbit::VirtualMachine::typeOf(const SQObjectPtr &obj1,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
if(is_delegable(obj1) && _delegable(obj1)->_delegate) {
|
if(is_delegable(obj1) && _delegable(obj1)->_delegate) {
|
||||||
SQObjectPtr closure;
|
SQObjectPtr closure;
|
||||||
@ -349,7 +349,7 @@ bool SQVM::typeOf(const SQObjectPtr &obj1,SQObjectPtr &dest)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::init(SQVM *friendvm, int64_t stacksize)
|
bool rabbit::VirtualMachine::init(rabbit::VirtualMachine *friendvm, int64_t stacksize)
|
||||||
{
|
{
|
||||||
_stack.resize(stacksize);
|
_stack.resize(stacksize);
|
||||||
_alloccallsstacksize = 4;
|
_alloccallsstacksize = 4;
|
||||||
@ -375,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 rabbit::VirtualMachine::startcall(SQClosure *closure,int64_t target,int64_t args,int64_t stackbase,bool tailcall)
|
||||||
{
|
{
|
||||||
SQFunctionProto *func = closure->_function;
|
SQFunctionProto *func = closure->_function;
|
||||||
|
|
||||||
@ -446,7 +446,7 @@ bool SQVM::startcall(SQClosure *closure,int64_t target,int64_t args,int64_t stac
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval)
|
bool rabbit::VirtualMachine::Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval)
|
||||||
{
|
{
|
||||||
SQBool _isroot = ci->_root;
|
SQBool _isroot = ci->_root;
|
||||||
int64_t callerbase = _stackbase - ci->_prevstkbase;
|
int64_t callerbase = _stackbase - ci->_prevstkbase;
|
||||||
@ -480,7 +480,7 @@ bool SQVM::Return(int64_t _arg0, int64_t _arg1, SQObjectPtr &retval)
|
|||||||
|
|
||||||
#define _RET_ON_FAIL(exp) { if(!exp) return false; }
|
#define _RET_ON_FAIL(exp) { if(!exp) return false; }
|
||||||
|
|
||||||
bool SQVM::PLOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr)
|
bool rabbit::VirtualMachine::PLOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPtr &incr)
|
||||||
{
|
{
|
||||||
SQObjectPtr trg;
|
SQObjectPtr trg;
|
||||||
_RET_ON_FAIL(ARITH_OP( op , trg, a, incr));
|
_RET_ON_FAIL(ARITH_OP( op , trg, a, incr));
|
||||||
@ -489,7 +489,7 @@ bool SQVM::PLOCAL_INC(int64_t op,SQObjectPtr &target, SQObjectPtr &a, SQObjectPt
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::derefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t selfidx)
|
bool rabbit::VirtualMachine::derefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectPtr &key, SQObjectPtr &incr, bool postfix,int64_t selfidx)
|
||||||
{
|
{
|
||||||
SQObjectPtr tmp, tself = self, tkey = key;
|
SQObjectPtr tmp, tself = self, tkey = key;
|
||||||
if (!get(tself, tkey, tmp, 0, selfidx)) { return false; }
|
if (!get(tself, tkey, tmp, 0, selfidx)) { return false; }
|
||||||
@ -507,7 +507,7 @@ bool SQVM::derefInc(int64_t op,SQObjectPtr &target, SQObjectPtr &self, SQObjectP
|
|||||||
#define arg3 (_i_._arg3)
|
#define arg3 (_i_._arg3)
|
||||||
#define sarg3 ((int64_t)*((const signed char *)&_i_._arg3))
|
#define sarg3 ((int64_t)*((const signed char *)&_i_._arg3))
|
||||||
|
|
||||||
SQRESULT SQVM::Suspend()
|
SQRESULT rabbit::VirtualMachine::Suspend()
|
||||||
{
|
{
|
||||||
if (_suspended)
|
if (_suspended)
|
||||||
return sq_throwerror(this, _SC("cannot suspend an already suspended vm"));
|
return sq_throwerror(this, _SC("cannot suspend an already suspended vm"));
|
||||||
@ -518,7 +518,7 @@ SQRESULT SQVM::Suspend()
|
|||||||
|
|
||||||
|
|
||||||
#define _FINISH(howmuchtojump) {jump = howmuchtojump; return true; }
|
#define _FINISH(howmuchtojump) {jump = howmuchtojump; return true; }
|
||||||
bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
bool rabbit::VirtualMachine::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
||||||
&o3,SQObjectPtr &o4,int64_t SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
|
&o3,SQObjectPtr &o4,int64_t SQ_UNUSED_ARG(arg_2),int exitpos,int &jump)
|
||||||
{
|
{
|
||||||
int64_t nrefidx;
|
int64_t nrefidx;
|
||||||
@ -584,7 +584,7 @@ bool SQVM::FOREACH_OP(SQObjectPtr &o1,SQObjectPtr &o2,SQObjectPtr
|
|||||||
|
|
||||||
#define _GUARD(exp) { if(!exp) { SQ_THROW();} }
|
#define _GUARD(exp) { if(!exp) { SQ_THROW();} }
|
||||||
|
|
||||||
bool SQVM::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func)
|
bool rabbit::VirtualMachine::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func)
|
||||||
{
|
{
|
||||||
int64_t nouters;
|
int64_t nouters;
|
||||||
SQClosure *closure = SQClosure::create(_ss(this), func,_table(_roottable)->getWeakRef(OT_TABLE));
|
SQClosure *closure = SQClosure::create(_ss(this), func,_table(_roottable)->getWeakRef(OT_TABLE));
|
||||||
@ -614,7 +614,7 @@ bool SQVM::CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SQVM::CLASS_OP(SQObjectPtr &target,int64_t baseclass,int64_t attributes)
|
bool rabbit::VirtualMachine::CLASS_OP(SQObjectPtr &target,int64_t baseclass,int64_t attributes)
|
||||||
{
|
{
|
||||||
SQClass *base = NULL;
|
SQClass *base = NULL;
|
||||||
SQObjectPtr attrs;
|
SQObjectPtr attrs;
|
||||||
@ -640,7 +640,7 @@ bool SQVM::CLASS_OP(SQObjectPtr &target,int64_t baseclass,int64_t attributes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::isEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
bool rabbit::VirtualMachine::isEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
||||||
{
|
{
|
||||||
if(sq_type(o1) == sq_type(o2)) {
|
if(sq_type(o1) == sq_type(o2)) {
|
||||||
res = (_rawval(o1) == _rawval(o2));
|
res = (_rawval(o1) == _rawval(o2));
|
||||||
@ -656,7 +656,7 @@ bool SQVM::isEqual(const SQObjectPtr &o1,const SQObjectPtr &o2,bool &res)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::IsFalse(SQObjectPtr &o)
|
bool rabbit::VirtualMachine::IsFalse(SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
if(((sq_type(o) & SQOBJECT_CANBEFALSE)
|
if(((sq_type(o) & SQOBJECT_CANBEFALSE)
|
||||||
&& ( ((sq_type(o) == OT_FLOAT) && (_float(o) == float_t(0.0))) ))
|
&& ( ((sq_type(o) == OT_FLOAT) && (_float(o) == float_t(0.0))) ))
|
||||||
@ -671,7 +671,7 @@ bool SQVM::IsFalse(SQObjectPtr &o)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
extern SQInstructionDesc g_InstrDesc[];
|
extern SQInstructionDesc g_InstrDesc[];
|
||||||
bool SQVM::execute(SQObjectPtr &closure, int64_t nargs, int64_t stackbase,SQObjectPtr &outres, SQBool raiseerror,ExecutionType et)
|
bool rabbit::VirtualMachine::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++;
|
_nnativecalls++;
|
||||||
@ -1103,7 +1103,7 @@ exception_trap:
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::createClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor)
|
bool rabbit::VirtualMachine::createClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr &constructor)
|
||||||
{
|
{
|
||||||
inst = theclass->createInstance();
|
inst = theclass->createInstance();
|
||||||
if(!theclass->getConstructor(constructor)) {
|
if(!theclass->getConstructor(constructor)) {
|
||||||
@ -1112,7 +1112,7 @@ bool SQVM::createClassInstance(SQClass *theclass, SQObjectPtr &inst, SQObjectPtr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::callerrorHandler(SQObjectPtr &error)
|
void rabbit::VirtualMachine::callerrorHandler(SQObjectPtr &error)
|
||||||
{
|
{
|
||||||
if(sq_type(_errorhandler) != OT_NULL) {
|
if(sq_type(_errorhandler) != OT_NULL) {
|
||||||
SQObjectPtr out;
|
SQObjectPtr out;
|
||||||
@ -1123,7 +1123,7 @@ void SQVM::callerrorHandler(SQObjectPtr &error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQVM::callDebugHook(int64_t type,int64_t forcedline)
|
void rabbit::VirtualMachine::callDebugHook(int64_t type,int64_t forcedline)
|
||||||
{
|
{
|
||||||
_debughook = false;
|
_debughook = false;
|
||||||
SQFunctionProto *func=_closure(ci->_closure)->_function;
|
SQFunctionProto *func=_closure(ci->_closure)->_function;
|
||||||
@ -1147,7 +1147,7 @@ void SQVM::callDebugHook(int64_t type,int64_t forcedline)
|
|||||||
_debughook = true;
|
_debughook = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::callNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase, SQObjectPtr &retval, int32_t target,bool &suspend, bool &tailcall)
|
bool rabbit::VirtualMachine::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 nparamscheck = nclosure->_nparamscheck;
|
||||||
int64_t newtop = newbase + nargs + nclosure->_noutervalues;
|
int64_t newtop = newbase + nargs + nclosure->_noutervalues;
|
||||||
@ -1216,7 +1216,7 @@ bool SQVM::callNative(SQNativeClosure *nclosure, int64_t nargs, int64_t newbase,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::tailcall(SQClosure *closure, int64_t parambase,int64_t nparams)
|
bool rabbit::VirtualMachine::tailcall(SQClosure *closure, int64_t parambase,int64_t nparams)
|
||||||
{
|
{
|
||||||
int64_t last_top = _top;
|
int64_t last_top = _top;
|
||||||
SQObjectPtr clo = closure;
|
SQObjectPtr clo = closure;
|
||||||
@ -1237,7 +1237,7 @@ bool SQVM::tailcall(SQClosure *closure, int64_t parambase,int64_t nparams)
|
|||||||
#define FALLBACK_NO_MATCH 1
|
#define FALLBACK_NO_MATCH 1
|
||||||
#define FALLBACK_ERROR 2
|
#define FALLBACK_ERROR 2
|
||||||
|
|
||||||
bool SQVM::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, uint64_t getflags, int64_t selfidx)
|
bool rabbit::VirtualMachine::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &dest, uint64_t getflags, int64_t selfidx)
|
||||||
{
|
{
|
||||||
switch(sq_type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
@ -1291,7 +1291,7 @@ bool SQVM::get(const SQObjectPtr &self, const SQObjectPtr &key, SQObjectPtr &des
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::invokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
bool rabbit::VirtualMachine::invokeDefaultDelegate(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
SQTable *ddel = NULL;
|
SQTable *ddel = NULL;
|
||||||
switch(sq_type(self)) {
|
switch(sq_type(self)) {
|
||||||
@ -1311,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 rabbit::VirtualMachine::fallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
switch(sq_type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
@ -1349,7 +1349,7 @@ int64_t SQVM::fallBackGet(const SQObjectPtr &self,const SQObjectPtr &key,SQObjec
|
|||||||
return FALLBACK_NO_MATCH;
|
return FALLBACK_NO_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,int64_t selfidx)
|
bool rabbit::VirtualMachine::set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,int64_t selfidx)
|
||||||
{
|
{
|
||||||
switch(sq_type(self)){
|
switch(sq_type(self)){
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
@ -1384,7 +1384,7 @@ bool SQVM::set(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t SQVM::fallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
|
int64_t rabbit::VirtualMachine::fallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val)
|
||||||
{
|
{
|
||||||
switch(sq_type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
@ -1419,7 +1419,7 @@ int64_t SQVM::fallBackSet(const SQObjectPtr &self,const SQObjectPtr &key,const S
|
|||||||
return FALLBACK_NO_MATCH;
|
return FALLBACK_NO_MATCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::clone(const SQObjectPtr &self,SQObjectPtr &target)
|
bool rabbit::VirtualMachine::clone(const SQObjectPtr &self,SQObjectPtr &target)
|
||||||
{
|
{
|
||||||
SQObjectPtr temp_reg;
|
SQObjectPtr temp_reg;
|
||||||
SQObjectPtr newobj;
|
SQObjectPtr newobj;
|
||||||
@ -1449,7 +1449,7 @@ cloned_mt:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::newSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
|
bool rabbit::VirtualMachine::newSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,const SQObjectPtr &attrs,bool bstatic,bool raw)
|
||||||
{
|
{
|
||||||
if(sq_type(self) != OT_CLASS) {
|
if(sq_type(self) != OT_CLASS) {
|
||||||
raise_error(_SC("object must be a class"));
|
raise_error(_SC("object must be a class"));
|
||||||
@ -1473,7 +1473,7 @@ bool SQVM::newSlotA(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjec
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::newSlot(const SQObjectPtr &self,const SQObjectPtr &key,const SQObjectPtr &val,bool bstatic)
|
bool rabbit::VirtualMachine::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)) {
|
switch(sq_type(self)) {
|
||||||
@ -1534,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 rabbit::VirtualMachine::deleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
switch(sq_type(self)) {
|
switch(sq_type(self)) {
|
||||||
case OT_TABLE:
|
case OT_TABLE:
|
||||||
@ -1572,7 +1572,7 @@ bool SQVM::deleteSlot(const SQObjectPtr &self,const SQObjectPtr &key,SQObjectPtr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::call(SQObjectPtr &closure,int64_t nparams,int64_t stackbase,SQObjectPtr &outres,SQBool raiseerror)
|
bool rabbit::VirtualMachine::call(SQObjectPtr &closure,int64_t nparams,int64_t stackbase,SQObjectPtr &outres,SQBool raiseerror)
|
||||||
{
|
{
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
int64_t prevstackbase = _stackbase;
|
int64_t prevstackbase = _stackbase;
|
||||||
@ -1610,7 +1610,7 @@ int64_t prevstackbase = _stackbase;
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::callMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),int64_t nparams,SQObjectPtr &outres)
|
bool rabbit::VirtualMachine::callMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),int64_t nparams,SQObjectPtr &outres)
|
||||||
{
|
{
|
||||||
//SQObjectPtr closure;
|
//SQObjectPtr closure;
|
||||||
|
|
||||||
@ -1626,7 +1626,7 @@ bool SQVM::callMetaMethod(SQObjectPtr &closure,SQMetaMethod SQ_UNUSED_ARG(mm),in
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::findOuter(SQObjectPtr &target, SQObjectPtr *stackindex)
|
void rabbit::VirtualMachine::findOuter(SQObjectPtr &target, SQObjectPtr *stackindex)
|
||||||
{
|
{
|
||||||
SQOuter **pp = &_openouters;
|
SQOuter **pp = &_openouters;
|
||||||
SQOuter *p;
|
SQOuter *p;
|
||||||
@ -1648,7 +1648,7 @@ void SQVM::findOuter(SQObjectPtr &target, SQObjectPtr *stackindex)
|
|||||||
target = SQObjectPtr(otr);
|
target = SQObjectPtr(otr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQVM::enterFrame(int64_t newbase, int64_t newtop, bool tailcall)
|
bool rabbit::VirtualMachine::enterFrame(int64_t newbase, int64_t newtop, bool tailcall)
|
||||||
{
|
{
|
||||||
if( !tailcall ) {
|
if( !tailcall ) {
|
||||||
if( _callsstacksize == _alloccallsstacksize ) {
|
if( _callsstacksize == _alloccallsstacksize ) {
|
||||||
@ -1679,7 +1679,7 @@ bool SQVM::enterFrame(int64_t newbase, int64_t newtop, bool tailcall)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::leaveFrame() {
|
void rabbit::VirtualMachine::leaveFrame() {
|
||||||
int64_t last_top = _top;
|
int64_t last_top = _top;
|
||||||
int64_t last_stackbase = _stackbase;
|
int64_t last_stackbase = _stackbase;
|
||||||
int64_t css = --_callsstacksize;
|
int64_t css = --_callsstacksize;
|
||||||
@ -1696,7 +1696,7 @@ void SQVM::leaveFrame() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::relocateOuters()
|
void rabbit::VirtualMachine::relocateOuters()
|
||||||
{
|
{
|
||||||
SQOuter *p = _openouters;
|
SQOuter *p = _openouters;
|
||||||
while (p) {
|
while (p) {
|
||||||
@ -1705,7 +1705,7 @@ void SQVM::relocateOuters()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::closeOuters(SQObjectPtr *stackindex) {
|
void rabbit::VirtualMachine::closeOuters(SQObjectPtr *stackindex) {
|
||||||
SQOuter *p;
|
SQOuter *p;
|
||||||
while ((p = _openouters) != NULL && p->_valptr >= stackindex) {
|
while ((p = _openouters) != NULL && p->_valptr >= stackindex) {
|
||||||
p->_value = *(p->_valptr);
|
p->_value = *(p->_valptr);
|
||||||
@ -1715,7 +1715,7 @@ void SQVM::closeOuters(SQObjectPtr *stackindex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::remove(int64_t n) {
|
void rabbit::VirtualMachine::remove(int64_t n) {
|
||||||
n = (n >= 0)?n + _stackbase - 1:_top + n;
|
n = (n >= 0)?n + _stackbase - 1:_top + n;
|
||||||
for(int64_t i = n; i < _top; i++){
|
for(int64_t i = n; i < _top; i++){
|
||||||
_stack[i] = _stack[i+1];
|
_stack[i] = _stack[i+1];
|
||||||
@ -1724,25 +1724,25 @@ void SQVM::remove(int64_t n) {
|
|||||||
_top--;
|
_top--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::pop() {
|
void rabbit::VirtualMachine::pop() {
|
||||||
_stack[--_top].Null();
|
_stack[--_top].Null();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::pop(int64_t n) {
|
void rabbit::VirtualMachine::pop(int64_t n) {
|
||||||
for(int64_t i = 0; i < n; i++){
|
for(int64_t i = 0; i < n; i++){
|
||||||
_stack[--_top].Null();
|
_stack[--_top].Null();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::pushNull() { _stack[_top++].Null(); }
|
void rabbit::VirtualMachine::pushNull() { _stack[_top++].Null(); }
|
||||||
void SQVM::push(const SQObjectPtr &o) { _stack[_top++] = o; }
|
void rabbit::VirtualMachine::push(const SQObjectPtr &o) { _stack[_top++] = o; }
|
||||||
SQObjectPtr &SQVM::top() { return _stack[_top-1]; }
|
SQObjectPtr &rabbit::VirtualMachine::top() { return _stack[_top-1]; }
|
||||||
SQObjectPtr &SQVM::popGet() { return _stack[--_top]; }
|
SQObjectPtr &rabbit::VirtualMachine::popGet() { return _stack[--_top]; }
|
||||||
SQObjectPtr &SQVM::getUp(int64_t n) { return _stack[_top+n]; }
|
SQObjectPtr &rabbit::VirtualMachine::getUp(int64_t n) { return _stack[_top+n]; }
|
||||||
SQObjectPtr &SQVM::getAt(int64_t n) { return _stack[n]; }
|
SQObjectPtr &rabbit::VirtualMachine::getAt(int64_t n) { return _stack[n]; }
|
||||||
|
|
||||||
#ifdef _DEBUG_DUMP
|
#ifdef _DEBUG_DUMP
|
||||||
void SQVM::dumpstack(int64_t stackbase,bool dumpall)
|
void rabbit::VirtualMachine::dumpstack(int64_t stackbase,bool dumpall)
|
||||||
{
|
{
|
||||||
int64_t size=dumpall?_stack.size():_top;
|
int64_t size=dumpall?_stack.size():_top;
|
||||||
int64_t n=0;
|
int64_t n=0;
|
223
rabbit/VirtualMachine.hpp
Normal file
223
rabbit/VirtualMachine.hpp
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
/**
|
||||||
|
* @author Alberto DEMICHELIS
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
* @copyright 2018, Edouard DUPIN, all right reserved
|
||||||
|
* @copyright 2003-2017, Alberto DEMICHELIS, all right reserved
|
||||||
|
* @license MPL-2 (see license file)
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <rabbit/sqopcodes.hpp>
|
||||||
|
#include <rabbit/sqobject.hpp>
|
||||||
|
|
||||||
|
#define MAX_NATIVE_CALLS 100
|
||||||
|
#define MIN_STACK_OVERHEAD 15
|
||||||
|
|
||||||
|
#define SQ_SUSPEND_FLAG -666
|
||||||
|
#define SQ_TAILCALL_FLAG -777
|
||||||
|
#define DONT_FALL_BACK 666
|
||||||
|
//#define EXISTS_FALL_BACK -1
|
||||||
|
|
||||||
|
#define GET_FLAG_RAW 0x00000001
|
||||||
|
#define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002
|
||||||
|
//base lib
|
||||||
|
void sq_base_register(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
|
struct SQExceptionTrap{
|
||||||
|
SQExceptionTrap() {}
|
||||||
|
SQExceptionTrap(int64_t ss, int64_t stackbase,SQInstruction *ip, int64_t ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;}
|
||||||
|
SQExceptionTrap(const SQExceptionTrap &et) { (*this) = et; }
|
||||||
|
int64_t _stackbase;
|
||||||
|
int64_t _stacksize;
|
||||||
|
SQInstruction *_ip;
|
||||||
|
int64_t _extarget;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define _INLINE
|
||||||
|
|
||||||
|
namespace rabbit {
|
||||||
|
class VirtualMachine : public rabbit::RefCounted
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct callInfo{
|
||||||
|
//callInfo() { _generator = NULL;}
|
||||||
|
SQInstruction *_ip;
|
||||||
|
SQObjectPtr *_literals;
|
||||||
|
SQObjectPtr _closure;
|
||||||
|
SQGenerator *_generator;
|
||||||
|
int32_t _etraps;
|
||||||
|
int32_t _prevstkbase;
|
||||||
|
int32_t _prevtop;
|
||||||
|
int32_t _target;
|
||||||
|
int32_t _ncalls;
|
||||||
|
SQBool _root;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
void DebugHookProxy(int64_t type, const SQChar * sourcename, int64_t line, const SQChar * funcname);
|
||||||
|
static void _DebugHookProxy(rabbit::VirtualMachine* 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
|
||||||
|
};
|
||||||
|
VirtualMachine(SQSharedState *ss);
|
||||||
|
~VirtualMachine();
|
||||||
|
bool init(VirtualMachine *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);
|
||||||
|
//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 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);
|
||||||
|
SQRESULT Suspend();
|
||||||
|
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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);
|
||||||
|
bool BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2);
|
||||||
|
bool NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o1);
|
||||||
|
bool CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res);
|
||||||
|
bool CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func);
|
||||||
|
bool CLASS_OP(SQObjectPtr &target,int64_t base,int64_t attrs);
|
||||||
|
//return true if the loop is finished
|
||||||
|
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);
|
||||||
|
#ifdef _DEBUG_DUMP
|
||||||
|
void dumpstack(int64_t stackbase=-1, bool dumpall = false);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
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();
|
||||||
|
void release() {
|
||||||
|
sq_delete(this,VirtualMachine);
|
||||||
|
}
|
||||||
|
////////////////////////////////////////////////////////////////////////////
|
||||||
|
//stack functions for the api
|
||||||
|
void remove(int64_t n);
|
||||||
|
|
||||||
|
static bool IsFalse(SQObjectPtr &o);
|
||||||
|
|
||||||
|
void pop();
|
||||||
|
void pop(int64_t n);
|
||||||
|
void push(const SQObjectPtr &o);
|
||||||
|
void pushNull();
|
||||||
|
SQObjectPtr& top();
|
||||||
|
SQObjectPtr& popGet();
|
||||||
|
SQObjectPtr& getUp(int64_t n);
|
||||||
|
SQObjectPtr& getAt(int64_t n);
|
||||||
|
|
||||||
|
SQObjectPtrVec _stack;
|
||||||
|
|
||||||
|
int64_t _top;
|
||||||
|
int64_t _stackbase;
|
||||||
|
SQOuter* _openouters;
|
||||||
|
SQObjectPtr _roottable;
|
||||||
|
SQObjectPtr _lasterror;
|
||||||
|
SQObjectPtr _errorhandler;
|
||||||
|
|
||||||
|
bool _debughook;
|
||||||
|
SQDEBUGHOOK _debughook_native;
|
||||||
|
SQObjectPtr _debughook_closure;
|
||||||
|
|
||||||
|
SQObjectPtr temp_reg;
|
||||||
|
|
||||||
|
|
||||||
|
callInfo* _callsstack;
|
||||||
|
int64_t _callsstacksize;
|
||||||
|
int64_t _alloccallsstacksize;
|
||||||
|
etk::Vector<callInfo> _callstackdata;
|
||||||
|
|
||||||
|
etk::Vector<SQExceptionTrap> _etraps;
|
||||||
|
callInfo *ci;
|
||||||
|
SQUserPointer _foreignptr;
|
||||||
|
//VMs sharing the same state
|
||||||
|
SQSharedState *_sharedstate;
|
||||||
|
int64_t _nnativecalls;
|
||||||
|
int64_t _nmetamethodscall;
|
||||||
|
SQRELEASEHOOK _releasehook;
|
||||||
|
//suspend infos
|
||||||
|
SQBool _suspended;
|
||||||
|
SQBool _suspended_root;
|
||||||
|
int64_t _suspended_target;
|
||||||
|
int64_t _suspended_traps;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AutoDec{
|
||||||
|
AutoDec(int64_t *n) {
|
||||||
|
_n = n;
|
||||||
|
}
|
||||||
|
~AutoDec() {
|
||||||
|
(*_n)--;
|
||||||
|
}
|
||||||
|
int64_t *_n;
|
||||||
|
};
|
||||||
|
|
||||||
|
inline SQObjectPtr &stack_get(rabbit::VirtualMachine* _vm,int64_t _idx) {
|
||||||
|
if (_idx>=0) {
|
||||||
|
return _vm->getAt(_idx+_vm->_stackbase-1);
|
||||||
|
}
|
||||||
|
return _vm->getUp(_idx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#define _ss(_vm_) (_vm_)->_sharedstate
|
||||||
|
|
||||||
|
#define PUSH_CALLINFO(v,nci){ \
|
||||||
|
int64_t css = v->_callsstacksize; \
|
||||||
|
if(css == v->_alloccallsstacksize) { \
|
||||||
|
v->GrowcallStack(); \
|
||||||
|
} \
|
||||||
|
v->ci = &v->_callsstack[css]; \
|
||||||
|
*(v->ci) = nci; \
|
||||||
|
v->_callsstacksize++; \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define POP_CALLINFO(v){ \
|
||||||
|
int64_t css = --v->_callsstacksize; \
|
||||||
|
v->ci->_closure.Null(); \
|
||||||
|
v->ci = css?&v->_callsstack[css-1]:NULL; \
|
||||||
|
}
|
@ -25,7 +25,6 @@
|
|||||||
#define SQTrue (1)
|
#define SQTrue (1)
|
||||||
#define SQFalse (0)
|
#define SQFalse (0)
|
||||||
|
|
||||||
struct SQVM;
|
|
||||||
struct SQTable;
|
struct SQTable;
|
||||||
struct SQString;
|
struct SQString;
|
||||||
struct SQClosure;
|
struct SQClosure;
|
||||||
@ -41,6 +40,7 @@ namespace rabbit {
|
|||||||
class Array;
|
class Array;
|
||||||
class RefCounted;
|
class RefCounted;
|
||||||
class WeakRef;
|
class WeakRef;
|
||||||
|
class VirtualMachine;
|
||||||
|
|
||||||
}
|
}
|
||||||
#ifdef _UNICODE
|
#ifdef _UNICODE
|
||||||
@ -117,23 +117,25 @@ typedef enum tagSQObjectType{
|
|||||||
typedef union tagSQObjectValue
|
typedef union tagSQObjectValue
|
||||||
{
|
{
|
||||||
struct SQTable *pTable;
|
struct SQTable *pTable;
|
||||||
struct rabbit::Array *pArray;
|
|
||||||
struct SQClosure *pClosure;
|
struct SQClosure *pClosure;
|
||||||
struct SQOuter *pOuter;
|
struct SQOuter *pOuter;
|
||||||
struct SQGenerator *pGenerator;
|
struct SQGenerator *pGenerator;
|
||||||
struct SQNativeClosure *pNativeClosure;
|
struct SQNativeClosure *pNativeClosure;
|
||||||
struct SQString *pString;
|
struct SQString *pString;
|
||||||
struct rabbit::UserData *pUserData;
|
|
||||||
int64_t nInteger;
|
int64_t nInteger;
|
||||||
float_t fFloat;
|
float_t fFloat;
|
||||||
SQUserPointer pUserPointer;
|
SQUserPointer pUserPointer;
|
||||||
struct SQFunctionProto *pFunctionProto;
|
struct SQFunctionProto *pFunctionProto;
|
||||||
struct rabbit::RefCounted *pRefCounted;
|
|
||||||
struct SQDelegable *pDelegable;
|
struct SQDelegable *pDelegable;
|
||||||
struct SQVM *pThread;
|
|
||||||
struct SQClass *pClass;
|
struct SQClass *pClass;
|
||||||
struct SQInstance *pInstance;
|
struct SQInstance *pInstance;
|
||||||
|
|
||||||
struct rabbit::WeakRef *pWeakRef;
|
struct rabbit::WeakRef *pWeakRef;
|
||||||
|
struct rabbit::VirtualMachine* pThread;
|
||||||
|
struct rabbit::RefCounted *pRefCounted;
|
||||||
|
struct rabbit::Array *pArray;
|
||||||
|
struct rabbit::UserData *pUserData;
|
||||||
|
|
||||||
SQRawObjectVal raw;
|
SQRawObjectVal raw;
|
||||||
}SQObjectValue;
|
}SQObjectValue;
|
||||||
|
|
||||||
@ -155,14 +157,13 @@ typedef struct tagSQStackInfos{
|
|||||||
int64_t line;
|
int64_t line;
|
||||||
}SQStackInfos;
|
}SQStackInfos;
|
||||||
|
|
||||||
typedef struct SQVM* HRABBITVM;
|
|
||||||
typedef SQObject HSQOBJECT;
|
typedef SQObject HSQOBJECT;
|
||||||
typedef SQMemberHandle HSQMEMBERHANDLE;
|
typedef SQMemberHandle HSQMEMBERHANDLE;
|
||||||
typedef int64_t (*SQFUNCTION)(HRABBITVM);
|
typedef int64_t (*SQFUNCTION)(rabbit::VirtualMachine*);
|
||||||
typedef int64_t (*SQRELEASEHOOK)(SQUserPointer,int64_t size);
|
typedef int64_t (*SQRELEASEHOOK)(SQUserPointer,int64_t size);
|
||||||
typedef void (*SQCOMPILERERROR)(HRABBITVM,const SQChar * /*desc*/,const SQChar * /*source*/,int64_t /*line*/,int64_t /*column*/);
|
typedef void (*SQCOMPILERERROR)(rabbit::VirtualMachine*,const SQChar * /*desc*/,const SQChar * /*source*/,int64_t /*line*/,int64_t /*column*/);
|
||||||
typedef void (*SQPRINTFUNCTION)(HRABBITVM,const SQChar * ,...);
|
typedef void (*SQPRINTFUNCTION)(rabbit::VirtualMachine*,const SQChar * ,...);
|
||||||
typedef void (*SQDEBUGHOOK)(HRABBITVM /*v*/, int64_t /*type*/, const SQChar * /*sourcename*/, int64_t /*line*/, const SQChar * /*funcname*/);
|
typedef void (*SQDEBUGHOOK)(rabbit::VirtualMachine* /*v*/, int64_t /*type*/, const SQChar * /*sourcename*/, int64_t /*line*/, const SQChar * /*funcname*/);
|
||||||
typedef int64_t (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,int64_t);
|
typedef int64_t (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,int64_t);
|
||||||
typedef int64_t (*SQREADFUNC)(SQUserPointer,SQUserPointer,int64_t);
|
typedef int64_t (*SQREADFUNC)(SQUserPointer,SQUserPointer,int64_t);
|
||||||
|
|
||||||
@ -183,147 +184,147 @@ typedef struct tagSQFunctionInfo {
|
|||||||
}SQFunctionInfo;
|
}SQFunctionInfo;
|
||||||
|
|
||||||
/*vm*/
|
/*vm*/
|
||||||
RABBIT_API HRABBITVM sq_open(int64_t initialstacksize);
|
RABBIT_API rabbit::VirtualMachine* sq_open(int64_t initialstacksize);
|
||||||
RABBIT_API HRABBITVM sq_newthread(HRABBITVM friendvm, int64_t initialstacksize);
|
RABBIT_API rabbit::VirtualMachine* sq_newthread(rabbit::VirtualMachine* friendvm, int64_t initialstacksize);
|
||||||
RABBIT_API void sq_seterrorhandler(HRABBITVM v);
|
RABBIT_API void sq_seterrorhandler(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_close(HRABBITVM v);
|
RABBIT_API void sq_close(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setforeignptr(HRABBITVM v,SQUserPointer p);
|
RABBIT_API void sq_setforeignptr(rabbit::VirtualMachine* v,SQUserPointer p);
|
||||||
RABBIT_API SQUserPointer sq_getforeignptr(HRABBITVM v);
|
RABBIT_API SQUserPointer sq_getforeignptr(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setsharedforeignptr(HRABBITVM v,SQUserPointer p);
|
RABBIT_API void sq_setsharedforeignptr(rabbit::VirtualMachine* v,SQUserPointer p);
|
||||||
RABBIT_API SQUserPointer sq_getsharedforeignptr(HRABBITVM v);
|
RABBIT_API SQUserPointer sq_getsharedforeignptr(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setvmreleasehook(HRABBITVM v,SQRELEASEHOOK hook);
|
RABBIT_API void sq_setvmreleasehook(rabbit::VirtualMachine* v,SQRELEASEHOOK hook);
|
||||||
RABBIT_API SQRELEASEHOOK sq_getvmreleasehook(HRABBITVM v);
|
RABBIT_API SQRELEASEHOOK sq_getvmreleasehook(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setsharedreleasehook(HRABBITVM v,SQRELEASEHOOK hook);
|
RABBIT_API void sq_setsharedreleasehook(rabbit::VirtualMachine* v,SQRELEASEHOOK hook);
|
||||||
RABBIT_API SQRELEASEHOOK sq_getsharedreleasehook(HRABBITVM v);
|
RABBIT_API SQRELEASEHOOK sq_getsharedreleasehook(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setprintfunc(HRABBITVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc);
|
RABBIT_API void sq_setprintfunc(rabbit::VirtualMachine* v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc);
|
||||||
RABBIT_API SQPRINTFUNCTION sq_getprintfunc(HRABBITVM v);
|
RABBIT_API SQPRINTFUNCTION sq_getprintfunc(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQPRINTFUNCTION sq_geterrorfunc(HRABBITVM v);
|
RABBIT_API SQPRINTFUNCTION sq_geterrorfunc(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_suspendvm(HRABBITVM v);
|
RABBIT_API SQRESULT sq_suspendvm(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_wakeupvm(HRABBITVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
|
RABBIT_API SQRESULT sq_wakeupvm(rabbit::VirtualMachine* v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
|
||||||
RABBIT_API int64_t sq_getvmstate(HRABBITVM v);
|
RABBIT_API int64_t sq_getvmstate(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API int64_t sq_getversion();
|
RABBIT_API int64_t sq_getversion();
|
||||||
|
|
||||||
/*compiler*/
|
/*compiler*/
|
||||||
RABBIT_API SQRESULT sq_compile(HRABBITVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
|
RABBIT_API SQRESULT sq_compile(rabbit::VirtualMachine* v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
|
||||||
RABBIT_API SQRESULT sq_compilebuffer(HRABBITVM v,const SQChar *s,int64_t size,const SQChar *sourcename,SQBool raiseerror);
|
RABBIT_API SQRESULT sq_compilebuffer(rabbit::VirtualMachine* v,const SQChar *s,int64_t size,const SQChar *sourcename,SQBool raiseerror);
|
||||||
RABBIT_API void sq_enabledebuginfo(HRABBITVM v, SQBool enable);
|
RABBIT_API void sq_enabledebuginfo(rabbit::VirtualMachine* v, SQBool enable);
|
||||||
RABBIT_API void sq_notifyallexceptions(HRABBITVM v, SQBool enable);
|
RABBIT_API void sq_notifyallexceptions(rabbit::VirtualMachine* v, SQBool enable);
|
||||||
RABBIT_API void sq_setcompilererrorhandler(HRABBITVM v,SQCOMPILERERROR f);
|
RABBIT_API void sq_setcompilererrorhandler(rabbit::VirtualMachine* v,SQCOMPILERERROR f);
|
||||||
|
|
||||||
/*stack operations*/
|
/*stack operations*/
|
||||||
RABBIT_API void sq_push(HRABBITVM v,int64_t idx);
|
RABBIT_API void sq_push(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API void sq_pop(HRABBITVM v,int64_t nelemstopop);
|
RABBIT_API void sq_pop(rabbit::VirtualMachine* v,int64_t nelemstopop);
|
||||||
RABBIT_API void sq_poptop(HRABBITVM v);
|
RABBIT_API void sq_poptop(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_remove(HRABBITVM v,int64_t idx);
|
RABBIT_API void sq_remove(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API int64_t sq_gettop(HRABBITVM v);
|
RABBIT_API int64_t sq_gettop(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_settop(HRABBITVM v,int64_t newtop);
|
RABBIT_API void sq_settop(rabbit::VirtualMachine* v,int64_t newtop);
|
||||||
RABBIT_API SQRESULT sq_reservestack(HRABBITVM v,int64_t nsize);
|
RABBIT_API SQRESULT sq_reservestack(rabbit::VirtualMachine* v,int64_t nsize);
|
||||||
RABBIT_API int64_t sq_cmp(HRABBITVM v);
|
RABBIT_API int64_t sq_cmp(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_move(HRABBITVM dest,HRABBITVM src,int64_t idx);
|
RABBIT_API void sq_move(rabbit::VirtualMachine* dest,rabbit::VirtualMachine* src,int64_t idx);
|
||||||
|
|
||||||
/*object creation handling*/
|
/*object creation handling*/
|
||||||
RABBIT_API SQUserPointer sq_newuserdata(HRABBITVM v,uint64_t size);
|
RABBIT_API SQUserPointer sq_newuserdata(rabbit::VirtualMachine* v,uint64_t size);
|
||||||
RABBIT_API void sq_newtable(HRABBITVM v);
|
RABBIT_API void sq_newtable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_newtableex(HRABBITVM v,int64_t initialcapacity);
|
RABBIT_API void sq_newtableex(rabbit::VirtualMachine* v,int64_t initialcapacity);
|
||||||
RABBIT_API void sq_newarray(HRABBITVM v,int64_t size);
|
RABBIT_API void sq_newarray(rabbit::VirtualMachine* v,int64_t size);
|
||||||
RABBIT_API void sq_newclosure(HRABBITVM v,SQFUNCTION func,uint64_t nfreevars);
|
RABBIT_API void sq_newclosure(rabbit::VirtualMachine* v,SQFUNCTION func,uint64_t nfreevars);
|
||||||
RABBIT_API SQRESULT sq_setparamscheck(HRABBITVM v,int64_t nparamscheck,const SQChar *typemask);
|
RABBIT_API SQRESULT sq_setparamscheck(rabbit::VirtualMachine* v,int64_t nparamscheck,const SQChar *typemask);
|
||||||
RABBIT_API SQRESULT sq_bindenv(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_bindenv(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_setclosureroot(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_setclosureroot(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getclosureroot(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getclosureroot(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API void sq_pushstring(HRABBITVM v,const SQChar *s,int64_t len);
|
RABBIT_API void sq_pushstring(rabbit::VirtualMachine* v,const SQChar *s,int64_t len);
|
||||||
RABBIT_API void sq_pushfloat(HRABBITVM v,float_t f);
|
RABBIT_API void sq_pushfloat(rabbit::VirtualMachine* v,float_t f);
|
||||||
RABBIT_API void sq_pushinteger(HRABBITVM v,int64_t n);
|
RABBIT_API void sq_pushinteger(rabbit::VirtualMachine* v,int64_t n);
|
||||||
RABBIT_API void sq_pushbool(HRABBITVM v,SQBool b);
|
RABBIT_API void sq_pushbool(rabbit::VirtualMachine* v,SQBool b);
|
||||||
RABBIT_API void sq_pushuserpointer(HRABBITVM v,SQUserPointer p);
|
RABBIT_API void sq_pushuserpointer(rabbit::VirtualMachine* v,SQUserPointer p);
|
||||||
RABBIT_API void sq_pushnull(HRABBITVM v);
|
RABBIT_API void sq_pushnull(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_pushthread(HRABBITVM v, HRABBITVM thread);
|
RABBIT_API void sq_pushthread(rabbit::VirtualMachine* v, rabbit::VirtualMachine* thread);
|
||||||
RABBIT_API SQObjectType sq_gettype(HRABBITVM v,int64_t idx);
|
RABBIT_API SQObjectType sq_gettype(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_typeof(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_typeof(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API int64_t sq_getsize(HRABBITVM v,int64_t idx);
|
RABBIT_API int64_t sq_getsize(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQHash sq_gethash(HRABBITVM v, int64_t idx);
|
RABBIT_API SQHash sq_gethash(rabbit::VirtualMachine* v, int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getbase(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getbase(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQBool sq_instanceof(HRABBITVM v);
|
RABBIT_API SQBool sq_instanceof(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_tostring(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_tostring(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API void sq_tobool(HRABBITVM v, int64_t idx, SQBool *b);
|
RABBIT_API void sq_tobool(rabbit::VirtualMachine* v, int64_t idx, SQBool *b);
|
||||||
RABBIT_API SQRESULT sq_getstringandsize(HRABBITVM v,int64_t idx,const SQChar **c,int64_t *size);
|
RABBIT_API SQRESULT sq_getstringandsize(rabbit::VirtualMachine* v,int64_t idx,const SQChar **c,int64_t *size);
|
||||||
RABBIT_API SQRESULT sq_getstring(HRABBITVM v,int64_t idx,const SQChar **c);
|
RABBIT_API SQRESULT sq_getstring(rabbit::VirtualMachine* v,int64_t idx,const SQChar **c);
|
||||||
RABBIT_API SQRESULT sq_getinteger(HRABBITVM v,int64_t idx,int64_t *i);
|
RABBIT_API SQRESULT sq_getinteger(rabbit::VirtualMachine* v,int64_t idx,int64_t *i);
|
||||||
RABBIT_API SQRESULT sq_getfloat(HRABBITVM v,int64_t idx,float_t *f);
|
RABBIT_API SQRESULT sq_getfloat(rabbit::VirtualMachine* v,int64_t idx,float_t *f);
|
||||||
RABBIT_API SQRESULT sq_getbool(HRABBITVM v,int64_t idx,SQBool *b);
|
RABBIT_API SQRESULT sq_getbool(rabbit::VirtualMachine* v,int64_t idx,SQBool *b);
|
||||||
RABBIT_API SQRESULT sq_getthread(HRABBITVM v,int64_t idx,HRABBITVM *thread);
|
RABBIT_API SQRESULT sq_getthread(rabbit::VirtualMachine* v,int64_t idx,rabbit::VirtualMachine* *thread);
|
||||||
RABBIT_API SQRESULT sq_getuserpointer(HRABBITVM v,int64_t idx,SQUserPointer *p);
|
RABBIT_API SQRESULT sq_getuserpointer(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer *p);
|
||||||
RABBIT_API SQRESULT sq_getuserdata(HRABBITVM v,int64_t idx,SQUserPointer *p,SQUserPointer *typetag);
|
RABBIT_API SQRESULT sq_getuserdata(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer *p,SQUserPointer *typetag);
|
||||||
RABBIT_API SQRESULT sq_settypetag(HRABBITVM v,int64_t idx,SQUserPointer typetag);
|
RABBIT_API SQRESULT sq_settypetag(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer typetag);
|
||||||
RABBIT_API SQRESULT sq_gettypetag(HRABBITVM v,int64_t idx,SQUserPointer *typetag);
|
RABBIT_API SQRESULT sq_gettypetag(rabbit::VirtualMachine* v,int64_t idx,SQUserPointer *typetag);
|
||||||
RABBIT_API void sq_setreleasehook(HRABBITVM v,int64_t idx,SQRELEASEHOOK hook);
|
RABBIT_API void sq_setreleasehook(rabbit::VirtualMachine* v,int64_t idx,SQRELEASEHOOK hook);
|
||||||
RABBIT_API SQRELEASEHOOK sq_getreleasehook(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRELEASEHOOK sq_getreleasehook(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQChar *sq_getscratchpad(HRABBITVM v,int64_t minsize);
|
RABBIT_API SQChar *sq_getscratchpad(rabbit::VirtualMachine* v,int64_t minsize);
|
||||||
RABBIT_API SQRESULT sq_getfunctioninfo(HRABBITVM v,int64_t level,SQFunctionInfo *fi);
|
RABBIT_API SQRESULT sq_getfunctioninfo(rabbit::VirtualMachine* v,int64_t level,SQFunctionInfo *fi);
|
||||||
RABBIT_API SQRESULT sq_getclosureinfo(HRABBITVM v,int64_t idx,uint64_t *nparams,uint64_t *nfreevars);
|
RABBIT_API SQRESULT sq_getclosureinfo(rabbit::VirtualMachine* v,int64_t idx,uint64_t *nparams,uint64_t *nfreevars);
|
||||||
RABBIT_API SQRESULT sq_getclosurename(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getclosurename(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_setnativeclosurename(HRABBITVM v,int64_t idx,const SQChar *name);
|
RABBIT_API SQRESULT sq_setnativeclosurename(rabbit::VirtualMachine* v,int64_t idx,const SQChar *name);
|
||||||
RABBIT_API SQRESULT sq_setinstanceup(HRABBITVM v, int64_t idx, SQUserPointer p);
|
RABBIT_API SQRESULT sq_setinstanceup(rabbit::VirtualMachine* v, int64_t idx, SQUserPointer p);
|
||||||
RABBIT_API SQRESULT sq_getinstanceup(HRABBITVM v, int64_t idx, SQUserPointer *p,SQUserPointer typetag);
|
RABBIT_API SQRESULT sq_getinstanceup(rabbit::VirtualMachine* v, int64_t idx, SQUserPointer *p,SQUserPointer typetag);
|
||||||
RABBIT_API SQRESULT sq_setclassudsize(HRABBITVM v, int64_t idx, int64_t udsize);
|
RABBIT_API SQRESULT sq_setclassudsize(rabbit::VirtualMachine* v, int64_t idx, int64_t udsize);
|
||||||
RABBIT_API SQRESULT sq_newclass(HRABBITVM v,SQBool hasbase);
|
RABBIT_API SQRESULT sq_newclass(rabbit::VirtualMachine* v,SQBool hasbase);
|
||||||
RABBIT_API SQRESULT sq_createinstance(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_createinstance(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_setattributes(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_setattributes(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getattributes(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getattributes(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getclass(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getclass(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API void sq_weakref(HRABBITVM v,int64_t idx);
|
RABBIT_API void sq_weakref(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getdefaultdelegate(HRABBITVM v,SQObjectType t);
|
RABBIT_API SQRESULT sq_getdefaultdelegate(rabbit::VirtualMachine* v,SQObjectType t);
|
||||||
RABBIT_API SQRESULT sq_getmemberhandle(HRABBITVM v,int64_t idx,HSQMEMBERHANDLE *handle);
|
RABBIT_API SQRESULT sq_getmemberhandle(rabbit::VirtualMachine* v,int64_t idx,HSQMEMBERHANDLE *handle);
|
||||||
RABBIT_API SQRESULT sq_getbyhandle(HRABBITVM v,int64_t idx,const HSQMEMBERHANDLE *handle);
|
RABBIT_API SQRESULT sq_getbyhandle(rabbit::VirtualMachine* v,int64_t idx,const HSQMEMBERHANDLE *handle);
|
||||||
RABBIT_API SQRESULT sq_setbyhandle(HRABBITVM v,int64_t idx,const HSQMEMBERHANDLE *handle);
|
RABBIT_API SQRESULT sq_setbyhandle(rabbit::VirtualMachine* v,int64_t idx,const HSQMEMBERHANDLE *handle);
|
||||||
|
|
||||||
/*object manipulation*/
|
/*object manipulation*/
|
||||||
RABBIT_API void sq_pushroottable(HRABBITVM v);
|
RABBIT_API void sq_pushroottable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_pushregistrytable(HRABBITVM v);
|
RABBIT_API void sq_pushregistrytable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_pushconsttable(HRABBITVM v);
|
RABBIT_API void sq_pushconsttable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_setroottable(HRABBITVM v);
|
RABBIT_API SQRESULT sq_setroottable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_setconsttable(HRABBITVM v);
|
RABBIT_API SQRESULT sq_setconsttable(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_newslot(HRABBITVM v, int64_t idx, SQBool bstatic);
|
RABBIT_API SQRESULT sq_newslot(rabbit::VirtualMachine* v, int64_t idx, SQBool bstatic);
|
||||||
RABBIT_API SQRESULT sq_deleteslot(HRABBITVM v,int64_t idx,SQBool pushval);
|
RABBIT_API SQRESULT sq_deleteslot(rabbit::VirtualMachine* v,int64_t idx,SQBool pushval);
|
||||||
RABBIT_API SQRESULT sq_set(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_set(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_get(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_get(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_rawget(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_rawget(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_rawset(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_rawset(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_rawdeleteslot(HRABBITVM v,int64_t idx,SQBool pushval);
|
RABBIT_API SQRESULT sq_rawdeleteslot(rabbit::VirtualMachine* v,int64_t idx,SQBool pushval);
|
||||||
RABBIT_API SQRESULT sq_newmember(HRABBITVM v,int64_t idx,SQBool bstatic);
|
RABBIT_API SQRESULT sq_newmember(rabbit::VirtualMachine* v,int64_t idx,SQBool bstatic);
|
||||||
RABBIT_API SQRESULT sq_rawnewmember(HRABBITVM v,int64_t idx,SQBool bstatic);
|
RABBIT_API SQRESULT sq_rawnewmember(rabbit::VirtualMachine* v,int64_t idx,SQBool bstatic);
|
||||||
RABBIT_API SQRESULT sq_arrayappend(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_arrayappend(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_arraypop(HRABBITVM v,int64_t idx,SQBool pushval);
|
RABBIT_API SQRESULT sq_arraypop(rabbit::VirtualMachine* v,int64_t idx,SQBool pushval);
|
||||||
RABBIT_API SQRESULT sq_arrayresize(HRABBITVM v,int64_t idx,int64_t newsize);
|
RABBIT_API SQRESULT sq_arrayresize(rabbit::VirtualMachine* v,int64_t idx,int64_t newsize);
|
||||||
RABBIT_API SQRESULT sq_arrayreverse(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_arrayreverse(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_arrayremove(HRABBITVM v,int64_t idx,int64_t itemidx);
|
RABBIT_API SQRESULT sq_arrayremove(rabbit::VirtualMachine* v,int64_t idx,int64_t itemidx);
|
||||||
RABBIT_API SQRESULT sq_arrayinsert(HRABBITVM v,int64_t idx,int64_t destpos);
|
RABBIT_API SQRESULT sq_arrayinsert(rabbit::VirtualMachine* v,int64_t idx,int64_t destpos);
|
||||||
RABBIT_API SQRESULT sq_setdelegate(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_setdelegate(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getdelegate(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getdelegate(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_clone(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_clone(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_setfreevariable(HRABBITVM v,int64_t idx,uint64_t nval);
|
RABBIT_API SQRESULT sq_setfreevariable(rabbit::VirtualMachine* v,int64_t idx,uint64_t nval);
|
||||||
RABBIT_API SQRESULT sq_next(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_next(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getweakrefval(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_getweakrefval(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
RABBIT_API SQRESULT sq_clear(HRABBITVM v,int64_t idx);
|
RABBIT_API SQRESULT sq_clear(rabbit::VirtualMachine* v,int64_t idx);
|
||||||
|
|
||||||
/*calls*/
|
/*calls*/
|
||||||
RABBIT_API SQRESULT sq_call(HRABBITVM v,int64_t params,SQBool retval,SQBool raiseerror);
|
RABBIT_API SQRESULT sq_call(rabbit::VirtualMachine* v,int64_t params,SQBool retval,SQBool raiseerror);
|
||||||
RABBIT_API SQRESULT sq_resume(HRABBITVM v,SQBool retval,SQBool raiseerror);
|
RABBIT_API SQRESULT sq_resume(rabbit::VirtualMachine* v,SQBool retval,SQBool raiseerror);
|
||||||
RABBIT_API const SQChar *sq_getlocal(HRABBITVM v,uint64_t level,uint64_t idx);
|
RABBIT_API const SQChar *sq_getlocal(rabbit::VirtualMachine* v,uint64_t level,uint64_t idx);
|
||||||
RABBIT_API SQRESULT sq_getcallee(HRABBITVM v);
|
RABBIT_API SQRESULT sq_getcallee(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API const SQChar *sq_getfreevariable(HRABBITVM v,int64_t idx,uint64_t nval);
|
RABBIT_API const SQChar *sq_getfreevariable(rabbit::VirtualMachine* v,int64_t idx,uint64_t nval);
|
||||||
RABBIT_API SQRESULT sq_throwerror(HRABBITVM v,const SQChar *err);
|
RABBIT_API SQRESULT sq_throwerror(rabbit::VirtualMachine* v,const SQChar *err);
|
||||||
RABBIT_API SQRESULT sq_throwobject(HRABBITVM v);
|
RABBIT_API SQRESULT sq_throwobject(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_reseterror(HRABBITVM v);
|
RABBIT_API void sq_reseterror(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_getlasterror(HRABBITVM v);
|
RABBIT_API void sq_getlasterror(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_tailcall(HRABBITVM v, int64_t nparams);
|
RABBIT_API SQRESULT sq_tailcall(rabbit::VirtualMachine* v, int64_t nparams);
|
||||||
|
|
||||||
/*raw object handling*/
|
/*raw object handling*/
|
||||||
RABBIT_API SQRESULT sq_getstackobj(HRABBITVM v,int64_t idx,HSQOBJECT *po);
|
RABBIT_API SQRESULT sq_getstackobj(rabbit::VirtualMachine* v,int64_t idx,HSQOBJECT *po);
|
||||||
RABBIT_API void sq_pushobject(HRABBITVM v,HSQOBJECT obj);
|
RABBIT_API void sq_pushobject(rabbit::VirtualMachine* v,HSQOBJECT obj);
|
||||||
RABBIT_API void sq_addref(HRABBITVM v,HSQOBJECT *po);
|
RABBIT_API void sq_addref(rabbit::VirtualMachine* v,HSQOBJECT *po);
|
||||||
RABBIT_API SQBool sq_release(HRABBITVM v,HSQOBJECT *po);
|
RABBIT_API SQBool sq_release(rabbit::VirtualMachine* v,HSQOBJECT *po);
|
||||||
RABBIT_API uint64_t sq_getrefcount(HRABBITVM v,HSQOBJECT *po);
|
RABBIT_API uint64_t sq_getrefcount(rabbit::VirtualMachine* v,HSQOBJECT *po);
|
||||||
RABBIT_API void sq_resetobject(HSQOBJECT *po);
|
RABBIT_API void sq_resetobject(HSQOBJECT *po);
|
||||||
RABBIT_API const SQChar *sq_objtostring(const HSQOBJECT *o);
|
RABBIT_API const SQChar *sq_objtostring(const HSQOBJECT *o);
|
||||||
RABBIT_API SQBool sq_objtobool(const HSQOBJECT *o);
|
RABBIT_API SQBool sq_objtobool(const HSQOBJECT *o);
|
||||||
@ -331,16 +332,16 @@ RABBIT_API int64_t sq_objtointeger(const HSQOBJECT *o);
|
|||||||
RABBIT_API float_t sq_objtofloat(const HSQOBJECT *o);
|
RABBIT_API float_t sq_objtofloat(const HSQOBJECT *o);
|
||||||
RABBIT_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
|
RABBIT_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
|
||||||
RABBIT_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
|
RABBIT_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
|
||||||
RABBIT_API uint64_t sq_getvmrefcount(HRABBITVM v, const HSQOBJECT *po);
|
RABBIT_API uint64_t sq_getvmrefcount(rabbit::VirtualMachine* v, const HSQOBJECT *po);
|
||||||
|
|
||||||
|
|
||||||
/*GC*/
|
/*GC*/
|
||||||
RABBIT_API int64_t sq_collectgarbage(HRABBITVM v);
|
RABBIT_API int64_t sq_collectgarbage(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API SQRESULT sq_resurrectunreachable(HRABBITVM v);
|
RABBIT_API SQRESULT sq_resurrectunreachable(rabbit::VirtualMachine* v);
|
||||||
|
|
||||||
/*serialization*/
|
/*serialization*/
|
||||||
RABBIT_API SQRESULT sq_writeclosure(HRABBITVM vm,SQWRITEFUNC writef,SQUserPointer up);
|
RABBIT_API SQRESULT sq_writeclosure(rabbit::VirtualMachine* vm,SQWRITEFUNC writef,SQUserPointer up);
|
||||||
RABBIT_API SQRESULT sq_readclosure(HRABBITVM vm,SQREADFUNC readf,SQUserPointer up);
|
RABBIT_API SQRESULT sq_readclosure(rabbit::VirtualMachine* vm,SQREADFUNC readf,SQUserPointer up);
|
||||||
|
|
||||||
/*mem allocation*/
|
/*mem allocation*/
|
||||||
RABBIT_API void *sq_malloc(uint64_t size);
|
RABBIT_API void *sq_malloc(uint64_t size);
|
||||||
@ -348,9 +349,9 @@ RABBIT_API void *sq_realloc(void* p,uint64_t oldsize,uint64_t newsize);
|
|||||||
RABBIT_API void sq_free(void *p,uint64_t size);
|
RABBIT_API void sq_free(void *p,uint64_t size);
|
||||||
|
|
||||||
/*debug*/
|
/*debug*/
|
||||||
RABBIT_API SQRESULT sq_stackinfos(HRABBITVM v,int64_t level,SQStackInfos *si);
|
RABBIT_API SQRESULT sq_stackinfos(rabbit::VirtualMachine* v,int64_t level,SQStackInfos *si);
|
||||||
RABBIT_API void sq_setdebughook(HRABBITVM v);
|
RABBIT_API void sq_setdebughook(rabbit::VirtualMachine* v);
|
||||||
RABBIT_API void sq_setnativedebughook(HRABBITVM v,SQDEBUGHOOK hook);
|
RABBIT_API void sq_setnativedebughook(rabbit::VirtualMachine* v,SQDEBUGHOOK hook);
|
||||||
|
|
||||||
/*UTILITY MACRO*/
|
/*UTILITY MACRO*/
|
||||||
#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
|
#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
|
||||||
|
307
rabbit/sqapi.cpp
307
rabbit/sqapi.cpp
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@
|
|||||||
* @license MPL-2 (see license file)
|
* @license MPL-2 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqstring.hpp>
|
#include <rabbit/sqstring.hpp>
|
||||||
#include <rabbit/sqtable.hpp>
|
#include <rabbit/sqtable.hpp>
|
||||||
#include <rabbit/Array.hpp>
|
#include <rabbit/Array.hpp>
|
||||||
@ -45,25 +45,25 @@ static bool str2num(const SQChar *s,SQObjectPtr &res,int64_t base)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_dummy(HRABBITVM SQ_UNUSED_ARG(v))
|
static int64_t base_dummy(rabbit::VirtualMachine* SQ_UNUSED_ARG(v))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_getroottable(HRABBITVM v)
|
static int64_t base_getroottable(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
v->push(v->_roottable);
|
v->push(v->_roottable);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_getconsttable(HRABBITVM v)
|
static int64_t base_getconsttable(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
v->push(_ss(v)->_consts);
|
v->push(_ss(v)->_consts);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t base_setroottable(HRABBITVM v)
|
static int64_t base_setroottable(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = v->_roottable;
|
SQObjectPtr o = v->_roottable;
|
||||||
if(SQ_FAILED(sq_setroottable(v))) return SQ_ERROR;
|
if(SQ_FAILED(sq_setroottable(v))) return SQ_ERROR;
|
||||||
@ -71,7 +71,7 @@ static int64_t base_setroottable(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_setconsttable(HRABBITVM v)
|
static int64_t base_setconsttable(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = _ss(v)->_consts;
|
SQObjectPtr o = _ss(v)->_consts;
|
||||||
if(SQ_FAILED(sq_setconsttable(v))) return SQ_ERROR;
|
if(SQ_FAILED(sq_setconsttable(v))) return SQ_ERROR;
|
||||||
@ -79,27 +79,27 @@ static int64_t base_setconsttable(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_seterrorhandler(HRABBITVM v)
|
static int64_t base_seterrorhandler(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_seterrorhandler(v);
|
sq_seterrorhandler(v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_setdebughook(HRABBITVM v)
|
static int64_t base_setdebughook(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_setdebughook(v);
|
sq_setdebughook(v);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_enabledebuginfo(HRABBITVM v)
|
static int64_t base_enabledebuginfo(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o=stack_get(v,2);
|
SQObjectPtr &o=stack_get(v,2);
|
||||||
|
|
||||||
sq_enabledebuginfo(v,SQVM::IsFalse(o)?SQFalse:SQTrue);
|
sq_enabledebuginfo(v,rabbit::VirtualMachine::IsFalse(o)?SQFalse:SQTrue);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t __getcallstackinfos(HRABBITVM v,int64_t level)
|
static int64_t __getcallstackinfos(rabbit::VirtualMachine* v,int64_t level)
|
||||||
{
|
{
|
||||||
SQStackInfos si;
|
SQStackInfos si;
|
||||||
int64_t seq = 0;
|
int64_t seq = 0;
|
||||||
@ -137,16 +137,16 @@ static int64_t __getcallstackinfos(HRABBITVM v,int64_t level)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static int64_t base_getstackinfos(HRABBITVM v)
|
static int64_t base_getstackinfos(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t level;
|
int64_t level;
|
||||||
sq_getinteger(v, -1, &level);
|
sq_getinteger(v, -1, &level);
|
||||||
return __getcallstackinfos(v,level);
|
return __getcallstackinfos(v,level);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_assert(HRABBITVM v)
|
static int64_t base_assert(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQVM::IsFalse(stack_get(v,2))){
|
if(rabbit::VirtualMachine::IsFalse(stack_get(v,2))){
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
if (top>2 && SQ_SUCCEEDED(sq_tostring(v,3))) {
|
if (top>2 && SQ_SUCCEEDED(sq_tostring(v,3))) {
|
||||||
const SQChar *str = 0;
|
const SQChar *str = 0;
|
||||||
@ -159,7 +159,7 @@ static int64_t base_assert(HRABBITVM v)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t get_slice_params(HRABBITVM v,int64_t &sidx,int64_t &eidx,SQObjectPtr &o)
|
static int64_t get_slice_params(rabbit::VirtualMachine* v,int64_t &sidx,int64_t &eidx,SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
sidx=0;
|
sidx=0;
|
||||||
@ -183,7 +183,7 @@ static int64_t get_slice_params(HRABBITVM v,int64_t &sidx,int64_t &eidx,SQObject
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_print(HRABBITVM v)
|
static int64_t base_print(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str;
|
const SQChar *str;
|
||||||
if(SQ_SUCCEEDED(sq_tostring(v,2)))
|
if(SQ_SUCCEEDED(sq_tostring(v,2)))
|
||||||
@ -196,7 +196,7 @@ static int64_t base_print(HRABBITVM v)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_error(HRABBITVM v)
|
static int64_t base_error(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
const SQChar *str;
|
const SQChar *str;
|
||||||
if(SQ_SUCCEEDED(sq_tostring(v,2)))
|
if(SQ_SUCCEEDED(sq_tostring(v,2)))
|
||||||
@ -209,7 +209,7 @@ static int64_t base_error(HRABBITVM v)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_compilestring(HRABBITVM v)
|
static int64_t base_compilestring(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t nargs=sq_gettop(v);
|
int64_t nargs=sq_gettop(v);
|
||||||
const SQChar *src=NULL,*name=_SC("unnamedbuffer");
|
const SQChar *src=NULL,*name=_SC("unnamedbuffer");
|
||||||
@ -225,21 +225,21 @@ static int64_t base_compilestring(HRABBITVM v)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_newthread(HRABBITVM v)
|
static int64_t base_newthread(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &func = stack_get(v,2);
|
SQObjectPtr &func = stack_get(v,2);
|
||||||
int64_t stksize = (_closure(func)->_function->_stacksize << 1) +2;
|
int64_t stksize = (_closure(func)->_function->_stacksize << 1) +2;
|
||||||
HRABBITVM newv = sq_newthread(v, (stksize < MIN_STACK_OVERHEAD + 2)? MIN_STACK_OVERHEAD + 2 : stksize);
|
rabbit::VirtualMachine* newv = sq_newthread(v, (stksize < MIN_STACK_OVERHEAD + 2)? MIN_STACK_OVERHEAD + 2 : stksize);
|
||||||
sq_move(newv,v,-2);
|
sq_move(newv,v,-2);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_suspend(HRABBITVM v)
|
static int64_t base_suspend(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return sq_suspendvm(v);
|
return sq_suspendvm(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_array(HRABBITVM v)
|
static int64_t base_array(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
rabbit::Array *a;
|
rabbit::Array *a;
|
||||||
SQObject &size = stack_get(v,2);
|
SQObject &size = stack_get(v,2);
|
||||||
@ -254,14 +254,14 @@ static int64_t base_array(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_type(HRABBITVM v)
|
static int64_t base_type(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,2);
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t base_callee(HRABBITVM v)
|
static int64_t base_callee(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(v->_callsstacksize > 1)
|
if(v->_callsstacksize > 1)
|
||||||
{
|
{
|
||||||
@ -294,7 +294,7 @@ static const SQRegFunction base_funcs[]={
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
void sq_base_register(HRABBITVM v)
|
void sq_base_register(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t i=0;
|
int64_t i=0;
|
||||||
sq_pushroottable(v);
|
sq_pushroottable(v);
|
||||||
@ -325,13 +325,13 @@ void sq_base_register(HRABBITVM v)
|
|||||||
sq_pop(v,1);
|
sq_pop(v,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t default_delegate_len(HRABBITVM v)
|
static int64_t default_delegate_len(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
v->push(int64_t(sq_getsize(v,1)));
|
v->push(int64_t(sq_getsize(v,1)));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t default_delegate_tofloat(HRABBITVM v)
|
static int64_t default_delegate_tofloat(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o=stack_get(v,1);
|
SQObjectPtr &o=stack_get(v,1);
|
||||||
switch(sq_type(o)){
|
switch(sq_type(o)){
|
||||||
@ -356,7 +356,7 @@ static int64_t default_delegate_tofloat(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t default_delegate_tointeger(HRABBITVM v)
|
static int64_t default_delegate_tointeger(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o=stack_get(v,1);
|
SQObjectPtr &o=stack_get(v,1);
|
||||||
int64_t base = 10;
|
int64_t base = 10;
|
||||||
@ -385,26 +385,26 @@ static int64_t default_delegate_tointeger(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t default_delegate_tostring(HRABBITVM v)
|
static int64_t default_delegate_tostring(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_tostring(v,1)))
|
if(SQ_FAILED(sq_tostring(v,1)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t obj_delegate_weakref(HRABBITVM v)
|
static int64_t obj_delegate_weakref(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
sq_weakref(v,1);
|
sq_weakref(v,1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t obj_clear(HRABBITVM v)
|
static int64_t obj_clear(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_clear(v,-1)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_clear(v,-1)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t number_delegate_tochar(HRABBITVM v)
|
static int64_t number_delegate_tochar(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,1);
|
SQObject &o=stack_get(v,1);
|
||||||
SQChar c = (SQChar)tointeger(o);
|
SQChar c = (SQChar)tointeger(o);
|
||||||
@ -417,7 +417,7 @@ static int64_t number_delegate_tochar(HRABBITVM v)
|
|||||||
/////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////
|
||||||
//TABLE DEFAULT DELEGATE
|
//TABLE DEFAULT DELEGATE
|
||||||
|
|
||||||
static int64_t table_rawdelete(HRABBITVM v)
|
static int64_t table_rawdelete(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_rawdeleteslot(v,1,SQTrue)))
|
if(SQ_FAILED(sq_rawdeleteslot(v,1,SQTrue)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
@ -425,7 +425,7 @@ static int64_t table_rawdelete(HRABBITVM v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t container_rawexists(HRABBITVM v)
|
static int64_t container_rawexists(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_SUCCEEDED(sq_rawget(v,-2))) {
|
if(SQ_SUCCEEDED(sq_rawget(v,-2))) {
|
||||||
sq_pushbool(v,SQTrue);
|
sq_pushbool(v,SQTrue);
|
||||||
@ -435,18 +435,18 @@ static int64_t container_rawexists(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t container_rawset(HRABBITVM v)
|
static int64_t container_rawset(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_rawset(v,-3)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_rawset(v,-3)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int64_t container_rawget(HRABBITVM v)
|
static int64_t container_rawget(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_rawget(v,-2))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_rawget(v,-2))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t table_setdelegate(HRABBITVM v)
|
static int64_t table_setdelegate(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_setdelegate(v,-2)))
|
if(SQ_FAILED(sq_setdelegate(v,-2)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
@ -454,12 +454,12 @@ static int64_t table_setdelegate(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t table_getdelegate(HRABBITVM v)
|
static int64_t table_getdelegate(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_getdelegate(v,-1))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t table_filter(HRABBITVM v)
|
static int64_t table_filter(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
SQTable *tbl = _table(o);
|
SQTable *tbl = _table(o);
|
||||||
@ -476,7 +476,7 @@ static int64_t table_filter(HRABBITVM v)
|
|||||||
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
|
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
if(!SQVM::IsFalse(v->getUp(-1))) {
|
if(!rabbit::VirtualMachine::IsFalse(v->getUp(-1))) {
|
||||||
_table(ret)->newSlot(key, val);
|
_table(ret)->newSlot(key, val);
|
||||||
}
|
}
|
||||||
v->pop();
|
v->pop();
|
||||||
@ -504,29 +504,29 @@ const SQRegFunction SQSharedState::_table_default_delegate_funcz[]={
|
|||||||
|
|
||||||
//ARRAY DEFAULT DELEGATE///////////////////////////////////////
|
//ARRAY DEFAULT DELEGATE///////////////////////////////////////
|
||||||
|
|
||||||
static int64_t array_append(HRABBITVM v)
|
static int64_t array_append(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_arrayappend(v,-2)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_arrayappend(v,-2)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_extend(HRABBITVM v)
|
static int64_t array_extend(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
_array(stack_get(v,1))->extend(_array(stack_get(v,2)));
|
_array(stack_get(v,1))->extend(_array(stack_get(v,2)));
|
||||||
sq_pop(v,1);
|
sq_pop(v,1);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_reverse(HRABBITVM v)
|
static int64_t array_reverse(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_arrayreverse(v,-1)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_arrayreverse(v,-1)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_pop(HRABBITVM v)
|
static int64_t array_pop(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_arraypop(v,1,SQTrue))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_arraypop(v,1,SQTrue))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_top(HRABBITVM v)
|
static int64_t array_top(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,1);
|
SQObject &o=stack_get(v,1);
|
||||||
if(_array(o)->size()>0){
|
if(_array(o)->size()>0){
|
||||||
@ -536,7 +536,7 @@ static int64_t array_top(HRABBITVM v)
|
|||||||
else return sq_throwerror(v,_SC("top() on a empty array"));
|
else return sq_throwerror(v,_SC("top() on a empty array"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_insert(HRABBITVM v)
|
static int64_t array_insert(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,1);
|
SQObject &o=stack_get(v,1);
|
||||||
SQObject &idx=stack_get(v,2);
|
SQObject &idx=stack_get(v,2);
|
||||||
@ -547,7 +547,7 @@ static int64_t array_insert(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_remove(HRABBITVM v)
|
static int64_t array_remove(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v, 1);
|
SQObject &o = stack_get(v, 1);
|
||||||
SQObject &idx = stack_get(v, 2);
|
SQObject &idx = stack_get(v, 2);
|
||||||
@ -561,7 +561,7 @@ static int64_t array_remove(HRABBITVM v)
|
|||||||
return sq_throwerror(v, _SC("idx out of range"));
|
return sq_throwerror(v, _SC("idx out of range"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_resize(HRABBITVM v)
|
static int64_t array_resize(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v, 1);
|
SQObject &o = stack_get(v, 1);
|
||||||
SQObject &nsize = stack_get(v, 2);
|
SQObject &nsize = stack_get(v, 2);
|
||||||
@ -580,7 +580,7 @@ static int64_t array_resize(HRABBITVM v)
|
|||||||
return sq_throwerror(v, _SC("size must be a number"));
|
return sq_throwerror(v, _SC("size must be a number"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t __map_array(rabbit::Array *dest,rabbit::Array *src,HRABBITVM v) {
|
static int64_t __map_array(rabbit::Array *dest,rabbit::Array *src,rabbit::VirtualMachine* v) {
|
||||||
SQObjectPtr temp;
|
SQObjectPtr temp;
|
||||||
int64_t size = src->size();
|
int64_t size = src->size();
|
||||||
for(int64_t n = 0; n < size; n++) {
|
for(int64_t n = 0; n < size; n++) {
|
||||||
@ -596,7 +596,7 @@ static int64_t __map_array(rabbit::Array *dest,rabbit::Array *src,HRABBITVM v) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_map(HRABBITVM v)
|
static int64_t array_map(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
int64_t size = _array(o)->size();
|
int64_t size = _array(o)->size();
|
||||||
@ -607,7 +607,7 @@ static int64_t array_map(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_apply(HRABBITVM v)
|
static int64_t array_apply(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
if(SQ_FAILED(__map_array(_array(o),_array(o),v)))
|
if(SQ_FAILED(__map_array(_array(o),_array(o),v)))
|
||||||
@ -616,7 +616,7 @@ static int64_t array_apply(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_reduce(HRABBITVM v)
|
static int64_t array_reduce(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
rabbit::Array *a = _array(o);
|
rabbit::Array *a = _array(o);
|
||||||
@ -644,7 +644,7 @@ static int64_t array_reduce(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_filter(HRABBITVM v)
|
static int64_t array_filter(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
rabbit::Array *a = _array(o);
|
rabbit::Array *a = _array(o);
|
||||||
@ -659,7 +659,7 @@ static int64_t array_filter(HRABBITVM v)
|
|||||||
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
|
if(SQ_FAILED(sq_call(v,3,SQTrue,SQFalse))) {
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
if(!SQVM::IsFalse(v->getUp(-1))) {
|
if(!rabbit::VirtualMachine::IsFalse(v->getUp(-1))) {
|
||||||
_array(ret)->append(val);
|
_array(ret)->append(val);
|
||||||
}
|
}
|
||||||
v->pop();
|
v->pop();
|
||||||
@ -668,7 +668,7 @@ static int64_t array_filter(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_find(HRABBITVM v)
|
static int64_t array_find(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o = stack_get(v,1);
|
SQObject &o = stack_get(v,1);
|
||||||
SQObjectPtr &val = stack_get(v,2);
|
SQObjectPtr &val = stack_get(v,2);
|
||||||
@ -678,7 +678,7 @@ static int64_t array_find(HRABBITVM v)
|
|||||||
for(int64_t n = 0; n < size; n++) {
|
for(int64_t n = 0; n < size; n++) {
|
||||||
bool res = false;
|
bool res = false;
|
||||||
a->get(n,temp);
|
a->get(n,temp);
|
||||||
if(SQVM::isEqual(temp,val,res) && res) {
|
if(rabbit::VirtualMachine::isEqual(temp,val,res) && res) {
|
||||||
v->push(n);
|
v->push(n);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -687,7 +687,7 @@ static int64_t array_find(HRABBITVM v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool _sort_compare(HRABBITVM v,SQObjectPtr &a,SQObjectPtr &b,int64_t func,int64_t &ret)
|
static bool _sort_compare(rabbit::VirtualMachine* v,SQObjectPtr &a,SQObjectPtr &b,int64_t func,int64_t &ret)
|
||||||
{
|
{
|
||||||
if(func < 0) {
|
if(func < 0) {
|
||||||
if(!v->objCmp(a,b,ret)) return false;
|
if(!v->objCmp(a,b,ret)) return false;
|
||||||
@ -713,7 +713,7 @@ static bool _sort_compare(HRABBITVM v,SQObjectPtr &a,SQObjectPtr &b,int64_t func
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _hsort_sift_down(HRABBITVM v,rabbit::Array *arr, int64_t root, int64_t bottom, int64_t func)
|
static bool _hsort_sift_down(rabbit::VirtualMachine* v,rabbit::Array *arr, int64_t root, int64_t bottom, int64_t func)
|
||||||
{
|
{
|
||||||
int64_t maxChild;
|
int64_t maxChild;
|
||||||
int64_t done = 0;
|
int64_t done = 0;
|
||||||
@ -753,7 +753,7 @@ static bool _hsort_sift_down(HRABBITVM v,rabbit::Array *arr, int64_t root, int64
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _hsort(HRABBITVM v,SQObjectPtr &arr, int64_t SQ_UNUSED_ARG(l), int64_t SQ_UNUSED_ARG(r),int64_t func)
|
static bool _hsort(rabbit::VirtualMachine* v,SQObjectPtr &arr, int64_t SQ_UNUSED_ARG(l), int64_t SQ_UNUSED_ARG(r),int64_t func)
|
||||||
{
|
{
|
||||||
rabbit::Array *a = _array(arr);
|
rabbit::Array *a = _array(arr);
|
||||||
int64_t i;
|
int64_t i;
|
||||||
@ -770,7 +770,7 @@ static bool _hsort(HRABBITVM v,SQObjectPtr &arr, int64_t SQ_UNUSED_ARG(l), int64
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_sort(HRABBITVM v)
|
static int64_t array_sort(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t func = -1;
|
int64_t func = -1;
|
||||||
SQObjectPtr &o = stack_get(v,1);
|
SQObjectPtr &o = stack_get(v,1);
|
||||||
@ -784,7 +784,7 @@ static int64_t array_sort(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t array_slice(HRABBITVM v)
|
static int64_t array_slice(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t sidx,eidx;
|
int64_t sidx,eidx;
|
||||||
SQObjectPtr o;
|
SQObjectPtr o;
|
||||||
@ -831,7 +831,7 @@ const SQRegFunction SQSharedState::_array_default_delegate_funcz[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
//STRING DEFAULT DELEGATE//////////////////////////
|
//STRING DEFAULT DELEGATE//////////////////////////
|
||||||
static int64_t string_slice(HRABBITVM v)
|
static int64_t string_slice(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t sidx,eidx;
|
int64_t sidx,eidx;
|
||||||
SQObjectPtr o;
|
SQObjectPtr o;
|
||||||
@ -845,7 +845,7 @@ static int64_t string_slice(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t string_find(HRABBITVM v)
|
static int64_t string_find(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t top,start_idx=0;
|
int64_t top,start_idx=0;
|
||||||
const SQChar *str,*substr,*ret;
|
const SQChar *str,*substr,*ret;
|
||||||
@ -863,7 +863,7 @@ static int64_t string_find(HRABBITVM v)
|
|||||||
return sq_throwerror(v,_SC("invalid param"));
|
return sq_throwerror(v,_SC("invalid param"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define STRING_TOFUNCZ(func) static int64_t string_##func(HRABBITVM v) \
|
#define STRING_TOFUNCZ(func) static int64_t string_##func(rabbit::VirtualMachine* v) \
|
||||||
{\
|
{\
|
||||||
int64_t sidx,eidx; \
|
int64_t sidx,eidx; \
|
||||||
SQObjectPtr str; \
|
SQObjectPtr str; \
|
||||||
@ -910,12 +910,12 @@ const SQRegFunction SQSharedState::_number_default_delegate_funcz[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
//CLOSURE DEFAULT DELEGATE//////////////////////////
|
//CLOSURE DEFAULT DELEGATE//////////////////////////
|
||||||
static int64_t closure_pcall(HRABBITVM v)
|
static int64_t closure_pcall(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_call(v,sq_gettop(v)-1,SQTrue,SQFalse))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_call(v,sq_gettop(v)-1,SQTrue,SQFalse))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_call(HRABBITVM v)
|
static int64_t closure_call(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &c = stack_get(v, -1);
|
SQObjectPtr &c = stack_get(v, -1);
|
||||||
if (sq_type(c) == OT_CLOSURE && (_closure(c)->_function->_bgenerator == false))
|
if (sq_type(c) == OT_CLOSURE && (_closure(c)->_function->_bgenerator == false))
|
||||||
@ -925,7 +925,7 @@ static int64_t closure_call(HRABBITVM v)
|
|||||||
return SQ_SUCCEEDED(sq_call(v, sq_gettop(v) - 1, SQTrue, SQTrue)) ? 1 : SQ_ERROR;
|
return SQ_SUCCEEDED(sq_call(v, sq_gettop(v) - 1, SQTrue, SQTrue)) ? 1 : SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t _closure_acall(HRABBITVM v,SQBool raiseerror)
|
static int64_t _closure_acall(rabbit::VirtualMachine* v,SQBool raiseerror)
|
||||||
{
|
{
|
||||||
rabbit::Array *aparams=_array(stack_get(v,2));
|
rabbit::Array *aparams=_array(stack_get(v,2));
|
||||||
int64_t nparams=aparams->size();
|
int64_t nparams=aparams->size();
|
||||||
@ -934,38 +934,38 @@ static int64_t _closure_acall(HRABBITVM v,SQBool raiseerror)
|
|||||||
return SQ_SUCCEEDED(sq_call(v,nparams,SQTrue,raiseerror))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_call(v,nparams,SQTrue,raiseerror))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_acall(HRABBITVM v)
|
static int64_t closure_acall(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return _closure_acall(v,SQTrue);
|
return _closure_acall(v,SQTrue);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_pacall(HRABBITVM v)
|
static int64_t closure_pacall(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return _closure_acall(v,SQFalse);
|
return _closure_acall(v,SQFalse);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_bindenv(HRABBITVM v)
|
static int64_t closure_bindenv(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_bindenv(v,1)))
|
if(SQ_FAILED(sq_bindenv(v,1)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_getroot(HRABBITVM v)
|
static int64_t closure_getroot(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_getclosureroot(v,-1)))
|
if(SQ_FAILED(sq_getclosureroot(v,-1)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_setroot(HRABBITVM v)
|
static int64_t closure_setroot(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_setclosureroot(v,-2)))
|
if(SQ_FAILED(sq_setclosureroot(v,-2)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t closure_getinfos(HRABBITVM v) {
|
static int64_t closure_getinfos(rabbit::VirtualMachine* v) {
|
||||||
SQObject o = stack_get(v,1);
|
SQObject o = stack_get(v,1);
|
||||||
SQTable *res = SQTable::create(_ss(v),4);
|
SQTable *res = SQTable::create(_ss(v),4);
|
||||||
if(sq_type(o) == OT_CLOSURE) {
|
if(sq_type(o) == OT_CLOSURE) {
|
||||||
@ -1025,7 +1025,7 @@ const SQRegFunction SQSharedState::_closure_default_delegate_funcz[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
//GENERATOR DEFAULT DELEGATE
|
//GENERATOR DEFAULT DELEGATE
|
||||||
static int64_t generator_getstatus(HRABBITVM v)
|
static int64_t generator_getstatus(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObject &o=stack_get(v,1);
|
SQObject &o=stack_get(v,1);
|
||||||
switch(_generator(o)->_state){
|
switch(_generator(o)->_state){
|
||||||
@ -1044,7 +1044,7 @@ const SQRegFunction SQSharedState::_generator_default_delegate_funcz[]={
|
|||||||
};
|
};
|
||||||
|
|
||||||
//THREAD DEFAULT DELEGATE
|
//THREAD DEFAULT DELEGATE
|
||||||
static int64_t thread_call(HRABBITVM v)
|
static int64_t thread_call(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(sq_type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
@ -1063,11 +1063,11 @@ static int64_t thread_call(HRABBITVM v)
|
|||||||
return sq_throwerror(v,_SC("wrong parameter"));
|
return sq_throwerror(v,_SC("wrong parameter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t thread_wakeup(HRABBITVM v)
|
static int64_t thread_wakeup(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(sq_type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
rabbit::VirtualMachine *thread = _thread(o);
|
||||||
int64_t state = sq_getvmstate(thread);
|
int64_t state = sq_getvmstate(thread);
|
||||||
if(state != SQ_VMSTATE_SUSPENDED) {
|
if(state != SQ_VMSTATE_SUSPENDED) {
|
||||||
switch(state) {
|
switch(state) {
|
||||||
@ -1099,11 +1099,11 @@ static int64_t thread_wakeup(HRABBITVM v)
|
|||||||
return sq_throwerror(v,_SC("wrong parameter"));
|
return sq_throwerror(v,_SC("wrong parameter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t thread_wakeupthrow(HRABBITVM v)
|
static int64_t thread_wakeupthrow(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(sq_type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
rabbit::VirtualMachine *thread = _thread(o);
|
||||||
int64_t state = sq_getvmstate(thread);
|
int64_t state = sq_getvmstate(thread);
|
||||||
if(state != SQ_VMSTATE_SUSPENDED) {
|
if(state != SQ_VMSTATE_SUSPENDED) {
|
||||||
switch(state) {
|
switch(state) {
|
||||||
@ -1140,7 +1140,7 @@ static int64_t thread_wakeupthrow(HRABBITVM v)
|
|||||||
return sq_throwerror(v,_SC("wrong parameter"));
|
return sq_throwerror(v,_SC("wrong parameter"));
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t thread_getstatus(HRABBITVM v)
|
static int64_t thread_getstatus(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr &o = stack_get(v,1);
|
SQObjectPtr &o = stack_get(v,1);
|
||||||
switch(sq_getvmstate(_thread(o))) {
|
switch(sq_getvmstate(_thread(o))) {
|
||||||
@ -1159,11 +1159,11 @@ static int64_t thread_getstatus(HRABBITVM v)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t thread_getstackinfos(HRABBITVM v)
|
static int64_t thread_getstackinfos(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
SQObjectPtr o = stack_get(v,1);
|
SQObjectPtr o = stack_get(v,1);
|
||||||
if(sq_type(o) == OT_THREAD) {
|
if(sq_type(o) == OT_THREAD) {
|
||||||
SQVM *thread = _thread(o);
|
rabbit::VirtualMachine *thread = _thread(o);
|
||||||
int64_t threadtop = sq_gettop(thread);
|
int64_t threadtop = sq_gettop(thread);
|
||||||
int64_t level;
|
int64_t level;
|
||||||
sq_getinteger(v,-1,&level);
|
sq_getinteger(v,-1,&level);
|
||||||
@ -1203,27 +1203,27 @@ const SQRegFunction SQSharedState::_thread_default_delegate_funcz[] = {
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int64_t class_getattributes(HRABBITVM v)
|
static int64_t class_getattributes(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_getattributes(v,-2))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_getattributes(v,-2))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t class_setattributes(HRABBITVM v)
|
static int64_t class_setattributes(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_setattributes(v,-3))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_setattributes(v,-3))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t class_instance(HRABBITVM v)
|
static int64_t class_instance(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_createinstance(v,-1))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_createinstance(v,-1))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t class_getbase(HRABBITVM v)
|
static int64_t class_getbase(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
return SQ_SUCCEEDED(sq_getbase(v,-1))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_getbase(v,-1))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t class_newmember(HRABBITVM v)
|
static int64_t class_newmember(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
SQBool bstatic = SQFalse;
|
SQBool bstatic = SQFalse;
|
||||||
@ -1239,7 +1239,7 @@ static int64_t class_newmember(HRABBITVM v)
|
|||||||
return SQ_SUCCEEDED(sq_newmember(v,-4,bstatic))?1:SQ_ERROR;
|
return SQ_SUCCEEDED(sq_newmember(v,-4,bstatic))?1:SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t class_rawnewmember(HRABBITVM v)
|
static int64_t class_rawnewmember(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
int64_t top = sq_gettop(v);
|
int64_t top = sq_gettop(v);
|
||||||
SQBool bstatic = SQFalse;
|
SQBool bstatic = SQFalse;
|
||||||
@ -1271,7 +1271,7 @@ const SQRegFunction SQSharedState::_class_default_delegate_funcz[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int64_t instance_getclass(HRABBITVM v)
|
static int64_t instance_getclass(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_SUCCEEDED(sq_getclass(v,1)))
|
if(SQ_SUCCEEDED(sq_getclass(v,1)))
|
||||||
return 1;
|
return 1;
|
||||||
@ -1288,7 +1288,7 @@ const SQRegFunction SQSharedState::_instance_default_delegate_funcz[] = {
|
|||||||
{NULL,(SQFUNCTION)0,0,NULL}
|
{NULL,(SQFUNCTION)0,0,NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int64_t weakref_ref(HRABBITVM v)
|
static int64_t weakref_ref(rabbit::VirtualMachine* v)
|
||||||
{
|
{
|
||||||
if(SQ_FAILED(sq_getweakrefval(v,1)))
|
if(SQ_FAILED(sq_getweakrefval(v,1)))
|
||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* @license MPL-2 (see license file)
|
* @license MPL-2 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqtable.hpp>
|
#include <rabbit/sqtable.hpp>
|
||||||
#include <rabbit/sqclass.hpp>
|
#include <rabbit/sqclass.hpp>
|
||||||
#include <rabbit/sqfuncproto.hpp>
|
#include <rabbit/sqfuncproto.hpp>
|
||||||
@ -76,7 +76,7 @@ bool SQClass::newSlot(SQSharedState *ss,const SQObjectPtr &key,const SQObjectPtr
|
|||||||
}
|
}
|
||||||
if(sq_type(temp) == OT_NULL) {
|
if(sq_type(temp) == OT_NULL) {
|
||||||
bool isconstructor;
|
bool isconstructor;
|
||||||
SQVM::isEqual(ss->_constructoridx, key, isconstructor);
|
rabbit::VirtualMachine::isEqual(ss->_constructoridx, key, isconstructor);
|
||||||
if(isconstructor) {
|
if(isconstructor) {
|
||||||
_constructoridx = (int64_t)_methods.size();
|
_constructoridx = (int64_t)_methods.size();
|
||||||
}
|
}
|
||||||
@ -186,7 +186,7 @@ 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)
|
bool SQInstance::getMetaMethod(rabbit::VirtualMachine* SQ_UNUSED_ARG(v),SQMetaMethod mm,SQObjectPtr &res)
|
||||||
{
|
{
|
||||||
if(sq_type(_class->_metamethods[mm]) != OT_NULL) {
|
if(sq_type(_class->_metamethods[mm]) != OT_NULL) {
|
||||||
res = _class->_metamethods[mm];
|
res = _class->_metamethods[mm];
|
||||||
|
@ -147,7 +147,7 @@ public:
|
|||||||
}
|
}
|
||||||
void finalize();
|
void finalize();
|
||||||
bool instanceOf(SQClass *trg);
|
bool instanceOf(SQClass *trg);
|
||||||
bool getMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res);
|
bool getMetaMethod(rabbit::VirtualMachine *v,SQMetaMethod mm,SQObjectPtr &res);
|
||||||
|
|
||||||
SQClass *_class;
|
SQClass *_class;
|
||||||
SQUserPointer _userpointer;
|
SQUserPointer _userpointer;
|
||||||
|
@ -60,8 +60,8 @@ public:
|
|||||||
}
|
}
|
||||||
~SQClosure();
|
~SQClosure();
|
||||||
|
|
||||||
bool save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
|
bool save(rabbit::VirtualMachine *v,SQUserPointer up,SQWRITEFUNC write);
|
||||||
static bool load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
|
static bool load(rabbit::VirtualMachine *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
|
||||||
rabbit::WeakRef *_env;
|
rabbit::WeakRef *_env;
|
||||||
rabbit::WeakRef *_root;
|
rabbit::WeakRef *_root;
|
||||||
SQClass *_base;
|
SQClass *_base;
|
||||||
@ -131,12 +131,12 @@ public:
|
|||||||
sq_delete(this,SQGenerator);
|
sq_delete(this,SQGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool yield(SQVM *v,int64_t target);
|
bool yield(rabbit::VirtualMachine *v,int64_t target);
|
||||||
bool resume(SQVM *v,SQObjectPtr &dest);
|
bool resume(rabbit::VirtualMachine *v,SQObjectPtr &dest);
|
||||||
SQObjectPtr _closure;
|
SQObjectPtr _closure;
|
||||||
SQObjectPtrVec _stack;
|
SQObjectPtrVec _stack;
|
||||||
SQVM::callInfo _ci;
|
rabbit::VirtualMachine::callInfo _ci;
|
||||||
ExceptionsTraps _etraps;
|
etk::Vector<SQExceptionTrap> _etraps;
|
||||||
SQGeneratorState _state;
|
SQGeneratorState _state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <rabbit/sqcompiler.hpp>
|
#include <rabbit/sqcompiler.hpp>
|
||||||
#include <rabbit/sqfuncstate.hpp>
|
#include <rabbit/sqfuncstate.hpp>
|
||||||
#include <rabbit/sqlexer.hpp>
|
#include <rabbit/sqlexer.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqtable.hpp>
|
#include <rabbit/sqtable.hpp>
|
||||||
|
|
||||||
#define EXPR 1
|
#define EXPR 1
|
||||||
@ -76,7 +76,7 @@ struct SQScope {
|
|||||||
class SQcompiler
|
class SQcompiler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SQcompiler(SQVM *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo)
|
SQcompiler(rabbit::VirtualMachine *v, SQLEXREADFUNC rg, SQUserPointer up, const SQChar* sourcename, bool raiseerror, bool lineinfo)
|
||||||
{
|
{
|
||||||
_vm=v;
|
_vm=v;
|
||||||
_lex.init(_ss(v), rg, up,Throwerror,this);
|
_lex.init(_ss(v), rg, up,Throwerror,this);
|
||||||
@ -1579,10 +1579,10 @@ private:
|
|||||||
SQScope _scope;
|
SQScope _scope;
|
||||||
SQChar _compilererror[MAX_COMPILER_ERROR_LEN];
|
SQChar _compilererror[MAX_COMPILER_ERROR_LEN];
|
||||||
jmp_buf _errorjmp;
|
jmp_buf _errorjmp;
|
||||||
SQVM *_vm;
|
rabbit::VirtualMachine *_vm;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool compile(SQVM *vm,SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo)
|
bool compile(rabbit::VirtualMachine *vm,SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo)
|
||||||
{
|
{
|
||||||
SQcompiler p(vm, rg, up, sourcename, raiseerror, lineinfo);
|
SQcompiler p(vm, rg, up, sourcename, raiseerror, lineinfo);
|
||||||
return p.compile(out);
|
return p.compile(out);
|
||||||
|
@ -6,8 +6,9 @@
|
|||||||
* @license MPL-2 (see license file)
|
* @license MPL-2 (see license file)
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
namespace rabbit {
|
||||||
struct SQVM;
|
class VirtualMachine;
|
||||||
|
}
|
||||||
|
|
||||||
#define TK_IDENTIFIER 258
|
#define TK_IDENTIFIER 258
|
||||||
#define TK_STRING_LITERAL 259
|
#define TK_STRING_LITERAL 259
|
||||||
@ -80,4 +81,4 @@ struct SQVM;
|
|||||||
|
|
||||||
|
|
||||||
typedef void(*compilererrorFunc)(void *ud, const SQChar *s);
|
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);
|
bool compile(rabbit::VirtualMachine *vm, SQLEXREADFUNC rg, SQUserPointer up, const SQChar *sourcename, SQObjectPtr &out, bool raiseerror, bool lineinfo);
|
||||||
|
@ -8,16 +8,16 @@
|
|||||||
|
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqfuncproto.hpp>
|
#include <rabbit/sqfuncproto.hpp>
|
||||||
#include <rabbit/sqclosure.hpp>
|
#include <rabbit/sqclosure.hpp>
|
||||||
#include <rabbit/sqstring.hpp>
|
#include <rabbit/sqstring.hpp>
|
||||||
|
|
||||||
SQRESULT sq_getfunctioninfo(HRABBITVM v,int64_t level,SQFunctionInfo *fi)
|
SQRESULT sq_getfunctioninfo(rabbit::VirtualMachine* v,int64_t level,SQFunctionInfo *fi)
|
||||||
{
|
{
|
||||||
int64_t cssize = v->_callsstacksize;
|
int64_t cssize = v->_callsstacksize;
|
||||||
if (cssize > level) {
|
if (cssize > level) {
|
||||||
SQVM::callInfo &ci = v->_callsstack[cssize-level-1];
|
rabbit::VirtualMachine::callInfo &ci = v->_callsstack[cssize-level-1];
|
||||||
if(sq_isclosure(ci._closure)) {
|
if(sq_isclosure(ci._closure)) {
|
||||||
SQClosure *c = _closure(ci._closure);
|
SQClosure *c = _closure(ci._closure);
|
||||||
SQFunctionProto *proto = c->_function;
|
SQFunctionProto *proto = c->_function;
|
||||||
@ -31,12 +31,12 @@ SQRESULT sq_getfunctioninfo(HRABBITVM v,int64_t level,SQFunctionInfo *fi)
|
|||||||
return sq_throwerror(v,_SC("the object is not a closure"));
|
return sq_throwerror(v,_SC("the object is not a closure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
SQRESULT sq_stackinfos(HRABBITVM v, int64_t level, SQStackInfos *si)
|
SQRESULT sq_stackinfos(rabbit::VirtualMachine* v, int64_t level, SQStackInfos *si)
|
||||||
{
|
{
|
||||||
int64_t cssize = v->_callsstacksize;
|
int64_t cssize = v->_callsstacksize;
|
||||||
if (cssize > level) {
|
if (cssize > level) {
|
||||||
memset(si, 0, sizeof(SQStackInfos));
|
memset(si, 0, sizeof(SQStackInfos));
|
||||||
SQVM::callInfo &ci = v->_callsstack[cssize-level-1];
|
rabbit::VirtualMachine::callInfo &ci = v->_callsstack[cssize-level-1];
|
||||||
switch (sq_type(ci._closure)) {
|
switch (sq_type(ci._closure)) {
|
||||||
case OT_CLOSURE:{
|
case OT_CLOSURE:{
|
||||||
SQFunctionProto *func = _closure(ci._closure)->_function;
|
SQFunctionProto *func = _closure(ci._closure)->_function;
|
||||||
@ -61,7 +61,7 @@ SQRESULT sq_stackinfos(HRABBITVM v, int64_t level, SQStackInfos *si)
|
|||||||
return SQ_ERROR;
|
return SQ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::raise_error(const SQChar *s, ...)
|
void rabbit::VirtualMachine::raise_error(const SQChar *s, ...)
|
||||||
{
|
{
|
||||||
va_list vl;
|
va_list vl;
|
||||||
va_start(vl, s);
|
va_start(vl, s);
|
||||||
@ -71,12 +71,12 @@ void SQVM::raise_error(const SQChar *s, ...)
|
|||||||
_lasterror = SQString::create(_ss(this),_spval,-1);
|
_lasterror = SQString::create(_ss(this),_spval,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::raise_error(const SQObjectPtr &desc)
|
void rabbit::VirtualMachine::raise_error(const SQObjectPtr &desc)
|
||||||
{
|
{
|
||||||
_lasterror = desc;
|
_lasterror = desc;
|
||||||
}
|
}
|
||||||
|
|
||||||
SQString *SQVM::printObjVal(const SQObjectPtr &o)
|
SQString *rabbit::VirtualMachine::printObjVal(const SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
switch(sq_type(o)) {
|
switch(sq_type(o)) {
|
||||||
case OT_STRING: return _string(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 rabbit::VirtualMachine::raise_Idxerror(const SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
SQObjectPtr oval = printObjVal(o);
|
SQObjectPtr oval = printObjVal(o);
|
||||||
raise_error(_SC("the index '%.50s' does not exist"), _stringval(oval));
|
raise_error(_SC("the index '%.50s' does not exist"), _stringval(oval));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SQVM::raise_Compareerror(const SQObject &o1, const SQObject &o2)
|
void rabbit::VirtualMachine::raise_Compareerror(const SQObject &o1, const SQObject &o2)
|
||||||
{
|
{
|
||||||
SQObjectPtr oval1 = printObjVal(o1), oval2 = printObjVal(o2);
|
SQObjectPtr oval1 = printObjVal(o1), oval2 = printObjVal(o2);
|
||||||
raise_error(_SC("comparison between '%.50s' and '%.50s'"), _stringval(oval1), _stringval(oval2));
|
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 rabbit::VirtualMachine::raise_ParamTypeerror(int64_t nparam,int64_t typemask,int64_t type)
|
||||||
{
|
{
|
||||||
SQObjectPtr exptypes = SQString::create(_ss(this), _SC(""), -1);
|
SQObjectPtr exptypes = SQString::create(_ss(this), _SC(""), -1);
|
||||||
int64_t found = 0;
|
int64_t found = 0;
|
||||||
|
@ -116,10 +116,10 @@ public:
|
|||||||
sq_vm_free(this,size);
|
sq_vm_free(this,size);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SQChar* getLocal(SQVM *v,uint64_t stackbase,uint64_t nseq,uint64_t nop);
|
const SQChar* getLocal(rabbit::VirtualMachine *v,uint64_t stackbase,uint64_t nseq,uint64_t nop);
|
||||||
int64_t getLine(SQInstruction *curr);
|
int64_t getLine(SQInstruction *curr);
|
||||||
bool save(SQVM *v,SQUserPointer up,SQWRITEFUNC write);
|
bool save(rabbit::VirtualMachine *v,SQUserPointer up,SQWRITEFUNC write);
|
||||||
static bool load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
|
static bool load(rabbit::VirtualMachine *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret);
|
||||||
SQObjectPtr _sourcename;
|
SQObjectPtr _sourcename;
|
||||||
SQObjectPtr _name;
|
SQObjectPtr _name;
|
||||||
int64_t _stacksize;
|
int64_t _stacksize;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* @license MPL-2 (see license file)
|
* @license MPL-2 (see license file)
|
||||||
*/
|
*/
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqstring.hpp>
|
#include <rabbit/sqstring.hpp>
|
||||||
#include <rabbit/Array.hpp>
|
#include <rabbit/Array.hpp>
|
||||||
#include <rabbit/sqtable.hpp>
|
#include <rabbit/sqtable.hpp>
|
||||||
@ -88,7 +88,7 @@ uint64_t translateIndex(const SQObjectPtr &idx)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
bool SQDelegable::getMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res) {
|
bool SQDelegable::getMetaMethod(rabbit::VirtualMachine *v,SQMetaMethod mm,SQObjectPtr &res) {
|
||||||
if(_delegate) {
|
if(_delegate) {
|
||||||
return _delegate->get((*_ss(v)->_metamethods)[mm],res);
|
return _delegate->get((*_ss(v)->_metamethods)[mm],res);
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ bool SQDelegable::setDelegate(SQTable *mt)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQGenerator::yield(SQVM *v,int64_t target)
|
bool SQGenerator::yield(rabbit::VirtualMachine *v,int64_t target)
|
||||||
{
|
{
|
||||||
if(_state==eSuspended) { v->raise_error(_SC("internal vm error, yielding 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; }
|
if(_state==eDead) { v->raise_error(_SC("internal vm error, yielding a dead generator")); return false; }
|
||||||
@ -140,7 +140,7 @@ bool SQGenerator::yield(SQVM *v,int64_t target)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQGenerator::resume(SQVM *v,SQObjectPtr &dest)
|
bool SQGenerator::resume(rabbit::VirtualMachine *v,SQObjectPtr &dest)
|
||||||
{
|
{
|
||||||
if(_state==eDead){ v->raise_error(_SC("resuming dead 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; }
|
if(_state==eRunning){ v->raise_error(_SC("resuming active generator")); return false; }
|
||||||
@ -190,7 +190,7 @@ void rabbit::Array::extend(const rabbit::Array *a){
|
|||||||
append((*a)[i]);
|
append((*a)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const SQChar* SQFunctionProto::getLocal(SQVM *vm,uint64_t stackbase,uint64_t nseq,uint64_t nop)
|
const SQChar* SQFunctionProto::getLocal(rabbit::VirtualMachine *vm,uint64_t stackbase,uint64_t nseq,uint64_t nop)
|
||||||
{
|
{
|
||||||
uint64_t nvars=_nlocalvarinfos;
|
uint64_t nvars=_nlocalvarinfos;
|
||||||
const SQChar *res=NULL;
|
const SQChar *res=NULL;
|
||||||
@ -253,7 +253,7 @@ SQClosure::~SQClosure()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define _CHECK_IO(exp) { if(!exp)return false; }
|
#define _CHECK_IO(exp) { if(!exp)return false; }
|
||||||
bool SafeWrite(HRABBITVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest,int64_t size)
|
bool SafeWrite(rabbit::VirtualMachine* v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest,int64_t size)
|
||||||
{
|
{
|
||||||
if(write(up,dest,size) != 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)"));
|
||||||
@ -262,7 +262,7 @@ bool SafeWrite(HRABBITVM v,SQWRITEFUNC write,SQUserPointer up,SQUserPointer dest
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SafeRead(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,int64_t size)
|
bool SafeRead(rabbit::VirtualMachine* v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,int64_t size)
|
||||||
{
|
{
|
||||||
if(size && read(up,dest,size) != 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"));
|
||||||
@ -271,12 +271,12 @@ bool SafeRead(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,SQUserPointer dest,i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteTag(HRABBITVM v,SQWRITEFUNC write,SQUserPointer up,uint32_t tag)
|
bool WriteTag(rabbit::VirtualMachine* v,SQWRITEFUNC write,SQUserPointer up,uint32_t tag)
|
||||||
{
|
{
|
||||||
return SafeWrite(v,write,up,&tag,sizeof(tag));
|
return SafeWrite(v,write,up,&tag,sizeof(tag));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckTag(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,uint32_t tag)
|
bool CheckTag(rabbit::VirtualMachine* v,SQWRITEFUNC read,SQUserPointer up,uint32_t tag)
|
||||||
{
|
{
|
||||||
uint32_t t;
|
uint32_t t;
|
||||||
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
|
_CHECK_IO(SafeRead(v,read,up,&t,sizeof(t)));
|
||||||
@ -287,7 +287,7 @@ bool CheckTag(HRABBITVM v,SQWRITEFUNC read,SQUserPointer up,uint32_t tag)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WriteObject(HRABBITVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
|
bool WriteObject(rabbit::VirtualMachine* v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
uint32_t _type = (uint32_t)sq_type(o);
|
uint32_t _type = (uint32_t)sq_type(o);
|
||||||
_CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
|
_CHECK_IO(SafeWrite(v,write,up,&_type,sizeof(_type)));
|
||||||
@ -310,7 +310,7 @@ bool WriteObject(HRABBITVM v,SQUserPointer up,SQWRITEFUNC write,SQObjectPtr &o)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadObject(HRABBITVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
|
bool ReadObject(rabbit::VirtualMachine* v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
|
||||||
{
|
{
|
||||||
uint32_t _type;
|
uint32_t _type;
|
||||||
_CHECK_IO(SafeRead(v,read,up,&_type,sizeof(_type)));
|
_CHECK_IO(SafeRead(v,read,up,&_type,sizeof(_type)));
|
||||||
@ -345,7 +345,7 @@ bool ReadObject(HRABBITVM v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &o)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQClosure::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
|
bool SQClosure::save(rabbit::VirtualMachine *v,SQUserPointer up,SQWRITEFUNC write)
|
||||||
{
|
{
|
||||||
_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_HEAD));
|
_CHECK_IO(WriteTag(v,write,up,SQ_CLOSURESTREAM_HEAD));
|
||||||
_CHECK_IO(WriteTag(v,write,up,sizeof(SQChar)));
|
_CHECK_IO(WriteTag(v,write,up,sizeof(SQChar)));
|
||||||
@ -356,7 +356,7 @@ bool SQClosure::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQClosure::load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
|
bool SQClosure::load(rabbit::VirtualMachine *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
|
||||||
{
|
{
|
||||||
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_HEAD));
|
_CHECK_IO(CheckTag(v,read,up,SQ_CLOSURESTREAM_HEAD));
|
||||||
_CHECK_IO(CheckTag(v,read,up,sizeof(SQChar)));
|
_CHECK_IO(CheckTag(v,read,up,sizeof(SQChar)));
|
||||||
@ -380,7 +380,7 @@ SQFunctionProto::~SQFunctionProto()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQFunctionProto::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
|
bool SQFunctionProto::save(rabbit::VirtualMachine *v,SQUserPointer up,SQWRITEFUNC write)
|
||||||
{
|
{
|
||||||
int64_t i,nliterals = _nliterals,nparameters = _nparameters;
|
int64_t i,nliterals = _nliterals,nparameters = _nparameters;
|
||||||
int64_t noutervalues = _noutervalues,nlocalvarinfos = _nlocalvarinfos;
|
int64_t noutervalues = _noutervalues,nlocalvarinfos = _nlocalvarinfos;
|
||||||
@ -443,7 +443,7 @@ bool SQFunctionProto::save(SQVM *v,SQUserPointer up,SQWRITEFUNC write)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SQFunctionProto::load(SQVM *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
|
bool SQFunctionProto::load(rabbit::VirtualMachine *v,SQUserPointer up,SQREADFUNC read,SQObjectPtr &ret)
|
||||||
{
|
{
|
||||||
int64_t i, nliterals,nparameters;
|
int64_t i, nliterals,nparameters;
|
||||||
int64_t noutervalues ,nlocalvarinfos ;
|
int64_t noutervalues ,nlocalvarinfos ;
|
||||||
|
@ -225,7 +225,7 @@ struct SQObjectPtr : public SQObject
|
|||||||
_REF_TYPE_DECL(OT_STRING,SQString,pString)
|
_REF_TYPE_DECL(OT_STRING,SQString,pString)
|
||||||
_REF_TYPE_DECL(OT_USERDATA,rabbit::UserData,pUserData)
|
_REF_TYPE_DECL(OT_USERDATA,rabbit::UserData,pUserData)
|
||||||
_REF_TYPE_DECL(OT_WEAKREF,rabbit::WeakRef,pWeakRef)
|
_REF_TYPE_DECL(OT_WEAKREF,rabbit::WeakRef,pWeakRef)
|
||||||
_REF_TYPE_DECL(OT_THREAD,SQVM,pThread)
|
_REF_TYPE_DECL(OT_THREAD,rabbit::VirtualMachine,pThread)
|
||||||
_REF_TYPE_DECL(OT_FUNCPROTO,SQFunctionProto,pFunctionProto)
|
_REF_TYPE_DECL(OT_FUNCPROTO,SQFunctionProto,pFunctionProto)
|
||||||
|
|
||||||
_SCALAR_TYPE_DECL(OT_INTEGER,int64_t,nInteger)
|
_SCALAR_TYPE_DECL(OT_INTEGER,int64_t,nInteger)
|
||||||
@ -302,7 +302,7 @@ inline void _Swap(SQObject &a,SQObject &b)
|
|||||||
|
|
||||||
struct SQDelegable : public rabbit::RefCounted {
|
struct SQDelegable : public rabbit::RefCounted {
|
||||||
bool setDelegate(SQTable *m);
|
bool setDelegate(SQTable *m);
|
||||||
virtual bool getMetaMethod(SQVM *v,SQMetaMethod mm,SQObjectPtr &res);
|
virtual bool getMetaMethod(rabbit::VirtualMachine *v,SQMetaMethod mm,SQObjectPtr &res);
|
||||||
SQTable *_delegate;
|
SQTable *_delegate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <rabbit/sqopcodes.hpp>
|
#include <rabbit/sqopcodes.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqfuncproto.hpp>
|
#include <rabbit/sqfuncproto.hpp>
|
||||||
#include <rabbit/sqclosure.hpp>
|
#include <rabbit/sqclosure.hpp>
|
||||||
#include <rabbit/sqstring.hpp>
|
#include <rabbit/sqstring.hpp>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <rabbit/sqpcheader.hpp>
|
#include <rabbit/sqpcheader.hpp>
|
||||||
#include <rabbit/sqvm.hpp>
|
#include <rabbit/VirtualMachine.hpp>
|
||||||
#include <rabbit/sqtable.hpp>
|
#include <rabbit/sqtable.hpp>
|
||||||
#include <rabbit/sqfuncproto.hpp>
|
#include <rabbit/sqfuncproto.hpp>
|
||||||
#include <rabbit/sqclosure.hpp>
|
#include <rabbit/sqclosure.hpp>
|
||||||
|
208
rabbit/sqvm.hpp
208
rabbit/sqvm.hpp
@ -1,208 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Alberto DEMICHELIS
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
* @copyright 2018, Edouard DUPIN, all right reserved
|
|
||||||
* @copyright 2003-2017, Alberto DEMICHELIS, all right reserved
|
|
||||||
* @license MPL-2 (see license file)
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <rabbit/sqopcodes.hpp>
|
|
||||||
#include <rabbit/sqobject.hpp>
|
|
||||||
|
|
||||||
#define MAX_NATIVE_CALLS 100
|
|
||||||
#define MIN_STACK_OVERHEAD 15
|
|
||||||
|
|
||||||
#define SQ_SUSPEND_FLAG -666
|
|
||||||
#define SQ_TAILCALL_FLAG -777
|
|
||||||
#define DONT_FALL_BACK 666
|
|
||||||
//#define EXISTS_FALL_BACK -1
|
|
||||||
|
|
||||||
#define GET_FLAG_RAW 0x00000001
|
|
||||||
#define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002
|
|
||||||
//base lib
|
|
||||||
void sq_base_register(HRABBITVM v);
|
|
||||||
|
|
||||||
struct SQExceptionTrap{
|
|
||||||
SQExceptionTrap() {}
|
|
||||||
SQExceptionTrap(int64_t ss, int64_t stackbase,SQInstruction *ip, int64_t ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;}
|
|
||||||
SQExceptionTrap(const SQExceptionTrap &et) { (*this) = et; }
|
|
||||||
int64_t _stackbase;
|
|
||||||
int64_t _stacksize;
|
|
||||||
SQInstruction *_ip;
|
|
||||||
int64_t _extarget;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define _INLINE
|
|
||||||
|
|
||||||
typedef etk::Vector<SQExceptionTrap> ExceptionsTraps;
|
|
||||||
|
|
||||||
struct SQVM : public rabbit::RefCounted
|
|
||||||
{
|
|
||||||
struct callInfo{
|
|
||||||
//callInfo() { _generator = NULL;}
|
|
||||||
SQInstruction *_ip;
|
|
||||||
SQObjectPtr *_literals;
|
|
||||||
SQObjectPtr _closure;
|
|
||||||
SQGenerator *_generator;
|
|
||||||
int32_t _etraps;
|
|
||||||
int32_t _prevstkbase;
|
|
||||||
int32_t _prevtop;
|
|
||||||
int32_t _target;
|
|
||||||
int32_t _ncalls;
|
|
||||||
SQBool _root;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef etk::Vector<callInfo> callInfoVec;
|
|
||||||
public:
|
|
||||||
void DebugHookProxy(int64_t type, const SQChar * sourcename, int64_t line, const SQChar * funcname);
|
|
||||||
static void _DebugHookProxy(HRABBITVM v, int64_t type, const SQChar * sourcename, int64_t line, const SQChar * funcname);
|
|
||||||
enum ExecutionType { ET_CALL, ET_RESUME_GENERATOR, ET_RESUME_VM,ET_RESUME_THROW_VM };
|
|
||||||
SQVM(SQSharedState *ss);
|
|
||||||
~SQVM();
|
|
||||||
bool init(SQVM *friendvm, int64_t stacksize);
|
|
||||||
bool execute(SQObjectPtr &func, int64_t nargs, int64_t stackbase, SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
|
|
||||||
//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);
|
|
||||||
//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 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);
|
|
||||||
SQRESULT Suspend();
|
|
||||||
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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);
|
|
||||||
bool BW_OP(uint64_t op,SQObjectPtr &trg,const SQObjectPtr &o1,const SQObjectPtr &o2);
|
|
||||||
bool NEG_OP(SQObjectPtr &trg,const SQObjectPtr &o1);
|
|
||||||
bool CMP_OP(CmpOP op, const SQObjectPtr &o1,const SQObjectPtr &o2,SQObjectPtr &res);
|
|
||||||
bool CLOSURE_OP(SQObjectPtr &target, SQFunctionProto *func);
|
|
||||||
bool CLASS_OP(SQObjectPtr &target,int64_t base,int64_t attrs);
|
|
||||||
//return true if the loop is finished
|
|
||||||
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);
|
|
||||||
#ifdef _DEBUG_DUMP
|
|
||||||
void dumpstack(int64_t stackbase=-1, bool dumpall = false);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
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();
|
|
||||||
void release(){ sq_delete(this,SQVM); }
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
//stack functions for the api
|
|
||||||
void remove(int64_t n);
|
|
||||||
|
|
||||||
static bool IsFalse(SQObjectPtr &o);
|
|
||||||
|
|
||||||
void pop();
|
|
||||||
void pop(int64_t n);
|
|
||||||
void push(const SQObjectPtr &o);
|
|
||||||
void pushNull();
|
|
||||||
SQObjectPtr &top();
|
|
||||||
SQObjectPtr &popGet();
|
|
||||||
SQObjectPtr &getUp(int64_t n);
|
|
||||||
SQObjectPtr &getAt(int64_t n);
|
|
||||||
|
|
||||||
SQObjectPtrVec _stack;
|
|
||||||
|
|
||||||
int64_t _top;
|
|
||||||
int64_t _stackbase;
|
|
||||||
SQOuter *_openouters;
|
|
||||||
SQObjectPtr _roottable;
|
|
||||||
SQObjectPtr _lasterror;
|
|
||||||
SQObjectPtr _errorhandler;
|
|
||||||
|
|
||||||
bool _debughook;
|
|
||||||
SQDEBUGHOOK _debughook_native;
|
|
||||||
SQObjectPtr _debughook_closure;
|
|
||||||
|
|
||||||
SQObjectPtr temp_reg;
|
|
||||||
|
|
||||||
|
|
||||||
callInfo* _callsstack;
|
|
||||||
int64_t _callsstacksize;
|
|
||||||
int64_t _alloccallsstacksize;
|
|
||||||
etk::Vector<callInfo> _callstackdata;
|
|
||||||
|
|
||||||
ExceptionsTraps _etraps;
|
|
||||||
callInfo *ci;
|
|
||||||
SQUserPointer _foreignptr;
|
|
||||||
//VMs sharing the same state
|
|
||||||
SQSharedState *_sharedstate;
|
|
||||||
int64_t _nnativecalls;
|
|
||||||
int64_t _nmetamethodscall;
|
|
||||||
SQRELEASEHOOK _releasehook;
|
|
||||||
//suspend infos
|
|
||||||
SQBool _suspended;
|
|
||||||
SQBool _suspended_root;
|
|
||||||
int64_t _suspended_target;
|
|
||||||
int64_t _suspended_traps;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AutoDec{
|
|
||||||
AutoDec(int64_t *n) { _n = n; }
|
|
||||||
~AutoDec() { (*_n)--; }
|
|
||||||
int64_t *_n;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline SQObjectPtr &stack_get(HRABBITVM v,int64_t idx){return ((idx>=0)?(v->getAt(idx+v->_stackbase-1)):(v->getUp(idx)));}
|
|
||||||
|
|
||||||
#define _ss(_vm_) (_vm_)->_sharedstate
|
|
||||||
|
|
||||||
#define PUSH_CALLINFO(v,nci){ \
|
|
||||||
int64_t css = v->_callsstacksize; \
|
|
||||||
if(css == v->_alloccallsstacksize) { \
|
|
||||||
v->GrowcallStack(); \
|
|
||||||
} \
|
|
||||||
v->ci = &v->_callsstack[css]; \
|
|
||||||
*(v->ci) = nci; \
|
|
||||||
v->_callsstacksize++; \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define POP_CALLINFO(v){ \
|
|
||||||
int64_t css = --v->_callsstacksize; \
|
|
||||||
v->ci->_closure.Null(); \
|
|
||||||
v->ci = css?&v->_callsstack[css-1]:NULL; \
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user