aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorJohn Gilmore <gnu@cygnus>1992-02-22 01:46:16 +0000
committerJohn Gilmore <gnu@cygnus>1992-02-22 01:46:16 +0000
commit1ab3bf1b148d31aad66735f52f9ff72af8769cd0 (patch)
treef599e61700fc54d6ecd3d090e3d01cf6fa66a801 /gdb/c-exp.y
parent8e48d87af60233cc7e8dc18ab4e8f63d223ac20f (diff)
downloadgdb-1ab3bf1b148d31aad66735f52f9ff72af8769cd0.zip
gdb-1ab3bf1b148d31aad66735f52f9ff72af8769cd0.tar.gz
gdb-1ab3bf1b148d31aad66735f52f9ff72af8769cd0.tar.bz2
* Check in Fred Fish's changes in these modules. Fred
will make ChangeLog entries for all of them.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y153
1 files changed, 85 insertions, 68 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index ea41e64..dc10d2b 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -32,6 +32,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <string.h>
#include "defs.h"
#include "symtab.h"
+#include "gdbtypes.h"
#include "frame.h"
#include "expression.h"
#include "parser-defs.h"
@@ -68,10 +69,17 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#define yyval c_val
#define yylloc c_lloc
-/* Forward decls */
-void yyerror ();
-static int parse_number ();
-int yyparse ();
+static void
+__yy_bcopy PARAMS ((char *, char *, int));
+
+int
+yyparse PARAMS ((void));
+
+int
+yylex PARAMS ((void));
+
+void
+yyerror PARAMS ((char *));
/* #define YYDEBUG 1 */
@@ -100,6 +108,12 @@ int yyparse ();
int *ivec;
}
+%{
+/* YYSTYPE gets defined by %union */
+static int
+parse_number PARAMS ((char *, int, int, YYSTYPE *));
+%}
+
%type <voidval> exp exp1 type_exp start variable
%type <tval> type typebase
%type <tvec> nonempty_typelist
@@ -564,7 +578,7 @@ variable: typebase COLONCOLON name
{
char *name = copy_name ($2);
struct symbol *sym;
- int i;
+ struct minimal_symbol *msymbol;
sym =
lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
@@ -575,31 +589,27 @@ variable: typebase COLONCOLON name
write_exp_elt_opcode (OP_VAR_VALUE);
break;
}
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, name))
- break;
- if (i < misc_function_count)
+ msymbol = lookup_minimal_symbol (name,
+ (struct objfile *) NULL);
+ if (msymbol != NULL)
{
- enum misc_function_type mft =
- misc_function_vector[i].type;
-
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
+ write_exp_elt_longcst ((LONGEST) msymbol -> address);
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (UNOP_MEMVAL);
- if (mft == mf_data || mft == mf_bss)
+ if (msymbol -> type == mst_data ||
+ msymbol -> type == mst_bss)
write_exp_elt_type (builtin_type_int);
- else if (mft == mf_text)
+ else if (msymbol -> type == mst_text)
write_exp_elt_type (lookup_function_type (builtin_type_int));
else
write_exp_elt_type (builtin_type_char);
write_exp_elt_opcode (UNOP_MEMVAL);
}
else
- if (symtab_list == 0
- && partial_symtab_list == 0)
+ if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
else
error ("No symbol \"%s\" in current context.", name);
@@ -662,35 +672,28 @@ variable: name_not_typename
}
else
{
- register int i;
+ struct minimal_symbol *msymbol;
register char *arg = copy_name ($1.stoken);
- /* FIXME, this search is linear! At least
- optimize the strcmp with a 1-char cmp... */
- for (i = 0; i < misc_function_count; i++)
- if (!strcmp (misc_function_vector[i].name, arg))
- break;
-
- if (i < misc_function_count)
+ msymbol = lookup_minimal_symbol (arg,
+ (struct objfile *) NULL);
+ if (msymbol != NULL)
{
- enum misc_function_type mft =
- misc_function_vector[i].type;
-
write_exp_elt_opcode (OP_LONG);
write_exp_elt_type (builtin_type_int);
- write_exp_elt_longcst ((LONGEST) misc_function_vector[i].address);
+ write_exp_elt_longcst ((LONGEST) msymbol -> address);
write_exp_elt_opcode (OP_LONG);
write_exp_elt_opcode (UNOP_MEMVAL);
- if (mft == mf_data || mft == mf_bss)
+ if (msymbol -> type == mst_data ||
+ msymbol -> type == mst_bss)
write_exp_elt_type (builtin_type_int);
- else if (mft == mf_text)
+ else if (msymbol -> type == mst_text)
write_exp_elt_type (lookup_function_type (builtin_type_int));
else
write_exp_elt_type (builtin_type_char);
write_exp_elt_opcode (UNOP_MEMVAL);
}
- else if (symtab_list == 0
- && partial_symtab_list == 0)
+ else if (!have_full_symbols () && !have_partial_symbols ())
error ("No symbol table is loaded. Use the \"file\" command.");
else
error ("No symbol \"%s\" in current context.",
@@ -869,7 +872,7 @@ nonempty_typelist
}
| nonempty_typelist ',' type
{ int len = sizeof (struct type *) * ++($<ivec>1[0]);
- $$ = (struct type **)xrealloc ($1, len);
+ $$ = (struct type **)xrealloc ((char *) $1, len);
$$[$<ivec>$[0]] = $3;
}
;
@@ -915,8 +918,6 @@ parse_number (p, len, parsed_float, putithere)
register int base = input_radix;
int unsigned_p = 0;
- extern double atof ();
-
if (parsed_float)
{
/* It's a float since it contains a point or an exponent. */
@@ -1535,53 +1536,69 @@ void
_initialize_c_exp ()
{
builtin_type_void =
- init_type (TYPE_CODE_VOID, 1, 0,
- "void");
+ init_type (TYPE_CODE_VOID, 1,
+ 0,
+ "void", (struct objfile *) NULL);
builtin_type_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 0,
- "char");
+ init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ 0,
+ "char", (struct objfile *) NULL);
builtin_type_unsigned_char =
- init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT, 1,
- "unsigned char");
+ init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned char", (struct objfile *) NULL);
builtin_type_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 0,
- "short");
+ init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ 0,
+ "short", (struct objfile *) NULL);
builtin_type_unsigned_short =
- init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT, 1,
- "unsigned short");
+ init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned short", (struct objfile *) NULL);
builtin_type_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 0,
- "int");
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+ 0,
+ "int", (struct objfile *) NULL);
builtin_type_unsigned_int =
- init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT, 1,
- "unsigned int");
+ init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned int", (struct objfile *) NULL);
builtin_type_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 0,
- "long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ 0,
+ "long", (struct objfile *) NULL);
builtin_type_unsigned_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT, 1,
- "unsigned long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned long", (struct objfile *) NULL);
builtin_type_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 0,
- "long long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ 0,
+ "long long", (struct objfile *) NULL);
builtin_type_unsigned_long_long =
- init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, 1,
- "unsigned long long");
+ init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
+ TYPE_FLAG_UNSIGNED,
+ "unsigned long long", (struct objfile *) NULL);
builtin_type_float =
- init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT, 0,
- "float");
+ init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
+ 0,
+ "float", (struct objfile *) NULL);
builtin_type_double =
- init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, 0,
- "double");
+ init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0,
+ "double", (struct objfile *) NULL);
builtin_type_long_double =
- init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, 0,
- "long double");
+ init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
+ 0,
+ "long double", (struct objfile *) NULL);
builtin_type_complex =
- init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT, 0,
- "complex");
+ init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
+ 0,
+ "complex", (struct objfile *) NULL);
builtin_type_double_complex =
- init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT, 0,
- "double complex");
+ init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
+ 0,
+ "double complex", (struct objfile *) NULL);
add_language (&c_language_defn);
add_language (&cplus_language_defn);