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.dcr; 11 12 import dextool.plugin.mutate.backend.type; 13 import dextool.plugin.mutate.backend.analyze.ast; 14 import dextool.plugin.mutate.backend.mutation_type.dcc : dccBranchMutationsRaw; 15 16 immutable Mutation.Kind[] dcrCaseMutationsRaw; 17 18 Mutation.Kind[] dcrMutations(Kind operator) @safe pure nothrow { 19 typeof(return) rval; 20 21 // an operator is a predicate, leaf. 22 // the condition is obviously the top node. 23 switch (operator) with (Mutation.Kind) { 24 case Kind.Call: 25 goto case; 26 case Kind.Expr: 27 // replace the functions body with return true/false; 28 goto case; 29 case Kind.OpAnd: 30 goto case; 31 case Kind.OpOr: 32 goto case; 33 case Kind.OpLess: 34 goto case; 35 case Kind.OpGreater: 36 goto case; 37 case Kind.OpLessEq: 38 goto case; 39 case Kind.OpGreaterEq: 40 goto case; 41 case Kind.OpEqual: 42 goto case; 43 case Kind.OpNotEqual: 44 goto case; 45 case Kind.Condition: 46 rval = [dccTrue, dccFalse]; 47 break; 48 case Kind.Branch: 49 rval = [dcrCaseDel]; 50 break; 51 default: 52 } 53 54 return rval; 55 } 56 57 immutable Mutation.Kind[] dcrMutationsAll; 58 59 shared static this() { 60 with (Mutation.Kind) { 61 dcrCaseMutationsRaw = [dcrCaseDel]; 62 } 63 dcrMutationsAll = dccBranchMutationsRaw ~ dcrCaseMutationsRaw; 64 }