1999-04-16 01:35:26 +00:00
|
|
|
|
/* Modula 2 language support routines for GDB, the GNU debugger.
|
2005-01-29 00:11:12 +00:00
|
|
|
|
|
2007-01-09 17:59:20 +00:00
|
|
|
|
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 2000, 2002, 2003, 2004,
|
|
|
|
|
2005, 2007 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
|
2005-12-17 22:34:03 +00:00
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
Boston, MA 02110-1301, 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_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
|
2005-05-09 Andrew Cagney <cagney@gnu.org>
Use gdb_byte in preference to bfd_byte.
* gdbarch.sh: Update.
* gdbarch.h, gdbarch.c: Re-generate.
* ada-lang.c, ada-lang.h, ada-valprint.c, arch-utils.c: Update.
* c-lang.c, c-lang.h, c-valprint.c, cp-valprint.c: Update.
* f-lang.c, f-lang.h, f-valprint.c, gdbcore.h, jv-lang.h: Update.
* jv-valprint.c, language.c, language.h, m2-lang.c: Update.
* m2-lang.h, m2-valprint.c, objc-lang.c, p-lang.c: Update.
* p-lang.h, p-valprint.c, regcache.c, scm-lang.c: Update.
* scm-lang.h, scm-valprint.c, target.c, target.h: Update.
* tramp-frame.c, valarith.c, valops.c, valprint.c: Update.
* valprint.h, value.c, value.h: Update.
2005-05-09 21:20:35 +00:00
|
|
|
|
m2_printstr (struct ui_file *stream, const gdb_byte *string,
|
2005-01-29 00:11:12 +00:00
|
|
|
|
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);
|
2005-02-10 Andrew Cagney <cagney@gnu.org>
Mark up all error and warning messages.
* ada-lang.c, amd64-tdep.c, arch-utils.c, breakpoint.c: Update.
* bsd-kvm.c, bsd-uthread.c, coff-solib.h, coffread.c: Update.
* core-aout.c, core-regset.c, corefile.c, corelow.c: Update.
* cp-abi.c, cp-support.c, cp-valprint.c, cris-tdep.c: Update.
* dbxread.c, demangle.c, doublest.c, dsrec.c: Update.
* dve3900-rom.c, dwarf2expr.c, dwarf2loc.c: Update.
* dwarf2read.c, dwarfread.c, elfread.c, eval.c: Update.
* event-top.c, exec.c, expprint.c, f-lang.c: Update.
* f-typeprint.c, f-valprint.c, fbsd-nat.c, findvar.c: Update.
* frame.c, frv-linux-tdep.c, gcore.c, gdbtypes.c: Update.
* gnu-nat.c, gnu-v2-abi.c, gnu-v3-abi.c, go32-nat.c: Update.
* hpacc-abi.c, hppa-hpux-nat.c, hppa-hpux-tdep.c: Update.
* hppa-linux-nat.c, hppa-linux-tdep.c, hppa-tdep.c: Update.
* hpread.c, hpux-thread.c, i386-linux-nat.c: Update.
* i386-linux-tdep.c, i386-tdep.c, i386bsd-nat.c: Update.
* i386gnu-nat.c, i387-tdep.c, ia64-linux-nat.c: Update.
* ia64-tdep.c, inf-child.c, inf-ptrace.c, inf-ttrace.c: Update.
* infcall.c, infcmd.c, inflow.c, infptrace.c, infrun.c: Update.
* inftarg.c, interps.c, irix5-nat.c, jv-lang.c: Update.
* kod-cisco.c, kod.c, language.c, libunwind-frame.c: Update.
* linespec.c, linux-nat.c, linux-thread-db.c, m2-lang.c: Update.
* m32r-rom.c, m68hc11-tdep.c, m68k-tdep.c: Update.
* m68klinux-nat.c, macrocmd.c, macroexp.c, main.c: Update.
* maint.c, mdebugread.c, mem-break.c, memattr.c: Update.
* mips-linux-tdep.c, mips-tdep.c, mipsread.c, monitor.c: Update.
* nlmread.c, nto-procfs.c, objc-lang.c, objfiles.c: Update.
* observer.c, ocd.c, p-lang.c, p-typeprint.c: Update.
* p-valprint.c, pa64solib.c, parse.c, ppc-linux-tdep.c: Update.
* ppcnbsd-tdep.c, printcmd.c, procfs.c, remote-e7000.c: Update.
* remote-fileio.c, remote-m32r-sdi.c, remote-rdi.c: Update.
* remote-rdp.c, remote-sim.c, remote-st.c: Update.
* remote-utils.c, remote-utils.h, remote.c: Update.
* rom68k-rom.c, rs6000-nat.c, s390-tdep.c, scm-lang.c: Update.
* ser-e7kpc.c, ser-tcp.c, ser-unix.c, sh-tdep.c: Update.
* sh3-rom.c, shnbsd-tdep.c, sol-thread.c, solib-aix5.c: Update.
* solib-frv.c, solib-irix.c, solib-osf.c, solib-pa64.c: Update.
* solib-som.c, solib-sunos.c, solib-svr4.c, solib.c: Update.
* somread.c, somsolib.c, source.c, stabsread.c: Update.
* stack.c, std-regs.c, symfile-mem.c, symfile.c: Update.
* symmisc.c, symtab.c, target.c, thread.c, top.c: Update.
* tracepoint.c, trad-frame.c, typeprint.c, utils.c: Update.
* uw-thread.c, valarith.c, valops.c, valprint.c: Update.
* value.c, varobj.c, version.in, win32-nat.c, wince.c: Update.
* xcoffread.c, xcoffsolib.c, cli/cli-cmds.c: Update.
* cli/cli-decode.c, cli/cli-dump.c, cli/cli-logging.c: Update.
* cli/cli-script.c, cli/cli-setshow.c, mi/mi-cmd-break.c: Update.
* mi/mi-cmd-disas.c, mi/mi-cmd-env.c, mi/mi-cmd-file.c: Update.
* mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-getopt.c: Update.
* mi/mi-symbol-cmds.c, tui/tui-layout.c, tui/tui-stack.c: Update.
* tui/tui-win.c: Update.
2005-02-11 04:06:14 +00:00
|
|
|
|
warning (_("internal error: no Modula fundamental type %d"), typeid);
|
1999-07-07 20:19:36 +00:00
|
|
|
|
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,
|
2004-08-29 10:12:24 +00:00
|
|
|
|
array_row_major,
|
* 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 */
|
2004-04-10 22:10:01 +00:00
|
|
|
|
null_post_parser,
|
1999-04-16 01:35:26 +00:00
|
|
|
|
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 */
|
2004-01-23 23:03:31 +00:00
|
|
|
|
basic_lookup_transparent_type,/* lookup_transparent_type */
|
2003-04-02 03:02:46 +00:00
|
|
|
|
NULL, /* Language specific symbol demangler */
|
2004-07-06 19:29:31 +00:00
|
|
|
|
NULL, /* Language specific class_name_from_physname */
|
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,
|
2004-07-28 02:46:24 +00:00
|
|
|
|
NULL, /* FIXME: la_language_arch_info. */
|
2005-10-03 21:21:20 +00:00
|
|
|
|
default_print_array_index,
|
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);
|
|
|
|
|
}
|