Example #1
0
VOIDPTRFUNC
CP_builtin_define(){


	OBJ env = ARG(0);
	OBJ argList = ARG(1);

	if( !ISCONS(argList) ){
		js_error("(define): expects at least  2 arguments", js_nil);
	}
	
	OBJ arg1 = CAR(argList);
	argList = CDR(argList);

	if( !ISCONS(argList) ){
		js_error("(define): expects at least  2 arguments", js_nil);
	}

	// case 1: define SYMBOL -> (define symbol expression)
	if( ISSYMBOL(arg1)) {
		OBJ arg2 = CAR(argList);
		argList = CDR(argList);
		VOIDPTRFUNC CP_builtin_define2();

		if( argList != js_nil ){
			js_error("(define): this form expects exactly 2 arguments", js_nil);
		}
		CREATE_LOCALS(1);
		SET_LOCAL(0, arg1);
		//printJStack(__FILE__,__LINE__,__FUNCTION__);
		DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
		CALL2(CP_js_eval, env, arg2, CP_builtin_define2);
	}
	// case 2: define CONS ( function ) -> (define (name args*) (body*) )
	if( ISCONS(arg1)){
		
		OBJ name = CAR(arg1);
		if( ISSYMBOL(name) ){
			OBJ formalArgList = CDR(arg1);
			OBJ bodyList = argList;
			OBJ newUDF;

			newUDF = newUserDefinedFunction("anonymous lambda", formalArgList, bodyList);
			newUDF->u.userDefinedFunction.numLocals = count_defines(bodyList);
			newUDF->u.userDefinedFunction.home = env;
			environmentPut(env, name, newUDF);
			//printJStack(__FILE__,__LINE__,__FUNCTION__);
			DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
			RETURN(js_void);
		}
	}
	error("define form unimplemented", __FILE__, __LINE__);
	// NOT REACHED
	return NULL;
}
Example #2
0
VOIDPTRFUNC
CP_builtin_if(){

	OBJ env = ARG(0);
	OBJ argList = ARG(1);

	OBJ condExpr, ifExpr, elseExpr = NULL;
	
	int numArgs = length(argList);
	if( numArgs == 2){
		// case 1: else-less if -> (if cond <expr>)
		elseExpr = js_nil;

	} else if( numArgs == 3){
		// case 2: regular if -> (if cond <ifExpr> <elseExpr>)
		elseExpr = CAR( CDR( CDR( argList )));
	} else {
		js_error("(if): expects 2 or 3 arguments", js_nil);
	}

	condExpr = CAR(argList); 
	ifExpr = CAR( CDR(argList));
	
	CREATE_LOCALS(2);
	SET_LOCAL(0, ifExpr);
	SET_LOCAL(1, elseExpr);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
	CALL2(CP_js_eval, env, condExpr, CP_builtin_if2);
}
Example #3
0
/**
 * Remove symbols from the statistics of the ancestors of this node in case that is necessary.
 * Symbols are removed from the ancestors if they only have the same symbols as the child node
 * (including the ones indicated in deletedChars).
 * @param[in] tree node of the tree.
 * @param[in] deletedChars bit vector indicating which characters have been erased from the node statistics.
 */
static void fixParents (fsmTree_t tree, BOOL *deletedChars) {
  Uint i; /*, numEscapes;*/
  fsmTree_t parTree = tree;
  BOOL newChars;

  while (!isRootFsmTree(parTree)) {
    parTree = parTree->parent->origin;
    newChars = False;

    for (i=0; i<parTree->totalSyms && !newChars; i++) {
      newChars |= parTree->count[i] > 1;
    }

    if (!newChars) { /* there are no new symbols */
      DEBUGCODE(printf("fixing %p\n", (void *)parTree));
      /*numEscapes = parTree->totalCount;*/
      parTree->totalCount = 0;
      for (i=0; i<parTree->totalSyms; i++) {  
	/*numEscapes -= parTree->count[i];*/
	if (deletedChars[alphaindex[parTree->symbols[i]]]) {
	  parTree->count[i] = 0;
	}
	else {
	  parTree->totalCount += parTree->count[i];
	}
      }

      /*numEscapes = numEscapes >> 1;
      if (numEscapes == 0) numEscapes = 1;  es necesario esto? 
      parTree->totalCount += numEscapes;*/
      parTree->totalCount *= 2;
    }
    else break;
  }
}
Example #4
0
int Opts_Initialize(void)
{
  int i;
  
  game_options = malloc(sizeof(game_option_type));
  global_options = malloc(sizeof(global_option_type));
  /* bail out if no struct */
  if (!game_options)
    return 0;

  /* set global program options */
  for (i = 0; i < NUM_GLOBAL_OPTS; ++i)
    global_options->iopts[i] = DEFAULT_GLOBAL_OPTS[i];
    
  /* set general game options */
  global_options->iopts[PER_USER_CONFIG] = DEFAULT_PER_USER_CONFIG;
  global_options->iopts[USE_SOUND] = DEFAULT_USE_SOUND;
  global_options->iopts[MENU_SOUND] = DEFAULT_MENU_SOUND;
  global_options->iopts[MENU_MUSIC] = DEFAULT_MENU_MUSIC;
  global_options->iopts[FULLSCREEN] = 0;
  global_options->iopts[USE_KEYPAD] = DEFAULT_USE_KEYPAD;
  global_options->iopts[USE_IGLOOS] = DEFAULT_USE_IGLOOS;
  strncpy(game_options->current_font_name, DEFAULT_FONT_NAME,
          sizeof(game_options->current_font_name));
  game_options->lan_mode = DEFAULT_LAN_MODE;
  game_options->use_bkgd = DEFAULT_USE_BKGD;
  game_options->help_mode = DEFAULT_HELP_MODE;
  game_options->demo_mode = DEFAULT_DEMO_MODE;
  game_options->oper_override = DEFAULT_OPER_OVERRIDE;
  game_options->allow_pause = DEFAULT_ALLOW_PAUSE;
  game_options->bonus_comet_interval = DEFAULT_BONUS_COMET_INTERVAL;
  game_options->bonus_speed_ratio = DEFAULT_BONUS_SPEED_RATIO;
  game_options->speed = DEFAULT_SPEED;
  game_options->allow_speedup = DEFAULT_ALLOW_SPEEDUP;
  game_options->speedup_factor = DEFAULT_SPEEDUP_FACTOR;
  game_options->max_speed = DEFAULT_MAX_SPEED;
  game_options->slow_after_wrong = DEFAULT_SLOW_AFTER_WRONG;
  game_options->starting_comets = DEFAULT_STARTING_COMETS;
  game_options->extra_comets_per_wave = DEFAULT_EXTRA_COMETS_PER_WAVE;
  game_options->max_comets = DEFAULT_MAX_COMETS;
  game_options->save_summary = DEFAULT_SAVE_SUMMARY;
  game_options->sound_hw_available = DEFAULT_SOUND_HW_AVAILABLE;
  game_options->use_feedback = DEFAULT_USE_FEEDBACK;
  game_options->danger_level = DEFAULT_DANGER_LEVEL;
  game_options->danger_level_speedup = DEFAULT_DANGER_LEVEL_SPEEDUP;
  game_options->danger_level_max = DEFAULT_DANGER_LEVEL_MAX;
  game_options->city_expl_handicap = DEFAULT_CITY_EXPL_HANDICAP;
  game_options->last_score = DEFAULT_LAST_SCORE;

  game_options->num_cities = DEFAULT_NUM_CITIES;   /* MUST BE AN EVEN NUMBER! */
  game_options->max_city_colors = DEFAULT_MAX_CITY_COLORS;

  DEBUGCODE(debug_options)
    print_game_options(stdout, 0);

  return 1;
}
Example #5
0
Bool CronC::Do(CronCallerE)
	{
	DEBUGCODE(MessageDat.Verify());

	Bool done = FALSE;

	if (Events && !Pause)
		{
		CronEventListS *StartEvent = OnEvent;

		WAITFORm(CronMutex);
		do
			{
			if (OnEvent->Event.CanDo(forceevent))
				{
				ExecutingEvent = OnEvent;

				repeatevent = !OnEvent->Event.Do() && repeatevent;

				ExecutingEvent = NULL;

				done = TRUE;
				}

			if (!repeatevent && (OnEvent = (CronEventListS *) getNextLL(OnEvent)) == NULL)
				{
				OnEvent = Events;
				}

			} while (!done && OnEvent != StartEvent);
		RELEASEm(CronMutex);
		}

#ifndef WINCIT
	if (!done)
		{
		DebugOut(52);

		CITWINDOW *w = ScreenSaver.IsOn() ? NULL : CitWindowsMsg(NULL, getmsg(19));

		Initport();

		if (w)
			{
			destroyCitWindow(w, FALSE);
			}

		return (FALSE);
		}

	doCR();
#endif

	return (TRUE);
	}
Example #6
0
VOIDPTRFUNC
CP_builtin_define2(){
	
	OBJ value = RETVAL;
	OBJ env = ARG(0);
	OBJ symbol = LOCAL(0);

	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
	environmentPut(env, symbol, value);
	RETURN(js_void);
}
Example #7
0
VOIDPTRFUNC
CP_builtin_quote(){

//	OBJ env = ARG(0);
	OBJ argList = ARG(1);

	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
	if( (!ISCONS(argList)) || ( CDR(argList) != js_nil) ){
		js_error("(quote): expects exactly 1 argument", js_nil);
	}
	RETURN( CAR(argList));
}
Example #8
0
VOIDPTRFUNC
CP_jREPL(){
	
	//fprintf(stdout, "\nStack in CP_jREPL:\n");
	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__));

	OBJ inputStream = ARG(0);

	OBJ expr;
	VOIDPTRFUNC CP_jREPL2();

	if( SP > 5) prompt_off();
	if(prompt_enabled) printf(CYN "JS> " RESET);
	expr = js_read(inputStream);				// R ead
	if( expr == js_eof ) RETURN( js_void );
	CALL2( CP_js_eval,globalEnvironment, expr, CP_jREPL2);	// E val
}
Example #9
0
/*
 *	CP_jREPL: read evaluate print loop using continuation passing
 */
OBJ
enterTrampoline1(OBJ input){
	
	//fprintf(stdout, "\nStack before Trampoline:\n");
	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__));
	VOIDPTRFUNC CP_jREPL();

	PUSH((OBJ)((INT)BP));
	PUSH((OBJ)((INT)AP));
	PUSH((OBJ)CP_jREPL);
	PUSH(NULL);	// last continuation
	AP = SP;
	BP = AP - 4;
	PUSH(input);
	VOIDPTRFUNC CP_jREPL();

	trampoline((VOIDPTRFUNC)CP_jREPL);

	return js_nil;
}
Example #10
0
void initialize_locale(const char* desired_loc)
{
    const char *s1, *s2, *s3, *s4;
    if(!desired_loc)
    {
        fprintf(stderr, "initialize_locale() - null desired_loc arg. \n");  
        return;
    }  

    s1 = setlocale(LC_ALL, desired_loc);
    s2 = bindtextdomain(PACKAGE, TUXLOCALE);
    s3 = bind_textdomain_codeset(PACKAGE, "UTF-8");
    s4 = textdomain(PACKAGE);

    strncpy(tuxmath_locale.setlocale_ret, s1, 64);
    strncpy(tuxmath_locale.bindtextdomain_ret, s2, 64);
    strncpy(tuxmath_locale.bind_textdomain_codeset_ret, s3, 64);
    strncpy(tuxmath_locale.textdomain_ret, s4, 64);

    DEBUGCODE(debug_setup) print_locale_info(stderr);
}
Example #11
0
static void rescale (fsmTree_t tree) {
  BOOL *charFlags, needToFix = False;
  Uint numEscapes, i;
  DEBUGCODE(printf("rescalo %p\n", (void *)tree));

  numEscapes = tree->totalCount; 
  tree->totalCount = 0; 
  CALLOC(charFlags, BOOL, alphasize);    

  for (i=0; i<tree->totalSyms; i++) {  
    if (tree->count[i] > 0) {
      numEscapes -= tree->count[i];
      tree->count[i] = tree->count[i] >> 1;
      if (tree->count[i] == 0) {
	charFlags[alphaindex[tree->symbols[i]]] = True;
	needToFix = True;
      }
      else {
	tree->totalCount += tree->count[i];
      }
    }
  }
Example #12
0
VOIDPTRFUNC
CP_builtin_if2(){

	OBJ env = ARG(0);
	
	OBJ condValue = RETVAL;
	OBJ ifExpr = LOCAL(0);
	OBJ elseExpr = LOCAL(1);
	
	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
	if (condValue == js_true){
		TAILCALL2(CP_js_eval, env, ifExpr);
	}
	if (condValue == js_false){
		TAILCALL2(CP_js_eval, env, elseExpr);
	}
	
	// TO-DO implement #t #f rules for all kind of OBJs
	js_error("(if): non-boolean condition value", condValue);
	//NOT REACHED
	return NULL;
}
Example #13
0
/* from titlescreen, to allow for user-login to occur.         */
void initialize_options_user(void)
{
    /* Read in user-specific settings, if desired.  By    */
    /* default, this restores settings from the player's last */
    /* game:                                                  */
    if (Opts_GetGlobalOpt(PER_USER_CONFIG))
    {
        if (!read_user_config_file(local_game))
        {
            fprintf(stderr, "\nCould not find user's config file.\n");
            /* can still proceed using hard-coded defaults.         */
        }

        /* If game being run for first time, try to write file: */
        if (!write_user_config_file(local_game))
        {
            fprintf(stderr, "\nUnable to write user's config file.\n");
        }
    }

    /* Read the lessons directory to determine which lesson   */
    /* files are available.                                   */
    if (!parse_lesson_file_directory())
        fprintf(stderr,"\nCould not parse the lesson file directory.\n");

    /* Now set up high score tables: */
    initialize_scores();
    if (!read_high_scores())
    {
        fprintf(stderr, "\nCould not find high score table.\n");
        /* (can still proceed).         */
    }

    DEBUGCODE(debug_setup)
        print_high_scores(stdout);
}
Example #14
0
VOIDPTRFUNC
CP_builtin_lambda(){
	
	OBJ env = ARG(0);
	OBJ argList = ARG(1);

	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__) );
	if( !ISCONS(argList) ){
		js_error("(lambda): expects at least 2 arguments", js_nil);
	}

	OBJ lambdaArgList = CAR(argList);
	if( ! (lambdaArgList == js_nil || ISCONS(lambdaArgList) )){
		js_error("(lambda): invalid argument list", lambdaArgList);
	}
	OBJ bodyList = CDR(argList);
	
	OBJ newUDF = newUserDefinedFunction( "anonymous lambda", lambdaArgList, bodyList);
	newUDF->u.userDefinedFunction.numLocals = count_defines(bodyList);
	newUDF->u.userDefinedFunction.home = env;

	RETURN(newUDF);
}
Example #15
0
int factoroids_init_graphics(void)
{
    int i;

    if(screen->h < 600 && screen->w < 800)
        zoom = 0.65;
    else
        zoom=(float)screen->w/(float)BASE_RES_X;

    DEBUGCODE(debug_factoroids)
        fprintf(stderr, "The zoom factor is: %f\n", zoom);

    /********   Set up properly scaled and optimized background surfaces: *********/
    /* NOTE - optimization code moved into LoadBothBkgds() so rest of program     */
    /* can take advantage of it - DSB                                             */

    T4K_LoadBothBkgds("factoroids/gbstars.png", &scaled_bkgd, &bkgd);

    if (bkgd == NULL || scaled_bkgd == NULL)
    {
        fprintf(stderr,
                "\nError: could not scale background\n");
        return 0;
    }

    /*************** Precalculating software rotation ***************/

    for(i = 0; i < NUM_OF_ROTO_IMGS; i++)
    {
        //rotozoomSurface (SDL_Surface *src, double angle, double zoom, int smooth);
        IMG_tuxship[i] = rotozoomSurface(images[IMG_SHIP01], i * DEG_PER_ROTATION, zoom, 1);
        IMG_tuxship_cloaked[i] = rotozoomSurface(images[IMG_SHIP_CLOAKED], i * DEG_PER_ROTATION, zoom, 1);
        IMG_tuxship_thrust[i] = rotozoomSurface(images[IMG_SHIP_THRUST], i * DEG_PER_ROTATION, zoom, 1);
        IMG_tuxship_thrust_cloaked[i] = rotozoomSurface(images[IMG_SHIP_THRUST_CLOAKED], i * DEG_PER_ROTATION, zoom, 1);

        if (IMG_tuxship[i] == NULL)
        {
            fprintf(stderr,
                    "\nError: rotozoomSurface() of images[IMG_SHIP01] for i = %d returned NULL\n", i);
            return 0;
        }

        IMG_asteroids1[i] = rotozoomSurface(images[IMG_ASTEROID1], i * DEG_PER_ROTATION, zoom, 1);

        if (IMG_asteroids1[i] == NULL)
        {
            fprintf(stderr,
                    "\nError: rotozoomSurface() of images[IMG_ASTEROID1] for i = %d returned NULL\n", i);
            return 0;
        }

        IMG_asteroids2[i] = rotozoomSurface(images[IMG_ASTEROID2], i*DEG_PER_ROTATION, zoom, 1);

        if (IMG_asteroids2[i] == NULL)
        {
            fprintf(stderr,
                    "\nError: rotozoomSurface() of images[IMG_ASTEROID2] for i = %d returned NULL\n", i);
            return 0;
        }
    }

    /* Create zoomed and scaled ship image for "lives" counter */
    IMG_lives_ship = rotozoomSurface(images[IMG_SHIP_CLOAKED], 90, zoom * 0.7, 1);
}
Example #16
0
/**
 * Decompresses the data in an input file and writes it in a new file.
 * @param[in] filename name and path of the input file.
 * @param[in] output name and path of the output file.
 * @param[in] see if see will be used.
 */
static void unzip(char *filename, char *output, BOOL see) {
  FILE *output_file, *compressed_file;
  int i, header, parts, part;
  Uint textlen = 0;
  decoderTree_t tree;

  initDecoderTreeStack();

  compressed_file = fopen(filename, "rb");
  if (!compressed_file) {
    perror( "Could not open input file");
    exit(1);
  }

  if (!output) {
    output = strrchr(filename, '.');
    if (output) {
      *output = '\0';
    } 
    else {
      strcat(filename, ".out");
    }
    output = filename;
  }

  output_file = fopen(output, "wb");
  if (!output_file) {
    perror( "Could not open output file");
    exit(1);
  }

  /* check magic */
  header = getc(compressed_file) << 8;
  header += getc(compressed_file);
  if (header != MAGIC) {
    fprintf(stderr, "Invalid compressed file\n");
    exit(1);
  }

  /* read parts */
  parts = getc(compressed_file);

  initialize_input_bitstream();
  initialize_arithmetic_decoder(compressed_file);

  readAlphabet(compressed_file);

  setMaxCount();

  for (part = 1; part <= parts; part++) {  
    printf("---------- part %d ---------------\n", part);
    /* read textlen */
    for (textlen=0, i=3; i>=0; i--) {
      textlen += readByte(compressed_file) << (8 * i);
    }

    /*if (part == 1) {*/
      tree = readDecoderTree(compressed_file);
      /*}*/

    printf("Tree built\n");
    printf("Textlen: %ld\n", textlen);
    printf("FSM...\n"); 
    /*if (part == 1) {*/
    DEBUGCODE(printDecoderTree(tree));
    makeDecoderFsm(tree);
    DEBUGCODE(printDecoderTree(tree));
      /*}*/

    printf("Decoding...\n");
    decode(tree, textlen, compressed_file, output_file, see);
  }
  /*freeDecoderTree(tree);*/
  fclose(compressed_file);
  fclose(output_file);
}
Example #17
0
/**
 * Compresses the input text and writes the compressed data to a file.
 * @param[in] filename name and path of the file to compress.
 * @param[in] compressed name and path of the compressed output file.
 * @param[in] algorithm the algorithm that will be used to build the suffix tree (Ukkonnen or Kurtz).
 * @param[in] see if see will be used.
 */
static void zip(char *filename, char *compressed, BOOL algorithm, int parts, BOOL see) {
  Uchar *origText, *prevText = NULL;
  Uint origTextLen, partTextLen, currentTextLen;
  FILE *compressed_file;
  int i, part;
  fsmTree_t stree = NULL, prevTree = NULL;
  BOOL alloc = False;

#ifdef WIN32
  HANDLE hndl;
  origText = (Uchar *) file2String(filename, &origTextLen, &hndl);
#else
  origText = (Uchar *) file2String(filename, &origTextLen);
#endif

  if(origText == NULL) {
    fprintf(stderr,"Cannot open file %s\n", filename);
    exit(EXIT_FAILURE);
  }
  /*if(textLen > MAXTEXTLEN)
    {
    fprintf(stderr,"Sorry, textlen = %lu is larger than maximal textlen = %lu\n",
    (Showuint) textLen,(Showuint) MAXTEXTLEN);
    exit(EXIT_FAILURE);
    }*/

  if (!compressed) {
    CALLOC(compressed, Uchar, strlen(filename) + 5);
    strcpy(compressed, filename);
    strcat(compressed, ".ctx");
    alloc = True;
  }

  compressed_file = fopen(compressed, "wb");
  if (!compressed_file) {
    printf( "Could not open output file");
    exit(1);
  }
  if (alloc) FREE(compressed);

  buildAlpha(origText, origTextLen);
  printf ("Alphasize: %ld\n", alphasize);
  printf("Algorithm %d\n", algorithm);

  setMaxCount();

  /* write magic number */
  putc(MAGIC >> 8, compressed_file);
  putc(MAGIC, compressed_file);
  /* write # of parts */
  putc(parts, compressed_file);

  initialize_output_bitstream();
  initialize_arithmetic_encoder();

  writeAlphabet(compressed_file);

  currentTextLen = 0;
  for (part = 1; part <= parts; part++) {
    printf("---------- part %d ---------------\n", part);
    if (part != parts) {
      partTextLen = floor(origTextLen / parts);
    }
    else {
      partTextLen = origTextLen - (floor(origTextLen / parts) * (parts - 1));
    }
 
    if (part > 1) {
      prevText = text;
      prevTree = stree;
    }

    textlen = partTextLen;
    CALLOC(text, Uchar, textlen);
    reversestring(origText + currentTextLen, textlen, text);
    
    if (algorithm == UKKONEN) {
      suffixTree_t tree = initSuffixTree();
      buildSuffixTree(tree);
      printf("Tree built\n");
      pruneSuffixTree(tree);
      stree = fsmSuffixTree(tree);   
    }
    else {
      stree = buildSTree();
      printf("Tree built\n");
    }

    /*if (part > 1) {
      copyStatistics(prevTree, stree, prevText);
      FREE(prevText);
      freeFsmTree(prevTree);
    }*/

    DEBUGCODE(printf("gamma hits: %d gamma Misses: %d\n", getHits(), getMisses()));
    printf("height: %ld\n", getHeight(stree));

    /* write textlen */
    for (i=3; i>=0; i--) {
      writeByte(textlen >> (8 * i), compressed_file);
    }
    printf ("Textlen: %ld\n", textlen);
    writeFsmTree(stree, compressed_file);
    printf("FSM...\n");
    makeFsm(stree);
    DEBUGCODE(printFsmTree(stree));
    printf("Encoding...\n");

    encode(stree, compressed_file, origText + currentTextLen, partTextLen, see);
    
    currentTextLen += partTextLen;
  }

  FREE(text);
  freeFsmTree(stree);

  flush_arithmetic_encoder(compressed_file);
  flush_output_bitstream(compressed_file);

#ifdef WIN32
  freetextspace(origText, hndl);
#else
  freetextspace(origText, origTextLen);
#endif

  fclose(compressed_file);
}
Example #18
0
VOIDPTRFUNC
CP_jREPL2(){
	
	//fprintf(stdout, "\nStack in CP_jREPL2:\n");
	//printJStack(__FILE__,__LINE__,__FUNCTION__);
	DEBUGCODE(PRINT_STACK->state, printJStack(__FILE__,__LINE__,__FUNCTION__));

	OBJ result = RETVAL;

#ifdef DEBUG
	if( (SP <= 5) || PRINT_INCLUDE->state){
		printIndent(indentLevelForInclude);
#else
	if( (SP <= 5)) {
#endif
		js_print(stdout, result, 1);		// P rint
		printf("\n");
	}
							// L oop
	OBJ inputStream = ARG(0);
	TAILCALL1((VOIDPTRFUNC)CP_jREPL, inputStream);	
}

int
main() {
	initSymbolTable();
	initializeWellKnownObjects();
	initJStack();
#ifdef DEBUG
	initDebugOptions();	
	initGlobalEnvironment();
	setupInitialEnvironment();
	setupBuiltinSyntax();
	selftest();
#endif
	
	printf("hello friend...\n");
	initGlobalEnvironment();
	setupInitialEnvironment();
	printf("Welcome to (JS)cheme\n");

	if( setjmp(whereEverythingWasFine) ){
#ifdef DEBUG
		indentLevel = 0;
		indentLevelForInclude = 0;
#endif
		// reset Stack index
		SP = 0;
		AP = 0;
		BP = 0;
		prompt_on();
		printf("back in wonderland\n");
	}	
	printf("...starting a REPL for you.\n");
	OBJ inputStream = newFileStream(stdin);
	
#ifdef DEBUG
	if(CONTINUATION_PASSING->state){
		CP_setupBuiltinSyntax();
		enterTrampoline1(inputStream);
	}else{
		setupBuiltinSyntax();
		jREPL(inputStream);
	}
#else 
	//jREPL(inputStream);
	CP_setupBuiltinSyntax();
	enterTrampoline1(inputStream);
#endif

	return 0;
}