rename to Quoted
This commit is contained in:
parent
c8d9fe333e
commit
475896f27e
1 changed files with 7 additions and 7 deletions
|
@ -8,12 +8,12 @@ import scala.compiletime.*
|
||||||
import scala.compiletime.ops.string.*
|
import scala.compiletime.ops.string.*
|
||||||
import scala.collection.immutable.{Map => IMap}
|
import scala.collection.immutable.{Map => IMap}
|
||||||
|
|
||||||
sealed trait Dsl {
|
sealed trait Quoted {
|
||||||
def ast: Ast
|
def ast: Ast
|
||||||
def lifts: IMap[String, (Any, ParamEncoder[?])] = IMap.empty
|
def lifts: IMap[String, (Any, ParamEncoder[?])] = IMap.empty
|
||||||
}
|
}
|
||||||
|
|
||||||
trait Query[E] extends Dsl
|
trait Query[E] extends Quoted
|
||||||
|
|
||||||
case class EntityQuery[E](ast: Ast) extends Query[E]
|
case class EntityQuery[E](ast: Ast) extends Query[E]
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ extension [A1, A2, B](inline f1: (A1, A2) => B) {
|
||||||
private inline def body = parsing.parseBody(f1)
|
private inline def body = parsing.parseBody(f1)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline def transform[D1 <: Dsl, D2 <: Dsl, A, B](inline ast: Ast)(
|
private inline def transform[D1 <: Quoted, D2 <: Quoted, A, B](inline ast: Ast)(
|
||||||
inline f: A => B
|
inline f: A => B
|
||||||
)(inline fast: (Ast, Ident, Ast) => Ast)(inline f2: Ast => D2): D2 = {
|
)(inline fast: (Ast, Ident, Ast) => Ast)(inline f2: Ast => D2): D2 = {
|
||||||
f2(fast(ast, f.param0, f.body))
|
f2(fast(ast, f.param0, f.body))
|
||||||
|
@ -57,8 +57,8 @@ private given FromExpr[EntityQuery[?]] with {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private given FromExpr[Dsl] with {
|
private given FromExpr[Quoted] with {
|
||||||
def unapply(x: Expr[Dsl])(using Quotes): Option[Dsl] = {
|
def unapply(x: Expr[Quoted])(using Quotes): Option[Quoted] = {
|
||||||
import quotes.reflect.*
|
import quotes.reflect.*
|
||||||
x match {
|
x match {
|
||||||
case '{ ($x: EntityQuery[?]) } => x.value
|
case '{ ($x: EntityQuery[?]) } => x.value
|
||||||
|
@ -69,9 +69,9 @@ private given FromExpr[Dsl] with {
|
||||||
inline def query[E](inline table: String) =
|
inline def query[E](inline table: String) =
|
||||||
EntityQuery[E](Entity(table, Nil))
|
EntityQuery[E](Entity(table, Nil))
|
||||||
|
|
||||||
inline def compile(inline x: Dsl): Option[String] = ${ compileImpl('x) }
|
inline def compile(inline x: Quoted): Option[String] = ${ compileImpl('x) }
|
||||||
|
|
||||||
private def compileImpl(x: Expr[Dsl])(using Quotes): Expr[Option[String]] = {
|
private def compileImpl(x: Expr[Quoted])(using Quotes): Expr[Option[String]] = {
|
||||||
import quotes.reflect.*
|
import quotes.reflect.*
|
||||||
x.value match {
|
x.value match {
|
||||||
case Some(xv) => '{ Some(${ Expr(xv.ast.toString()) }) }
|
case Some(xv) => '{ Some(${ Expr(xv.ast.toString()) }) }
|
||||||
|
|
Loading…
Reference in a new issue