CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ExpressionVarSetter.cc
Go to the documentation of this file.
5 #include <string>
6 using namespace reco::parser;
7 using namespace std;
8 
9 void ExpressionVarSetter::operator()(const char * begin, const char* end) const {
10  //std::cerr << "ExpressionVarSetter: Pushed [" << std::string(begin,end) << "]" << std::endl;
11  if (!methStack_.empty()) push(begin,end);
12  else if (!lazyMethStack_.empty()) lazyPush(begin,end);
13  else throw Exception(begin) << " Expression didn't parse neither hastily nor lazyly. This must not happen.\n";
14 }
15 
16 void ExpressionVarSetter::push(const char *begin, const char *end) const {
17  edm::TypeWithDict type = typeStack_.back();
18  method::TypeCode retType = reco::typeCode(type);
19  if(retType == method::invalid) {
20  throw Exception(begin)
21  << "member \"" << methStack_.back().methodName() << "\" has an invalid return type: \""
22  << methStack_.back().returnTypeName() << "\"";
23  }
24  if(!ExpressionVar::isValidReturnType(retType)) {
25  throw Exception(begin)
26  << "member \"" << methStack_.back().methodName()
27  << "\" return type is \"" << methStack_.back().returnTypeName()
28  << "\" which is not convertible to double.";
29  }
30 
31  exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionVar(methStack_, retType)));
32  methStack_.clear();
33  typeStack_.resize(1);
34 }
35 
36 void ExpressionVarSetter::lazyPush(const char *begin, const char *end) const {
37  exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionLazyVar(lazyMethStack_)));
38  lazyMethStack_.clear();
39  typeStack_.resize(1);
40 }
41 
type
Definition: HCALResponse.h:21
void operator()(const char *, const char *) const
void lazyPush(const char *, const char *) const
static bool isValidReturnType(method::TypeCode)
TypeCode typeCode(const edm::TypeWithDict &t)
Definition: returnType.cc:44
#define end
Definition: vmac.h:37
Evaluate an object&#39;s method or datamember (or chain of them) to get a number.
Definition: ExpressionVar.h:23
void push(const char *, const char *) const
#define begin
Definition: vmac.h:30