예제 #1
0
int main(int argc, char **argv)
#endif
{
  int BootMode;
  int i;
  YAP_init_args init_args;
  BootMode = init_standard_system(argc, argv, &init_args);
  if (BootMode == YAP_BOOT_ERROR) {
    fprintf(stderr, "[ FATAL ERROR: could not find saved state ]\n");
    exit(1);
  }
  /* Begin preprocessor code */
  if (BootMode != YAP_BOOT_FROM_SAVED_STACKS) {
    // process the definitions
    for (i = 0; i < init_args.def_c; ++i) {
      YAP_Term t_args[2], t_goal;
      t_args[0] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_var[i]));
      t_args[1] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_value[i]));
      t_goal = YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("ypp_define"), 2), 2,
                              t_args);
      YAP_RunGoalOnce(t_goal);
    }
  }

  YAP_Reset(YAP_FULL_RESET);
  /* End preprocessor code */

  exec_top_level(BootMode, &init_args);

  return (0);
}
예제 #2
0
파일: yap.c 프로젝트: jnorthrup/yap-6.3
int
main (int argc, char **argv)
#endif
{
  int BootMode;
  YAP_init_args init_args;
  int i;

#if DEBUG_LOCKS
  char buf[1024];
  sprintf(buf, "/tmp/yap%d", getpid());
  debugf= fopen(buf, "w");
  if (!debugf) fprintf(stderr,"ERROR %s\n", strerror(errno));
  setvbuf( debugf,NULL, _IOLBF, 1024);
#endif
  BootMode = init_standard_system(argc, argv, &init_args);
  if (BootMode == YAP_BOOT_ERROR) {
    fprintf(stderr,"[ FATAL ERROR: could not find saved state ]\n");
    exit(1);
  }
  /* Begin preprocessor code */
  if (BootMode != YAP_BOOT_FROM_SAVED_STACKS) {
    // process the definitions
    for(i=0;i<init_args.def_c;++i) {
      YAP_Term t_args[2],t_goal;
      t_args[0] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_var[i]));
      t_args[1] = YAP_MkAtomTerm(YAP_LookupAtom(init_args.def_value[i])); 
      t_goal  = YAP_MkApplTerm(YAP_MkFunctor(YAP_LookupAtom("ypp_define"),2), 2, t_args); 
      YAP_RunGoalOnce(t_goal);
    }
    
  }
  YAP_Reset( YAP_FULL_RESET );
  /* End preprocessor code */

  exec_top_level(BootMode, &init_args);

  return(0);
}
예제 #3
0
static void exec_top_level(int BootMode, YAP_init_args *iap) {
  YAP_Term atomfalse;
  YAP_Atom livegoal;

  if (BootMode == YAP_BOOT_FROM_SAVED_STACKS) {
    /* continue executing from the frozen stacks */
    YAP_ContinueGoal();
  }
  livegoal = YAP_FullLookupAtom("$live");
  /* the top-level is now ready */

  /* read it before case someone, that is, Ashwin, hides
     the atom false away ;-).
  */
  atomfalse = YAP_MkAtomTerm(YAP_FullLookupAtom("$false"));
  while (YAP_GetValue(livegoal) != atomfalse) {
    YAP_Reset(YAP_FULL_RESET);
    do_top_goal(YAP_MkAtomTerm(livegoal));
    livegoal = YAP_FullLookupAtom("$live");
  }
  YAP_Exit(EXIT_SUCCESS);
}