Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

streevariable.cpp

Go to the documentation of this file.
00001 #include "streevariable.h"
00002 #include "streelist.h"
00003 
00004 Variable::Variable(int iid) : id(iid) {};
00005 
00006 Variable::Variable(Constant *name) : id(name->toInt()){
00007       delete name;
00008 };
00009 
00010 Variable::Variable(const string &name) {
00011       istringstream is(name.c_str());
00012       is >> id;
00013 };
00014 
00015 ostream& Variable::print(ostream &os) const{
00016       return os << id;
00017 };
00018 
00019 ostream& Variable::php(ostream &os) const{
00020       //      cerr <<"ERROR: php can not be called for Variables" << endl;
00021       return os << "$" << id;
00022 }
00023 
00024     
00025 bool Variable::match(const Node *p, Assignment &assign, const NameSpace &nameSpace) const{
00026   if (assign.find(getId())!=assign.end())
00027     return assign[getId()]->match(p,assign,nameSpace);
00028   
00029   assign[getId()] = p->copy();
00030   return true;
00031 };
00032 
00033 bool Variable::matchToBegining(const List *p, Assignment &assign, const NameSpace &nameSpace) const{
00034   if (assign.find(getId())!=assign.end())
00035     return assign[getId()]->match(p,assign,nameSpace);  
00036   assign[getId()] = p->copy();
00037   return true;
00038 };
00039 
00040 bool Variable::compare(const Node *p) const{
00041       if (p->getType()!=SVariable) return false;      
00042       if (((Variable*)p)->getId()!=getId()) return false;
00043       return true;
00044 };
00045     
00046 Node* Variable::substitute(const Assignment &assign){
00047       if (assign.find(getId())!=assign.end()){
00048         return assign.find(getId())->second->copy();
00049       }
00050       return this;
00051 };
00052     
00053 Node* Variable::copy() const{
00054       return new Variable(getId());
00055 };
00056 
00057 void Variable::getVariables(VariableList &vlist) const{
00058     vlist.insert(getId());
00059 };
00060 
00061 string Variable::evaluate(const NameSpace &nameSpace) const{
00062   throw "ERROR: Variable::evaluate";
00063 };

Generated on Fri Nov 21 17:54:04 2003 for PHPX by doxygen 1.3.3