00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef NL_OP_CODE_CALL_METHOD_H
00026 #define NL_OP_CODE_CALL_METHOD_H
00027
00028 namespace NLAISCRIPT
00029 {
00030 class IMethodContext
00031 {
00032 public:
00033 virtual void saveConstext(CCodeContext &context) = 0;
00034 virtual void loadConstext(CCodeContext &context) = 0;
00035
00036 virtual const IMethodContext *clone() const = 0;
00037 };
00038
00039
00040 class CMethodContext: public IMethodContext
00041 {
00042 public:
00043 virtual void saveConstext(CCodeContext &context);
00044 virtual void loadConstext(CCodeContext &context);
00045
00046 const IMethodContext *clone() const;
00047
00048 };
00049
00050 class CMethodContextDebug: public IMethodContext
00051 {
00052 public:
00053 virtual void saveConstext(CCodeContext &context);
00054 virtual void loadConstext(CCodeContext &context);
00055
00056 const IMethodContext *clone() const;
00057
00058 };
00059
00060 class ICallMethod: public IOpRunCode
00061 {
00062 private:
00063 IMethodContext *_MethodContext;
00064
00065 public:
00066 ICallMethod(const ICallMethod &c):_MethodContext((IMethodContext *)c._MethodContext->clone())
00067 {
00068 }
00069
00070 ICallMethod(IMethodContext *c):_MethodContext(c)
00071 {
00072 }
00073
00074 void saveConstext(CCodeContext &context)
00075 {
00076 _MethodContext->saveConstext(context);
00077 }
00078
00079 void loadConstext(CCodeContext &context)
00080 {
00081 _MethodContext->loadConstext(context);
00082 }
00083
00084 virtual ~ICallMethod()
00085 {
00086 delete _MethodContext;
00087 }
00088 };
00089
00090 class CCallMethod: public ICallMethod
00091 {
00092 public:
00093 static const NLAIC::CIdentType IdCallMethode;
00094
00095 private:
00096 sint32 _Inheritance;
00097 sint32 _I;
00098
00099 public:
00100
00101 CCallMethod(const CCallMethod &c):ICallMethod(c),_Inheritance(c._Inheritance),_I(c._I)
00102 {
00103 }
00104
00105 CCallMethod(IMethodContext *c,sint32 inheritance,sint32 i):ICallMethod(c),_Inheritance(inheritance),_I(i)
00106 {
00107 }
00108
00109 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00110
00111 void getDebugResult(std::string &str,CCodeContext &context) const;
00112
00113 const NLAIC::IBasicType *clone() const
00114 {
00115 NLAIC::IBasicType *x = new CCallMethod(*this);
00116 return x;
00117 }
00118 const NLAIC::IBasicType *newInstance() const
00119 {
00120 return clone();
00121 }
00122 const NLAIC::CIdentType &getType() const
00123 {
00124 return IdCallMethode;
00125 }
00126
00127
00128
00129 void save(NLMISC::IStream &os)
00130 {
00131 sint32 n = (sint32) _I;
00132 os.serial(n);
00133 n = (sint32) _Inheritance;
00134 os.serial(n);
00135 }
00136
00137 void load(NLMISC::IStream &is)
00138 {
00139 sint32 n;
00140 is.serial(n);
00141 _I = n;
00142 is.serial(n);
00143 _Inheritance = n;
00144 }
00145
00146
00147 virtual ~CCallMethod()
00148 {
00149 }
00150
00151 };
00152
00153 class CCallHeapMethodi: public ICallMethod
00154 {
00155 public:
00156 static const NLAIC::CIdentType IdCallHeapMethodei;
00157
00158 private:
00159 sint32 _Inheritance;
00160 sint32 _I;
00161 sint32 _HeapPos;
00162 std::list<sint32> _N;
00163
00164 public:
00165 CCallHeapMethodi(const CCallHeapMethodi &c):ICallMethod(c),_Inheritance(c._Inheritance),_I(c._I),_HeapPos(c._HeapPos),_N(c._N)
00166 {
00167 }
00168 CCallHeapMethodi(IMethodContext *c,sint32 inheritance,sint32 i,sint32 heapPos,const std::list<sint32> &l):
00169 ICallMethod(c),_Inheritance(inheritance),_I(i),_HeapPos(heapPos),_N(l)
00170 {
00171 }
00172
00173 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00174 void getDebugResult(std::string &str,CCodeContext &context) const;
00175
00176 const NLAIC::IBasicType *clone() const
00177 {
00178 NLAIC::IBasicType *x = new CCallHeapMethodi(*this);
00179 return x;
00180 }
00181 const NLAIC::IBasicType *newInstance() const
00182 {
00183 return clone();
00184 }
00185 const NLAIC::CIdentType &getType() const
00186 {
00187 return IdCallHeapMethodei;
00188 }
00189
00190 void save(NLMISC::IStream &os)
00191 {
00192 sint32 n = (sint32) _I;
00193 os.serial(n);
00194 n = (sint32) _Inheritance;
00195 os.serial(n);
00196 n = (sint32) _HeapPos;
00197 os.serial(n);
00198 std::list<sint32> &i = (std::list<sint32> &)_N;
00199 os.serialCont(i);
00200 }
00201
00202 void load(NLMISC::IStream &is)
00203 {
00204 sint32 n;
00205 is.serial(n);
00206 _I = n;
00207 is.serial(n);
00208 _Inheritance = n;
00209 is.serial(n);
00210 _HeapPos = n;
00211 is.serialCont(_N);
00212 }
00213
00214 virtual ~CCallHeapMethodi()
00215 {
00216 }
00217
00218 };
00219
00220
00221 class CCallStackMethodi: public ICallMethod
00222 {
00223 public:
00224 static const NLAIC::CIdentType IdCallStackMethodei;
00225
00226 protected:
00227 sint32 _Inheritance;
00228 sint32 _I;
00229 std::list<sint32> _N;
00230
00231 public:
00232 CCallStackMethodi(const CCallStackMethodi &c):ICallMethod(c),_Inheritance(c._Inheritance),_I(c._I),_N(c._N)
00233 {
00234 }
00235 CCallStackMethodi(IMethodContext *c,sint32 inheritance,sint32 i,const std::list<sint32> &l):ICallMethod(c),_Inheritance(inheritance),_I(i),_N(l)
00236 {
00237 }
00238
00239 virtual NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00240
00241 void getDebugResult(std::string &str,CCodeContext &context) const;
00242
00243 virtual const NLAIC::IBasicType *clone() const
00244 {
00245 NLAIC::IBasicType *x = new CCallStackMethodi(*this);
00246 return x;
00247 }
00248 const NLAIC::IBasicType *newInstance() const
00249 {
00250 return clone();
00251 }
00252 virtual const NLAIC::CIdentType &getType() const
00253 {
00254 return IdCallStackMethodei;
00255 }
00256
00257
00258 void save(NLMISC::IStream &os)
00259 {
00260 sint32 n = (sint32) _I;
00261 os.serial(n);
00262 n = (sint32) _Inheritance;
00263 os.serial(n);
00264 std::list<sint32> &i = (std::list<sint32> &)_N;
00265 os.serialCont(i);
00266 }
00267
00268 void load(NLMISC::IStream &is)
00269 {
00270 sint32 n;
00271 is.serial(n);
00272 _I = n;
00273 is.serial(n);
00274 _Inheritance = n;
00275 is.serialCont(_N);
00276 }
00277
00278 virtual ~CCallStackMethodi()
00279 {
00280 }
00281
00282 };
00283
00284 class CCallStackNewMethodi: public CCallStackMethodi
00285 {
00286 public:
00287 static const NLAIC::CIdentType IdCallStackNewMethodei;
00288
00289 public:
00290 CCallStackNewMethodi(const CCallStackNewMethodi &c):CCallStackMethodi(c)
00291 {
00292
00293 }
00294 CCallStackNewMethodi(IMethodContext *c,sint32 inheritance,sint32 i,const std::list<sint32> &l):CCallStackMethodi(c,inheritance,i,l)
00295 {
00296 }
00297
00298 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00299
00300 void getDebugResult(std::string &str,CCodeContext &context) const
00301 {
00302 NLAIAGENT::IObjectIA *obj = (NLAIAGENT::IObjectIA *)context.Stack[(int)context.Stack];
00303 std::list<sint32>::const_iterator it = _N.begin();
00304
00305 while(it != _N.end())
00306 {
00307 obj = (NLAIAGENT::IObjectIA *)obj->getStaticMember(*it++);
00308 }
00309
00310 str = NLAIC::stringGetBuild("CallMethod %d de la class '%s' dans le stack apres un new",_I, (const char *)obj->getType());
00311 }
00312
00313 const NLAIC::IBasicType *clone() const
00314 {
00315 NLAIC::IBasicType *x = new CCallStackNewMethodi(*this);
00316 return x;
00317 }
00318
00319 const NLAIC::CIdentType &getType() const
00320 {
00321 return IdCallStackNewMethodei;
00322 }
00323
00324 virtual ~CCallStackNewMethodi()
00325 {
00326 }
00327
00328 };
00329
00330
00331 class CCallMethodi: public ICallMethod
00332 {
00333 public:
00334 static const NLAIC::CIdentType IdCallMethodei;
00335
00336 private:
00337 sint32 _Inheritance;
00338 sint32 _I;
00339 std::list<sint32> _N;
00340
00341 public:
00342 CCallMethodi(const CCallMethodi &c):ICallMethod(c),_Inheritance(c._Inheritance),_I(c._I),_N(c._N)
00343 {
00344
00345 }
00346
00347 CCallMethodi(IMethodContext *c,sint32 inheritance,sint32 i,const std::list<sint32> &l):ICallMethod(c),_Inheritance(inheritance),_I(i),_N(l)
00348 {
00349 }
00350
00351 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00352
00353 void getDebugResult(std::string &str,CCodeContext &context) const;
00354
00355 const NLAIC::IBasicType *clone() const
00356 {
00357 NLAIC::IBasicType *x = new CCallMethodi(*this);
00358 return x;
00359 }
00360 const NLAIC::IBasicType *newInstance() const
00361 {
00362 return clone();
00363 }
00364 const NLAIC::CIdentType &getType() const
00365 {
00366 return IdCallMethodei;
00367 }
00368
00369
00370 void save(NLMISC::IStream &os)
00371 {
00372 sint32 n = (sint32) _I;
00373 os.serial(n);
00374 n = (sint32) _Inheritance;
00375 os.serial(n);
00376 std::list<sint32> &i = (std::list<sint32> &)_N;
00377 os.serialCont(i);
00378 }
00379
00380 void load(NLMISC::IStream &is)
00381 {
00382 sint32 n;
00383 is.serial(n);
00384 _I = n;
00385 is.serial(n);
00386 _Inheritance = n;
00387 is.serialCont(_N);
00388 }
00389
00390 virtual ~CCallMethodi()
00391 {
00392 }
00393
00394 };
00395 }
00396 #endif