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.lcrb;
11 
12 import std.algorithm : filter;
13 
14 import dextool.plugin.mutate.backend.type;
15 import dextool.clang_extensions : OpKind;
16 
17 auto lcrbMutations(Mutation.Kind is_a) @safe pure nothrow {
18     return lcrbMutationsAll.filter!(a => a != is_a);
19 }
20 
21 auto lcrbAssignMutations(Mutation.Kind is_a) @safe pure nothrow {
22     return lcrbAssignMutationsAll.filter!(a => a != is_a);
23 }
24 
25 immutable Mutation.Kind[OpKind] isLcrb;
26 immutable Mutation.Kind[OpKind] isLcrbAssign;
27 
28 immutable Mutation.Kind[] lcrbMutationsAll;
29 immutable Mutation.Kind[] lcrbAssignMutationsAll;
30 
31 shared static this() {
32     // dfmt off
33     with (OpKind) {
34     isLcrb = [
35         And : Mutation.Kind.lcrbAnd, // "&"
36         Or : Mutation.Kind.lcrbOr, // "|"
37         OO_Amp : Mutation.Kind.lcrbAnd, // "&"
38         OO_Pipe : Mutation.Kind.lcrbOr, // "|"
39     ];
40 
41     isLcrbAssign = [
42         AndAssign : Mutation.Kind.lcrbAndAssign,
43         OrAssign : Mutation.Kind.lcrbOrAssign,
44         OO_AmpEqual : Mutation.Kind.lcrbAndAssign,
45         OO_PipeEqual : Mutation.Kind.lcrbOrAssign,
46     ];
47     }
48     // dfmt on
49 
50     with (Mutation.Kind) {
51         lcrbMutationsAll = [lcrbAnd, lcrbOr];
52         lcrbAssignMutationsAll = [lcrbOrAssign, lcrbAndAssign];
53     }
54 }