mirror of
https://github.com/fluencelabs/aqua.git
synced 2025-06-28 05:51:35 +00:00
Streams support (#87)
* #29 going to support streams * Added StreamName * StreamName removed * Streams support works * Debug println removed Co-authored-by: Dima <dmitry.shakhtarin@fluence.ai>
This commit is contained in:
@ -3,6 +3,7 @@ package aqua.backend.air
|
||||
import aqua.model._
|
||||
import aqua.model.func.Call
|
||||
import aqua.model.func.body._
|
||||
import aqua.types.StreamType
|
||||
import cats.Eval
|
||||
import cats.data.Chain
|
||||
import cats.free.Cofree
|
||||
@ -24,9 +25,13 @@ object AirGen {
|
||||
|
||||
def valueToData(vm: ValueModel): DataView = vm match {
|
||||
case LiteralModel(value) => DataView.StringScalar(value)
|
||||
case VarModel(name, lambda) =>
|
||||
if (lambda.isEmpty) DataView.Variable(name)
|
||||
else DataView.VarLens(name, lambdaToString(lambda.toList))
|
||||
case VarModel(name, t, lambda) =>
|
||||
val n = t match {
|
||||
case _: StreamType => "$" + name
|
||||
case _ => name
|
||||
}
|
||||
if (lambda.isEmpty) DataView.Variable(n)
|
||||
else DataView.VarLens(n, lambdaToString(lambda.toList))
|
||||
}
|
||||
|
||||
def opsToSingle(ops: Chain[AirGen]): AirGen = ops.toList match {
|
||||
@ -76,8 +81,11 @@ object AirGen {
|
||||
peerId.map(valueToData).getOrElse(DataView.InitPeerId),
|
||||
valueToData(serviceId),
|
||||
funcName,
|
||||
args.map(_.model).map(valueToData),
|
||||
exportTo
|
||||
args.map(valueToData),
|
||||
exportTo.map {
|
||||
case Call.Export(name, _: StreamType) => "$" + name
|
||||
case Call.Export(name, _) => name
|
||||
}
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -39,7 +39,7 @@ case class TypescriptFunc(func: FuncCallable) {
|
||||
}.mkString("\n")
|
||||
|
||||
val retType = func.ret
|
||||
.map(_.`type`)
|
||||
.map(_._2)
|
||||
.fold("void")(typeToTs)
|
||||
|
||||
val returnVal =
|
||||
@ -90,6 +90,7 @@ object TypescriptFunc {
|
||||
|
||||
def typeToTs(t: Type): String = t match {
|
||||
case ArrayType(t) => typeToTs(t) + "[]"
|
||||
case StreamType(t) => typeToTs(t) + "[]"
|
||||
case pt: ProductType =>
|
||||
s"{${pt.fields.map(typeToTs).toNel.map(kv => kv._1 + ":" + kv._2).toList.mkString(";")}}"
|
||||
case st: ScalarType if ScalarType.number(st) => "number"
|
||||
|
Reference in New Issue
Block a user