aboutsummaryrefslogtreecommitdiff
path: root/gdb/ch-exp.y
diff options
context:
space:
mode:
authorPer Bothner <per@bothner.com>1995-06-14 19:59:35 +0000
committerPer Bothner <per@bothner.com>1995-06-14 19:59:35 +0000
commit6137983598c57aa8557001079b10fa3be8b77ef6 (patch)
treeffe6a013f33ab7bb0d0d01f7aa68f8c344107208 /gdb/ch-exp.y
parent69cb5925c9f6146f2ca098cc23e209f00683d61d (diff)
downloadgdb-6137983598c57aa8557001079b10fa3be8b77ef6.zip
gdb-6137983598c57aa8557001079b10fa3be8b77ef6.tar.gz
gdb-6137983598c57aa8557001079b10fa3be8b77ef6.tar.bz2
* parser-defs.h (enum precedence): Added PREC_BUILTIN_FUNCTION.
* expression.h (enum exp_opcode): Added UNOP_LOWER, UNOP_UPPER, UNUP_LENGTH. * expprint.c (dump_expression): Handle the new exp_opcodes. (print_subexp): Handle PREC_BUILTIN_FUNCTION. (print_simple_m2_func): Removed. (print_subexp): Remove support for Modula2 builtin functions. * m2-lang.c (m2_op_print_tab): Add support for builtin functions. * ch-exp.y: Parse LOWER, UPPER, and LENGTH builtins. (write_lower_upper_value): Convenience function for LOWER and UPPER. (upper_lower_argument, length_argument): Removed non-terminals. * ch-lang.c (chill_op_print_tab): Entries for UPPER, LOWER, LENGTH. (type_lower_upper): New function. Calculate LOWER/UPPER of type. (value_chill_length): New function. Calcalate LENGTH of ARRAY/STRING. (evaluate_subexp_chill): Handle UNOP_LOWER, UNOP_UPPER, UNOP_LENGTH. This fixes PR 5015 (and 5826 which is a duplicate).
Diffstat (limited to 'gdb/ch-exp.y')
-rw-r--r--gdb/ch-exp.y54
1 files changed, 24 insertions, 30 deletions
diff --git a/gdb/ch-exp.y b/gdb/ch-exp.y
index c1b132b..c450b5c 100644
--- a/gdb/ch-exp.y
+++ b/gdb/ch-exp.y
@@ -291,8 +291,6 @@ yyerror PARAMS ((char *));
%type <voidval> value_receive_name
%type <voidval> expression_list
%type <tval> mode_argument
-%type <voidval> upper_lower_argument
-%type <voidval> length_argument
%type <voidval> array_mode_name
%type <voidval> string_mode_name
%type <voidval> variant_structure_mode_name
@@ -940,18 +938,16 @@ chill_value_built_in_routine_call :
write_exp_elt_type (builtin_type_int);
write_exp_elt_longcst ((LONGEST) TYPE_LENGTH ($3));
write_exp_elt_opcode (OP_LONG); }
- | UPPER '(' upper_lower_argument ')'
- {
- $$ = 0; /* FIXME */
- }
- | LOWER '(' upper_lower_argument ')'
- {
- $$ = 0; /* FIXME */
- }
- | LENGTH '(' length_argument ')'
- {
- $$ = 0; /* FIXME */
- }
+ | LOWER '(' mode_argument ')'
+ { write_lower_upper_value (UNOP_LOWER, $3); }
+ | UPPER '(' mode_argument ')'
+ { write_lower_upper_value (UNOP_UPPER, $3); }
+ | LOWER '(' expression ')'
+ { write_exp_elt_opcode (UNOP_LOWER); }
+ | UPPER '(' expression ')'
+ { write_exp_elt_opcode (UNOP_UPPER); }
+ | LENGTH '(' expression ')'
+ { write_exp_elt_opcode (UNOP_LENGTH); }
;
mode_argument : mode_name
@@ -975,22 +971,6 @@ mode_argument : mode_name
mode_name : TYPENAME
;
-upper_lower_argument : expression
- {
- $$ = 0; /* FIXME */
- }
- | mode_name
- {
- $$ = 0; /* FIXME */
- }
- ;
-
-length_argument : expression
- {
- $$ = 0; /* FIXME */
- }
- ;
-
/* Things which still need productions... */
array_mode_name : FIXME_08 { $$ = 0; }
@@ -2019,6 +1999,20 @@ yylex ()
}
void
+write_lower_upper_value (opcode, type)
+ enum exp_opcode opcode; /* Either UNOP_LOWER or UNOP_UPPER */
+ struct type *type;
+{
+ extern LONGEST type_lower_upper ();
+ struct type *result_type;
+ LONGEST val = type_lower_upper (opcode, type, &result_type);
+ write_exp_elt_opcode (OP_LONG);
+ write_exp_elt_type (result_type);
+ write_exp_elt_longcst (val);
+ write_exp_elt_opcode (OP_LONG);
+}
+
+void
yyerror (msg)
char *msg;
{