Skip to content

Commit a29d5a5

Browse files
committed
Merge branch 'scoot-generalized' into scoot-abstract
2 parents 0c93d7c + 2dfc191 commit a29d5a5

4 files changed

Lines changed: 19 additions & 3 deletions

File tree

src/main/scala/edu/colorado/plv/cuanto/scoot/interpreter/control/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import soot.toolkits.graph.UnitGraph
66

77
import expression.Env
88

9+
/** Interpret soot Units that affect control-flow */
910
package object control {
1011

12+
/** Find the next Unit, given an environment */
1113
def succ(graph: UnitGraph)(env: Env, unit: SootUnit):
1214
Option[SootUnit] = ???
1315

src/main/scala/edu/colorado/plv/cuanto/scoot/interpreter/expression/Arithmetic.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import soot.jimple._
77
import domains._
88
import domains.IntDom
99

10+
/** Sub-interpreter for arithmetic nodes */
1011
object Arithmetic {
1112

12-
def omerge[A,B](t: (Option[A],Option[B])): Option[(A,B)] =
13+
private def omerge[A,B](t: (Option[A],Option[B])): Option[(A,B)] =
1314
for (a <- t._1; b <- t._2) yield (a,b)
1415

1516

17+
/** Interpret an arithmetic operator node */
1618
def interpNode(v: Value)(r: Value => Option[RFun]):
1719
Option[RFun] = v match {
1820
// case v: Local => env get v

src/main/scala/edu/colorado/plv/cuanto/scoot/interpreter/expression/package.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,34 @@ import soot._
66

77
import scoot.domains._
88

9+
/** Interpreter for expressions (soot Values). This depends on
10+
* expression evaluation not having side-effects.
11+
*/
912
package object expression {
13+
/** A sum type of possible types that an expression can evaluate to */
1014
type R = Result[IntDom]
15+
16+
/** Evaluation environment */
1117
type Env = Map[String,R]
1218
type RFun = Env => Option[R]
1319

20+
/** The empty environment */
1421
val emptyEnv: Env = new HashMap[String,R]()
1522

23+
/** Interpret a value under a particular environment */
1624
def interpret(v: Value, env: Env = emptyEnv): Option[R] = (for {
1725
rfun <- interpR(v)
1826
} yield rfun(env)).flatten
1927

20-
def interpR(v: Value): Option[RFun] =
28+
private def interpR(v: Value): Option[RFun] =
2129
anyOf(Seq(Arithmetic.interpNode(v)(interpR), Locals.interpNode(v)(interpR)))
2230

23-
def anyOf(is: Traversable[Option[RFun]]): Option[RFun] =
31+
private def anyOf(is: Traversable[Option[RFun]]): Option[RFun] =
2432
is.flatten.headOption
2533

34+
/** Sub-interpreter for looking up Local values in the environment */
2635
object Locals {
36+
/** Interpret a Local node */
2737
def interpNode(v: Value)(r: Value => Option[RFun]):
2838
Option[RFun] = v match {
2939
case v: Local => Some(_ get v.getName())

src/main/scala/edu/colorado/plv/cuanto/scoot/interpreter/mutation/package.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import soot.jimple._
66

77
import expression._
88

9+
/** Interpreter for soot Units that modify the evaluation
10+
* environment */
911
package object mutation {
1012

1113
private def some[A](a: A): Option[A] = Some(a)

0 commit comments

Comments
 (0)