(&mut self)
| 49 | } |
| 50 | |
| 51 | fn build_mapping(&mut self) { |
| 52 | let regex = Regex::new(r"^(\d+):.*").unwrap(); |
| 53 | let fun_regex = Regex::new(r"^public\s+([a-zA-Z_]+)\(").unwrap(); |
| 54 | let mut current_fun = None; |
| 55 | let mut current_fdef_idx = None; |
| 56 | let mut line_map = HashMap::new(); |
| 57 | |
| 58 | let function_def_for_name: HashMap<String, u16> = self |
| 59 | .view |
| 60 | .function_defs() |
| 61 | .into_iter() |
| 62 | .flatten() |
| 63 | .enumerate() |
| 64 | .map(|(index, fdef)| { |
| 65 | ( |
| 66 | self.view |
| 67 | .identifier_at(self.view.function_handle_at(fdef.function).name) |
| 68 | .to_string(), |
| 69 | index as u16, |
| 70 | ) |
| 71 | }) |
| 72 | .collect(); |
| 73 | |
| 74 | for (i, line) in self.lines.iter().enumerate() { |
| 75 | let line = line.trim(); |
| 76 | if let Some(cap) = fun_regex.captures(line) { |
| 77 | let fn_name = cap.get(1).unwrap().as_str(); |
| 78 | let function_definition_index = function_def_for_name[fn_name]; |
| 79 | current_fun = Some(fn_name); |
| 80 | current_fdef_idx = Some(FunctionDefinitionIndex(function_definition_index)); |
| 81 | } |
| 82 | |
| 83 | if let Some(cap) = regex.captures(line) { |
| 84 | current_fun.map(|fname| { |
| 85 | let d = cap.get(1).unwrap().as_str().parse::<u16>().unwrap(); |
| 86 | line_map.insert( |
| 87 | i, |
| 88 | BytecodeInfo { |
| 89 | function_name: fname.to_string(), |
| 90 | function_index: current_fdef_idx.unwrap(), |
| 91 | code_offset: d, |
| 92 | }, |
| 93 | ) |
| 94 | }); |
| 95 | } |
| 96 | } |
| 97 | self.line_map = line_map; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | impl LeftScreen for BytecodeViewer<'_> { |
no test coverage detected