VarModel -> VarRaw in collect functions (#405)

This commit is contained in:
Dima 2022-01-20 07:08:26 +03:00 committed by GitHub
parent f795edfaf7
commit 255c1f61b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 14 deletions

View File

@ -2,6 +2,7 @@ version = 3.3.1
runner.dialect = scala3 runner.dialect = scala3
docstrings.style = Asterisk docstrings.style = Asterisk
docstrings.wrap = no
maxColumn = 100 maxColumn = 100

View File

@ -5,14 +5,14 @@ import aqua.js.{CallJsFunction, CallServiceHandler, FluencePeer}
import aqua.model.{LiteralModel, VarModel} import aqua.model.{LiteralModel, VarModel}
import aqua.raw.ops import aqua.raw.ops
import aqua.raw.ops.{Call, CallServiceTag} import aqua.raw.ops.{Call, CallServiceTag}
import aqua.raw.value.LiteralRaw import aqua.raw.value.{LiteralRaw, VarRaw}
import scalajs.js import scalajs.js
import scala.concurrent.Promise import scala.concurrent.Promise
// Service that can return argument to use it from a code // Service that can return argument to use it from a code
case class ArgumentGetter(serviceId: String, value: VarModel, arg: scalajs.js.Dynamic) case class ArgumentGetter(serviceId: String, value: VarRaw, arg: scalajs.js.Dynamic)
extends ServiceFunction { extends ServiceFunction {
def registerService(peer: FluencePeer): Unit = { def registerService(peer: FluencePeer): Unit = {
CallJsFunction.registerService( CallJsFunction.registerService(
@ -44,6 +44,6 @@ object ArgumentGetter {
val ServiceId = "getDataSrv" val ServiceId = "getDataSrv"
def apply(value: VarModel, arg: scalajs.js.Dynamic): ArgumentGetter = def apply(value: VarRaw, arg: scalajs.js.Dynamic): ArgumentGetter =
ArgumentGetter(ServiceId, value, arg) ArgumentGetter(ServiceId, value, arg)
} }

View File

@ -126,7 +126,7 @@ object RunOpts extends Logging {
args: List[ValueRaw], args: List[ValueRaw],
data: Option[js.Dynamic] data: Option[js.Dynamic]
): ValidatedNec[String, Map[String, ArgumentGetter]] = { ): ValidatedNec[String, Map[String, ArgumentGetter]] = {
val vars = args.collect { case v @ VarModel(_, _, _) => val vars = args.collect { case v @ VarRaw(_, _, _) =>
v v
// one variable could be used multiple times // one variable could be used multiple times
}.distinctBy(_.name) }.distinctBy(_.name)

View File

@ -18,11 +18,11 @@ import scala.concurrent.ExecutionContext
import scala.scalajs.js import scala.scalajs.js
class Runner( class Runner(
funcName: String, funcName: String,
funcCallable: FuncArrow, funcCallable: FuncArrow,
args: List[ValueRaw], args: List[ValueRaw],
config: RunConfig, config: RunConfig,
transformConfig: TransformConfig transformConfig: TransformConfig
) { ) {
def resultVariableNames(funcCallable: FuncArrow, name: String): List[String] = def resultVariableNames(funcCallable: FuncArrow, name: String): List[String] =
@ -54,9 +54,9 @@ class Runner(
// Generates air from function, register all services and make a call through FluenceJS // Generates air from function, register all services and make a call through FluenceJS
private def genAirAndMakeCall[F[_]: Async]( private def genAirAndMakeCall[F[_]: Async](
wrapped: FuncArrow, wrapped: FuncArrow,
consoleService: Console, consoleService: Console,
finisherService: Finisher finisherService: Finisher
)(implicit ec: ExecutionContext): F[Unit] = { )(implicit ec: ExecutionContext): F[Unit] = {
val funcRes = Transform.funcRes(wrapped, transformConfig) val funcRes = Transform.funcRes(wrapped, transformConfig)
val definitions = FunctionDef(funcRes) val definitions = FunctionDef(funcRes)
@ -134,7 +134,7 @@ class Runner(
val vars = args val vars = args
.zip(funcCallable.arrowType.domain.toList) .zip(funcCallable.arrowType.domain.toList)
.collect { case (VarModel(n, _, _), argType) => .collect { case (VarRaw(n, _, _), argType) =>
(n, argType) (n, argType)
} }
.distinctBy(_._1) .distinctBy(_._1)