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.lcr; 11 12 import std.typecons : Tuple; 13 14 import dextool.plugin.mutate.backend.type; 15 16 import dextool.plugin.mutate.backend.analyze.ast; 17 18 auto lcrMutations(Kind operator) { 19 alias Rval = Tuple!(Mutation.Kind[], "op", Mutation.Kind[], "expr", 20 Mutation.Kind[], "lhs", Mutation.Kind[], "rhs"); 21 Rval rval; 22 23 switch (operator) with (Mutation.Kind) { 24 case Kind.OpAnd: 25 rval = Rval([lcrOr], [lcrTrue, lcrFalse], null, null); 26 break; 27 case Kind.OpOr: 28 rval = Rval([lcrAnd], [lcrTrue, lcrFalse], null, null); 29 break; 30 // TODO: add assign 31 case Kind.OpAndBitwise: 32 rval = Rval([lcrbOr], null, [lcrbLhs], [lcrbRhs]); 33 break; 34 case Kind.OpOrBitwise: 35 rval = Rval([lcrbAnd], null, [lcrbLhs], [lcrbRhs]); 36 break; 37 case Kind.OpAssignAndBitwise: 38 rval = Rval([lcrbOrAssign], null, null, null); 39 break; 40 case Kind.OpAssignOrBitwise: 41 rval = Rval([lcrbAndAssign], null, null, null); 42 break; 43 default: 44 } 45 46 return rval; 47 } 48 49 immutable Mutation.Kind[] lcrMutationsAll; 50 51 shared static this() { 52 with (Mutation.Kind) { 53 lcrMutationsAll = [ 54 lcrAnd, lcrOr, lcrLhs, lcrRhs, lcrTrue, lcrFalse, lcrbAnd, lcrbOr, 55 lcrbLhs, lcrbRhs 56 ]; 57 } 58 }