File tree Expand file tree Collapse file tree 2 files changed +17
-12
lines changed
tests/run-with-compiler-custom-args/tasty-interpreter/interpreter Expand file tree Collapse file tree 2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,22 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
2323 def withLocalValues [T ](syms : List [Symbol ], values : List [LocalValue ])(in : implicit Env => T )(implicit env : Env ): T =
2424 in(env ++ syms.zip(values))
2525
26+ def interpretCall (instance : AbstractAny , sym : DefSymbol , args : List [AbstractAny ]): Result = {
27+ // TODO
28+ // withLocalValue(`this`, instance) {
29+ val syms = sym.tree.paramss.headOption.getOrElse(Nil ).map(_.symbol)
30+ withLocalValues(syms, args.map(LocalValue .valFrom(_))) {
31+ eval(sym.tree.rhs.get)
32+ }
33+ // }
34+ }
35+
2636 def interpretCall (fn : Term , argss : List [List [Term ]]): Result = {
27- val env0 = fn match {
28- case Term .Select (prefix, _) =>
29- val pre = eval(prefix)
30- implicitly[ Env ] // FIXME add pre to the env as `this`
31- case _ => implicitly[ Env ]
37+ fn match {
38+ case Term .Select (prefix, _) =>
39+ val pre = eval (prefix)
40+ // TODO use
41+ case _ =>
3242 }
3343 val evaluatedArgs = argss.flatten.map(arg => LocalValue .valFrom(eval(arg)))
3444 val IsDefSymbol (sym) = fn.symbol
Original file line number Diff line number Diff line change @@ -31,15 +31,10 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre
3131 val symbol = sym.methods.find(_.name == method.getName).get
3232
3333 if (symbol.isDefinedInCurrentRun) {
34- // TODO use `super.interpretCall(...)`
34+ val argsList = if (args == null ) Nil else args.toList
3535 symbol match {
3636 case IsDefSymbol (symbol) =>
37- val args1 = if (args == null ) Nil else args.toList
38- val evaluatedArgs = args1.map(arg => LocalValue .valFrom(arg))
39- val syms = symbol.tree.paramss.headOption.getOrElse(Nil ).map(_.symbol)
40- withLocalValues(syms, evaluatedArgs) {
41- eval(symbol.tree.rhs.get).asInstanceOf [Object ]
42- }
37+ interpretCall(this , symbol, argsList).asInstanceOf [Object ]
4338 }
4439 }
4540 else {
You can’t perform that action at this time.
0 commit comments