Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import z3.scala.{Z3Solver, Z3AST}
* Created by radu on 3/24/15.
*/
case class ConstantValue(value: Long) extends Expression with FloatingExpression {
lazy val ast = Z3Util.z3Context.mkInt(value.asInstanceOf[Int], Z3Util.defaultSort)
lazy val ast = Z3Util.z3Context.mkNumeral(value.toString, Z3Util.defaultSort)

override def toZ3(solver: Option[Z3Solver] = None): (Z3AST, Option[Z3Solver]) = (ast, solver)

Expand All @@ -26,7 +26,7 @@ case class ConstantValue(value: Long) extends Expression with FloatingExpression
}

case class ConstantBitVector(value: Long) extends Expression with FloatingExpression {
lazy val ast = Z3Util.z3Context.mkInt(value.asInstanceOf[Int], Z3Util.bv32Sort)
lazy val ast = Z3Util.z3Context.mkNumeral(value.toString, Z3Util.bv32Sort)

override def toZ3(solver: Option[Z3Solver] = None): (Z3AST, Option[Z3Solver]) = (ast, solver)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ case class InstructionBlock(instructions: Iterable[Instruction]) extends Instruc
* @param s
* @return
*/
override def apply(s: State, v: Boolean): (List[State], List[State]) =
override def apply(s: State, v: Boolean): (List[State], List[State]) = {
val initialHistory = s.history

instructions.foldLeft((List(s), Nil: List[State])) { (acc, i) => {
val (valid: List[State], failed: List[State]) = acc
val (nextValid, nextFailed) = valid.map(i(_, v)).unzip
val allValid = nextValid.foldLeft(Nil: List[State])(_ ++ _)
val allFailed = nextFailed.foldLeft(failed: List[State])(_ ++ _)
val (valid, failed) = acc
val (forwarded, notForwarded) = valid.partition(_.history != s.history)
val (nextValid, nextFailed) = notForwarded.map(i(_, v)).unzip
val allValid = nextValid.foldLeft(forwarded)(_ ++ _)
val allFailed = nextFailed.foldLeft(failed)(_ ++ _)
(allValid, allFailed)
}
}
}
}

object InstructionBlock {
Expand Down