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) {
23
23
def withLocalValues [T ](syms : List [Symbol ], values : List [LocalValue ])(in : implicit Env => T )(implicit env : Env ): T =
24
24
in(env ++ syms.zip(values))
25
25
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
+
26
36
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 _ =>
32
42
}
33
43
val evaluatedArgs = argss.flatten.map(arg => LocalValue .valFrom(eval(arg)))
34
44
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
31
31
val symbol = sym.methods.find(_.name == method.getName).get
32
32
33
33
if (symbol.isDefinedInCurrentRun) {
34
- // TODO use `super.interpretCall(...)`
34
+ val argsList = if (args == null ) Nil else args.toList
35
35
symbol match {
36
36
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 ]
43
38
}
44
39
}
45
40
else {
You can’t perform that action at this time.
0 commit comments