"); foreach (c; e.children) dump(c); buf.put(""); } else { buf.put(""); dumpText(e.head); foreach (c; e.children) dump(c); dumpText(e.tail); buf.put(""); } } buf.put(q"EOT EOT"); dump(root); std.file.write(fn, buf.data()); } void dumpToJson(Entity root, string fn) { import std.json : JSONValue; bool[const(Address)*] needLabel; void scan(Entity e, const(Address)* addr) { foreach (dependent; e.dependents) { assert(dependent.address); needLabel[dependent.address] = true; } foreach (i, child; e.children) scan(child, addr.child(i)); } scan(root, &rootAddress); JSONValue toJson(Entity e, const(Address)* addr) { JSONValue[string] o; if (e.isFile) o["filename"] = e.filename; if (e.head.length) o["head"] = e.head; if (e.children.length) o["children"] = e.children.length.iota.map!(i => toJson(e.children[i], addr.child(i)) ).array; if (e.tail.length) o["tail"] = e.tail; if (e.noRemove) o["noRemove"] = true; if (addr in needLabel) o["label"] = e.id.to!string; if (e.dependents.length) o["dependents"] = e.dependents.map!((ref dependent) => root.findEntity(dependent.address).entity.id.to!string ).array; return JSONValue(o); } auto jsonDoc = JSONValue([ "version" : JSONValue(1), "root" : toJson(root, &rootAddress), ]); std.file.write(fn, jsonDoc.toPrettyString()); } // void dumpText(string fn, ref Reduction r = nullReduction) // { // auto f = File(fn, "wt"); // dump(root, r, (string) {}, &f.write!string); // f.close(); // } version(testsuite) shared static this() { import core.runtime; "../../cov".mkdir.collectException(); dmd_coverDestPath("../../cov"); dmd_coverSetMerge(true); } DustMite-0.0.430/polyhash.d 0000664 0000000 0000000 00000021746 14134264103 0015420 0 ustar 00root root 0000000 0000000 /// Polynomial hash for partial rehashing. /// http://stackoverflow.com/a/42112687/21501 /// Written by Vladimir Panteleev
int f(int i)
{
if (i > -1 && i < 1)
{
return 0;
}
return i * i;
}
void main()
{
assert(f(5) == 30);
}