Пример #1
0
int main() {


	setbuf(stdout, NULL);

	start_interpreter();
//	char ss [30];
//	Stack s = init_stack();
//	scanf("%s" , ss);
//	doIntCommand(s , ss);
//	scanf("%s" , ss);
//	doIntCommand(s , ss);
//	doPComand(s);
//	push(s ,"1130" ,INTEGER );
//	push (s , "c" , CHAR);
//	push(s ,"11301" ,INTEGER );
//	push(s ,"1132" ,INTEGER );
//	push(s ,"1133" ,INTEGER );

//	printStack(s);
//

//	printStack(s);
//
//	printf("%s\n" , pop(s)->data);
//	printf("%s\n" , pop(s)->data);


	return EXIT_SUCCESS;
}
Пример #2
0
/* Initial entry point to RIP. This initialises all of the modules present,
   and then calls the interpreter initialisation. */
HqBool RIPCALL SwStart(SWSTART *params)
{
  Bool result ;

#ifdef FPEXCEPTION
  /* Ensure fp exceptions enabled when the RIP is run in a different thread to
   * the one used to initialise it */
  enable_fp_exceptions();
#endif /* FPEXCEPTION */

  /* One way or another SwInit is *ALWAYS* called before
     SwStart(). */
  if ( core_init_state == CORE_NOT_INITIALISED ) {
    /* If SwInit fails, it calls rip_finish() */
    if ( !SwInit(params) )
      return FALSE ;
  }

  if ( core_init_state != CORE_DONE_SWINIT ) {
    HQFAIL("SwStart called with core in inconsistent state") ;
    return FALSE ;
  }

  /* Set this parameter again, in case it was only supplied to SwStart(). */
  set_swstart_must_return(params) ;

  core_init_state = CORE_DOING_SWSTART ;

  /* Restart init recursion and accumulated error numbers */
  core_init_error = CORE_BASE_MODULE_SWEXIT ;

  result = core_swstart_run(init_functions, NUM_ARRAY_ITEMS(init_functions),
                            params) ;

  HQASSERT(core_init_error < CORE_BASE_SWEXIT,
           "Exit code range for modules needs to be made bigger") ;

  if ( !result ) {
    HQASSERT(core_init_state == CORE_NOT_INITIALISED,
             "SwStart failure didn't clean up properly") ;
    return FALSE ;
  }

  core_init_state = CORE_STARTING_INTERPRETER ;

  /* We don't care about the return status of the interpreter. It
     takes care of error handling itself. It also deals with the calls
     to dispatch_SwExit() under any error condition which may
     arise. */
  start_interpreter() ;

  /* If we get this far there are two scenarios:

     a. start_interpreter has returned raising an error condition
     itself (i.e. It has called dispatch_SwExit()).

     b. Is returning cleanly under no error condition.

     Since we don't know which, we will invoke a non-error call to
     dispatch_SwExit(). This is OK because dispatch_SwExit() protects
     itself when called multiple times ensuring the client only gets
     to see the first dispatch. */
  rip_finish() ;

  /* Make sure client always gets a call to SwExit() under all
     conditions. */
  if (exiting_rip_cleanly) {
    (void)dispatch_SwExit(0, NULL) ;
    return TRUE ;
  }

  /* The only way start_interpreter will return is if
     exiting_rip_cleanly is TRUE which is caught above. */
  HQFAIL("Should NEVER reach here.") ;

  /* If there is a bug in the code and the above assert fires (because
     of a bug in the RIP), the function will return anyway. This is
     the best we can do at this stage and release builds should
     continue to work. */
  return dispatch_SwExit(1, "exiting_rip_cleanly protocol error.") ;
}