From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12919 invoked by alias); 5 Sep 2003 16:23:33 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 12845 invoked from network); 5 Sep 2003 16:23:29 -0000 Received: from unknown (HELO localhost.redhat.com) (66.30.197.194) by sources.redhat.com with SMTP; 5 Sep 2003 16:23:29 -0000 Received: from redhat.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id BDDE42B7F; Fri, 5 Sep 2003 12:23:16 -0400 (EDT) Message-ID: <3F58B874.7020904@redhat.com> Date: Fri, 05 Sep 2003 16:23:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0.2) Gecko/20030820 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Paul Hilfinger Cc: gdb-patches@sources.redhat.com Subject: Re: RFA: Changes to allow extensions to operator set References: <20030901093941.0D2E9F2A64@nile.gnat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2003-09/txt/msg00073.txt.bz2 > +/* 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