# HG changeset patch # User Mike Pavone # Date 1376189660 25200 # Node ID 2b5357b13e2df95f2411f35ca0d1a5b8c4df2974 # Parent 3690601c8c70713341768462e8bbb3f570750b62 Initial work on solver diff -r 3690601c8c70 -r 2b5357b13e2d src/solver.tp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/solver.tp Sat Aug 10 19:54:20 2013 -0700 @@ -0,0 +1,44 @@ +#{ + classify <- :prog trees { + testvals <- #[] + i <- 0 + (os srand: (os time)) + while: {i < 256} do: { + i <- i + 1 + testvals append: (uint64: (os rand64)) + } + root <- dict linear + foreach: trees :idx tree { + prog root!: tree + res <- prog run: (testvals get: 0) + arr <- root get: res withDefault: #[] + arr append: tree + if: (arr length) = 1 { + root set: res arr + } + } + #{ + inputs <- { testvals } + valmap <- { root } + } + } + + main <- :args { + size <- 3 + if: (args length) > 1 { + size <- int32: (args get: 1) + } + prog <- bv program + if: size >= 2 { + trees <- (prog allOfSize: size) + if: (args length) > 2 { + ops <- (args get: 2) splitOn: "," + trees <- prog filterTrees: trees ops + } + info <- classify: prog trees + foreach: (info valmap) :val arr { + print: "Value: 0x" . (hex: val) ." produced by " . (string: (arr length)) . "programs\n" + } + } + } +}