From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id CFzAOs6Y718XTQAAWB0awg (envelope-from ) for ; Fri, 01 Jan 2021 16:49:02 -0500 Received: by simark.ca (Postfix, from userid 112) id ED6D71F0C3; Fri, 1 Jan 2021 16:49:02 -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 85D441F0B8 for ; Fri, 1 Jan 2021 16:48:58 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B40223896832; Fri, 1 Jan 2021 21:48:32 +0000 (GMT) Received: from gateway33.websitewelcome.com (gateway33.websitewelcome.com [192.185.146.130]) by sourceware.org (Postfix) with ESMTPS id E2A163896830 for ; Fri, 1 Jan 2021 21:48:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E2A163896830 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 cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 85FDD107C2DE for ; Fri, 1 Jan 2021 15:48:29 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id vSHdkzbDtDT64vSHdk79HW; Fri, 01 Jan 2021 15:48:29 -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=BCWZbnP89QBa3uAQ0YsbHY8br75ZLtLW28lVfmL7AUo=; b=n6DwudaT/TfJHBpfEUy4IeoyPZ E3IHYjX53MkgH8A3YAyoKnVrhC6jWV2thfqwDKYP7K8E+Vcc9RSYnyUjoophWFXn8rrTeHWbhi7/z SjheTcRbPgZJgzZSe4THSFf+M; Received: from 97-122-81-39.hlrn.qwest.net ([97.122.81.39]:60412 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 1kvSHd-0029i1-8t for gdb-patches@sourceware.org; Fri, 01 Jan 2021 14:48:29 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [PATCH 130/203] Implement some Rust operations Date: Fri, 1 Jan 2021 14:46:10 -0700 Message-Id: <20210101214723.1784144-131-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: 1kvSHd-0029i1-8t X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-122-81-39.hlrn.qwest.net (localhost.localdomain) [97.122.81.39]:60412 X-Source-Auth: tom+tromey.com X-Email-Count: 131 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 implements some straightforward Rust operations, using existing template classes. gdb/ChangeLog 2021-01-01 Tom Tromey * rust-lang.c (eval_op_rust_complement, eval_op_rust_array): No longer static. Add "opcode" parameter. (rust_evaluate_subexp): Update. * rust-exp.h: New file. --- gdb/ChangeLog | 7 +++++++ gdb/rust-exp.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ gdb/rust-lang.c | 14 +++++++++----- 3 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 gdb/rust-exp.h diff --git a/gdb/rust-exp.h b/gdb/rust-exp.h new file mode 100644 index 00000000000..cce1fd9a7d9 --- /dev/null +++ b/gdb/rust-exp.h @@ -0,0 +1,47 @@ +/* Definitions for Rust 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 RUST_EXP_H +#define RUST_EXP_H + +#include "expop.h" + +extern struct value *eval_op_rust_complement (struct type *expect_type, + struct expression *exp, + enum noside noside, + enum exp_opcode opcode, + struct value *value); +extern struct value *eval_op_rust_array (struct type *expect_type, + struct expression *exp, + enum noside noside, + enum exp_opcode opcode, + struct value *ncopies, + struct value *elt); + +namespace expr +{ + +using rust_unop_compl_operation = unop_operation; +using rust_array_operation = binop_operation; + +} /* namespace expr */ + +#endif /* RUST_EXP_H */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index a7c62610a1d..1305ee092fa 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -39,6 +39,7 @@ #include #include "cli/cli-style.h" #include "parser-defs.h" +#include "rust-exp.h" /* See rust-lang.h. */ @@ -1339,9 +1340,10 @@ eval_op_rust_ind (struct type *expect_type, struct expression *exp, /* A helper function for UNOP_COMPLEMENT. */ -static struct value * +struct value * eval_op_rust_complement (struct type *expect_type, struct expression *exp, enum noside noside, + enum exp_opcode opcode, struct value *value) { if (noside == EVAL_SKIP) @@ -1356,9 +1358,10 @@ eval_op_rust_complement (struct type *expect_type, struct expression *exp, /* A helper function for OP_ARRAY. */ -static struct value * +struct value * eval_op_rust_array (struct type *expect_type, struct expression *exp, enum noside noside, + enum exp_opcode opcode, struct value *elt, struct value *ncopies) { int copies = value_as_long (ncopies); @@ -1505,8 +1508,9 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, int *pos, enum noside noside) { struct value *result; + enum exp_opcode op = exp->elts[*pos].opcode; - switch (exp->elts[*pos].opcode) + switch (op) { case UNOP_IND: { @@ -1528,7 +1532,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, ++*pos; value = evaluate_subexp (nullptr, exp, pos, noside); - result = eval_op_rust_complement (expect_type, exp, noside, value); + result = eval_op_rust_complement (expect_type, exp, noside, op, value); } break; @@ -1621,7 +1625,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, elt = rust_evaluate_subexp (NULL, exp, pos, noside); ncopies = rust_evaluate_subexp (NULL, exp, pos, noside); - return eval_op_rust_array (expect_type, exp, noside, elt, ncopies); + return eval_op_rust_array (expect_type, exp, noside, op, elt, ncopies); } break; -- 2.26.2