7 #define MAX_NATIVE_CALLS 100 8 #define MIN_STACK_OVERHEAD 15 10 #define SQ_SUSPEND_FLAG -666 11 #define SQ_TAILCALL_FLAG -777 12 #define DONT_FALL_BACK 666 15 #define GET_FLAG_RAW 0x00000001 16 #define GET_FLAG_DO_NOT_RAISE_ERROR 0x00000002 21 SQExceptionTrap() : _stackbase(0), _stacksize(0), _ip(
nullptr), _extarget(0) {}
22 SQExceptionTrap(SQInteger ss, SQInteger stackbase,
SQInstruction *ip, SQInteger ex_target){ _stacksize = ss; _stackbase = stackbase; _ip = ip; _extarget = ex_target;}
33 struct SQVM :
public CHAINABLE_OBJ
51 void DebugHookProxy(SQInteger type,
const SQChar * sourcename, SQInteger line,
const SQChar * funcname);
52 static void _DebugHookProxy(
HSQUIRRELVM v, SQInteger type,
const SQChar * sourcename, SQInteger line,
const SQChar * funcname);
53 enum ExecutionType { ET_CALL, ET_RESUME_GENERATOR, ET_RESUME_VM,ET_RESUME_THROW_VM };
56 bool Init(
SQVM *friendvm, SQInteger stacksize);
57 bool Execute(
SQObjectPtr &func, SQInteger nargs, SQInteger stackbase,
SQObjectPtr &outres, SQBool raiseerror, ExecutionType et = ET_CALL);
59 bool CallNative(
SQNativeClosure *nclosure, SQInteger nargs, SQInteger newbase,
SQObjectPtr &retval, SQInt32 target,
bool &suspend,
bool &tailcall);
60 bool TailCall(
SQClosure *closure, SQInteger firstparam, SQInteger nparams);
62 bool StartCall(
SQClosure *closure, SQInteger target, SQInteger nargs, SQInteger stackbase,
bool tailcall);
65 bool Call(
SQObjectPtr &closure, SQInteger nparams, SQInteger stackbase,
SQObjectPtr &outres,SQBool raiseerror);
68 void CallDebugHook(SQInteger type,SQInteger forcedline=0);
86 void Raise_Error(
const SQChar *s, ...);
90 void Raise_ParamTypeError(SQInteger nparam,SQInteger typemask,SQInteger type);
93 void RelocateOuters();
99 bool Return(SQInteger _arg0, SQInteger _arg1,
SQObjectPtr &retval);
106 bool CLASS_OP(
SQObjectPtr &target,SQInteger base,SQInteger attrs);
113 void dumpstack(SQInteger stackbase=-1,
bool dumpall =
false);
116 #ifndef NO_GARBAGE_COLLECTOR 118 SQObjectType GetType() {
return OT_THREAD;}
122 void GrowCallStack() {
123 SQInteger newsize = _alloccallsstacksize*2;
124 _callstackdata.resize(newsize);
125 _callsstack = &_callstackdata[0];
126 _alloccallsstacksize = newsize;
128 bool EnterFrame(SQInteger newbase, SQInteger newtop,
bool tailcall);
130 void Release(){ sq_delete(
this,
SQVM); }
131 void CheckStackAccess(SQInteger n);
134 void Remove(SQInteger n);
139 void Pop(SQInteger n);
150 SQInteger _stackbase = 0;
157 SQDEBUGHOOK _debughook_native;
164 SQInteger _callsstacksize = 0;
165 SQInteger _alloccallsstacksize = 0;
170 SQUserPointer _foreignptr;
172 SQInteger _nnativecalls;
173 SQInteger _nmetamethodscall;
174 SQRELEASEHOOK _releasehook;
177 SQBool _suspended_root;
178 SQInteger _suspended_target;
179 SQInteger _suspended_traps;
183 AutoDec(SQInteger *n) { _n = n; }
188 inline SQObjectPtr &stack_get(
HSQUIRRELVM v,SQInteger idx){
return ((idx>=0)?(v->GetAt(idx+v->_stackbase-1)):(v->GetUp(idx)));}
190 #define _ss(_vm_) (_vm_)->_sharedstate 192 #ifndef NO_GARBAGE_COLLECTOR 193 #define _opt_ss(_vm_) (_vm_)->_sharedstate 195 #define _opt_ss(_vm_) NULL 198 #define PUSH_CALLINFO(v,nci){ \ 199 SQInteger css = v->_callsstacksize; \ 200 if(css == v->_alloccallsstacksize) { \ 201 v->GrowCallStack(); \ 203 v->ci = &v->_callsstack[css]; \ 205 v->_callsstacksize++; \ 208 #define POP_CALLINFO(v){ \ 209 SQInteger css = --v->_callsstacksize; \ 210 v->ci->_closure.Null(); \ 211 v->ci = css?&v->_callsstack[css-1]:NULL; \
Definition: sqclosure.h:10
Definition: sqclosure.h:74
Definition: sqclosure.h:108
Definition: sqopcodes.h:109
Definition: squirrel.h:153
Definition: sqobject.h:205
Definition: sqstring.h:14
Definition: sqclosure.h:147
Definition: sqfuncproto.h:49
Definition: sqobject.h:313