예제 #1
0
파일: ast_call.c 프로젝트: stesla/csci4700
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);
    }
}
예제 #2
0
void *
retrieve_parsed_object (struct symtab *symtab, enum toplevel_type tp,
			str_ptr name)
{
  obj_t *obj;

  obj = symbol_table_find (symtab, name);

  if (obj == NULL)
    {
      notify_error_msg (SCRIPT_ERROR, "default %s not defined",
			tl_type_name[tp]);
      return NULL;
    }

  if (obj->type != tp)
    {
      notify_error_msg (SCRIPT_ERROR, "default %s is invalid",
			tl_type_name[tp]);
      return NULL;
    }

  return obj->cont.generic;
}