From: Andrew Cagney <ac131313@redhat.com>
To: Paul Hilfinger <hilfingr@gnat.com>
Cc: gdb-patches@sources.redhat.com
Subject: Re: RFA: Changes to allow extensions to operator set
Date: Fri, 05 Sep 2003 16:23:00 -0000 [thread overview]
Message-ID: <3F58B874.7020904@redhat.com> (raw)
In-Reply-To: <20030901093941.0D2E9F2A64@nile.gnat.com>
> +/* Information needed to print and prefixify expressions for a given
> + language. */
> +
> +struct exp_descriptor
> + {
> + /* Print subexpression */
> + void (*print_subexp) (struct expression *, int *, struct ui_file *,
> + enum precedence);
> +
> + /* Returns number of exp_elements needed to represent an operator and
> + the number of subexpressions it takes. */
> + void (*operator_length) (struct expression*, int, int*, int *);
> +
> + /* Name of this operator for dumping purposes. */
> + char *(*op_name) (enum exp_opcode);
> +
> + /* Dump the rest of this (prefix) expression after the operator
> + itself has been printed. See dump_subexp_body_standard in
> + (expprint.c). */
> + int (*dump_subexp_body) (struct expression *, struct ui_file *, int);
> + };
Here is a method to handle operator evaluation missing? Otherwize won't
the jumbo switch in evaluate_subexp_standard still need to be modified
as languages add additional operators.
I was thinking more of
struct operator
{
const char *name;
void (*length) (struct expression *exp, struct operator *op, ?others?);
int (*eval) (...);
?others?
int opcode; // for backward compatibility
};
struct exp_descriptor
{
int num_oper;
const struct operator *op; // is **op easier?
dump_...;
print_...;
}
which is a step beyond what you posted. It should completly eliminate
the need to add to that OP enum list (and eliminate the enum).
To create backward compatibility, the default table would just have all
its length() and eval() members pointing at the default_* methods you
posted (they could pull the "enum exp_opcode" ->opcode). Ada would have
a larger table.
Does this work?
> One explanatory comment as to technique: I bundled up a related set of
> function pointers into a new type (struct exp_descriptor) and put a
> pointer to the structure into the language_defn vectors (i.e., as
> opposed to just adding the four functions contained in it to the
> language_defn vector). I thought it looked neater, but more to the
> point, it avoided some awkward dependency issues.
Yes, definitly. Like the strategy.
Andrew
next prev parent reply other threads:[~2003-09-05 16:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-01 9:39 Paul Hilfinger
2003-09-04 2:18 ` Andrew Cagney
2003-09-05 8:32 ` Paul Hilfinger
2003-09-05 15:57 ` Andrew Cagney
2003-09-05 16:23 ` Andrew Cagney [this message]
2003-09-06 11:13 ` Paul Hilfinger
2003-09-11 18:55 ` Andrew Cagney
2003-09-13 8:58 ` Paul Hilfinger
2003-09-18 9:20 ` Paul Hilfinger
2003-09-22 17:04 ` Andrew Cagney
2003-09-05 16:29 ` Andrew Cagney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3F58B874.7020904@redhat.com \
--to=ac131313@redhat.com \
--cc=gdb-patches@sources.redhat.com \
--cc=hilfingr@gnat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox