Files Classes Functions Hierarchy
#include <scopedependentfunctions.h>
Public Member Functions | |
| dictadd () | |
| dictadd (deque< rpnbase * > &ds, bool const evaluate=true) | |
| ~dictadd () | |
| rpnbase * | copy () const |
| void | visit (deque< rpnbase * > &ds, rpnstring &fname) |
| string const | name () const |
| void | eval (deque< rpnbase * > &ds) |
Definition at line 106 of file scopedependentfunctions.h.
| dictadd::dictadd | ( | ) | [inline] |
Definition at line 409 of file scopedependentfunctions.cpp.
References eval().
00410 { 00411 if (evaluate) 00412 eval(ds); 00413 else 00414 ds.push_front(this); 00415 }
| dictadd::~dictadd | ( | ) | [inline] |
| rpnbase * dictadd::copy | ( | ) | const [virtual] |
Reimplemented from rpnfunction.
Definition at line 417 of file scopedependentfunctions.cpp.
References dictadd().
00418 { 00419 return new dictadd(); 00420 }
| void dictadd::eval | ( | deque< rpnbase * > & | ds | ) | [virtual] |
Reimplemented from rpnfunction.
Definition at line 422 of file scopedependentfunctions.cpp.
References rpnbase::dec().
Referenced by dictadd().
00423 { 00424 if(ds.empty()) 00425 return; 00426 00427 ds[0]->accept(ds,*this); 00428 00429 dec(); 00430 }
| string const dictadd::name | ( | ) | const [inline, virtual] |
Reimplemented from rpnfunction.
Definition at line 432 of file scopedependentfunctions.cpp.
References rpnbase::dec(), rpnbase::inc(), rpnbase::isprogram(), rpnstring::str, rpnprogram::variables, rpnvar::varname, and rpnvar::x.
00433 { 00434 if (ds.size()<2) 00435 return; 00436 00437 rpnbase* x0 = ds.front(); 00438 ds.pop_front(); 00439 rpnbase* x1 = ds.front(); 00440 ds.pop_front(); 00441 00442 rpnprogram* hm = rpnprogramstackstate().ps->back(); 00443 rpnprogram* bin; 00444 bool notfound=true; 00445 if (!hm->variables.empty()) 00446 { 00447 rpnvar* var; 00448 for (unsigned int i=0, imax=hm->variables.size(); i<imax; ++i) 00449 { 00450 var = hm->variables[i]; 00451 if (var->varname=="bin") 00452 { 00453 notfound=false; 00454 i=imax; 00455 bin = (rpnprogram*)(var->x); 00456 00457 if (! var->x->isprogram() ) /* Restore the stack. */ 00458 { 00459 ds.push_front(x1); 00460 ds.push_front(x0); 00461 00462 return; 00463 } 00464 00465 } 00466 } 00467 } 00468 if (notfound) 00469 { 00470 bin = new rpnprogram(); 00471 new rpnvar(*hm,bin,"bin"); 00472 } 00473 00474 /* x1 is now owned by the rpn variable. */ 00475 new rpnvar(*bin,x1,fname.str); 00476 00477 /* fbuild user has a pointer to x1. */ 00478 x1->inc(); 00479 SingletonPtr<inputstatescope>()->fd.add( new fbuilduser(x1,fname.str) ); 00480 00481 x0->dec(); 00482 }
1.5.8