-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2976a6
commit 82ee1df
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use std::collections::HashMap; | ||
|
||
use gitql_core::signature::Signature; | ||
use gitql_core::signature::StandardFunction; | ||
use gitql_core::values::base::Value; | ||
|
||
use crate::ir::types::InstMatcherType; | ||
use crate::ir::values::InstMatcherValue; | ||
use crate::matchers::call::CallInstMatcher; | ||
|
||
#[inline(always)] | ||
pub fn register_call_inst_matchers_functions(map: &mut HashMap<&'static str, StandardFunction>) { | ||
map.insert("m_call", match_call_inst); | ||
} | ||
|
||
#[inline(always)] | ||
pub fn register_call_inst_matchers_function_signatures(map: &mut HashMap<&'static str, Signature>) { | ||
map.insert("m_call", Signature::with_return(Box::new(InstMatcherType))); | ||
} | ||
|
||
fn match_call_inst(_values: &[Box<dyn Value>]) -> Box<dyn Value> { | ||
let matcher = Box::new(CallInstMatcher::create_call()); | ||
Box::new(InstMatcherValue { matcher }) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
pub mod arithmetic; | ||
pub mod binary; | ||
pub mod call; | ||
pub mod combine; | ||
pub mod constants; | ||
pub mod exception; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use inkwell::llvm_sys::core::LLVMGetInstructionOpcode; | ||
use inkwell::llvm_sys::prelude::LLVMValueRef; | ||
use inkwell::llvm_sys::LLVMOpcode; | ||
|
||
use super::InstMatcher; | ||
|
||
#[derive(Clone)] | ||
pub struct CallInstMatcher; | ||
|
||
impl CallInstMatcher { | ||
pub fn create_call() -> Self { | ||
CallInstMatcher | ||
} | ||
} | ||
|
||
impl InstMatcher for CallInstMatcher { | ||
#[allow(clippy::not_unsafe_ptr_arg_deref)] | ||
fn is_match(&self, instruction: LLVMValueRef) -> bool { | ||
unsafe { LLVMGetInstructionOpcode(instruction) == LLVMOpcode::LLVMCall } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters