Struct test_assembler::Label [] [src]

pub struct Label(pub Rc<RealLabel>);

A Label represents a value not yet known that is stored in a Section.

As long as all the labels a section refers to are defined by the time its contents are retrieved as bytes, undefined labels can be used freely in that section's construction. A label can be in one of three states:

  • undefined,
  • defined as the sum of some other label and a constant, or
  • a constant.

A label's value never changes, but it can accumulate constraints. Adding labels and integers is permitted, and yields a label. Subtracting a constant from a label is permitted, and also yields a label. Subtracting two labels that have some relationship to each other is permitted, and yields a constant.

Examples

Labels can be set to point to other Labels, potentially with an offset.

use test_assembler::*;

let l1 = Label::new();
// l2 is l1's value (which is currently undefined) + 10
let l2 = &l1 + 10;
// Now give l1 a value.
l1.set_const(1);
// l2's value is derived from l1.
assert_eq!(l2.value().unwrap(), 11);

Methods from Deref<Target = RealLabel>

Get the constant value of the RealLabel, if known.

Get the relative offset from another label, if possible.

Set this RealLabels value to val.

Set this RealLabels value equal to other.

Trait Implementations

impl Clone for Label
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Label
[src]

Formats the value using the given formatter.

impl Deref for Label
[src]

The resulting type after dereferencing

The method called to dereference a value

impl LabelMaker for Label
[src]

Create an undefined label.

Create a label with a constant value val.

Create a label whose value is equal to other.

Create a label whose value is equal to other plus offset.

impl<'a> Add<i64> for &'a Label
[src]

Add a constant to a Label, producing a new Label.

The new Label references the existing Label.

The resulting type after applying the + operator

The method for the + operator

impl<'a> Sub<i64> for &'a Label
[src]

Subtract a constant from a Label, producing a new Label.

The new Label references the existing Label.

The resulting type after applying the - operator

The method for the - operator

impl<'a> Sub<&'a Label> for &'a Label
[src]

Subtract a Label from another Label, returning an i64.

If the labels are unrelated this will panic.

The resulting type after applying the - operator

The method for the - operator

impl<'a, T: Num> ToLabelOrNum<'a, T> for Label
[src]

impl<'a, T: Num> ToLabelOrNum<'a, T> for &'a Label
[src]