aboutsummaryrefslogtreecommitdiff
path: root/gdb/c-exp.y
diff options
context:
space:
mode:
authorThiago Jung Bauermann <bauerman@br.ibm.com>2007-10-25 18:01:58 +0000
committerThiago Jung Bauermann <bauerman@br.ibm.com>2007-10-25 18:01:58 +0000
commit27bc4d809ea2b4a3e4833806494db3a2fee83c64 (patch)
tree828f8e1b2e3e055419d3ce36e1d1cb41742d0a5a /gdb/c-exp.y
parent7678ef8fb055dd4853c7c6b25f739a8d74650899 (diff)
downloadgdb-27bc4d809ea2b4a3e4833806494db3a2fee83c64.zip
gdb-27bc4d809ea2b4a3e4833806494db3a2fee83c64.tar.gz
gdb-27bc4d809ea2b4a3e4833806494db3a2fee83c64.tar.bz2
2007-10-25 Wu Zhou <woodzltc@cn.ibm.com>
Thiago Jung Bauermann <bauerman@br.ibm.com> * 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.
Diffstat (limited to 'gdb/c-exp.y')
-rw-r--r--gdb/c-exp.y47
1 files changed, 47 insertions, 0 deletions
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 6318955..40dbc93 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -52,6 +52,7 @@ Boston, MA 02110-1301, USA. */
#include "charset.h"
#include "block.h"
#include "cp-support.h"
+#include "dfp.h"
/* Remap normal yacc parser interface names (yyparse, yylex, yyerror, etc),
as well as gratuitiously global symbol names, so we can have multiple
@@ -130,6 +131,10 @@ void yyerror (char *);
DOUBLEST dval;
struct type *type;
} typed_val_float;
+ struct {
+ gdb_byte val[16];
+ struct type *type;
+ } typed_val_decfloat;
struct symbol *sym;
struct type *tval;
struct stoken sval;
@@ -162,6 +167,7 @@ static int parse_number (char *, int, int, YYSTYPE *);
%token <typed_val_int> INT
%token <typed_val_float> FLOAT
+%token <typed_val_decfloat> DECFLOAT
/* Both NAME and TYPENAME tokens represent symbols in the input,
and both convey their data as strings.
@@ -496,6 +502,13 @@ exp : FLOAT
write_exp_elt_opcode (OP_DOUBLE); }
;
+exp : DECFLOAT
+ { write_exp_elt_opcode (OP_DECFLOAT);
+ write_exp_elt_type ($1.type);
+ write_exp_elt_decfloatcst ($1.val);
+ write_exp_elt_opcode (OP_DECFLOAT); }
+ ;
+
exp : variable
;
@@ -1077,6 +1090,40 @@ parse_number (p, len, parsed_float, putithere)
char saved_char = p[len];
p[len] = 0; /* null-terminate the token */
+
+ /* If it ends at "df", "dd" or "dl", take it as type of decimal floating
+ point. Return DECFLOAT. */
+
+ if (p[len - 2] == 'd' && p[len - 1] == 'f')
+ {
+ p[len - 2] = '\0';
+ putithere->typed_val_decfloat.type
+ = builtin_type (current_gdbarch)->builtin_decfloat;
+ decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+ p[len] = saved_char;
+ return (DECFLOAT);
+ }
+
+ if (p[len - 2] == 'd' && p[len - 1] == 'd')
+ {
+ p[len - 2] = '\0';
+ putithere->typed_val_decfloat.type
+ = builtin_type (current_gdbarch)->builtin_decdouble;
+ decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+ p[len] = saved_char;
+ return (DECFLOAT);
+ }
+
+ if (p[len - 2] == 'd' && p[len - 1] == 'l')
+ {
+ p[len - 2] = '\0';
+ putithere->typed_val_decfloat.type
+ = builtin_type (current_gdbarch)->builtin_declong;
+ decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+ p[len] = saved_char;
+ return (DECFLOAT);
+ }
+
num = sscanf (p, DOUBLEST_SCAN_FORMAT "%s",
&putithere->typed_val_float.dval, s);
p[len] = saved_char; /* restore the input stream */