public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] libproc_macro: Add Group implementation
@ 2023-04-06 21:32 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:32 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:9eaf139ee7bb743422ed9c32d153185e125194f9

commit 9eaf139ee7bb743422ed9c32d153185e125194f9
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Mon Feb 20 16:49:06 2023 +0100

    libproc_macro: Add Group implementation
    
    Add Group rust structure implementation in libproc_macro.
    
    ChangeLog:
    
            * librust/proc_macro/rust/bridge/group.rs: Add internal Group
            implementation.
            * librust/proc_macro/rust/group.rs: Add Group implementation.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 librust/proc_macro/rust/bridge/group.rs | 28 ++++++++++++++++++++++++++--
 librust/proc_macro/rust/group.rs        | 18 +++++++++---------
 2 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/librust/proc_macro/rust/bridge/group.rs b/librust/proc_macro/rust/bridge/group.rs
index 12c1b605c50..83d2e068429 100644
--- a/librust/proc_macro/rust/bridge/group.rs
+++ b/librust/proc_macro/rust/bridge/group.rs
@@ -1,4 +1,5 @@
-use bridge;
+use bridge::span::Span;
+use bridge::token_stream::TokenStream;
 use std::fmt;
 use Delimiter;
 
@@ -6,8 +7,31 @@ use Delimiter;
 #[derive(Debug, Clone)]
 pub struct Group {
     delimiter: Delimiter,
-    stream: bridge::token_stream::TokenStream,
+    stream: TokenStream,
 }
+
+impl Group {
+    pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self {
+        Group { delimiter, stream }
+    }
+
+    pub fn delimiter(&self) -> Delimiter {
+        self.delimiter
+    }
+
+    pub fn span(&self) -> Span {
+        Span {}
+    }
+
+    pub fn set_span(&mut self, span: Span) {
+        let _ = span;
+    }
+
+    pub fn stream(&self) -> TokenStream {
+        self.stream.clone()
+    }
+}
+
 impl fmt::Display for Group {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self.delimiter {
diff --git a/librust/proc_macro/rust/group.rs b/librust/proc_macro/rust/group.rs
index 224fbada835..29bfb9d7132 100644
--- a/librust/proc_macro/rust/group.rs
+++ b/librust/proc_macro/rust/group.rs
@@ -28,13 +28,13 @@ impl Group {
     ///
     /// * `delimiter` - The delimiter surrounding the inner [`TokenStream`].
     /// * `stream` - The tokenstream for this `Group`.
-    pub fn new(_delimiter: Delimiter, _stream: TokenStream) -> Self {
-        todo!("Implement this function")
+    pub fn new(delimiter: Delimiter, stream: TokenStream) -> Self {
+        Group(bridge::group::Group::new(delimiter, stream.0))
     }
 
     /// Get the delimiter of the `Group`.
     pub fn delimiter(&self) -> Delimiter {
-        todo!("Implement this function")
+        self.0.delimiter()
     }
 
     /// Get the stream of the `Group`.
@@ -43,23 +43,23 @@ impl Group {
     ///
     /// The returned stream does not include the delimiters of this group.
     pub fn stream(&self) -> TokenStream {
-        todo!("Implement this function")
+        TokenStream(self.0.stream())
     }
 
     /// Get the span for the delimiters of this token stream, spanning the
     /// entire group.
     pub fn span(&self) -> Span {
-        todo!("Implement this function")
+        Span(self.0.span())
     }
 
     /// Get the span pointing to the opening delimiter of this `Group`.
     pub fn span_open(&self) -> Span {
-        todo!("Implement this function")
+        Span(self.0.span())
     }
 
     /// Get the span pointing to the closing delimiter of this `Group`.
     pub fn span_close(&self) -> Span {
-        todo!("Implement this function")
+        Span(self.0.span())
     }
 
     /// Change the span for this `Group`'s delimiters, but not its internal
@@ -70,8 +70,8 @@ impl Group {
     /// This method will **not** set the span of all the internal tokens spanned
     /// by this group, but rather it will only set the span of the delimiter
     /// tokens at the level of the `Group`.
-    pub fn set_span(&mut self, _span: Span) {
-        todo!("Implement this function")
+    pub fn set_span(&mut self, span: Span) {
+        self.0.set_span(span.0)
     }
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-04-06 21:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:32 [gcc/devel/rust/master] libproc_macro: Add Group implementation Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).