* c-exp.y: Fix problems with parsing "'foo.bar'::func". Some languages

allow symbols with dots.

	* gdbtypes.c (check_stub_method):  Cosmetic.  Use more descriptive
	names for parameters.

start-sanitize-java
	* jv-exp.y:  Parser now accepts primitive types.
	* (parse_number):  Use correct ifdef for scanf long double support.
	* jv-lang.c (java_array_type):  Initial cut at array support.
end-sanitize-java

	* language.c language.h (set_language):  Now returns previous language.

	* symtab.c (find_methods):  Make static.  Cosmetic changes, including
	indentation, and adding descriptive comments.  Move local variable defs
	into the block they are used in.
	* Don't call check_stub_method any more.  Use gdb_mangle_name to
	generate the full method name.  find_method doesn't need all the other
	goobldegook that check_stub_method does.
	* (gdb_mangle_name):  Use more descriptive names for parameters.  Fix
	comment.
start-sanitize-java
	* (lookup_partial_symbol lookup_block_symbol):  Check for java to
	ensure we can find mangled names.
end-sanitize-java
	* (decode_line_1):  Move local variable defs into the block they are
	used in.  (Improves code readability.)
This commit is contained in:
Stu Grossman 1998-06-10 23:29:59 +00:00
parent a27a2a8de4
commit f6d23b6f3b
7 changed files with 104 additions and 40 deletions

View File

@ -1,3 +1,34 @@
Wed Jun 10 15:39:14 1998 Stu Grossman <grossman@babylon-5.cygnus.com>
* c-exp.y: Fix problems with parsing "'foo.bar'::func". Some languages
allow symbols with dots.
* gdbtypes.c (check_stub_method): Cosmetic. Use more descriptive
names for parameters.
start-sanitize-java
* jv-exp.y: Parser now accepts primitive types.
* (parse_number): Use correct ifdef for scanf long double support.
* jv-lang.c (java_array_type): Initial cut at array support.
end-sanitize-java
* language.c language.h (set_language): Now returns previous language.
* symtab.c (find_methods): Make static. Cosmetic changes, including
indentation, and adding descriptive comments. Move local variable defs
into the block they are used in.
* Don't call check_stub_method any more. Use gdb_mangle_name to
generate the full method name. find_method doesn't need all the other
goobldegook that check_stub_method does.
* (gdb_mangle_name): Use more descriptive names for parameters. Fix
comment.
start-sanitize-java
* (lookup_partial_symbol lookup_block_symbol): Check for java to
ensure we can find mangled names.
end-sanitize-java
* (decode_line_1): Move local variable defs into the block they are
used in. (Improves code readability.)
Wed Jun 10 14:06:05 1998 Jason Molenda (crash@bugshack.cygnus.com) Wed Jun 10 14:06:05 1998 Jason Molenda (crash@bugshack.cygnus.com)
* configure.in: Add some tests for gnu-regex.c's benefit. * configure.in: Add some tests for gnu-regex.c's benefit.

View File

@ -214,6 +214,7 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *));
%right UNARY INCREMENT DECREMENT %right UNARY INCREMENT DECREMENT
%right ARROW '.' '[' '(' %right ARROW '.' '[' '('
%token <ssym> BLOCKNAME %token <ssym> BLOCKNAME
%token <bval> FILENAME
%type <bval> block %type <bval> block
%left COLONCOLON %left COLONCOLON
@ -531,18 +532,15 @@ exp : THIS
block : BLOCKNAME block : BLOCKNAME
{ {
if ($1.sym != 0) if ($1.sym)
$$ = SYMBOL_BLOCK_VALUE ($1.sym); $$ = SYMBOL_BLOCK_VALUE ($1.sym);
else else
{ error ("No file or function \"%s\".",
struct symtab *tem = copy_name ($1.stoken));
lookup_symtab (copy_name ($1.stoken)); }
if (tem) | FILENAME
$$ = BLOCKVECTOR_BLOCK (BLOCKVECTOR (tem), STATIC_BLOCK); {
else $$ = $1;
error ("No file or function \"%s\".",
copy_name ($1.stoken));
}
} }
; ;
@ -1526,13 +1524,25 @@ yylex ()
/* Call lookup_symtab, not lookup_partial_symtab, in case there are /* Call lookup_symtab, not lookup_partial_symtab, in case there are
no psymtabs (coff, xcoff, or some future change to blow away the no psymtabs (coff, xcoff, or some future change to blow away the
psymtabs once once symbols are read). */ psymtabs once once symbols are read). */
if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) || if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
lookup_symtab (tmp))
{ {
yylval.ssym.sym = sym; yylval.ssym.sym = sym;
yylval.ssym.is_a_field_of_this = is_a_field_of_this; yylval.ssym.is_a_field_of_this = is_a_field_of_this;
return BLOCKNAME; return BLOCKNAME;
} }
else if (!sym)
{ /* See if it's a file name. */
struct symtab *symtab;
symtab = lookup_symtab (tmp);
if (symtab)
{
yylval.bval = BLOCKVECTOR_BLOCK (BLOCKVECTOR (symtab), STATIC_BLOCK);
return FILENAME;
}
}
if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF) if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
{ {
#if 1 #if 1

View File

@ -1238,13 +1238,13 @@ cfront_mangle_name(type, i, j)
the space required for them. */ the space required for them. */
void void
check_stub_method (type, i, j) check_stub_method (type, method_id, signature_id)
struct type *type; struct type *type;
int i; int method_id;
int j; int signature_id;
{ {
struct fn_field *f; struct fn_field *f;
char *mangled_name = gdb_mangle_name (type, i, j); char *mangled_name = gdb_mangle_name (type, method_id, signature_id);
char *demangled_name = cplus_demangle (mangled_name, char *demangled_name = cplus_demangle (mangled_name,
DMGL_PARAMS | DMGL_ANSI); DMGL_PARAMS | DMGL_ANSI);
char *argtypetext, *p; char *argtypetext, *p;
@ -1331,16 +1331,16 @@ check_stub_method (type, i, j)
free (demangled_name); free (demangled_name);
f = TYPE_FN_FIELDLIST1 (type, i); f = TYPE_FN_FIELDLIST1 (type, method_id);
TYPE_FN_FIELD_PHYSNAME (f, j) = mangled_name; TYPE_FN_FIELD_PHYSNAME (f, signature_id) = mangled_name;
/* Now update the old "stub" type into a real type. */ /* Now update the old "stub" type into a real type. */
mtype = TYPE_FN_FIELD_TYPE (f, j); mtype = TYPE_FN_FIELD_TYPE (f, signature_id);
TYPE_DOMAIN_TYPE (mtype) = type; TYPE_DOMAIN_TYPE (mtype) = type;
TYPE_ARG_TYPES (mtype) = argtypes; TYPE_ARG_TYPES (mtype) = argtypes;
TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB; TYPE_FLAGS (mtype) &= ~TYPE_FLAG_STUB;
TYPE_FN_FIELD_STUB (f, j) = 0; TYPE_FN_FIELD_STUB (f, signature_id) = 0;
} }
const struct cplus_struct_type cplus_struct_default; const struct cplus_struct_type cplus_struct_default;

View File

@ -151,7 +151,7 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *));
%type <lval> rcurly Dims Dims_opt %type <lval> rcurly Dims Dims_opt
%type <tval> ClassOrInterfaceType ClassType /* ReferenceType Type ArrayType */ %type <tval> ClassOrInterfaceType ClassType /* ReferenceType Type ArrayType */
%type <tval> IntegralType FloatingPointType NumericType PrimitiveType %type <tval> IntegralType FloatingPointType NumericType PrimitiveType ArrayType PrimitiveOrArrayType
%token <typed_val_int> INTEGER_LITERAL %token <typed_val_int> INTEGER_LITERAL
%token <typed_val_float> FLOATING_POINT_LITERAL %token <typed_val_float> FLOATING_POINT_LITERAL
@ -201,7 +201,20 @@ parse_number PARAMS ((char *, int, int, YYSTYPE *));
%% %%
start : exp1 start : exp1
/* | type_exp FIXME */ | type_exp
;
type_exp: PrimitiveOrArrayType
{
write_exp_elt_opcode(OP_TYPE);
write_exp_elt_type($1);
write_exp_elt_opcode(OP_TYPE);
}
;
PrimitiveOrArrayType:
PrimitiveType
| ArrayType
; ;
StringLiteral: StringLiteral:
@ -294,14 +307,12 @@ ClassType:
ClassOrInterfaceType ClassOrInterfaceType
; ;
/* UNUSED:
ArrayType: ArrayType:
PrimitiveType Dims PrimitiveType Dims
{ $$ = java_array_type ($1, $2); } { $$ = java_array_type ($1, $2); }
| Name Dims | Name Dims
{ $$ = java_array_type (java_type_from_name ($1), $2); } { $$ = java_array_type (java_type_from_name ($1), $2); }
; ;
*/
Name: Name:
IDENTIFIER IDENTIFIER
@ -697,7 +708,7 @@ parse_number (p, len, parsed_float, putithere)
num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval, &c); num = sscanf (p, "%lg%c", (double *) &putithere->typed_val_float.dval, &c);
else else
{ {
#ifdef PRINTF_HAS_LONG_DOUBLE #ifdef SCANF_HAS_LONG_DOUBLE
num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval, &c); num = sscanf (p, "%Lg%c", &putithere->typed_val_float.dval, &c);
#else #else
/* Scan it into a double, then assign it to the long double. /* Scan it into a double, then assign it to the long double.
@ -723,7 +734,7 @@ parse_number (p, len, parsed_float, putithere)
return ERROR; return ERROR;
return FLOATING_POINT_LITERAL; return FLOATING_POINT_LITERAL;
} }
/* Handle base-switching prefixes 0x, 0t, 0d, 0 */ /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
if (p[0] == '0') if (p[0] == '0')
@ -1080,13 +1091,13 @@ yylex ()
(c == '_' || c == '$' || (c >= '0' && c <= '9') (c == '_' || c == '$' || (c >= '0' && c <= '9')
|| (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');) || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '<');)
{ {
if (c == '<') if (c == '<')
{ {
int i = namelen; int i = namelen;
while (tokstart[++i] && tokstart[i] != '>'); while (tokstart[++i] && tokstart[i] != '>');
if (tokstart[i] == '>') if (tokstart[i] == '>')
namelen = i; namelen = i;
} }
c = tokstart[++namelen]; c = tokstart[++namelen];
} }

View File

@ -681,9 +681,16 @@ java_array_type (type, dims)
struct type *type; struct type *type;
int dims; int dims;
{ {
if (dims == 0) struct type *range_type;
return type;
error ("array types not implemented"); while (dims-- > 0)
{
range_type = create_range_type (NULL, builtin_type_int, 0, 0);
type = create_array_type (NULL, type, range_type);
}
return type;
} }
/* Create a Java string in the inferior from a (Utf8) literal. */ /* Create a Java string in the inferior from a (Utf8) literal. */

View File

@ -345,13 +345,16 @@ set_type_range()
set_range_str(); set_range_str();
} }
/* Set current language to (enum language) LANG. */ /* Set current language to (enum language) LANG. Returns previous language. */
void enum language
set_language(lang) set_language(lang)
enum language lang; enum language lang;
{ {
int i; int i;
enum language prev_language;
prev_language = current_language->la_language;
for (i = 0; i < languages_size; i++) { for (i = 0; i < languages_size; i++) {
if (languages[i]->la_language == lang) { if (languages[i]->la_language == lang) {
@ -361,6 +364,8 @@ set_language(lang)
break; break;
} }
} }
return prev_language;
} }
/* This page contains functions that update the global vars /* This page contains functions that update the global vars

View File

@ -245,7 +245,7 @@ extern enum language_mode
extern void extern void
language_info PARAMS ((int)); language_info PARAMS ((int));
extern void extern enum language
set_language PARAMS ((enum language)); set_language PARAMS ((enum language));