# 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  

opcode_ldb.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/agent/agent_script.h"
00026 #include "nel/ai/script/interpret_object_agent.h"
00027 #include "nel/ai/script/interpret_object_message.h"
00028 
00029 namespace NLAISCRIPT
00030 {
00031         CLdbOpCode::CLdbOpCode(const NLAIAGENT::IObjectIA &b)
00032         {
00033           _B = (NLAIAGENT::IObjectIA *)b.clone();
00034 
00035         }
00036 
00037         NLAIAGENT::TProcessStatement CLdbOpCode::runOpCode(CCodeContext &context)
00038         {
00039                 context.Stack ++;
00040                 context.Stack[(int)context.Stack] = (NLAIAGENT::IObjectIA *)_B->clone();
00041                 return NLAIAGENT::IObjectIA::ProcessIdle;
00042         }
00043 
00044         void CLdbOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00045         {                       
00046                 std::string X;
00047                 _B->getDebugString(X);
00048                 str += "ldb ";
00049                 str += X;               
00050         }
00051         NLAIAGENT::TProcessStatement CLdbMemberOpCode::runOpCode(CCodeContext &context)
00052         {
00053                 context.Stack ++;
00054 
00055                 NLAIAGENT::IObjectIA *t = (NLAIAGENT::IObjectIA *)(context.Self)->getStaticMember(_B);//->clone();
00056                 t->incRef();
00057                 context.Stack[(int)context.Stack] = t;
00058                 return NLAIAGENT::IObjectIA::ProcessIdle;;
00059         }
00060 
00061         void CLdbMemberOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00062         {               
00063                 const NLAIAGENT::IObjectIA *r = (context.Self);
00064                 std::string name = "????";
00065                 std::string className = "????";
00066 
00067                 if(((const NLAIC::CTypeOfObject &)r->getType()) & NLAIC::CTypeOfObject::tInterpret)
00068                 {
00069                         if(((const NLAIC::CTypeOfObject &)r->getType()) & NLAIC::CTypeOfObject::tAgent)
00070                         {                       
00071                                 name = ((NLAIAGENT::CAgentScript *)r)->getClass()->getComponentName(_B);
00072                         }
00073                         else
00074                         if(((const NLAIC::CTypeOfObject &)r->getType()) & NLAIC::CTypeOfObject::tMessage)
00075                         {                       
00076                                 name = ((NLAIAGENT::CMessageScript *)r)->getCreatorClass()->getComponentName(_B);
00077                         }
00078                 }
00079                 className = (const char *)r->getType();
00080                 r = r->getStaticMember(_B);
00081                                         
00082                 str += NLAIC::stringGetBuild("ldb le composant membre %d named: '%s' de la class '%s'",_B, name.c_str(),className.c_str());
00083         }
00084 
00085 
00086         NLAIAGENT::TProcessStatement CLdbStackMemberiOpCode::runOpCode(CCodeContext &context)
00087         {
00088                 NLAIAGENT::IObjectIA *a = ((NLAIAGENT::IObjectIA *)context.Stack);
00089                 NLAIAGENT::IObjectIA *obj = a; 
00090                 std::list<sint32>::iterator i = _I.begin();
00091                 sint32 n = _I.size() - 1;
00092                 
00093                 while(n --)
00094                 {                       
00095                         a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i++);
00096                 }
00097                 //context.Stack[(int)context.Stack] = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i)->clone();
00098                 a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i);
00099                 a->incRef();
00100                 context.Stack[(int)context.Stack] = a;
00101                 obj->release();
00102                 return NLAIAGENT::processIdle;
00103         }
00104 
00105         void CLdbStackMemberiOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00106         {       
00107                 NLAIAGENT::IObjectIA *a = ((NLAIAGENT::IObjectIA *)context.Stack);              
00108                 std::list<sint32>::const_iterator i = _I.begin();
00109                 sint32 n = _I.size() - 1;
00110                 std::string name = "????";
00111                 std::string className = "????";
00112                 while(n --)
00113                 {
00114                         if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tInterpret)
00115                         {
00116                                 if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tAgent)
00117                                 {                       
00118                                         name = ((NLAIAGENT::CAgentScript *)a)->getClass()->getComponentName(*i);
00119                                 }
00120                                 else
00121                                 if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tMessage)
00122                                 {                       
00123                                         name = ((NLAIAGENT::CMessageScript *)a)->getCreatorClass()->getComponentName(*i);
00124                                 }
00125                         }
00126                         className = (const char *)a->getType();
00127                         a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i++);
00128                 }
00129                 std::string txt;
00130                 a->getStaticMember(*i)->getDebugString(txt);
00131                 str += NLAIC::stringGetBuild("ldb %s le composon '%s' membre sur la pile de la class '%s'",txt.c_str(),name.c_str(),className.c_str());
00132         }
00133 
00134         NLAIAGENT::TProcessStatement CLdbHeapMemberiOpCode::runOpCode(CCodeContext &context)
00135         {
00136                 NLAIAGENT::IObjectIA *a = (NLAIAGENT::IObjectIA *)context.Heap[(int)_N];
00137 
00138 #ifdef NL_DEBUG
00139                 std::string text;
00140                 text = NLAIC::stringGetBuild("ldb le composant membre sur le heap de la class '%s'",(const char *)a->getType());                
00141 #endif
00142                 std::list<sint32>::iterator i = _I.begin();             
00143                 sint32 n = _I.size() - 1;
00144                 while(n --)
00145                 {
00146                         
00147                         a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i++);
00148                 }
00149                 a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i);//->clone();
00150                 context.Stack ++;
00151                 a->incRef();
00152                 context.Stack[(int)context.Stack] = a;
00153                 return NLAIAGENT::processIdle;
00154         }
00155 
00156         void CLdbHeapMemberiOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00157         {                                               
00158                 NLAIAGENT::IObjectIA *a = (NLAIAGENT::IObjectIA *)context.Heap[(int)_N];
00159 #ifdef NL_DEBUG
00160                 std::string text;
00161                 text = NLAIC::stringGetBuild("ldb le composant membre sur le heap de la class '%s'",(const char *)a->getType());                
00162 #endif
00163                 
00164                 std::string name = "????";
00165                 std::string className = "????";
00166                 std::list<sint32>::const_iterator i = _I.begin();
00167                 while(i != _I.end())
00168                 {
00169                         if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tInterpret)
00170                         {                       
00171                                 if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tAgent)
00172                                 {                       
00173                                         name = ((NLAIAGENT::CAgentScript *)a)->getClass()->getComponentName(*i);
00174                                 }
00175                                 else
00176                                 if(((const NLAIC::CTypeOfObject &)a->getType()) & NLAIC::CTypeOfObject::tMessage)
00177                                 {                       
00178                                         name = ((NLAIAGENT::CMessageScript *)a)->getCreatorClass()->getComponentName(*i);
00179                                 }
00180                         }
00181                         className = (const char *)a->getType();
00182                         a = (NLAIAGENT::IObjectIA *)a->getStaticMember(*i++);
00183                 }
00184 
00185                 std::string txt;
00186                 a->getDebugString(txt);
00187                 str += NLAIC::stringGetBuild("ldb %s le composon '%s' membre sur le heap de la class '%s'",txt.c_str(),name.c_str(),className.c_str());         
00188         }
00189 
00190         NLAIAGENT::TProcessStatement CLdbMemberiOpCode::runOpCode(CCodeContext &context)
00191         {
00192                 context.Stack ++;
00193                 NLAIAGENT::IObjectIA *obj = (NLAIAGENT::IObjectIA *)context.Self;
00194                 std::list<sint32>::iterator i = _I.begin();
00195                 while(i != _I.end())
00196                 {
00197                         obj = (NLAIAGENT::IObjectIA *)obj->getStaticMember(*i++);
00198                 }
00199                 context.Stack[(int)context.Stack] = (NLAIAGENT::IObjectIA *)obj;//->clone();
00200                 obj->incRef();
00201                 
00202                 return NLAIAGENT::IObjectIA::ProcessIdle;
00203         }
00204 
00205         void CLdbMemberiOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00206         {                       
00207                 NLAIAGENT::IObjectIA *obj = (NLAIAGENT::IObjectIA *)context.Self;
00208                 std::list<sint32>::const_iterator i = _I.begin();
00209                 int j=0;
00210                 std::string className, name = "????";
00211 
00212                 while(i != _I.end())
00213                 {
00214                         j = *i++;
00215                         if(((const NLAIC::CTypeOfObject &)obj->getType()) & NLAIC::CTypeOfObject::tInterpret)
00216                         {                       
00217                                 if(((const NLAIC::CTypeOfObject &)obj->getType()) & NLAIC::CTypeOfObject::tAgent)
00218                                 {                       
00219                                         name = ((NLAIAGENT::CAgentScript *)obj)->getClass()->getComponentName(j);
00220                                 }
00221                                 else
00222                                 if(((const NLAIC::CTypeOfObject &)obj->getType()) & NLAIC::CTypeOfObject::tMessage)
00223                                 {                       
00224                                         name = ((NLAIAGENT::CMessageScript *)obj)->getCreatorClass()->getComponentName(j);
00225                                 }
00226                         }
00227                         className = (const char *)obj->getType();
00228                         obj = (NLAIAGENT::IObjectIA *)obj->getStaticMember(j);
00229                 }                       
00230                                         
00231                 str += NLAIC::stringGetBuild("ldb le composon '%s' membre <%d> member de la class '%s'",name.c_str(),j,className.c_str());              
00232         }
00233 
00234         NLAIAGENT::TProcessStatement CLdbRefOpCode::runOpCode(CCodeContext &context)
00235         {
00236                 NLAIAGENT::IObjectIA *o = (NLAIAGENT::IObjectIA *)context.Heap[_B];//->clone();
00237                 o->incRef();
00238                 context.Stack ++;
00239                 context.Stack[(int)context.Stack] = o;
00240                 return NLAIAGENT::IObjectIA::ProcessIdle;
00241         }
00242 
00243         void CLdbRefOpCode::getDebugResult(std::string &str,CCodeContext &context) const
00244         {
00245                 std::string X;
00246                 context.Heap[_B]->getDebugString(X);
00247                 str += NLAIC::stringGetBuild("ldb<%d>: %s",_B,X.c_str());
00248         }
00249 }