1 /**
2 Copyright: Copyright (c) 2018, Joakim Brännström. All rights reserved.
3 License: MPL-2
4 Author: Joakim Brännström (joakim.brannstrom@gmx.com)
5 
6 This Source Code Form is subject to the terms of the Mozilla Public License,
7 v.2.0. If a copy of the MPL was not distributed with this file, You can obtain
8 one at http://mozilla.org/MPL/2.0/.
9 */
10 module dextool.plugin.mutate.backend.mutation_type.aor;
11 
12 import std.algorithm : filter;
13 
14 import dextool.plugin.mutate.backend.type;
15 import dextool.clang_extensions : OpKind;
16 
17 auto aorMutations(Mutation.Kind is_a) @safe pure nothrow {
18     return aorMutationsAll.filter!(a => a != is_a);
19 }
20 
21 auto aorAssignMutations(Mutation.Kind is_a) @safe pure nothrow {
22     return aorAssignMutationsAll.filter!(a => a != is_a);
23 }
24 
25 immutable Mutation.Kind[OpKind] isAor;
26 immutable Mutation.Kind[OpKind] isAorAssign;
27 
28 immutable Mutation.Kind[] aorMutationsAll;
29 immutable Mutation.Kind[] aorAssignMutationsAll;
30 shared static this() {
31     // dfmt off
32     with (OpKind) {
33     isAor = cast(immutable)
34         [
35         Mul: Mutation.Kind.aorMul, // "*"
36         Div: Mutation.Kind.aorDiv, // "/"
37         Rem: Mutation.Kind.aorRem, // "%"
38         Add: Mutation.Kind.aorAdd, // "+"
39         Sub: Mutation.Kind.aorSub, // "-"
40         OO_Plus: Mutation.Kind.aorAdd, // "+"
41         OO_Minus: Mutation.Kind.aorSub, // "-"
42         OO_Star: Mutation.Kind.aorMul, // "*"
43         OO_Slash: Mutation.Kind.aorDiv, // "/"
44         OO_Percent: Mutation.Kind.aorRem, // "%"
45         ];
46 
47     isAorAssign = cast(immutable)
48         [
49         MulAssign: Mutation.Kind.aorMulAssign, // "*="
50         DivAssign: Mutation.Kind.aorDivAssign, // "/="
51         RemAssign: Mutation.Kind.aorRemAssign, // "%="
52         AddAssign: Mutation.Kind.aorAddAssign, // "+="
53         SubAssign: Mutation.Kind.aorSubAssign, // "-="
54         OO_PlusEqual: Mutation.Kind.aorAddAssign, // "+="
55         OO_MinusEqual: Mutation.Kind.aorSubAssign, // "-="
56         OO_StarEqual: Mutation.Kind.aorMulAssign, // "*="
57         OO_SlashEqual: Mutation.Kind.aorDivAssign, // "/="
58         OO_PercentEqual: Mutation.Kind.aorRemAssign, // "%="
59         ];
60     }
61     // dfmt on
62 
63     with (Mutation.Kind) {
64         aorMutationsAll = [aorMul, aorDiv, aorRem, aorAdd, aorSub,];
65         aorAssignMutationsAll = [aorMulAssign, aorDivAssign, aorRemAssign,
66             aorAddAssign, aorSubAssign,];
67     }
68 }