CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/CommonTools/Utils/src/ExpressionVarSetter.cc

Go to the documentation of this file.
00001 #include "CommonTools/Utils/src/ExpressionVarSetter.h"
00002 #include "CommonTools/Utils/src/ExpressionVar.h"
00003 #include "CommonTools/Utils/src/returnType.h"
00004 #include "CommonTools/Utils/interface/Exception.h"
00005 #include <string>
00006 using namespace reco::parser;
00007 using namespace std;
00008 using namespace Reflex;
00009 
00010 void ExpressionVarSetter::operator()(const char * begin, const char* end) const {
00011   //std::cerr << "ExpressionVarSetter: Pushed [" << std::string(begin,end) << "]" << std::endl;  
00012   if (!methStack_.empty())          push(begin,end);
00013   else if (!lazyMethStack_.empty()) lazyPush(begin,end);
00014   else throw Exception(begin) << " Expression didn't parse neither hastily nor lazyly. This must not happen.\n";
00015 }
00016 
00017 void ExpressionVarSetter::push(const char *begin, const char *end) const {
00018   Type type = typeStack_.back();
00019   method::TypeCode retType = reco::typeCode(type);
00020   if(retType == method::invalid)
00021     throw  Exception(begin)
00022       << "member \"" << methStack_.back().method().Name() << "\" has an invalid return type: \"" 
00023       <<  methStack_.back().method().TypeOf().Name() << "\"";
00024   if(!ExpressionVar::isValidReturnType(retType))
00025      throw Exception(begin)
00026        << "member \"" << methStack_.back().method().Name() 
00027        << "\" return type is \"" << methStack_.back().method().TypeOf().Name() 
00028        << "\" which is not convertible to double.";
00029   
00030   exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionVar(methStack_, retType)));
00031   methStack_.clear();
00032   typeStack_.resize(1);
00033 }
00034 
00035 void ExpressionVarSetter::lazyPush(const char *begin, const char *end) const {
00036   exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionLazyVar(lazyMethStack_)));
00037   lazyMethStack_.clear();
00038   typeStack_.resize(1);
00039 }
00040