Files Classes Functions Hierarchy
#include <rpnfunc.h>
Public Member Functions | |
| rpncp () | |
| rpncp (deque< rpnbase * > &ds, bool const evaluate=true) | |
| ~rpncp () | |
| rpnbase * | copy () const |
| void | visit (deque< rpnbase * > &ds, rpnstring &s) |
| string const | name () const |
| void | eval (deque< rpnbase * > &ds) |
Definition at line 1050 of file rpnfunc.h.
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 }
| 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().
| string const rpncp::name | ( | ) | const [inline, 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 }
1.5.8