about summary refs log tree commit diff
path: root/src/lib/ebml.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2011-03-31 14:37:09 -0700
committerPatrick Walton <pcwalton@mimiga.net>2011-03-31 14:37:44 -0700
commit3c1de96cda33e9547adda14dc66294752c99e4c3 (patch)
tree63d8743667358697013299ba452f412f48c658f2 /src/lib/ebml.rs
parentef0c903f6a25cd9d8c900fbde336d4a4a5b43c56 (diff)
rustc: Use the crate index to look up defs
Diffstat (limited to 'src/lib/ebml.rs')
-rw-r--r--src/lib/ebml.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/ebml.rs b/src/lib/ebml.rs
index 047218a33a6..8ed249130f2 100644
--- a/src/lib/ebml.rs
+++ b/src/lib/ebml.rs
@@ -90,11 +90,32 @@ impure fn move_to_parent(&reader r) {
     r.reader.seek(st.tag_pos as int, io.seek_set);
 }
 
+// Moves to the sibling of the current item with the given tag ID.
+impure fn move_to_sibling_with_id(&reader r, uint tag_id) {
+    while (peek(r).id != tag_id) {
+        move_to_next_sibling(r);
+    }
+}
+
+// Moves to the first child of the current item with the given tag ID.
+impure fn move_to_child_with_id(&reader r, uint tag_id) {
+    move_to_first_child(r);
+    move_to_sibling_with_id(r, tag_id);
+}
+
 // Reads the data segment of a tag.
 impure fn read_data(&reader r) -> vec[u8] {
     ret r.reader.read_bytes(bytes_left(r));
 }
 
+// Blows away the tag stack and moves the reader to the given byte position.
+impure fn reset_reader(&reader r, uint pos) {
+    // FIXME: rustc "ty_var in trans.type_of" bug
+    let vec[ebml_state] states = vec();
+    r.states = states;
+    r.reader.seek(pos as int, io.seek_set);
+}
+
 impure fn peek(&reader r) -> ebml_tag {
     check (bytes_left(r) > 0u);
     auto pos = r.reader.tell();