#include <module.h>
Inheritance diagram for NLAISCRIPT::IBlock:
This class allows to store a block of op-code with eachs local variables.
Nevrax France
Definition at line 43 of file module.h.
Public Member Functions | |
void | addCode (IOpCode *op) |
Add a op-code pointer, warnning the function increment the ref of the pointer by incRef(). | |
bool | allocLocVar (const char *name, NLAIAGENT::IObjectIA *var) |
Allocs a new local var . | |
sint32 | decRef () |
Decrement the reference of an object. | |
NLAIAGENT::IObjectIA * | eraseVar (const char *Name) |
CCodeBrancheRun * | getCode () |
Builds the code, here we update all IConstarint reference. | |
CCodeBrancheRunDebug * | getCodeDebug (IScriptDebugSource *sourceCode) |
Build a CCodeBrancheRunDebug. | |
virtual const std::string | getInfo () |
const sint32 & | getRef () const |
get the refence count. | |
NLAIAGENT::IObjectIA * | getVar (const char *Name) |
Gets a pointer to a locale variable. | |
IBlock (bool debugMode) | |
IBlock (bool debugMode, TDicoStr *dico) | |
Construct with an active dictionarry and debug mode. | |
void | incRef () |
Inc a reference. We use this when we have to conserve a pointer memeory for exemple in a list. | |
sint32 | isCodeMonted () |
If the code is builded. | |
TListCode & | listCode () |
Get the list of code. | |
TDicoStr * | lockDictionarry () |
Locks the dictionnarry and get it. | |
virtual void | release () |
Release allow to release the pointer. The last release when the _Ref is nul delete the object. | |
virtual void | serial (NLMISC::IStream &f) throw (NLMISC::EStream) |
void | setCurrentLine (uint16 line) |
Set the current line number in the source code. | |
void | setFirstOpCodeInLine (bool b) |
Set the Flag _FirstOpCodeInLine. | |
virtual | ~IBlock () |
Base class method. | |
const NLAIC::IBasicType * | clone () const |
void | getDebugString (std::string &) const |
const NLAIC::CIdentType & | getType () const |
bool | isEqual (const NLAIAGENT::IBasicObjectIA &a) const |
void | load (NLMISC::IStream &is) |
const NLAIC::IBasicType * | newInstance () const |
const NLAIAGENT::IObjectIA::CProcessResult & | run () |
void | save (NLMISC::IStream &os) |
Op-code list manipulation. | |
IOpCode * | getBack () |
CBagOfCode * | getBagOfCode () |
IOpCode * | getFront () |
void | pushBagCode (CBagOfCode *bOp) |
void | pushCode (IOpCode *op) |
Static Public Attributes | |
const NLAIC::CIdentType | IdBlock |
Protected Types | |
typedef std::map< NLAISCRIPT::CStringType, NLAIAGENT::IObjectIA * >::iterator | TDicoStrIter |
this typedef define an correct std::map iterator for store local variable in the heap. | |
Private Attributes | |
CCodeBrancheRun * | _Cbr |
Op-code that define the block. This object is build at the end of parse. | |
uint16 | _CurrentLine |
True while no new opCode as been add since the laste . | |
bool | _Debug |
TDicoStr * | _DicoLocVar |
Local variable is stored here. | |
bool | _FirstOpCodeInLine |
Switch between a normal CCodeBrancheRun and a debug one. | |
bool | _HaveToDeleteDico |
If user want a reference to the local variable dictionary then we don't have to delete it. | |
TListCode | _ListCode |
This list containe the bag of code. |
|
this typedef define an correct std::map iterator for store local variable in the heap.
Definition at line 50 of file module.h. Referenced by ~IBlock(). |
|
Construct with an active dictionarry and debug mode.
Definition at line 70 of file module.h. References _Cbr, _CurrentLine, _DicoLocVar, _FirstOpCodeInLine, _HaveToDeleteDico, and NLAISCRIPT::TDicoStr. Referenced by clone().
00071 { 00072 _Debug = debugMode; 00073 _Cbr = NULL; 00074 _FirstOpCodeInLine = true; 00075 _CurrentLine = 0; 00076 _HaveToDeleteDico = false; 00077 _DicoLocVar = dico; 00078 } |
|
Definition at line 80 of file module.h. References _Cbr, _CurrentLine, _DicoLocVar, _FirstOpCodeInLine, _HaveToDeleteDico, and NLAISCRIPT::TDicoStr.
00081 { 00082 _Debug = debugMode; 00083 _Cbr = NULL; 00084 _FirstOpCodeInLine = true; 00085 _CurrentLine = 0; 00086 _HaveToDeleteDico = true; 00087 _DicoLocVar = new TDicoStr; 00088 } |
|
Definition at line 91 of file module.h. References _Cbr, _DicoLocVar, _HaveToDeleteDico, _ListCode, NLAIC::IPointerGestion::release(), and TDicoStrIter.
00092 { 00093 while(_ListCode.size() != 0) 00094 { 00095 ((IOpCode *)*_ListCode.front())->release(); 00096 delete _ListCode.front(); 00097 _ListCode.pop_front(); 00098 } 00099 00100 if(_Cbr) _Cbr->release(); 00101 TDicoStrIter it = _DicoLocVar->begin(); 00102 while(it != _DicoLocVar->end()) 00103 { 00104 #ifdef NL_DEBUG 00105 const NLAIAGENT::IObjectIA *o = (*it).second; 00106 #endif 00107 (*it).second->release(); 00108 it ++; 00109 } 00110 if(_HaveToDeleteDico) delete _DicoLocVar; 00111 00112 } |
|
|
Allocs a new local var .
Definition at line 148 of file module.h. References _DicoLocVar, and getVar(). Referenced by NLAISCRIPT::CCompilateur::affectation(), and NLAISCRIPT::CCompilateur::registerMethod().
00149 { 00150 if(getVar(name) != NULL) return false; 00151 _DicoLocVar->insert(TDicoStr::value_type(NLAISCRIPT::CStringType(name),var)); 00152 return true; 00153 } |
|
This function allow a pointer copy, that mean that the new class have the sam attributs caracteristics as the owne. Implements NLAIC::IBasicType. Definition at line 208 of file module.h. Referenced by newInstance().
00209 { 00210 NLAIC::IBasicType *x = new IBlock(_Debug); 00211 return x; 00212 } |
|
Decrement the reference of an object.
Definition at line 93 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIC::IPointerGestion::release(), and NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00094 {
00095 return --_Ref;
00096 }
|
|
Definition at line 127 of file module.h. References _DicoLocVar. Referenced by NLAISCRIPT::CCompilateur::affectation().
00128 { 00129 TDicoStr::iterator Itr = _DicoLocVar->find(NLAISCRIPT::CStringType(Name)); 00130 00131 if(Itr != _DicoLocVar->end()) 00132 { 00133 _DicoLocVar->erase(Itr); 00134 } 00135 00136 return NULL; 00137 } |
|
Definition at line 269 of file module.h. References _ListCode.
00270 { 00271 return (IOpCode *)*_ListCode.back(); 00272 } |
|
Definition at line 284 of file module.h. References _ListCode. Referenced by NLAISCRIPT::CCompilateur::affectation(), NLAISCRIPT::CCompilateur::allocExpression(), NLAISCRIPT::CCompilateur::buildObject(), NLAISCRIPT::CCompilateur::callFunction(), NLAISCRIPT::CCompilateur::ifInterrogationEnd(), and NLAISCRIPT::CCompilateur::interrogationEnd().
00285 { 00286 return _ListCode.back(); 00287 } |
|
Implements NLMISC::IClassable. Reimplemented in NLAIC::CIdentType. Definition at line 116 of file abstract_interface.h. Referenced by NLAISCRIPT::CAgentClass::isClassInheritedFrom().
00117 { 00118 return std::string("<unnamed>"); 00119 } |
|
Builds the code, here we update all IConstarint reference.
Definition at line 156 of file module.h. References _ListCode, sint32, and x. Referenced by NLAISCRIPT::CCompilateur::getCode().
00157 { 00158 if(/*_Cbr == NULL && */_ListCode.size()) 00159 { 00160 sint32 k = _ListCode.size(); 00161 CCodeBrancheRun *cbr; 00162 cbr = new CCodeBrancheRun(k); 00163 for(sint32 i = 0; i < k; i++) 00164 { 00165 CBagOfCode *x = _ListCode.front(); 00166 (*cbr)[i] = (IOpCode *)*x; 00167 x->setConstraintIndex(i,cbr); 00168 delete x; 00169 _ListCode.pop_front(); 00170 } 00171 return cbr; 00172 00173 } 00174 return NULL; 00175 } |
|
Build a CCodeBrancheRunDebug.
Definition at line 178 of file module.h. References _ListCode, sint32, and x. Referenced by NLAISCRIPT::CCompilateur::getCode().
00179 { 00180 if(/*_Cbr == NULL && */_ListCode.size()) 00181 { 00182 sint32 k = _ListCode.size(); 00183 CCodeBrancheRunDebug *cbr; 00184 cbr = new CCodeBrancheRunDebug(k, sourceCode); 00185 00186 for(sint32 i = 0; i < k; i++) 00187 { 00188 CBagOfCode *x = _ListCode.front(); 00189 (*cbr)[i] = (IOpCode *)*x; 00190 x->setConstraintIndex(i,cbr); 00191 delete x; 00192 _ListCode.pop_front(); 00193 } 00194 return cbr; 00195 00196 } 00197 return NULL; 00198 } |
|
This is a Debug function, text is an character pointer to receive the debug text output, the debug text containe all think sensible to interset user. Implements NLAIC::IBasicType. Definition at line 224 of file module.h.
00225 { 00226 } |
|
Definition at line 274 of file module.h. References _ListCode.
00275 { 00276 return (IOpCode *)*_ListCode.front(); 00277 } |
|
Definition at line 292 of file abstract_interface.h. References NLAIC::IBasicType::getDebugString(), and s.
00293 { 00294 std::string s; 00295 getDebugString(s); 00296 return s; 00297 } |
|
get the refence count.
Definition at line 99 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00100 {
00101 return _Ref;
00102 }
|
|
getType return a unique string how represente the class, it can be the name of the class. This function is used for the sytem regstry class (see the definition of the template class Gen::CRegistry). Implements NLAIC::IBasicType. Definition at line 219 of file module.h. References IdBlock.
00220 { 00221 return IdBlock; 00222 } |
|
Gets a pointer to a locale variable.
Definition at line 115 of file module.h. References _DicoLocVar. Referenced by allocLocVar(), and NLAISCRIPT::CCompilateur::getVar().
00116 { 00117 TDicoStr::iterator Itr = _DicoLocVar->find(NLAISCRIPT::CStringType(Name)); 00118 00119 if(Itr != _DicoLocVar->end()) 00120 { 00121 return (*Itr).second; 00122 } 00123 00124 return NULL; 00125 } |
|
|
If the code is builded.
Definition at line 201 of file module.h. Referenced by NLAISCRIPT::CCompilateur::getCode().
00202 { 00203 return _Cbr != NULL; 00204 } |
|
Definition at line 236 of file module.h.
00236 { return true;} |
|
Get the list of code.
Definition at line 240 of file module.h. References _ListCode, and NLAISCRIPT::TListCode.
00241 { 00242 return _ListCode; 00243 } |
|
Load the class from a stream. Implements NLAIC::IBasicInterface. Definition at line 232 of file module.h.
00233 { 00234 } |
|
Locks the dictionnarry and get it.
Definition at line 141 of file module.h. References _DicoLocVar, _HaveToDeleteDico, and NLAISCRIPT::TDicoStr.
00142 { 00143 _HaveToDeleteDico = false; 00144 return _DicoLocVar; 00145 } |
|
This function allow a new instance, that mean that the class is a class factory. Implements NLAIC::IBasicType. Definition at line 214 of file module.h. References clone().
00215 { 00216 return clone(); 00217 } |
|
Definition at line 279 of file module.h. References _ListCode.
00280 { 00281 _ListCode.push_back(bOp); 00282 } |
|
Definition at line 264 of file module.h. References _ListCode. Referenced by NLAISCRIPT::CCompilateur::ifInterrogationEnd(), and NLAISCRIPT::CCompilateur::interrogationEnd().
00265 { 00266 _ListCode.push_back(new CBagOfCode(op)); 00267 } |
|
|
Definition at line 28 of file module.cpp.
00029 { 00030 return NLAIAGENT::IObjectIA::ProcessRun; 00031 } |
|
Save the class in a stream. Implements NLAIC::IBasicInterface. Definition at line 228 of file module.h.
00229 { 00230 } |
|
Reimplemented from NLAIC::IPointerGestion. Definition at line 328 of file abstract_interface.h. References NLAIC::IBasicInterface::load(), and NLAIC::IBasicInterface::save().
|
|
Set the current line number in the source code.
Definition at line 291 of file module.h. References _CurrentLine, and uint16. Referenced by NLAISCRIPT::CCompilateur::setNewLine().
00292 { 00293 _CurrentLine = line; 00294 } |
|
Set the Flag _FirstOpCodeInLine.
Definition at line 297 of file module.h. References _FirstOpCodeInLine. Referenced by NLAISCRIPT::CCompilateur::setNewLine().
00298 { 00299 _FirstOpCodeInLine = b; 00300 } |
|
Op-code that define the block. This object is build at the end of parse.
Definition at line 54 of file module.h. Referenced by IBlock(), isCodeMonted(), and ~IBlock(). |
|
True while no new opCode as been add since the laste
Definition at line 64 of file module.h. Referenced by addCode(), IBlock(), and setCurrentLine(). |
|
|
|
Local variable is stored here.
Definition at line 58 of file module.h. Referenced by allocLocVar(), eraseVar(), getVar(), IBlock(), lockDictionarry(), and ~IBlock(). |
|
Switch between a normal CCodeBrancheRun and a debug one.
Definition at line 63 of file module.h. Referenced by addCode(), IBlock(), and setFirstOpCodeInLine(). |
|
If user want a reference to the local variable dictionary then we don't have to delete it.
Definition at line 60 of file module.h. Referenced by IBlock(), lockDictionarry(), and ~IBlock(). |
|
This list containe the bag of code.
Definition at line 56 of file module.h. Referenced by addCode(), getBack(), getBagOfCode(), getCode(), getCodeDebug(), getFront(), listCode(), pushBagCode(), pushCode(), and ~IBlock(). |
|
Referenced by getType(). |