From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id yMggNdcl919nDAAAWB0awg (envelope-from ) for ; Thu, 07 Jan 2021 10:16:39 -0500 Received: by simark.ca (Postfix, from userid 112) id D7B771E965; Thu, 7 Jan 2021 10:16:39 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RDNS_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from sourceware.org (unknown [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 893FD1E590 for ; Thu, 7 Jan 2021 10:16:39 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3DD8A396EC9C; Thu, 7 Jan 2021 15:16:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3DD8A396EC9C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610032599; bh=8k9j8XEdKXkqvCUxCLwkGvz2cxZqp9haxxGLFIyg1Zk=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ZhB+gs6IK8tF10VeTUCNr2wavjWQck+N77pzn1ZsmJeD4r5A1PjVtFi41dfE7AVYd uLXT6QGhWTblyAvv+/AefwRH1SrarU0y5w9IZZLAR9xRtspwlA55FD8qNQhMpX/mjR N1EJZ1W2nsj0Mz9sHniTjGLW8aPsvqKG4dguDddk= Received: from postbox-1.southwales.ac.uk (postbox-1.southwales.ac.uk [194.82.57.76]) by sourceware.org (Postfix) with ESMTPS id C5B66396EC79 for ; Thu, 7 Jan 2021 15:16:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C5B66396EC79 Received: from j228-gm.comp.glam.ac.uk ([193.63.148.84]) by postbox-1.southwales.ac.uk with esmtp (Exim 4.90_1) (envelope-from ) id 1kxX1f-000uAW-AP; Thu, 07 Jan 2021 15:16:35 +0000 To: Tom Tromey Subject: Re: [PATCH 136/203] Add two simple Modula-2 operations References: <20210101214723.1784144-1-tom@tromey.com> <20210101214723.1784144-137-tom@tromey.com> Date: Thu, 07 Jan 2021 15:16:35 +0000 In-Reply-To: <20210101214723.1784144-137-tom@tromey.com> (Tom Tromey's message of "Fri, 1 Jan 2021 14:46:16 -0700") Message-ID: <87pn2gojzg.fsf@j228-gm.comp.glam.ac.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Gaius Mulley via Gdb-patches Reply-To: Gaius Mulley Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" Tom Tromey writes: > This adds a couple of simple Modula-2 operations. > > gdb/ChangeLog > 2021-01-01 Tom Tromey > > * m2-lang.c (eval_op_m2_high, eval_op_m2_subscript): No longer > static. > * m2-exp.h: New file. > --- > gdb/ChangeLog | 6 ++++ > gdb/m2-exp.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ > gdb/m2-lang.c | 5 +-- > 3 files changed, 93 insertions(+), 2 deletions(-) > create mode 100644 gdb/m2-exp.h > > diff --git a/gdb/m2-exp.h b/gdb/m2-exp.h > new file mode 100644 > index 00000000000..e034963a9a6 > --- /dev/null > +++ b/gdb/m2-exp.h > @@ -0,0 +1,84 @@ > +/* Definitions for Modula-2 expressions > + > + Copyright (C) 2020 Free Software Foundation, Inc. > + > + This file is part of GDB. > + > + This program is free software; you can redistribute it and/or modify > + it under the terms of the GNU General Public License as published by > + the Free Software Foundation; either version 3 of the License, or > + (at your option) any later version. > + > + This program is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + GNU General Public License for more details. > + > + You should have received a copy of the GNU General Public License > + along with this program. If not, see . */ > + > +#ifndef M2_EXP_H > +#define M2_EXP_H > + > +#include "expop.h" > + > +extern struct value *eval_op_m2_high (struct type *expect_type, > + struct expression *exp, > + enum noside noside, > + struct value *arg1); > +extern struct value *eval_op_m2_subscript (struct type *expect_type, > + struct expression *exp, > + enum noside noside, > + struct value *arg1, > + struct value *arg2); > + > +namespace expr > +{ > + > +/* The Modula-2 "HIGH" operation. */ > +class m2_unop_high_operation > + : public tuple_holding_operation > +{ > +public: > + > + using tuple_holding_operation::tuple_holding_operation; > + > + value *evaluate (struct type *expect_type, > + struct expression *exp, > + enum noside noside) override > + { > + value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp, > + noside); > + return eval_op_m2_high (expect_type, exp, noside, arg1); > + } > + > + enum exp_opcode opcode () const override > + { return UNOP_HIGH; } > +}; > + > +/* Subscripting for Modula-2. */ > +class m2_binop_subscript_operation > + : public tuple_holding_operation > +{ > +public: > + > + using tuple_holding_operation::tuple_holding_operation; > + > + value *evaluate (struct type *expect_type, > + struct expression *exp, > + enum noside noside) override > + { > + value *arg1 = std::get<0> (m_storage)->evaluate_with_coercion (exp, > + noside); > + value *arg2 = std::get<1> (m_storage)->evaluate_with_coercion (exp, > + noside); > + return eval_op_m2_subscript (expect_type, exp, noside, arg1, arg2); > + } > + > + enum exp_opcode opcode () const override > + { return BINOP_SUBSCRIPT; } > +}; > + > +} /* namespace expr */ > + > +#endif /* M2_EXP_H */ > diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c > index f5e80eee9c6..60d373ec2b9 100644 > --- a/gdb/m2-lang.c > +++ b/gdb/m2-lang.c > @@ -28,10 +28,11 @@ > #include "c-lang.h" > #include "valprint.h" > #include "gdbarch.h" > +#include "m2-exp.h" > > /* A helper function for UNOP_HIGH. */ > > -static struct value * > +struct value * > eval_op_m2_high (struct type *expect_type, struct expression *exp, > enum noside noside, > struct value *arg1) > @@ -62,7 +63,7 @@ eval_op_m2_high (struct type *expect_type, struct expression *exp, > > /* A helper function for BINOP_SUBSCRIPT. */ > > -static struct value * > +struct value * > eval_op_m2_subscript (struct type *expect_type, struct expression *exp, > enum noside noside, > struct value *arg1, struct value *arg2) > -- > 2.26.2 thanks Tom for all the work keeping this up to date - all looks great! regards, Gaius