mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-03 14:10:17 +00:00
build[S]
This commit is contained in:
parent
78ee753c7b
commit
d130e5aab0
@ -1,6 +1,14 @@
|
||||
alias Troll: u32
|
||||
aqua A
|
||||
|
||||
func test() -> i8:
|
||||
MyAbility = Troll(f = "sf")
|
||||
export newFunc
|
||||
|
||||
<- 42
|
||||
func returnNil() -> *string:
|
||||
someStr: *string
|
||||
<- someStr
|
||||
|
||||
func newFunc() -> []string:
|
||||
-- new stream
|
||||
stream <- returnNil() -- stream -> someStr: *str
|
||||
stream <<- "asd"
|
||||
<- stream
|
||||
-- end
|
@ -317,7 +317,7 @@ object ArrowInliner extends Logging {
|
||||
)
|
||||
defineRenames <- Mangler[S].findAndForbidNames(defineNames)
|
||||
|
||||
renaming = (
|
||||
renaming =
|
||||
data.renames ++
|
||||
streamRenames ++
|
||||
arrowRenames ++
|
||||
@ -325,7 +325,6 @@ object ArrowInliner extends Logging {
|
||||
capturedValues.renames ++
|
||||
capturedArrows.renames ++
|
||||
defineRenames
|
||||
)
|
||||
|
||||
/**
|
||||
* TODO: Optimize resolve.
|
||||
|
@ -68,13 +68,15 @@ object TagInliner extends Logging {
|
||||
prefix: Option[OpModel.Tree] = None
|
||||
) extends TagInlined(prefix)
|
||||
|
||||
// case After(process: () => State[S, TagInlined[S]], prefix: Option[OpModel.Tree] = None) extends TagInlined(prefix)
|
||||
|
||||
/**
|
||||
* Finalize inlining, construct a tree
|
||||
*
|
||||
* @param children Children results
|
||||
* @return Result of inlining
|
||||
*/
|
||||
def build(children: Chain[OpModel.Tree]): OpModel.Tree = {
|
||||
def build[S](children: Chain[OpModel.Tree]): State[S, OpModel.Tree] = {
|
||||
val inlined = this match {
|
||||
case Empty(_) => children
|
||||
case Single(model, _) =>
|
||||
@ -83,7 +85,7 @@ object TagInliner extends Logging {
|
||||
Chain.one(toModel(children))
|
||||
}
|
||||
|
||||
SeqModel.wrap(Chain.fromOption(prefix) ++ inlined)
|
||||
State.pure(SeqModel.wrap(Chain.fromOption(prefix) ++ inlined))
|
||||
}
|
||||
}
|
||||
|
||||
@ -371,6 +373,16 @@ object TagInliner extends Logging {
|
||||
} yield model.fold(TagInlined.Empty())(m => TagInlined.Single(model = m))
|
||||
|
||||
case RestrictionTag(name, typ) =>
|
||||
// for {
|
||||
// exps <- Exports[S].exports
|
||||
// _ = println(s"exps for restriction tag $name: " + exps)
|
||||
// } yield TagInlined.Single(model = RestrictionModel(name, typ))
|
||||
// ...after(
|
||||
// for {
|
||||
// // exps <- Exports[S].exports
|
||||
// // _ = println(s"exps for restriction tag $name: " + exps)
|
||||
// // } yield TagInlined.Single(model = RestrictionModel(name, typ))
|
||||
// )
|
||||
pure(RestrictionModel(name, typ))
|
||||
|
||||
case DeclareStreamTag(value) =>
|
||||
@ -444,7 +456,8 @@ object TagInliner extends Logging {
|
||||
headInlined <- f(cf.head)
|
||||
tail <- StateT.liftF(cf.tail)
|
||||
children <- tail.traverse(traverseS[S](_, f))
|
||||
} yield headInlined.build(children)
|
||||
inlined <- headInlined.build(children)
|
||||
} yield inlined
|
||||
|
||||
def handleTree[S: Exports: Mangler: Arrows](
|
||||
tree: RawTag.Tree
|
||||
|
@ -1,12 +1,10 @@
|
||||
package aqua.model.transform.pre
|
||||
|
||||
import aqua.model.FuncArrow
|
||||
import aqua.model.ArgsCall
|
||||
import aqua.raw.ops.{Call, CallArrowRawTag, RawTag, SeqTag, TryTag}
|
||||
import aqua.raw.value.{ValueRaw, VarRaw}
|
||||
import aqua.model.{ArgsCall, FuncArrow}
|
||||
import aqua.raw.ops.*
|
||||
import aqua.raw.value.VarRaw
|
||||
import aqua.types.*
|
||||
|
||||
import cats.syntax.show.*
|
||||
import cats.syntax.option.*
|
||||
|
||||
/**
|
||||
@ -47,7 +45,7 @@ case class FuncPreTransformer(
|
||||
* @return FuncArrow that can be called and delegates the call to a client-registered callback
|
||||
*/
|
||||
private def arrowToCallback(name: String, arrowType: ArrowType): FuncArrow = {
|
||||
val (args, call, ret) = ArgsCall.arrowToArgsCallRet(arrowType)
|
||||
val (_, call, ret) = ArgsCall.arrowToArgsCallRet(arrowType)
|
||||
FuncArrow(
|
||||
arrowCallbackPrefix + name,
|
||||
callback(name, call),
|
||||
|
@ -3,15 +3,15 @@ package aqua.semantics.rules.names
|
||||
import aqua.parser.lexer.{Name, Token}
|
||||
import aqua.semantics.Levenshtein
|
||||
import aqua.semantics.rules.StackInterpreter
|
||||
import aqua.semantics.rules.report.ReportAlgebra
|
||||
import aqua.semantics.rules.locations.LocationsAlgebra
|
||||
import aqua.types.{AbilityType, ArrowType, StreamType, Type}
|
||||
import aqua.semantics.rules.report.ReportAlgebra
|
||||
import aqua.types.{ArrowType, StreamType, Type}
|
||||
|
||||
import cats.data.{OptionT, State}
|
||||
import cats.syntax.all.*
|
||||
import cats.syntax.applicative.*
|
||||
import cats.syntax.flatMap.*
|
||||
import cats.syntax.functor.*
|
||||
import cats.syntax.applicative.*
|
||||
import cats.syntax.all.*
|
||||
import monocle.Lens
|
||||
import monocle.macros.GenLens
|
||||
|
||||
@ -160,7 +160,7 @@ class NamesInterpreter[S[_], X](using
|
||||
mapStackHead(Map.empty) { frame =>
|
||||
frame -> frame.names.collect { case (n, st @ StreamType(_)) =>
|
||||
n -> st
|
||||
}.toMap
|
||||
}
|
||||
}
|
||||
|
||||
override def beginScope(token: Token[S]): SX[Unit] =
|
||||
|
Loading…
Reference in New Issue
Block a user