1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use raw::{
jit_label_t,
jit_function_reserve_label
};
use function::UncompiledFunction;
use std::marker::PhantomData;
use std::fmt;
use std::ops::{Deref, DerefMut};
#[derive(PartialEq)]
pub struct Label<'a> {
_label: jit_label_t,
marker: PhantomData<&'a ()>,
}
impl<'a> fmt::Display for Label<'a> {
fn fmt(&self, fmt:&mut fmt::Formatter) -> fmt::Result {
write!(fmt, "{}", self._label)
}
}
impl<'a> Label<'a> {
#[inline(always)]
pub fn new(func:&UncompiledFunction<'a>) -> Label<'a> {
unsafe {
Label {
_label: jit_function_reserve_label(func.into()),
marker: PhantomData,
}
}
}
}
impl<'a> Deref for Label<'a> {
type Target = u64;
fn deref(&self) -> &u64 {
&self._label
}
}
impl<'a> DerefMut for Label<'a> {
fn deref_mut(&mut self) -> &mut u64 {
&mut self._label
}
}