31 SQUnsignedInteger _start_op;
32 SQUnsignedInteger _end_op;
33 SQUnsignedInteger _pos;
42 #define _FUNC_SIZE(ni,nl,nparams,nfuncs,nouters,nlineinf,localinf,defparams) (sizeof(SQFunctionProto) \ 43 +((ni-1)*sizeof(SQInstruction))+(nl*sizeof(SQObjectPtr)) \ 44 +(nparams*sizeof(SQObjectPtr))+(nfuncs*sizeof(SQObjectPtr)) \ 45 +(nouters*sizeof(SQOuterVar))+(nlineinf*sizeof(SQLineInfo)) \ 46 +(localinf*sizeof(SQLocalVarInfo))+(defparams*sizeof(SQInteger))) 57 SQInteger nliterals,SQInteger nparameters,
58 SQInteger nfunctions,SQInteger noutervalues,
59 SQInteger nlineinfos,SQInteger nlocalvarinfos,SQInteger ndefaultparams)
63 f = (
SQFunctionProto *)sq_vm_malloc(_FUNC_SIZE(ninstructions,nliterals,nparameters,nfunctions,noutervalues,nlineinfos,nlocalvarinfos,ndefaultparams));
65 f->_ninstructions = ninstructions;
66 f->_literals = (
SQObjectPtr*)&f->_instructions[ninstructions];
67 f->_nliterals = nliterals;
68 f->_parameters = (
SQObjectPtr*)&f->_literals[nliterals];
69 f->_nparameters = nparameters;
70 f->_functions = (
SQObjectPtr*)&f->_parameters[nparameters];
71 f->_nfunctions = nfunctions;
72 f->_outervalues = (
SQOuterVar*)&f->_functions[nfunctions];
73 f->_noutervalues = noutervalues;
74 f->_lineinfos = (
SQLineInfo *)&f->_outervalues[noutervalues];
75 f->_nlineinfos = nlineinfos;
77 f->_nlocalvarinfos = nlocalvarinfos;
78 f->_defaultparams = (SQInteger *)&f->_localvarinfos[nlocalvarinfos];
79 f->_ndefaultparams = ndefaultparams;
81 _CONSTRUCT_VECTOR(
SQObjectPtr,f->_nliterals,f->_literals);
82 _CONSTRUCT_VECTOR(
SQObjectPtr,f->_nparameters,f->_parameters);
83 _CONSTRUCT_VECTOR(
SQObjectPtr,f->_nfunctions,f->_functions);
84 _CONSTRUCT_VECTOR(
SQOuterVar,f->_noutervalues,f->_outervalues);
86 _CONSTRUCT_VECTOR(
SQLocalVarInfo,f->_nlocalvarinfos,f->_localvarinfos);
91 _DESTRUCT_VECTOR(
SQObjectPtr,_nparameters,_parameters);
92 _DESTRUCT_VECTOR(
SQObjectPtr,_nfunctions,_functions);
93 _DESTRUCT_VECTOR(
SQOuterVar,_noutervalues,_outervalues);
96 SQInteger size = _FUNC_SIZE(_ninstructions,_nliterals,_nparameters,_nfunctions,_noutervalues,_nlineinfos,_nlocalvarinfos,_ndefaultparams);
98 sq_vm_free(
this,size);
101 const SQChar* GetLocal(
SQVM *v,SQUnsignedInteger stackbase,SQUnsignedInteger nseq,SQUnsignedInteger nop);
103 bool Save(
SQVM *v,SQUserPointer up,SQWRITEFUNC write);
104 static bool Load(
SQVM *v,SQUserPointer up,SQREADFUNC read,
SQObjectPtr &ret);
105 #ifndef NO_GARBAGE_COLLECTOR 107 void Finalize(){ _NULL_SQOBJECT_VECTOR(_literals,_nliterals); }
108 SQObjectType GetType() {
return OT_FUNCPROTO;}
112 SQInteger _stacksize;
114 SQInteger _varparams = 0;
116 SQInteger _nlocalvarinfos = 0;
119 SQInteger _nlineinfos = 0;
122 SQInteger _nliterals = 0;
125 SQInteger _nparameters = 0;
128 SQInteger _nfunctions = 0;
131 SQInteger _noutervalues = 0;
134 SQInteger _ndefaultparams = 0;
135 SQInteger *_defaultparams =
nullptr;
137 SQInteger _ninstructions = 0;
141 #endif //_SQFUNCTION_H_
Definition: sqfuncproto.h:27
Definition: sqfuncproto.h:12
Definition: sqfuncproto.h:36
Definition: sqopcodes.h:109
Definition: sqobject.h:205
Definition: sqfuncproto.h:49
Definition: sqobject.h:313