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