]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: stacked-contexts: Add peek() method
authorArthur Cohen <arthur.cohen@embecosm.com>
Tue, 26 Nov 2024 16:34:37 +0000 (16:34 +0000)
committerArthur Cohen <arthur.cohen@embecosm.com>
Fri, 21 Mar 2025 11:33:06 +0000 (12:33 +0100)
gcc/rust/ChangeLog:

* util/rust-stacked-contexts.h: Add new method to see what context we are currently in.

gcc/rust/util/rust-stacked-contexts.h

index 39a0c08de79276ccd17c7d3da66cd37e05390b6b..fe0bc8a291b7087f26457a68f059f14faa32f195 100644 (file)
@@ -71,6 +71,13 @@ public:
     return last;
   }
 
+  const T &peek ()
+  {
+    rust_assert (!stack.empty ());
+
+    return stack.back ();
+  }
+
   /**
    * Are we currently inside of a special context?
    */