From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../constraint__stack__component_8cpp-source.html | 261 +++++++++++++++++++++ 1 file changed, 261 insertions(+) create mode 100644 docs/doxygen/nel/constraint__stack__component_8cpp-source.html (limited to 'docs/doxygen/nel/constraint__stack__component_8cpp-source.html') diff --git a/docs/doxygen/nel/constraint__stack__component_8cpp-source.html b/docs/doxygen/nel/constraint__stack__component_8cpp-source.html new file mode 100644 index 00000000..70d02a41 --- /dev/null +++ b/docs/doxygen/nel/constraint__stack__component_8cpp-source.html @@ -0,0 +1,261 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

constraint_stack_component.cpp

Go to the documentation of this file.
00001 
+00006 /* Copyright, 2000 Nevrax Ltd.
+00007  *
+00008  * This file is part of NEVRAX NEL.
+00009  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00010  * it under the terms of the GNU General Public License as published by
+00011  * the Free Software Foundation; either version 2, or (at your option)
+00012  * any later version.
+00013 
+00014  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00015  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00017  * General Public License for more details.
+00018 
+00019  * You should have received a copy of the GNU General Public License
+00020  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00022  * MA 02111-1307, USA.
+00023  */
+00024 #include "nel/ai/script/compilateur.h"
+00025 #include "nel/ai/script/constraint.h"
+00026 #include "nel/ai/script/type_def.h"
+00027 #include "nel/ai/script/constraint_stack_component.h"
+00028 
+00029 namespace NLAISCRIPT
+00030 {
+00031 
+00032         CConstraintStackComp::CConstraintStackComp(OpCodeType opCodeType,sint32 stackPos,const std::list<NLAISCRIPT::CStringType > &memberName,IOpType *typeStack,sint32 lign,sint32 col):
+00033         _TypeStack(typeStack),_MemberName(memberName),_Lin(lign),_Col(col)
+00034         {               
+00035                 char m[1028*8];
+00036                 std::list<NLAISCRIPT::CStringType >::const_iterator i = _MemberName.begin();
+00037                 m[0] = 0;
+00038                 while(i != _MemberName.end())
+00039                 {
+00040                         const NLAISCRIPT::CStringType &s = *i;
+00041                         strcat(m,s.data());
+00042                         i ++;
+00043                         if(i != _MemberName.end()) strcat(m,".");
+00044                 }
+00045                 std::string text;
+00046                 text = NLAIC::stringGetBuild("resolve constraint for the component '%s' at line %d",m,_Lin);
+00047                 _TxtInfo = new char [strlen(text.c_str()) + 1];
+00048                 strcpy(_TxtInfo,text.c_str());          
+00049                 _Satisfied = false;
+00050                 _Id = NULL;
+00051                 _OpCodeType = opCodeType;
+00052                 _StackPos = stackPos;
+00053 
+00054 #ifdef NL_DEBUG
+00055                 static int kkkkk = 0;
+00056                 nlinfo("meme %4x, %d",this, kkkkk ++);
+00057 #endif
+00058         }
+00059 
+00060         CConstraintStackComp::~CConstraintStackComp()
+00061         {
+00062                 _TypeStack->release();
+00063                 if(_Id) delete _Id;
+00064                 delete _TxtInfo;
+00065         }
+00066 
+00067         void CConstraintStackComp::run(CCompilateur &comp)
+00068         {
+00069                 if(_Satisfied) return;
+00070                 _TypeStack->run(comp);
+00071                 if(_TypeStack->satisfied())
+00072                 {
+00073                         if(_MemberName.size() == 1)
+00074                         {
+00075                                 const NLAIAGENT::IObjectIA *c = (NLAIAGENT::IObjectIA *)((NLAIC::IClassFactory *)_TypeStack->getConstraintTypeOf()->getFactory())->getClass();
+00076                                 sint32 i = c->getStaticMemberIndex(NLAIAGENT::CStringVarName(_MemberName.front().data()));
+00077                                 if(i >= 0)
+00078                                 {                                       
+00079                                         /*if((const NLAIC::CTypeOfObject &)c->getType() & NLAIC::CTypeOfObject::tAgentInterpret) 
+00080                                         {
+00081                                                 i += comp.getCompementShift((IClassInterpret *)c);
+00082                                         }*/                                     
+00083 
+00084                                         std::list<sint32> b;
+00085                                         b.push_back(i);
+00086                                         IOpCode *x=0;
+00087                                         switch(_OpCodeType)
+00088                                         {
+00089                                         case stackCall:
+00090                                                 x = new CLdbStackMemberiOpCode(b);
+00091                                                 break;
+00092                                         case heapCall:
+00093                                                 x = new CLdbHeapMemberiOpCode(b,_StackPos);
+00094                                                 break;
+00095 
+00096                                         case heapAffectation:
+00097                                                 x = new CAffHeapMemberiOpCode(b,_StackPos);
+00098                                                 break;
+00099                                                 
+00100                                         }
+00101 
+00102                                         std::pair<sint32, CCodeBrancheRun *> &p = _Code.back();
+00103                                         IOpCode *op = (*p.second)[p.first];//
+00104                                         op->release();
+00105                                         (*p.second)[p.first] = x;
+00106                                         _Code.pop_back();       
+00107                                         _Satisfied = true;
+00108                                 }
+00109                                 else
+00110                                 {                                       
+00111                                         return;
+00112                                 }                                                               
+00113                         }
+00114                         else
+00115                         {
+00116                                 std::list<sint32> b;
+00117                                 IOpType *c;
+00118                                 NLAIAGENT::IObjectIA *cl = (NLAIAGENT::IObjectIA *)((NLAIC::IClassFactory *)_TypeStack->getConstraintTypeOf()->getFactory())->getClass();
+00119                                 if(!comp.isValidateVarName(cl,b,_MemberName,c) && c->getConstraintTypeOf() != NULL)
+00120                                 {
+00121                                         c->release();
+00122                                         return;
+00123                                 }
+00124                                 _Id = new NLAIC::CIdentType (*c->getConstraintTypeOf());
+00125                                 c->release();
+00126                                 IOpCode *x=0;
+00127 
+00128                                 switch(_OpCodeType)
+00129                                 {
+00130                                 case stackCall:
+00131                                         x = new CLdbStackMemberiOpCode(b);
+00132                                         break;
+00133                                 case heapCall:
+00134                                         x = new CLdbHeapMemberiOpCode(b,_StackPos);
+00135                                         break;
+00136 
+00137                                 case heapAffectation:
+00138                                         x = new CAffHeapMemberiOpCode(b,_StackPos);
+00139                                         break;
+00140                                 }
+00141 
+00142                                 std::pair<sint32, CCodeBrancheRun *> &p = _Code.back();
+00143                                 IOpCode *op = (*p.second)[p.first];//
+00144                                 op->release();
+00145                                 (*p.second)[p.first] = x;
+00146                                 _Code.pop_back();       
+00147                                 _Satisfied = true;
+00148                                 
+00149                         }
+00150                 }
+00151         }
+00152 
+00153         void CConstraintStackComp::run(IConstraint *)
+00154         {               
+00155         }
+00156         
+00157         bool CConstraintStackComp::dependOn(const IConstraint *c) const
+00158         {
+00159                 return _TypeStack == c;
+00160         }
+00161 
+00162         bool CConstraintStackComp::operator == (const IConstraint &c) const
+00163         {
+00164                 if((getTypeOfClass() == c.getTypeOfClass()) && *((const CConstraintStackComp &)c)._TypeStack == *_TypeStack)
+00165                 {
+00166                         return  ((const CConstraintStackComp &)c)._MemberName == _MemberName && 
+00167                                         ((const CConstraintStackComp &)c)._OpCodeType == _OpCodeType && 
+00168                                         ((const CConstraintStackComp &)c)._StackPos == _StackPos;
+00169                 }
+00170                 return false;
+00171         }
+00172 
+00173         void CConstraintStackComp::getError(char *txt) const
+00174         {
+00175                 std::string text;
+00176                 text = NLAIC::stringGetBuild("can't %s",_TxtInfo);
+00177                 strcpy(txt, (char *)text.c_str());
+00178         }
+00179 
+00180         const IConstraint *CConstraintStackComp::clone() const          
+00181         {
+00182                 _TypeStack->incRef();
+00183                 IConstraint *x = new CConstraintStackComp(_OpCodeType,0,_MemberName,_TypeStack,_Lin,_Col);
+00184                 return x;
+00185         }
+00186 
+00187         const NLAIC::CIdentType *CConstraintStackComp::getConstraintTypeOf()
+00188         {
+00189                 return _Id;
+00190         }
+00191 }
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1