Exemplo n.º 1
0
void create_jack_plugins(void){
  static bool has_inited = false;
  if (has_inited==false){
    init_types();
    has_inited = true;
  }
  
  stereo_in_type.data = g_jack_client;
  PR_add_plugin_type(&stereo_in_type);

  jack8_in_type.data = g_jack_client;
  PR_add_plugin_type(&jack8_in_type);

  stereo_out_type.data = g_jack_client;
  PR_add_plugin_type(&stereo_out_type);

  jack8_out_type.data = g_jack_client;
  PR_add_plugin_type(&jack8_out_type);

  //PR_add_menu_entry(PluginMenuEntry::separator());
  
  system_in_type.data = g_jack_client;
  PR_add_plugin_type(&system_in_type);

  system_in_type8.data = g_jack_client;
  PR_add_plugin_type(&system_in_type8);

  system_out_type.data = g_jack_client;
  PR_add_plugin_type(&system_out_type);

  system_out_type8.data = g_jack_client;
  PR_add_plugin_type(&system_out_type8);
}
Exemplo n.º 2
0
int	synthaxe_error(char *str)
{
  char  *tab_synthaxe[20];

  int   i;
  int   alright;

  alright = 0;
  i = 0;
  init_types(tab_synthaxe);
  early_space(str);
  while (tab_synthaxe[i] != NULL)
    {
      if (strncmp(str, tab_synthaxe[i], strlen(tab_synthaxe[i])) == 0)
	{
	  alright = 1;
	  printf("Déclaration de la %s %s de type %s\n",
		 get_parenthesis(get_name(str)) ? "variable" : "fonction",
		 get_name(str), get_types(str,tab_synthaxe));
	  break;
	}
      i++;
    }
  if (alright == 0)
    return (fprintf(stderr, "%s n'est pas un type valide \n", str));
  return (check_integrity(str, strlen(tab_synthaxe[i])));
}
Exemplo n.º 3
0
  void init()
  {
    InitializeNativeTarget();
	master.version = 0.9;
    master.Program = new Module("Hylas Lisp",Context);
    master.Engine = ExecutionEngine::createJIT(master.Program);
    master.Loader = new Linker("Hylas Lisp",master.Program);
    master.Loader->addSystemPaths();
    master.allow_RedefineMacros = true;
    master.allow_RedefineWordMacros = true;
    master.allow_RedefinePrePostfixes = true;
    master.allow_RedefineFunctions = false;
    master.Colorscheme = defaultColorscheme();
    master.CSS = defaultCSS();
    master.errormode = NormalError;
    init_stdlib();
    init_types();
    init_optimizer();
    master.Engine =  EngineBuilder(master.Program).create();
	try
	{
	  ifstream base("src/base.hylas");
	  if(!base.good())
		nerror("Could not find base.hylas. You will not have print functions for the basic types.");
	  stringstream file;
	  file << base.rdbuf();
	  JIT(Compile(readString(file.str())));
	  Run();
	}
	catch(exception except)
    {
      cerr << getError() << endl;
	  exit(-1);
    }
  }
Exemplo n.º 4
0
static ModuleTypeList *find_type(module_init_type type)
{
    ModuleTypeList *l;

    init_types();

    l = &init_type_list[type];

    return l;
}
Exemplo n.º 5
0
int main(void) {
    type_t tau;

    init_type_table(&types, 0);
    init_variables();
    init_types();

    // pair(A) = (tuple A A)
    tau = pair_type(var[0], var[0]);
    test_macro("pair", 1, var, tau);

    // triple(B) = (tuple B B B)
    tau = triple_type(var[1], var[1], var[1]);
    test_macro("triple", 1, var+1, tau);

    // test(C, D) = bool
    test_macro("test", 2, var+2, base[0]);

    // fun(E, F) = (-> (tuple E E) F)
    tau = pair_type(var[4], var[4]);
    tau = function_type(&types, var[5], 1, &tau);
    test_macro("fun", 2, var+4, tau);

    // two constructors
    test_constructor("mk_type2", 2);
    test_constructor("mk_type3", 3);

    printf("\n====== TYPES ========\n");
    print_type_table(stdout, &types);
    printf("\n===== MACROS ========\n");
    print_type_macros(stdout, &types);
    printf("===\n\n");

    // creation after remove
    // vector[G] = (-> int G)
    tau = int_type(&types);
    tau = function_type(&types, var[6], 1, &tau);
    test_macro("vector", 1, var+6, tau);

    // matrix[H] = (-> int int H)
    tau = int_type(&types);
    tau = binary_ftype(tau, tau, var[7]);
    test_macro("matrix", 1, var+7, tau);

    printf("\n====== TYPES ========\n");
    print_type_table(stdout, &types);
    printf("\n===== MACROS ========\n");
    print_type_macros(stdout, &types);
    printf("===\n\n");

    delete_type_table(&types);

    return 0;
}
Exemplo n.º 6
0
int
main (int argc, char *argv[])
{
    char* load_filename;

    /* Initialize some global variables */
    initialize_server ();

    /* Set up the paths to certain files and directories */
    init_path_strings ();

#ifndef CS_PROFILE
#ifdef SEED_RAND
    srand (time (0));
#endif
#endif

    init_types ();
    initialize_tax_rates ();

    reset_start_time ();

    load_filename = parse_server_args (argc, argv);
    if (load_filename && file_exists(load_filename)) {
	printf ("Server is trying to load: %s\n", load_filename);
	load_city (load_filename);
	zoom_originx = main_screen_originx;
	zoom_originy = main_screen_originy;
    } else {
	engine_new_city (&zoom_originx, &zoom_originy, 1);
    }

    printf ("Server starting main loop!\n");
    while (1) {
	sniff_packets ();
	engine_do_time_step ();
	get_real_time ();
	send_periodic_messages ();
	if (total_time % 1000 == 0) {
	    debug_print_stats ();
	}
    }

    return 0;
}
Exemplo n.º 7
0
Arquivo: init.c Projeto: Strade288/42
t_env			*init_env(char *path)
{
	t_env		*e;

	if (!(e = (t_env *)malloc(sizeof(t_env))))
		ft_error(1, NULL, "Not enough memory.\n");
	if (!(e->mlx = mlx_init()))
		ft_error(1, e, "Mlx fail init.\n");
	if (!(e->win = mlx_new_window(e->mlx, WIDTH, HEIGHT, NAME)))
		ft_error(1, e, "Win fail init.\n");
	if (!init_scene(e, path))
		ft_error(1, e, "Wrong file format.\n");
	e->x_ratio = 0.5 / (double)WIDTH;
	e->y_ratio = 0.35 / (double)HEIGHT;
	init_events(e);
	init_types(e);
	init_screen(e->mlx, &e->screen, WIDTH, HEIGHT);
	return (e);
}
void initLCengine()
{
  /* I18n */
  lincity_set_locale ();

  /* Set up the paths to certain files and directories */
  init_path_strings ();

  /* Make sure that things are installed where they should be */
  //  verify_package ();

  /* Make sure the save directory exists */
  check_savedir ();

  /* Load preferences */
  load_lincityrc ();

  /* Initialize random number generator */
  srand (time (0));

  /* Save preferences */
    save_lincityrc ();

    //    init_fonts ();

    initialize_monthgraph ();
    //    init_mouse_registry ();
    //    init_mini_map_mouse ();
    mps_init();




    //    setcustompalette ();
    //    draw_background ();
    //    prog_box (_("Loading the game"), 1);
    init_types ();
    // means "init buttons"    init_modules();
    init_mappoint_array ();
    initialize_tax_rates ();
}
Exemplo n.º 9
0
    static int
PythonMod_Init(void)
{
    /* The special value is removed from sys.path in Python_Init(). */
    static char	*(argv[2]) = {"/must>not&exist/foo", NULL};

    if (init_types())
	return -1;

    /* Set sys.argv[] to avoid a crash in warn(). */
    PySys_SetArgv(1, argv);

    vim_module = Py_InitModule4("vim", VimMethods, (char *)NULL,
				(PyObject *)NULL, PYTHON_API_VERSION);

    if (populate_module(vim_module))
	return -1;

    if (init_sys_path())
	return -1;

    return 0;
}
Exemplo n.º 10
0
static PyObject *
Py3Init_vim(void)
{
	/* The special value is removed from sys.path in Python3_Init(). */
	static wchar_t *(argv[2]) = {L"/must>not&exist/foo", NULL};

	if (init_types())
		return NULL;

	/* Set sys.argv[] to avoid a crash in warn(). */
	PySys_SetArgv(1, argv);

	if ((vim_module = PyModule_Create(&vimmodule)) == NULL)
		return NULL;

	if (populate_module(vim_module))
		return NULL;

	if (init_sys_path())
		return NULL;

	return vim_module;
}
Exemplo n.º 11
0
int
lincity_main (int argc, char *argv[])
{
#if defined (LC_X11)
    char *geometry = NULL;
#endif

#if defined (SVGALIB)
    int q;
    vga_init ();
#endif

#if !defined (WIN32)
    signal (SIGPIPE, SIG_IGN);    /* broken pipes are ignored. */
#endif

    /* Initialize some global variables */
    make_dir_ok_flag = 1;
    main_screen_originx = 1;
    main_screen_originy = 1;
    given_scene[0] = 0;
    quit_flag = network_flag = load_flag = save_flag 
	    = prefs_flag = cheat_flag = monument_bul_flag
	    = river_bul_flag = shanty_bul_flag;
    prefs_drawn_flag = 0;
    kmouse_val = 8;

#ifdef LC_X11
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif

    /* I18n */
    lincity_set_locale ();

    /* Set up the paths to certain files and directories */
    init_path_strings ();

    /* Make sure that things are installed where they should be */
    verify_package ();

    /* Make sure the save directory exists */
    check_savedir ();

    /* Load preferences */
    load_lincityrc ();

#ifndef CS_PROFILE
#ifdef SEED_RAND
    srand (time (0));
#endif
#endif

#ifdef LC_X11
#if defined (commentout)
    borderx = 0;
    bordery = 0;
    parse_xargs (argc, argv, &geometry);
#endif
    Create_Window (geometry);
    pirate_cursor = XCreateFontCursor (display.dpy, XC_pirate);
#elif defined (WIN32)
    /* Deal with all outstanding messages */
    ProcessPendingEvents ();
#else
    parse_args (argc, argv);
    q = vga_setmode (G640x480x256);
    gl_setcontextvga (G640x480x256);
#endif

#if defined (WIN32) || defined (LC_X11)
    initialize_pixmap ();
#endif

    init_fonts ();

#if defined (SKIP_OPENING_SCENE)
    skip_splash_screen = 1;
#endif
    if (!skip_splash_screen) {
	load_start_image ();
    }

#ifdef LC_X11
    unlock_window_size ();
#endif

    Fgl_setfont (8, 8, main_font);
    Fgl_setfontcolors (TEXT_BG_COLOUR, TEXT_FG_COLOUR);

    initialize_geometry (&scr);

#if defined (SVGALIB)
    set_vga_mode ();
#endif

    initialize_monthgraph ();
    init_mouse_registry ();
    init_mini_map_mouse ();

#ifdef LC_X11
    x_key_value = 0;
#elif defined (WIN32)
    RefreshScreen ();
#endif
    setcustompalette ();
    draw_background ();
    prog_box (_("Loading the game"), 1);
    init_types ();
    init_modules();
    init_mappoint_array ();
    initialize_tax_rates ();
    prog_box ("", 95);
    mouse_hide_count = 0;
    suppress_ok_buttons = 0;
    prog_box ("", 100);
#ifdef USE_PIXMAPS
    prog_box (_("Creating pixmaps"), 1);
    init_pixmaps ();
    prog_box ("", 100);
#endif
    //draw_normal_mouse (1, 1);
#if defined (LC_X11)
    init_x_mouse ();
#endif
    init_timer_buttons();
    mouse_initialized = 1;
    //set_selected_module (CST_TRACK_LR);
    screen_setup ();

    /* Main loop! */
    client_main_loop ();

#if defined (SVGALIB)
    mouse_close ();
    vga_setmode (TEXT);
#endif

    print_results ();

#if defined (WIN32) || defined (LC_X11)
    free_pixmap ();
#endif

#if defined (WIN32)
    return 0;
#else
    exit (0);
#endif
}
Exemplo n.º 12
0
/*
 * Decode the specified CTF buffer and optional symbol table and create a new
 * CTF container representing the symbolic debugging information.  This code
 * can be used directly by the debugger, or it can be used as the engine for
 * ctf_fdopen() or ctf_open(), below.
 */
ctf_file_t *
ctf_bufopen(const ctf_sect_t *ctfsect, const ctf_sect_t *symsect,
    const ctf_sect_t *strsect, int *errp)
{
	const ctf_preamble_t *pp;
	ctf_header_t hp;
	ctf_file_t *fp;
	void *buf, *base;
	size_t size, hdrsz;
	int err;

	if (ctfsect == NULL || ((symsect == NULL) != (strsect == NULL)))
		return (ctf_set_open_errno(errp, EINVAL));

	if (symsect != NULL && symsect->cts_entsize != sizeof (struct nlist) &&
	    symsect->cts_entsize != sizeof (struct nlist_64))
		return (ctf_set_open_errno(errp, ECTF_SYMTAB));

	if (symsect != NULL && symsect->cts_data == NULL)
		return (ctf_set_open_errno(errp, ECTF_SYMBAD));

	if (strsect != NULL && strsect->cts_data == NULL)
		return (ctf_set_open_errno(errp, ECTF_STRBAD));

	if (ctfsect->cts_size < sizeof (ctf_preamble_t))
		return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));

	pp = (const ctf_preamble_t *)ctfsect->cts_data;

	ctf_dprintf("ctf_bufopen: magic=0x%x version=%u\n",
	    pp->ctp_magic, pp->ctp_version);

	/*
	 * Validate each part of the CTF header (either V1 or V2).
	 * First, we validate the preamble (common to all versions).  At that
	 * point, we know specific header version, and can validate the
	 * version-specific parts including section offsets and alignments.
	 */
	if (pp->ctp_magic != CTF_MAGIC)
		return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));

	if (pp->ctp_version == CTF_VERSION_2) {
		if (ctfsect->cts_size < sizeof (ctf_header_t))
			return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));

		bcopy(ctfsect->cts_data, &hp, sizeof (hp));
		hdrsz = sizeof (ctf_header_t);

	} else if (pp->ctp_version == CTF_VERSION_1) {
		const ctf_header_v1_t *h1p =
		    (const ctf_header_v1_t *)ctfsect->cts_data;

		if (ctfsect->cts_size < sizeof (ctf_header_v1_t))
			return (ctf_set_open_errno(errp, ECTF_NOCTFBUF));

		bzero(&hp, sizeof (hp));
		hp.cth_preamble = h1p->cth_preamble;
		hp.cth_objtoff = h1p->cth_objtoff;
		hp.cth_funcoff = h1p->cth_funcoff;
		hp.cth_typeoff = h1p->cth_typeoff;
		hp.cth_stroff = h1p->cth_stroff;
		hp.cth_strlen = h1p->cth_strlen;

		hdrsz = sizeof (ctf_header_v1_t);
	} else
		return (ctf_set_open_errno(errp, ECTF_CTFVERS));

	size = hp.cth_stroff + hp.cth_strlen;

	ctf_dprintf("ctf_bufopen: uncompressed size=%lu\n", (ulong_t)size);

	if (hp.cth_lbloff > size || hp.cth_objtoff > size ||
	    hp.cth_funcoff > size || hp.cth_typeoff > size ||
	    hp.cth_stroff > size)
		return (ctf_set_open_errno(errp, ECTF_CORRUPT));

	if (hp.cth_lbloff > hp.cth_objtoff ||
	    hp.cth_objtoff > hp.cth_funcoff ||
	    hp.cth_funcoff > hp.cth_typeoff ||
	    hp.cth_typeoff > hp.cth_stroff)
		return (ctf_set_open_errno(errp, ECTF_CORRUPT));

	if ((hp.cth_lbloff & 3) || (hp.cth_objtoff & 1) ||
	    (hp.cth_funcoff & 1) || (hp.cth_typeoff & 3))
		return (ctf_set_open_errno(errp, ECTF_CORRUPT));

	/*
	 * Once everything is determined to be valid, attempt to decompress
	 * the CTF data buffer if it is compressed.  Otherwise we just put
	 * the data section's buffer pointer into ctf_buf, below.
	 */
	if (hp.cth_flags & CTF_F_COMPRESS) {
		size_t srclen, dstlen;
		const void *src;
		int rc = Z_OK;

		if (ctf_zopen(errp) == NULL)
			return (NULL); /* errp is set for us */

		if ((base = ctf_data_alloc(size + hdrsz)) == MAP_FAILED)
			return (ctf_set_open_errno(errp, ECTF_ZALLOC));

		bcopy(ctfsect->cts_data, base, hdrsz);
		((ctf_preamble_t *)base)->ctp_flags &= ~CTF_F_COMPRESS;
		buf = (uchar_t *)base + hdrsz;

		src = (uchar_t *)ctfsect->cts_data + hdrsz;
		srclen = ctfsect->cts_size - hdrsz;
		dstlen = size;

		if ((rc = z_uncompress(buf, &dstlen, src, srclen)) != Z_OK) {
			ctf_dprintf("zlib inflate err: %s\n", z_strerror(rc));
			ctf_data_free(base, size + hdrsz);
			return (ctf_set_open_errno(errp, ECTF_DECOMPRESS));
		}

		if (dstlen != size) {
			ctf_dprintf("zlib inflate short -- got %lu of %lu "
			    "bytes\n", (ulong_t)dstlen, (ulong_t)size);
			ctf_data_free(base, size + hdrsz);
			return (ctf_set_open_errno(errp, ECTF_CORRUPT));
		}

		ctf_data_protect(base, size + hdrsz);

	} else {
		base = (void *)ctfsect->cts_data;
		buf = (uchar_t *)base + hdrsz;
	}

	/*
	 * Once we have uncompressed and validated the CTF data buffer, we can
	 * proceed with allocating a ctf_file_t and initializing it.
	 */
	if ((fp = ctf_alloc(sizeof (ctf_file_t))) == NULL)
		return (ctf_set_open_errno(errp, EAGAIN));

	bzero(fp, sizeof (ctf_file_t));
	fp->ctf_version = hp.cth_version;
	fp->ctf_fileops = &ctf_fileops[hp.cth_version];
	bcopy(ctfsect, &fp->ctf_data, sizeof (ctf_sect_t));

	if (symsect != NULL) {
		bcopy(symsect, &fp->ctf_symtab, sizeof (ctf_sect_t));
		bcopy(strsect, &fp->ctf_strtab, sizeof (ctf_sect_t));
	}

	if (fp->ctf_data.cts_name != NULL)
		fp->ctf_data.cts_name = ctf_strdup(fp->ctf_data.cts_name);
	if (fp->ctf_symtab.cts_name != NULL)
		fp->ctf_symtab.cts_name = ctf_strdup(fp->ctf_symtab.cts_name);
	if (fp->ctf_strtab.cts_name != NULL)
		fp->ctf_strtab.cts_name = ctf_strdup(fp->ctf_strtab.cts_name);

	if (fp->ctf_data.cts_name == NULL)
		fp->ctf_data.cts_name = _CTF_NULLSTR;
	if (fp->ctf_symtab.cts_name == NULL)
		fp->ctf_symtab.cts_name = _CTF_NULLSTR;
	if (fp->ctf_strtab.cts_name == NULL)
		fp->ctf_strtab.cts_name = _CTF_NULLSTR;

	fp->ctf_str[CTF_STRTAB_0].cts_strs = (const char *)buf + hp.cth_stroff;
	fp->ctf_str[CTF_STRTAB_0].cts_len = hp.cth_strlen;

	if (strsect != NULL) {
		fp->ctf_str[CTF_STRTAB_1].cts_strs = strsect->cts_data;
		fp->ctf_str[CTF_STRTAB_1].cts_len = strsect->cts_size;
	}

	fp->ctf_base = base;
	fp->ctf_buf = buf;
	fp->ctf_size = size + hdrsz;

	/*
	 * If we have a parent container name and label, store the relocated
	 * string pointers in the CTF container for easy access later.
	 */
	if (hp.cth_parlabel != 0)
		fp->ctf_parlabel = ctf_strptr(fp, hp.cth_parlabel);
	if (hp.cth_parname != 0)
		fp->ctf_parname = ctf_strptr(fp, hp.cth_parname);

	ctf_dprintf("ctf_bufopen: parent name %s (label %s)\n",
	    fp->ctf_parname ? fp->ctf_parname : "<NULL>",
	    fp->ctf_parlabel ? fp->ctf_parlabel : "<NULL>");

	/*
	 * If we have a symbol table section, allocate and initialize
	 * the symtab translation table, pointed to by ctf_sxlate.
	 */
	if (symsect != NULL) {
		fp->ctf_nsyms = symsect->cts_size / symsect->cts_entsize;
		fp->ctf_sxlate = ctf_alloc(fp->ctf_nsyms * sizeof (uint_t));

		if (fp->ctf_sxlate == NULL) {
			(void) ctf_set_open_errno(errp, EAGAIN);
			goto bad;
		}

		if ((err = init_symtab(fp, &hp, symsect, strsect)) != 0) {
			(void) ctf_set_open_errno(errp, err);
			goto bad;
		}
	}

	if ((err = init_types(fp, &hp)) != 0) {
		(void) ctf_set_open_errno(errp, err);
		goto bad;
	}

	/*
	 * Initialize the ctf_lookup_by_name top-level dictionary.  We keep an
	 * array of type name prefixes and the corresponding ctf_hash to use.
	 * NOTE: This code must be kept in sync with the code in ctf_update().
	 */
	fp->ctf_lookups[0].ctl_prefix = "struct";
	fp->ctf_lookups[0].ctl_len = strlen(fp->ctf_lookups[0].ctl_prefix);
	fp->ctf_lookups[0].ctl_hash = &fp->ctf_structs;
	fp->ctf_lookups[1].ctl_prefix = "union";
	fp->ctf_lookups[1].ctl_len = strlen(fp->ctf_lookups[1].ctl_prefix);
	fp->ctf_lookups[1].ctl_hash = &fp->ctf_unions;
	fp->ctf_lookups[2].ctl_prefix = "enum";
	fp->ctf_lookups[2].ctl_len = strlen(fp->ctf_lookups[2].ctl_prefix);
	fp->ctf_lookups[2].ctl_hash = &fp->ctf_enums;
	fp->ctf_lookups[3].ctl_prefix = _CTF_NULLSTR;
	fp->ctf_lookups[3].ctl_len = strlen(fp->ctf_lookups[3].ctl_prefix);
	fp->ctf_lookups[3].ctl_hash = &fp->ctf_names;
	fp->ctf_lookups[4].ctl_prefix = NULL;
	fp->ctf_lookups[4].ctl_len = 0;
	fp->ctf_lookups[4].ctl_hash = NULL;

	if (symsect != NULL) {
		if (symsect->cts_entsize == sizeof (struct nlist_64))
			(void) ctf_setmodel(fp, CTF_MODEL_LP64);
		else if (symsect->cts_entsize == sizeof (struct nlist))
			(void) ctf_setmodel(fp, CTF_MODEL_ILP32);
		else if (symsect->cts_entsize == sizeof (Elf64_Sym))
			(void) ctf_setmodel(fp, CTF_MODEL_LP64);
		else
			(void) ctf_setmodel(fp, CTF_MODEL_ILP32);
	} else
		(void) ctf_setmodel(fp, CTF_MODEL_NATIVE);

	fp->ctf_refcnt = 1;
	return (fp);

bad:
	ctf_close(fp);
	return (NULL);
}
Exemplo n.º 13
0
void target_adjust_types_and_dialect(void)
{
	unsigned int_size     = ir_platform_type_size(IR_TYPE_INT);
	unsigned long_size    = ir_platform_type_size(IR_TYPE_LONG);
	unsigned pointer_size = ir_target_pointer_size();
	atomic_type_kind_t pointer_sized_int
		= ir_platform_to_ast(ir_platform_intptr_type(), true);
	atomic_type_kind_t pointer_sized_uint
		= ir_platform_to_ast(ir_platform_intptr_type(), false);
	atomic_type_kind_t wchar_atomic_kind
		= set_wchar ? (short_wchar ? ATOMIC_TYPE_USHORT : ATOMIC_TYPE_INT)
		            : ir_platform_to_ast(ir_platform_wchar_type(),
		                                 ir_platform_wchar_is_signed());
	init_types(int_size, long_size, pointer_size, wchar_atomic_kind,
			   pointer_sized_int, pointer_sized_uint);

	atomic_type_properties_t *const props = atomic_type_properties;

	unsigned const ll_d_struct_align
		= ir_platform_long_long_and_double_struct_align_override();
	if (ll_d_struct_align > 0) {
		props[ATOMIC_TYPE_LONGLONG].struct_alignment  = ll_d_struct_align;
		props[ATOMIC_TYPE_ULONGLONG].struct_alignment = ll_d_struct_align;
		props[ATOMIC_TYPE_DOUBLE].struct_alignment    = ll_d_struct_align;
	}

	props[ATOMIC_TYPE_LONG_DOUBLE].size
		= ir_platform_type_size(IR_TYPE_LONG_DOUBLE);
	unsigned align = ir_platform_type_align(IR_TYPE_LONG_DOUBLE);
	props[ATOMIC_TYPE_LONG_DOUBLE].alignment        = align;
	props[ATOMIC_TYPE_LONG_DOUBLE].struct_alignment = align;

	/* stuff decided after processing operating system specifics and
	 * commandline flags */
	if (unsigned_char) {
		props[ATOMIC_TYPE_CHAR].flags &= ~ATOMIC_TYPE_FLAG_SIGNED;
	} else {
		props[ATOMIC_TYPE_CHAR].flags |= ATOMIC_TYPE_FLAG_SIGNED;
	}

	static bool had_cpp_warning;
	if (dialect.cpp && !had_cpp_warning) {
		warningf(WARN_EXPERIMENTAL, NULL,
		         "C++ support is highly experimental and unfinished");
		had_cpp_warning = true;
	}

	/* Check that we match libfirms view of the world */
	assert(ir_platform_type_size(IR_TYPE_BOOL) == props[ATOMIC_TYPE_BOOL].size);
	assert(ir_platform_type_size(IR_TYPE_CHAR) == props[ATOMIC_TYPE_CHAR].size);
	assert(ir_platform_type_size(IR_TYPE_SHORT)
	       == props[ATOMIC_TYPE_SHORT].size);
	assert(ir_platform_type_size(IR_TYPE_INT) == props[ATOMIC_TYPE_INT].size);
	assert(ir_platform_type_size(IR_TYPE_LONG) == props[ATOMIC_TYPE_LONG].size);
	assert(ir_platform_type_size(IR_TYPE_LONG_LONG)
	       == props[ATOMIC_TYPE_LONGLONG].size);
	assert(ir_platform_type_size(IR_TYPE_FLOAT)
	       == props[ATOMIC_TYPE_FLOAT].size);
	assert(ir_platform_type_size(IR_TYPE_DOUBLE)
	       == props[ATOMIC_TYPE_DOUBLE].size);
	assert(ir_platform_type_size(IR_TYPE_LONG_DOUBLE)
	       == props[ATOMIC_TYPE_LONG_DOUBLE].size);
}
Exemplo n.º 14
0
void Init_llvmruby() {
  cLLVMRuby = rb_define_module("LLVM");

  cLLVMType = rb_define_class_under(cLLVMRuby, "Type", rb_cObject);
  cLLVMPointerType = rb_define_class_under(cLLVMRuby, "PointerType", cLLVMType);
  cLLVMStructType = rb_define_class_under(cLLVMRuby, "StructType", cLLVMType);
  cLLVMArrayType = rb_define_class_under(cLLVMRuby, "ArrayType", cLLVMType);
  cLLVMVectorType = rb_define_class_under(cLLVMRuby, "VectorType", cLLVMType);
  cLLVMFunctionType = rb_define_class_under(cLLVMRuby, "FunctionType", cLLVMType);

  cLLVMValue = rb_define_class_under(cLLVMRuby, "Value", rb_cObject);
  cLLVMUser = rb_define_class_under(cLLVMRuby, "User", cLLVMValue);
  cLLVMUse = rb_define_class_under(cLLVMRuby, "Use", rb_cObject);
  cLLVMModule = rb_define_class_under(cLLVMRuby, "Module", rb_cObject);
  cLLVMFunction = rb_define_class_under(cLLVMRuby, "Function", rb_cObject);
  cLLVMBasicBlock = rb_define_class_under(cLLVMRuby, "BasicBlock", cLLVMValue);   
  cLLVMBuilder = rb_define_class_under(cLLVMRuby, "Builder", rb_cObject);

  cLLVMInstruction = rb_define_class_under(cLLVMRuby, "Instruction", cLLVMUser);
  cLLVMUnaryInstruction = rb_define_class_under(cLLVMRuby, "UnaryInstruction", cLLVMInstruction);
  cLLVMBinaryOperator = rb_define_class_under(cLLVMRuby, "BinaryOperator", cLLVMInstruction);
  cLLVMTerminatorInst = rb_define_class_under(cLLVMRuby, "TerminatorInst", cLLVMInstruction);
  cLLVMAllocationInst = rb_define_class_under(cLLVMRuby, "AllocationInst", cLLVMInstruction);
  cLLVMBinaryOps = rb_define_class_under(cLLVMInstruction, "BinaryOps", rb_cObject);

  #define HANDLE_TERM_INST(Num, Opcode, Klass) cLLVM##Klass = rb_define_class_under(cLLVMRuby, #Klass, cLLVMTerminatorInst);
  #include "llvm/Instruction.def"

  cLLVMLoadInst = rb_define_class_under(cLLVMRuby, "LoadInst", cLLVMUnaryInstruction);
  cLLVMStoreInst = rb_define_class_under(cLLVMRuby, "StoreInst", cLLVMInstruction);
  cLLVMFreeInst = rb_define_class_under(cLLVMRuby, "FreeInst", cLLVMUnaryInstruction);
  cLLVMGetElementPtrInst = rb_define_class_under(cLLVMRuby, "GetElementPtrInst", cLLVMInstruction);
  cLLVMAllocaInst = rb_define_class_under(cLLVMRuby, "AllocaInst", cLLVMAllocationInst);
  cLLVMMallocInst = rb_define_class_under(cLLVMRuby, "MallocInst", cLLVMAllocationInst);

  cLLVMCmpInst = rb_define_class_under(cLLVMRuby, "CmpInst", cLLVMInstruction);
  cLLVMICmpInst = rb_define_class_under(cLLVMRuby, "ICmpInst", cLLVMCmpInst);
  cLLVMFCmpInst = rb_define_class_under(cLLVMRuby, "FCmpInst", cLLVMCmpInst);
  cLLVMPhi = rb_define_class_under(cLLVMRuby, "Phi", cLLVMValue);

  cLLVMPassManager = rb_define_class_under(cLLVMRuby, "PassManager", rb_cObject);
  cLLVMExecutionEngine = rb_define_class_under(cLLVMRuby, "ExecutionEngine", rb_cObject);

  init_types();
  rb_define_module_function(cLLVMType, "pointer", llvm_type_pointer, 1);
  rb_define_module_function(cLLVMType, "struct", llvm_type_struct, 1);
  rb_define_module_function(cLLVMType, "array", llvm_type_array, 2);
  rb_define_module_function(cLLVMType, "vector", llvm_type_vector, 2);
  rb_define_module_function(cLLVMType, "function", llvm_type_function, -1);
  rb_define_method(cLLVMType, "to_s", llvm_type_to_s, 0);
  rb_define_method(cLLVMType, "type_id", llvm_type_type_id, 0);

  rb_define_module_function(cLLVMValue, "get_constant", llvm_value_get_constant, 2);
  rb_define_module_function(cLLVMValue, "get_float_constant", llvm_value_get_float_constant, 1);
  rb_define_module_function(cLLVMValue, "get_double_constant", llvm_value_get_double_constant, 1);
  rb_define_module_function(cLLVMValue, "get_immediate_constant", llvm_value_get_immediate_constant, 1);
  rb_define_module_function(cLLVMValue, "get_struct_constant", llvm_value_get_struct_constant, -1);
  rb_define_method(cLLVMValue, "name", llvm_value_name, 0);
  rb_define_method(cLLVMValue, "name=", llvm_value_set_name, 1);
  rb_define_method(cLLVMValue, "type", llvm_value_type, 0);
  rb_define_method(cLLVMValue, "num_uses", llvm_value_num_uses, 0);
  rb_define_method(cLLVMValue, "used_in_basic_block?", llvm_value_used_in_basic_block, 1);
  rb_define_method(cLLVMValue, "replace_all_uses_with", llvm_value_replace_all_uses_with, 1);

  rb_define_method(cLLVMValue, "is_constant", llvm_value_is_constant, 0);
  rb_define_method(cLLVMValue, "is_int_constant", llvm_value_is_int_constant, 0);
  rb_define_method(cLLVMValue, "is_float_constant", llvm_value_is_float_constant, 0);
  rb_define_method(cLLVMValue, "get_int_constant_value", llvm_value_get_int_constant_value, 0);
  rb_define_method(cLLVMValue, "get_float_constant_value", llvm_value_get_float_constant_value, 0);
  rb_define_method(cLLVMValue, "is_null", llvm_value_is_null, 0);
  rb_define_method(cLLVMValue, "is_undef", llvm_value_is_undef, 0);

  rb_define_method(cLLVMUser, "get_operand_list", llvm_user_get_operand_list, 0);
  rb_define_method(cLLVMUser, "get_num_operands", llvm_user_get_num_operands, 0);
  rb_define_method(cLLVMUser, "get_operand", llvm_user_get_operand, 1);
  rb_define_method(cLLVMUser, "set_operand", llvm_user_set_operand, 2);
  rb_define_method(cLLVMUser, "drop_all_references", llvm_user_drop_all_references, 0);
  rb_define_method(cLLVMUser, "replace_uses_of_with", llvm_user_replace_uses_of_with, 2);


  init_instructions();

  rb_define_alloc_func(cLLVMModule, llvm_module_allocate);
  rb_define_module_function(cLLVMModule, "read_assembly", llvm_module_read_assembly, 1);
  rb_define_module_function(cLLVMModule, "read_bitcode", llvm_module_read_bitcode, 1);
  rb_define_method(cLLVMModule, "initialize", llvm_module_initialize, 1);
  rb_define_method(cLLVMModule, "get_or_insert_function", llvm_module_get_or_insert_function, 2);
  rb_define_method(cLLVMModule, "get_function", llvm_module_get_function, 1);
  rb_define_method(cLLVMModule, "global_constant", llvm_module_global_constant, 2);
  rb_define_method(cLLVMModule, "global_variable", llvm_module_global_variable, 2);
  rb_define_method(cLLVMModule, "external_function", llvm_module_external_function, 2);
  rb_define_method(cLLVMModule, "write_bitcode", llvm_module_write_bitcode, 1);
  rb_define_method(cLLVMModule, "inspect", llvm_module_inspect, 0);

  rb_define_method(cLLVMFunction, "create_block", llvm_function_create_block, 0);
  rb_define_method(cLLVMFunction, "arguments", llvm_function_arguments, 0);
  rb_define_method(cLLVMFunction, "inspect", llvm_function_inspect, 0);
  rb_define_method(cLLVMFunction, "get_basic_block_list", llvm_function_get_basic_block_list, 0);
  rb_define_method(cLLVMFunction, "set_gc", llvm_function_set_gc, 1);

  rb_define_method(cLLVMBasicBlock, "builder", llvm_basic_block_builder, 0);
  rb_define_method(cLLVMBasicBlock, "size", llvm_basic_block_size, 0);
  rb_define_method(cLLVMBasicBlock, "get_instruction_list", llvm_basic_block_get_instruction_list, 0);

  rb_define_method(cLLVMInstruction, "inspect", llvm_instruction_inspect, 0);
  rb_define_method(cLLVMInstruction, "get_opcode_name", llvm_instruction_get_opcode_name, 0);
  rb_define_method(cLLVMInstruction, "may_read_from_memory?", llvm_instruction_may_read_from_memory, 0);
  rb_define_method(cLLVMInstruction, "may_write_to_memory?", llvm_instruction_may_write_to_memory, 0);
  rb_define_method(cLLVMInstruction, "identical_to?", llvm_instruction_is_identical_to, 1);
  rb_define_method(cLLVMInstruction, "same_operation_as?", llvm_instruction_is_same_operation_as, 1);
  rb_define_method(cLLVMInstruction, "used_outside_of_block?", llvm_instruction_is_used_outside_of_block, 1);
  
  rb_define_method(cLLVMTerminatorInst, "num_successors", llvm_terminator_inst_num_successors, 0);
  rb_define_method(cLLVMTerminatorInst, "get_successor", llvm_terminator_inst_get_successor, 1);
  rb_define_method(cLLVMTerminatorInst, "set_successor", llvm_terminator_inst_set_successor, 2);

  rb_define_method(cLLVMBranchInst, "conditional?", llvm_branch_inst_is_conditional, 0);
  rb_define_method(cLLVMBranchInst, "unconditional?", llvm_branch_inst_is_unconditional, 0);
  rb_define_method(cLLVMBranchInst, "condition", llvm_branch_inst_get_condition, 0);
  rb_define_method(cLLVMBranchInst, "condition=", llvm_branch_inst_set_condition, 1);

  rb_define_method(cLLVMSwitchInst, "get_default_dest", llvm_switch_inst_get_default_dest, 0);
  rb_define_method(cLLVMSwitchInst, "get_num_cases", llvm_switch_inst_get_num_cases, 0);
  rb_define_method(cLLVMSwitchInst, "add_case", llvm_switch_inst_add_case, 2);

  rb_define_method(cLLVMAllocationInst, "array_allocation?", llvm_allocation_inst_is_array_allocation, 0);
  rb_define_method(cLLVMAllocationInst, "array_size", llvm_allocation_inst_array_size, 0);
  rb_define_method(cLLVMAllocationInst, "allocated_type", llvm_allocation_inst_allocated_type, 0);
  rb_define_method(cLLVMAllocationInst, "alignment", llvm_allocation_inst_alignment, 0);

  rb_define_method(cLLVMBuilder, "set_insert_point", llvm_builder_set_insert_point, 1);
  rb_define_method(cLLVMBuilder, "bin_op", llvm_builder_bin_op, 3);
  rb_define_method(cLLVMBuilder, "phi", llvm_builder_phi, 1);
  rb_define_method(cLLVMBuilder, "return", llvm_builder_return, 1);
  rb_define_method(cLLVMBuilder, "br", llvm_builder_br, 1);
  rb_define_method(cLLVMBuilder, "cond_br", llvm_builder_cond_br, 3);
  rb_define_method(cLLVMBuilder, "switch", llvm_builder_switch, 2);
  rb_define_method(cLLVMBuilder, "invoke", llvm_builder_invoke, -1);
  rb_define_method(cLLVMBuilder, "unwind", llvm_builder_unwind, 0);
  rb_define_method(cLLVMBuilder, "malloc", llvm_builder_malloc, 2);
  rb_define_method(cLLVMBuilder, "free", llvm_builder_free, 1);
  rb_define_method(cLLVMBuilder, "alloca", llvm_builder_alloca, 2);
  rb_define_method(cLLVMBuilder, "load", llvm_builder_load, -1);
  rb_define_method(cLLVMBuilder, "store", llvm_builder_store, -1);
  rb_define_method(cLLVMBuilder, "icmp", llvm_builder_icmp, 3);
  rb_define_method(cLLVMBuilder, "fcmp", llvm_builder_fcmp, 3);

  rb_define_method(cLLVMBuilder, "gep", llvm_builder_gep, 2);
  rb_define_method(cLLVMBuilder, "struct_gep", llvm_builder_struct_gep, 2);
  rb_define_method(cLLVMBuilder, "cast", llvm_builder_cast, 3);
  rb_define_method(cLLVMBuilder, "int_cast", llvm_builder_int_cast, 3);
  rb_define_method(cLLVMBuilder, "call", llvm_builder_call, -1);
  rb_define_method(cLLVMBuilder, "insert_element", llvm_builder_insert_element, 3);
  rb_define_method(cLLVMBuilder, "extract_element", llvm_builder_extract_element, 2);
  rb_define_method(cLLVMBuilder, "get_global", llvm_builder_get_global, 0);
  rb_define_method(cLLVMBuilder, "create_global_string_ptr", llvm_builder_create_global_string_ptr, 1);

  rb_define_method(cLLVMPhi, "add_incoming", llvm_phi_add_incoming, 2);

  rb_define_alloc_func(cLLVMModule, llvm_pass_manager_allocate);
  rb_define_method(cLLVMPassManager, "initialize", llvm_pass_manager_initialize, 0);
  rb_define_method(cLLVMPassManager, "run", llvm_pass_manager_run, 1);

  rb_define_module_function(cLLVMExecutionEngine, "get", llvm_execution_engine_get, 1);
  rb_define_module_function(cLLVMExecutionEngine, "run_function", llvm_execution_engine_run_function, -1);
  rb_define_module_function(cLLVMExecutionEngine, "run_autoconvert", llvm_execution_engine_run_autoconvert, 1);

  /*
  printf("sizeof long: %d\n", (int)sizeof(long));
  printf("sizeof ptr: %d\n", (int)sizeof(long*));
  printf("sizeof value: %d\n", (int)sizeof(VALUE));
  printf("sizeof array: %d\n", (int)sizeof(struct RArray));
  printf("sizeof int: %d\n", (int)sizeof(int));
  printf("sizeof char: %d\n", (int)sizeof(char));
  */
}
Exemplo n.º 15
0
void target_adjust_types_and_dialect(void)
{
	init_types(dialect.int_size, dialect.long_size, dialect.pointer_size);

	atomic_type_properties_t *props = atomic_type_properties;

	/* Adjustments for some systems */
	props[ATOMIC_TYPE_LONGLONG].size             = dialect.long_long_size;
	props[ATOMIC_TYPE_LONGLONG].alignment        = dialect.long_long_size;
	props[ATOMIC_TYPE_LONGLONG].struct_alignment = dialect.long_long_size;
	props[ATOMIC_TYPE_ULONGLONG].size             = dialect.long_long_size;
	props[ATOMIC_TYPE_ULONGLONG].alignment        = dialect.long_long_size;
	props[ATOMIC_TYPE_ULONGLONG].struct_alignment = dialect.long_long_size;

	unsigned const ll_d_struct_align
		= dialect.long_long_and_double_struct_align;
	if (ll_d_struct_align > 0) {
		props[ATOMIC_TYPE_LONGLONG].struct_alignment  = ll_d_struct_align;
		props[ATOMIC_TYPE_ULONGLONG].struct_alignment = ll_d_struct_align;
		props[ATOMIC_TYPE_DOUBLE].struct_alignment    = ll_d_struct_align;
	}

	unsigned const size = dialect.long_double_size;
	unsigned const alignment = size == 12 && dialect.long_double_x87_80bit_float
	                         ? 4 : size;
	props[ATOMIC_TYPE_LONG_DOUBLE].size             = size;
	props[ATOMIC_TYPE_LONG_DOUBLE].alignment        = alignment;
	props[ATOMIC_TYPE_LONG_DOUBLE].struct_alignment = alignment;

	/* stuff decided after processing operating system specifics and
	 * commandline flags */
	if (dialect.char_is_signed) {
		props[ATOMIC_TYPE_CHAR].flags |= ATOMIC_TYPE_FLAG_SIGNED;
	} else {
		props[ATOMIC_TYPE_CHAR].flags &= ~ATOMIC_TYPE_FLAG_SIGNED;
	}
	/* copy over wchar_t properties (including rank) */
	props[ATOMIC_TYPE_WCHAR_T] = props[dialect.wchar_atomic_kind];

	static bool had_cpp_warning;
	if (dialect.cpp && !had_cpp_warning) {
		warningf(WARN_EXPERIMENTAL, NULL,
		         "C++ support is highly experimental and unfinished");
		had_cpp_warning = true;
	}

	if (target.firm_isa_specified) {
		backend_params const *const p = be_get_backend_param();
		target.float_int_overflow    = p->float_int_overflow;
		target.byte_order_big_endian = p->byte_order_big_endian;
		dialect.pointer_size         = p->machine_size / BITS_PER_BYTE;
	} else {
		/* The frontend should do all decisions and should not be influenced by
		 * outside influences like the firm backend. So we just check here that
		 * our decisions match the firm backend. */
		assert(be_get_backend_param()->machine_size % BITS_PER_BYTE == 0);
		assert(dialect.pointer_size
		       == be_get_backend_param()->machine_size / BITS_PER_BYTE);
		assert(target.byte_order_big_endian
		       == be_get_backend_param()->byte_order_big_endian);
		assert(target.float_int_overflow
		       == be_get_backend_param()->float_int_overflow);
	}
}
Exemplo n.º 16
0
Arquivo: l15p.c Projeto: eZanmoto/L15P
/*
 * Starts the read-eval-print loop.
 *
 * \return '0' on successful termination
 */
int main() {
    output_splash();
    init_types();
    repl();
    return 0;
}
Exemplo n.º 17
0
/* Entry point of cc1/c++.  Decode command args, then call compile_file.
   Exit code is 35 if can't open files, 34 if fatal error,
   33 if had nonfatal errors, else success.  */
int main(int argc, char **argv)
{
  register int i;
  dd_list files, preludes;
  dd_list_pos cur;
  int version_flag = 0;
  char *p;
  char *config_file = NULL;

#ifdef TIMER_USERTIME
  reset_timer(&total_time);
#endif
  start_timer(&total_time);
  region_init();
  parse_region = newregion();
  in_prelude = FALSE;
  num_hotspots = 0;
  parsed_files = dd_new_list(parse_region);

  copy_argc = 0;
  copy_argv = xmalloc((argc + 1) * sizeof(*copy_argv));
  files = dd_new_list(parse_region);
  preludes = dd_new_list(parse_region);

  p = argv[0] + strlen (argv[0]);
  while (p != argv[0] && p[-1] != '/'
#ifdef DIR_SEPARATOR
	 && p[-1] != DIR_SEPARATOR
#endif
	 )
    --p;
  progname = p;

#ifdef SIGPIPE
  signal (SIGPIPE, pipe_closed);
#endif

  copy_argv[0] = argv[0];
  copy_argc = 1;
  for (i = 1; i < argc; i++)
    {
      int j;
      bool copy_arg = TRUE;

      /* If this is a language-specific option,
	 decode it in a language-specific way.  */
      for (j = 0; lang_options[j] != 0; j++)
	if (!strncmp (argv[i], lang_options[j],
		      strlen (lang_options[j])))
	  break;
      if (lang_options[j] != 0)
	/* If the option is valid for *some* language,
	   treat it as valid even if this language doesn't understand it.  */
	c_decode_option(argv[i]);
      else if (argv[i][0] == '-' && argv[i][1] != 0)
	{
	  register char *str = argv[i] + 1;
	  if (str[0] == 'Y')
	    str++;

	  if (!strcmp (str, "dumpbase"))
	    copy_argv[copy_argc++] = argv[i++];
	  else if (str[0] == 'f')
	    {
	      register char *p = &str[1];
	      int found = 0;

	      /* Some kind of -f option.
		 P's value is the option sans `-f'.
		 Search for it in the table of options.  */

	      for (j = 0;
		   !found && j < sizeof (f_options) / sizeof (f_options[0]);
		   j++)
		{
		  if (!strcmp (p, f_options[j].string))
		    {
		      *f_options[j].variable = f_options[j].on_value;
		      /* A goto here would be cleaner,
			 but breaks the vax pcc.  */
		      found = 1;
		    }
		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
		      && ! strcmp (p+3, f_options[j].string))
		    {
		      *f_options[j].variable = ! f_options[j].on_value;
		      found = 1;
		    }
		}
	    }
	  else if (!strcmp (str, "pedantic"))
	    pedantic = 1;
	  else if (!strcmp (str, "pedantic-errors"))
	    flag_pedantic_errors = pedantic = 1;
	  else if (!strcmp (str, "quiet"))
	    quiet_flag = 1;
	  else if (!strcmp (str, "version"))
	    version_flag = 1;
	  else if (!strcmp (str, "w"))
	    inhibit_warnings = 1;
	  else if (!strcmp (str, "W"))
	    {
	      extra_warnings = 1;
	      /* We save the value of warn_uninitialized, since if they put
		 -Wuninitialized on the command line, we need to generate a
		 warning about not using it without also specifying -O.  */
	      if (warn_uninitialized != 1)
		warn_uninitialized = 2;
	    }
	  else if (str[0] == 'W')
	    {
	      register char *p = &str[1];
	      int found = 0;

	      /* Some kind of -W option.
		 P's value is the option sans `-W'.
		 Search for it in the table of options.  */

	      for (j = 0;
		   !found && j < sizeof (W_options) / sizeof (W_options[0]);
		   j++)
		{
		  if (!strcmp (p, W_options[j].string))
		    {
		      *W_options[j].variable = W_options[j].on_value;
		      /* A goto here would be cleaner,
			 but breaks the vax pcc.  */
		      found = 1;
		    }
		  if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
		      && ! strcmp (p+3, W_options[j].string))
		    {
		      *W_options[j].variable = ! W_options[j].on_value;
		      found = 1;
		    }
		}

	      if (found)
		;
	      else if (!strncmp (p, "id-clash-", 9))
		{
		  char *endp = p + 9;

		  while (*endp)
		    {
		      if (*endp >= '0' && *endp <= '9')
			endp++;
		      else
			{
			  error ("Invalid option `%s'", argv[i]);
			  goto id_clash_lose;
			}
		    }
		  warn_id_clash = 1;
		  id_clash_len = atoi (str + 10);
		id_clash_lose: ;
		}
	      else if (!strncmp (p, "larger-than-", 12))
		{
		  char *endp = p + 12;

		  while (*endp)
		    {
		      if (*endp >= '0' && *endp <= '9')
			endp++;
		      else
			{
			  error ("Invalid option `%s'", argv[i]);
			  goto larger_than_lose;
			}
		    }
		  warn_larger_than = 1;
		  larger_than_size = atoi (str + 13);
		larger_than_lose: ;
		}
	    }
	  else if (!strcmp (str, "o"))
	    copy_argv[copy_argc++] = argv[i++];
	  else if (str[0] == 'G')
	    {
	      if (str[1] == '\0')
		copy_argv[copy_argc++] = argv[i++];
	    }
	  else if (!strncmp (str, "aux-info", 8))
	    {
	      if (str[8] == '\0')
		copy_argv[copy_argc++] = argv[i++];
	    }
	  else if (!strcmp(str, "config"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  config_file = strdup(argv[i]);
		}
	      else
		error ("Missing -config file");
	    }
	  else if (!strcmp(str, "prelude"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  dd_add_last(parse_region, preludes,
			      rstrdup(parse_region, argv[i]));
		}
	      else
		error("Missing -prelude file");
	    }
	  else if (!strcmp(str, "hotspots"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  num_hotspots = atoi(argv[i]);
		  if (num_hotspots < 0)
		    error("Negative value for -hotspots count");
		}
	      else
		error("Missing -hotspots count");
	    }
	  else if (!strcmp( str, "program-files"))
	    {
	      if (i < argc - 1)
		{
		  i++;
		  add_program_files(argv[i], files);
		}
	      else
		error("Missing -program-files file");
	    }
	}
      else if (argv[i][0] == '+')
	;
      else
	{
	  /* Allow wildcards, because PAM won't expand files */
	  glob_t globbuf;
	  char **cur;

	  if (glob(argv[i], 0, NULL, &globbuf))
	    {
	      /* glob returned non-zero error status; abort */
	      fprintf(stderr, "%s: file not found\n", argv[i]);
	      exit(FATAL_EXIT_CODE);
	    }
	  else
	    for (cur = globbuf.gl_pathv; *cur; cur++)
	      {
		/* Assume anything called prelude.i is a prelude file */
		if ( strlen(*cur) >= 9 &&
                    !strncmp("prelude.i", *cur + strlen(*cur) - 9, 9))
		  dd_add_last(parse_region, preludes,
			      rstrdup(parse_region, *cur));
		else
		  dd_add_last(parse_region, files,
			      rstrdup(parse_region, *cur));
	      }
	  copy_arg = FALSE;
	}

      if (copy_arg)
	copy_argv[copy_argc++] = argv[i];
    }
  copy_argv[copy_argc] = NULL;

  if (flag_casts_preserve && flag_flow_sensitive) {
    fprintf(stderr, "-fcasts-preserve currently not allowed with "
	    "-fflow_sensitive");
    exit(FATAL_EXIT_CODE);
  }

  /* Now analyze *all* of the files.  First, initialize all appropriate
     data structures. */
  init_types();
  cval_init();
  init_effects();
  init_qtype();
  init_quals();
  init_qerror();

  init_store();

  if (config_file)
    load_config_file_quals(config_file);

  /* Add const so that we can do -fconst-subtyping no matter what */
  if (!const_qual)
    {
      begin_po_qual();
      const_qual = add_qual("const");
      add_level_qual(const_qual, level_ref);
      set_po_nonprop();
      end_po_qual();
    }

  /* Add volatile so we can handle noreturn functions */
  if (!volatile_qual)
    {
      begin_po_qual();
      volatile_qual = add_qual("volatile");
      add_level_qual(volatile_qual, level_ref);
      add_sign_qual(volatile_qual, sign_eq);
      set_po_nonprop();
      end_po_qual();
    }

  /* Add noreturn, for non-returning functions */
  if (!noreturn_qual)
    {
      begin_po_qual();
      noreturn_qual = add_qual("noreturn");
      add_level_qual(noreturn_qual, level_value);
      add_sign_qual(noreturn_qual, sign_eq);
      set_po_nonprop();
      end_po_qual();
    }

  end_define_pos(); /* Allow cqual to run with no qualifiers */

  init_pam();
  init_analyze();
  found_fs_qual = FALSE; /* Force reset, since init_analyze may
			    look up some quals */

  /* Now analyze the prelude files */
  in_prelude = TRUE;
  dd_scan(cur, preludes)
    {
      char *file;
      
      file = DD_GET(char *, cur);
      fprintf(stderr, "Analyzing prelude %s\n", file);
      compile_file(file);
    }
Exemplo n.º 18
0
Arquivo: omgidl.c Projeto: spchamp/ilu
int main(int argc, char* argv[])
{
  char *filename;
  extern FILE* idlin;
  extern int idl_flex_debug;
  list defs;
  list toplevel_prefix; /* Current prefix for repository ID. */
  int i;

  search_list = iluparser_new_list ();

  for (i = 1; i < argc; i++){
    if (argv[i][0] != '-')
      break;
    switch (argv[i][1]){
    case 'a':
      idl_subset |= IDL_STYLE_GUIDE;
      break;
    case 'I':
      if (argv[i][2])
	list_insert (search_list, argv[i]+2);
      else
	list_insert (search_list, argv[++i]);
      break;
    case 'h':
    default:
      usage();
      break;
    }
  }
  if (i+1 != argc)
    usage();
  filename = argv[i];
	
  /* Open top-level IDL file. */
  init_types();
  idl_flex_debug=0;
  if ((idlin = fopen (filename, "r")) == NULL)
    {
      perror(argv[1]);
      exit(1);
    }

  /* Syntactical analysis */
  idlsetinitialfile(filename);
  if(idlparse())
    return 1;
  defs = the_result;

  /* Semantical analysis */

  /* join modules for re-opening */
  defs = reopen_modules (defs);
  /* backlink, toplevel has no parent */
  list_enumerate (defs, definition_backlink,0);
  /* resolve all names */
  list_enumerate (defs, definition_resolvenames, defs);
  /* perform consistency checks, compute constants */
  list_enumerate (defs, definition_check, defs);
  /* assign repository IDs */
  toplevel_prefix = iluparser_new_list ();
  list_push (toplevel_prefix, "");
  list_enumerate (defs, definition_setuid, toplevel_prefix);
  /* Test conformance with AB style guide */
  list_enumerate (defs, ab_style, 0);

  /* Drop all results :-) */
  return 0;
}