+2016-06-23 Tom Tromey <tom@tromey.com>
+
+ * ada-lang.c (ada_extensions): New array.
+ (ada_language_defn): Use it.
+ * c-lang.c (c_extensions): New array.
+ (c_language_defn): Use it.
+ (cplus_extensions): New array.
+ (cplus_language_defn): Use it.
+ (asm_extensions): New array.
+ (asm_language_defn): Use it.
+ (minimal_language_defn): Update.
+ * d-lang.c (d_extensions): New array.
+ (d_language_defn): Use it.
+ * f-lang.c (f_extensions): New array.
+ (f_language_defn): Use it.
+ * go-lang.c (go_language_defn): Update.
+ * jv-lang.c (java_extensions): New array.
+ (java_language_defn): Use it.
+ * language.c (add_language): Call add_filename_language.
+ (unknown_language_defn, auto_language_defn, local_language_defn):
+ Update.
+ * language.h (struct language_defn) <la_filename_extensions>: New
+ field.
+ * m2-lang.c (m2_language_defn): Update.
+ * objc-lang.c (objc_extensions): New array.
+ (objc_language_defn): Use it.
+ * opencl-lang.c (opencl_language_defn): Update.
+ * p-lang.c (p_extensions): New array.
+ (pascal_language_defn): Use it.
+ * rust-lang.c (rust_extensions): New array.
+ (rust_language_defn): Use it.
+ * symfile.c (add_filename_language): No longer static. Make "ext"
+ const.
+ (init_filename_language_table): Remove.
+ (_initialize_symfile): Update.
+ * symfile.h (add_filename_language): Declare.
+
2016-06-23 Tom Tromey <tom@tromey.com>
* symfile.c (filename_language_table): Now a VEC.
return default_read_var_value (var, var_block, frame);
}
+static const char *ada_extensions[] =
+{
+ ".adb", ".ads", ".a", ".ada", ".dg", NULL
+};
+
const struct language_defn ada_language_defn = {
"ada", /* Language name */
"Ada",
that's not quite what this means. */
array_row_major,
macro_expansion_no,
+ ada_extensions,
&ada_exp_descriptor,
parse,
ada_yyerror,
evaluate_subexp_c
};
+static const char *c_extensions[] =
+{
+ ".c", NULL
+};
+
const struct language_defn c_language_defn =
{
"c", /* Language name */
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ c_extensions,
&exp_descriptor_c,
c_parse,
c_yyerror,
lai->bool_type_default = builtin->builtin_bool;
}
+static const char *cplus_extensions[] =
+{
+ ".C", ".cc", ".cp", ".cpp", ".cxx", ".c++", NULL
+};
+
const struct language_defn cplus_language_defn =
{
"c++", /* Language name */
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ cplus_extensions,
&exp_descriptor_c,
c_parse,
c_yyerror,
LANG_MAGIC
};
+static const char *asm_extensions[] =
+{
+ ".s", ".sx", ".S", NULL
+};
+
const struct language_defn asm_language_defn =
{
"asm", /* Language name */
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ asm_extensions,
&exp_descriptor_c,
c_parse,
c_yyerror,
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ NULL,
&exp_descriptor_c,
c_parse,
c_yyerror,
lai->bool_type_default = builtin->builtin_bool;
}
+static const char *d_extensions[] =
+{
+ ".d", NULL
+};
+
static const struct language_defn d_language_defn =
{
"d",
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ d_extensions,
&exp_descriptor_c,
d_parse,
d_yyerror,
return default_make_symbol_completion_list_break_on (text, word, ":", code);
}
+static const char *f_extensions[] =
+{
+ ".f", ".F", ".for", ".FOR", ".ftn", ".FTN", ".fpp", ".FPP",
+ ".f90", ".F90", ".f95", ".F95", ".f03", ".F03", ".f08", ".F08",
+ NULL
+};
+
const struct language_defn f_language_defn =
{
"fortran",
case_sensitive_off,
array_column_major,
macro_expansion_no,
+ f_extensions,
&exp_descriptor_standard,
f_parse, /* parser */
f_yyerror, /* parser error function */
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ NULL,
&exp_descriptor_c,
go_parse,
go_yyerror,
evaluate_subexp_java
};
+static const char *java_extensions[] =
+{
+ ".java", ".class", NULL
+};
+
const struct language_defn java_language_defn =
{
"java", /* Language name */
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ java_extensions,
&exp_descriptor_java,
java_parse,
java_yyerror,
language_names[i] = languages[i]->la_name;
language_names[i] = NULL;
+ /* Add the filename extensions. */
+ if (lang->la_filename_extensions != NULL)
+ {
+ int i;
+
+ for (i = 0; lang->la_filename_extensions[i] != NULL; ++i)
+ add_filename_language (lang->la_filename_extensions[i],
+ lang->la_language);
+ }
+
/* Build the "help set language" docs. */
tmp_stream = mem_fileopen ();
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ NULL,
&exp_descriptor_standard,
unk_lang_parser,
unk_lang_error,
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ NULL,
&exp_descriptor_standard,
unk_lang_parser,
unk_lang_error,
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ NULL,
&exp_descriptor_standard,
unk_lang_parser,
unk_lang_error,
/* Style of macro expansion, if any, supported by this language. */
enum macro_expansion la_macro_expansion;
+ /* A NULL-terminated array of file extensions for this language.
+ The extension must include the ".", like ".c". If this
+ language doesn't need to provide any filename extensions, this
+ may be NULL. */
+
+ const char *const *la_filename_extensions;
+
/* Definitions related to expression printing, prefixifying, and
dumping. */
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ NULL,
&exp_descriptor_modula2,
m2_parse, /* parser */
m2_yyerror, /* parser error function */
{NULL, OP_NULL, PREC_NULL, 0}
};
+static const char *objc_extensions[] =
+{
+ ".m", NULL
+};
+
const struct language_defn objc_language_defn = {
"objective-c", /* Language name */
"Objective-C",
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ objc_extensions,
&exp_descriptor_standard,
c_parse,
c_yyerror,
case_sensitive_on,
array_row_major,
macro_expansion_c,
+ NULL,
&exp_descriptor_opencl,
c_parse,
c_yyerror,
lai->bool_type_default = builtin->builtin_bool;
}
+static const char *p_extensions[] =
+{
+ ".pas", ".p", ".pp", NULL
+};
+
const struct language_defn pascal_language_defn =
{
"pascal", /* Language name */
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ p_extensions,
&exp_descriptor_standard,
pascal_parse,
pascal_yyerror,
rust_evaluate_subexp
};
+static const char *rust_extensions[] =
+{
+ ".rs", NULL
+};
+
static const struct language_defn rust_language_defn =
{
"rust",
case_sensitive_on,
array_row_major,
macro_expansion_no,
+ rust_extensions,
&exp_descriptor_rust,
rust_parse,
rustyyerror,
static int simple_overlay_update_1 (struct obj_section *);
-static void add_filename_language (char *ext, enum language lang);
-
static void info_ext_lang_command (char *args, int from_tty);
-static void init_filename_language_table (void);
-
static void symfile_find_segment_sections (struct objfile *objfile);
void _initialize_symfile (void);
static VEC (filename_language) *filename_language_table;
-static void
-add_filename_language (char *ext, enum language lang)
+/* See symfile.h. */
+
+void
+add_filename_language (const char *ext, enum language lang)
{
filename_language entry;
printf_filtered ("\t%s\t- %s\n", entry->ext, language_str (entry->lang));
}
-static void
-init_filename_language_table (void)
-{
- /* Protect against repetition. */
- if (VEC_empty (filename_language, filename_language_table))
- {
- add_filename_language (".c", language_c);
- add_filename_language (".d", language_d);
- add_filename_language (".C", language_cplus);
- add_filename_language (".cc", language_cplus);
- add_filename_language (".cp", language_cplus);
- add_filename_language (".cpp", language_cplus);
- add_filename_language (".cxx", language_cplus);
- add_filename_language (".c++", language_cplus);
- add_filename_language (".java", language_java);
- add_filename_language (".class", language_java);
- add_filename_language (".m", language_objc);
- add_filename_language (".f", language_fortran);
- add_filename_language (".F", language_fortran);
- add_filename_language (".for", language_fortran);
- add_filename_language (".FOR", language_fortran);
- add_filename_language (".ftn", language_fortran);
- add_filename_language (".FTN", language_fortran);
- add_filename_language (".fpp", language_fortran);
- add_filename_language (".FPP", language_fortran);
- add_filename_language (".f90", language_fortran);
- add_filename_language (".F90", language_fortran);
- add_filename_language (".f95", language_fortran);
- add_filename_language (".F95", language_fortran);
- add_filename_language (".f03", language_fortran);
- add_filename_language (".F03", language_fortran);
- add_filename_language (".f08", language_fortran);
- add_filename_language (".F08", language_fortran);
- add_filename_language (".s", language_asm);
- add_filename_language (".sx", language_asm);
- add_filename_language (".S", language_asm);
- add_filename_language (".pas", language_pascal);
- add_filename_language (".p", language_pascal);
- add_filename_language (".pp", language_pascal);
- add_filename_language (".adb", language_ada);
- add_filename_language (".ads", language_ada);
- add_filename_language (".a", language_ada);
- add_filename_language (".ada", language_ada);
- add_filename_language (".dg", language_ada);
- add_filename_language (".rs", language_rust);
- }
-}
-
enum language
deduce_language_from_filename (const char *filename)
{
_("Read the overlay mapping state from the target."), &overlaylist);
/* Filename extension to source language lookup table: */
- init_filename_language_table ();
add_setshow_string_noescape_cmd ("extension-language", class_files,
&ext_args, _("\
Set mapping between filename extension and source language."), _("\
extern enum language deduce_language_from_filename (const char *);
+/* Map the filename extension EXT to the language LANG. Any previous
+ association of EXT will be removed. EXT will be copied by this
+ function. */
+extern void add_filename_language (const char *ext, enum language lang);
+
/* This enum encodes bit-flags passed as ADD_FLAGS parameter to
symbol_file_add, etc. */