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., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "defs.h"
#include "symtab.h"
#include "parser-defs.h"
#include "language.h"
#include "m2-lang.h"
+#include "c-lang.h"
+
+static struct type *m2_create_fundamental_type PARAMS ((struct objfile *, int));
+static void m2_printstr PARAMS ((GDB_FILE *, char *, unsigned int, int));
+static void m2_printchar PARAMS ((int, GDB_FILE *));
+static void emit_char PARAMS ((int, GDB_FILE *, int));
/* 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
static void
emit_char (c, stream, quoter)
register int c;
- FILE *stream;
+ GDB_FILE *stream;
int quoter;
{
static void
m2_printchar (c, stream)
int c;
- FILE *stream;
+ GDB_FILE *stream;
{
fputs_filtered ("'", stream);
emit_char (c, stream, '\'');
static void
m2_printstr (stream, string, length, force_ellipses)
- FILE *stream;
+ GDB_FILE *stream;
char *string;
unsigned int length;
int force_ellipses;
if (length == 0)
{
- fputs_filtered ("\"\"", stdout);
+ fputs_filtered ("\"\"", gdb_stdout);
return;
}
int typeid;
{
register struct type *type = NULL;
- register int nbytes;
switch (typeid)
{
TYPE_FLAG_UNSIGNED, "boolean", objfile);
break;
case FT_STRING:
- type = init_type (TYPE_CODE_PASCAL_ARRAY,
+ type = init_type (TYPE_CODE_STRING,
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
0, "string", objfile);
break;
case FT_SIGNED_CHAR:
type = init_type (TYPE_CODE_INT,
TARGET_CHAR_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_SIGNED, "signed char", objfile);
+ 0, "signed char", objfile);
break;
case FT_UNSIGNED_CHAR:
type = init_type (TYPE_CODE_INT,
case FT_SIGNED_SHORT:
type = init_type (TYPE_CODE_INT,
TARGET_SHORT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_SIGNED, "short", objfile); /* FIXME-fnf */
+ 0, "short", objfile); /* FIXME-fnf */
break;
case FT_UNSIGNED_SHORT:
type = init_type (TYPE_CODE_INT,
case FT_SIGNED_INTEGER:
type = init_type (TYPE_CODE_INT,
TARGET_INT_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_SIGNED, "int", objfile); /* FIXME -fnf */
+ 0, "int", objfile); /* FIXME -fnf */
break;
case FT_UNSIGNED_INTEGER:
type = init_type (TYPE_CODE_INT,
case FT_SIGNED_LONG:
type = init_type (TYPE_CODE_INT,
TARGET_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_SIGNED, "long", objfile); /* FIXME -fnf */
+ 0, "long", objfile); /* FIXME -fnf */
break;
case FT_UNSIGNED_LONG:
type = init_type (TYPE_CODE_INT,
case FT_SIGNED_LONG_LONG:
type = init_type (TYPE_CODE_INT,
TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT,
- TYPE_FLAG_SIGNED, "signed long long", objfile);
+ 0, "signed long long", objfile);
break;
case FT_UNSIGNED_LONG_LONG:
type = init_type (TYPE_CODE_INT,
0, "long double", objfile);
break;
case FT_COMPLEX:
- type = init_type (TYPE_CODE_FLT,
- TARGET_COMPLEX_BIT / TARGET_CHAR_BIT,
+ 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_FLT,
- TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
+ 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_FLT,
- TARGET_DOUBLE_COMPLEX_BIT / TARGET_CHAR_BIT,
+ 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;
}
return (type);
\f
/* Table of operators and their precedences for printing expressions. */
-const static struct op_print m2_op_print_tab[] = {
+static const struct op_print m2_op_print_tab[] = {
{"+", BINOP_ADD, PREC_ADD, 0},
{"+", UNOP_PLUS, PREC_PREFIX, 0},
{"-", BINOP_SUB, PREC_ADD, 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}
};
\f
struct type *builtin_type_m2_real;
struct type *builtin_type_m2_bool;
-struct type ** const (m2_builtin_types[]) =
+struct type ** CONST_PTR (m2_builtin_types[]) =
{
&builtin_type_m2_char,
&builtin_type_m2_int,
type_check_on,
m2_parse, /* parser */
m2_error, /* parser error function */
+ evaluate_subexp_standard,
m2_printchar, /* Print character constant */
m2_printstr, /* function to print string constant */
m2_create_fundamental_type, /* Create fundamental type in this language */
- &builtin_type_m2_int, /* longest signed integral type */
- &builtin_type_m2_card, /* longest unsigned integral type */
- &builtin_type_m2_real, /* longest floating point type */
+ 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 */
{"", "", "", ""}, /* Binary format info */
- {"%oB", "", "o", "B"}, /* Octal format info */
- {"%d", "", "d", ""}, /* Decimal format info */
- {"0%XH", "0", "X", "H"}, /* Hex format info */
+ {"%loB", "", "o", "B"}, /* Octal format info */
+ {"%ld", "", "d", ""}, /* Decimal format info */
+ {"0%lXH", "0", "X", "H"}, /* Hex format info */
m2_op_print_tab, /* expression operators for printing */
+ 0, /* arrays are first-class (not c-style) */
+ 0, /* String lower bound */
+ &builtin_type_m2_char, /* Type of string elements */
LANG_MAGIC
};
/* Initialization for Modula-2 */
void
-_initialize_m2_exp ()
+_initialize_m2_language ()
{
/* Modula-2 "pervasive" types. NOTE: these can be redefined!!! */
builtin_type_m2_int =
TYPE_FLAG_UNSIGNED,
"BOOLEAN", (struct objfile *) NULL);
- TYPE_NFIELDS(builtin_type_m2_bool) = 2;
- TYPE_FIELDS(builtin_type_m2_bool) =
- (struct field *) malloc (sizeof (struct field) * 2);
- TYPE_FIELD_BITPOS(builtin_type_m2_bool,0) = 0;
- TYPE_FIELD_NAME(builtin_type_m2_bool,0) = (char *)malloc(6);
- strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,0),"FALSE");
- TYPE_FIELD_BITPOS(builtin_type_m2_bool,1) = 1;
- TYPE_FIELD_NAME(builtin_type_m2_bool,1) = (char *)malloc(5);
- strcpy(TYPE_FIELD_NAME(builtin_type_m2_bool,1),"TRUE");
-
add_language (&m2_language_defn);
}