From 63fc81541e90bc4256a2caacb8338ecd7e5edf79 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 4 Nov 2016 08:44:01 -0700 Subject: [PATCH] Add Cursor::set_position. Make it possible to move a cursor to a new position. In the current implementation of Layout and Cursor, this is a trivial operation, but if we switch to a B-tree based function layout, this involves navigating the tree. --- lib/cretonne/src/ir/layout.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/cretonne/src/ir/layout.rs b/lib/cretonne/src/ir/layout.rs index fdd2305747..bdcf4cdd52 100644 --- a/lib/cretonne/src/ir/layout.rs +++ b/lib/cretonne/src/ir/layout.rs @@ -381,6 +381,11 @@ impl<'f> Cursor<'f> { self.pos } + /// Move the cursor to a new position. + pub fn set_position(&mut self, pos: CursorPosition) { + self.pos = pos; + } + /// Get the EBB corresponding to the current position. pub fn current_ebb(&self) -> Option { use self::CursorPosition::*;