1999-04-16 01:35:26 +00:00
|
|
|
|
/* Modula 2 language support routines for GDB, the GNU debugger.
|
2002-02-13 18:49:30 +00:00
|
|
|
|
Copyright 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2002
|
2001-03-06 08:22:02 +00:00
|
|
|
|
Free Software Foundation, Inc.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This file is part of GDB.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
(at your option) any later version.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
|
Boston, MA 02111-1307, USA. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
#include "symtab.h"
|
|
|
|
|
#include "gdbtypes.h"
|
|
|
|
|
#include "expression.h"
|
|
|
|
|
#include "parser-defs.h"
|
|
|
|
|
#include "language.h"
|
|
|
|
|
#include "m2-lang.h"
|
|
|
|
|
#include "c-lang.h"
|
2000-02-08 04:39:02 +00:00
|
|
|
|
#include "valprint.h"
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
2000-05-28 01:12:42 +00:00
|
|
|
|
extern void _initialize_m2_language (void);
|
|
|
|
|
static struct type *m2_create_fundamental_type (struct objfile *, int);
|
2000-02-02 00:21:19 +00:00
|
|
|
|
static void m2_printstr (struct ui_file * stream, char *string,
|
|
|
|
|
unsigned int length, int width,
|
|
|
|
|
int force_ellipses);
|
|
|
|
|
static void m2_printchar (int, struct ui_file *);
|
|
|
|
|
static void m2_emit_char (int, struct ui_file *, int);
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
/* Print the character C on STREAM as part of the contents of a literal
|
|
|
|
|
string whose delimiter is QUOTER. Note that that format for printing
|
|
|
|
|
characters and strings is language specific.
|
|
|
|
|
FIXME: This is a copy of the same function from c-exp.y. It should
|
|
|
|
|
be replaced with a true Modula version.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static void
|
2003-09-09 08:05:43 +00:00
|
|
|
|
m2_emit_char (int c, struct ui_file *stream, int quoter)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
c &= 0xFF; /* Avoid sign bit follies */
|
|
|
|
|
|
|
|
|
|
if (PRINT_LITERAL_FORM (c))
|
|
|
|
|
{
|
|
|
|
|
if (c == '\\' || c == quoter)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered ("\\", stream);
|
|
|
|
|
}
|
|
|
|
|
fprintf_filtered (stream, "%c", c);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
switch (c)
|
|
|
|
|
{
|
|
|
|
|
case '\n':
|
|
|
|
|
fputs_filtered ("\\n", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\b':
|
|
|
|
|
fputs_filtered ("\\b", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\t':
|
|
|
|
|
fputs_filtered ("\\t", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\f':
|
|
|
|
|
fputs_filtered ("\\f", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\r':
|
|
|
|
|
fputs_filtered ("\\r", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\033':
|
|
|
|
|
fputs_filtered ("\\e", stream);
|
|
|
|
|
break;
|
|
|
|
|
case '\007':
|
|
|
|
|
fputs_filtered ("\\a", stream);
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: This is a copy of the same function from c-exp.y. It should
|
|
|
|
|
be replaced with a true Modula version. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
m2_printchar (int c, struct ui_file *stream)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
fputs_filtered ("'", stream);
|
|
|
|
|
LA_EMIT_CHAR (c, stream, '\'');
|
|
|
|
|
fputs_filtered ("'", stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Print the character string STRING, printing at most LENGTH characters.
|
|
|
|
|
Printing stops early if the number hits print_max; repeat counts
|
|
|
|
|
are printed as appropriate. Print ellipses at the end if we
|
|
|
|
|
had to stop before printing LENGTH characters, or if FORCE_ELLIPSES.
|
|
|
|
|
FIXME: This is a copy of the same function from c-exp.y. It should
|
|
|
|
|
be replaced with a true Modula version. */
|
|
|
|
|
|
|
|
|
|
static void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
m2_printstr (struct ui_file *stream, char *string, unsigned int length,
|
|
|
|
|
int width, int force_ellipses)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
|
unsigned int i;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
unsigned int things_printed = 0;
|
|
|
|
|
int in_quotes = 0;
|
|
|
|
|
int need_comma = 0;
|
|
|
|
|
|
|
|
|
|
if (length == 0)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered ("\"\"", gdb_stdout);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < length && things_printed < print_max; ++i)
|
|
|
|
|
{
|
|
|
|
|
/* Position of the character we are examining
|
1999-07-07 20:19:36 +00:00
|
|
|
|
to see whether it is repeated. */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
unsigned int rep1;
|
|
|
|
|
/* Number of repetitions we have detected so far. */
|
|
|
|
|
unsigned int reps;
|
|
|
|
|
|
|
|
|
|
QUIT;
|
|
|
|
|
|
|
|
|
|
if (need_comma)
|
|
|
|
|
{
|
|
|
|
|
fputs_filtered (", ", stream);
|
|
|
|
|
need_comma = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
rep1 = i + 1;
|
|
|
|
|
reps = 1;
|
|
|
|
|
while (rep1 < length && string[rep1] == string[i])
|
|
|
|
|
{
|
|
|
|
|
++rep1;
|
|
|
|
|
++reps;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (reps > repeat_count_threshold)
|
|
|
|
|
{
|
|
|
|
|
if (in_quotes)
|
|
|
|
|
{
|
|
|
|
|
if (inspect_it)
|
|
|
|
|
fputs_filtered ("\\\", ", stream);
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("\", ", stream);
|
|
|
|
|
in_quotes = 0;
|
|
|
|
|
}
|
|
|
|
|
m2_printchar (string[i], stream);
|
|
|
|
|
fprintf_filtered (stream, " <repeats %u times>", reps);
|
|
|
|
|
i = rep1 - 1;
|
|
|
|
|
things_printed += repeat_count_threshold;
|
|
|
|
|
need_comma = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!in_quotes)
|
|
|
|
|
{
|
|
|
|
|
if (inspect_it)
|
|
|
|
|
fputs_filtered ("\\\"", stream);
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("\"", stream);
|
|
|
|
|
in_quotes = 1;
|
|
|
|
|
}
|
|
|
|
|
LA_EMIT_CHAR (string[i], stream, '"');
|
|
|
|
|
++things_printed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Terminate the quotes if necessary. */
|
|
|
|
|
if (in_quotes)
|
|
|
|
|
{
|
|
|
|
|
if (inspect_it)
|
|
|
|
|
fputs_filtered ("\\\"", stream);
|
|
|
|
|
else
|
|
|
|
|
fputs_filtered ("\"", stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (force_ellipses || i < length)
|
|
|
|
|
fputs_filtered ("...", stream);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: This is a copy of c_create_fundamental_type(), before
|
|
|
|
|
all the non-C types were stripped from it. Needs to be fixed
|
|
|
|
|
by an experienced Modula programmer. */
|
|
|
|
|
|
|
|
|
|
static struct type *
|
2000-07-30 01:48:28 +00:00
|
|
|
|
m2_create_fundamental_type (struct objfile *objfile, int typeid)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
2003-09-09 08:05:43 +00:00
|
|
|
|
struct type *type = NULL;
|
1999-04-16 01:35:26 +00:00
|
|
|
|
|
|
|
|
|
switch (typeid)
|
|
|
|
|
{
|
1999-07-07 20:19:36 +00:00
|
|
|
|
default:
|
|
|
|
|
/* FIXME: For now, if we are asked to produce a type not in this
|
|
|
|
|
language, create the equivalent of a C integer type with the
|
|
|
|
|
name "<?type?>". When all the dust settles from the type
|
|
|
|
|
reconstruction work, this should probably become an error. */
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "<?type?>", objfile);
|
|
|
|
|
warning ("internal error: no Modula fundamental type %d", typeid);
|
|
|
|
|
break;
|
|
|
|
|
case FT_VOID:
|
|
|
|
|
type = init_type (TYPE_CODE_VOID,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "void", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_BOOLEAN:
|
|
|
|
|
type = init_type (TYPE_CODE_BOOL,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "boolean", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_STRING:
|
|
|
|
|
type = init_type (TYPE_CODE_STRING,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "string", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_CHAR:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "char", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SIGNED_CHAR:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "signed char", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_UNSIGNED_CHAR:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned char", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SHORT:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "short", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SIGNED_SHORT:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "short", objfile); /* FIXME-fnf */
|
|
|
|
|
break;
|
|
|
|
|
case FT_UNSIGNED_SHORT:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned short", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_INTEGER:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "int", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SIGNED_INTEGER:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "int", objfile); /* FIXME -fnf */
|
|
|
|
|
break;
|
|
|
|
|
case FT_UNSIGNED_INTEGER:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned int", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_FIXED_DECIMAL:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "fixed decimal", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "long", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SIGNED_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "long", objfile); /* FIXME -fnf */
|
|
|
|
|
break;
|
|
|
|
|
case FT_UNSIGNED_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned long", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_LONG_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "long long", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_SIGNED_LONG_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "signed long long", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_UNSIGNED_LONG_LONG:
|
|
|
|
|
type = init_type (TYPE_CODE_INT,
|
|
|
|
|
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED, "unsigned long long", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_FLOAT:
|
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
|
TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "float", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_DBL_PREC_FLOAT:
|
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
|
TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "double", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_FLOAT_DECIMAL:
|
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
|
TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "floating decimal", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_EXT_PREC_FLOAT:
|
|
|
|
|
type = init_type (TYPE_CODE_FLT,
|
|
|
|
|
TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "long double", objfile);
|
|
|
|
|
break;
|
|
|
|
|
case FT_COMPLEX:
|
|
|
|
|
type = init_type (TYPE_CODE_COMPLEX,
|
|
|
|
|
2 * TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "complex", objfile);
|
|
|
|
|
TYPE_TARGET_TYPE (type)
|
|
|
|
|
= m2_create_fundamental_type (objfile, FT_FLOAT);
|
|
|
|
|
break;
|
|
|
|
|
case FT_DBL_PREC_COMPLEX:
|
|
|
|
|
type = init_type (TYPE_CODE_COMPLEX,
|
|
|
|
|
2 * TARGET_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "double complex", objfile);
|
|
|
|
|
TYPE_TARGET_TYPE (type)
|
|
|
|
|
= m2_create_fundamental_type (objfile, FT_DBL_PREC_FLOAT);
|
|
|
|
|
break;
|
|
|
|
|
case FT_EXT_PREC_COMPLEX:
|
|
|
|
|
type = init_type (TYPE_CODE_COMPLEX,
|
|
|
|
|
2 * TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0, "long double complex", objfile);
|
|
|
|
|
TYPE_TARGET_TYPE (type)
|
|
|
|
|
= m2_create_fundamental_type (objfile, FT_EXT_PREC_FLOAT);
|
|
|
|
|
break;
|
|
|
|
|
}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
return (type);
|
|
|
|
|
}
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
|
1999-04-16 01:35:26 +00:00
|
|
|
|
/* Table of operators and their precedences for printing expressions. */
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
static const struct op_print m2_op_print_tab[] =
|
|
|
|
|
{
|
|
|
|
|
{"+", BINOP_ADD, PREC_ADD, 0},
|
|
|
|
|
{"+", UNOP_PLUS, PREC_PREFIX, 0},
|
|
|
|
|
{"-", BINOP_SUB, PREC_ADD, 0},
|
|
|
|
|
{"-", UNOP_NEG, PREC_PREFIX, 0},
|
|
|
|
|
{"*", BINOP_MUL, PREC_MUL, 0},
|
|
|
|
|
{"/", BINOP_DIV, PREC_MUL, 0},
|
|
|
|
|
{"DIV", BINOP_INTDIV, PREC_MUL, 0},
|
|
|
|
|
{"MOD", BINOP_REM, PREC_MUL, 0},
|
|
|
|
|
{":=", BINOP_ASSIGN, PREC_ASSIGN, 1},
|
|
|
|
|
{"OR", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
|
|
|
|
|
{"AND", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
|
|
|
|
|
{"NOT", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
|
|
|
|
|
{"=", BINOP_EQUAL, PREC_EQUAL, 0},
|
|
|
|
|
{"<>", BINOP_NOTEQUAL, PREC_EQUAL, 0},
|
|
|
|
|
{"<=", BINOP_LEQ, PREC_ORDER, 0},
|
|
|
|
|
{">=", BINOP_GEQ, PREC_ORDER, 0},
|
|
|
|
|
{">", BINOP_GTR, PREC_ORDER, 0},
|
|
|
|
|
{"<", BINOP_LESS, PREC_ORDER, 0},
|
|
|
|
|
{"^", UNOP_IND, PREC_PREFIX, 0},
|
|
|
|
|
{"@", BINOP_REPEAT, PREC_REPEAT, 0},
|
|
|
|
|
{"CAP", UNOP_CAP, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"CHR", UNOP_CHR, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"ORD", UNOP_ORD, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"FLOAT", UNOP_FLOAT, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"HIGH", UNOP_HIGH, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"MAX", UNOP_MAX, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"MIN", UNOP_MIN, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"ODD", UNOP_ODD, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{"TRUNC", UNOP_TRUNC, PREC_BUILTIN_FUNCTION, 0},
|
|
|
|
|
{NULL, 0, 0, 0}
|
1999-04-16 01:35:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* The built-in types of Modula-2. */
|
|
|
|
|
|
|
|
|
|
struct type *builtin_type_m2_char;
|
|
|
|
|
struct type *builtin_type_m2_int;
|
|
|
|
|
struct type *builtin_type_m2_card;
|
|
|
|
|
struct type *builtin_type_m2_real;
|
|
|
|
|
struct type *builtin_type_m2_bool;
|
|
|
|
|
|
2002-02-13 18:49:30 +00:00
|
|
|
|
struct type **const (m2_builtin_types[]) =
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
&builtin_type_m2_char,
|
1999-07-07 20:19:36 +00:00
|
|
|
|
&builtin_type_m2_int,
|
|
|
|
|
&builtin_type_m2_card,
|
|
|
|
|
&builtin_type_m2_real,
|
|
|
|
|
&builtin_type_m2_bool,
|
|
|
|
|
0
|
1999-04-16 01:35:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
1999-07-07 20:19:36 +00:00
|
|
|
|
const struct language_defn m2_language_defn =
|
|
|
|
|
{
|
1999-04-16 01:35:26 +00:00
|
|
|
|
"modula-2",
|
|
|
|
|
language_m2,
|
|
|
|
|
m2_builtin_types,
|
|
|
|
|
range_check_on,
|
|
|
|
|
type_check_on,
|
2000-08-10 Jimmy Guo <guo@cup.hp.com>
* c-lang.c: Set case sensitivity on for c_language_defn,
cplus_language_defn, and asm_language_defn.
* ch-lang.c: Set case sensitivity on for chill_language_defn.
* f-lang.c: Set case sensivitity off for f_language_defn.
* jv-lang.c: Set case sensitivity on for java_language_defn.
* language.h: Add enum case_mode, case_sensitivity.
* language.c: Define case_mode, case_sensitivity. Set case
sensitivity on for unknown_language_defn, auto_language_defn,
and local_language_defn.
(show_case_command,set_case_command,set_case_str): New static func.
(set_type_range_case): New static func, replaces set_type_range ().
(set_language_command,set_type_command,set_range_command,set_language):
Call set_type_range_case ().
(language_info): Print case sensitivity setting.
(_initialize_language): Add set/show commands for 'case-sensitive'.
Set default case mode 'auto'. Set default language 'auto'.
* m2-lang.c: Set case sensitivity on for m2_language_defn.
* p-lang.c: Set case sensitivity on for pascal_language_defn.
* scm-lang.c: Set case sensitivity off for scm_language_defn.
* symtab.c (lookup_symbol): Downcase symbol name if case sensivitity
is off.
2000-08-11 01:02:35 +00:00
|
|
|
|
case_sensitive_on,
|
* parser-defs.h (struct exp_descriptor): New definition, containing
language-specific info for printing, prefixifying, dumping, and
evaluating expressions.
(exp_descriptor_standard): Declare new variable.
(print_subexp): Make global and declare here (from expprint.c).
(dump_subexp): Ditto.
(dump_subexp_body_standard): Declare.
(operator_length_standard): Declare.
(op_name_standard): Declare.
(print_subexp): Declare.
(print_subexp_standard): Declare.
* language.h (struct language_defn): Add la_exp_desc field to hold
pointer to table for language-specific operators.
Remove evaluate_exp field, which is now in struct exp_descriptor.
* parse.c (operator_length): Move most code to new
operator_length_standard function. Use language-specific information.
(operator_length_standard): New function taking most code from
operator_length.
(exp_descriptor_standard): New constant.
* expression.h (enum exp_opcode): Add definitions of OP_EXTENDED0
and OP_EXTENDED_LAST.
* expprint.c (print_subexp): Use language-specific print_subexp.
Make global; remove static declaration.
Move most code to print_subexp_standard.
(print_subexp_standard): New function, containing code formerly in
print_subexp.
(op_name): Add expression to argument signature.
Use langauge-specific op_name.
Move most code to op_name_standard.
(op_name_standard): New function, containing code formerly in op_name.
(dump_subexp): Use new version of op_name function.
Use language-specific dump_subexp_body, and move most existing code to
dump_subexp_body_standard.
(dump_raw_expression): Use new op_name interface.
(dump_subexp_body): Move most code to dump_subexp_body_standard.
(dump_subexp_body_standard): New function, containing code formerly
in dump_subexp_body.
* language.c (unknown_language): Add default la_exp_desc field and
remove evaluate_exp field.
(auto_language): Ditto.
(local_language): Ditto.
* f-lang.c (f_language_defn): Ditto.
* c-lang.c (c_language_defn): Ditto.
(cplus_language_defn): Ditto.
(asm_language_defn): Ditto.
(minimal_language_defn): Ditto.
* p-lang.c (pascal_language_defn): Ditto.
* m2-lang.c (m2_language_defn): Ditto.
* objc-lang.c (objc_language_defn): Ditto.
* jv-lang.c (exp_descriptor_java): New variable, containing
Java-specific expression evaluator.
(java_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* scm-lang.c (exp_descriptor_scm): New variable, containing
Scheme-specific expression evaluator.
(scm_language_defn): Add la_exp_desc field and remove evaluate_exp
field.
* objc-lang.c (print_object_command): Take evaluate_exp from the
la_exp_desc field.
* Makefile.in (eval.o): Add dependency on parser-defs.h.
* eval.c: Include parser-defs.h for the full declaration of
la_exp_desc's type.
(evaluate_subexp): Get evaluate_exp out of la_exp_desc field.
2003-09-25 08:40:45 +00:00
|
|
|
|
&exp_descriptor_standard,
|
1999-04-16 01:35:26 +00:00
|
|
|
|
m2_parse, /* parser */
|
|
|
|
|
m2_error, /* parser error function */
|
|
|
|
|
m2_printchar, /* Print character constant */
|
|
|
|
|
m2_printstr, /* function to print string constant */
|
|
|
|
|
m2_emit_char, /* Function to print a single character */
|
|
|
|
|
m2_create_fundamental_type, /* Create fundamental type in this language */
|
|
|
|
|
m2_print_type, /* Print a type using appropriate syntax */
|
|
|
|
|
m2_val_print, /* Print a value using appropriate syntax */
|
|
|
|
|
c_value_print, /* Print a top-level value */
|
2003-03-26 03:39:44 +00:00
|
|
|
|
NULL, /* Language specific skip_trampoline */
|
2003-05-20 01:55:18 +00:00
|
|
|
|
value_of_this, /* value_of_this */
|
|
|
|
|
basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
|
2003-04-02 03:02:46 +00:00
|
|
|
|
NULL, /* Language specific symbol demangler */
|
1999-07-07 20:19:36 +00:00
|
|
|
|
{"", "", "", ""}, /* Binary format info */
|
|
|
|
|
{"%loB", "", "o", "B"}, /* Octal format info */
|
|
|
|
|
{"%ld", "", "d", ""}, /* Decimal format info */
|
|
|
|
|
{"0%lXH", "0", "X", "H"}, /* Hex format info */
|
1999-04-16 01:35:26 +00:00
|
|
|
|
m2_op_print_tab, /* expression operators for printing */
|
|
|
|
|
0, /* arrays are first-class (not c-style) */
|
|
|
|
|
0, /* String lower bound */
|
1999-07-07 20:19:36 +00:00
|
|
|
|
&builtin_type_m2_char, /* Type of string elements */
|
2003-10-06 22:38:03 +00:00
|
|
|
|
default_word_break_characters,
|
1999-04-16 01:35:26 +00:00
|
|
|
|
LANG_MAGIC
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* Initialization for Modula-2 */
|
|
|
|
|
|
|
|
|
|
void
|
2000-07-30 01:48:28 +00:00
|
|
|
|
_initialize_m2_language (void)
|
1999-04-16 01:35:26 +00:00
|
|
|
|
{
|
|
|
|
|
/* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
|
|
|
|
|
builtin_type_m2_int =
|
|
|
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0,
|
|
|
|
|
"INTEGER", (struct objfile *) NULL);
|
|
|
|
|
builtin_type_m2_card =
|
|
|
|
|
init_type (TYPE_CODE_INT, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED,
|
|
|
|
|
"CARDINAL", (struct objfile *) NULL);
|
|
|
|
|
builtin_type_m2_real =
|
|
|
|
|
init_type (TYPE_CODE_FLT, TARGET_FLOAT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
0,
|
|
|
|
|
"REAL", (struct objfile *) NULL);
|
|
|
|
|
builtin_type_m2_char =
|
|
|
|
|
init_type (TYPE_CODE_CHAR, TARGET_CHAR_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED,
|
|
|
|
|
"CHAR", (struct objfile *) NULL);
|
|
|
|
|
builtin_type_m2_bool =
|
|
|
|
|
init_type (TYPE_CODE_BOOL, TARGET_INT_BIT / TARGET_CHAR_BIT,
|
|
|
|
|
TYPE_FLAG_UNSIGNED,
|
|
|
|
|
"BOOLEAN", (struct objfile *) NULL);
|
|
|
|
|
|
|
|
|
|
add_language (&m2_language_defn);
|
|
|
|
|
}
|