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.cor;
11 
12 import dextool.plugin.mutate.backend.type;
13 import dextool.clang_extensions : OpKind;
14 
15 /// What the operator should be replaced by.
16 auto corOpMutations(Mutation.Kind is_a) @safe pure nothrow {
17     if (is_a == Mutation.Kind.corAnd) {
18         return [Mutation.Kind.corEQ];
19     } else if (is_a == Mutation.Kind.corOr) {
20         return [Mutation.Kind.corNE];
21     }
22 
23     return null;
24 }
25 
26 /// What the expression should be replaced by.
27 auto corExprMutations(Mutation.Kind is_a) @safe pure nothrow {
28     if (is_a == Mutation.Kind.corAnd) {
29         return [Mutation.Kind.corFalse];
30     } else if (is_a == Mutation.Kind.corOr) {
31         return [Mutation.Kind.corTrue];
32     }
33 
34     return null;
35 }
36 
37 immutable Mutation.Kind[OpKind] isCor;
38 immutable Mutation.Kind[] corMutationsRaw;
39 
40 shared static this() {
41     // dfmt off
42     with (OpKind) {
43     isCor = cast(immutable)
44         [
45         LAnd: Mutation.Kind.corAnd, // "&&"
46         LOr: Mutation.Kind.corOr, // "||"
47         OO_AmpAmp: Mutation.Kind.corAnd, // "&&"
48         OO_PipePipe: Mutation.Kind.corOr, // "||"
49         ];
50     }
51     // dfmt on
52 
53     with (Mutation.Kind) {
54         corMutationsRaw = [corFalse, corLhs, corRhs, corEQ, corNE, corTrue];
55     }
56 }