From 73afa0b1041b4aac8ec0990a14ed9d4948fb2e63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=BE=AA?= Date: Fri, 25 Oct 2024 11:58:21 +1300 Subject: [PATCH] up --- build.sbt | 13 ++++----- .../main/scala/chester/parser/Parser.scala | 4 +-- .../main/scala/chester/syntax/core/Term.scala | 28 +++++++++++++++++++ .../main/scala/chester/resolve/Desalt.scala | 4 +-- .../src/main/scala/chester/i18n/macros.scala | 12 ++++---- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/build.sbt b/build.sbt index a905127a2..3fb97b3dd 100644 --- a/build.sbt +++ b/build.sbt @@ -276,14 +276,13 @@ ThisBuild / nativeConfig ~= ((System.getProperty("os.name").toLowerCase, System. _.withGC(GC.commix) } /* - -[error] /usr/bin/ld: /tmp/lto-llvm-7d968c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `__stack_chk_guard@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC -[error] /usr/bin/ld: /tmp/lto-llvm-7d968c.o(.text.MutatorThreads_init+0x8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17' -[error] /usr/bin/ld: final link failed: bad value -[error] clang++: error: linker command failed with exit code 1 (use -v to see invocation) -[info] Total (36687 ms) + [error] /usr/bin/ld: /tmp/lto-llvm-7d968c.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `__stack_chk_guard@@GLIBC_2.17' which may bind externally can not be used when making a shared object; recompile with -fPIC + [error] /usr/bin/ld: /tmp/lto-llvm-7d968c.o(.text.MutatorThreads_init+0x8): unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol `__stack_chk_guard@@GLIBC_2.17' + [error] /usr/bin/ld: final link failed: bad value + [error] clang++: error: linker command failed with exit code 1 (use -v to see invocation) + [info] Total (36687 ms) */ - // Archlinux aarch64 Virtual Machine on Apple Silicon + // Archlinux aarch64 Virtual Machine on Apple Silicon: LTO is broken too case (linux, "aarch64") if linux.contains("linux") => { _.withMode(Mode.releaseFast) .withGC(GC.commix) diff --git a/parser/src/main/scala/chester/parser/Parser.scala b/parser/src/main/scala/chester/parser/Parser.scala index eea0d9bee..8dc7026e2 100644 --- a/parser/src/main/scala/chester/parser/Parser.scala +++ b/parser/src/main/scala/chester/parser/Parser.scala @@ -417,11 +417,11 @@ case class ParserInternal( def objectClause0: P[ObjectClause] = (maybeSpace ~ qualifiedName ~ maybeSpace ~ "=" ~ maybeSpace ~ parse() ~ maybeSpace) - .map(ObjectExprClause) + .map(ObjectExprClause.apply) def objectClause1: P[ObjectClause] = (maybeSpace ~ parse(ctx = ParsingContext(dontallowOpSeq = true)) ~ maybeSpace ~ "=>" ~ maybeSpace ~ parse() ~ maybeSpace) - .map(ObjectExprClauseOnValue) + .map(ObjectExprClauseOnValue.apply) def objectParse: P[ParsedExpr] = PwithMeta( "{" ~ (objectClause0 | objectClause1).rep(sep = comma) ~ comma.? ~ maybeSpace ~ "}" diff --git a/syntax/src/main/scala/chester/syntax/core/Term.scala b/syntax/src/main/scala/chester/syntax/core/Term.scala index 288920116..5a0da5cca 100644 --- a/syntax/src/main/scala/chester/syntax/core/Term.scala +++ b/syntax/src/main/scala/chester/syntax/core/Term.scala @@ -569,6 +569,34 @@ case class RationalTerm(value: Rational, meta: OptionTermMeta) extends LiteralTe Doc.text(value.toString, ColorProfile.literalColor) } +trait BooleanTermC[+Rec <: TermT[Rec]] extends LiteralTermT[Rec] { + override type ThisTree <: BooleanTermC[Rec] + def value: Boolean + override def toTerm: BooleanTerm = BooleanTerm(value, meta) +} + +case class BooleanTerm(value: Boolean, meta: OptionTermMeta) extends LiteralTerm with BooleanTermC[Term] derives ReadWriter { + override type ThisTree = BooleanTerm + override def descent(f: Term => Term, g: SpecialMap): BooleanTerm = this + + override def toDoc(using options: PrettierOptions): Doc = + Doc.text(value.toString, ColorProfile.literalColor) +} + +trait BooleanTypeC[+Rec <: TermT[Rec]] extends TypeTermT[Rec] with WithTypeT[Rec] { + override type ThisTree <: BooleanTypeC[Rec] + override def toTerm: BooleanType = BooleanType(meta) +} + +case class BooleanType(meta: OptionTermMeta) extends TypeTerm with WithType with BooleanTypeC[Term] derives ReadWriter { + override type ThisTree = BooleanType + override def descent(f: Term => Term, g: SpecialMap): BooleanType = this + + override def ty: Term = Type0 + override def toDoc(using options: PrettierOptions): Doc = + Doc.text("Boolean", ColorProfile.typeColor) +} + trait StringTermC[+Rec <: TermT[Rec]] extends LiteralTermT[Rec] { override type ThisTree <: StringTermC[Rec] def value: String diff --git a/tyck/src/main/scala/chester/resolve/Desalt.scala b/tyck/src/main/scala/chester/resolve/Desalt.scala index 64b34afcb..8591bc44b 100644 --- a/tyck/src/main/scala/chester/resolve/Desalt.scala +++ b/tyck/src/main/scala/chester/resolve/Desalt.scala @@ -582,9 +582,7 @@ case object SimpleDesalt { } } - private def parseExtendsClause(tokens: List[Expr], meta: Option[ExprMeta])(using - reporter: Reporter[TyckProblem] - ): (Option[ExtendsClause], List[Expr]) = { + private def parseExtendsClause(tokens: List[Expr], meta: Option[ExprMeta]): (Option[ExtendsClause], List[Expr]) = { tokens match { case Identifier(Const.`<:`, _) :: rest => val (superTypes, remainingTokens) = parseSuperTypes(rest) diff --git a/utils/shared/src/main/scala/chester/i18n/macros.scala b/utils/shared/src/main/scala/chester/i18n/macros.scala index ce6380b3e..d92d9debf 100644 --- a/utils/shared/src/main/scala/chester/i18n/macros.scala +++ b/utils/shared/src/main/scala/chester/i18n/macros.scala @@ -7,11 +7,13 @@ trait T { } private def tMacro(sc: Expr[StringContext])(using Quotes): Expr[T] = { - println(sc.show) - println(System.getProperty("user.dir")) - println("aaa") - // it works - // Files.write(Paths.get("/Users/.../test.output"), sc.show.getBytes, StandardOpenOption.CREATE, StandardOpenOption.APPEND) + if (false) { + println(sc.show) + println(System.getProperty("user.dir")) + println("aaa") + // it works + // Files.write(Paths.get("/Users/.../test.output"), sc.show.getBytes, StandardOpenOption.CREATE, StandardOpenOption.APPEND) + } '{ new T { def t(args: Any*)(using lang: Language): String = {