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
00009 void ExpressionVarSetter::operator()(const char * begin, const char* end) const {
00010
00011 if (!methStack_.empty()) push(begin,end);
00012 else if (!lazyMethStack_.empty()) lazyPush(begin,end);
00013 else throw Exception(begin) << " Expression didn't parse neither hastily nor lazyly. This must not happen.\n";
00014 }
00015
00016 void ExpressionVarSetter::push(const char *begin, const char *end) const {
00017 edm::TypeWithDict type = typeStack_.back();
00018 method::TypeCode retType = reco::typeCode(type);
00019 if(retType == method::invalid) {
00020 throw Exception(begin)
00021 << "member \"" << methStack_.back().methodName() << "\" has an invalid return type: \""
00022 << methStack_.back().returnTypeName() << "\"";
00023 }
00024 if(!ExpressionVar::isValidReturnType(retType)) {
00025 throw Exception(begin)
00026 << "member \"" << methStack_.back().methodName()
00027 << "\" return type is \"" << methStack_.back().returnTypeName()
00028 << "\" which is not convertible to double.";
00029 }
00030
00031 exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionVar(methStack_, retType)));
00032 methStack_.clear();
00033 typeStack_.resize(1);
00034 }
00035
00036 void ExpressionVarSetter::lazyPush(const char *begin, const char *end) const {
00037 exprStack_.push_back(boost::shared_ptr<ExpressionBase>(new ExpressionLazyVar(lazyMethStack_)));
00038 lazyMethStack_.clear();
00039 typeStack_.resize(1);
00040 }
00041