Skip to content

Commit

Permalink
Fix new tests after merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala
#	tests/run-with-compiler-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala
  • Loading branch information
odersky committed Jan 30, 2019
1 parent 262d5f9 commit 08c3e81
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class CodeTester(projects: List[Project]) {

private def doAction(action: Action): this.type = {
try {
action.execute() with (testServer, testServer.client, positions)
action.execute() given (testServer, testServer.client, positions)
} catch {
case ex: AssertionError =>
val sourcesStr =
Expand All @@ -252,7 +252,7 @@ class CodeTester(projects: List[Project]) {
|
|$sourcesStr
|
|while executing action: ${action.show with positions}
|while executing action: ${action.show given positions}
|
""".stripMargin
val assertionError = new AssertionError(msg + ex.getMessage)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class TastyInterpreter extends TastyConsumer {
case DefDef("main", _, _, _, Some(rhs)) =>
val interpreter = new jvm.Interpreter(reflect)

interpreter.eval(rhs) with Map.empty
interpreter.eval(rhs) given Map.empty
// TODO: recurse only for PackageDef, ClassDef
case tree =>
super.traverseTree(tree)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
/** Representation of objects and values in the interpreter */
type AbstractAny

type Result = Env |=> AbstractAny
type Result = given Env => AbstractAny

def localValue(sym: Symbol)(implicit env: Env): LocalValue = env(sym)

def withLocalValue[T](sym: Symbol, value: LocalValue)(in: Env |=> T)(implicit env: Env): T =
in with env.updated(sym, value)
def withLocalValue[T](sym: Symbol, value: LocalValue)(in: given Env => T)(implicit env: Env): T =
in given env.updated(sym, value)

def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: Env |=> T)(implicit env: Env): T =
in with (env ++ syms.zip(values))
def withLocalValues[T](syms: List[Symbol], values: List[LocalValue])(in: given Env => T)(implicit env: Env): T =
in given (env ++ syms.zip(values))

def interpretCall(inst: AbstractAny, sym: DefSymbol, args: List[AbstractAny]): Result = {
// TODO
Expand Down Expand Up @@ -65,7 +65,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
def interpretBlock(stats: List[Statement], expr: Term): Result = {
val newEnv = stats.foldLeft(implicitly[Env])((accEnv, stat) => stat match {
case ValDef(name, tpt, Some(rhs)) =>
def evalRhs = eval(rhs) with accEnv
def evalRhs = eval(rhs) given accEnv
val evalRef: LocalValue =
if (stat.symbol.flags.is(Flags.Lazy)) LocalValue.lazyValFrom(evalRhs)
else if (stat.symbol.flags.is(Flags.Mutable)) LocalValue.varFrom(evalRhs)
Expand All @@ -76,10 +76,10 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
// TODO: record the environment for closure purposes
accEnv
case stat =>
eval(stat) with accEnv
eval(stat) given accEnv
accEnv
})
eval(expr) with newEnv
eval(expr) given newEnv
}

def interpretUnit(): AbstractAny
Expand Down

0 comments on commit 08c3e81

Please sign in to comment.