diff --git a/.jvmopts b/.jvmopts index 5de9cbcb..0fc0c685 100644 --- a/.jvmopts +++ b/.jvmopts @@ -1,6 +1,6 @@ -Dfile.encoding=UTF8 -Xms1G --Xmx6G +-Xmx16G -XX:ReservedCodeCacheSize=500M -XX:+TieredCompilation -XX:+UseParallelGC \ No newline at end of file diff --git a/api/aqua-api-example/index.js b/api/aqua-api-example/index.js index 26e0bb7d..6c3ec3dd 100644 --- a/api/aqua-api-example/index.js +++ b/api/aqua-api-example/index.js @@ -2,6 +2,7 @@ import { Aqua, Call, Path, + AquaConfig } from "@fluencelabs/aqua-api/aqua-api.js"; const aquaPath = new Path("test.aqua") @@ -9,8 +10,11 @@ const aquaPath = new Path("test.aqua") const args = {num: 42} const call = new Call("getNumber(num)", args, aquaPath) + +const inputPath = new Path("test.aqua") + // compile call -const compilationResult = await Aqua.compile(call, []) +const compilationResult = await Aqua.compile(inputPath, [], new AquaConfig("info", [], false, false, "typescript")) /* @@ -29,4 +33,5 @@ export class CompilationResult { // get function definition, that describes types of arguments and results of a function // and AIR script -const {funcDef, script} = compilationResult.functionCall + +console.log(compilationResult.generatedSources) diff --git a/api/aqua-api-example/package-lock.json b/api/aqua-api-example/package-lock.json index 954514cc..056377ea 100644 --- a/api/aqua-api-example/package-lock.json +++ b/api/aqua-api-example/package-lock.json @@ -9,13 +9,19 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "@fluencelabs/aqua-api": "0.10.4" + "@fluencelabs/aqua-api": "file:/../aqua-api-npm" + } + }, + "../aqua-api-npm": { + "version": "0.11.0", + "license": "Apache-2.0", + "devDependencies": { + "@fluencelabs/fluence": "0.28.0" } }, "node_modules/@fluencelabs/aqua-api": { - "version": "0.10.4", - "resolved": "https://registry.npmjs.org/@fluencelabs/aqua-api/-/aqua-api-0.10.4.tgz", - "integrity": "sha512-mBT/ht0mVcGqBfkrnQw9E/tqIW3RNOCDhNwjra9X5WI/TRlztU3G8Vn/odVn6YTpZWJeDwn1qN1VgLoS3VkASA==" + "resolved": "../aqua-api-npm", + "link": true } } } diff --git a/api/aqua-api-example/package.json b/api/aqua-api-example/package.json index 027143fd..ca2fee46 100644 --- a/api/aqua-api-example/package.json +++ b/api/aqua-api-example/package.json @@ -10,6 +10,6 @@ "type": "module", "license": "Apache-2.0", "dependencies": { - "@fluencelabs/aqua-api": "0.10.4" + "@fluencelabs/aqua-api": "file:/../aqua-api-npm" } } diff --git a/aqua-src/antithesis.aqua b/aqua-src/antithesis.aqua index 1194b54e..e9725391 100644 --- a/aqua-src/antithesis.aqua +++ b/aqua-src/antithesis.aqua @@ -1,9 +1,7 @@ -module Import3 declares * +import "import1" +import "import2" -export foo_bar - -use "export.aqua" - -func foo_bar() -> string, string: - z <- FooBars.foo() - <- z, FooBars.DECLARE_CONST2 \ No newline at end of file +func transitive() -> string, string: + result1 <- runFrom1() + result2 <- runFrom2() + <- result1, result2 \ No newline at end of file diff --git a/aqua-src/testImport1/import1.aqua b/aqua-src/testImport1/import1.aqua new file mode 100644 index 00000000..1c84f897 --- /dev/null +++ b/aqua-src/testImport1/import1.aqua @@ -0,0 +1,8 @@ +import "inside/somelib" + +service A(""): + call(s: string) -> string + +func runFrom1() -> string: + res <- version() + <- A.call(res) \ No newline at end of file diff --git a/aqua-src/testImport1/insideLib1/inside/somelib.aqua b/aqua-src/testImport1/insideLib1/inside/somelib.aqua new file mode 100644 index 00000000..476d71e3 --- /dev/null +++ b/aqua-src/testImport1/insideLib1/inside/somelib.aqua @@ -0,0 +1,5 @@ +service Some(""): + callee(s: string) -> string + +func version() -> string: + <- Some.callee("11111111") \ No newline at end of file diff --git a/aqua-src/testImport2/import2.aqua b/aqua-src/testImport2/import2.aqua new file mode 100644 index 00000000..09a0f71e --- /dev/null +++ b/aqua-src/testImport2/import2.aqua @@ -0,0 +1,8 @@ +import "inside/somelib" + +service B(""): + bzzzz(s: string) -> string + +func runFrom2() -> string: + res <- version() + <- B.bzzzz(res) \ No newline at end of file diff --git a/aqua-src/testImport2/insideLib2/inside/somelib.aqua b/aqua-src/testImport2/insideLib2/inside/somelib.aqua new file mode 100644 index 00000000..85b50591 --- /dev/null +++ b/aqua-src/testImport2/insideLib2/inside/somelib.aqua @@ -0,0 +1,5 @@ +service Some(""): + callee(s: string) -> string + +func version() -> string: + <- Some.callee("222222222") \ No newline at end of file diff --git a/cli/cli/.jvm/src/main/scala/aqua/Test.scala b/cli/cli/.jvm/src/main/scala/aqua/Test.scala index 38ae5e76..46696f17 100644 --- a/cli/cli/.jvm/src/main/scala/aqua/Test.scala +++ b/cli/cli/.jvm/src/main/scala/aqua/Test.scala @@ -24,7 +24,12 @@ object Test extends IOApp.Simple { _ <- AquaPathCompiler .compileFilesTo[IO]( Path("./aqua-src/antithesis.aqua"), - List(Path("./aqua")), + List( + Path("./aqua-src/testImport1"), + Path("./aqua-src/testImport2"), + Path("./aqua-src/testImport1/insideLib1"), + Path("./aqua-src/testImport2/insideLib2") + ), Option(Path("./target")), TypeScriptBackend(false, "IFluenceClient$$"), TransformConfig(wrapWithXor = false), diff --git a/compiler/src/main/scala/aqua/compiler/AquaCompiler.scala b/compiler/src/main/scala/aqua/compiler/AquaCompiler.scala index 34ac6703..53610b8c 100644 --- a/compiler/src/main/scala/aqua/compiler/AquaCompiler.scala +++ b/compiler/src/main/scala/aqua/compiler/AquaCompiler.scala @@ -67,6 +67,13 @@ class AquaCompiler[F[_]: Monad, E, I: Order, S[_]: Comonad, C: Monoid: Picker]( .mapValues(ctx(_)) .collect { case (fn, Some(fc)) => fn -> fc } .toMap + + println("======================") + println("imports: " + imports) + println("for: " + mod.imports) + println("from: " + mod.id) + println("======================") + val header = mod.body.head // To manage imports, exports run HeaderHandler headerHandler diff --git a/io/src/main/scala/aqua/files/AquaFileSources.scala b/io/src/main/scala/aqua/files/AquaFileSources.scala index facb5934..bf792aed 100644 --- a/io/src/main/scala/aqua/files/AquaFileSources.scala +++ b/io/src/main/scala/aqua/files/AquaFileSources.scala @@ -23,6 +23,8 @@ class AquaFileSources[F[_]: AquaIO: Monad: Files: Functor]( ) extends AquaSources[F, AquaFileError, FileModuleId] with Logging { private val filesIO = implicitly[AquaIO[F]] + private val importFromAbs = importFrom.map(_.absolute.normalize) + override def sources: F[ValidatedNec[AquaFileError, Chain[(FileModuleId, String)]]] = filesIO.listAqua(sourcesPath).flatMap { case Validated.Valid(files) => @@ -57,9 +59,15 @@ class AquaFileSources[F[_]: AquaIO: Monad: Files: Functor]( val validatedPath = Validated.fromEither(Try(Path(imp)).toEither.leftMap(FileSystemError.apply)) validatedPath match { case Validated.Valid(importP) => + importFromAbs.sortBy { importPath => + + } + println(s"importP: $importP") + println(s"resolveImport from '$from' import '$imp'") + println(s"importFrom: $importFromAbs with ${from.file.parent}") // if there is no `.aqua` extension, than add it filesIO - .resolve(importP, importFrom.prependedAll(from.file.parent)) + .resolve(importP, importFromAbs.prependedAll(from.file.parent)) .bimap(NonEmptyChain.one, FileModuleId(_)) .value .map(Validated.fromEither) diff --git a/language-server/language-server-api/.jvm/src/main/scala/aqua/lsp/Test.scala b/language-server/language-server-api/.jvm/src/main/scala/aqua/lsp/Test.scala index b58dd32b..07ed22cb 100644 --- a/language-server/language-server-api/.jvm/src/main/scala/aqua/lsp/Test.scala +++ b/language-server/language-server-api/.jvm/src/main/scala/aqua/lsp/Test.scala @@ -32,7 +32,16 @@ object Test extends IOApp.Simple { case Validated.Invalid(errs) => errs.map(System.err.println): Unit case Validated.Valid(res) => - res.map(println): Unit + res.foreach { + case (_, a) => a.foreach(_.values.toList.map { + context => + println("import tokens:") + println(context.importTokens) + println("locations:") + println(context.locations) + }) + } + } _ <- IO.println("Compilation ends in: " + (System.currentTimeMillis() - start) + " ms") } yield () diff --git a/model/raw/src/main/scala/aqua/raw/RawContext.scala b/model/raw/src/main/scala/aqua/raw/RawContext.scala index 4c5b1d96..707611ad 100644 --- a/model/raw/src/main/scala/aqua/raw/RawContext.scala +++ b/model/raw/src/main/scala/aqua/raw/RawContext.scala @@ -92,7 +92,7 @@ case class RawContext( ) .map(StructType(name, _)) - override def toString: String = s"module: $module\ndeclares: $declares\nexports: $exports" + override def toString: String = s"module: $module, declares: $declares, exports: $exports" } object RawContext {