mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-11 09:20:19 +00:00
Remove Arrows
This commit is contained in:
parent
a7d21b8a21
commit
fe8873571a
@ -3,7 +3,7 @@ package aqua.model.inline
|
||||
import aqua.errors.Errors.internalError
|
||||
import aqua.model
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.ops.RawTag
|
||||
import aqua.raw.value.{ValueRaw, VarRaw}
|
||||
import aqua.types.*
|
||||
@ -26,7 +26,7 @@ import scribe.Logging
|
||||
*/
|
||||
object ArrowInliner extends Logging {
|
||||
|
||||
def callArrow[S: Exports: Arrows: Mangler](
|
||||
def callArrow[S: Exports: Mangler](
|
||||
arrow: FuncArrow,
|
||||
call: CallModel
|
||||
): State[S, OpModel.Tree] =
|
||||
@ -42,7 +42,7 @@ object ArrowInliner extends Logging {
|
||||
)
|
||||
|
||||
// push results to streams if they are exported to streams
|
||||
private def pushStreamResults[S: Mangler: Exports: Arrows](
|
||||
private def pushStreamResults[S: Mangler: Exports](
|
||||
outsideStreamNames: Set[String],
|
||||
exportTo: List[CallModel.Export],
|
||||
results: List[ValueRaw]
|
||||
@ -83,7 +83,7 @@ object ArrowInliner extends Logging {
|
||||
)
|
||||
|
||||
// Apply a callable function, get its fully resolved body & optional value, if any
|
||||
private def inline[S: Mangler: Arrows: Exports](
|
||||
private def inline[S: Mangler: Exports](
|
||||
fn: FuncArrow,
|
||||
call: CallModel,
|
||||
outsideDeclaredStreams: Set[String]
|
||||
@ -116,7 +116,8 @@ object ArrowInliner extends Logging {
|
||||
|
||||
// find and get resolved arrows if we return them from the function
|
||||
returnedArrows = rets.collect { case VarModel(name, _: ArrowType, _) => name }.toSet
|
||||
arrowsToSave <- Arrows[S].pickArrows(returnedArrows)
|
||||
// TODO: rewrite
|
||||
// arrowsToSave <- Arrows[S].pickArrows(returnedArrows)
|
||||
|
||||
body = SeqModel.wrap(callableFuncBody :: ops)
|
||||
} yield InlineResult(
|
||||
@ -213,13 +214,14 @@ object ArrowInliner extends Logging {
|
||||
}
|
||||
}
|
||||
|
||||
private def getAbilityArrows[S: Arrows: Exports](
|
||||
private def getAbilityArrows[S: Exports](
|
||||
name: String,
|
||||
`type`: GeneralAbilityType
|
||||
): State[S, Map[String, FuncArrow]] = for {
|
||||
exports <- Exports[S].exports
|
||||
arrows <- Arrows[S].arrows
|
||||
} yield getAbilityArrows(name, None, `type`, exports, arrows)
|
||||
// TODO: Rewrite
|
||||
// arrows <- Arrows[S].arrows
|
||||
} yield getAbilityArrows(name, None, `type`, exports, ???)
|
||||
|
||||
final case class Renamed[T](
|
||||
renames: Map[String, String],
|
||||
@ -298,9 +300,10 @@ object ArrowInliner extends Logging {
|
||||
}
|
||||
|
||||
// Gather abilities related arrows
|
||||
val abilitiesArrows = abilitiesValues.toList.foldMap { case (_, (_, values)) =>
|
||||
Arrows.arrowsByValues(fn.capturedArrows, values).toList
|
||||
}.toMap
|
||||
val abilitiesArrows = ???
|
||||
// abilitiesValues.toList.foldMap { case (_, (_, values)) =>
|
||||
// Arrows.arrowsByValues(fn.capturedArrows, values).toList
|
||||
// }.toMap
|
||||
|
||||
// Gather all other values and arrows that are not related to abilities
|
||||
val otherValues = fn.capturedValues -- abilitiesValuesKeys
|
||||
@ -354,10 +357,11 @@ object ArrowInliner extends Logging {
|
||||
|
||||
// Rename values and arrows unrelated to abilities
|
||||
otherValuesRenamed <- findNewNames(otherValues)
|
||||
otherArrowsValues = Arrows.arrowsByValues(
|
||||
otherArrows,
|
||||
otherValues
|
||||
)
|
||||
otherArrowsValues = ???
|
||||
// Arrows.arrowsByValues(
|
||||
// otherArrows,
|
||||
// otherValues
|
||||
// )
|
||||
otherArrowsValuesRenamed = Renamed(
|
||||
otherValuesRenamed.renames.filterKeys(otherArrowsValues.keySet).toMap,
|
||||
otherArrowsValues.renamed(otherValuesRenamed.renames)
|
||||
@ -414,7 +418,7 @@ object ArrowInliner extends Logging {
|
||||
* @param arrows Arrows that are available for callee
|
||||
* @return Prepared function
|
||||
*/
|
||||
private def prelude[S: Mangler: Arrows: Exports](
|
||||
private def prelude[S: Mangler: Exports](
|
||||
fn: FuncArrow,
|
||||
call: CallModel,
|
||||
exports: Map[String, ValueModel],
|
||||
@ -481,35 +485,37 @@ object ArrowInliner extends Logging {
|
||||
|
||||
ret = fn.ret.map(_.renameVars(renaming))
|
||||
|
||||
_ <- Arrows[S].resolved(arrowsResolved)
|
||||
// TODO: Rewrite
|
||||
// _ <- Arrows[S].resolved(arrowsResolved)
|
||||
_ <- Exports[S].resolved(exportsResolved)
|
||||
} yield (fn.copy(body = treeWithCanons, ret = ret), SeqModel.wrap(canons))
|
||||
|
||||
private[inline] def callArrowRet[S: Exports: Arrows: Mangler](
|
||||
private[inline] def callArrowRet[S: Exports: Mangler](
|
||||
arrow: FuncArrow,
|
||||
call: CallModel
|
||||
): State[S, (OpModel.Tree, List[ValueModel])] = for {
|
||||
passArrows <- Arrows[S].pickArrows(call.arrowArgNames)
|
||||
// TODO: Rewrite
|
||||
// passArrows <- Arrows[S].pickArrows(call.arrowArgNames)
|
||||
arrowsFromAbilities <- call.abilityArgs
|
||||
.traverse(getAbilityArrows.tupled)
|
||||
.map(_.flatMap(_.toList).toMap)
|
||||
passArrows = ???
|
||||
|
||||
exports <- Exports[S].exports
|
||||
streams <- getOutsideStreamNames
|
||||
arrows = passArrows ++ arrowsFromAbilities
|
||||
|
||||
inlineResult <- Exports[S].scope(
|
||||
Arrows[S].scope(
|
||||
for {
|
||||
// Process renamings, prepare environment
|
||||
fnCanon <- ArrowInliner.prelude(arrow, call, exports, arrows)
|
||||
inlineResult <- ArrowInliner.inline(fnCanon._1, call, streams)
|
||||
} yield inlineResult.copy(tree = SeqModel.wrap(fnCanon._2, inlineResult.tree))
|
||||
)
|
||||
)
|
||||
|
||||
exportTo = call.exportTo.map(_.name)
|
||||
_ <- Arrows[S].resolved(inlineResult.arrowsToSave)
|
||||
// TODO: Rewrite
|
||||
// _ <- Arrows[S].resolved(inlineResult.arrowsToSave)
|
||||
_ <- Exports[S].resolved(
|
||||
exportTo
|
||||
.zip(inlineResult.returnedValues)
|
||||
|
@ -1,15 +1,15 @@
|
||||
package aqua.model.inline
|
||||
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.RawValueInliner.unfold
|
||||
import aqua.model.inline.raw.RawInliner
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.MakeStructRaw
|
||||
import aqua.types.{StreamMapType, StructType}
|
||||
|
||||
import cats.data.{Chain, NonEmptyMap, State}
|
||||
import cats.syntax.foldable.*
|
||||
import cats.syntax.bifunctor.*
|
||||
import cats.syntax.foldable.*
|
||||
import cats.syntax.functor.*
|
||||
|
||||
object MakeStructRawInliner extends RawInliner[MakeStructRaw] {
|
||||
@ -58,7 +58,7 @@ object MakeStructRawInliner extends RawInliner[MakeStructRaw] {
|
||||
constructThroughMap(mapName, mapType, CallModel.Export(resultName, resultType), fields)
|
||||
}
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: MakeStructRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] = {
|
||||
|
@ -75,7 +75,7 @@ object RawValueInliner extends Logging {
|
||||
}
|
||||
} yield result
|
||||
|
||||
private[inline] def inlineToTree[S: Mangler: Exports: Arrows](
|
||||
private[inline] def inlineToTree[S: Mangler: Exports](
|
||||
inline: Inline
|
||||
): State[S, List[OpModel.Tree]] =
|
||||
(inline.mergeMode match {
|
||||
@ -83,7 +83,7 @@ object RawValueInliner extends Logging {
|
||||
case ParMode => inline.predo.toList
|
||||
}).pure
|
||||
|
||||
private[inline] def toModel[S: Mangler: Exports: Arrows](
|
||||
private[inline] def toModel[S: Mangler: Exports](
|
||||
unfoldF: State[S, (ValueModel, Inline)]
|
||||
): State[S, (ValueModel, Option[OpModel.Tree])] =
|
||||
for {
|
||||
@ -98,7 +98,7 @@ object RawValueInliner extends Logging {
|
||||
_ = logger.trace("map was: " + map)
|
||||
} yield vm -> parDesugarPrefix(ops.filterNot(_ == EmptyModel.leaf))
|
||||
|
||||
def valueToModel[S: Mangler: Exports: Arrows](
|
||||
def valueToModel[S: Mangler: Exports](
|
||||
value: ValueRaw,
|
||||
propertiesAllowed: Boolean = true
|
||||
): State[S, (ValueModel, Option[OpModel.Tree])] = for {
|
||||
@ -106,7 +106,7 @@ object RawValueInliner extends Logging {
|
||||
model <- toModel(unfold(value, propertiesAllowed))
|
||||
} yield model
|
||||
|
||||
def valueListToModel[S: Mangler: Exports: Arrows](
|
||||
def valueListToModel[S: Mangler: Exports](
|
||||
values: List[ValueRaw]
|
||||
): State[S, List[(ValueModel, Option[OpModel.Tree])]] =
|
||||
values.traverse(valueToModel(_))
|
||||
@ -115,7 +115,7 @@ object RawValueInliner extends Logging {
|
||||
* Unfold all arguments and make CallModel
|
||||
* @param flatStreamArguments canonicalize and flatten all stream arguments if true
|
||||
*/
|
||||
def callToModel[S: Mangler: Exports: Arrows](
|
||||
def callToModel[S: Mangler: Exports](
|
||||
call: Call,
|
||||
flatStreamArguments: Boolean
|
||||
): State[S, (CallModel, Option[OpModel.Tree])] = {
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline
|
||||
import aqua.errors.Errors.internalError
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.raw.{CallArrowRawInliner, CallServiceRawInliner}
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.model.inline.tag.IfTagInliner
|
||||
import aqua.raw.ops.*
|
||||
import aqua.raw.value.*
|
||||
@ -193,7 +193,7 @@ object TagInliner extends Logging {
|
||||
* @tparam S Current state
|
||||
* @return Model (if any), and prefix (if any)
|
||||
*/
|
||||
def tagToModel[S: Mangler: Arrows: Exports](
|
||||
def tagToModel[S: Mangler: Exports](
|
||||
tag: RawTag
|
||||
): State[S, TagInlined[S]] =
|
||||
tag match {
|
||||
@ -374,11 +374,13 @@ object TagInliner extends Logging {
|
||||
} yield TagInlined.Empty(prefix = prefix)
|
||||
|
||||
case ClosureTag(arrow, detach) =>
|
||||
if (detach) Arrows[S].resolved(arrow, None).as(TagInlined.Empty())
|
||||
else
|
||||
Arrows[S]
|
||||
.resolved(arrow, arrow.name.some)
|
||||
.as(TagInlined.Single(model = CaptureTopologyModel(arrow.name)))
|
||||
???
|
||||
// TODO: Rewrite
|
||||
// if (detach) Arrows[S].resolved(arrow, None).as(TagInlined.Empty())
|
||||
// else
|
||||
// Arrows[S]
|
||||
// .resolved(arrow, arrow.name.some)
|
||||
// .as(TagInlined.Single(model = CaptureTopologyModel(arrow.name)))
|
||||
|
||||
case NextTag(item) =>
|
||||
for {
|
||||
@ -431,12 +433,13 @@ object TagInliner extends Logging {
|
||||
} yield methodName -> fn
|
||||
}
|
||||
|
||||
// TODO: Rewrite
|
||||
// Resolve wrappers in arrows
|
||||
_ <- Arrows[S].resolved(
|
||||
methods.map { case (_, fn) =>
|
||||
fn.funcName -> fn
|
||||
}.toMap
|
||||
)
|
||||
// _ <- Arrows[S].resolved(
|
||||
// methods.map { case (_, fn) =>
|
||||
// fn.funcName -> fn
|
||||
// }.toMap
|
||||
// )
|
||||
|
||||
// Resolve wrappers in exports
|
||||
_ <- methods.traverse { case (methodName, fn) =>
|
||||
@ -475,7 +478,7 @@ object TagInliner extends Logging {
|
||||
inlined <- headInlined.build(children)
|
||||
} yield inlined
|
||||
|
||||
def handleTree[S: Exports: Mangler: Arrows](
|
||||
def handleTree[S: Exports: Mangler](
|
||||
tree: RawTag.Tree
|
||||
): State[S, OpModel.Tree] =
|
||||
traverseS(tree, tagToModel(_))
|
||||
|
@ -2,32 +2,32 @@ package aqua.model.inline.raw
|
||||
|
||||
import aqua.errors.Errors.internalError
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.raw.RawInliner
|
||||
import aqua.model.inline.TagInliner
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.raw.value.{AbilityRaw, LiteralRaw, MakeStructRaw}
|
||||
import cats.data.{NonEmptyList, NonEmptyMap, State}
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.Inline.MergeMode
|
||||
import aqua.model.inline.RawValueInliner.{unfold, valueToModel}
|
||||
import aqua.types.{ArrowType, ScalarType, Type}
|
||||
import aqua.model.inline.TagInliner
|
||||
import aqua.model.inline.raw.RawInliner
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.ApplyBinaryOpRaw
|
||||
import aqua.raw.value.ApplyBinaryOpRaw.Op
|
||||
import aqua.raw.value.ApplyBinaryOpRaw.Op.*
|
||||
import aqua.model.inline.Inline.MergeMode
|
||||
import aqua.raw.value.{AbilityRaw, LiteralRaw, MakeStructRaw}
|
||||
import aqua.types.LiteralType
|
||||
import aqua.types.{ArrowType, ScalarType, Type}
|
||||
|
||||
import cats.data.Chain
|
||||
import cats.syntax.traverse.*
|
||||
import cats.syntax.monoid.*
|
||||
import cats.syntax.functor.*
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.apply.*
|
||||
import cats.syntax.foldable.*
|
||||
import cats.data.{NonEmptyList, NonEmptyMap, State}
|
||||
import cats.syntax.applicative.*
|
||||
import aqua.types.LiteralType
|
||||
import cats.syntax.apply.*
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.foldable.*
|
||||
import cats.syntax.functor.*
|
||||
import cats.syntax.monoid.*
|
||||
import cats.syntax.traverse.*
|
||||
|
||||
object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: ApplyBinaryOpRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] = for {
|
||||
@ -83,7 +83,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
}
|
||||
} yield result
|
||||
|
||||
private def inlineEqOp[S: Mangler: Exports: Arrows](
|
||||
private def inlineEqOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
@ -106,7 +106,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
case _ => fullInlineEqOp(lmodel, rmodel, linline, rinline, op, resType)
|
||||
}
|
||||
|
||||
private def fullInlineEqOp[S: Mangler: Exports: Arrows](
|
||||
private def fullInlineEqOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
@ -152,7 +152,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
result(name, resType, predo)
|
||||
}
|
||||
|
||||
private def inlineBoolOp[S: Mangler: Exports: Arrows](
|
||||
private def inlineBoolOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
@ -178,7 +178,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
case _ => fullInlineBoolOp(lmodel, rmodel, linline, rinline, op, resType)
|
||||
}
|
||||
|
||||
private def fullInlineBoolOp[S: Mangler: Exports: Arrows](
|
||||
private def fullInlineBoolOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
@ -230,7 +230,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
result(name, resType, predo)
|
||||
}
|
||||
|
||||
private def inlineCmpOp[S: Mangler: Exports: Arrows](
|
||||
private def inlineCmpOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
@ -276,7 +276,7 @@ object ApplyBinaryOpRawInliner extends RawInliner[ApplyBinaryOpRaw] {
|
||||
result(fn, resType, predo)
|
||||
}
|
||||
|
||||
private def inlineMathOp[S: Mangler: Exports: Arrows](
|
||||
private def inlineMathOp[S: Mangler: Exports](
|
||||
lmodel: ValueModel,
|
||||
rmodel: ValueModel,
|
||||
linline: Inline,
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline.raw
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.Inline.MergeMode.*
|
||||
import aqua.model.inline.RawValueInliner.unfold
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.model.{
|
||||
CallModel,
|
||||
CanonicalizeModel,
|
||||
@ -24,7 +24,7 @@ import scribe.Logging
|
||||
|
||||
object ApplyFunctorRawInliner extends Logging {
|
||||
|
||||
def apply[S: Mangler: Exports: Arrows](
|
||||
def apply[S: Mangler: Exports](
|
||||
value: ValueModel,
|
||||
functor: FunctorRaw
|
||||
): State[S, (VarModel, Inline)] = {
|
||||
|
@ -4,10 +4,11 @@ import aqua.errors.Errors.internalError
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.Inline.MergeMode.*
|
||||
import aqua.model.inline.RawValueInliner.unfold
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.model.inline.{Inline, MakeStructRawInliner}
|
||||
import aqua.raw.value.IntoCopyRaw
|
||||
import aqua.types.{StreamMapType, StructType}
|
||||
|
||||
import cats.data.{Chain, NonEmptyMap, State}
|
||||
import cats.syntax.foldable.*
|
||||
import cats.syntax.functor.*
|
||||
@ -40,10 +41,16 @@ object ApplyIntoCopyRawInliner extends Logging {
|
||||
}
|
||||
|
||||
MakeStructRawInliner
|
||||
.constructThroughMap(mapName, mapType, CallModel.Export(resultName, resultType), fields, nonCopiedValues)
|
||||
.constructThroughMap(
|
||||
mapName,
|
||||
mapType,
|
||||
CallModel.Export(resultName, resultType),
|
||||
fields,
|
||||
nonCopiedValues
|
||||
)
|
||||
}
|
||||
|
||||
def apply[S: Mangler: Exports: Arrows](
|
||||
def apply[S: Mangler: Exports](
|
||||
value: VarModel,
|
||||
intoCopy: IntoCopyRaw
|
||||
): State[S, (VarModel, Inline)] = {
|
||||
|
@ -1,28 +1,28 @@
|
||||
package aqua.model.inline.raw
|
||||
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.raw.RawInliner
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.raw.value.{AbilityRaw, LiteralRaw, MakeStructRaw}
|
||||
import cats.data.{NonEmptyList, NonEmptyMap, State}
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.{unfold, valueToModel}
|
||||
import aqua.types.{ArrowType, ScalarType}
|
||||
import aqua.model.inline.raw.RawInliner
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.ApplyUnaryOpRaw
|
||||
import aqua.raw.value.ApplyUnaryOpRaw.Op.*
|
||||
import aqua.raw.value.{AbilityRaw, LiteralRaw, MakeStructRaw}
|
||||
import aqua.types.{ArrowType, ScalarType}
|
||||
|
||||
import cats.data.Chain
|
||||
import cats.syntax.traverse.*
|
||||
import cats.syntax.monoid.*
|
||||
import cats.syntax.functor.*
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.apply.*
|
||||
import cats.syntax.foldable.*
|
||||
import cats.data.{NonEmptyList, NonEmptyMap, State}
|
||||
import cats.syntax.applicative.*
|
||||
import cats.syntax.apply.*
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.foldable.*
|
||||
import cats.syntax.functor.*
|
||||
import cats.syntax.monoid.*
|
||||
import cats.syntax.traverse.*
|
||||
|
||||
object ApplyUnaryOpRawInliner extends RawInliner[ApplyUnaryOpRaw] {
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: ApplyUnaryOpRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] = for {
|
||||
@ -40,7 +40,7 @@ object ApplyUnaryOpRawInliner extends RawInliner[ApplyUnaryOpRaw] {
|
||||
}
|
||||
} yield result
|
||||
|
||||
private def fullInline[S: Mangler: Exports: Arrows](
|
||||
private def fullInline[S: Mangler: Exports](
|
||||
vm: ValueModel,
|
||||
vinline: Inline,
|
||||
op: ApplyUnaryOpRaw.Op
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline.raw
|
||||
import aqua.errors.Errors.internalError
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.RawValueInliner.callToModel
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.model.inline.{ArrowInliner, Inline, RawValueInliner}
|
||||
import aqua.raw.ops.Call
|
||||
import aqua.raw.value.CallArrowRaw
|
||||
@ -31,7 +31,7 @@ object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging {
|
||||
resolveArrow(funcName, call)
|
||||
}
|
||||
|
||||
private def resolveFuncArrow[S: Mangler: Exports: Arrows](
|
||||
private def resolveFuncArrow[S: Mangler: Exports](
|
||||
fn: FuncArrow,
|
||||
call: Call
|
||||
): State[S, (List[ValueModel], Inline)] = {
|
||||
@ -52,13 +52,15 @@ object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging {
|
||||
}
|
||||
}
|
||||
|
||||
private def resolveArrow[S: Mangler: Exports: Arrows](
|
||||
private def resolveArrow[S: Mangler: Exports](
|
||||
funcName: String,
|
||||
call: Call
|
||||
): State[S, (List[ValueModel], Inline)] = for {
|
||||
arrows <- Arrows[S].arrows
|
||||
// TODO: Rewrite
|
||||
// arrows <- Arrows[S].arrows
|
||||
exports <- Exports[S].exports
|
||||
lastArrow <- Exports[S].getLastVarName(funcName)
|
||||
arrows: Map[String, FuncArrow] = ???
|
||||
arrow = arrows
|
||||
.get(funcName)
|
||||
.orElse(
|
||||
@ -76,7 +78,7 @@ object CallArrowRawInliner extends RawInliner[CallArrowRaw] with Logging {
|
||||
})
|
||||
} yield result
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: CallArrowRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] =
|
||||
|
@ -3,22 +3,22 @@ package aqua.model.inline.raw
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.{callToModel, valueToModel}
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.ops.Call
|
||||
import aqua.raw.value.CallServiceRaw
|
||||
|
||||
import cats.data.{Chain, State}
|
||||
import scribe.Logging
|
||||
|
||||
object CallServiceRawInliner extends RawInliner[CallServiceRaw] with Logging {
|
||||
|
||||
private[inline] def unfold[S: Mangler: Exports: Arrows](
|
||||
private[inline] def unfold[S: Mangler: Exports](
|
||||
value: CallServiceRaw,
|
||||
exportTo: List[Call.Export]
|
||||
): State[S, (List[ValueModel], Inline)] = Exports[S].exports.flatMap { exports =>
|
||||
logger.trace(s"${exportTo.mkString(" ")} $value")
|
||||
logger.trace(Console.BLUE + s"call service id ${value.serviceId}" + Console.RESET)
|
||||
|
||||
|
||||
val call = Call(value.arguments, exportTo)
|
||||
|
||||
for {
|
||||
@ -40,7 +40,7 @@ object CallServiceRawInliner extends RawInliner[CallServiceRaw] with Logging {
|
||||
} yield values.values.toList -> inline
|
||||
}
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: CallServiceRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] =
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline.raw
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.valueToModel
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.CollectionRaw
|
||||
import aqua.types.StreamMapType
|
||||
import aqua.types.{ArrayType, CanonStreamType, OptionType, StreamType}
|
||||
@ -12,7 +12,7 @@ import cats.data.{Chain, State}
|
||||
|
||||
object CollectionRawInliner extends RawInliner[CollectionRaw] {
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: CollectionRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] =
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline.raw
|
||||
import aqua.model.ValueModel.Ability
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.unfold
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.model.{SeqModel, ValueModel, VarModel}
|
||||
import aqua.raw.value.AbilityRaw
|
||||
import aqua.types.AbilityType
|
||||
@ -15,7 +15,7 @@ import cats.syntax.functor.*
|
||||
|
||||
object MakeAbilityRawInliner extends RawInliner[AbilityRaw] {
|
||||
|
||||
private def updateFields[S: Mangler: Exports: Arrows](
|
||||
private def updateFields[S: Mangler: Exports](
|
||||
name: String,
|
||||
fields: NonEmptyMap[String, (ValueModel, Inline)]
|
||||
): State[S, Unit] =
|
||||
@ -27,7 +27,7 @@ object MakeAbilityRawInliner extends RawInliner[AbilityRaw] {
|
||||
Exports[S].resolveAbilityField(name, n, vm)
|
||||
}.as(())
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: AbilityRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] = {
|
||||
|
@ -4,7 +4,7 @@ import aqua.errors.Errors.internalError
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.unfold
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.types.{ArrayType, CanonStreamType, ScalarType, StreamType}
|
||||
|
||||
import cats.data.Chain
|
||||
|
@ -3,7 +3,7 @@ package aqua.model.inline.raw
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.Inline
|
||||
import aqua.model.inline.RawValueInliner.valueToModel
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.StreamRaw
|
||||
|
||||
import cats.data.{Chain, State}
|
||||
@ -11,7 +11,7 @@ import cats.syntax.traverse.*
|
||||
|
||||
object StreamRawInliner extends RawInliner[StreamRaw] {
|
||||
|
||||
override def apply[S: Mangler: Exports: Arrows](
|
||||
override def apply[S: Mangler: Exports](
|
||||
raw: StreamRaw,
|
||||
propertiesAllowed: Boolean
|
||||
): State[S, (ValueModel, Inline)] = {
|
||||
|
@ -7,6 +7,7 @@ import aqua.types.ServiceType
|
||||
import aqua.types.{AbilityType, GeneralAbilityType, NamedType}
|
||||
|
||||
import cats.data.{NonEmptyList, State}
|
||||
import cats.syntax.functor.*
|
||||
|
||||
/**
|
||||
* Exports – trace values available in the scope
|
||||
@ -86,11 +87,28 @@ object Exports {
|
||||
}
|
||||
}
|
||||
|
||||
final case class ExportsState(
|
||||
global: Export.Context = Export.Context(Map.empty)
|
||||
) {
|
||||
|
||||
def resolved(name: String, exp: Export): ExportsState =
|
||||
copy(global = global.resolved(name, exp))
|
||||
|
||||
def resolved(exports: Map[String, Export]): ExportsState =
|
||||
copy(global = global.resolved(exports))
|
||||
|
||||
def renameExports(renames: Map[String, String]): ExportsState =
|
||||
copy(global = global.renameExports(renames))
|
||||
|
||||
def values: Map[String, Export] =
|
||||
global.values
|
||||
}
|
||||
|
||||
def apply[S](using exports: Exports[S]): Exports[S] = exports
|
||||
|
||||
object Simple extends Exports[Export.Context] {
|
||||
given Exports[ExportsState] with {
|
||||
|
||||
type ST[A] = State[Export.Context, A]
|
||||
type ST[A] = State[ExportsState, A]
|
||||
|
||||
override def resolved(name: String, exp: Export): ST[Unit] =
|
||||
State.modify(_.resolved(name, exp))
|
||||
@ -99,7 +117,7 @@ object Exports {
|
||||
State.modify(_.resolved(exports))
|
||||
|
||||
override def renameExports(renames: Map[String, String]): ST[Unit] =
|
||||
State.modify(_.renameExports(renames))
|
||||
State.modify[ExportsState](_.renameExports(renames)).void
|
||||
|
||||
override def get(name: String): ST[Option[Export]] =
|
||||
State.inspect(_.values.get(name))
|
||||
|
@ -1,11 +1,13 @@
|
||||
package aqua.model.inline.state
|
||||
|
||||
import aqua.mangler.ManglerState
|
||||
import aqua.model.inline.state.Exports.ExportsState
|
||||
import aqua.model.inline.state.{Counter, Exports, Mangler}
|
||||
import aqua.model.{FuncArrow, ValueModel}
|
||||
import aqua.model.inline.state.{Arrows, Counter, Exports, Mangler}
|
||||
import aqua.raw.arrow.FuncRaw
|
||||
import aqua.raw.value.{ValueRaw, VarRaw}
|
||||
import aqua.types.ArrowType
|
||||
|
||||
import cats.data.{Chain, State}
|
||||
import cats.instances.list.*
|
||||
import cats.syntax.traverse.*
|
||||
@ -25,8 +27,7 @@ import scribe.Logging
|
||||
*/
|
||||
case class InliningState(
|
||||
noNames: ManglerState = ManglerState(),
|
||||
resolvedExports: Map[String, ValueModel] = Map.empty,
|
||||
resolvedArrows: Map[String, FuncArrow] = Map.empty,
|
||||
resolvedExports: ExportsState = ExportsState(),
|
||||
instructionCounter: Int = 0
|
||||
)
|
||||
|
||||
@ -38,10 +39,7 @@ object InliningState {
|
||||
given Mangler[InliningState] =
|
||||
Mangler[ManglerState].transformS(_.noNames, (acc, nn) => acc.copy(noNames = nn))
|
||||
|
||||
given Arrows[InliningState] =
|
||||
Arrows.Simple.transformS(_.resolvedArrows, (acc, aa) => acc.copy(resolvedArrows = aa))
|
||||
|
||||
given Exports[InliningState] =
|
||||
Exports.Simple.transformS(_.resolvedExports, (acc, ex) => acc.copy(resolvedExports = ex))
|
||||
Exports[ExportsState].transformS(_.resolvedExports, (acc, ex) => acc.copy(resolvedExports = ex))
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
package aqua.model.inline.tag
|
||||
|
||||
import aqua.raw.value.{ApplyBinaryOpRaw, ValueRaw}
|
||||
import aqua.raw.value.ApplyBinaryOpRaw.Op as BinOp
|
||||
import aqua.model.ValueModel
|
||||
import aqua.model.*
|
||||
import aqua.model.inline.state.{Arrows, Exports, Mangler}
|
||||
import aqua.model.ValueModel
|
||||
import aqua.model.inline.Inline.parDesugarPrefixOpt
|
||||
import aqua.model.inline.RawValueInliner.valueToModel
|
||||
import aqua.model.inline.TagInliner.canonicalizeIfStream
|
||||
import aqua.model.inline.Inline.parDesugarPrefixOpt
|
||||
import aqua.model.inline.state.{Exports, Mangler}
|
||||
import aqua.raw.value.ApplyBinaryOpRaw.Op as BinOp
|
||||
import aqua.raw.value.{ApplyBinaryOpRaw, ValueRaw}
|
||||
|
||||
import cats.data.Chain
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.apply.*
|
||||
import cats.syntax.flatMap.*
|
||||
|
||||
final case class IfTagInliner(
|
||||
valueRaw: ValueRaw
|
||||
|
Loading…
Reference in New Issue
Block a user