void alloc_aux_for_edges (int size) { static int initialized; if (!initialized) { gcc_obstack_init (&edge_aux_obstack); initialized = 1; } else /* Check whether AUX data are still allocated. */ gcc_assert (!first_edge_aux_obj); first_edge_aux_obj = obstack_alloc (&edge_aux_obstack, 0); if (size) { basic_block bb; FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) { edge e; edge_iterator ei; FOR_EACH_EDGE (e, ei, bb->succs) alloc_aux_for_edge (e, size); } }
/* Initialize the string pool. */ void init_stringpool (void) { /* Create with 16K (2^14) entries. */ ident_hash = ht_create (14); ident_hash->alloc_node = alloc_node; ident_hash->alloc_subobject = stringpool_ggc_alloc; gcc_obstack_init (&string_stack); }
/* Initialize the string pool. */ void init_stringpool () { /* Create with 16K (2^14) entries. */ ident_hash = ht_create (14); ident_hash->alloc_node = alloc_node; gcc_obstack_init (&string_stack); ggc_add_root (&ident_hash, 1, sizeof ident_hash, mark_ident_hash); }
static void init_mangling (void) { if (!mangle_obstack) { mangle_obstack = &mangle_obstack_1; gcc_obstack_init (mangle_obstack); } gcc_assert (compression_table == NULL); compression_table = make_tree_vec (10); /* Mangled name are to be suffixed */ MANGLE_RAW_STRING ("_Z"); }
/* Initialize the string pool. */ void init_stringpool () { /* Create with 16K (2^14) entries. */ /* APPLE LOCAL PFE */ #ifdef PFE /* Create identifier hashtable, only if we are not doing PFE_LOAD. If we are doing PFE_LOAD then it is already loaded from the precompiled header. */ if (pfe_operation != PFE_LOAD) #endif ident_hash = ht_create (14); ident_hash->alloc_node = alloc_node; gcc_obstack_init (&string_stack); ggc_add_root (&ident_hash, 1, sizeof ident_hash, mark_ident_hash); }
void init_flow () { static int initialized; first_deleted_edge = 0; first_deleted_block = 0; n_edges = 0; if (!initialized) { gcc_obstack_init (&flow_obstack); flow_firstobj = (char *) obstack_alloc (&flow_obstack, 0); initialized = 1; } else { obstack_free (&flow_obstack, flow_firstobj); flow_firstobj = (char *) obstack_alloc (&flow_obstack, 0); } }
void alloc_aux_for_blocks (int size) { static int initialized; if (!initialized) { gcc_obstack_init (&block_aux_obstack); initialized = 1; } else /* Check whether AUX data are still allocated. */ gcc_assert (!first_block_aux_obj); first_block_aux_obj = obstack_alloc (&block_aux_obstack, 0); if (size) { basic_block bb; FOR_ALL_BB (bb) alloc_aux_for_block (bb, size); } }
static enum cpp_ttype lex_string (const cpp_token *tok, tree *valp, bool objc_string) { tree value; bool wide = false; size_t concats = 0; struct obstack str_ob; cpp_string istr; /* Try to avoid the overhead of creating and destroying an obstack for the common case of just one string. */ cpp_string str = tok->val.str; cpp_string *strs = &str; if (tok->type == CPP_WSTRING) wide = true; retry: tok = cpp_get_token (parse_in); switch (tok->type) { case CPP_PADDING: goto retry; case CPP_ATSIGN: if (c_dialect_objc ()) { objc_string = true; goto retry; } /* FALLTHROUGH */ default: break; case CPP_WSTRING: wide = true; /* FALLTHROUGH */ case CPP_STRING: if (!concats) { gcc_obstack_init (&str_ob); obstack_grow (&str_ob, &str, sizeof (cpp_string)); } concats++; obstack_grow (&str_ob, &tok->val.str, sizeof (cpp_string)); goto retry; } /* We have read one more token than we want. */ _cpp_backup_tokens (parse_in, 1); if (concats) strs = XOBFINISH (&str_ob, cpp_string *); if (concats && !objc_string && !in_system_header) warning (OPT_Wtraditional, "traditional C rejects string constant concatenation"); if ((c_lex_string_translate ? cpp_interpret_string : cpp_interpret_string_notranslate) (parse_in, strs, concats + 1, &istr, wide)) { value = build_string (istr.len, (char *) istr.text); free ((void *) istr.text); if (c_lex_string_translate == -1) { int xlated = cpp_interpret_string_notranslate (parse_in, strs, concats + 1, &istr, wide); /* Assume that, if we managed to translate the string above, then the untranslated parsing will always succeed. */ gcc_assert (xlated); if (TREE_STRING_LENGTH (value) != (int) istr.len || 0 != strncmp (TREE_STRING_POINTER (value), (char *) istr.text, istr.len)) { /* Arrange for us to return the untranslated string in *valp, but to set up the C type of the translated one. */ *valp = build_string (istr.len, (char *) istr.text); valp = &TREE_CHAIN (*valp); } free ((void *) istr.text); } } else { /* Callers cannot generally handle error_mark_node in this context, so return the empty string instead. cpp_interpret_string has issued an error. */ if (wide) value = build_string (TYPE_PRECISION (wchar_type_node) / TYPE_PRECISION (char_type_node), "\0\0\0"); /* widest supported wchar_t is 32 bits */ else value = build_string (1, ""); } TREE_TYPE (value) = wide ? wchar_array_type_node : char_array_type_node; *valp = fix_string_type (value); if (concats) obstack_free (&str_ob, 0); return objc_string ? CPP_OBJC_STRING : wide ? CPP_WSTRING : CPP_STRING; }
int main (int argc, char **argv) { char *classname, *p; FILE *stream; const char *mangled_classname; int i, last_arg; int indirect = 0; char *prog_name = argv[0]; /* Unlock the stdio streams. */ unlock_std_streams (); gcc_init_libintl (); if (argc > 1 && ! strcmp (argv[1], "-findirect-dispatch")) { indirect = 1; ++argv; --argc; } if (argc < 2) usage (prog_name); for (i = 1; i < argc; ++i) { if (! strncmp (argv[i], "-D", 2)) { /* Handled later. */ } else break; } if (i < argc - 2 || i == argc) usage (prog_name); last_arg = i; classname = argv[i]; /* gcj always appends `main' to classname. We need to strip this here. */ p = strrchr (classname, 'm'); if (p == NULL || p == classname || strcmp (p, "main") != 0) usage (prog_name); else *p = '\0'; gcc_obstack_init (mangle_obstack); mangled_classname = do_mangle_classname (classname); if (i < argc - 1 && strcmp (argv[i + 1], "-") != 0) { const char *outfile = argv[i + 1]; stream = fopen (outfile, "w"); if (stream == NULL) { fprintf (stderr, _("%s: Cannot open output file: %s\n"), prog_name, outfile); exit (1); } } else stream = stdout; /* At this point every element of ARGV from 1 to LAST_ARG is a `-D' option. Process them appropriately. */ fprintf (stream, "extern const char **_Jv_Compiler_Properties;\n"); fprintf (stream, "static const char *props[] =\n{\n"); for (i = 1; i < last_arg; ++i) { const char *p; fprintf (stream, " \""); for (p = &argv[i][2]; *p; ++p) { if (! ISPRINT (*p)) fprintf (stream, "\\%o", *p); else if (*p == '\\' || *p == '"') fprintf (stream, "\\%c", *p); else putc (*p, stream); } fprintf (stream, "\",\n"); } fprintf (stream, " 0\n};\n\n"); fprintf (stream, "int main (int argc, const char **argv)\n"); fprintf (stream, "{\n"); fprintf (stream, " _Jv_Compiler_Properties = props;\n"); if (indirect) fprintf (stream, " JvRunMainName (\"%s\", argc, argv);\n", classname); else { fprintf (stream, " extern char %s;\n", mangled_classname); fprintf (stream, " JvRunMain (&%s, argc, argv);\n", mangled_classname); } fprintf (stream, "}\n"); if (stream != stdout && fclose (stream) != 0) { fprintf (stderr, _("%s: Failed to close output file %s\n"), prog_name, argv[2]); exit (1); } return 0; }
/* jc1-lite main entry point */ int main (int argc, char **argv) { int i = 1; const char *output_file = NULL; const char *encoding = NULL; long ft; int opt; exec_name = argv[0]; /* Default for output */ out = stdout; /* Unlock the stdio streams. */ unlock_std_streams (); gcc_init_libintl (); /* Process options first. We use getopt_long and not getopt_long_only because we only support `--' long options here. */ while ((opt = getopt_long (argc, argv, "o:", options, NULL)) != -1) { switch (opt) { case 0: /* Already handled. */ break; case 'o': output_file = optarg; break; case OPT_HELP: help (); break; case OPT_VERSION: version (); break; case OPT_ENCODING: encoding = optarg; break; default: usage (); break; } } /* No flags? Do nothing */ if (! flag_find_main && ! flag_dump_class && ! flag_complexity) return 0; /* Check on bad usage */ if (flag_find_main + flag_dump_class + flag_complexity > 1) fatal_error ("only one of '--print-main', '--list-class', and '--complexity' allowed"); if (output_file && !(out = fopen (output_file, "w"))) fatal_error ("can't open output file '%s'", output_file); ft = ftell (out); gcc_obstack_init (&temporary_obstack); java_push_parser_context (); for ( i = optind; i < argc; i++ ) if (argv [i]) { char *filename = argv[i]; if ( (finput = fopen (filename, "r")) ) { /* There's no point in trying to find the current encoding unless we are going to do something intelligent with it -- hence the test for iconv. */ #if defined (HAVE_LOCALE_H) && defined (HAVE_ICONV) && defined (HAVE_LANGINFO_CODESET) setlocale (LC_CTYPE, ""); if (encoding == NULL) encoding = nl_langinfo (CODESET); #endif if (encoding == NULL || *encoding == '\0') encoding = DEFAULT_ENCODING; main_input_filename = filename; java_init_lex (finput, encoding); ctxp->filename = filename; yyparse (); report (); if (ftell (out) != ft) fputc ('\n', out); ft = ftell (out); fclose (finput); reset_report (); } else fatal_error ("file not found '%s'", argv [i]); } /* Flush and close */ if (ftell (out) != ft) fputc ('\n', out); if (!output_file) fclose (out); return 0; }
void init_iterators () { gcc_obstack_init (&ixp_obstack); ixp_firstobj = (char *) obstack_alloc (&ixp_obstack, 0); }
void init_error () { gcc_obstack_init (&scratch_obstack); scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0); }