aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-buffered-queue.h
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-07-05 16:56:14 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-07-07 12:28:58 +0100
commitec5da37dbfbcc55183f7ea4658c8856b9335ad61 (patch)
treec1ae133b17d14f2c96f8d5b56774b6e09c9b79bb /gcc/rust/rust-buffered-queue.h
parent29d594e263f0ccbcbd2babf43ff453c5188f4f2c (diff)
downloadgcc-ec5da37dbfbcc55183f7ea4658c8856b9335ad61.zip
gcc-ec5da37dbfbcc55183f7ea4658c8856b9335ad61.tar.gz
gcc-ec5da37dbfbcc55183f7ea4658c8856b9335ad61.tar.bz2
Refactor Lexer to support an abstract InputSource class
This patch allows us to remove the fmemopen lex_string hack to support parsing buffers. This will allow us to support mutliple sources such as metadata imports etc. The patch here updates the parser to hold onto a reference to the lexer rather than 'owning' the lexer which allows us to decouple the move semantics here. Fixes #1203 #1000
Diffstat (limited to 'gcc/rust/rust-buffered-queue.h')
-rw-r--r--gcc/rust/rust-buffered-queue.h6
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/rust/rust-buffered-queue.h b/gcc/rust/rust-buffered-queue.h
index 39f3506..afcc467 100644
--- a/gcc/rust/rust-buffered-queue.h
+++ b/gcc/rust/rust-buffered-queue.h
@@ -28,9 +28,7 @@ template <typename T, typename Source> class buffered_queue
{
public:
// Construct empty queue from Source src.
- buffered_queue (Source src)
- : source (std::move (src)), start (0), end (0), buffer ()
- {}
+ buffered_queue (Source src) : source (src), start (0), end (0), buffer () {}
/* disable copying (since source is probably non-copyable)
* TODO is this actually a good idea? If source is non-copyable, it would
@@ -104,7 +102,7 @@ public:
/* iterate through buffer and invoke operator () on source on values
* past original end */
for (int i = 0; i < num_items_to_read; i++)
- buffer[end + i] = source ();
+ buffer[end + i] = source.next ();
// move end based on additional items added
end += num_items_to_read;