Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
mio-19 committed Dec 4, 2024
1 parent 3fe48ae commit 8ab15b5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
10 changes: 7 additions & 3 deletions interpreter/shared/src/main/scala/chester/eval/Eval.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package chester.eval

import chester.runtime.Value
import chester.syntax.core.TermT
import chester.syntax.core.*

case class EvalContext()

object Eval {
def evalNoEffect[T<:TermT[T]](ctx: EvalContext, code: T): Value = ???
case class Eval[Term<:TermT[Term]]() {
type BooleanTerm = BooleanTermC[Term]
def evalNoEffect(ctx: EvalContext, code: Term): Value = code match {
case b: BooleanTerm => Value(b.value)
case _ => ???
}
}
8 changes: 6 additions & 2 deletions interpreter/shared/src/main/scala/chester/runtime/Value.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import spire.math.Rational
import scala.collection.immutable.HashMap
import scala.language.implicitConversions

opaque type Value = Vector[Any] | Int | BigInt | String | Symbol | HashMap[Any, Any] | Rational | Double | Function[Any, Any]
type OpenValue = Vector[Value] | Int | BigInt | String | Symbol | HashMap[Value, Value] | Rational | Double | Function[Vector[Value], Value]
opaque type Value = Vector[Any] | Boolean | Int | BigInt | String | Symbol | HashMap[Any, Any] | Rational | Double | Function[Any, Any]
type OpenValue = Vector[Value] | Boolean |Int | BigInt | String | Symbol | HashMap[Value, Value] | Rational | Double | Function[Vector[Value], Value]

inline implicit def viewValue(x: Value): OpenValue = x.asInstanceOf[OpenValue]

inline implicit def packValue(x: OpenValue): Value = x.asInstanceOf[Value]

inline def Value(x: OpenValue | Value): Value = x.asInstanceOf[Value]

0 comments on commit 8ab15b5

Please sign in to comment.