1 /** 2 Copyright: Copyright (c) 2017, 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.utility; 11 12 import std.algorithm : filter; 13 14 import dextool.type : Path, AbsolutePath; 15 16 public import dextool.plugin.mutate.backend.type; 17 public import dextool.plugin.mutate.backend.mutation_type; 18 public import dextool.clang_extensions : OpKind; 19 20 Path trustedRelativePath(string p, AbsolutePath root) @trusted { 21 import std.path : relativePath; 22 23 return relativePath(p, root).Path; 24 } 25 26 /** 27 * trusted: void[] is perfectly representable as ubyte[] accoding to the specification. 28 */ 29 Checksum checksum(const(ubyte)[] a) @safe { 30 import dextool.hash : makeMurmur3; 31 32 return makeMurmur3(a); 33 } 34 35 /// Package the values to a checksum. 36 Checksum ckecksum(T)(const(T[2]) a) @safe if (T.sizeof == 8) { 37 return Checksum(cast(ulong) a[0], cast(ulong) a[1]); 38 } 39 40 /// Package the values to a checksum. 41 Checksum checksum(T)(const T a, const T b) @safe if (T.sizeof == 8) { 42 return Checksum(cast(ulong) a, cast(ulong) b); 43 }