NLAISCRIPT::CStackPointer Class Reference

#include <codage.h>

Inheritance diagram for NLAISCRIPT::CStackPointer:

NLAISCRIPT::CIndexStackPointer

Detailed Description

Class CStackPointer.

Defined a basic fonctionality of a stack index pointer.

Author:
Chafik sameh

Nevrax France

Date:
2000

Definition at line 148 of file codage.h.

Public Member Functions

void addStack (int bp)
 set an bp shift to relative stack pointer _Bp.

void clear ()
 Reinitializ the stack manager.

 CStackPointer (int count=1024 *8)
virtual int mark ()
 Get the last mark.

virtual int markSize ()
virtual operator int ()
 To get the pointer.

 operator NLAIAGENT::IObjectIA * ()
 Get the IObjectIA pointer in current position.

virtual void operator++ (int)
 To inc the pointer.

virtual void operator+= (int k)
 To add by k range.

virtual void operator-- (int)
 Dec the current position of the stack point by one.

virtual void operator-= (int k)
 Dec the current position of the stack point by k unite.

NLAIAGENT::IObjectIA *& operator[] (int i)
 Get the pointer in the position i.

virtual int popMark ()
 Get the last mark pushed in the list.

virtual void pushMark ()
 Add a mark to store the pointer possition in a list.

void restoreShift ()
 restore the last _Sh shift to the stack pointer.

bool restoreShiftState ()
 if there is any _Sh shift.

void restoreStack ()
 restore the last _Bp shift to the stack pointer.

bool restoreStackState ()
 if there is any _Bp shift.

void setShift (int s)
 set an s shift to relative stack pointer _Sh.

 ~CStackPointer ()

Protected Attributes

int _Sp
 Index of the stack pointer.


Private Attributes

int _Bp
 _Bp is a relative pointer to upright the stack point at the entry point of a methode.

int _Count
 the count of allocation table.

std::list< int > _Decalage
 list to storager the last shift release in _Bp

int _Sh
 _Sh is a relative pointer to upright the stack after allocat the argument of a methode.

std::list< int > _Shift
 list to storager the last shift release in _Sh

NLAIAGENT::IObjectIA ** _Stack
 this IObjectIA table have _Count size.


Constructor & Destructor Documentation

NLAISCRIPT::CStackPointer::CStackPointer int  count = 1024*8  )  [inline]
 

Definition at line 168 of file codage.h.

References _Bp, _Sh, and count.

00169                 {
00170                         _Count = count;
00171                         _Stack = new NLAIAGENT::IObjectIA *[ count ];
00172                         for(int i = 0; i < _Count; i ++)
00173                         {
00174                                 _Stack[i] = NULL;
00175                         }                       
00176                         _Sp = 0;
00177                         _Bp = 0;
00178                         _Sh = 0;
00179                 }

NLAISCRIPT::CStackPointer::~CStackPointer  )  [inline]
 

Definition at line 293 of file codage.h.

00294                 {               
00295                         if(_Stack)
00296                         {
00297                         
00298                                 for(int i = _Bp; i < (_Sp + _Bp); i ++)
00299                                 {
00300                                         if(_Stack[i] != NULL)
00301                                         {
00302                                                 _Stack[i]->release();
00303                                                 _Stack[i] = NULL;
00304                                         }
00305                                 }
00306                                 delete []_Stack;
00307                                 _Stack = NULL;
00308                         }                       
00309                 }


Member Function Documentation

void NLAISCRIPT::CStackPointer::addStack int  bp  )  [inline]
 

set an bp shift to relative stack pointer _Bp.

Definition at line 245 of file codage.h.

Referenced by NLAISCRIPT::CMethodContextDebug::saveContext(), and NLAISCRIPT::CMethodContext::saveContext().

00246                 {
00247                         _Bp += bp;
00248                         _Sp -= bp;
00249                         _Decalage.push_back(bp);
00250                 }

void NLAISCRIPT::CIndexStackPointer::clear void   )  [inline, inherited]
 

Reinitializ the stack manager.

Definition at line 124 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Marque, and NLAISCRIPT::CIndexStackPointer::_Sp.

Referenced by NLAISCRIPT::CCompilateur::initParam().

00125                 {
00126                         _Sp = 0;                        
00127                         _Marque.clear();
00128                 }

virtual int NLAISCRIPT::CIndexStackPointer::mark  )  [inline, virtual, inherited]
 

Get the last mark.

Definition at line 118 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Marque.

Referenced by NLAISCRIPT::CFreeAlloc::getDebugResult(), and NLAISCRIPT::CFreeAllocDebug::getDebugResult().

00119                 {
00120                         return _Marque.back();          
00121                 }

virtual int NLAISCRIPT::CIndexStackPointer::markSize  )  [inline, virtual, inherited]
 

Definition at line 112 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Marque.

00113                 {
00114                         return _Marque.size();
00115                 }

virtual NLAISCRIPT::CIndexStackPointer::operator int  )  [inline, virtual, inherited]
 

To get the pointer.

Definition at line 68 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Sp.

00069                 {
00070                         return _Sp;
00071                 }

NLAISCRIPT::CStackPointer::operator NLAIAGENT::IObjectIA *  )  [inline]
 

Get the IObjectIA pointer in current position.

Definition at line 194 of file codage.h.

References _Bp, _Sh, and operator NLAIAGENT::IObjectIA *().

Referenced by operator NLAIAGENT::IObjectIA *().

00195                 {
00196 #ifdef NL_DEBUG
00197                         if ( (_Sp + _Bp + _Sh) >= _Count )
00198                         {
00199                                 throw NLAIE::CExceptionIndexError();
00200                         }
00201 #endif                  
00202                         return _Stack[_Sp + _Bp + _Sh];
00203                 }

virtual void NLAISCRIPT::CIndexStackPointer::operator++ int   )  [inline, virtual, inherited]
 

To inc the pointer.

Definition at line 74 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Sp.

00075                 {               
00076                         _Sp ++;
00077                 }

virtual void NLAISCRIPT::CIndexStackPointer::operator+= int  k  )  [inline, virtual, inherited]
 

To add by k range.

Definition at line 86 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Sp.

00087                 {
00088                         _Sp += k;
00089                 }

virtual void NLAISCRIPT::CStackPointer::operator-- int   )  [inline, virtual]
 

Dec the current position of the stack point by one.

Reimplemented from NLAISCRIPT::CIndexStackPointer.

Definition at line 206 of file codage.h.

00207                 {
00208 #ifdef NL_DEBUG
00209                         if ( (_Sp + _Bp + _Sh) >= _Count )
00210                         {
00211                                 throw NLAIE::CExceptionIndexError();
00212                         }
00213 #endif                                          
00214                         int i = _Sp + _Bp  + _Sh;
00215                         if(_Stack[i])
00216                         {                       
00217                                 _Stack[i]->release(); 
00218                                 _Stack[i] = NULL;
00219                         }
00220                         _Sp --;
00221                 }

virtual void NLAISCRIPT::CStackPointer::operator-= int  k  )  [inline, virtual]
 

Dec the current position of the stack point by k unite.

Reimplemented from NLAISCRIPT::CIndexStackPointer.

Definition at line 224 of file codage.h.

00225                 {
00226 #ifdef NL_DEBUG
00227                         if ( (_Sp + _Bp + _Sh) >= _Count )
00228                         {
00229                                 throw NLAIE::CExceptionIndexError();
00230                         }
00231 #endif                                          
00232                         int n = _Sp + _Bp + _Sh;
00233                         for(int i = n - k; i < n; i ++) 
00234                         {
00235                                 if(_Stack[i])
00236                                 {
00237                                         _Stack[i]->release();
00238                                         _Stack[i] = NULL;
00239                                 }
00240                         }
00241                         _Sp -= k;
00242                 }

NLAIAGENT::IObjectIA*& NLAISCRIPT::CStackPointer::operator[] int  i  )  [inline]
 

Get the pointer in the position i.

Definition at line 182 of file codage.h.

References _Bp, and _Sh.

00183                 {
00184 #ifdef NL_DEBUG
00185                         if ( (_Sp + _Bp + _Sh) >= _Count )
00186                         {
00187                                 throw NLAIE::CExceptionIndexError();
00188                         }
00189 #endif                  
00190                         return _Stack[i + _Bp + _Sh];
00191                 }

virtual int NLAISCRIPT::CIndexStackPointer::popMark  )  [inline, virtual, inherited]
 

Get the last mark pushed in the list.

Definition at line 104 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Marque.

Referenced by NLAISCRIPT::CCompilateur::getCode(), NLAISCRIPT::CCompilateur::ifInterrogationEnd(), NLAISCRIPT::CCompilateur::ifInterrogationPoint(), NLAISCRIPT::CCompilateur::interrogationEnd(), NLAISCRIPT::CFreeAlloc::runOpCode(), and NLAISCRIPT::CFreeAllocDebug::runOpCode().

00105                 {
00106                         int i = 0;                      
00107                         i = _Marque.back();
00108                         _Marque.pop_back();             
00109                         return i;
00110                 }

virtual void NLAISCRIPT::CIndexStackPointer::pushMark  )  [inline, virtual, inherited]
 

Add a mark to store the pointer possition in a list.

Definition at line 98 of file codage.h.

References NLAISCRIPT::CIndexStackPointer::_Marque, and NLAISCRIPT::CIndexStackPointer::_Sp.

Referenced by NLAISCRIPT::CCompilateur::ifInterrogation(), NLAISCRIPT::CCompilateur::ifInterrogationPoint(), NLAISCRIPT::CCompilateur::initParam(), and NLAISCRIPT::CMarkAlloc::runOpCode().

00099                 {
00100                         _Marque.push_back(_Sp);
00101                 }

void NLAISCRIPT::CStackPointer::restoreShift  )  [inline]
 

restore the last _Sh shift to the stack pointer.

Definition at line 272 of file codage.h.

References s.

Referenced by NLAISCRIPT::CCompilateur::getCode(), NLAISCRIPT::CMethodContextDebug::loadContext(), NLAISCRIPT::CMethodContext::loadContext(), and NLAISCRIPT::CCompilateur::registerMethod().

00273                 {                       
00274                         int s = _Shift.back();
00275                         _Shift.pop_back();
00276                         _Sp += s;
00277                         _Sh -= s;
00278                 }

bool NLAISCRIPT::CStackPointer::restoreShiftState  )  [inline]
 

if there is any _Sh shift.

Definition at line 288 of file codage.h.

Referenced by NLAISCRIPT::CCompilateur::getCode(), and NLAISCRIPT::CCompilateur::registerMethod().

00289                 {
00290                         return _Shift.size() != 0;
00291                 }

void NLAISCRIPT::CStackPointer::restoreStack  )  [inline]
 

restore the last _Bp shift to the stack pointer.

Definition at line 253 of file codage.h.

Referenced by NLAISCRIPT::CCompilateur::getCode(), NLAISCRIPT::CMethodContextDebug::loadContext(), NLAISCRIPT::CMethodContext::loadContext(), and NLAISCRIPT::CCompilateur::registerMethod().

00254                 {                       
00255                         int k = _Bp;
00256                         _Bp -= _Decalage.back();
00257                         _Decalage.pop_back();
00258                         _Sp += k;
00259                         
00260                         *this -= k;                             
00261                 }

bool NLAISCRIPT::CStackPointer::restoreStackState  )  [inline]
 

if there is any _Bp shift.

Definition at line 282 of file codage.h.

Referenced by NLAISCRIPT::CCompilateur::getCode(), and NLAISCRIPT::CCompilateur::registerMethod().

00283                 {
00284                         return _Decalage.size() != 0;
00285                 }

void NLAISCRIPT::CStackPointer::setShift int  s  )  [inline]
 

set an s shift to relative stack pointer _Sh.

Definition at line 264 of file codage.h.

References s.

Referenced by NLAISCRIPT::CCompilateur::registerMethod(), NLAISCRIPT::CMethodContextDebug::saveContext(), and NLAISCRIPT::CMethodContext::saveContext().

00265                 {
00266                         _Sh += s;
00267                         _Sp -= s;
00268                         _Shift.push_back(s);
00269                 }


Field Documentation

int NLAISCRIPT::CStackPointer::_Bp [private]
 

_Bp is a relative pointer to upright the stack point at the entry point of a methode.

Definition at line 154 of file codage.h.

Referenced by CStackPointer(), operator NLAIAGENT::IObjectIA *(), and operator[]().

int NLAISCRIPT::CStackPointer::_Count [private]
 

the count of allocation table.

Definition at line 152 of file codage.h.

std::list<int> NLAISCRIPT::CStackPointer::_Decalage [private]
 

list to storager the last shift release in _Bp

Definition at line 160 of file codage.h.

int NLAISCRIPT::CStackPointer::_Sh [private]
 

_Sh is a relative pointer to upright the stack after allocat the argument of a methode.

Definition at line 157 of file codage.h.

Referenced by CStackPointer(), operator NLAIAGENT::IObjectIA *(), and operator[]().

std::list<int> NLAISCRIPT::CStackPointer::_Shift [private]
 

list to storager the last shift release in _Sh

Definition at line 162 of file codage.h.

int NLAISCRIPT::CIndexStackPointer::_Sp [protected, inherited]
 

Index of the stack pointer.

Definition at line 56 of file codage.h.

Referenced by NLAISCRIPT::CIndexStackPointer::CIndexStackPointer(), NLAISCRIPT::CIndexStackPointer::clear(), NLAISCRIPT::CIndexStackPointer::operator int(), NLAISCRIPT::CIndexStackPointer::operator++(), NLAISCRIPT::CIndexStackPointer::operator+=(), NLAISCRIPT::CIndexStackPointer::operator--(), NLAISCRIPT::CIndexStackPointer::operator-=(), and NLAISCRIPT::CIndexStackPointer::pushMark().

NLAIAGENT::IObjectIA** NLAISCRIPT::CStackPointer::_Stack [private]
 

this IObjectIA table have _Count size.

Definition at line 165 of file codage.h.


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 12:25:30 2004 for NeL by doxygen 1.3.6