|
| 1 | +use std::collections::HashMap; |
| 2 | + |
| 3 | +use crate::ir::types::InstMatcherType; |
| 4 | +use crate::ir::values::InstMatcherValue; |
| 5 | +use crate::matchers::debug::DebugInfoColumnMatcher; |
| 6 | +use crate::matchers::debug::DebugInfoLineMatcher; |
| 7 | + |
| 8 | +use gitql_ast::types::integer::IntType; |
| 9 | +use gitql_core::signature::Signature; |
| 10 | +use gitql_core::signature::StandardFunction; |
| 11 | +use gitql_core::values::Value; |
| 12 | + |
| 13 | +#[inline(always)] |
| 14 | +pub fn register_debug_inst_matchers_functions(map: &mut HashMap<&'static str, StandardFunction>) { |
| 15 | + map.insert("m_dbg_line", match_debug_info_line); |
| 16 | + map.insert("m_dbg_column", match_debug_info_column); |
| 17 | +} |
| 18 | + |
| 19 | +#[inline(always)] |
| 20 | +pub fn register_debug_inst_matchers_function_signatures( |
| 21 | + map: &mut HashMap<&'static str, Signature>, |
| 22 | +) { |
| 23 | + map.insert( |
| 24 | + "m_dbg_line", |
| 25 | + Signature { |
| 26 | + parameters: vec![Box::new(IntType)], |
| 27 | + return_type: Box::new(InstMatcherType), |
| 28 | + }, |
| 29 | + ); |
| 30 | + |
| 31 | + map.insert( |
| 32 | + "m_dbg_column", |
| 33 | + Signature { |
| 34 | + parameters: vec![Box::new(IntType)], |
| 35 | + return_type: Box::new(InstMatcherType), |
| 36 | + }, |
| 37 | + ); |
| 38 | +} |
| 39 | + |
| 40 | +fn match_debug_info_line(values: &[Box<dyn Value>]) -> Box<dyn Value> { |
| 41 | + let line = values[0].as_int().unwrap() as u32; |
| 42 | + let matcher = Box::new(DebugInfoLineMatcher { line }); |
| 43 | + Box::new(InstMatcherValue { matcher }) |
| 44 | +} |
| 45 | + |
| 46 | +fn match_debug_info_column(values: &[Box<dyn Value>]) -> Box<dyn Value> { |
| 47 | + let column = values[0].as_int().unwrap() as u32; |
| 48 | + let matcher = Box::new(DebugInfoColumnMatcher { column }); |
| 49 | + Box::new(InstMatcherValue { matcher }) |
| 50 | +} |
0 commit comments