Beispiel #1
0
 void insert(symbol const & name, param_kind k, char const * descr) {
     SASSERT(!name.is_numerical());
     info i;
     if (m_info.find(name, i)) {
         SASSERT(i.first == k);
         return;
     }
     m_info.insert(name, info(k, descr));
     m_names.push_back(name);
 }
Beispiel #2
0
 // unfortunately, params_ref is not thread safe
 // so better create a local copy of the parameters.
 params_ref get_module(symbol const & module_name) {
     params_ref result;
     params_ref * ps = nullptr;
     #pragma omp critical (gparams)
     {
         if (m_module_params.find(module_name, ps)) {
             result.copy(*ps);
         }
     }
     return result;
 }
Beispiel #3
0
 void register_module(char const * module_name, param_descrs * d) {
     // Don't need synchronization here, this method
     // is invoked from check_registered that is already protected.
     symbol s(module_name);
     param_descrs * old_d;
     if (m_module_param_descrs.find(s, old_d)) {
         old_d->copy(*d);
         dealloc(d);
     }
     else {
         m_module_param_descrs.insert(s, d);
     }
 }
Beispiel #4
0
 params_ref & get_params(symbol const & mod_name) {
     if (mod_name == symbol::null) {
         return m_params;
     }
     else {
         params_ref * p = nullptr;
         if (!m_module_params.find(mod_name, p)) {
             p = alloc(params_ref);
             m_module_params.insert(mod_name, p);
         }
         SASSERT(p != 0);
         return *p;
     }
 }
Beispiel #5
0
/*
 * Given a word, add it to the dictionary, increment its count
 * and add the line number on which it was found.
 */
void processWord(string& word, dictionary& dict, int lineNumber) {
    if (word.size() > 0) {
        dictionary::iterator itr = dict.find(word);
        if (itr == dict.end()) {
            dict[word] = pair<int, vector<int> >(1, vector<int>(1, lineNumber));
        } else {
            pair<int, vector<int> > value = itr->second;
            ++(value.first);
            value.second.push_back(lineNumber);

            // Update the dictionary reference
            dict[word] = value;
        }
    }
}
Beispiel #6
0
 std::string get_value(char const * name) {
     std::string r;
     bool error = false;
     std::string error_msg;
     #pragma omp critical (gparams)
     {
         try {
             symbol m, p;
             normalize(name, m, p);
             if (m == symbol::null) {
                 if (m_params.contains(p)) {
                     r = get_value(m_params, p);
                 }
                 else {
                     r = get_default(get_param_descrs(), p, m);
                 }
             }
             else {
                 params_ref * ps = nullptr;
                 if (m_module_params.find(m, ps) && ps->contains(p)) {
                     r = get_value(*ps, p);
                 }
                 else {
                     param_descrs * d;
                     if (get_module_param_descrs().find(m, d)) {
                         r = get_default(*d, p, m);
                     }
                     else {
                         std::stringstream strm;
                         strm << "unknown module '" << m << "'";
                         throw exception(strm.str());
                     }
                 }
             }
         }
         catch (z3_exception & ex) {
             // Exception cannot cross critical section boundaries.
             error = true;
             error_msg = ex.msg();
         }
     }
     if (error)
         throw exception(std::move(error_msg));
     return r;
 }
Beispiel #7
0
 void display(std::ostream & out, unsigned indent) const {
     svector<symbol> names;
     dictionary<info>::iterator it  = m_info.begin();
     dictionary<info>::iterator end = m_info.end();
     for (; it != end; ++it) {
         names.push_back(it->m_key);
     }
     std::sort(names.begin(), names.end(), lt());
     svector<symbol>::iterator it2  = names.begin();
     svector<symbol>::iterator end2 = names.end();
     for (; it2 != end2; ++it2) {
         for (unsigned i = 0; i < indent; i++) out << " ";
         out << *it2;
         info d;
         d.second = 0;
         m_info.find(*it2, d);
         SASSERT(d.second);
         out << " (" << d.first << ") " << d.second << "\n";
     }
 }
Beispiel #8
0
 void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) const {
     svector<symbol> names;
     dictionary<info>::iterator it  = m_info.begin();
     dictionary<info>::iterator end = m_info.end();
     for (; it != end; ++it) {
         names.push_back(it->m_key);
     }
     std::sort(names.begin(), names.end(), lt());
     svector<symbol>::iterator it2  = names.begin();
     svector<symbol>::iterator end2 = names.end();
     for (; it2 != end2; ++it2) {
         for (unsigned i = 0; i < indent; i++) out << " ";
         if (smt2_style)
             out << ':';
         char const * s = it2->bare_str();
         unsigned n = static_cast<unsigned>(strlen(s));
         for (unsigned i = 0; i < n; i++) {
             if (smt2_style && s[i] == '_')
                 out << '-';
             else if (!smt2_style && s[i] == '-')
                 out << '_';
             else if (s[i] >= 'A' && s[i] <= 'Z')
                 out << (s[i] - 'A' + 'a');
             else 
                 out << s[i];
         }
         info d;
         m_info.find(*it2, d);
         SASSERT(d.m_descr);
         out << " (" << d.m_kind << ")";
         if (include_descr)
             out << " " << d.m_descr;
         if (d.m_default != 0)
             out << " (default: " << d.m_default << ")";
         out << "\n";
     }
 }
Beispiel #9
0
 param_kind get_kind(symbol const & name) const {
     info i;
     if (m_info.find(name, i))
         return i.first;
     return CPK_INVALID;
 }
Beispiel #10
0
 char const * get_default(symbol const & name) const {
     info i;
     if (m_info.find(name, i))
         return i.m_default;
     return 0;
 }
Beispiel #11
0
 char const* get_module(symbol const& name) const {
     info i;
     if (m_info.find(name, i)) 
         return i.m_module;
     return 0;
 }