symbol_data const & find(const char * str, size_t strlen)
        {
            mutex.lock_shared();
            lookup_result_type lookup_result = symbol_lookup(str);
            mutex.unlock_shared();
            if (lookup_result.second)
                return *lookup_result.first;

            boost::unique_lock<nova::nonrecursive_rw_mutex> lock(mutex);
            lookup_result = symbol_lookup(str);
            if (lookup_result.second)
                return *lookup_result.first;

            std::pair<table_type::iterator, bool> inserted = table.insert(symbol_data(duplicate_string(str, strlen)));
            assert(inserted.second);
            return *inserted.first;
        }
Exemple #2
0
static void check_functions(NODE *node, SYMBOLS *symbols)
{
  const char *id = ast_to_s(S(node).func);
  NODE *arg = S(node).args;
  NODE *formal;
  int size_diff;
  S(node).symbol = symbol_table_find(symbols, id);
  formal = (NODE *) symbol_data(S(node).symbol);
  size_diff = ast_list_length(arg) - ast_list_length(formal);
  if (size_diff < 0)
    {
      fprintf(stderr, "Too few parameters in call to %s\n",
              symbol_id(S(node).symbol));
      exit(1);
    }
  else if (size_diff > 0)
    {
      fprintf(stderr, "Too many parameters in call to %s\n",
              symbol_id(S(node).symbol));
      exit(1);
    }
}