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
ability InnerAb:
arrow() -> i8, i8
func create(a: i8) -> -> i8:
closureArrow = () -> i8:
<- a
<- closureArrow
ability TestAb:
inner: InnerAb
-- func create(a: i8, b: i8) -> TestAb:
-- 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
func test() -> i8, i8:
arr1 <- create(1)
arr2 <- create(2)
<- arr1(), arr2()

View File

@ -60,7 +60,7 @@ object ArrowInliner extends Logging {
) if !outsideStreamNames.contains(n) =>
resDesugar.toList -> res
case (
cexp @ CallModel.Export(exp, st @ StreamType(_)),
cexp @ CallModel.Export(_, StreamType(_)),
(res, resDesugar)
) =>
// pass nested function results to a stream
@ -340,7 +340,7 @@ object ArrowInliner extends Logging {
_ <- Arrows[S].resolved(arrowsResolved)
_ <- 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](
arrow: FuncArrow,

View File

@ -290,13 +290,17 @@ case class ClosureTag(
override def usesVarNames: Set[String] = Set.empty
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 =
copy(
func.copy(arrow =
func.arrow.copy(
ret = func.arrow.ret.map(_.mapValues(f)),
body = func.arrow.body.map(_.mapValues(f))
)
)