diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-03-05 21:41:25 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2023-03-05 21:41:25 +0100 |
commit | 90233c3cf84453424f1de6dd68f19255ece26f1d (patch) | |
tree | d1108e9f3a8a30e87a1a4d7ac431fab7ee9da6b0 /src/label.rs | |
parent | 7e50574500e4c33d8f12a5cb4893249f29e311f0 (diff) | |
download | juicebox-asm-90233c3cf84453424f1de6dd68f19255ece26f1d.tar.gz juicebox-asm-90233c3cf84453424f1de6dd68f19255ece26f1d.zip |
Updated doc comments
Diffstat (limited to 'src/label.rs')
-rw-r--r-- | src/label.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/label.rs b/src/label.rs index b1f1133..a0bd864 100644 --- a/src/label.rs +++ b/src/label.rs @@ -1,3 +1,6 @@ +//! Definition of the lable type which can be used as jump target and can be bound to a location in +//! the emitted code. + use std::collections::HashSet; /// A label which is used as target for jump instructions. @@ -35,7 +38,11 @@ impl Label { } } - /// Bind the label to the `location`. + /// Bind the label to the `location`, can only be bound once. + /// + /// # Panics + /// + /// Panics if the lable is already bound. pub(crate) fn bind(&mut self, loc: usize) { // A label can only be bound once! assert!(!self.is_bound()); @@ -48,10 +55,13 @@ impl Label { self.offsets.insert(off); } + /// Get the location of the lable if already bound, `None` else. pub(crate) fn location(&self) -> Option<usize> { self.location } + /// Get the offsets which refer to the label. These are used to patch the jump instructions to + /// the label location. pub(crate) fn offsets_mut(&mut self) -> &mut HashSet<usize> { &mut self.offsets } |