-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Primetalk/feature/quill2
Feature/quill2
- Loading branch information
Showing
10 changed files
with
119 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
typed-ontology-metameta/src/main/scala/ru/primetalk/typed/ontology/utils/objectName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
package ru.primetalk.typed.ontology.utils | ||
|
||
import scala.quoted.{Expr, Type, Quotes, quotes} | ||
|
||
/** Определяет имя переданного объекта. */ | ||
inline def nameOf(o: Any): String = ${ObjectNameImpl.nameOfImpl('o)} | ||
|
||
/** | ||
* Вычисляет имя объекта на основе имени класса. | ||
*/ | ||
def objectName(o: Any): String = | ||
val simpleName = o.getClass.getSimpleName | ||
val l = simpleName.length | ||
if simpleName(l - 1) == '$' then simpleName.substring(0, l - 1) | ||
else simpleName | ||
|
||
object ObjectNameImpl: | ||
def nameOfImpl(o: Expr[Any])(using Quotes): Expr[String] = | ||
import quotes.reflect.* | ||
o.asTerm match | ||
case Inlined(_, _, Ident(name)) => | ||
Expr(name) | ||
case t => | ||
report.errorAndAbort(s"Couldn't determine name of $t") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters