Also, fix a C++ problem when looking for methods in super-classes.
(There was confusion between base and derived types.)
+Tue Nov 5 16:47:47 1991 Per Bothner (bothner at cygnus.com)
+
+ Add C++ as a separate language.
+ * defs.h (enum language): Add language_cplus.
+ * dwarfread.c (end_symtab): Support language_cplus.
+ * c-exp.y: Add new struct language_defn cplus_language_defn.
+ Don't set c to be the default language (see main.c).
+ * c-exp.y (yylex): Only look for field of this if
+ language is C++. (First difference from C!)
+ * language.c: Add case branches for C++ (currently, all
+ the same as C). Also, add c++ to "usage" note for "set lang".
+ * valprint.c (typedef_print). Add case branches for C++.
+ * main.c (main): New way to set initial language: Look at
+ file extension of psymtab containing main(). (Same as we
+ do for symtabs, but avoid loading the symtab yet.)
+ * symtab.c: New routine find_main_psymtab(), used by main()
+ to set initial language.
+ * symfile.c (allocate_symtab): Move code for mapping file
+ extensions-> languages to new deduce_language_from_filename().
+
+ Fix a C++ problem when looking for methods in super-classes.
+ There was confusion between base and derived types.
+ * valops.c (value_fn_field): Change function interface.
+ * values.c: Use new value_fn_field interface.
+
Mon Nov 4 10:49:33 1991 Per Bothner (bothner at cygnus.com)
* infrun.c: Fixed typo in comment.
int hextype;
sym = lookup_symbol (tmp, expression_context_block,
- VAR_NAMESPACE, &is_a_field_of_this, NULL);
+ VAR_NAMESPACE,
+ current_language->la_language == language_cplus
+ ? &is_a_field_of_this : NULL,
+ NULL);
if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
lookup_partial_symtab (tmp))
{
0
};
-/* FIXME: Eventually do a separate defintion for C++. */
-
const struct language_defn c_language_defn = {
"c", /* Language name */
language_c,
LANG_MAGIC
};
+const struct language_defn cplus_language_defn = {
+ "c++", /* Language name */
+ language_cplus,
+ c_builtin_types,
+ range_check_off,
+ type_check_off,
+ c_parse,
+ c_error,
+ &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
+ &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
+ &builtin_type_double, /* longest floating point type */ /*FIXME*/
+ "0x%x", "0x%", "x", /* Hex format, prefix, suffix */
+ "0%o", "0%", "o", /* Octal format, prefix, suffix */
+ c_op_print_tab, /* expression operators for printing */
+ LANG_MAGIC
+};
+
void
_initialize_c_exp ()
{
"double complex");
add_language (&c_language_defn);
- set_language (language_c); /* Make C the default language */
+ add_language (&cplus_language_defn);
}
symtab -> line_charpos = 0;
/* FIXME: The following may need to be expanded for other languages */
- if (language == LANG_C89 || language == LANG_C)
+ switch (language)
{
- symtab -> language = language_c;
+ case LANG_C89:
+ case LANG_C:
+ symtab -> language = language_c;
+ break;
+ case LANG_C_PLUS_PLUS:
+ symtab -> language = language_cplus;
+ break;
+ default:
+ ;
}
-
+
/* Link the new symtab into the list of such. */
symtab -> next = symtab_list;
symtab_list = symtab;
printf("The currently understood settings are:\n\n\
local or auto Automatic setting based on source file\n\
c Use the C language\n\
+c++ Use the C++ language\n\
modula-2 Use the Modula-2 language\n");
/* Restore the silly string. */
set_language(current_language->la_language);
current_language = languages[i];
set_type_range ();
set_lang_str();
+ break;
}
}
}
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
if (TYPE_CODE(VALUE_TYPE(v1))==TYPE_CODE_FLT)
return TYPE_CODE(VALUE_TYPE(v2)) == TYPE_CODE_FLT && l2 > l1 ?
VALUE_TYPE(v2) : VALUE_TYPE(v1);
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) != TYPE_CODE_INT) &&
(TYPE_CODE(type) != TYPE_CODE_ENUM) ? 0 : 1;
case language_m2:
return TYPE_CODE(type) != TYPE_CODE_CHAR ? 0 : 1;
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) == TYPE_CODE_INT) &&
TYPE_LENGTH(type) == sizeof(char)
? 1 : 0;
return TYPE_CODE(type) != TYPE_CODE_BOOL ? 0 : 1;
case language_c:
+ case language_cplus:
return TYPE_CODE(type) != TYPE_CODE_INT ? 0 : 1;
}
}
switch(current_language->la_language)
{
case language_c:
+ case language_cplus:
return (TYPE_CODE(type) == TYPE_CODE_STRUCT) ||
(TYPE_CODE(type) == TYPE_CODE_UNION) ||
(TYPE_CODE(type) == TYPE_CODE_ARRAY);
switch (current_language->la_language) {
case language_c:
+ case language_cplus:
return !value_zerop (val);
case language_m2:
{
#ifdef _LANG_c
case language_c:
+ case language_cplus:
switch(op)
{
case BINOP_DIV:
return value_primitive_field (arg1, 0, fieldno, VALUE_TYPE (arg1));
}
+/* Return a non-virtual function as a value.
+ F is the list of member functions which contains the desired method.
+ J is an index into F which provides the desired method. */
+
value
-value_fn_field (arg1, fieldno, subfieldno)
- register value arg1;
- register int fieldno;
- int subfieldno;
+value_fn_field (f, j)
+ struct fn_field *f;
+ int j;
{
register value v;
- struct fn_field *f = TYPE_FN_FIELDLIST1 (VALUE_TYPE (arg1), fieldno);
- register struct type *type = TYPE_FN_FIELD_TYPE (f, subfieldno);
+ register struct type *type = TYPE_FN_FIELD_TYPE (f, j);
struct symbol *sym;
- sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, subfieldno),
+ sym = lookup_symbol (TYPE_FN_FIELD_PHYSNAME (f, j),
0, VAR_NAMESPACE, 0, NULL);
if (! sym) error ("Internal error: could not find physical method named %s",
- TYPE_FN_FIELD_PHYSNAME (f, subfieldno));
+ TYPE_FN_FIELD_PHYSNAME (f, j));
v = allocate_value (type);
VALUE_ADDRESS (v) = BLOCK_START (SYMBOL_BLOCK_VALUE (sym));