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