00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef NL_OP_CODE_H
00027 #define NL_OP_CODE_H
00028
00029 #include <math.h>
00030 #include "nel/ai/logic/varset.h"
00031 #include "nel/ai/script/opcode_ldb.h"
00032 #include "nel/ai/script/opcode_lpt.h"
00033 #include "nel/ai/script/interpret_methodes.h"
00034 #include "nel/ai/script/constraint.h"
00035
00036 namespace NLAISCRIPT
00037 {
00048 class CLdbNewOpCode : public IOpRunCode
00049 {
00050 public:
00051 static const NLAIC::CIdentType IdLdbNewOpCode;
00052 private:
00053 NLAIAGENT::IObjectIA *_B;
00054 public:
00055 CLdbNewOpCode(const NLAIAGENT::IObjectIA &b): _B( (NLAIAGENT::IObjectIA *) b.clone() )
00056 {
00057 }
00058
00059 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
00060 {
00061 NLAIAGENT::IObjectIA *obj = (NLAIAGENT::IObjectIA *)_B->clone();
00062 NLAIAGENT::IBaseGroupType *param = (NLAIAGENT::IBaseGroupType *)context.Stack[(int)context.Stack];
00063 obj->init(param);
00064 param->release();
00065
00066 context.Stack[(int)context.Stack] = obj;
00067 return NLAIAGENT::IObjectIA::ProcessIdle;;
00068 }
00069
00070
00071 void getDebugResult(std::string &str,CCodeContext &context) const
00072 {
00073 std::string X;
00074 _B->getDebugString(X);
00075 str = "ldb ";
00076 str += X;
00077 }
00078
00079 const NLAIC::IBasicType *clone() const
00080 {
00081 NLAIC::IBasicType *x = new CLdbNewOpCode(*_B);
00082 return x;
00083 }
00084
00085 const NLAIC::IBasicType *newInstance() const
00086 {
00087 return clone();
00088 }
00089
00090 const NLAIC::CIdentType &getType() const
00091 {
00092 return IdLdbNewOpCode;
00093 }
00094
00095 void getDebugString(char *) const{ }
00096
00097 void save(NLMISC::IStream &os)
00098 {
00099 os.serial( (NLAIC::CIdentType &) (_B->getType()) );
00100 _B->save(os);
00101 }
00102
00103 void load(NLMISC::IStream &is)
00104 {
00105 _B->release();
00106 NLAIC::CIdentTypeAlloc id;
00107 is >> id;
00108 _B = (NLAIAGENT::IObjectIA *)id.allocClass();
00109 _B->load(is);
00110 }
00111 const NLAIAGENT::IObjectIA::CProcessResult &run(){return NLAIAGENT::IObjectIA::ProcessRun;;}
00112 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const{ return true;}
00113
00114 virtual ~CLdbNewOpCode()
00115 {
00116 _B->release();
00117 }
00118 };
00119
00121
00127
00138 class CNegOpCode: public IOpRunCode
00139 {
00140 public:
00141 static const NLAIC::CIdentType IdNegOpCode;
00142 private:
00143
00144 public:
00145
00146 CNegOpCode()
00147 {
00148 }
00149
00150 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00151
00152 void getDebugResult(std::string &str,CCodeContext &context) const;
00153
00154 const NLAIC::IBasicType *clone() const
00155 {
00156 NLAIC::IBasicType *x = new CNegOpCode();
00157 return x;
00158 }
00159 const NLAIC::IBasicType *newInstance() const
00160 {
00161 return clone();
00162 }
00163
00164 const NLAIC::CIdentType &getType() const
00165 {
00166 return IdNegOpCode;
00167 }
00168
00169
00170 void save(NLMISC::IStream &os)
00171 {
00172 }
00173
00174 void load(NLMISC::IStream &is)
00175 {
00176 }
00177
00178 virtual ~CNegOpCode()
00179 {
00180 }
00181 };
00182
00193 class CAddOpCode: public IOpRunCode
00194 {
00195 public:
00196 static const NLAIC::CIdentType IdAddOpCode;
00197 private:
00198
00199 public:
00200
00201 CAddOpCode()
00202 {
00203 }
00204
00205 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00206
00207 void getDebugResult(std::string &str,CCodeContext &context) const ;
00208
00209 const NLAIC::IBasicType *clone() const
00210 {
00211 NLAIC::IBasicType *x = new CAddOpCode();
00212 return x;
00213 }
00214 const NLAIC::IBasicType *newInstance() const
00215 {
00216 return clone();
00217 }
00218
00219 const NLAIC::CIdentType &getType() const
00220 {
00221 return IdAddOpCode;
00222 }
00223
00224
00225 void save(NLMISC::IStream &os)
00226 {
00227 }
00228
00229 void load(NLMISC::IStream &is)
00230 {
00231 }
00232
00233 virtual ~CAddOpCode()
00234 {
00235 }
00236 };
00237
00248 class CSubOpCode: public IOpRunCode
00249 {
00250 public:
00251 static const NLAIC::CIdentType IdSubOpCode;
00252 private:
00253
00254 public:
00255
00256 CSubOpCode()
00257 {
00258 }
00259
00260 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00261
00262 void getDebugResult(std::string &str,CCodeContext &context) const;
00263
00264 const NLAIC::IBasicType *clone() const
00265 {
00266 NLAIC::IBasicType *x = new CSubOpCode();
00267 return x;
00268 }
00269
00270 const NLAIC::IBasicType *newInstance() const
00271 {
00272 return clone();
00273 }
00274
00275 const NLAIC::CIdentType &getType() const
00276 {
00277 return IdSubOpCode;
00278 }
00279
00280
00281 void save(NLMISC::IStream &os)
00282 {
00283 }
00284
00285 void load(NLMISC::IStream &is)
00286 {
00287 }
00288
00289 virtual ~CSubOpCode()
00290 {
00291 }
00292 };
00293
00304 class CDivOpCode: public IOpRunCode
00305 {
00306 public:
00307 static const NLAIC::CIdentType IdDivOpCode;
00308 private:
00309
00310 public:
00311
00312 CDivOpCode()
00313 {
00314 }
00315
00316 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00317 void getDebugResult(std::string &str,CCodeContext &context) const;
00318
00319 const NLAIC::IBasicType *clone() const
00320 {
00321 NLAIC::IBasicType *x = new CDivOpCode();
00322 return x;
00323 }
00324
00325 const NLAIC::IBasicType *newInstance() const
00326 {
00327 return clone();
00328 }
00329
00330 const NLAIC::CIdentType &getType() const
00331 {
00332 return IdDivOpCode;
00333 }
00334
00335
00336 void save(NLMISC::IStream &os)
00337 {
00338 }
00339
00340 void load(NLMISC::IStream &is)
00341 {
00342 }
00343
00344 virtual ~CDivOpCode()
00345 {
00346 }
00347 };
00348
00359 class CMulOpCode: public IOpRunCode
00360 {
00361 public:
00362 static const NLAIC::CIdentType IdMulOpCode;
00363
00364 private:
00365
00366 public:
00367
00368 CMulOpCode()
00369 {
00370 }
00371
00372 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00373
00374 void getDebugResult(std::string &str,CCodeContext &context) const;
00375
00376 const NLAIC::IBasicType *clone() const
00377 {
00378 NLAIC::IBasicType *x = new CMulOpCode();
00379 return x;
00380 }
00381 const NLAIC::IBasicType *newInstance() const
00382 {
00383 return clone();
00384 }
00385
00386 const NLAIC::CIdentType &getType() const
00387 {
00388 return IdMulOpCode;
00389 }
00390
00391
00392 void save(NLMISC::IStream &os)
00393 {
00394 }
00395
00396 void load(NLMISC::IStream &is)
00397 {
00398 }
00399
00400 virtual ~CMulOpCode()
00401 {
00402 }
00403 };
00404
00405
00416 class CSupOpCode: public IOpRunCode
00417 {
00418 public:
00419 static const NLAIC::CIdentType IdSupOpCode;
00420 private:
00421
00422 public:
00423
00424 CSupOpCode()
00425 {
00426 }
00427
00428 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00429
00430 void getDebugResult(std::string &str,CCodeContext &context) const;
00431
00432 const NLAIC::IBasicType *clone() const
00433 {
00434 NLAIC::IBasicType *x = new CSupOpCode();
00435 return x;
00436 }
00437 const NLAIC::IBasicType *newInstance() const
00438 {
00439 return clone();
00440 }
00441
00442 const NLAIC::CIdentType &getType() const
00443 {
00444 return IdSupOpCode;
00445 }
00446
00447
00448 void save(NLMISC::IStream &os)
00449 {
00450 }
00451
00452 void load(NLMISC::IStream &is)
00453 {
00454 }
00455
00456 virtual ~CSupOpCode()
00457 {
00458 }
00459 };
00460
00471 class CInfOpCode: public IOpRunCode
00472 {
00473 public:
00474 static const NLAIC::CIdentType IdInfOpCode;
00475
00476 private:
00477
00478 public:
00479
00480 CInfOpCode()
00481 {
00482 }
00483
00484 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00485
00486 void getDebugResult(std::string &str,CCodeContext &context) const;
00487
00488 const NLAIC::IBasicType *clone() const
00489 {
00490 NLAIC::IBasicType *x = new CInfOpCode();
00491 return x;
00492 }
00493 const NLAIC::IBasicType *newInstance() const
00494 {
00495 return clone();
00496 }
00497
00498 const NLAIC::CIdentType &getType() const
00499 {
00500 return IdInfOpCode;
00501 }
00502
00503
00504 void save(NLMISC::IStream &os)
00505 {
00506 }
00507
00508 void load(NLMISC::IStream &is)
00509 {
00510 }
00511
00512 virtual ~CInfOpCode()
00513 {
00514 }
00515 };
00516
00527 class CEqOpCode: public IOpRunCode
00528 {
00529 public:
00530 static const NLAIC::CIdentType IdEqOpCode;
00531 private:
00532
00533 public:
00534
00535 CEqOpCode()
00536 {
00537 }
00538
00539 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00540
00541 void getDebugResult(std::string &str,CCodeContext &context) const;
00542
00543 const NLAIC::IBasicType *clone() const
00544 {
00545 NLAIC::IBasicType *x = new CEqOpCode();
00546 return x;
00547 }
00548
00549 const NLAIC::IBasicType *newInstance() const
00550 {
00551 return clone();
00552 }
00553
00554 const NLAIC::CIdentType &getType() const
00555 {
00556 return IdEqOpCode;
00557 }
00558
00559
00560 void save(NLMISC::IStream &os)
00561 {
00562 }
00563
00564 void load(NLMISC::IStream &is)
00565 {
00566 }
00567
00568 virtual ~CEqOpCode()
00569 {
00570 }
00571 };
00572
00583 class CSupEqOpCode: public IOpRunCode
00584 {
00585 public:
00586 static const NLAIC::CIdentType IdSupEqOpCode;
00587 private:
00588
00589 public:
00590
00591 CSupEqOpCode()
00592 {
00593 }
00594
00595 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00596 void getDebugResult(std::string &str,CCodeContext &context) const;
00597
00598 const NLAIC::IBasicType *clone() const
00599 {
00600 NLAIC::IBasicType *x = new CSupEqOpCode();
00601 return x;
00602 }
00603 const NLAIC::IBasicType *newInstance() const
00604 {
00605 return clone();
00606 }
00607
00608 const NLAIC::CIdentType &getType() const
00609 {
00610 return IdSupEqOpCode;
00611 }
00612
00613
00614 void save(NLMISC::IStream &os)
00615 {
00616 }
00617
00618 void load(NLMISC::IStream &is)
00619 {
00620 }
00621
00622
00623 virtual ~CSupEqOpCode()
00624 {
00625 }
00626 };
00627
00638 class CInfEqOpCode: public IOpRunCode
00639 {
00640 public:
00641 static const NLAIC::CIdentType IdInfEqOpCode;
00642 private:
00643
00644 public:
00645 CInfEqOpCode()
00646 {
00647 }
00648
00649 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00650
00651 void getDebugResult(std::string &str,CCodeContext &context) const;
00652
00653 const NLAIC::IBasicType *clone() const
00654 {
00655 NLAIC::IBasicType *x = new CInfEqOpCode();
00656 return x;
00657 }
00658
00659 const NLAIC::IBasicType *newInstance() const
00660 {
00661 return clone();
00662 }
00663
00664 const NLAIC::CIdentType &getType() const
00665 {
00666 return IdInfEqOpCode;
00667 }
00668
00669
00670 void save(NLMISC::IStream &os)
00671 {
00672 }
00673
00674 void load(NLMISC::IStream &is)
00675 {
00676 }
00677
00678
00679 virtual ~CInfEqOpCode()
00680 {
00681 }
00682 };
00683
00694 class CDiffOpCode: public IOpRunCode
00695 {
00696 public:
00697 static const NLAIC::CIdentType IdDiffOpCode;
00698 private:
00699
00700 public:
00701 CDiffOpCode()
00702 {
00703 }
00704
00705 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00706
00707 void getDebugResult(std::string &str,CCodeContext &context) const;
00708
00709 const NLAIC::IBasicType *clone() const
00710 {
00711 NLAIC::IBasicType *x = new CDiffOpCode();
00712 return x;
00713 }
00714 const NLAIC::IBasicType *newInstance() const
00715 {
00716 return clone();
00717 }
00718
00719 const NLAIC::CIdentType &getType() const
00720 {
00721 return IdDiffOpCode;
00722 }
00723
00724 void getDebugString(char *) const{ }
00725
00726 void save(NLMISC::IStream &os)
00727 {
00728 }
00729
00730 void load(NLMISC::IStream &is)
00731 {
00732 }
00733
00734 virtual ~CDiffOpCode()
00735 {
00736 }
00737 };
00738
00749 class CNotOpCode: public IOpRunCode
00750 {
00751 public:
00752 static const NLAIC::CIdentType IdNotOpCode;
00753
00754 private:
00755
00756 public:
00757 CNotOpCode()
00758 {
00759 }
00760
00761 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
00762
00763 void getDebugResult(std::string &str,CCodeContext &context) const;
00764
00765 const NLAIC::IBasicType *clone() const
00766 {
00767 NLAIC::IBasicType *x = new CNotOpCode();
00768 return x;
00769 }
00770 const NLAIC::IBasicType *newInstance() const
00771 {
00772 return clone();
00773 }
00774
00775 const NLAIC::CIdentType &getType() const
00776 {
00777 return IdNotOpCode;
00778 }
00779
00780 void getDebugString(char *) const{ }
00781
00782 void save(NLMISC::IStream &os)
00783 {
00784 }
00785
00786 void load(NLMISC::IStream &is)
00787 {
00788 }
00789
00790
00791 virtual ~CNotOpCode()
00792 {
00793 }
00794 };
00795
00797
00808 class CJFalseOpCode: public IOpRunCode
00809 {
00810 public:
00811 static const NLAIC::CIdentType IdJFalseOpCode;
00812 private:
00813 int _N;
00814 public:
00815 CJFalseOpCode(int l):
00816 _N(l)
00817 {
00818 }
00819
00820 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
00821 {
00822 NLAIAGENT::IObjetOp *op = !*((NLAIAGENT::IObjetOp *)((NLAIAGENT::IObjectIA *)context.Stack));
00823 if(op->isTrue()) *context.Code += _N;
00824 op->release();
00825 context.Stack--;
00826 return NLAIAGENT::IObjectIA::ProcessIdle;
00827 }
00828
00829 void getDebugResult(std::string &str,CCodeContext &context) const
00830 {
00831 std::string X;
00832 context.Stack[(int)context.Stack]->getDebugString(X);
00833 str = NLAIC::stringGetBuild("if !(%s) is false then goto %d",X.c_str(),_N);
00834 }
00835 const NLAIC::IBasicType *clone() const
00836 {
00837 NLAIC::IBasicType *x = new CJFalseOpCode(_N);
00838 return x;
00839 }
00840 const NLAIC::IBasicType *newInstance() const
00841 {
00842 return clone();
00843 }
00844 const NLAIC::CIdentType &getType() const
00845 {
00846 return IdJFalseOpCode;
00847 }
00848
00849 void save(NLMISC::IStream &os)
00850 {
00851 sint32 n = (sint32) _N;
00852 os.serial( n );
00853 }
00854
00855 void load(NLMISC::IStream &is)
00856 {
00857 sint32 n;
00858 is.serial( n );
00859 _N = (int) n;
00860 }
00861
00862 virtual ~CJFalseOpCode()
00863 {
00864 }
00865 };
00866
00876 class CJmpOpCode: public IOpRunCode
00877 {
00878 public:
00879 static const NLAIC::CIdentType IdJmpOpCode;
00880 private:
00881 int _N;
00882 public:
00883 CJmpOpCode(int l):
00884 _N(l)
00885 {
00886 }
00887
00888
00889 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
00890 {
00891 *context.Code += _N;
00892 return NLAIAGENT::IObjectIA::ProcessIdle;;
00893 }
00894
00895 void getDebugResult(std::string &str,CCodeContext &context) const
00896 {
00897 str = NLAIC::stringGetBuild("goto %d",_N);
00898 }
00899 const NLAIC::IBasicType *clone() const
00900 {
00901 NLAIC::IBasicType *x = new CJmpOpCode(_N);
00902 return x;
00903 }
00904 const NLAIC::IBasicType *newInstance() const
00905 {
00906 return clone();
00907 }
00908 const NLAIC::CIdentType &getType() const
00909 {
00910 return IdJmpOpCode;
00911 }
00912
00913 void save(NLMISC::IStream &os)
00914 {
00915 sint32 n = (sint32) _N;
00916 os.serial( n );
00917 }
00918
00919 void load(NLMISC::IStream &is)
00920 {
00921 sint32 n;
00922 is.serial( n );
00923 _N = (int) n;
00924 }
00925
00926 virtual ~CJmpOpCode()
00927 {
00928 }
00929 };
00930
00931
00933
00934
00946 class CAffOpCode: public IOpRunCode
00947 {
00948 public:
00949 static const NLAIC::CIdentType IdAffOpCode;
00950
00951 private:
00953 int _I;
00954 public:
00955 CAffOpCode(int i):
00956 _I(i)
00957 {
00958
00959 }
00960
00961 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
00962 {
00963 NLAIAGENT::IObjectIA *i = (NLAIAGENT::IObjectIA *)context.Stack;
00964 i->incRef();
00965 NLAIAGENT::IObjectIA *tmp = context.Heap[(int)_I];
00966 context.Heap[_I] = i;
00967 if(tmp) tmp->release();
00968 context.Stack --;
00969 return NLAIAGENT::IObjectIA::ProcessIdle;;
00970 }
00971
00972 void getDebugResult(std::string &str,CCodeContext &context) const
00973 {
00974 std::string Y;
00975 context.Stack[(int)context.Stack]->getDebugString(Y);
00976 str = NLAIC::stringGetBuild("Affectation<%d> a %s",_I,Y.c_str());
00977 }
00978
00979 const NLAIC::IBasicType *clone() const
00980 {
00981 NLAIC::IBasicType *x = new CAffOpCode(_I);
00982 return x;
00983 }
00984 const NLAIC::IBasicType *newInstance() const
00985 {
00986 return clone();
00987 }
00988
00989 const NLAIC::CIdentType &getType() const
00990 {
00991 return IdAffOpCode;
00992 }
00993
00994 void getDebugString(char *) const{ }
00995
00996 void save(NLMISC::IStream &os)
00997 {
00998 sint32 i = (sint32) _I;
00999 os.serial( i );
01000 }
01001
01002 void load(NLMISC::IStream &is)
01003 {
01004 sint32 i;
01005 is.serial( i );
01006 _I = (int) i;
01007 }
01008
01009
01010 virtual ~CAffOpCode()
01011 {
01012 }
01013 };
01014
01016 class CAffOpCodeDebug : public IOpRunCode
01017 {
01018 public:
01019 static const NLAIC::CIdentType IdAffOpCodeDebug;
01020
01021 private:
01022 int _I;
01023 char * _VarName;
01024
01025 public:
01026 CAffOpCodeDebug(int i, const char* varName);
01027
01028 virtual ~CAffOpCodeDebug();
01029
01030 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01031
01032 void getDebugResult(std::string &str,CCodeContext &context) const;
01033
01034 const NLAIC::IBasicType *clone() const;
01035
01036 const NLAIC::IBasicType *newInstance() const;
01037
01038 const NLAIC::CIdentType &getType() const;
01039
01040 void getDebugString(char *) const;
01041
01042 void save(NLMISC::IStream &os);
01043
01044 void load(NLMISC::IStream &is);
01045 };
01046
01058 class CAffHeapMemberiOpCode: public IOpRunCode
01059 {
01060 public:
01061 static const NLAIC::CIdentType IdAffHeapMemberiOpCode;
01062 private:
01063 std::list<sint32> _I;
01064 sint32 _N;
01065 public:
01066 CAffHeapMemberiOpCode(std::list<sint32> i,sint32 n):
01067 _I(i),_N(n)
01068 {
01069
01070 }
01071
01072 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01073
01074 void getDebugResult(std::string &str,CCodeContext &context) const;
01075
01076 const NLAIC::IBasicType *clone() const
01077 {
01078 NLAIC::IBasicType *x = new CAffHeapMemberiOpCode(_I,_N);
01079 return x;
01080 }
01081 const NLAIC::IBasicType *newInstance() const
01082 {
01083 return clone();
01084 }
01085
01086 const NLAIC::CIdentType &getType() const
01087 {
01088 return IdAffHeapMemberiOpCode;
01089 }
01090
01091
01092 void save(NLMISC::IStream &os)
01093 {
01094 sint32 n = (sint32) _N;
01095 os.serial( n );
01096 std::list<sint32> &i = (std::list<sint32> &)_I;
01097 os.serialCont(i);
01098 }
01099
01100 void load(NLMISC::IStream &is)
01101 {
01102 sint32 n;
01103 is.serial(n);
01104 _N = n;
01105 is.serialCont(_I);
01106 }
01107
01108 virtual ~CAffHeapMemberiOpCode()
01109 {
01110 }
01111 };
01112
01123 class CAffMemberiOpCode: public IOpRunCode
01124 {
01125 public:
01126 static const NLAIC::CIdentType IdAffMemberiOpCode;
01127 private:
01128 std::list<sint32> _I;
01129 public:
01130 CAffMemberiOpCode(std::list<sint32> i):
01131 _I(i)
01132 {
01133
01134 }
01135
01136 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01137
01138 void getDebugResult(std::string &str,CCodeContext &context) const
01139 {
01140
01141 str = "Affectation du membre";
01142 }
01143
01144 const NLAIC::IBasicType *clone() const
01145 {
01146 NLAIC::IBasicType *x = new CAffMemberiOpCode(_I);
01147 return x;
01148 }
01149 const NLAIC::IBasicType *newInstance() const
01150 {
01151 return clone();
01152 }
01153
01154 const NLAIC::CIdentType &getType() const
01155 {
01156 return IdAffMemberiOpCode;
01157 }
01158
01159
01160 void save(NLMISC::IStream &os)
01161 {
01162 std::list<sint32> &i = (std::list<sint32> &)_I;
01163 os.serialCont(i);
01164 }
01165
01166 void load(NLMISC::IStream &is)
01167 {
01168 is.serialCont( _I );
01169 }
01170
01171
01172 virtual ~CAffMemberiOpCode()
01173 {
01174 }
01175 };
01176
01187 class CAffMemberOpCode: public IOpRunCode
01188 {
01189 public:
01190 static const NLAIC::CIdentType IdAffMemberOpCode;
01191
01192 private:
01193 int _I;
01194 public:
01195 CAffMemberOpCode(int i):
01196 _I(i)
01197 {
01198
01199 }
01200
01201 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01202
01203 void getDebugResult(std::string &str,CCodeContext &context) const
01204 {
01205 str = NLAIC::stringGetBuild("Affectation du membre %d",_I);
01206 }
01207
01208 const NLAIC::IBasicType *clone() const
01209 {
01210 NLAIC::IBasicType *x = new CAffMemberOpCode(_I);
01211 return x;
01212 }
01213 const NLAIC::IBasicType *newInstance() const
01214 {
01215 return clone();
01216 }
01217
01218 const NLAIC::CIdentType &getType() const
01219 {
01220 return IdAffMemberOpCode;
01221 }
01222
01223
01224 void save(NLMISC::IStream &os)
01225 {
01226 sint32 i = (sint32) _I;
01227 os.serial( i );
01228 }
01229
01230 void load(NLMISC::IStream &is)
01231 {
01232 sint32 i;
01233 is.serial( i );
01234 _I = (int) i;
01235 }
01236
01237
01238 virtual ~CAffMemberOpCode()
01239 {
01240 }
01241 };
01242
01244
01246 class CLocAlloc: public IOpRunCode
01247 {
01248 public:
01249 static const NLAIC::CIdentType IdLocAlloc;
01250 public:
01251
01252 CLocAlloc()
01253 {
01254
01255 }
01256
01257
01258 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01259 {
01260
01261
01262 context.Heap ++;
01263 return NLAIAGENT::IObjectIA::ProcessIdle;;
01264 }
01265
01266 void getDebugResult(std::string &str,CCodeContext &context) const
01267 {
01268 str = NLAIC::stringGetBuild("Reservation d'un espace memoir locale pour une variable à l'emplacement %d",(int)context.Heap);
01269 }
01270
01271 const NLAIC::IBasicType *clone() const
01272 {
01273 NLAIC::IBasicType *x = new CLocAlloc();
01274 return x;
01275 }
01276 const NLAIC::IBasicType *newInstance() const
01277 {
01278 return clone();
01279 }
01280
01281 const NLAIC::CIdentType &getType() const
01282 {
01283 return IdLocAlloc;
01284 }
01285
01286 void save(NLMISC::IStream &os)
01287 {
01288 }
01289
01290 void load(NLMISC::IStream &is)
01291 {
01292 }
01293
01294
01295 virtual ~CLocAlloc()
01296 {
01297 }
01298 };
01299
01301 class CLocAllocDebug: public IOpRunCode
01302 {
01303 public:
01304 static const NLAIC::CIdentType IdLocAllocDebug;
01305
01306 public:
01307
01308 CLocAllocDebug();
01309
01310 virtual ~CLocAllocDebug();
01311
01312 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01313
01314 void getDebugResult(std::string &str,CCodeContext &context) const;
01315
01316 const NLAIC::IBasicType *clone() const;
01317
01318 const NLAIC::IBasicType *newInstance() const ;
01319
01320 const NLAIC::CIdentType &getType() const;
01321
01322 void save(NLMISC::IStream &os);
01323
01324 void load(NLMISC::IStream &is);
01325
01326 };
01327
01329 class CMarkAlloc: public IOpRunCode
01330 {
01331 public:
01332 static const NLAIC::CIdentType IdMarkAlloc;
01333 public:
01334 CMarkAlloc()
01335 {
01336 }
01337
01338 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01339 {
01340 context.Heap.pushMark();
01341 return NLAIAGENT::IObjectIA::ProcessIdle;;
01342 }
01343 void getDebugResult(std::string &str,CCodeContext &context) const
01344 {
01345 str = NLAIC::stringGetBuild("Marque le bloc de memoire a %d",(int)context.Heap);
01346 }
01347
01348 const NLAIC::IBasicType *clone() const
01349 {
01350 NLAIC::IBasicType *x = new CMarkAlloc();
01351 return x;
01352 }
01353 const NLAIC::IBasicType *newInstance() const
01354 {
01355 return clone();
01356 }
01357
01358 const NLAIC::CIdentType &getType() const
01359 {
01360 return IdMarkAlloc;
01361 }
01362
01363
01364 void save(NLMISC::IStream &os)
01365 {
01366 }
01367
01368 void load(NLMISC::IStream &is)
01369 {
01370 }
01371
01372 virtual ~CMarkAlloc()
01373 {
01374 }
01375 };
01376
01378 class CFreeAlloc: public IOpRunCode
01379 {
01380 public:
01381 static const NLAIC::CIdentType IdFreeAlloc;
01382 public:
01383
01384 CFreeAlloc()
01385 {
01386 }
01387
01388 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01389 {
01390 int i = (int)context.Heap;
01391 i -= context.Heap.popMark();
01392 context.Heap -= i;
01393 return NLAIAGENT::IObjectIA::ProcessIdle;;
01394 }
01395 void getDebugResult(std::string &str,CCodeContext &context) const
01396 {
01397 str = NLAIC::stringGetBuild("libere le bloc de memoire de %d Ó %d",(int)context.Heap.mark(),(int)context.Heap);
01398 }
01399
01400 const NLAIC::IBasicType *clone() const
01401 {
01402 NLAIC::IBasicType *x = new CFreeAlloc();
01403 return x;
01404 }
01405 const NLAIC::IBasicType *newInstance() const
01406 {
01407 return clone();
01408 }
01409
01410 const NLAIC::CIdentType &getType() const
01411 {
01412 return IdFreeAlloc;
01413 }
01414
01415
01416
01417 void save(NLMISC::IStream &os)
01418 {
01419 }
01420
01421 void load(NLMISC::IStream &is)
01422 {
01423 }
01424
01425 virtual ~CFreeAlloc()
01426 {
01427 }
01428 };
01429
01431 class CFreeAllocDebug: public IOpRunCode
01432 {
01433 public:
01434 static const NLAIC::CIdentType IdFreeAllocDebug;
01435 public:
01436
01437 CFreeAllocDebug();
01438
01439 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01440
01441 virtual ~CFreeAllocDebug();
01442
01443 void getDebugResult(std::string &str,CCodeContext &context) const;
01444
01445 const NLAIC::IBasicType *clone() const;
01446
01447 const NLAIC::IBasicType *newInstance() const;
01448
01449 const NLAIC::CIdentType &getType() const;
01450
01451 void save(NLMISC::IStream &os);
01452
01453 void load(NLMISC::IStream &is);
01454 };
01455
01457 class CHaltOpCode: public IOpRunCode
01458 {
01459 public:
01460 static const NLAIC::CIdentType IdHaltOpCode;
01461 public:
01462 CHaltOpCode()
01463 {
01464 }
01465
01466 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01467 {
01468 return NLAIAGENT::IObjectIA::ProcessEnd;
01469 }
01470 void getDebugResult(std::string &str,CCodeContext &context) const
01471 {
01472 str = "Stop";
01473 }
01474
01475 const NLAIC::IBasicType *clone() const
01476 {
01477 NLAIC::IBasicType *x = new CHaltOpCode();
01478 return x;
01479 }
01480 const NLAIC::IBasicType *newInstance() const
01481 {
01482 return clone();
01483 }
01484 const NLAIC::CIdentType &getType() const
01485 {
01486 return IdHaltOpCode;
01487 }
01488
01489
01490
01491 void save(NLMISC::IStream &os)
01492 {
01493 }
01494
01495 void load(NLMISC::IStream &is)
01496 {
01497 }
01498
01499
01500 virtual ~CHaltOpCode()
01501 {
01502 }
01503 };
01504
01505
01507 class CNopOpCode: public IOpRunCode
01508 {
01509 public:
01510 static const NLAIC::CIdentType IdNopOpCode;
01511 public:
01512 CNopOpCode()
01513 {
01514 }
01515
01516 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01517 {
01518 return NLAIAGENT::IObjectIA::ProcessIdle;
01519 }
01520
01521 void getDebugResult(std::string &str,CCodeContext &context) const
01522 {
01523 str = "No operation";
01524 }
01525
01526 const NLAIC::IBasicType *clone() const
01527 {
01528 NLAIC::IBasicType *x = new CNopOpCode();
01529 return x;
01530 }
01531 const NLAIC::IBasicType *newInstance() const
01532 {
01533 return clone();
01534 }
01535 const NLAIC::CIdentType &getType() const
01536 {
01537 return IdNopOpCode;
01538 }
01539
01540
01541
01542 void save(NLMISC::IStream &os)
01543 {
01544 }
01545
01546 void load(NLMISC::IStream &is)
01547 {
01548 }
01549
01550
01551 virtual ~CNopOpCode()
01552 {
01553 }
01554 };
01555
01556 class CTellOpCode : public IOpRunCode
01557 {
01558 public:
01559 static const NLAIC::CIdentType IdTellOpCode;
01560 public:
01561 CTellOpCode()
01562 {
01563 }
01564
01565 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01566 {
01567 std::string f;
01568 context.Stack[(int)context.Stack]->getDebugString(f);
01569 ( (NLAILOGIC::CFactPattern *) context.Stack[(int)context.Stack] )->propagate();
01570 return NLAIAGENT::IObjectIA::ProcessIdle;
01571 }
01572
01573 void getDebugResult(std::string &str,CCodeContext &context) const
01574 {
01575 std::string f;
01576 context.Stack[(int)context.Stack]->getDebugString(f);
01577 str = NLAIC::stringGetBuild("tell %s",f.c_str());
01578 }
01579
01580 const NLAIC::IBasicType *clone() const
01581 {
01582 NLAIC::IBasicType *x = new CTellOpCode();
01583 return x;
01584 }
01585
01586 const NLAIC::IBasicType *newInstance() const
01587 {
01588 return clone();
01589 }
01590
01591 const NLAIC::CIdentType &getType() const
01592 {
01593 return IdTellOpCode;
01594 }
01595
01596 void getDebugString(std::string &str) const
01597 {
01598 str = "tell";
01599 }
01600
01601 void save(NLMISC::IStream &os)
01602 {
01603 }
01604
01605 void load(NLMISC::IStream &is)
01606 {
01607 }
01608
01609 virtual ~CTellOpCode()
01610 {
01611 }
01612 };
01613
01615 class CMakeArgOpCode : public IOpRunCode
01616 {
01617 public:
01618 static const NLAIC::CIdentType IdMakeArgOpCode;
01619 public:
01620
01621 CMakeArgOpCode()
01622 {
01623 }
01624
01625 virtual ~CMakeArgOpCode()
01626 {
01627 }
01628
01629 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context)
01630 {
01631 NLAIAGENT::IObjectIA *param = context.Stack[(int)context.Stack];
01632 NLAIAGENT::IBaseGroupType *arglist = new NLAIAGENT::CGroupType;
01633 arglist->cpy(*param);
01634 param->release();
01635 context.Stack[(int)context.Stack] = arglist;
01636 return NLAIAGENT::IObjectIA::ProcessIdle;;
01637 }
01638
01639 void getDebugResult(std::string &str,CCodeContext &context) const
01640 {
01641 std::string buf;
01642 NLAIAGENT::IObjectIA *param = context.Stack[(int)context.Stack];
01643 param->getDebugString(buf);
01644 str = NLAIC::stringGetBuild("ldb %s -> [%s]", buf.c_str(), buf.c_str());
01645 }
01646
01647 const NLAIC::IBasicType *clone() const
01648 {
01649 NLAIC::IBasicType *clone = new CMakeArgOpCode();
01650 return clone;
01651 }
01652
01653 const NLAIC::IBasicType *newInstance() const
01654 {
01655 return clone();
01656 }
01657
01658 const NLAIC::CIdentType &getType() const
01659 {
01660 return IdMakeArgOpCode;
01661 }
01662
01663 void getDebugString(char *txt) const
01664 {
01665 strcpy(txt, "CMakeArgOpCode");
01666 }
01667
01668 void save(NLMISC::IStream &os)
01669 {
01670 }
01671
01672 void load(NLMISC::IStream &is)
01673 {
01674 }
01675
01676 const NLAIAGENT::IObjectIA::CProcessResult &run()
01677 {
01678 return NLAIAGENT::IObjectIA::ProcessRun;
01679 }
01680
01681 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
01682 {
01683 return true;
01684 }
01685
01686 };
01687
01688 class CMarkMsg : public IOpRunCode
01689 {
01690 public:
01691 static const NLAIC::CIdentType IdMarkMsg;
01692
01693 private:
01694 int _I;
01695 int _Heritance;
01696
01697 public:
01698
01699 CMarkMsg(int h,int i):_I(i),_Heritance(h)
01700 {
01701 }
01702
01703 virtual ~CMarkMsg()
01704 {
01705 }
01706
01707 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01708
01709 void getDebugResult(std::string &str,CCodeContext &context) const
01710 {
01711 str = NLAIC::stringGetBuild("MarkMsg for method %d in heritance %d", _I, _Heritance);
01712 }
01713
01714 const NLAIC::IBasicType *clone() const
01715 {
01716 NLAIC::IBasicType *clone = new CMarkMsg(_Heritance,_I);
01717 return clone;
01718 }
01719
01720 const NLAIC::IBasicType *newInstance() const
01721 {
01722 return clone();
01723 }
01724
01725 const NLAIC::CIdentType &getType() const
01726 {
01727 return IdMarkMsg;
01728 }
01729
01730 void getDebugString(char *txt) const
01731 {
01732 strcpy(txt, "CMakeArgOpCode");
01733 }
01734
01735 void save(NLMISC::IStream &os)
01736 {
01737 sint32 i = (sint32) _I;
01738 os.serial( i );
01739 i = (sint32) _Heritance;
01740 os.serial( i );
01741 }
01742
01743 void load(NLMISC::IStream &is)
01744 {
01745 sint32 i;
01746 is.serial( i );
01747 _I = i;
01748 is.serial( i );
01749 _Heritance = (int) i;
01750 }
01751
01752 const NLAIAGENT::IObjectIA::CProcessResult &run()
01753 {
01754 return NLAIAGENT::IObjectIA::ProcessRun;
01755 }
01756
01757 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
01758 {
01759 return true;
01760 }
01761
01762 };
01763
01764 class ILoadObject;
01765
01766 class CMsgSetSender : public IOpRunCode
01767 {
01768 public:
01769 static const NLAIC::CIdentType IdMsgSetSender;
01770
01771
01772 public:
01773
01774
01775 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01776 void getDebugResult(std::string &str,CCodeContext &context) const;
01777
01778 const NLAIC::IBasicType *clone() const
01779 {
01780 return new CMsgSetSender();
01781 }
01782
01783 const NLAIC::IBasicType *newInstance() const
01784 {
01785 return clone();
01786 }
01787
01788 const NLAIC::CIdentType &getType() const
01789 {
01790 return IdMsgSetSender;
01791 }
01792
01793 void getDebugString(char *txt) const
01794 {
01795 }
01796
01797 void save(NLMISC::IStream &os);
01798
01799 void load(NLMISC::IStream &is);
01800
01801 const NLAIAGENT::IObjectIA::CProcessResult &run()
01802 {
01803 return NLAIAGENT::IObjectIA::ProcessRun;
01804 }
01805
01806 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
01807 {
01808 return true;
01809 }
01810
01811 };
01812
01813 class CFindRunMsg : public IOpRunCode
01814 {
01815 public:
01816 static const NLAIC::CIdentType IdFindRunMsg;
01817
01818 private:
01819 CParam *_Param;
01820 NLAIAGENT::IBaseGroupType *_MethodName;
01821 IOpType *_BaseClass;
01822 ILoadObject *_ObjectLoad;
01823
01824 public:
01825
01826 CFindRunMsg(NLAIAGENT::IBaseGroupType *methodName,CParam *param,IOpType *baseClass,ILoadObject *objectLoad);
01827
01828 CFindRunMsg(const NLAIAGENT::IBaseGroupType &methodName,const CParam ¶m,const IOpType &baseClass,const ILoadObject &objectLoad);
01829
01830 virtual ~CFindRunMsg();
01831
01832 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01833 void getDebugResult(std::string &str,CCodeContext &context) const;
01834
01835 const NLAIC::IBasicType *clone() const;
01836
01837 const NLAIC::IBasicType *newInstance() const
01838 {
01839 return clone();
01840 }
01841
01842 const NLAIC::CIdentType &getType() const
01843 {
01844 return IdFindRunMsg;
01845 }
01846
01847 void getDebugString(char *txt) const
01848 {
01849 }
01850
01851 void save(NLMISC::IStream &os);
01852
01853 void load(NLMISC::IStream &is);
01854
01855 const NLAIAGENT::IObjectIA::CProcessResult &run()
01856 {
01857 return NLAIAGENT::IObjectIA::ProcessRun;
01858 }
01859
01860 bool isEqual(const NLAIAGENT::IBasicObjectIA &a) const
01861 {
01862 return true;
01863 }
01864
01865 };
01866
01868 class CAddParamNameDebug: public IOpRunCode
01869 {
01870 private :
01871 NLAIAGENT::IBaseGroupType* _DebugAttrib;
01872
01873 public:
01874 static const NLAIC::CIdentType IdAddParamNameDebug;
01875 public:
01876
01877 CAddParamNameDebug(const NLAIAGENT::IBaseGroupType &debugAttrib);
01878
01879 NLAIAGENT::TProcessStatement runOpCode(CCodeContext &context);
01880
01881 virtual ~CAddParamNameDebug();
01882
01883 void getDebugResult(std::string &str,CCodeContext &context) const;
01884
01885 const NLAIC::IBasicType *clone() const;
01886
01887 const NLAIC::IBasicType *newInstance() const;
01888
01889 const NLAIC::CIdentType &getType() const;
01890
01891 void save(NLMISC::IStream &os);
01892
01893 void load(NLMISC::IStream &is);
01894 };
01895 }
01896
01897 #include "nel/ai/script/opcode_call_method.h"
01898 #include "nel/ai/script/opcode_call_lib_method.h"
01899 #endif
01900