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
43
44
45
46
47
48
49
50
51
52
use crate::{marking::MarkedSourceMapping, source_map::SourceMap};
use anyhow::Result;
use move_binary_format::binary_views::BinaryIndexedView;
use move_ir_types::location::Loc;
#[derive(Debug)]
pub struct SourceMapping<'view> {
pub bytecode: BinaryIndexedView<'view>,
pub source_map: SourceMap,
pub source_code: Option<(String, String)>,
pub marks: Option<MarkedSourceMapping>,
}
impl<'view> SourceMapping<'view> {
pub fn new(source_map: SourceMap, bytecode: BinaryIndexedView<'view>) -> Self {
Self {
source_map,
bytecode,
source_code: None,
marks: None,
}
}
pub fn new_from_view(bytecode: BinaryIndexedView<'view>, default_loc: Loc) -> Result<Self> {
Ok(Self::new(
SourceMap::dummy_from_view(&bytecode, default_loc)?,
bytecode,
))
}
pub fn with_marks(&mut self, marks: MarkedSourceMapping) {
self.marks = Some(marks);
}
pub fn with_source_code(&mut self, source_code: (String, String)) {
self.source_code = Some(source_code);
}
}