Exemple #1
0
int main()
{
  printf("allocating continuation\n");
  cont = create_cont();

  int age = 10;
  calltest(age);

  // we've now made a "function" out of the continuation; we are now at liberty
  // to call it as many times as we want, each time returning through all
  // functions involved between root and reify.
  do {
    reinstate(root, cont, --age);
  } while (age>0);

  printf("done\n");
  return 0;
}
Exemple #2
0
/*
** 'recover_program' is called to verify that the program at 'page'
** is legal. It resets the various program pointers if it is, or
** flags the program as invalid if not (after resetting the various
** pointer to 'safe' values)
*/
void recover_program(void) {
  byte *bp = NULL;
  if (basicvars.misc_flags.validsaved) {	/* Only check if the command 'new' has been used */
    reinstate();		/* Restore start of program */
    bp = basicvars.start;
    basicvars.misc_flags.validsaved = isvalidprog();
  }
  if (basicvars.misc_flags.validsaved) {	/* Old program is okay */
    while (!AT_PROGEND(bp)) bp+=get_linelen(bp);	/* Find end */
    basicvars.top = bp;
    adjust_heaplimits();
  }
  else {	/* Program is not valid - Ensure everything is set to safe values */
    clear_varlists();
    clear_strings();
    clear_heap();
    basicvars.misc_flags.badprogram = TRUE;
    save_lineno(basicvars.start, ENDLINENO);
    basicvars.current = basicvars.datacur = basicvars.top = basicvars.page+MARKERSIZE;
    adjust_heaplimits();
    error(ERR_BADPROG);
  }
}