fix: name uniqueness in stream gate (#676)

* fix name uniqueness in gate

* fix unit test
This commit is contained in:
Dima 2023-02-25 12:12:40 +07:00 committed by GitHub
parent 75c7135e12
commit 00ee8b5312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 5 deletions

View File

@ -19,6 +19,8 @@ trait Backend {
object Backend {
val client = "IFluenceClient$$"
trait Transform extends Backend {
def transform(ex: AquaContext): AquaRes
}

View File

@ -4,7 +4,7 @@ import aqua.backend.ts.TypeScriptTypes
import aqua.backend.*
import aqua.res.AquaRes
case class JavaScriptBackend(isOldFluenceJs: Boolean, client: String) extends Backend {
case class JavaScriptBackend(isOldFluenceJs: Boolean, client: String = Backend.client) extends Backend {
val ext = ".js"
val tsExt = ".d.ts"

View File

@ -4,7 +4,7 @@ import aqua.backend.{Backend, Generated, OutputFile}
import aqua.res.AquaRes
import cats.data.NonEmptyChain
case class TypeScriptBackend(isOldFluenceJs: Boolean, client: String) extends Backend {
case class TypeScriptBackend(isOldFluenceJs: Boolean, client: String = Backend.client) extends Backend {
val ext = ".ts"

View File

@ -36,7 +36,7 @@ object AquaCli extends IOApp with Logging {
case object AirTarget extends CompileTarget
def targetToBackend(target: CompileTarget, isOldFluenceJs: Boolean): Backend = {
val client = if (isOldFluenceJs) "FluencePeer" else "IFluenceClient$$"
val client = if (isOldFluenceJs) "FluencePeer" else Backend.client
target match {
case TypescriptTarget =>
TypeScriptBackend(isOldFluenceJs, client)

View File

@ -130,7 +130,7 @@ class AquaCompilerSpec extends AnyFlatSpec with Matchers {
private def join(vm: VarModel, length: ValueModel) = {
val testVM = VarModel(vm.name + "_test", vm.`type`)
val iter = VarModel("s", ScalarType.string)
val iter = VarModel(vm.name + "_fold_var", ScalarType.string)
val canon = VarModel(vm.name + "_iter_canon", CanonStreamType(ScalarType.string))
val canonRes = VarModel(vm.name + "_result_canon", CanonStreamType(ScalarType.string))
val arrayRes = VarModel(vm.name + "_gate", ArrayType(ScalarType.string))

View File

@ -23,11 +23,12 @@ object ApplyGateRawInliner extends RawInliner[ApplyGateRaw] with Logging {
uniqueTestName <- Mangler[S].findAndForbidName(afr.name + "_test")
uniqueIdxIncr <- Mangler[S].findAndForbidName(afr.name + "_incr")
uniqueIterCanon <- Mangler[S].findAndForbidName(afr.name + "_iter_canon")
uniqueIter <- Mangler[S].findAndForbidName(afr.name + "_fold_var")
idxFolded <- unfold(afr.idx)
(idxModel, idxInline) = idxFolded
} yield {
val varSTest = VarModel(uniqueTestName, afr.streamType)
val iter = VarModel("s", afr.streamType.element)
val iter = VarModel(uniqueIter, afr.streamType.element)
val iterCanon = VarModel(uniqueIterCanon, CanonStreamType(afr.streamType.element))