mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 14:40:17 +00:00
fix: ParRes with no children converted to Null
log (#699)
This commit is contained in:
parent
667ea300f0
commit
5f00b1ea8d
@ -1,6 +1,6 @@
|
||||
package aqua.model.inline
|
||||
|
||||
import aqua.model.{OpModel, ParModel, SeqModel}
|
||||
import aqua.model.{EmptyModel, OpModel, ParModel, SeqModel}
|
||||
import aqua.raw.ops.RawTag
|
||||
import aqua.raw.value.ValueRaw
|
||||
import cats.Monoid
|
||||
@ -33,7 +33,10 @@ private[inline] case class Inline(
|
||||
case l =>
|
||||
mergeMode match
|
||||
case SeqMode =>
|
||||
Chain.one(SeqModel.wrap(l: _*))
|
||||
val wrapped = SeqModel.wrap(l: _*)
|
||||
wrapped match
|
||||
case EmptyModel.leaf => Chain.empty
|
||||
case _ => Chain.one(wrapped)
|
||||
case ParMode => Chain.one(ParModel.wrap(l: _*))
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ object RawValueInliner extends Logging {
|
||||
ops <- inlineToTree(map)
|
||||
_ = logger.trace("desugarized ops: " + ops)
|
||||
_ = logger.trace("map was: " + map)
|
||||
} yield vm -> parDesugarPrefix(ops)
|
||||
} yield vm -> parDesugarPrefix(ops.filterNot(_ == EmptyModel.leaf))
|
||||
|
||||
def collectionToModel[S: Mangler: Exports: Arrows](
|
||||
value: CollectionRaw,
|
||||
|
@ -35,6 +35,16 @@ object TagInliner extends Logging {
|
||||
private def none[S]: State[S, (Option[OpModel], Option[OpModel.Tree])] =
|
||||
State.pure(None -> None)
|
||||
|
||||
private def combineOpsWithSeq(l: Option[OpModel.Tree], r: Option[OpModel.Tree]) =
|
||||
l match {
|
||||
case None => r
|
||||
case Some(a) =>
|
||||
r match {
|
||||
case None => l
|
||||
case Some(b) => Some(SeqModel.wrap(a, b))
|
||||
}
|
||||
}
|
||||
|
||||
def canonicalizeIfStream[S: Mangler](
|
||||
vm: ValueModel,
|
||||
ops: Option[OpModel.Tree]
|
||||
@ -45,7 +55,7 @@ object TagInliner extends Logging {
|
||||
Mangler[S].findAndForbidName(canonName).map { n =>
|
||||
val canon = VarModel(n, CanonStreamType(el), l)
|
||||
val canonModel = CanonicalizeModel(vm, CallModel.Export(canon.name, canon.`type`)).leaf
|
||||
canon -> Some(ops.fold(canonModel)(t => SeqModel.wrap(t, canonModel)))
|
||||
canon -> combineOpsWithSeq(ops, Option(canonModel))
|
||||
}
|
||||
case _ => State.pure(vm -> ops)
|
||||
}
|
||||
@ -69,7 +79,7 @@ object TagInliner extends Logging {
|
||||
flatResult <- flatCanonStream(canonV, Some(canonOp))
|
||||
} yield {
|
||||
val (resV, resOp) = flatResult
|
||||
(resV, op.fold(resOp)(t => resOp.map(o => SeqModel.wrap(t, o))))
|
||||
(resV, combineOpsWithSeq(op, resOp))
|
||||
}
|
||||
case v @ VarModel(_, CanonStreamType(_), _) =>
|
||||
flatCanonStream(v, op)
|
||||
@ -88,7 +98,7 @@ object TagInliner extends Logging {
|
||||
val apOp = FlattenModel(canonV, apN).leaf
|
||||
(
|
||||
apV,
|
||||
Some(op.fold(apOp)(o => SeqModel.wrap(o, apOp)))
|
||||
combineOpsWithSeq(op, Option(apOp))
|
||||
)
|
||||
}
|
||||
} else {
|
||||
@ -171,7 +181,7 @@ object TagInliner extends Logging {
|
||||
case (l @ LiteralModel(_, _), p) =>
|
||||
for {
|
||||
_ <- Exports[S].resolved(exportTo.name, l)
|
||||
} yield Some(SeqModel) -> p
|
||||
} yield None -> p
|
||||
case (v, p) =>
|
||||
State.pure(Some(CanonicalizeModel(v, CallModel.callExport(exportTo))) -> p)
|
||||
}
|
||||
@ -182,7 +192,7 @@ object TagInliner extends Logging {
|
||||
case (l @ LiteralModel(_, _), p) =>
|
||||
for {
|
||||
_ <- Exports[S].resolved(assignTo, l)
|
||||
} yield Some(SeqModel) -> p
|
||||
} yield None -> p
|
||||
case (v, p) =>
|
||||
State.pure(Some(FlattenModel(v, assignTo)) -> p)
|
||||
}
|
||||
@ -211,7 +221,7 @@ object TagInliner extends Logging {
|
||||
}).flatMap { cd =>
|
||||
for {
|
||||
_ <- Exports[S].resolved(assignTo, cd._1)
|
||||
} yield Some(SeqModel) -> cd._2
|
||||
} yield None -> cd._2
|
||||
}
|
||||
|
||||
case ClosureTag(arrow, detach) =>
|
||||
|
@ -134,7 +134,7 @@ class RawValueInlinerSpec extends AnyFlatSpec with Matchers {
|
||||
"x",
|
||||
ArrayType(ScalarType.string),
|
||||
Chain.one(IntoIndexModel("y", ScalarType.string))
|
||||
) -> Some(EmptyModel.leaf)
|
||||
) -> None
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class TagInlinerSpec extends AnyFlatSpec with Matchers {
|
||||
.value
|
||||
|
||||
model._1.resolvedExports(canonTo) shouldBe LiteralModel(ValueRaw.Nil.value, ValueRaw.Nil.baseType)
|
||||
model._2._1 shouldBe Some(SeqModel)
|
||||
model._2._1 shouldBe None
|
||||
model._2._2 shouldBe None
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ class TagInlinerSpec extends AnyFlatSpec with Matchers {
|
||||
ValueRaw.Nil.value,
|
||||
ValueRaw.Nil.baseType
|
||||
)
|
||||
model._2._1 shouldBe Some(SeqModel)
|
||||
model._2._1 shouldBe None
|
||||
model._2._2 shouldBe None
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,8 @@ object MakeRes {
|
||||
MatchMismatchRes(a, b, s).leaf
|
||||
case ForModel(item, iter, mode) if !isNillLiteral(iter) => FoldRes(item, iter, mode).leaf
|
||||
case RestrictionModel(item, isStream) => RestrictionRes(item, isStream).leaf
|
||||
case ParModel | DetachModel => ParRes.leaf
|
||||
case DetachModel => ParRes.leaf
|
||||
case ParModel => ParRes.leaf
|
||||
case XorModel => XorRes.leaf
|
||||
case NextModel(item) => NextRes(item).leaf
|
||||
case PushToStreamModel(operand @ VarModel(_, StreamType(st), _), exportTo) =>
|
||||
|
Loading…
Reference in New Issue
Block a user