This commit is contained in:
DieMyst 2023-10-24 16:40:23 +07:00
parent 2f11a0649f
commit 66bcd39abe
3 changed files with 16 additions and 33 deletions

View File

@ -2,33 +2,12 @@ aqua A
export test export test
ability InnerAb: func create(a: i8) -> -> i8:
arrow() -> i8, i8 closureArrow = () -> i8:
<- a
<- closureArrow
ability TestAb: func test() -> i8, i8:
inner: InnerAb arr1 <- create(1)
arr2 <- create(2)
-- func create(a: i8, b: i8) -> TestAb: <- arr1(), arr2()
-- arrow = () -> i8, i8:
-- <- a, b
-- <- TestAb(inner = InnerAb(arrow = arrow))
--
-- func test() -> i8, i8, i8, i8, i8, i8:
-- Ab <- create(1, 2)
-- ab <- create(3, 4)
-- AB <- create(5, 6)
-- res1, res2 <- ab.inner.arrow()
-- res3, res4 <- Ab.inner.arrow()
-- res5, res6 <- AB.inner.arrow()
-- <- res1, res2, res3, res4, res5, res6
func create(a: i8, b: i8) -> i8 -> i8, i8:
arrow = (c: i8) -> i8, i8:
<- a, b
<- arrow
func test() -> i8, i8, i8, i8, i8, i8:
Ab <- create(1, 2)
ab <- create(3, 4)
AB <- create(5, 6)
<- res1, res2, res3, res4, res5, res6

View File

@ -60,7 +60,7 @@ object ArrowInliner extends Logging {
) if !outsideStreamNames.contains(n) => ) if !outsideStreamNames.contains(n) =>
resDesugar.toList -> res resDesugar.toList -> res
case ( case (
cexp @ CallModel.Export(exp, st @ StreamType(_)), cexp @ CallModel.Export(_, StreamType(_)),
(res, resDesugar) (res, resDesugar)
) => ) =>
// pass nested function results to a stream // pass nested function results to a stream
@ -340,7 +340,7 @@ object ArrowInliner extends Logging {
_ <- Arrows[S].resolved(arrowsResolved) _ <- Arrows[S].resolved(arrowsResolved)
_ <- Exports[S].resolved(exportsResolved) _ <- Exports[S].resolved(exportsResolved)
} yield fn.copy(body = tree, ret = ret) } yield fn.copy(body = tree, ret = ret, capturedValues = capturedValues.renamed)
private[inline] def callArrowRet[S: Exports: Arrows: Mangler]( private[inline] def callArrowRet[S: Exports: Arrows: Mangler](
arrow: FuncArrow, arrow: FuncArrow,

View File

@ -290,13 +290,17 @@ case class ClosureTag(
override def usesVarNames: Set[String] = Set.empty override def usesVarNames: Set[String] = Set.empty
override def renameExports(map: Map[String, String]): RawTag = override def renameExports(map: Map[String, String]): RawTag =
copy(func = func.copy(name = map.getOrElse(func.name, func.name))) copy(func =
func.copy(
name = map.getOrElse(func.name, func.name),
arrow = func.arrow.copy(ret = func.arrow.ret.map(_.renameVars(map)))
)
)
override def mapValues(f: ValueRaw => ValueRaw): RawTag = override def mapValues(f: ValueRaw => ValueRaw): RawTag =
copy( copy(
func.copy(arrow = func.copy(arrow =
func.arrow.copy( func.arrow.copy(
ret = func.arrow.ret.map(_.mapValues(f)),
body = func.arrow.body.map(_.mapValues(f)) body = func.arrow.body.map(_.mapValues(f))
) )
) )