From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eB3PLNiY718DTQAAWB0awg (envelope-from ) for ; Fri, 01 Jan 2021 16:49:12 -0500 Received: by simark.ca (Postfix, from userid 112) id 687971F0B7; Fri, 1 Jan 2021 16:49:11 -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.9 required=5.0 tests=DKIM_SIGNED, MAILING_LIST_MULTI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [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 0B7CF1F0B8 for ; Fri, 1 Jan 2021 16:49:03 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B852438618C3; Fri, 1 Jan 2021 21:48:37 +0000 (GMT) Received: from gateway36.websitewelcome.com (gateway36.websitewelcome.com [192.185.187.5]) by sourceware.org (Postfix) with ESMTPS id D784C38618C3 for ; Fri, 1 Jan 2021 21:48:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D784C38618C3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=tom@tromey.com Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway36.websitewelcome.com (Postfix) with ESMTP id 792AD400C8F61 for ; Fri, 1 Jan 2021 15:48:33 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSHhkyOQesvw9vSHhkLuRK; Fri, 01 Jan 2021 15:48:33 -0600 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=WQQjVYylQ0xC+kxsz1eo5dkYEhSum39ZvllQt1dDoyU=; b=prHlZhjAPEOMrWf8IwY5V7cXaA I0byYAJ+AJ4/nINS0IS5UlTMou9jyiKmnW3IO8hamsNNtMj6BcoE52ez8BEVUPWCEeu7yZSR/+1Ih lM2j93zgWVO2bG7pIsWT5G+We; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60414 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1kvSHh-0029lU-9p for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:48:33 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 136/203] Add two simple Modula-2 operations Date: Fri, 1 Jan 2021 14:46:16 -0700 Message-Id: <20210101214723.1784144-137-tom@tromey.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210101214723.1784144-1-tom@tromey.com> References: <20210101214723.1784144-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.122.81.39 X-Source-L: No X-Exim-ID: 1kvSHh-0029lU-9p X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60414 X-Source-Auth: tom+tromey.com X-Email-Count: 137 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes 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: , Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" 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