Skip to content

Commit e37da87

Browse files
committed
Improve the structure of Binary Matchers
1 parent 5e7a33a commit e37da87

6 files changed

Lines changed: 379 additions & 451 deletions

File tree

src/functions/matchers/arithmetic.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gitql_core::values::base::Value;
77
use crate::functions::binary_matcher_signature;
88
use crate::functions::binary_matchers_sides;
99
use crate::ir::values::InstMatcherValue;
10-
use crate::matchers::arithmetic::ArithmeticInstMatcher;
10+
use crate::matchers::binary::BinaryInstMatcher;
1111

1212
#[inline(always)]
1313
pub fn register_arithmetic_matchers_functions(map: &mut HashMap<&'static str, StandardFunction>) {
@@ -67,120 +67,120 @@ pub fn register_arithmetic_matchers_function_signatures(
6767

6868
fn match_add_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
6969
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
70-
let matcher = ArithmeticInstMatcher::create_add(lhs_matcher, rhs_matcher);
70+
let matcher = BinaryInstMatcher::create_add(lhs_matcher, rhs_matcher);
7171
Box::new(InstMatcherValue { matcher })
7272
}
7373

7474
fn match_sub_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
7575
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
76-
let matcher = ArithmeticInstMatcher::create_sub(lhs_matcher, rhs_matcher);
76+
let matcher = BinaryInstMatcher::create_sub(lhs_matcher, rhs_matcher);
7777
Box::new(InstMatcherValue { matcher })
7878
}
7979

8080
fn match_mul_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
8181
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
82-
let matcher = ArithmeticInstMatcher::create_mul(lhs_matcher, rhs_matcher);
82+
let matcher = BinaryInstMatcher::create_mul(lhs_matcher, rhs_matcher);
8383
Box::new(InstMatcherValue { matcher })
8484
}
8585

8686
fn match_div_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
8787
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
88-
let matcher = ArithmeticInstMatcher::create_div(lhs_matcher, rhs_matcher);
88+
let matcher = BinaryInstMatcher::create_div(lhs_matcher, rhs_matcher);
8989
Box::new(InstMatcherValue { matcher })
9090
}
9191

9292
fn match_rem_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
9393
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
94-
let matcher = ArithmeticInstMatcher::create_div(lhs_matcher, rhs_matcher);
94+
let matcher = BinaryInstMatcher::create_div(lhs_matcher, rhs_matcher);
9595
Box::new(InstMatcherValue { matcher })
9696
}
9797

9898
fn match_commutatively_add_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
9999
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
100-
let matcher = ArithmeticInstMatcher::create_commutatively_add(lhs_matcher, rhs_matcher);
100+
let matcher = BinaryInstMatcher::create_commutatively_add(lhs_matcher, rhs_matcher);
101101
Box::new(InstMatcherValue { matcher })
102102
}
103103

104104
fn match_commutatively_sub_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
105105
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
106-
let matcher = ArithmeticInstMatcher::create_commutatively_sub(lhs_matcher, rhs_matcher);
106+
let matcher = BinaryInstMatcher::create_commutatively_sub(lhs_matcher, rhs_matcher);
107107
Box::new(InstMatcherValue { matcher })
108108
}
109109

110110
fn match_commutatively_mul_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
111111
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
112-
let matcher = ArithmeticInstMatcher::create_commutatively_mul(lhs_matcher, rhs_matcher);
112+
let matcher = BinaryInstMatcher::create_commutatively_mul(lhs_matcher, rhs_matcher);
113113
Box::new(InstMatcherValue { matcher })
114114
}
115115

116116
fn match_commutatively_div_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
117117
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
118-
let matcher = ArithmeticInstMatcher::create_commutatively_div(lhs_matcher, rhs_matcher);
118+
let matcher = BinaryInstMatcher::create_commutatively_div(lhs_matcher, rhs_matcher);
119119
Box::new(InstMatcherValue { matcher })
120120
}
121121

122122
fn match_commutatively_rem_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
123123
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
124-
let matcher = ArithmeticInstMatcher::create_commutatively_rem(lhs_matcher, rhs_matcher);
124+
let matcher = BinaryInstMatcher::create_commutatively_rem(lhs_matcher, rhs_matcher);
125125
Box::new(InstMatcherValue { matcher })
126126
}
127127

128128
fn match_float_add_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
129129
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
130-
let matcher = ArithmeticInstMatcher::create_float_add(lhs_matcher, rhs_matcher);
130+
let matcher = BinaryInstMatcher::create_float_add(lhs_matcher, rhs_matcher);
131131
Box::new(InstMatcherValue { matcher })
132132
}
133133

134134
fn match_float_sub_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
135135
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
136-
let matcher = ArithmeticInstMatcher::create_float_sub(lhs_matcher, rhs_matcher);
136+
let matcher = BinaryInstMatcher::create_float_sub(lhs_matcher, rhs_matcher);
137137
Box::new(InstMatcherValue { matcher })
138138
}
139139

140140
fn match_float_mul_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
141141
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
142-
let matcher = ArithmeticInstMatcher::create_float_mul(lhs_matcher, rhs_matcher);
142+
let matcher = BinaryInstMatcher::create_float_mul(lhs_matcher, rhs_matcher);
143143
Box::new(InstMatcherValue { matcher })
144144
}
145145

146146
fn match_float_div_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
147147
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
148-
let matcher = ArithmeticInstMatcher::create_float_div(lhs_matcher, rhs_matcher);
148+
let matcher = BinaryInstMatcher::create_float_div(lhs_matcher, rhs_matcher);
149149
Box::new(InstMatcherValue { matcher })
150150
}
151151

152152
fn match_float_rem_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
153153
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
154-
let matcher = ArithmeticInstMatcher::create_float_div(lhs_matcher, rhs_matcher);
154+
let matcher = BinaryInstMatcher::create_float_div(lhs_matcher, rhs_matcher);
155155
Box::new(InstMatcherValue { matcher })
156156
}
157157

158158
fn match_commutatively_float_add_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
159159
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
160-
let matcher = ArithmeticInstMatcher::create_commutatively_float_add(lhs_matcher, rhs_matcher);
160+
let matcher = BinaryInstMatcher::create_commutatively_float_add(lhs_matcher, rhs_matcher);
161161
Box::new(InstMatcherValue { matcher })
162162
}
163163

164164
fn match_commutatively_float_sub_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
165165
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
166-
let matcher = ArithmeticInstMatcher::create_commutatively_float_sub(lhs_matcher, rhs_matcher);
166+
let matcher = BinaryInstMatcher::create_commutatively_float_sub(lhs_matcher, rhs_matcher);
167167
Box::new(InstMatcherValue { matcher })
168168
}
169169

170170
fn match_commutatively_float_mul_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
171171
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
172-
let matcher = ArithmeticInstMatcher::create_commutatively_float_mul(lhs_matcher, rhs_matcher);
172+
let matcher = BinaryInstMatcher::create_commutatively_float_mul(lhs_matcher, rhs_matcher);
173173
Box::new(InstMatcherValue { matcher })
174174
}
175175

176176
fn match_commutatively_float_div_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
177177
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
178-
let matcher = ArithmeticInstMatcher::create_commutatively_float_div(lhs_matcher, rhs_matcher);
178+
let matcher = BinaryInstMatcher::create_commutatively_float_div(lhs_matcher, rhs_matcher);
179179
Box::new(InstMatcherValue { matcher })
180180
}
181181

182182
fn match_commutatively_float_rem_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
183183
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
184-
let matcher = ArithmeticInstMatcher::create_commutatively_float_rem(lhs_matcher, rhs_matcher);
184+
let matcher = BinaryInstMatcher::create_commutatively_float_rem(lhs_matcher, rhs_matcher);
185185
Box::new(InstMatcherValue { matcher })
186186
}

src/functions/matchers/shifts.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use gitql_core::values::base::Value;
77
use crate::functions::binary_matcher_signature;
88
use crate::functions::binary_matchers_sides;
99
use crate::ir::values::InstMatcherValue;
10-
use crate::matchers::shifts::ShiftInstMatcher;
10+
use crate::matchers::binary::BinaryInstMatcher;
1111

1212
#[inline(always)]
1313
pub fn register_shift_matchers_functions(map: &mut HashMap<&'static str, StandardFunction>) {
@@ -33,36 +33,36 @@ pub fn register_shift_matchers_function_signatures(map: &mut HashMap<&'static st
3333

3434
fn match_shl_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
3535
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
36-
let matcher = ShiftInstMatcher::create_logical_shl(lhs_matcher, rhs_matcher);
36+
let matcher = BinaryInstMatcher::create_logical_shl(lhs_matcher, rhs_matcher);
3737
Box::new(InstMatcherValue { matcher })
3838
}
3939

4040
fn match_shr_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
4141
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
42-
let matcher = ShiftInstMatcher::create_logical_shr(lhs_matcher, rhs_matcher);
42+
let matcher = BinaryInstMatcher::create_logical_shr(lhs_matcher, rhs_matcher);
4343
Box::new(InstMatcherValue { matcher })
4444
}
4545

4646
fn match_arithmetic_shr_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
4747
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
48-
let matcher = ShiftInstMatcher::create_arithmetic_shr(lhs_matcher, rhs_matcher);
48+
let matcher = BinaryInstMatcher::create_arithmetic_shr(lhs_matcher, rhs_matcher);
4949
Box::new(InstMatcherValue { matcher })
5050
}
5151

5252
fn match_commutatively_shl_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
5353
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
54-
let matcher = ShiftInstMatcher::create_commutatively_logical_shl(lhs_matcher, rhs_matcher);
54+
let matcher = BinaryInstMatcher::create_commutatively_logical_shl(lhs_matcher, rhs_matcher);
5555
Box::new(InstMatcherValue { matcher })
5656
}
5757

5858
fn match_commutatively_shr_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
5959
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
60-
let matcher = ShiftInstMatcher::create_commutatively_logical_shr(lhs_matcher, rhs_matcher);
60+
let matcher = BinaryInstMatcher::create_commutatively_logical_shr(lhs_matcher, rhs_matcher);
6161
Box::new(InstMatcherValue { matcher })
6262
}
6363

6464
fn match_commutatively_arithmetic_shr_inst(values: &[Box<dyn Value>]) -> Box<dyn Value> {
6565
let (lhs_matcher, rhs_matcher) = binary_matchers_sides(values);
66-
let matcher = ShiftInstMatcher::create_commutatively_arithmetic_shr(lhs_matcher, rhs_matcher);
66+
let matcher = BinaryInstMatcher::create_commutatively_arithmetic_shr(lhs_matcher, rhs_matcher);
6767
Box::new(InstMatcherValue { matcher })
6868
}

0 commit comments

Comments
 (0)