Changes for Amiga Unix from rhealey@ub.d.umn.edu.
[deliverable/binutils-gdb.git] / gdb / c-exp.y
CommitLineData
3d6b6a90
JG
1/* YACC parser for C expressions, for GDB.
2 Copyright (C) 1986, 1989, 1990, 1991 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/* Parse a C expression from text in a string,
21 and return the result as a struct expression pointer.
22 That structure contains arithmetic operations in reverse polish,
23 with constants represented by operations that are followed by special data.
24 See expression.h for the details of the format.
25 What is important here is that it can be built up sequentially
26 during the process of parsing; the lower levels of the tree always
e35843d4
FF
27 come first in the result.
28
29 Note that malloc's and realloc's in this file are transformed to
30 xmalloc and xrealloc respectively by the same sed command in the
31 makefile that remaps any other malloc/realloc inserted by the parser
32 generator. Doing this with #defines and trying to control the interaction
33 with include files (<malloc.h> and <stdlib.h> for example) just became
34 too messy, particularly when such includes can be inserted at random
35 times by the parser generator. */
3d6b6a90
JG
36
37%{
38
39#include <stdio.h>
40#include <string.h>
41#include "defs.h"
3d6b6a90 42#include "symtab.h"
1ab3bf1b 43#include "gdbtypes.h"
3d6b6a90
JG
44#include "frame.h"
45#include "expression.h"
46#include "parser-defs.h"
47#include "value.h"
48#include "language.h"
ac88ca20
JG
49#include "bfd.h"
50#include "symfile.h"
51#include "objfiles.h"
3d6b6a90 52
36ce1b64
FF
53/* These MUST be included in any grammar file!!!! Please choose unique names!
54 Note that this are a combined list of variables that can be produced
55 by any one of bison, byacc, or yacc. */
d018c8a6 56#define yymaxdepth c_maxdepth
3d6b6a90
JG
57#define yyparse c_parse
58#define yylex c_lex
59#define yyerror c_error
60#define yylval c_lval
61#define yychar c_char
62#define yydebug c_debug
63#define yypact c_pact
64#define yyr1 c_r1
65#define yyr2 c_r2
66#define yydef c_def
67#define yychk c_chk
68#define yypgo c_pgo
69#define yyact c_act
70#define yyexca c_exca
9ce7cb7c
SG
71#define yyerrflag c_errflag
72#define yynerrs c_nerrs
39bf5952
JG
73#define yyps c_ps
74#define yypv c_pv
75#define yys c_s
d018c8a6 76#define yy_yys c_yys
39bf5952
JG
77#define yystate c_state
78#define yytmp c_tmp
79#define yyv c_v
d018c8a6 80#define yy_yyv c_yyv
39bf5952
JG
81#define yyval c_val
82#define yylloc c_lloc
36ce1b64
FF
83#define yyss c_yyss /* byacc */
84#define yyssp c_yysp /* byacc */
85#define yyvs c_yyvs /* byacc */
86#define yyvsp c_yyvsp /* byacc */
3d6b6a90 87
d26b50b7 88int
1ab3bf1b
JG
89yyparse PARAMS ((void));
90
91int
92yylex PARAMS ((void));
93
94void
95yyerror PARAMS ((char *));
3d6b6a90
JG
96
97/* #define YYDEBUG 1 */
98
99%}
100
101/* Although the yacc "value" of an expression is not used,
102 since the result is stored in the structure being created,
103 other node types do have values. */
104
105%union
106 {
107 LONGEST lval;
108 unsigned LONGEST ulval;
2e6edad1
SC
109 struct {
110 LONGEST val;
111 struct type *type;
112 } typed_val;
3d6b6a90
JG
113 double dval;
114 struct symbol *sym;
115 struct type *tval;
116 struct stoken sval;
117 struct ttype tsym;
118 struct symtoken ssym;
119 int voidval;
120 struct block *bval;
121 enum exp_opcode opcode;
122 struct internalvar *ivar;
123
124 struct type **tvec;
125 int *ivec;
126 }
127
1ab3bf1b
JG
128%{
129/* YYSTYPE gets defined by %union */
130static int
131parse_number PARAMS ((char *, int, int, YYSTYPE *));
132%}
133
01be6913 134%type <voidval> exp exp1 type_exp start variable qualified_name
2640f7e1 135%type <tval> type typebase
3d6b6a90
JG
136%type <tvec> nonempty_typelist
137/* %type <bval> block */
138
139/* Fancy type parsing. */
140%type <voidval> func_mod direct_abs_decl abs_decl
141%type <tval> ptype
142%type <lval> array_mod
143
2e6edad1 144%token <typed_val> INT
3d6b6a90
JG
145%token <dval> FLOAT
146
147/* Both NAME and TYPENAME tokens represent symbols in the input,
148 and both convey their data as strings.
149 But a TYPENAME is a string that happens to be defined as a typedef
150 or builtin type name (such as int or char)
151 and a NAME is any other symbol.
152 Contexts where this distinction is not important can use the
153 nonterminal "name", which matches either NAME or TYPENAME. */
154
155%token <sval> STRING
156%token <ssym> NAME /* BLOCKNAME defined below to give it higher precedence. */
157%token <tsym> TYPENAME
158%type <sval> name
159%type <ssym> name_not_typename
160%type <tsym> typename
161
162/* A NAME_OR_INT is a symbol which is not known in the symbol table,
163 but which would parse as a valid number in the current input radix.
164 E.g. "c" when input_radix==16. Depending on the parse, it will be
2e6edad1 165 turned into a name or into a number. */
3d6b6a90 166
2e6edad1 167%token <ssym> NAME_OR_INT
3d6b6a90 168
8050a57b 169%token STRUCT CLASS UNION ENUM SIZEOF UNSIGNED COLONCOLON
4c53d9ca 170%token TEMPLATE
3d6b6a90
JG
171%token ERROR
172
173/* Special type cases, put in to allow the parser to distinguish different
174 legal basetypes. */
a252e715 175%token SIGNED_KEYWORD LONG SHORT INT_KEYWORD CONST_KEYWORD VOLATILE_KEYWORD
3d6b6a90
JG
176%token <lval> LAST REGNAME
177
178%token <ivar> VARIABLE
179
180%token <opcode> ASSIGN_MODIFY
181
182/* C++ */
183%token THIS
184
185%left ','
186%left ABOVE_COMMA
187%right '=' ASSIGN_MODIFY
188%right '?'
088c3a0b
JG
189%left OROR
190%left ANDAND
3d6b6a90
JG
191%left '|'
192%left '^'
193%left '&'
194%left EQUAL NOTEQUAL
195%left '<' '>' LEQ GEQ
196%left LSH RSH
197%left '@'
198%left '+' '-'
199%left '*' '/' '%'
200%right UNARY INCREMENT DECREMENT
201%right ARROW '.' '[' '('
202%token <ssym> BLOCKNAME
203%type <bval> block
204%left COLONCOLON
36ce1b64 205
368c8614
MT
206\f
207%%
208
3d6b6a90
JG
209start : exp1
210 | type_exp
211 ;
212
213type_exp: type
214 { write_exp_elt_opcode(OP_TYPE);
215 write_exp_elt_type($1);
216 write_exp_elt_opcode(OP_TYPE);}
217 ;
218
219/* Expressions, including the comma operator. */
220exp1 : exp
221 | exp1 ',' exp
222 { write_exp_elt_opcode (BINOP_COMMA); }
223 ;
224
225/* Expressions, not including the comma operator. */
226exp : '*' exp %prec UNARY
227 { write_exp_elt_opcode (UNOP_IND); }
228
229exp : '&' exp %prec UNARY
230 { write_exp_elt_opcode (UNOP_ADDR); }
231
232exp : '-' exp %prec UNARY
233 { write_exp_elt_opcode (UNOP_NEG); }
234 ;
235
236exp : '!' exp %prec UNARY
e58de8a2 237 { write_exp_elt_opcode (UNOP_LOGICAL_NOT); }
3d6b6a90
JG
238 ;
239
240exp : '~' exp %prec UNARY
e58de8a2 241 { write_exp_elt_opcode (UNOP_COMPLEMENT); }
3d6b6a90
JG
242 ;
243
244exp : INCREMENT exp %prec UNARY
245 { write_exp_elt_opcode (UNOP_PREINCREMENT); }
246 ;
247
248exp : DECREMENT exp %prec UNARY
249 { write_exp_elt_opcode (UNOP_PREDECREMENT); }
250 ;
251
252exp : exp INCREMENT %prec UNARY
253 { write_exp_elt_opcode (UNOP_POSTINCREMENT); }
254 ;
255
256exp : exp DECREMENT %prec UNARY
257 { write_exp_elt_opcode (UNOP_POSTDECREMENT); }
258 ;
259
260exp : SIZEOF exp %prec UNARY
261 { write_exp_elt_opcode (UNOP_SIZEOF); }
262 ;
263
264exp : exp ARROW name
265 { write_exp_elt_opcode (STRUCTOP_PTR);
266 write_exp_string ($3);
267 write_exp_elt_opcode (STRUCTOP_PTR); }
268 ;
269
2640f7e1
JG
270exp : exp ARROW qualified_name
271 { /* exp->type::name becomes exp->*(&type::name) */
272 /* Note: this doesn't work if name is a
273 static member! FIXME */
274 write_exp_elt_opcode (UNOP_ADDR);
275 write_exp_elt_opcode (STRUCTOP_MPTR); }
01be6913 276 ;
3d6b6a90
JG
277exp : exp ARROW '*' exp
278 { write_exp_elt_opcode (STRUCTOP_MPTR); }
279 ;
280
281exp : exp '.' name
282 { write_exp_elt_opcode (STRUCTOP_STRUCT);
283 write_exp_string ($3);
284 write_exp_elt_opcode (STRUCTOP_STRUCT); }
285 ;
286
2640f7e1
JG
287exp : exp '.' qualified_name
288 { /* exp.type::name becomes exp.*(&type::name) */
289 /* Note: this doesn't work if name is a
290 static member! FIXME */
291 write_exp_elt_opcode (UNOP_ADDR);
292 write_exp_elt_opcode (STRUCTOP_MEMBER); }
01be6913
PB
293 ;
294
3d6b6a90
JG
295exp : exp '.' '*' exp
296 { write_exp_elt_opcode (STRUCTOP_MEMBER); }
297 ;
298
299exp : exp '[' exp1 ']'
300 { write_exp_elt_opcode (BINOP_SUBSCRIPT); }
301 ;
302
303exp : exp '('
304 /* This is to save the value of arglist_len
305 being accumulated by an outer function call. */
306 { start_arglist (); }
307 arglist ')' %prec ARROW
308 { write_exp_elt_opcode (OP_FUNCALL);
309 write_exp_elt_longcst ((LONGEST) end_arglist ());
310 write_exp_elt_opcode (OP_FUNCALL); }
311 ;
312
313arglist :
314 ;
315
316arglist : exp
317 { arglist_len = 1; }
318 ;
319
320arglist : arglist ',' exp %prec ABOVE_COMMA
321 { arglist_len++; }
322 ;
323
324exp : '{' type '}' exp %prec UNARY
325 { write_exp_elt_opcode (UNOP_MEMVAL);
326 write_exp_elt_type ($2);
327 write_exp_elt_opcode (UNOP_MEMVAL); }
328 ;
329
330exp : '(' type ')' exp %prec UNARY
331 { write_exp_elt_opcode (UNOP_CAST);
332 write_exp_elt_type ($2);
333 write_exp_elt_opcode (UNOP_CAST); }
334 ;
335
336exp : '(' exp1 ')'
337 { }
338 ;
339
340/* Binary operators in order of decreasing precedence. */
341
342exp : exp '@' exp
343 { write_exp_elt_opcode (BINOP_REPEAT); }
344 ;
345
346exp : exp '*' exp
347 { write_exp_elt_opcode (BINOP_MUL); }
348 ;
349
350exp : exp '/' exp
351 { write_exp_elt_opcode (BINOP_DIV); }
352 ;
353
354exp : exp '%' exp
355 { write_exp_elt_opcode (BINOP_REM); }
356 ;
357
358exp : exp '+' exp
359 { write_exp_elt_opcode (BINOP_ADD); }
360 ;
361
362exp : exp '-' exp
363 { write_exp_elt_opcode (BINOP_SUB); }
364 ;
365
366exp : exp LSH exp
367 { write_exp_elt_opcode (BINOP_LSH); }
368 ;
369
370exp : exp RSH exp
371 { write_exp_elt_opcode (BINOP_RSH); }
372 ;
373
374exp : exp EQUAL exp
375 { write_exp_elt_opcode (BINOP_EQUAL); }
376 ;
377
378exp : exp NOTEQUAL exp
379 { write_exp_elt_opcode (BINOP_NOTEQUAL); }
380 ;
381
382exp : exp LEQ exp
383 { write_exp_elt_opcode (BINOP_LEQ); }
384 ;
385
386exp : exp GEQ exp
387 { write_exp_elt_opcode (BINOP_GEQ); }
388 ;
389
390exp : exp '<' exp
391 { write_exp_elt_opcode (BINOP_LESS); }
392 ;
393
394exp : exp '>' exp
395 { write_exp_elt_opcode (BINOP_GTR); }
396 ;
397
398exp : exp '&' exp
e58de8a2 399 { write_exp_elt_opcode (BINOP_BITWISE_AND); }
3d6b6a90
JG
400 ;
401
402exp : exp '^' exp
e58de8a2 403 { write_exp_elt_opcode (BINOP_BITWISE_XOR); }
3d6b6a90
JG
404 ;
405
406exp : exp '|' exp
e58de8a2 407 { write_exp_elt_opcode (BINOP_BITWISE_IOR); }
3d6b6a90
JG
408 ;
409
088c3a0b 410exp : exp ANDAND exp
e58de8a2 411 { write_exp_elt_opcode (BINOP_LOGICAL_AND); }
3d6b6a90
JG
412 ;
413
088c3a0b 414exp : exp OROR exp
e58de8a2 415 { write_exp_elt_opcode (BINOP_LOGICAL_OR); }
3d6b6a90
JG
416 ;
417
418exp : exp '?' exp ':' exp %prec '?'
419 { write_exp_elt_opcode (TERNOP_COND); }
420 ;
421
422exp : exp '=' exp
423 { write_exp_elt_opcode (BINOP_ASSIGN); }
424 ;
425
426exp : exp ASSIGN_MODIFY exp
427 { write_exp_elt_opcode (BINOP_ASSIGN_MODIFY);
428 write_exp_elt_opcode ($2);
429 write_exp_elt_opcode (BINOP_ASSIGN_MODIFY); }
430 ;
431
432exp : INT
433 { write_exp_elt_opcode (OP_LONG);
2e6edad1
SC
434 write_exp_elt_type ($1.type);
435 write_exp_elt_longcst ((LONGEST)($1.val));
3d6b6a90
JG
436 write_exp_elt_opcode (OP_LONG); }
437 ;
438
439exp : NAME_OR_INT
440 { YYSTYPE val;
441 parse_number ($1.stoken.ptr, $1.stoken.length, 0, &val);
442 write_exp_elt_opcode (OP_LONG);
2e6edad1
SC
443 write_exp_elt_type (val.typed_val.type);
444 write_exp_elt_longcst ((LONGEST)val.typed_val.val);
3d6b6a90
JG
445 write_exp_elt_opcode (OP_LONG);
446 }
447 ;
448
3d6b6a90
JG
449
450exp : FLOAT
451 { write_exp_elt_opcode (OP_DOUBLE);
452 write_exp_elt_type (builtin_type_double);
453 write_exp_elt_dblcst ($1);
454 write_exp_elt_opcode (OP_DOUBLE); }
455 ;
456
457exp : variable
458 ;
459
460exp : LAST
461 { write_exp_elt_opcode (OP_LAST);
462 write_exp_elt_longcst ((LONGEST) $1);
463 write_exp_elt_opcode (OP_LAST); }
464 ;
465
466exp : REGNAME
467 { write_exp_elt_opcode (OP_REGISTER);
468 write_exp_elt_longcst ((LONGEST) $1);
469 write_exp_elt_opcode (OP_REGISTER); }
470 ;
471
472exp : VARIABLE
473 { write_exp_elt_opcode (OP_INTERNALVAR);
474 write_exp_elt_intern ($1);
475 write_exp_elt_opcode (OP_INTERNALVAR); }
476 ;
477
478exp : SIZEOF '(' type ')' %prec UNARY
479 { write_exp_elt_opcode (OP_LONG);
480 write_exp_elt_type (builtin_type_int);
481 write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
482 write_exp_elt_opcode (OP_LONG); }
483 ;
484
485exp : STRING
486 { write_exp_elt_opcode (OP_STRING);
487 write_exp_string ($1);
488 write_exp_elt_opcode (OP_STRING); }
489 ;
490
491/* C++. */
492exp : THIS
493 { write_exp_elt_opcode (OP_THIS);
494 write_exp_elt_opcode (OP_THIS); }
495 ;
496
497/* end of C++. */
498
499block : BLOCKNAME
500 {
501 if ($1.sym != 0)
502 $$ = SYMBOL_BLOCK_VALUE ($1.sym);
503 else
504 {
505 struct symtab *tem =
506 lookup_symtab (copy_name ($1.stoken));
507 if (tem)
508 $$ = BLOCKVECTOR_BLOCK
509 (BLOCKVECTOR (tem), STATIC_BLOCK);
510 else
511 error ("No file or function \"%s\".",
512 copy_name ($1.stoken));
513 }
514 }
515 ;
516
517block : block COLONCOLON name
518 { struct symbol *tem
519 = lookup_symbol (copy_name ($3), $1,
520 VAR_NAMESPACE, 0, NULL);
521 if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
522 error ("No function \"%s\" in specified context.",
523 copy_name ($3));
524 $$ = SYMBOL_BLOCK_VALUE (tem); }
525 ;
526
527variable: block COLONCOLON name
528 { struct symbol *sym;
529 sym = lookup_symbol (copy_name ($3), $1,
530 VAR_NAMESPACE, 0, NULL);
531 if (sym == 0)
532 error ("No symbol \"%s\" in specified context.",
533 copy_name ($3));
534
535 write_exp_elt_opcode (OP_VAR_VALUE);
536 write_exp_elt_sym (sym);
537 write_exp_elt_opcode (OP_VAR_VALUE); }
538 ;
539
2640f7e1 540qualified_name: typebase COLONCOLON name
3d6b6a90
JG
541 {
542 struct type *type = $1;
543 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
544 && TYPE_CODE (type) != TYPE_CODE_UNION)
545 error ("`%s' is not defined as an aggregate type.",
546 TYPE_NAME (type));
547
548 write_exp_elt_opcode (OP_SCOPE);
549 write_exp_elt_type (type);
2640f7e1 550 write_exp_string ($3);
3d6b6a90
JG
551 write_exp_elt_opcode (OP_SCOPE);
552 }
2640f7e1 553 | typebase COLONCOLON '~' name
3d6b6a90
JG
554 {
555 struct type *type = $1;
01be6913 556 struct stoken tmp_token;
3d6b6a90
JG
557 if (TYPE_CODE (type) != TYPE_CODE_STRUCT
558 && TYPE_CODE (type) != TYPE_CODE_UNION)
559 error ("`%s' is not defined as an aggregate type.",
560 TYPE_NAME (type));
561
2640f7e1 562 if (strcmp (type_name_no_tag (type), $4.ptr))
3d6b6a90 563 error ("invalid destructor `%s::~%s'",
2640f7e1 564 type_name_no_tag (type), $4.ptr);
3d6b6a90 565
2640f7e1
JG
566 tmp_token.ptr = (char*) alloca ($4.length + 2);
567 tmp_token.length = $4.length + 1;
01be6913 568 tmp_token.ptr[0] = '~';
2640f7e1 569 memcpy (tmp_token.ptr+1, $4.ptr, $4.length);
01be6913 570 tmp_token.ptr[tmp_token.length] = 0;
3d6b6a90
JG
571 write_exp_elt_opcode (OP_SCOPE);
572 write_exp_elt_type (type);
01be6913 573 write_exp_string (tmp_token);
3d6b6a90 574 write_exp_elt_opcode (OP_SCOPE);
3d6b6a90 575 }
01be6913
PB
576 ;
577
578variable: qualified_name
3d6b6a90
JG
579 | COLONCOLON name
580 {
581 char *name = copy_name ($2);
582 struct symbol *sym;
1ab3bf1b 583 struct minimal_symbol *msymbol;
3d6b6a90
JG
584
585 sym =
586 lookup_symbol (name, 0, VAR_NAMESPACE, 0, NULL);
587 if (sym)
588 {
589 write_exp_elt_opcode (OP_VAR_VALUE);
590 write_exp_elt_sym (sym);
591 write_exp_elt_opcode (OP_VAR_VALUE);
592 break;
593 }
3d6b6a90 594
1ab3bf1b
JG
595 msymbol = lookup_minimal_symbol (name,
596 (struct objfile *) NULL);
597 if (msymbol != NULL)
3d6b6a90 598 {
3d6b6a90
JG
599 write_exp_elt_opcode (OP_LONG);
600 write_exp_elt_type (builtin_type_int);
1ab3bf1b 601 write_exp_elt_longcst ((LONGEST) msymbol -> address);
3d6b6a90
JG
602 write_exp_elt_opcode (OP_LONG);
603 write_exp_elt_opcode (UNOP_MEMVAL);
1ab3bf1b
JG
604 if (msymbol -> type == mst_data ||
605 msymbol -> type == mst_bss)
3d6b6a90 606 write_exp_elt_type (builtin_type_int);
1ab3bf1b 607 else if (msymbol -> type == mst_text)
3d6b6a90
JG
608 write_exp_elt_type (lookup_function_type (builtin_type_int));
609 else
610 write_exp_elt_type (builtin_type_char);
611 write_exp_elt_opcode (UNOP_MEMVAL);
612 }
613 else
1ab3bf1b 614 if (!have_full_symbols () && !have_partial_symbols ())
3d6b6a90
JG
615 error ("No symbol table is loaded. Use the \"file\" command.");
616 else
617 error ("No symbol \"%s\" in current context.", name);
618 }
619 ;
620
621variable: name_not_typename
622 { struct symbol *sym = $1.sym;
623
624 if (sym)
625 {
5b0a744f 626 switch (SYMBOL_CLASS (sym))
3d6b6a90
JG
627 {
628 case LOC_REGISTER:
629 case LOC_ARG:
630 case LOC_REF_ARG:
631 case LOC_REGPARM:
632 case LOC_LOCAL:
633 case LOC_LOCAL_ARG:
634 if (innermost_block == 0 ||
635 contained_in (block_found,
636 innermost_block))
637 innermost_block = block_found;
638 case LOC_UNDEF:
639 case LOC_CONST:
640 case LOC_STATIC:
641 case LOC_TYPEDEF:
642 case LOC_LABEL:
643 case LOC_BLOCK:
644 case LOC_CONST_BYTES:
645
646 /* In this case the expression can
647 be evaluated regardless of what
648 frame we are in, so there is no
649 need to check for the
650 innermost_block. These cases are
651 listed so that gcc -Wall will
652 report types that may not have
653 been considered. */
654
655 break;
656 }
657 write_exp_elt_opcode (OP_VAR_VALUE);
658 write_exp_elt_sym (sym);
659 write_exp_elt_opcode (OP_VAR_VALUE);
660 }
661 else if ($1.is_a_field_of_this)
662 {
663 /* C++: it hangs off of `this'. Must
664 not inadvertently convert from a method call
665 to data ref. */
666 if (innermost_block == 0 ||
667 contained_in (block_found, innermost_block))
668 innermost_block = block_found;
669 write_exp_elt_opcode (OP_THIS);
670 write_exp_elt_opcode (OP_THIS);
671 write_exp_elt_opcode (STRUCTOP_PTR);
672 write_exp_string ($1.stoken);
673 write_exp_elt_opcode (STRUCTOP_PTR);
674 }
675 else
676 {
1ab3bf1b 677 struct minimal_symbol *msymbol;
3d6b6a90
JG
678 register char *arg = copy_name ($1.stoken);
679
1ab3bf1b
JG
680 msymbol = lookup_minimal_symbol (arg,
681 (struct objfile *) NULL);
682 if (msymbol != NULL)
3d6b6a90 683 {
3d6b6a90
JG
684 write_exp_elt_opcode (OP_LONG);
685 write_exp_elt_type (builtin_type_int);
1ab3bf1b 686 write_exp_elt_longcst ((LONGEST) msymbol -> address);
3d6b6a90
JG
687 write_exp_elt_opcode (OP_LONG);
688 write_exp_elt_opcode (UNOP_MEMVAL);
1ab3bf1b
JG
689 if (msymbol -> type == mst_data ||
690 msymbol -> type == mst_bss)
3d6b6a90 691 write_exp_elt_type (builtin_type_int);
1ab3bf1b 692 else if (msymbol -> type == mst_text)
3d6b6a90
JG
693 write_exp_elt_type (lookup_function_type (builtin_type_int));
694 else
695 write_exp_elt_type (builtin_type_char);
696 write_exp_elt_opcode (UNOP_MEMVAL);
697 }
1ab3bf1b 698 else if (!have_full_symbols () && !have_partial_symbols ())
3d6b6a90
JG
699 error ("No symbol table is loaded. Use the \"file\" command.");
700 else
701 error ("No symbol \"%s\" in current context.",
702 copy_name ($1.stoken));
703 }
704 }
705 ;
706
707
708ptype : typebase
709 | typebase abs_decl
710 {
711 /* This is where the interesting stuff happens. */
712 int done = 0;
713 int array_size;
714 struct type *follow_type = $1;
715
716 while (!done)
717 switch (pop_type ())
718 {
719 case tp_end:
720 done = 1;
721 break;
722 case tp_pointer:
723 follow_type = lookup_pointer_type (follow_type);
724 break;
725 case tp_reference:
726 follow_type = lookup_reference_type (follow_type);
727 break;
728 case tp_array:
729 array_size = pop_type_int ();
730 if (array_size != -1)
731 follow_type = create_array_type (follow_type,
732 array_size);
733 else
734 follow_type = lookup_pointer_type (follow_type);
735 break;
736 case tp_function:
737 follow_type = lookup_function_type (follow_type);
738 break;
739 }
740 $$ = follow_type;
741 }
742 ;
743
744abs_decl: '*'
745 { push_type (tp_pointer); $$ = 0; }
746 | '*' abs_decl
747 { push_type (tp_pointer); $$ = $2; }
748 | '&'
749 { push_type (tp_reference); $$ = 0; }
750 | '&' abs_decl
751 { push_type (tp_reference); $$ = $2; }
752 | direct_abs_decl
753 ;
754
755direct_abs_decl: '(' abs_decl ')'
756 { $$ = $2; }
757 | direct_abs_decl array_mod
758 {
759 push_type_int ($2);
760 push_type (tp_array);
761 }
762 | array_mod
763 {
764 push_type_int ($1);
765 push_type (tp_array);
766 $$ = 0;
767 }
768 | direct_abs_decl func_mod
769 { push_type (tp_function); }
770 | func_mod
771 { push_type (tp_function); }
772 ;
773
774array_mod: '[' ']'
775 { $$ = -1; }
776 | '[' INT ']'
2e6edad1 777 { $$ = $2.val; }
3d6b6a90
JG
778 ;
779
780func_mod: '(' ')'
781 { $$ = 0; }
0e2a896c 782 | '(' nonempty_typelist ')'
be772100 783 { free ((PTR)$2); $$ = 0; }
3d6b6a90
JG
784 ;
785
786type : ptype
2640f7e1
JG
787 | typebase COLONCOLON '*'
788 { $$ = lookup_member_type (builtin_type_int, $1); }
3d6b6a90
JG
789 | type '(' typebase COLONCOLON '*' ')'
790 { $$ = lookup_member_type ($1, $3); }
791 | type '(' typebase COLONCOLON '*' ')' '(' ')'
792 { $$ = lookup_member_type
793 (lookup_function_type ($1), $3); }
794 | type '(' typebase COLONCOLON '*' ')' '(' nonempty_typelist ')'
795 { $$ = lookup_member_type
796 (lookup_function_type ($1), $3);
be772100 797 free ((PTR)$8); }
3d6b6a90
JG
798 ;
799
10a297b7 800typebase /* Implements (approximately): (type-qualifier)* type-specifier */
3d6b6a90
JG
801 : TYPENAME
802 { $$ = $1.type; }
803 | INT_KEYWORD
804 { $$ = builtin_type_int; }
805 | LONG
806 { $$ = builtin_type_long; }
807 | SHORT
808 { $$ = builtin_type_short; }
809 | LONG INT_KEYWORD
810 { $$ = builtin_type_long; }
811 | UNSIGNED LONG INT_KEYWORD
812 { $$ = builtin_type_unsigned_long; }
813 | LONG LONG
814 { $$ = builtin_type_long_long; }
815 | LONG LONG INT_KEYWORD
816 { $$ = builtin_type_long_long; }
817 | UNSIGNED LONG LONG
818 { $$ = builtin_type_unsigned_long_long; }
819 | UNSIGNED LONG LONG INT_KEYWORD
820 { $$ = builtin_type_unsigned_long_long; }
821 | SHORT INT_KEYWORD
822 { $$ = builtin_type_short; }
823 | UNSIGNED SHORT INT_KEYWORD
824 { $$ = builtin_type_unsigned_short; }
825 | STRUCT name
826 { $$ = lookup_struct (copy_name ($2),
827 expression_context_block); }
8050a57b
FF
828 | CLASS name
829 { $$ = lookup_struct (copy_name ($2),
830 expression_context_block); }
3d6b6a90
JG
831 | UNION name
832 { $$ = lookup_union (copy_name ($2),
833 expression_context_block); }
834 | ENUM name
835 { $$ = lookup_enum (copy_name ($2),
836 expression_context_block); }
837 | UNSIGNED typename
838 { $$ = lookup_unsigned_typename (TYPE_NAME($2.type)); }
839 | UNSIGNED
840 { $$ = builtin_type_unsigned_int; }
088c3a0b 841 | SIGNED_KEYWORD typename
a252e715 842 { $$ = lookup_signed_typename (TYPE_NAME($2.type)); }
088c3a0b 843 | SIGNED_KEYWORD
3d6b6a90 844 { $$ = builtin_type_int; }
4c53d9ca
DHW
845 | TEMPLATE name '<' type '>'
846 { $$ = lookup_template_type(copy_name($2), $4,
847 expression_context_block);
848 }
10a297b7
PB
849 /* "const" and "volatile" are curently ignored. */
850 | CONST_KEYWORD typebase { $$ = $2; }
851 | VOLATILE_KEYWORD typebase { $$ = $2; }
3d6b6a90
JG
852 ;
853
854typename: TYPENAME
855 | INT_KEYWORD
856 {
857 $$.stoken.ptr = "int";
858 $$.stoken.length = 3;
859 $$.type = builtin_type_int;
860 }
861 | LONG
862 {
863 $$.stoken.ptr = "long";
864 $$.stoken.length = 4;
865 $$.type = builtin_type_long;
866 }
867 | SHORT
868 {
869 $$.stoken.ptr = "short";
870 $$.stoken.length = 5;
871 $$.type = builtin_type_short;
872 }
873 ;
874
875nonempty_typelist
876 : type
e35843d4 877 { $$ = (struct type **) malloc (sizeof (struct type *) * 2);
6c316cfd 878 $<ivec>$[0] = 1; /* Number of types in vector */
3d6b6a90
JG
879 $$[1] = $1;
880 }
881 | nonempty_typelist ',' type
6c316cfd 882 { int len = sizeof (struct type *) * (++($<ivec>1[0]) + 1);
e35843d4 883 $$ = (struct type **) realloc ((char *) $1, len);
3d6b6a90
JG
884 $$[$<ivec>$[0]] = $3;
885 }
886 ;
887
888name : NAME { $$ = $1.stoken; }
889 | BLOCKNAME { $$ = $1.stoken; }
890 | TYPENAME { $$ = $1.stoken; }
891 | NAME_OR_INT { $$ = $1.stoken; }
3d6b6a90
JG
892 ;
893
894name_not_typename : NAME
895 | BLOCKNAME
896/* These would be useful if name_not_typename was useful, but it is just
897 a fake for "variable", so these cause reduce/reduce conflicts because
898 the parser can't tell whether NAME_OR_INT is a name_not_typename (=variable,
899 =exp) or just an exp. If name_not_typename was ever used in an lvalue
900 context where only a name could occur, this might be useful.
901 | NAME_OR_INT
3d6b6a90
JG
902 */
903 ;
904
905%%
906
907/* Take care of parsing a number (anything that starts with a digit).
908 Set yylval and return the token type; update lexptr.
909 LEN is the number of characters in it. */
910
911/*** Needs some error checking for the float case ***/
912
913static int
914parse_number (p, len, parsed_float, putithere)
915 register char *p;
916 register int len;
917 int parsed_float;
918 YYSTYPE *putithere;
919{
920 register LONGEST n = 0;
921 register LONGEST prevn = 0;
922 register int i;
923 register int c;
924 register int base = input_radix;
925 int unsigned_p = 0;
2e6edad1
SC
926 int long_p = 0;
927 LONGEST high_bit;
928 struct type *signed_type;
929 struct type *unsigned_type;
3d6b6a90 930
3d6b6a90
JG
931 if (parsed_float)
932 {
933 /* It's a float since it contains a point or an exponent. */
934 putithere->dval = atof (p);
935 return FLOAT;
936 }
937
938 /* Handle base-switching prefixes 0x, 0t, 0d, 0 */
939 if (p[0] == '0')
940 switch (p[1])
941 {
942 case 'x':
943 case 'X':
944 if (len >= 3)
945 {
946 p += 2;
947 base = 16;
948 len -= 2;
949 }
950 break;
951
952 case 't':
953 case 'T':
954 case 'd':
955 case 'D':
956 if (len >= 3)
957 {
958 p += 2;
959 base = 10;
960 len -= 2;
961 }
962 break;
963
964 default:
965 base = 8;
966 break;
967 }
968
969 while (len-- > 0)
970 {
971 c = *p++;
972 if (c >= 'A' && c <= 'Z')
973 c += 'a' - 'A';
974 if (c != 'l' && c != 'u')
975 n *= base;
976 if (c >= '0' && c <= '9')
977 n += i = c - '0';
978 else
979 {
980 if (base > 10 && c >= 'a' && c <= 'f')
981 n += i = c - 'a' + 10;
2e6edad1
SC
982 else if (len == 0 && c == 'l')
983 long_p = 1;
3d6b6a90
JG
984 else if (len == 0 && c == 'u')
985 unsigned_p = 1;
986 else
987 return ERROR; /* Char not a digit */
988 }
989 if (i >= base)
990 return ERROR; /* Invalid digit in this base */
2e6edad1 991
2a5ec41d
JG
992 /* Portably test for overflow (only works for nonzero values, so make
993 a second check for zero). */
994 if((prevn >= n) && n != 0)
3d6b6a90 995 unsigned_p=1; /* Try something unsigned */
2a5ec41d 996 /* If range checking enabled, portably test for unsigned overflow. */
3d6b6a90
JG
997 if(RANGE_CHECK && n!=0)
998 {
999 if((unsigned_p && (unsigned)prevn >= (unsigned)n))
1000 range_error("Overflow on numeric constant.");
1001 }
1002 prevn=n;
1003 }
2e6edad1
SC
1004
1005 /* If the number is too big to be an int, or it's got an l suffix
1006 then it's a long. Work out if this has to be a long by
1007 shifting right and and seeing if anything remains, and the
1008 target int size is different to the target long size. */
3d6b6a90 1009
2e6edad1
SC
1010 if ((TARGET_INT_BIT != TARGET_LONG_BIT && (n >> TARGET_INT_BIT)) || long_p)
1011 {
1012 high_bit = ((LONGEST)1) << (TARGET_LONG_BIT-1);
1013 unsigned_type = builtin_type_unsigned_long;
1014 signed_type = builtin_type_long;
1015 }
1016 else
1017 {
1018 high_bit = ((LONGEST)1) << (TARGET_INT_BIT-1);
1019 unsigned_type = builtin_type_unsigned_int;
1020 signed_type = builtin_type_int;
1021 }
1022
1023 putithere->typed_val.val = n;
1024
1025 /* If the high bit of the worked out type is set then this number
1026 has to be unsigned. */
1027
1028 if (unsigned_p || (n & high_bit))
1029 {
1030 putithere->typed_val.type = unsigned_type;
1031 }
1032 else
1033 {
1034 putithere->typed_val.type = signed_type;
1035 }
1036
1037 return INT;
3d6b6a90
JG
1038}
1039
1040struct token
1041{
1042 char *operator;
1043 int token;
1044 enum exp_opcode opcode;
1045};
1046
1047const static struct token tokentab3[] =
1048 {
1049 {">>=", ASSIGN_MODIFY, BINOP_RSH},
1050 {"<<=", ASSIGN_MODIFY, BINOP_LSH}
1051 };
1052
1053const static struct token tokentab2[] =
1054 {
1055 {"+=", ASSIGN_MODIFY, BINOP_ADD},
1056 {"-=", ASSIGN_MODIFY, BINOP_SUB},
1057 {"*=", ASSIGN_MODIFY, BINOP_MUL},
1058 {"/=", ASSIGN_MODIFY, BINOP_DIV},
1059 {"%=", ASSIGN_MODIFY, BINOP_REM},
e58de8a2
FF
1060 {"|=", ASSIGN_MODIFY, BINOP_BITWISE_IOR},
1061 {"&=", ASSIGN_MODIFY, BINOP_BITWISE_AND},
1062 {"^=", ASSIGN_MODIFY, BINOP_BITWISE_XOR},
3d6b6a90
JG
1063 {"++", INCREMENT, BINOP_END},
1064 {"--", DECREMENT, BINOP_END},
1065 {"->", ARROW, BINOP_END},
088c3a0b
JG
1066 {"&&", ANDAND, BINOP_END},
1067 {"||", OROR, BINOP_END},
3d6b6a90
JG
1068 {"::", COLONCOLON, BINOP_END},
1069 {"<<", LSH, BINOP_END},
1070 {">>", RSH, BINOP_END},
1071 {"==", EQUAL, BINOP_END},
1072 {"!=", NOTEQUAL, BINOP_END},
1073 {"<=", LEQ, BINOP_END},
1074 {">=", GEQ, BINOP_END}
1075 };
1076
1077/* Read one token, getting characters through lexptr. */
1078
1079int
1080yylex ()
1081{
bac89d6c
FF
1082 int c;
1083 int namelen;
1084 unsigned int i;
1085 char *tokstart;
1086 char *tokptr;
1087 int tempbufindex;
1088 static char *tempbuf;
1089 static int tempbufsize;
1090
3d6b6a90
JG
1091 retry:
1092
1093 tokstart = lexptr;
1094 /* See if it is a special token of length 3. */
1095 for (i = 0; i < sizeof tokentab3 / sizeof tokentab3[0]; i++)
1096 if (!strncmp (tokstart, tokentab3[i].operator, 3))
1097 {
1098 lexptr += 3;
1099 yylval.opcode = tokentab3[i].opcode;
1100 return tokentab3[i].token;
1101 }
1102
1103 /* See if it is a special token of length 2. */
1104 for (i = 0; i < sizeof tokentab2 / sizeof tokentab2[0]; i++)
1105 if (!strncmp (tokstart, tokentab2[i].operator, 2))
1106 {
1107 lexptr += 2;
1108 yylval.opcode = tokentab2[i].opcode;
1109 return tokentab2[i].token;
1110 }
1111
1112 switch (c = *tokstart)
1113 {
1114 case 0:
1115 return 0;
1116
1117 case ' ':
1118 case '\t':
1119 case '\n':
1120 lexptr++;
1121 goto retry;
1122
1123 case '\'':
d630b615
FF
1124 /* We either have a character constant ('0' or '\177' for example)
1125 or we have a quoted symbol reference ('foo(int,int)' in C++
1126 for example). */
3d6b6a90
JG
1127 lexptr++;
1128 c = *lexptr++;
1129 if (c == '\\')
1130 c = parse_escape (&lexptr);
2e6edad1
SC
1131
1132 yylval.typed_val.val = c;
1133 yylval.typed_val.type = builtin_type_char;
1134
3d6b6a90
JG
1135 c = *lexptr++;
1136 if (c != '\'')
d630b615
FF
1137 {
1138 namelen = skip_quoted (tokstart) - tokstart;
1139 if (namelen > 2)
1140 {
1141 lexptr = tokstart + namelen;
1142 namelen -= 2;
1143 tokstart++;
1144 goto tryname;
1145 }
1146 error ("Invalid character constant.");
1147 }
2e6edad1 1148 return INT;
3d6b6a90
JG
1149
1150 case '(':
1151 paren_depth++;
1152 lexptr++;
1153 return c;
1154
1155 case ')':
1156 if (paren_depth == 0)
1157 return 0;
1158 paren_depth--;
1159 lexptr++;
1160 return c;
1161
1162 case ',':
1163 if (comma_terminates && paren_depth == 0)
1164 return 0;
1165 lexptr++;
1166 return c;
1167
1168 case '.':
1169 /* Might be a floating point number. */
1170 if (lexptr[1] < '0' || lexptr[1] > '9')
1171 goto symbol; /* Nope, must be a symbol. */
1172 /* FALL THRU into number case. */
1173
1174 case '0':
1175 case '1':
1176 case '2':
1177 case '3':
1178 case '4':
1179 case '5':
1180 case '6':
1181 case '7':
1182 case '8':
1183 case '9':
1184 {
1185 /* It's a number. */
1186 int got_dot = 0, got_e = 0, toktype;
1187 register char *p = tokstart;
1188 int hex = input_radix > 10;
1189
1190 if (c == '0' && (p[1] == 'x' || p[1] == 'X'))
1191 {
1192 p += 2;
1193 hex = 1;
1194 }
1195 else if (c == '0' && (p[1]=='t' || p[1]=='T' || p[1]=='d' || p[1]=='D'))
1196 {
1197 p += 2;
1198 hex = 0;
1199 }
1200
1201 for (;; ++p)
1202 {
1203 if (!hex && !got_e && (*p == 'e' || *p == 'E'))
1204 got_dot = got_e = 1;
1205 else if (!hex && !got_dot && *p == '.')
1206 got_dot = 1;
1207 else if (got_e && (p[-1] == 'e' || p[-1] == 'E')
1208 && (*p == '-' || *p == '+'))
1209 /* This is the sign of the exponent, not the end of the
1210 number. */
1211 continue;
1212 /* We will take any letters or digits. parse_number will
1213 complain if past the radix, or if L or U are not final. */
1214 else if ((*p < '0' || *p > '9')
1215 && ((*p < 'a' || *p > 'z')
1216 && (*p < 'A' || *p > 'Z')))
1217 break;
1218 }
1219 toktype = parse_number (tokstart, p - tokstart, got_dot|got_e, &yylval);
1220 if (toktype == ERROR)
1221 {
1222 char *err_copy = (char *) alloca (p - tokstart + 1);
1223
4ed3a9ea 1224 memcpy (err_copy, tokstart, p - tokstart);
3d6b6a90
JG
1225 err_copy[p - tokstart] = 0;
1226 error ("Invalid number \"%s\".", err_copy);
1227 }
1228 lexptr = p;
1229 return toktype;
1230 }
1231
1232 case '+':
1233 case '-':
1234 case '*':
1235 case '/':
1236 case '%':
1237 case '|':
1238 case '&':
1239 case '^':
1240 case '~':
1241 case '!':
1242 case '@':
1243 case '<':
1244 case '>':
1245 case '[':
1246 case ']':
1247 case '?':
1248 case ':':
1249 case '=':
1250 case '{':
1251 case '}':
1252 symbol:
1253 lexptr++;
1254 return c;
1255
1256 case '"':
bac89d6c
FF
1257
1258 /* Build the gdb internal form of the input string in tempbuf,
1259 translating any standard C escape forms seen. Note that the
1260 buffer is null byte terminated *only* for the convenience of
1261 debugging gdb itself and printing the buffer contents when
1262 the buffer contains no embedded nulls. Gdb does not depend
1263 upon the buffer being null byte terminated, it uses the length
1264 string instead. This allows gdb to handle C strings (as well
1265 as strings in other languages) with embedded null bytes */
1266
1267 tokptr = ++tokstart;
1268 tempbufindex = 0;
1269
1270 do {
1271 /* Grow the static temp buffer if necessary, including allocating
1272 the first one on demand. */
1273 if (tempbufindex + 1 >= tempbufsize)
3d6b6a90 1274 {
bac89d6c
FF
1275 tempbuf = (char *) realloc (tempbuf, tempbufsize += 64);
1276 }
1277 switch (*tokptr)
1278 {
1279 case '\0':
1280 case '"':
1281 /* Do nothing, loop will terminate. */
1282 break;
1283 case '\\':
1284 tokptr++;
1285 c = parse_escape (&tokptr);
1286 if (c == -1)
3d6b6a90 1287 {
bac89d6c 1288 continue;
3d6b6a90 1289 }
bac89d6c
FF
1290 tempbuf[tempbufindex++] = c;
1291 break;
1292 default:
1293 tempbuf[tempbufindex++] = *tokptr++;
1294 break;
3d6b6a90 1295 }
bac89d6c
FF
1296 } while ((*tokptr != '"') && (*tokptr != '\0'));
1297 if (*tokptr++ != '"')
1298 {
1299 error ("Unterminated string in expression.");
1300 }
1301 tempbuf[tempbufindex] = '\0'; /* See note above */
1302 yylval.sval.ptr = tempbuf;
1303 yylval.sval.length = tempbufindex;
1304 lexptr = tokptr;
1305 return (STRING);
3d6b6a90
JG
1306 }
1307
1308 if (!(c == '_' || c == '$'
1309 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
1310 /* We must have come across a bad character (e.g. ';'). */
1311 error ("Invalid character '%c' in expression.", c);
1312
1313 /* It's a name. See how long it is. */
1314 namelen = 0;
1315 for (c = tokstart[namelen];
1316 (c == '_' || c == '$' || (c >= '0' && c <= '9')
1317 || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'));
1318 c = tokstart[++namelen])
1319 ;
1320
1321 /* The token "if" terminates the expression and is NOT
1322 removed from the input stream. */
1323 if (namelen == 2 && tokstart[0] == 'i' && tokstart[1] == 'f')
1324 {
1325 return 0;
1326 }
1327
1328 lexptr += namelen;
1329
1330 /* Handle the tokens $digits; also $ (short for $0) and $$ (short for $$1)
1331 and $$digits (equivalent to $<-digits> if you could type that).
1332 Make token type LAST, and put the number (the digits) in yylval. */
1333
d630b615 1334 tryname:
3d6b6a90
JG
1335 if (*tokstart == '$')
1336 {
1337 register int negate = 0;
1338 c = 1;
1339 /* Double dollar means negate the number and add -1 as well.
1340 Thus $$ alone means -1. */
1341 if (namelen >= 2 && tokstart[1] == '$')
1342 {
1343 negate = 1;
1344 c = 2;
1345 }
1346 if (c == namelen)
1347 {
1348 /* Just dollars (one or two) */
1349 yylval.lval = - negate;
1350 return LAST;
1351 }
1352 /* Is the rest of the token digits? */
1353 for (; c < namelen; c++)
1354 if (!(tokstart[c] >= '0' && tokstart[c] <= '9'))
1355 break;
1356 if (c == namelen)
1357 {
1358 yylval.lval = atoi (tokstart + 1 + negate);
1359 if (negate)
1360 yylval.lval = - yylval.lval;
1361 return LAST;
1362 }
1363 }
1364
1365 /* Handle tokens that refer to machine registers:
1366 $ followed by a register name. */
1367
1368 if (*tokstart == '$') {
1369 for (c = 0; c < NUM_REGS; c++)
1370 if (namelen - 1 == strlen (reg_names[c])
1371 && !strncmp (tokstart + 1, reg_names[c], namelen - 1))
1372 {
1373 yylval.lval = c;
1374 return REGNAME;
1375 }
1376 for (c = 0; c < num_std_regs; c++)
1377 if (namelen - 1 == strlen (std_regs[c].name)
1378 && !strncmp (tokstart + 1, std_regs[c].name, namelen - 1))
1379 {
1380 yylval.lval = std_regs[c].regnum;
1381 return REGNAME;
1382 }
1383 }
1384 /* Catch specific keywords. Should be done with a data structure. */
1385 switch (namelen)
1386 {
1387 case 8:
1388 if (!strncmp (tokstart, "unsigned", 8))
1389 return UNSIGNED;
5a4e7215
JG
1390 if (current_language->la_language == language_cplus
1391 && !strncmp (tokstart, "template", 8))
4c53d9ca 1392 return TEMPLATE;
a252e715
PB
1393 if (!strncmp (tokstart, "volatile", 8))
1394 return VOLATILE_KEYWORD;
3d6b6a90
JG
1395 break;
1396 case 6:
1397 if (!strncmp (tokstart, "struct", 6))
1398 return STRUCT;
1399 if (!strncmp (tokstart, "signed", 6))
088c3a0b 1400 return SIGNED_KEYWORD;
3d6b6a90
JG
1401 if (!strncmp (tokstart, "sizeof", 6))
1402 return SIZEOF;
1403 break;
1404 case 5:
866ecded
FF
1405 if (current_language->la_language == language_cplus
1406 && !strncmp (tokstart, "class", 5))
8050a57b 1407 return CLASS;
3d6b6a90
JG
1408 if (!strncmp (tokstart, "union", 5))
1409 return UNION;
1410 if (!strncmp (tokstart, "short", 5))
1411 return SHORT;
a252e715
PB
1412 if (!strncmp (tokstart, "const", 5))
1413 return CONST_KEYWORD;
3d6b6a90
JG
1414 break;
1415 case 4:
1416 if (!strncmp (tokstart, "enum", 4))
1417 return ENUM;
1418 if (!strncmp (tokstart, "long", 4))
1419 return LONG;
5a4e7215
JG
1420 if (current_language->la_language == language_cplus
1421 && !strncmp (tokstart, "this", 4))
3d6b6a90
JG
1422 {
1423 static const char this_name[] =
1424 { CPLUS_MARKER, 't', 'h', 'i', 's', '\0' };
1425
1426 if (lookup_symbol (this_name, expression_context_block,
1427 VAR_NAMESPACE, 0, NULL))
1428 return THIS;
1429 }
1430 break;
1431 case 3:
1432 if (!strncmp (tokstart, "int", 3))
1433 return INT_KEYWORD;
1434 break;
1435 default:
1436 break;
1437 }
1438
1439 yylval.sval.ptr = tokstart;
1440 yylval.sval.length = namelen;
1441
1442 /* Any other names starting in $ are debugger internal variables. */
1443
1444 if (*tokstart == '$')
1445 {
1446 yylval.ivar = lookup_internalvar (copy_name (yylval.sval) + 1);
1447 return VARIABLE;
1448 }
1449
1450 /* Use token-type BLOCKNAME for symbols that happen to be defined as
1451 functions or symtabs. If this is not so, then ...
1452 Use token-type TYPENAME for symbols that happen to be defined
1453 currently as names of types; NAME for other symbols.
1454 The caller is not constrained to care about the distinction. */
1455 {
1456 char *tmp = copy_name (yylval.sval);
1457 struct symbol *sym;
1458 int is_a_field_of_this = 0;
1459 int hextype;
1460
1461 sym = lookup_symbol (tmp, expression_context_block,
545af6ce
PB
1462 VAR_NAMESPACE,
1463 current_language->la_language == language_cplus
1464 ? &is_a_field_of_this : NULL,
1465 NULL);
3d6b6a90
JG
1466 if ((sym && SYMBOL_CLASS (sym) == LOC_BLOCK) ||
1467 lookup_partial_symtab (tmp))
1468 {
1469 yylval.ssym.sym = sym;
1470 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1471 return BLOCKNAME;
1472 }
1473 if (sym && SYMBOL_CLASS (sym) == LOC_TYPEDEF)
1474 {
1475 yylval.tsym.type = SYMBOL_TYPE (sym);
1476 return TYPENAME;
1477 }
1478 if ((yylval.tsym.type = lookup_primitive_typename (tmp)) != 0)
1479 return TYPENAME;
1480
1481 /* Input names that aren't symbols but ARE valid hex numbers,
1482 when the input radix permits them, can be names or numbers
1483 depending on the parse. Note we support radixes > 16 here. */
1484 if (!sym &&
1485 ((tokstart[0] >= 'a' && tokstart[0] < 'a' + input_radix - 10) ||
1486 (tokstart[0] >= 'A' && tokstart[0] < 'A' + input_radix - 10)))
1487 {
1488 YYSTYPE newlval; /* Its value is ignored. */
1489 hextype = parse_number (tokstart, namelen, 0, &newlval);
1490 if (hextype == INT)
1491 {
1492 yylval.ssym.sym = sym;
1493 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1494 return NAME_OR_INT;
1495 }
3d6b6a90
JG
1496 }
1497
1498 /* Any other kind of symbol */
1499 yylval.ssym.sym = sym;
1500 yylval.ssym.is_a_field_of_this = is_a_field_of_this;
1501 return NAME;
1502 }
1503}
1504
1505void
1506yyerror (msg)
1507 char *msg;
1508{
d671e293 1509 error (msg ? msg : "Invalid syntax in expression.");
3d6b6a90 1510}
5d074aa9
FF
1511\f
1512/* Print the character C on STREAM as part of the contents of a literal
1513 string whose delimiter is QUOTER. Note that that format for printing
1514 characters and strings is language specific. */
1515
1516static void
1517emit_char (c, stream, quoter)
1518 register int c;
1519 FILE *stream;
1520 int quoter;
1521{
1522
1523 c &= 0xFF; /* Avoid sign bit follies */
1524
5707ea9f
FF
1525 if (PRINT_LITERAL_FORM (c))
1526 {
1527 if (c == '\\' || c == quoter)
1528 {
1529 fputs_filtered ("\\", stream);
1530 }
1531 fprintf_filtered (stream, "%c", c);
1532 }
1533 else
1534 {
1535 switch (c)
1536 {
1537 case '\n':
1538 fputs_filtered ("\\n", stream);
1539 break;
1540 case '\b':
1541 fputs_filtered ("\\b", stream);
1542 break;
1543 case '\t':
1544 fputs_filtered ("\\t", stream);
1545 break;
1546 case '\f':
1547 fputs_filtered ("\\f", stream);
1548 break;
1549 case '\r':
1550 fputs_filtered ("\\r", stream);
1551 break;
1552 case '\033':
1553 fputs_filtered ("\\e", stream);
1554 break;
1555 case '\007':
1556 fputs_filtered ("\\a", stream);
1557 break;
1558 default:
1559 fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
1560 break;
1561 }
1562 }
5d074aa9
FF
1563}
1564
1565static void
1566c_printchar (c, stream)
1567 int c;
1568 FILE *stream;
1569{
1570 fputs_filtered ("'", stream);
1571 emit_char (c, stream, '\'');
1572 fputs_filtered ("'", stream);
1573}
1574
1575/* Print the character string STRING, printing at most LENGTH characters.
1576 Printing stops early if the number hits print_max; repeat counts
1577 are printed as appropriate. Print ellipses at the end if we
1578 had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */
1579
1580static void
1581c_printstr (stream, string, length, force_ellipses)
1582 FILE *stream;
1583 char *string;
1584 unsigned int length;
1585 int force_ellipses;
1586{
1587 register unsigned int i;
1588 unsigned int things_printed = 0;
1589 int in_quotes = 0;
1590 int need_comma = 0;
1591 extern int inspect_it;
1592 extern int repeat_count_threshold;
1593 extern int print_max;
1594
1595 if (length == 0)
1596 {
1597 fputs_filtered ("\"\"", stdout);
1598 return;
1599 }
1600
1601 for (i = 0; i < length && things_printed < print_max; ++i)
1602 {
1603 /* Position of the character we are examining
1604 to see whether it is repeated. */
1605 unsigned int rep1;
1606 /* Number of repetitions we have detected so far. */
1607 unsigned int reps;
1608
1609 QUIT;
1610
1611 if (need_comma)
1612 {
1613 fputs_filtered (", ", stream);
1614 need_comma = 0;
1615 }
1616
1617 rep1 = i + 1;
1618 reps = 1;
1619 while (rep1 < length && string[rep1] == string[i])
1620 {
1621 ++rep1;
1622 ++reps;
1623 }
1624
1625 if (reps > repeat_count_threshold)
1626 {
1627 if (in_quotes)
1628 {
1629 if (inspect_it)
1630 fputs_filtered ("\\\", ", stream);
1631 else
1632 fputs_filtered ("\", ", stream);
1633 in_quotes = 0;
1634 }
1635 c_printchar (string[i], stream);
1636 fprintf_filtered (stream, " <repeats %u times>", reps);
1637 i = rep1 - 1;
1638 things_printed += repeat_count_threshold;
1639 need_comma = 1;
1640 }
1641 else
1642 {
1643 if (!in_quotes)
1644 {
1645 if (inspect_it)
1646 fputs_filtered ("\\\"", stream);
1647 else
1648 fputs_filtered ("\"", stream);
1649 in_quotes = 1;
1650 }
1651 emit_char (string[i], stream, '"');
1652 ++things_printed;
1653 }
1654 }
1655
1656 /* Terminate the quotes if necessary. */
1657 if (in_quotes)
1658 {
1659 if (inspect_it)
1660 fputs_filtered ("\\\"", stream);
1661 else
1662 fputs_filtered ("\"", stream);
1663 }
1664
1665 if (force_ellipses || i < length)
1666 fputs_filtered ("...", stream);
1667}
1668
bf229b4e
FF
1669/* Create a fundamental C type using default reasonable for the current
1670 target machine.
1671
1672 Some object/debugging file formats (DWARF version 1, COFF, etc) do not
1673 define fundamental types such as "int" or "double". Others (stabs or
1674 DWARF version 2, etc) do define fundamental types. For the formats which
1675 don't provide fundamental types, gdb can create such types using this
1676 function.
1677
1678 FIXME: Some compilers distinguish explicitly signed integral types
1679 (signed short, signed int, signed long) from "regular" integral types
1680 (short, int, long) in the debugging information. There is some dis-
1681 agreement as to how useful this feature is. In particular, gcc does
1682 not support this. Also, only some debugging formats allow the
1683 distinction to be passed on to a debugger. For now, we always just
1684 use "short", "int", or "long" as the type name, for both the implicit
1685 and explicitly signed types. This also makes life easier for the
1686 gdb test suite since we don't have to account for the differences
1687 in output depending upon what the compiler and debugging format
1688 support. We will probably have to re-examine the issue when gdb
1689 starts taking it's fundamental type information directly from the
1690 debugging information supplied by the compiler. fnf@cygnus.com */
1691
1692static struct type *
1693c_create_fundamental_type (objfile, typeid)
1694 struct objfile *objfile;
1695 int typeid;
1696{
1697 register struct type *type = NULL;
1698 register int nbytes;
1699
1700 switch (typeid)
1701 {
1702 default:
1703 /* FIXME: For now, if we are asked to produce a type not in this
1704 language, create the equivalent of a C integer type with the
1705 name "<?type?>". When all the dust settles from the type
1706 reconstruction work, this should probably become an error. */
1707 type = init_type (TYPE_CODE_INT,
1708 TARGET_INT_BIT / TARGET_CHAR_BIT,
1709 0, "<?type?>", objfile);
1710 warning ("internal error: no C/C++ fundamental type %d", typeid);
1711 break;
1712 case FT_VOID:
1713 type = init_type (TYPE_CODE_VOID,
1714 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1715 0, "void", objfile);
1716 break;
1717 case FT_CHAR:
1718 type = init_type (TYPE_CODE_INT,
1719 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1720 0, "char", objfile);
1721 break;
1722 case FT_SIGNED_CHAR:
1723 type = init_type (TYPE_CODE_INT,
1724 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1725 TYPE_FLAG_SIGNED, "signed char", objfile);
1726 break;
1727 case FT_UNSIGNED_CHAR:
1728 type = init_type (TYPE_CODE_INT,
1729 TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1730 TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
1731 break;
1732 case FT_SHORT:
1733 type = init_type (TYPE_CODE_INT,
1734 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1735 0, "short", objfile);
1736 break;
1737 case FT_SIGNED_SHORT:
1738 type = init_type (TYPE_CODE_INT,
1739 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1740 TYPE_FLAG_SIGNED, "short", objfile); /* FIXME-fnf */
1741 break;
1742 case FT_UNSIGNED_SHORT:
1743 type = init_type (TYPE_CODE_INT,
1744 TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1745 TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
1746 break;
1747 case FT_INTEGER:
1748 type = init_type (TYPE_CODE_INT,
1749 TARGET_INT_BIT / TARGET_CHAR_BIT,
1750 0, "int", objfile);
1751 break;
1752 case FT_SIGNED_INTEGER:
1753 type = init_type (TYPE_CODE_INT,
1754 TARGET_INT_BIT / TARGET_CHAR_BIT,
1755 TYPE_FLAG_SIGNED, "int", objfile); /* FIXME -fnf */
1756 break;
1757 case FT_UNSIGNED_INTEGER:
1758 type = init_type (TYPE_CODE_INT,
1759 TARGET_INT_BIT / TARGET_CHAR_BIT,
1760 TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
1761 break;
1762 case FT_LONG:
1763 type = init_type (TYPE_CODE_INT,
1764 TARGET_LONG_BIT / TARGET_CHAR_BIT,
1765 0, "long", objfile);
1766 break;
1767 case FT_SIGNED_LONG:
1768 type = init_type (TYPE_CODE_INT,
1769 TARGET_LONG_BIT / TARGET_CHAR_BIT,
1770 TYPE_FLAG_SIGNED, "long", objfile); /* FIXME -fnf */
1771 break;
1772 case FT_UNSIGNED_LONG:
1773 type = init_type (TYPE_CODE_INT,
1774 TARGET_LONG_BIT / TARGET_CHAR_BIT,
1775 TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
1776 break;
1777 case FT_LONG_LONG:
1778 type = init_type (TYPE_CODE_INT,
1779 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1780 0, "long long", objfile);
1781 break;
1782 case FT_SIGNED_LONG_LONG:
1783 type = init_type (TYPE_CODE_INT,
1784 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1785 TYPE_FLAG_SIGNED, "signed long long", objfile);
1786 break;
1787 case FT_UNSIGNED_LONG_LONG:
1788 type = init_type (TYPE_CODE_INT,
1789 TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1790 TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
1791 break;
1792 case FT_FLOAT:
1793 type = init_type (TYPE_CODE_FLT,
1794 TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1795 0, "float", objfile);
1796 break;
1797 case FT_DBL_PREC_FLOAT:
1798 type = init_type (TYPE_CODE_FLT,
1799 TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1800 0, "double", objfile);
1801 break;
1802 case FT_EXT_PREC_FLOAT:
1803 type = init_type (TYPE_CODE_FLT,
1804 TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
1805 0, "long double", objfile);
1806 break;
1807 }
1808 return (type);
1809}
1810
3d6b6a90
JG
1811\f
1812/* Table mapping opcodes into strings for printing operators
1813 and precedences of the operators. */
1814
1815const static struct op_print c_op_print_tab[] =
1816 {
1817 {",", BINOP_COMMA, PREC_COMMA, 0},
1818 {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
e58de8a2
FF
1819 {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
1820 {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
1821 {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
1822 {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
1823 {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
3d6b6a90
JG
1824 {"==", BINOP_EQUAL, PREC_EQUAL, 0},
1825 {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
1826 {"<=", BINOP_LEQ, PREC_ORDER, 0},
1827 {">=", BINOP_GEQ, PREC_ORDER, 0},
1828 {">", BINOP_GTR, PREC_ORDER, 0},
1829 {"<", BINOP_LESS, PREC_ORDER, 0},
1830 {">>", BINOP_RSH, PREC_SHIFT, 0},
1831 {"<<", BINOP_LSH, PREC_SHIFT, 0},
1832 {"+", BINOP_ADD, PREC_ADD, 0},
1833 {"-", BINOP_SUB, PREC_ADD, 0},
1834 {"*", BINOP_MUL, PREC_MUL, 0},
1835 {"/", BINOP_DIV, PREC_MUL, 0},
1836 {"%", BINOP_REM, PREC_MUL, 0},
1837 {"@", BINOP_REPEAT, PREC_REPEAT, 0},
1838 {"-", UNOP_NEG, PREC_PREFIX, 0},
e58de8a2
FF
1839 {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
1840 {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
3d6b6a90
JG
1841 {"*", UNOP_IND, PREC_PREFIX, 0},
1842 {"&", UNOP_ADDR, PREC_PREFIX, 0},
1843 {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
1844 {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
1845 {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
1846 /* C++ */
1847 {"::", BINOP_SCOPE, PREC_PREFIX, 0},
e58de8a2 1848 {NULL, 0, 0, 0}
3d6b6a90
JG
1849};
1850\f
1851/* These variables point to the objects
1852 representing the predefined C data types. */
1853
1854struct type *builtin_type_void;
1855struct type *builtin_type_char;
1856struct type *builtin_type_short;
1857struct type *builtin_type_int;
1858struct type *builtin_type_long;
1859struct type *builtin_type_long_long;
04f27ddc 1860struct type *builtin_type_signed_char;
3d6b6a90
JG
1861struct type *builtin_type_unsigned_char;
1862struct type *builtin_type_unsigned_short;
1863struct type *builtin_type_unsigned_int;
1864struct type *builtin_type_unsigned_long;
1865struct type *builtin_type_unsigned_long_long;
1866struct type *builtin_type_float;
1867struct type *builtin_type_double;
e2aab031
FF
1868struct type *builtin_type_long_double;
1869struct type *builtin_type_complex;
1870struct type *builtin_type_double_complex;
3d6b6a90 1871
9dffe475 1872struct type ** const (c_builtin_types[]) =
3d6b6a90
JG
1873{
1874 &builtin_type_int,
1875 &builtin_type_long,
1876 &builtin_type_short,
1877 &builtin_type_char,
1878 &builtin_type_float,
1879 &builtin_type_double,
1880 &builtin_type_void,
1881 &builtin_type_long_long,
04f27ddc 1882 &builtin_type_signed_char,
3d6b6a90
JG
1883 &builtin_type_unsigned_char,
1884 &builtin_type_unsigned_short,
1885 &builtin_type_unsigned_int,
1886 &builtin_type_unsigned_long,
1887 &builtin_type_unsigned_long_long,
e2aab031
FF
1888 &builtin_type_long_double,
1889 &builtin_type_complex,
1890 &builtin_type_double_complex,
3d6b6a90
JG
1891 0
1892};
1893
9dffe475 1894const struct language_defn c_language_defn = {
3d6b6a90
JG
1895 "c", /* Language name */
1896 language_c,
1897 c_builtin_types,
1898 range_check_off,
1899 type_check_off,
1900 c_parse,
1901 c_error,
5d074aa9
FF
1902 c_printchar, /* Print a character constant */
1903 c_printstr, /* Function to print string constant */
bf229b4e
FF
1904 c_create_fundamental_type, /* Create fundamental type in this language */
1905 &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
3d6b6a90 1906 &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
e2aab031 1907 &builtin_type_double, /* longest floating point type */ /*FIXME*/
2e66cf7d
FF
1908 {"", "", "", ""}, /* Binary format info */
1909 {"0%o", "0", "o", ""}, /* Octal format info */
1910 {"%d", "", "d", ""}, /* Decimal format info */
1911 {"0x%x", "0x", "x", ""}, /* Hex format info */
3d6b6a90
JG
1912 c_op_print_tab, /* expression operators for printing */
1913 LANG_MAGIC
1914};
1915
545af6ce
PB
1916const struct language_defn cplus_language_defn = {
1917 "c++", /* Language name */
1918 language_cplus,
1919 c_builtin_types,
1920 range_check_off,
1921 type_check_off,
1922 c_parse,
1923 c_error,
5d074aa9
FF
1924 c_printchar, /* Print a character constant */
1925 c_printstr, /* Function to print string constant */
bf229b4e 1926 c_create_fundamental_type, /* Create fundamental type in this language */
545af6ce
PB
1927 &BUILTIN_TYPE_LONGEST, /* longest signed integral type */
1928 &BUILTIN_TYPE_UNSIGNED_LONGEST,/* longest unsigned integral type */
1929 &builtin_type_double, /* longest floating point type */ /*FIXME*/
2e66cf7d
FF
1930 {"", "", "", ""}, /* Binary format info */
1931 {"0%o", "0", "o", ""}, /* Octal format info */
1932 {"%d", "", "d", ""}, /* Decimal format info */
1933 {"0x%x", "0x", "x", ""}, /* Hex format info */
545af6ce
PB
1934 c_op_print_tab, /* expression operators for printing */
1935 LANG_MAGIC
1936};
1937
3d6b6a90
JG
1938void
1939_initialize_c_exp ()
1940{
e2aab031 1941 builtin_type_void =
1ab3bf1b 1942 init_type (TYPE_CODE_VOID, 1,
1867b3be 1943 0,
1ab3bf1b 1944 "void", (struct objfile *) NULL);
e2aab031 1945 builtin_type_char =
1ab3bf1b 1946 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1867b3be 1947 0,
1ab3bf1b 1948 "char", (struct objfile *) NULL);
04f27ddc
PB
1949 builtin_type_signed_char =
1950 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1867b3be 1951 TYPE_FLAG_SIGNED,
04f27ddc 1952 "signed char", (struct objfile *) NULL);
e2aab031 1953 builtin_type_unsigned_char =
1ab3bf1b 1954 init_type (TYPE_CODE_INT, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
1867b3be 1955 TYPE_FLAG_UNSIGNED,
1ab3bf1b 1956 "unsigned char", (struct objfile *) NULL);
e2aab031 1957 builtin_type_short =
1ab3bf1b 1958 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1867b3be 1959 0,
1ab3bf1b 1960 "short", (struct objfile *) NULL);
e2aab031 1961 builtin_type_unsigned_short =
1ab3bf1b 1962 init_type (TYPE_CODE_INT, TARGET_SHORT_BIT / TARGET_CHAR_BIT,
1867b3be 1963 TYPE_FLAG_UNSIGNED,
1ab3bf1b 1964 "unsigned short", (struct objfile *) NULL);
e2aab031 1965 builtin_type_int =
1ab3bf1b 1966 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1867b3be 1967 0,
1ab3bf1b 1968 "int", (struct objfile *) NULL);
e2aab031 1969 builtin_type_unsigned_int =
1ab3bf1b 1970 init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
1867b3be 1971 TYPE_FLAG_UNSIGNED,
1ab3bf1b 1972 "unsigned int", (struct objfile *) NULL);
e2aab031 1973 builtin_type_long =
1ab3bf1b 1974 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1867b3be 1975 0,
1ab3bf1b 1976 "long", (struct objfile *) NULL);
e2aab031 1977 builtin_type_unsigned_long =
1ab3bf1b 1978 init_type (TYPE_CODE_INT, TARGET_LONG_BIT / TARGET_CHAR_BIT,
1867b3be 1979 TYPE_FLAG_UNSIGNED,
1ab3bf1b 1980 "unsigned long", (struct objfile *) NULL);
3d6b6a90 1981 builtin_type_long_long =
1ab3bf1b 1982 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1867b3be 1983 0,
1ab3bf1b 1984 "long long", (struct objfile *) NULL);
3d6b6a90 1985 builtin_type_unsigned_long_long =
1ab3bf1b 1986 init_type (TYPE_CODE_INT, TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
1867b3be 1987 TYPE_FLAG_UNSIGNED,
1ab3bf1b 1988 "unsigned long long", (struct objfile *) NULL);
e2aab031 1989 builtin_type_float =
1ab3bf1b 1990 init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
1867b3be 1991 0,
1ab3bf1b 1992 "float", (struct objfile *) NULL);
e2aab031 1993 builtin_type_double =
1ab3bf1b 1994 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
1867b3be 1995 0,
1ab3bf1b 1996 "double", (struct objfile *) NULL);
e2aab031 1997 builtin_type_long_double =
1ab3bf1b 1998 init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
1867b3be 1999 0,
1ab3bf1b 2000 "long double", (struct objfile *) NULL);
e2aab031 2001 builtin_type_complex =
1ab3bf1b 2002 init_type (TYPE_CODE_FLT, TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
1867b3be 2003 0,
1ab3bf1b 2004 "complex", (struct objfile *) NULL);
e2aab031 2005 builtin_type_double_complex =
1ab3bf1b 2006 init_type (TYPE_CODE_FLT, TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
1867b3be 2007 0,
1ab3bf1b 2008 "double complex", (struct objfile *) NULL);
3d6b6a90
JG
2009
2010 add_language (&c_language_defn);
545af6ce 2011 add_language (&cplus_language_defn);
3d6b6a90 2012}
This page took 0.146286 seconds and 4 git commands to generate.