Skip to content

Commit 085e1dd

Browse files
nicolasstuckibiboudis
authored andcommitted
Interpret varargs
1 parent 18d4ca8 commit 085e1dd

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
8888
def interpretIsInstanceOf(o: AbstractAny, tpt: TypeTree): Result
8989
def interpretAsInstanceOf(o: AbstractAny, tpt: TypeTree): Result
9090

91+
def interpretRepeated(elems: List[AbstractAny]): AbstractAny
92+
9193
def interpretEqEq(x: AbstractAny, y: AbstractAny): AbstractAny
9294

9395
def interpretPrivitiveLt(x: AbstractAny, y: AbstractAny): AbstractAny
@@ -148,6 +150,7 @@ abstract class TreeInterpreter[R <: Reflection & Singleton](val reflect: R) {
148150
case Term.Block(stats, expr) => log("interpretBlock", tree)(interpretBlock(stats, expr))
149151
case Term.Literal(const) => log("interpretLiteral", tree)(interpretLiteral(const))
150152
case Term.Typed(expr, _) => log("<interpretTyped>", tree)(eval(expr))
153+
case Term.Repeated(elems, _) => log("<interpretRepeated>", tree)(interpretRepeated(elems.map(elem => eval(elem))))
151154

152155
case _ => throw new MatchError(tree.show)
153156
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class Interpreter[R <: Reflection & Singleton](reflect0: R) extends TreeInterpre
9797
def interpretAsInstanceOf(o: AbstractAny, tpt: TypeTree): Result =
9898
jvmReflection.getClassOf(tpt.symbol).cast(o)
9999

100+
def interpretRepeated(elems: List[AbstractAny]): AbstractAny = elems.toSeq
101+
100102
def interpretEqEq(x: AbstractAny, y: AbstractAny): AbstractAny = x == y
101103

102104
def interpretPrivitiveLt(x: AbstractAny, y: AbstractAny): AbstractAny = withNumeric(x, y)(_.lt(_, _))

0 commit comments

Comments
 (0)