From 27bc4d809ea2b4a3e4833806494db3a2fee83c64 Mon Sep 17 00:00:00 2001 From: Thiago Jung Bauermann Date: Thu, 25 Oct 2007 18:01:58 +0000 Subject: 2007-10-25 Wu Zhou Thiago Jung Bauermann * c-exp.y (YYSTYPE): Add typed_val_decfloat for decimal floating point in YYSTYPE union. (DECFLOAT) Add token and expression element handling code. (parse_number): Parse DFP constants, which end with suffix 'df', 'dd' or 'dl'. Return DECFLOAT. * eval.c (evaluate_subexp_standard): Call value_from_decfloat to handle OP_DECFLOAT. * expression.h (enum exp_opcode): Add an opcode (OP_DECFLOAT) for DFP constants. (union exp_element): Add decfloatconst to represent DFP elements, which is 16 bytes by default. * parse.c (write_exp_elt_decfloatcst): New function to write a decimal float const into the expression. (operator_length_standard): Set operator length for OP_DECFLOAT to 4. * parser-defs.h (write_exp_elt_decfloatcst): Prototype. * valarith.c (value_neg): Add code to handle the negation operation of DFP values. * value.c (value_from_decfloat): New function to get the value from a decimal floating point. * value.h (value_from_decfloat): Prototype. --- gdb/value.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'gdb/value.c') diff --git a/gdb/value.c b/gdb/value.c index 7085ec1..89759b8 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -34,6 +34,7 @@ #include "gdb_assert.h" #include "regcache.h" #include "block.h" +#include "dfp.h" /* Prototypes for exported functions. */ @@ -1642,6 +1643,27 @@ value_from_double (struct type *type, DOUBLEST num) } struct value * +value_from_decfloat (struct type *expect_type, struct type *type, + gdb_byte decbytes[16]) +{ + struct value *val = allocate_value (type); + int len = TYPE_LENGTH (type); + + if (expect_type) + { + int expect_len = TYPE_LENGTH (expect_type); + char decstr[128]; + int real_len; + + decimal_to_string (decbytes, len, decstr); + decimal_from_string (decbytes, expect_len, decstr); + } + + memcpy (value_contents_raw (val), decbytes, len); + return val; +} + +struct value * coerce_ref (struct value *arg) { struct type *value_type_arg_tmp = check_typedef (value_type (arg)); -- cgit v1.1