Esempio n. 1
0
void check_generic_arguments(expression args, typelist gparms)
{
  expression arg;
  typelist_scanner scan_gparms;

  typelist_scan(gparms, &scan_gparms);
  scan_expression (arg, args)
    {
      location l = arg->location;
      type gparm_type = typelist_next(&scan_gparms);

      if (!gparm_type)
	{
	  error_with_location(l, "too many arguments");
	  return;
	}

      if (arg->type == error_type || !check_constant_once(arg, cst_numerical))
	continue;

      if (!arg->cst || !constant_integral(arg->cst))
	error_with_location(l, "constant expression expected");
      else
	{
	  if (!cval_inrange(arg->cst->cval, gparm_type))
	    error_with_location(l, "constant out of range for argument type");
	}
    }
Esempio n. 2
0
void load_scheduler(void)
{
  scheduler = load(l_component, toplevel_location, scheduler_name, FALSE);
  if (scheduler_name)
    {
      data_declaration intf = env_lookup(scheduler->env->id_env,
					 scheduler_interface_name, TRUE);

      /* Check interface for validity. It must be the provided, have a
	 single parameter and be the right interface type.
	 Also, no generic interfaces please. */
      if (intf && intf->kind == decl_interface_ref && !intf->required &&
	  intf->gparms && !intf->itype->abstract &&
	  !strcmp(intf->itype->name, scheduler_interfacedef_name))
	{
	  typelist_scanner dummy;

	  typelist_scan(intf->gparms, &dummy);
	  if (typelist_next(&dummy) && !typelist_next(&dummy))
	    scheduler_interface = intf;
	}
      if (!scheduler_interface)
	error_with_location(toplevel_location,
			    "Scheduler `%s' has no scheduling interface named `%s'",
			    scheduler_name, scheduler_interface_name);
    }
}