OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.3/] [gdb/] [c-lang.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1181 sfurman
/* C language support routines for GDB, the GNU debugger.
2
   Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2002
3
   Free Software Foundation, Inc.
4
 
5
   This file is part of GDB.
6
 
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
 
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
 
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 59 Temple Place - Suite 330,
20
   Boston, MA 02111-1307, USA.  */
21
 
22
#include "defs.h"
23
#include "symtab.h"
24
#include "gdbtypes.h"
25
#include "expression.h"
26
#include "parser-defs.h"
27
#include "language.h"
28
#include "c-lang.h"
29
#include "valprint.h"
30
#include "macroscope.h"
31
#include "gdb_assert.h"
32
 
33
extern void _initialize_c_language (void);
34
static void c_emit_char (int c, struct ui_file * stream, int quoter);
35
 
36
/* Print the character C on STREAM as part of the contents of a literal
37
   string whose delimiter is QUOTER.  Note that that format for printing
38
   characters and strings is language specific. */
39
 
40
static void
41
c_emit_char (register int c, struct ui_file *stream, int quoter)
42
{
43
  c &= 0xFF;                    /* Avoid sign bit follies */
44
 
45
  if (PRINT_LITERAL_FORM (c))
46
    {
47
      if (c == '\\' || c == quoter)
48
        {
49
          fputs_filtered ("\\", stream);
50
        }
51
      fprintf_filtered (stream, "%c", c);
52
    }
53
  else
54
    {
55
      switch (c)
56
        {
57
        case '\n':
58
          fputs_filtered ("\\n", stream);
59
          break;
60
        case '\b':
61
          fputs_filtered ("\\b", stream);
62
          break;
63
        case '\t':
64
          fputs_filtered ("\\t", stream);
65
          break;
66
        case '\f':
67
          fputs_filtered ("\\f", stream);
68
          break;
69
        case '\r':
70
          fputs_filtered ("\\r", stream);
71
          break;
72
        case '\013':
73
          fputs_filtered ("\\v", stream);
74
          break;
75
        case '\033':
76
          fputs_filtered ("\\e", stream);
77
          break;
78
        case '\007':
79
          fputs_filtered ("\\a", stream);
80
          break;
81
        case '\0':
82
          fputs_filtered ("\\0", stream);
83
          break;
84
        default:
85
          fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
86
          break;
87
        }
88
    }
89
}
90
 
91
void
92
c_printchar (int c, struct ui_file *stream)
93
{
94
  fputc_filtered ('\'', stream);
95
  LA_EMIT_CHAR (c, stream, '\'');
96
  fputc_filtered ('\'', stream);
97
}
98
 
99
/* Print the character string STRING, printing at most LENGTH characters.
100
   LENGTH is -1 if the string is nul terminated.  Each character is WIDTH bytes
101
   long.  Printing stops early if the number hits print_max; repeat counts are
102
   printed as appropriate.  Print ellipses at the end if we had to stop before
103
   printing LENGTH characters, or if FORCE_ELLIPSES.  */
104
 
105
void
106
c_printstr (struct ui_file *stream, char *string, unsigned int length,
107
            int width, int force_ellipses)
108
{
109
  register unsigned int i;
110
  unsigned int things_printed = 0;
111
  int in_quotes = 0;
112
  int need_comma = 0;
113
  extern int inspect_it;
114
 
115
  /* If the string was not truncated due to `set print elements', and
116
     the last byte of it is a null, we don't print that, in traditional C
117
     style.  */
118
  if (!force_ellipses
119
      && length > 0
120
      && (extract_unsigned_integer (string + (length - 1) * width, width)
121
          == '\0'))
122
    length--;
123
 
124
  if (length == 0)
125
    {
126
      fputs_filtered ("\"\"", stream);
127
      return;
128
    }
129
 
130
  for (i = 0; i < length && things_printed < print_max; ++i)
131
    {
132
      /* Position of the character we are examining
133
         to see whether it is repeated.  */
134
      unsigned int rep1;
135
      /* Number of repetitions we have detected so far.  */
136
      unsigned int reps;
137
      unsigned long current_char;
138
 
139
      QUIT;
140
 
141
      if (need_comma)
142
        {
143
          fputs_filtered (", ", stream);
144
          need_comma = 0;
145
        }
146
 
147
      current_char = extract_unsigned_integer (string + i * width, width);
148
 
149
      rep1 = i + 1;
150
      reps = 1;
151
      while (rep1 < length
152
             && extract_unsigned_integer (string + rep1 * width, width)
153
             == current_char)
154
        {
155
          ++rep1;
156
          ++reps;
157
        }
158
 
159
      if (reps > repeat_count_threshold)
160
        {
161
          if (in_quotes)
162
            {
163
              if (inspect_it)
164
                fputs_filtered ("\\\", ", stream);
165
              else
166
                fputs_filtered ("\", ", stream);
167
              in_quotes = 0;
168
            }
169
          LA_PRINT_CHAR (current_char, stream);
170
          fprintf_filtered (stream, " <repeats %u times>", reps);
171
          i = rep1 - 1;
172
          things_printed += repeat_count_threshold;
173
          need_comma = 1;
174
        }
175
      else
176
        {
177
          if (!in_quotes)
178
            {
179
              if (inspect_it)
180
                fputs_filtered ("\\\"", stream);
181
              else
182
                fputs_filtered ("\"", stream);
183
              in_quotes = 1;
184
            }
185
          LA_EMIT_CHAR (current_char, stream, '"');
186
          ++things_printed;
187
        }
188
    }
189
 
190
  /* Terminate the quotes if necessary.  */
191
  if (in_quotes)
192
    {
193
      if (inspect_it)
194
        fputs_filtered ("\\\"", stream);
195
      else
196
        fputs_filtered ("\"", stream);
197
    }
198
 
199
  if (force_ellipses || i < length)
200
    fputs_filtered ("...", stream);
201
}
202
 
203
/* Create a fundamental C type using default reasonable for the current
204
   target machine.
205
 
206
   Some object/debugging file formats (DWARF version 1, COFF, etc) do not
207
   define fundamental types such as "int" or "double".  Others (stabs or
208
   DWARF version 2, etc) do define fundamental types.  For the formats which
209
   don't provide fundamental types, gdb can create such types using this
210
   function.
211
 
212
   FIXME:  Some compilers distinguish explicitly signed integral types
213
   (signed short, signed int, signed long) from "regular" integral types
214
   (short, int, long) in the debugging information.  There is some dis-
215
   agreement as to how useful this feature is.  In particular, gcc does
216
   not support this.  Also, only some debugging formats allow the
217
   distinction to be passed on to a debugger.  For now, we always just
218
   use "short", "int", or "long" as the type name, for both the implicit
219
   and explicitly signed types.  This also makes life easier for the
220
   gdb test suite since we don't have to account for the differences
221
   in output depending upon what the compiler and debugging format
222
   support.  We will probably have to re-examine the issue when gdb
223
   starts taking it's fundamental type information directly from the
224
   debugging information supplied by the compiler.  fnf@cygnus.com */
225
 
226
struct type *
227
c_create_fundamental_type (struct objfile *objfile, int typeid)
228
{
229
  register struct type *type = NULL;
230
 
231
  switch (typeid)
232
    {
233
    default:
234
      /* FIXME:  For now, if we are asked to produce a type not in this
235
         language, create the equivalent of a C integer type with the
236
         name "<?type?>".  When all the dust settles from the type
237
         reconstruction work, this should probably become an error. */
238
      type = init_type (TYPE_CODE_INT,
239
                        TARGET_INT_BIT / TARGET_CHAR_BIT,
240
                        0, "<?type?>", objfile);
241
      warning ("internal error: no C/C++ fundamental type %d", typeid);
242
      break;
243
    case FT_VOID:
244
      type = init_type (TYPE_CODE_VOID,
245
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
246
                        0, "void", objfile);
247
      break;
248
    case FT_BOOLEAN:
249
      type = init_type (TYPE_CODE_BOOL,
250
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
251
                        0, "bool", objfile);
252
      break;
253
    case FT_CHAR:
254
      type = init_type (TYPE_CODE_INT,
255
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
256
                        TYPE_FLAG_NOSIGN, "char", objfile);
257
      break;
258
    case FT_SIGNED_CHAR:
259
      type = init_type (TYPE_CODE_INT,
260
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
261
                        0, "signed char", objfile);
262
      break;
263
    case FT_UNSIGNED_CHAR:
264
      type = init_type (TYPE_CODE_INT,
265
                        TARGET_CHAR_BIT / TARGET_CHAR_BIT,
266
                        TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
267
      break;
268
    case FT_SHORT:
269
      type = init_type (TYPE_CODE_INT,
270
                        TARGET_SHORT_BIT / TARGET_CHAR_BIT,
271
                        0, "short", objfile);
272
      break;
273
    case FT_SIGNED_SHORT:
274
      type = init_type (TYPE_CODE_INT,
275
                        TARGET_SHORT_BIT / TARGET_CHAR_BIT,
276
                        0, "short", objfile);    /* FIXME-fnf */
277
      break;
278
    case FT_UNSIGNED_SHORT:
279
      type = init_type (TYPE_CODE_INT,
280
                        TARGET_SHORT_BIT / TARGET_CHAR_BIT,
281
                        TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
282
      break;
283
    case FT_INTEGER:
284
      type = init_type (TYPE_CODE_INT,
285
                        TARGET_INT_BIT / TARGET_CHAR_BIT,
286
                        0, "int", objfile);
287
      break;
288
    case FT_SIGNED_INTEGER:
289
      type = init_type (TYPE_CODE_INT,
290
                        TARGET_INT_BIT / TARGET_CHAR_BIT,
291
                        0, "int", objfile);      /* FIXME -fnf */
292
      break;
293
    case FT_UNSIGNED_INTEGER:
294
      type = init_type (TYPE_CODE_INT,
295
                        TARGET_INT_BIT / TARGET_CHAR_BIT,
296
                        TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
297
      break;
298
    case FT_LONG:
299
      type = init_type (TYPE_CODE_INT,
300
                        TARGET_LONG_BIT / TARGET_CHAR_BIT,
301
                        0, "long", objfile);
302
      break;
303
    case FT_SIGNED_LONG:
304
      type = init_type (TYPE_CODE_INT,
305
                        TARGET_LONG_BIT / TARGET_CHAR_BIT,
306
                        0, "long", objfile);     /* FIXME -fnf */
307
      break;
308
    case FT_UNSIGNED_LONG:
309
      type = init_type (TYPE_CODE_INT,
310
                        TARGET_LONG_BIT / TARGET_CHAR_BIT,
311
                        TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
312
      break;
313
    case FT_LONG_LONG:
314
      type = init_type (TYPE_CODE_INT,
315
                        TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
316
                        0, "long long", objfile);
317
      break;
318
    case FT_SIGNED_LONG_LONG:
319
      type = init_type (TYPE_CODE_INT,
320
                        TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
321
                        0, "signed long long", objfile);
322
      break;
323
    case FT_UNSIGNED_LONG_LONG:
324
      type = init_type (TYPE_CODE_INT,
325
                        TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
326
                        TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
327
      break;
328
    case FT_FLOAT:
329
      type = init_type (TYPE_CODE_FLT,
330
                        TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
331
                        0, "float", objfile);
332
      break;
333
    case FT_DBL_PREC_FLOAT:
334
      type = init_type (TYPE_CODE_FLT,
335
                        TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
336
                        0, "double", objfile);
337
      break;
338
    case FT_EXT_PREC_FLOAT:
339
      type = init_type (TYPE_CODE_FLT,
340
                        TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
341
                        0, "long double", objfile);
342
      break;
343
    case FT_COMPLEX:
344
      type = init_type (TYPE_CODE_FLT,
345
                        2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
346
                        0, "complex float", objfile);
347
      TYPE_TARGET_TYPE (type)
348
        = init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
349
                     0, "float", objfile);
350
      break;
351
    case FT_DBL_PREC_COMPLEX:
352
      type = init_type (TYPE_CODE_FLT,
353
                        2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
354
                        0, "complex double", objfile);
355
      TYPE_TARGET_TYPE (type)
356
        = init_type (TYPE_CODE_FLT, TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
357
                     0, "double", objfile);
358
      break;
359
    case FT_EXT_PREC_COMPLEX:
360
      type = init_type (TYPE_CODE_FLT,
361
                        2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
362
                        0, "complex long double", objfile);
363
      TYPE_TARGET_TYPE (type)
364
        = init_type (TYPE_CODE_FLT, TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
365
                     0, "long double", objfile);
366
      break;
367
    case FT_TEMPLATE_ARG:
368
      type = init_type (TYPE_CODE_TEMPLATE_ARG,
369
                        0,
370
                        0, "<template arg>", objfile);
371
      break;
372
    }
373
  return (type);
374
}
375
 
376
/* Preprocessing and parsing C and C++ expressions.  */
377
 
378
 
379
/* When we find that lexptr (the global var defined in parse.c) is
380
   pointing at a macro invocation, we expand the invocation, and call
381
   scan_macro_expansion to save the old lexptr here and point lexptr
382
   into the expanded text.  When we reach the end of that, we call
383
   end_macro_expansion to pop back to the value we saved here.  The
384
   macro expansion code promises to return only fully-expanded text,
385
   so we don't need to "push" more than one level.
386
 
387
   This is disgusting, of course.  It would be cleaner to do all macro
388
   expansion beforehand, and then hand that to lexptr.  But we don't
389
   really know where the expression ends.  Remember, in a command like
390
 
391
     (gdb) break *ADDRESS if CONDITION
392
 
393
   we evaluate ADDRESS in the scope of the current frame, but we
394
   evaluate CONDITION in the scope of the breakpoint's location.  So
395
   it's simply wrong to try to macro-expand the whole thing at once.  */
396
static char *macro_original_text;
397
static char *macro_expanded_text;
398
 
399
 
400
void
401
scan_macro_expansion (char *expansion)
402
{
403
  /* We'd better not be trying to push the stack twice.  */
404
  gdb_assert (! macro_original_text);
405
  gdb_assert (! macro_expanded_text);
406
 
407
  /* Save the old lexptr value, so we can return to it when we're done
408
     parsing the expanded text.  */
409
  macro_original_text = lexptr;
410
  lexptr = expansion;
411
 
412
  /* Save the expanded text, so we can free it when we're finished.  */
413
  macro_expanded_text = expansion;
414
}
415
 
416
 
417
int
418
scanning_macro_expansion (void)
419
{
420
  return macro_original_text != 0;
421
}
422
 
423
 
424
void
425
finished_macro_expansion (void)
426
{
427
  /* There'd better be something to pop back to, and we better have
428
     saved a pointer to the start of the expanded text.  */
429
  gdb_assert (macro_original_text);
430
  gdb_assert (macro_expanded_text);
431
 
432
  /* Pop back to the original text.  */
433
  lexptr = macro_original_text;
434
  macro_original_text = 0;
435
 
436
  /* Free the expanded text.  */
437
  xfree (macro_expanded_text);
438
  macro_expanded_text = 0;
439
}
440
 
441
 
442
static void
443
scan_macro_cleanup (void *dummy)
444
{
445
  if (macro_original_text)
446
    finished_macro_expansion ();
447
}
448
 
449
 
450
/* We set these global variables before calling c_parse, to tell it
451
   how it to find macro definitions for the expression at hand.  */
452
macro_lookup_ftype *expression_macro_lookup_func;
453
void *expression_macro_lookup_baton;
454
 
455
 
456
static struct macro_definition *
457
null_macro_lookup (const char *name, void *baton)
458
{
459
  return 0;
460
}
461
 
462
 
463
static int
464
c_preprocess_and_parse (void)
465
{
466
  /* Set up a lookup function for the macro expander.  */
467
  struct macro_scope *scope = 0;
468
  struct cleanup *back_to = make_cleanup (free_current_contents, &scope);
469
 
470
  if (expression_context_block)
471
    scope = sal_macro_scope (find_pc_line (expression_context_pc, 0));
472
  else
473
    scope = default_macro_scope ();
474
 
475
  if (scope)
476
    {
477
      expression_macro_lookup_func = standard_macro_lookup;
478
      expression_macro_lookup_baton = (void *) scope;
479
    }
480
  else
481
    {
482
      expression_macro_lookup_func = null_macro_lookup;
483
      expression_macro_lookup_baton = 0;
484
    }
485
 
486
  gdb_assert (! macro_original_text);
487
  make_cleanup (scan_macro_cleanup, 0);
488
 
489
  {
490
    int result = c_parse ();
491
    do_cleanups (back_to);
492
    return result;
493
  }
494
}
495
 
496
 
497
 
498
/* Table mapping opcodes into strings for printing operators
499
   and precedences of the operators.  */
500
 
501
const struct op_print c_op_print_tab[] =
502
{
503
  {",", BINOP_COMMA, PREC_COMMA, 0},
504
  {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
505
  {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
506
  {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
507
  {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
508
  {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
509
  {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
510
  {"==", BINOP_EQUAL, PREC_EQUAL, 0},
511
  {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
512
  {"<=", BINOP_LEQ, PREC_ORDER, 0},
513
  {">=", BINOP_GEQ, PREC_ORDER, 0},
514
  {">", BINOP_GTR, PREC_ORDER, 0},
515
  {"<", BINOP_LESS, PREC_ORDER, 0},
516
  {">>", BINOP_RSH, PREC_SHIFT, 0},
517
  {"<<", BINOP_LSH, PREC_SHIFT, 0},
518
  {"+", BINOP_ADD, PREC_ADD, 0},
519
  {"-", BINOP_SUB, PREC_ADD, 0},
520
  {"*", BINOP_MUL, PREC_MUL, 0},
521
  {"/", BINOP_DIV, PREC_MUL, 0},
522
  {"%", BINOP_REM, PREC_MUL, 0},
523
  {"@", BINOP_REPEAT, PREC_REPEAT, 0},
524
  {"-", UNOP_NEG, PREC_PREFIX, 0},
525
  {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
526
  {"~", UNOP_COMPLEMENT, PREC_PREFIX, 0},
527
  {"*", UNOP_IND, PREC_PREFIX, 0},
528
  {"&", UNOP_ADDR, PREC_PREFIX, 0},
529
  {"sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
530
  {"++", UNOP_PREINCREMENT, PREC_PREFIX, 0},
531
  {"--", UNOP_PREDECREMENT, PREC_PREFIX, 0},
532
  {NULL, 0, 0, 0}
533
};
534
 
535
struct type **const (c_builtin_types[]) =
536
{
537
  &builtin_type_int,
538
  &builtin_type_long,
539
  &builtin_type_short,
540
  &builtin_type_char,
541
  &builtin_type_float,
542
  &builtin_type_double,
543
  &builtin_type_void,
544
  &builtin_type_long_long,
545
  &builtin_type_signed_char,
546
  &builtin_type_unsigned_char,
547
  &builtin_type_unsigned_short,
548
  &builtin_type_unsigned_int,
549
  &builtin_type_unsigned_long,
550
  &builtin_type_unsigned_long_long,
551
  &builtin_type_long_double,
552
  &builtin_type_complex,
553
  &builtin_type_double_complex,
554
 
555
};
556
 
557
const struct language_defn c_language_defn =
558
{
559
  "c",                          /* Language name */
560
  language_c,
561
  c_builtin_types,
562
  range_check_off,
563
  type_check_off,
564
  case_sensitive_on,
565
  c_preprocess_and_parse,
566
  c_error,
567
  evaluate_subexp_standard,
568
  c_printchar,                  /* Print a character constant */
569
  c_printstr,                   /* Function to print string constant */
570
  c_emit_char,                  /* Print a single char */
571
  c_create_fundamental_type,    /* Create fundamental type in this language */
572
  c_print_type,                 /* Print a type using appropriate syntax */
573
  c_val_print,                  /* Print a value using appropriate syntax */
574
  c_value_print,                /* Print a top-level value */
575
  {"", "", "", ""},             /* Binary format info */
576
  {"0%lo", "0", "o", ""},        /* Octal format info */
577
  {"%ld", "", "d", ""},         /* Decimal format info */
578
  {"0x%lx", "0x", "x", ""},     /* Hex format info */
579
  c_op_print_tab,               /* expression operators for printing */
580
  1,                            /* c-style arrays */
581
  0,                             /* String lower bound */
582
  &builtin_type_char,           /* Type of string elements */
583
  LANG_MAGIC
584
};
585
 
586
struct type **const (cplus_builtin_types[]) =
587
{
588
  &builtin_type_int,
589
  &builtin_type_long,
590
  &builtin_type_short,
591
  &builtin_type_char,
592
  &builtin_type_float,
593
  &builtin_type_double,
594
  &builtin_type_void,
595
  &builtin_type_long_long,
596
  &builtin_type_signed_char,
597
  &builtin_type_unsigned_char,
598
  &builtin_type_unsigned_short,
599
  &builtin_type_unsigned_int,
600
  &builtin_type_unsigned_long,
601
  &builtin_type_unsigned_long_long,
602
  &builtin_type_long_double,
603
  &builtin_type_complex,
604
  &builtin_type_double_complex,
605
  &builtin_type_bool,
606
 
607
};
608
 
609
const struct language_defn cplus_language_defn =
610
{
611
  "c++",                        /* Language name */
612
  language_cplus,
613
  cplus_builtin_types,
614
  range_check_off,
615
  type_check_off,
616
  case_sensitive_on,
617
  c_preprocess_and_parse,
618
  c_error,
619
  evaluate_subexp_standard,
620
  c_printchar,                  /* Print a character constant */
621
  c_printstr,                   /* Function to print string constant */
622
  c_emit_char,                  /* Print a single char */
623
  c_create_fundamental_type,    /* Create fundamental type in this language */
624
  c_print_type,                 /* Print a type using appropriate syntax */
625
  c_val_print,                  /* Print a value using appropriate syntax */
626
  c_value_print,                /* Print a top-level value */
627
  {"", "", "", ""},             /* Binary format info */
628
  {"0%lo", "0", "o", ""},        /* Octal format info */
629
  {"%ld", "", "d", ""},         /* Decimal format info */
630
  {"0x%lx", "0x", "x", ""},     /* Hex format info */
631
  c_op_print_tab,               /* expression operators for printing */
632
  1,                            /* c-style arrays */
633
  0,                             /* String lower bound */
634
  &builtin_type_char,           /* Type of string elements */
635
  LANG_MAGIC
636
};
637
 
638
const struct language_defn asm_language_defn =
639
{
640
  "asm",                        /* Language name */
641
  language_asm,
642
  c_builtin_types,
643
  range_check_off,
644
  type_check_off,
645
  case_sensitive_on,
646
  c_preprocess_and_parse,
647
  c_error,
648
  evaluate_subexp_standard,
649
  c_printchar,                  /* Print a character constant */
650
  c_printstr,                   /* Function to print string constant */
651
  c_emit_char,                  /* Print a single char */
652
  c_create_fundamental_type,    /* Create fundamental type in this language */
653
  c_print_type,                 /* Print a type using appropriate syntax */
654
  c_val_print,                  /* Print a value using appropriate syntax */
655
  c_value_print,                /* Print a top-level value */
656
  {"", "", "", ""},             /* Binary format info */
657
  {"0%lo", "0", "o", ""},        /* Octal format info */
658
  {"%ld", "", "d", ""},         /* Decimal format info */
659
  {"0x%lx", "0x", "x", ""},     /* Hex format info */
660
  c_op_print_tab,               /* expression operators for printing */
661
  1,                            /* c-style arrays */
662
  0,                             /* String lower bound */
663
  &builtin_type_char,           /* Type of string elements */
664
  LANG_MAGIC
665
};
666
 
667
void
668
_initialize_c_language (void)
669
{
670
  add_language (&c_language_defn);
671
  add_language (&cplus_language_defn);
672
  add_language (&asm_language_defn);
673
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.