From 475896f27e7b6958f377175459fddc32bfcb8bf3 Mon Sep 17 00:00:00 2001 From: jilen Date: Thu, 12 Dec 2024 15:37:14 +0800 Subject: [PATCH] rename to Quoted --- src/main/scala/minisql/dsl.scala | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/scala/minisql/dsl.scala b/src/main/scala/minisql/dsl.scala index 76b6d09..c566cf3 100644 --- a/src/main/scala/minisql/dsl.scala +++ b/src/main/scala/minisql/dsl.scala @@ -8,12 +8,12 @@ import scala.compiletime.* import scala.compiletime.ops.string.* import scala.collection.immutable.{Map => IMap} -sealed trait Dsl { +sealed trait Quoted { def ast: Ast 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] @@ -34,7 +34,7 @@ extension [A1, A2, B](inline f1: (A1, A2) => B) { 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 fast: (Ast, Ident, Ast) => Ast)(inline f2: Ast => D2): D2 = { f2(fast(ast, f.param0, f.body)) @@ -57,8 +57,8 @@ private given FromExpr[EntityQuery[?]] with { } } } -private given FromExpr[Dsl] with { - def unapply(x: Expr[Dsl])(using Quotes): Option[Dsl] = { +private given FromExpr[Quoted] with { + def unapply(x: Expr[Quoted])(using Quotes): Option[Quoted] = { import quotes.reflect.* x match { case '{ ($x: EntityQuery[?]) } => x.value @@ -69,9 +69,9 @@ private given FromExpr[Dsl] with { inline def query[E](inline table: String) = 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.* x.value match { case Some(xv) => '{ Some(${ Expr(xv.ast.toString()) }) }