Skip to content

Commit a0d5147

Browse files
committed
Update implementation of tasty-interpreter
Now that the inspector provides the quote context, the interpreter can also use it
1 parent a05fc4b commit a0d5147

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

tests/run-custom-args/tasty-interpreter/interpreter/TastyInterpreter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class TastyInterpreter extends TastyInspector {
1212
override def traverseTree(tree: Tree)(implicit ctx: Context): Unit = tree match {
1313
// TODO: check the correct sig and object enclosement for main
1414
case DefDef("main", _, _, _, Some(rhs)) =>
15-
val interpreter = new jvm.Interpreter(this.reflect)
15+
val interpreter = new jvm.Interpreter
1616

1717
interpreter.eval(rhs)(using Map.empty)
1818
// TODO: recurse only for PackageDef, ClassDef

tests/run-custom-args/tasty-interpreter/interpreter/TreeInterpreter.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
package scala.tasty.interpreter
22

3+
import scala.quoted._
34
import scala.tasty.interpreter.jvm.JVMReflection
45
import scala.tasty.Reflection
56

6-
abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
7-
import reflect.{_, given _}
7+
abstract class TreeInterpreter[QCtx <: QuoteContext & Singleton](using val qctx: QCtx) {
8+
import qctx.tasty._
89

910
final val LOG = false
1011

tests/run-custom-args/tasty-interpreter/interpreter/jvm/Interpreter.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package scala.tasty.interpreter
22
package jvm
33

4+
import scala.quoted._
45
import scala.tasty.interpreter.jvm.JVMReflection
56
import scala.tasty.Reflection
67

7-
class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpreter[R](reflect0) {
8-
import reflect.{_, given _}
8+
class Interpreter[QCtx <: QuoteContext & Singleton](using qctx0: QCtx) extends TreeInterpreter[QCtx] {
9+
import qctx.tasty._
910

1011
// All references are represented by themselves and values are boxed
1112
type AbstractAny = Any
1213

13-
val jvmReflection = new JVMReflection(reflect)
14+
val jvmReflection = new JVMReflection(using qctx)
1415

1516
def interpretNew(fn: Tree, argss: List[List[Term]]): Result = {
1617
if (fn.symbol.isDefinedInCurrentRun) {

tests/run-custom-args/tasty-interpreter/interpreter/jvm/JVMReflection.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package scala.tasty.interpreter.jvm
22

3+
import scala.quoted._
34
import scala.tasty.Reflection
45

5-
class JVMReflection[R <: Reflection & Singleton](val reflect: R) {
6-
import reflect.{_, given _}
6+
class JVMReflection[QCtx <: QuoteContext & Singleton](using val tasty: QCtx) {
7+
import qctx.tasty._
8+
79
import java.lang.reflect.{InvocationTargetException, Method}
810
private val classLoader: ClassLoader = getClass.getClassLoader
911

0 commit comments

Comments
 (0)