mirror of
https://github.com/fluencelabs/aqua.git
synced 2024-12-04 06:30: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:
|
export newFunc
|
||||||
MyAbility = Troll(f = "sf")
|
|
||||||
|
|
||||||
<- 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)
|
defineRenames <- Mangler[S].findAndForbidNames(defineNames)
|
||||||
|
|
||||||
renaming = (
|
renaming =
|
||||||
data.renames ++
|
data.renames ++
|
||||||
streamRenames ++
|
streamRenames ++
|
||||||
arrowRenames ++
|
arrowRenames ++
|
||||||
@ -325,7 +325,6 @@ object ArrowInliner extends Logging {
|
|||||||
capturedValues.renames ++
|
capturedValues.renames ++
|
||||||
capturedArrows.renames ++
|
capturedArrows.renames ++
|
||||||
defineRenames
|
defineRenames
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Optimize resolve.
|
* TODO: Optimize resolve.
|
||||||
|
@ -68,13 +68,15 @@ object TagInliner extends Logging {
|
|||||||
prefix: Option[OpModel.Tree] = None
|
prefix: Option[OpModel.Tree] = None
|
||||||
) extends TagInlined(prefix)
|
) extends TagInlined(prefix)
|
||||||
|
|
||||||
|
// case After(process: () => State[S, TagInlined[S]], prefix: Option[OpModel.Tree] = None) extends TagInlined(prefix)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finalize inlining, construct a tree
|
* Finalize inlining, construct a tree
|
||||||
*
|
*
|
||||||
* @param children Children results
|
* @param children Children results
|
||||||
* @return Result of inlining
|
* @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 {
|
val inlined = this match {
|
||||||
case Empty(_) => children
|
case Empty(_) => children
|
||||||
case Single(model, _) =>
|
case Single(model, _) =>
|
||||||
@ -83,7 +85,7 @@ object TagInliner extends Logging {
|
|||||||
Chain.one(toModel(children))
|
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))
|
} yield model.fold(TagInlined.Empty())(m => TagInlined.Single(model = m))
|
||||||
|
|
||||||
case RestrictionTag(name, typ) =>
|
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))
|
pure(RestrictionModel(name, typ))
|
||||||
|
|
||||||
case DeclareStreamTag(value) =>
|
case DeclareStreamTag(value) =>
|
||||||
@ -444,7 +456,8 @@ object TagInliner extends Logging {
|
|||||||
headInlined <- f(cf.head)
|
headInlined <- f(cf.head)
|
||||||
tail <- StateT.liftF(cf.tail)
|
tail <- StateT.liftF(cf.tail)
|
||||||
children <- tail.traverse(traverseS[S](_, f))
|
children <- tail.traverse(traverseS[S](_, f))
|
||||||
} yield headInlined.build(children)
|
inlined <- headInlined.build(children)
|
||||||
|
} yield inlined
|
||||||
|
|
||||||
def handleTree[S: Exports: Mangler: Arrows](
|
def handleTree[S: Exports: Mangler: Arrows](
|
||||||
tree: RawTag.Tree
|
tree: RawTag.Tree
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package aqua.model.transform.pre
|
package aqua.model.transform.pre
|
||||||
|
|
||||||
import aqua.model.FuncArrow
|
import aqua.model.{ArgsCall, FuncArrow}
|
||||||
import aqua.model.ArgsCall
|
import aqua.raw.ops.*
|
||||||
import aqua.raw.ops.{Call, CallArrowRawTag, RawTag, SeqTag, TryTag}
|
import aqua.raw.value.VarRaw
|
||||||
import aqua.raw.value.{ValueRaw, VarRaw}
|
|
||||||
import aqua.types.*
|
import aqua.types.*
|
||||||
|
|
||||||
import cats.syntax.show.*
|
|
||||||
import cats.syntax.option.*
|
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
|
* @return FuncArrow that can be called and delegates the call to a client-registered callback
|
||||||
*/
|
*/
|
||||||
private def arrowToCallback(name: String, arrowType: ArrowType): FuncArrow = {
|
private def arrowToCallback(name: String, arrowType: ArrowType): FuncArrow = {
|
||||||
val (args, call, ret) = ArgsCall.arrowToArgsCallRet(arrowType)
|
val (_, call, ret) = ArgsCall.arrowToArgsCallRet(arrowType)
|
||||||
FuncArrow(
|
FuncArrow(
|
||||||
arrowCallbackPrefix + name,
|
arrowCallbackPrefix + name,
|
||||||
callback(name, call),
|
callback(name, call),
|
||||||
|
@ -3,15 +3,15 @@ package aqua.semantics.rules.names
|
|||||||
import aqua.parser.lexer.{Name, Token}
|
import aqua.parser.lexer.{Name, Token}
|
||||||
import aqua.semantics.Levenshtein
|
import aqua.semantics.Levenshtein
|
||||||
import aqua.semantics.rules.StackInterpreter
|
import aqua.semantics.rules.StackInterpreter
|
||||||
import aqua.semantics.rules.report.ReportAlgebra
|
|
||||||
import aqua.semantics.rules.locations.LocationsAlgebra
|
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.data.{OptionT, State}
|
||||||
|
import cats.syntax.all.*
|
||||||
|
import cats.syntax.applicative.*
|
||||||
import cats.syntax.flatMap.*
|
import cats.syntax.flatMap.*
|
||||||
import cats.syntax.functor.*
|
import cats.syntax.functor.*
|
||||||
import cats.syntax.applicative.*
|
|
||||||
import cats.syntax.all.*
|
|
||||||
import monocle.Lens
|
import monocle.Lens
|
||||||
import monocle.macros.GenLens
|
import monocle.macros.GenLens
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class NamesInterpreter[S[_], X](using
|
|||||||
mapStackHead(Map.empty) { frame =>
|
mapStackHead(Map.empty) { frame =>
|
||||||
frame -> frame.names.collect { case (n, st @ StreamType(_)) =>
|
frame -> frame.names.collect { case (n, st @ StreamType(_)) =>
|
||||||
n -> st
|
n -> st
|
||||||
}.toMap
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override def beginScope(token: Token[S]): SX[Unit] =
|
override def beginScope(token: Token[S]): SX[Unit] =
|
||||||
|
Loading…
Reference in New Issue
Block a user