コード例 #1
0
ファイル: nesc-component.c プロジェクト: HengeSense/nesc
void copy_interface_functions(region r, nesc_declaration container,
			      data_declaration iref, environment fns)
{
  environment icopy = new_environment(r, NULL, TRUE, FALSE);
  env_scanner scanif;
  const char *fnname;
  void *fnentry;

  env_scan(fns->id_env, &scanif);
  while (env_next(&scanif, &fnname, &fnentry))
    {
      data_declaration fndecl = fnentry, fncopy;

      /* Strings acquire a magic_string decl which we don't care about
	 legal example: 
	  command int (*init())[sizeof "aa"];
      */
      if (fndecl->kind == decl_magic_string)
	continue;

      fncopy = declare(icopy, fndecl, FALSE);
      fncopy->fn_uses = NULL;
      fncopy->nuses = NULL;
      fncopy->instanceof = fndecl;
      fncopy->container = container;
      fncopy->interface = iref;
      /* required events and provided commands are defined */
      fncopy->defined = (fncopy->ftype == function_command) ^ iref->required;
    }

  iref->functions = icopy;
}
コード例 #2
0
ファイル: runtime.c プロジェクト: sjf/rustle
environ* setup_main_environment() {
  none_object.type  = T_NONE;
  true_object.type  = T_TRUE;
  false_object.type = T_FALSE;
  null_object.type  = T_NULL;

  init_env(&builtins);
  add_builtins_to_env(&builtins);

  return new_environment(&builtins);
}
コード例 #3
0
ファイル: runtime.c プロジェクト: sjf/rustle
object *call_proc(object *theproc, environ *env, 
                  object **args, int arglen) {
  CHECK_TYPE_PROC(theproc);
  if (theproc->val.proc.builtin) {
    return call_builtin1(theproc, args, arglen);
  } else {
    // Restore the environment that was available where the
    // function was defined.
    // Create new namespace for this invocation of the function.
    environ *new_env = new_environment(theproc->val.proc.closure);
    // Check function arity matches call
    check_arity(theproc, arglen);
    // Call function
    return ((FP) theproc->val.proc.func)(new_env, args, arglen);
  }
}