proj home

Files   Classes   Functions   Hierarchy  

rpncp Class Reference

#include <rpnfunc.h>

Inheritance diagram for rpncp:
Collaboration diagram for rpncp:

List of all members.

Public Member Functions

 rpncp ()
 rpncp (deque< rpnbase * > &ds, bool const evaluate=true)
 ~rpncp ()
rpnbasecopy () const
void visit (deque< rpnbase * > &ds, rpnstring &s)
string const name () const
void eval (deque< rpnbase * > &ds)


Detailed Description

Definition at line 1050 of file rpnfunc.h.


Constructor & Destructor Documentation

rpncp::rpncp (  )  [inline]

Definition at line 1054 of file rpnfunc.h.

Referenced by copy().

01054 {}

rpncp::rpncp ( deque< rpnbase * > &  ds,
bool const   evaluate = true 
)

Definition at line 3258 of file rpnfunc.cpp.

References eval().

03259 {
03260   if (evaluate)
03261     eval(ds);
03262   else
03263     ds.push_front(this);
03264 }

rpncp::~rpncp (  )  [inline]

Definition at line 1056 of file rpnfunc.h.

01056 {}


Member Function Documentation

rpnbase * rpncp::copy (  )  const [virtual]

Reimplemented from rpnfunction.

Definition at line 3266 of file rpnfunc.cpp.

References rpncp().

Referenced by visit().

03267 {
03268   return new rpncp();
03269 }

void rpncp::eval ( deque< rpnbase * > &  ds  )  [virtual]

Reimplemented from rpnfunction.

Definition at line 3271 of file rpnfunc.cpp.

References rpnbase::accept(), and rpnbase::dec().

Referenced by rpncp().

03272 {
03273   if (!ds.empty())
03274     ds[0]->accept(ds,*this);
03275 
03276   dec();
03277 }

string const rpncp::name (  )  const [inline, virtual]

Reimplemented from rpnfunction.

Definition at line 1061 of file rpnfunc.h.

01061 { return string("cp"); }

void rpncp::visit ( deque< rpnbase * > &  ds,
rpnstring s 
) [virtual]

Reimplemented from rpnfunction.

Definition at line 3279 of file rpnfunc.cpp.

References copy(), rpnbase::dec(), rpnbase::isstring(), rpnstring::str, and rpnprogram::variables.

03280 {
03281   if (ds.size()<2)
03282     return;
03283   
03284   if (!ds[1]->isstring())
03285     return;
03286 
03287   deque<rpnvar*>& vs = rpnprogramstackstate().vs();
03288   if (vs.empty())
03289     return;
03290 
03291   rpnbase* x0 = ds.front();
03292   ds.pop_front();
03293   rpnbase* x1 = ds.front();
03294   ds.pop_front();
03295 
03296   string nm(varname.str);
03297   bool found = false;
03298   unsigned int index;
03299   for (unsigned int i=0, imax=vs.size(); i<imax; ++i)
03300   {
03301     if (vs[i]->varname==nm)
03302     {
03303       found = true;
03304       index = i;
03305       i = imax;
03306     }
03307   }
03308 
03309   if (!found)
03310   {
03311     ds.push_front(x1);
03312     ds.push_front(x0);
03313     return;
03314   }
03315 
03316   rpnstring* s = (rpnstring*)x1;
03317 
03318   rpnprogram* p;
03319   vector<string> v;
03320   pathstuff().convert(v,s->str);
03321 
03322   pathstuff().findpath(found,p,v);
03323   
03324   if (!found)
03325   {
03326     ds.push_front(x1);
03327     ds.push_front(x0);
03328 
03329     return;
03330   }
03331 
03332   p->variables.push_back( (rpnvar*)(vs[index]->copy()) );
03333 
03334   x0->dec();
03335   x1->dec();
03336 }


The documentation for this class was generated from the following files:

Generated on Fri Mar 4 00:50:13 2011 for Chelton Evans Source by  doxygen 1.5.8