mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 22:50:18 +00:00
Multireturn bugfix (#238)
This commit is contained in:
parent
3eb3ecc221
commit
f7aa118006
@ -1,15 +1,20 @@
|
|||||||
service Getter("test"):
|
service GetStr("multiret-test"):
|
||||||
createStr: u32 -> string
|
retStr: string -> string
|
||||||
|
|
||||||
service OpO("op"):
|
service GetNum("multiret-num"):
|
||||||
identity: string -> string
|
retNum: -> u8
|
||||||
|
|
||||||
-- a question mark means that this constant could be rewritten before this definition
|
const someNum = 5
|
||||||
const anotherConst ?= "default-str"
|
const someStr = "some-str"
|
||||||
const uniqueConst ?= 5
|
|
||||||
|
|
||||||
func callConstant() -> []string, u8:
|
func tupleFunc() -> string, u8:
|
||||||
|
str <- GetStr.retStr(someStr)
|
||||||
|
n <- GetNum.retNum()
|
||||||
|
<- str, n
|
||||||
|
|
||||||
|
func multiReturnFunc(somethingToReturn: []u8, smthOption: ?string) -> []string, u8, string, []u8, ?string, u8:
|
||||||
res: *string
|
res: *string
|
||||||
res <- Getter.createStr(uniqueConst)
|
res <- GetStr.retStr(someStr)
|
||||||
res <- OpO.identity(anotherConst)
|
res <- GetStr.retStr("random-str")
|
||||||
<- res, 5
|
res, tNum <- tupleFunc()
|
||||||
|
<- res, 5, someStr, somethingToReturn, smthOption, tNum
|
||||||
|
@ -167,7 +167,7 @@ case class FuncCallable(
|
|||||||
case ((ops, rets), (_, r)) => (ops, r :: rets)
|
case ((ops, rets), (_, r)) => (ops, r :: rets)
|
||||||
}
|
}
|
||||||
|
|
||||||
FuncOps.seq(ops.reverse: _*) -> rets
|
FuncOps.seq(ops.reverse: _*) -> rets.reverse
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +44,13 @@ case class ResolveFunc(
|
|||||||
case t => t
|
case t => t
|
||||||
}).toLabelledList(returnVar)
|
}).toLabelledList(returnVar)
|
||||||
|
|
||||||
|
val retModel = returnType.map { case (l, t) => VarModel(l, t) }
|
||||||
|
|
||||||
|
val funcCall = Call(
|
||||||
|
func.arrowType.domain.toLabelledList().map(ad => VarModel(ad._1, ad._2)),
|
||||||
|
returnType.map { case (l, t) => Call.Export(l, t) }
|
||||||
|
)
|
||||||
|
|
||||||
FuncCallable(
|
FuncCallable(
|
||||||
wrapCallableName,
|
wrapCallableName,
|
||||||
transform(
|
transform(
|
||||||
@ -51,13 +58,10 @@ case class ResolveFunc(
|
|||||||
FuncOps
|
FuncOps
|
||||||
.callArrow(
|
.callArrow(
|
||||||
func.funcName,
|
func.funcName,
|
||||||
Call(
|
funcCall
|
||||||
func.arrowType.domain.toLabelledList().map(ad => VarModel(ad._1, ad._2)),
|
) :: (returnType.headOption
|
||||||
returnType.map { case (l, t) => Call.Export(l, t) }
|
.map(_ => returnCallback(retModel))
|
||||||
)
|
.toList): _*
|
||||||
) :: returnType.headOption
|
|
||||||
.map(_ => returnCallback(returnType.map { case (l, t) => VarModel(l, t) }))
|
|
||||||
.toList: _*
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
ArrowType(ConsType.cons(func.funcName, func.arrowType, NilType), NilType),
|
ArrowType(ConsType.cons(func.funcName, func.arrowType, NilType), NilType),
|
||||||
|
@ -96,6 +96,7 @@ class FuncSem[F[_]](val expr: FuncExpr[F]) extends AnyVal {
|
|||||||
.map(vs.prependedAll)
|
.map(vs.prependedAll)
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.map(_.reverse)
|
||||||
.flatMap(retModel =>
|
.flatMap(retModel =>
|
||||||
// Erase arguments and internal variables
|
// Erase arguments and internal variables
|
||||||
A.endScope() >> N.endScope() >> (bodyGen match {
|
A.endScope() >> N.endScope() >> (bodyGen match {
|
||||||
|
@ -94,7 +94,7 @@ object ConsType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case class LabelledConsType(label: String, `type`: Type, tail: ProductType) extends ConsType {
|
case class LabelledConsType(label: String, `type`: Type, tail: ProductType) extends ConsType {
|
||||||
override def toString: String = s"($label: " + `type` + s" :: $tail"
|
override def toString: String = s"($label: " + `type` + s") :: $tail"
|
||||||
}
|
}
|
||||||
|
|
||||||
case class UnlabelledConsType(`type`: Type, tail: ProductType) extends ConsType {
|
case class UnlabelledConsType(`type`: Type, tail: ProductType) extends ConsType {
|
||||||
|
Loading…
Reference in New Issue
Block a user