Add top-bottom support (#442)

This commit is contained in:
Dima 2022-02-23 12:37:18 +03:00 committed by GitHub
parent 4c08cf7343
commit 5eae05dff0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 11 deletions

View File

@ -17,7 +17,7 @@ val scribeV = "3.6.3"
name := "aqua-hll"
val commons = Seq(
baseAquaVersion := "0.6.1",
baseAquaVersion := "0.6.2",
version := baseAquaVersion.value + "-" + sys.env.getOrElse("BUILD_NUMBER", "SNAPSHOT"),
scalaVersion := dottyVersion,
libraryDependencies ++= Seq(

View File

@ -24,7 +24,10 @@ object Console {
override def fnName: String = funcName
def handler: ServiceHandler = { varArgs =>
OutputPrinter.print(JSON.stringify(varArgs(0), space = 2))
js.typeOf(varArgs(0)) match {
case "string" | "number" | "boolean" => OutputPrinter.print(varArgs(0).toString)
case _ => OutputPrinter.print(JSON.stringify(varArgs(0), space = 2))
}
js.Promise.resolve(Service.emptyObject)
}
def argDefinitions: List[ArgDefinition] = ArgDefinition("str", PrimitiveType) :: Nil

View File

@ -98,9 +98,9 @@ object BasicTypeToken {
}
case class ArrowTypeToken[S[_]: Comonad](
override val unit: S[Unit],
args: List[(Option[Name[S]], TypeToken[S])],
res: List[DataTypeToken[S]]
override val unit: S[Unit],
args: List[(Option[Name[S]], TypeToken[S])],
res: List[DataTypeToken[S]]
) extends TypeToken[S] {
override def as[T](v: T): S[T] = unit.as(v)
@ -143,18 +143,18 @@ object DataTypeToken {
val `withoutstreamdatatypedef`: P[DataTypeToken[Span.S]] =
P.oneOf(
P.defer(`arraytypedef`) :: P.defer(
P.defer(`topbottomdef`) :: P.defer(`arraytypedef`) :: P.defer(
OptionTypeToken.`optiontypedef`
) :: BasicTypeToken
.`basictypedef` :: CustomTypeToken.dotted :: Nil
) :: BasicTypeToken.`basictypedef` :: CustomTypeToken.dotted :: Nil
)
def `datatypedef`: P[DataTypeToken[Span.S]] =
P.oneOf(
P.defer(`arraytypedef`) :: P.defer(StreamTypeToken.`streamtypedef`) :: P.defer(
P.defer(`topbottomdef`) :: P.defer(`arraytypedef`) :: P.defer(
StreamTypeToken.`streamtypedef`
) :: P.defer(
OptionTypeToken.`optiontypedef`
) :: BasicTypeToken
.`basictypedef` :: CustomTypeToken.dotted :: Nil
) :: BasicTypeToken.`basictypedef` :: CustomTypeToken.dotted :: Nil
)
}