diff --git a/aqua/examples/complex.aqua b/aqua/examples/complex.aqua index 3f4d269..8da7cb1 100644 --- a/aqua/examples/complex.aqua +++ b/aqua/examples/complex.aqua @@ -5,9 +5,15 @@ import "func.aqua" service TestS("some-id"): t: string -> string + multiline(a: string, + b: string, + c: bool) -> string -- just a lot of imports and calls -func doStuff(a: string, b: string, c: bool, d: bool, e: []string, g: []string, str: string) -> []string: +func doStuff(a: string, + b: string, + c: bool, + d: bool, e: []string, g: []string, str: string) -> []string: stream: *string stream <- TestS.t(str) par Println.print(a) @@ -22,4 +28,7 @@ func doStuff(a: string, b: string, c: bool, d: bool, e: []string, g: []string, s stream <- TestS.t(gEl) stream <- TestS.t(eEl) stream <- TestS.t(eEl) + stream <- TestS.multiline(a, + b, + c) <- stream diff --git a/aqua/examples/constants.aqua b/aqua/examples/constants.aqua index 21277c4..347c0b9 100644 --- a/aqua/examples/constants.aqua +++ b/aqua/examples/constants.aqua @@ -8,6 +8,7 @@ service OpO("op"): -- a question mark means that this constant could be rewritten before this definition const anotherConst ?= "default-str" +const uniqueConst ?= 5 func callConstant() -> []string: res: *string diff --git a/src/compiled/examples/complex.ts b/src/compiled/examples/complex.ts index 29cb4e5..62d33a6 100644 --- a/src/compiled/examples/complex.ts +++ b/src/compiled/examples/complex.ts @@ -34,92 +34,92 @@ export async function doStuff(client: FluenceClient, a: string, b: string, c: bo (seq (seq (seq - (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) - (call %init_peer_id% ("getDataSrv" "a") [] a) + (seq + (call %init_peer_id% ("getDataSrv" "-relay-") [] -relay-) + (call %init_peer_id% ("getDataSrv" "a") [] a) + ) + (call %init_peer_id% ("getDataSrv" "b") [] b) ) - (call %init_peer_id% ("getDataSrv" "b") [] b) + (call %init_peer_id% ("getDataSrv" "c") [] c) ) - (call %init_peer_id% ("getDataSrv" "c") [] c) + (call %init_peer_id% ("getDataSrv" "d") [] d) ) - (call %init_peer_id% ("getDataSrv" "d") [] d) + (call %init_peer_id% ("getDataSrv" "e") [] e) ) - (call %init_peer_id% ("getDataSrv" "e") [] e) + (call %init_peer_id% ("getDataSrv" "g") [] g) ) - (call %init_peer_id% ("getDataSrv" "g") [] g) + (call %init_peer_id% ("getDataSrv" "str") [] str) ) - (call %init_peer_id% ("getDataSrv" "str") [] str) + (call %init_peer_id% ("some-id" "t") [str] $stream) ) - (call %init_peer_id% ("some-id" "t") [str] $stream) - ) - (par - (call %init_peer_id% ("println-service-id" "print") [a]) - (seq + (par + (call %init_peer_id% ("println-service-id" "print") [a]) (seq (seq - (call -relay- ("op" "identity") []) - (xor - (call a ("peer" "identify") []) - (seq - (call -relay- ("op" "identity") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + (seq + (call -relay- ("op" "identity") []) + (xor + (call a ("peer" "identify") []) + (seq + (call -relay- ("op" "identity") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 1]) + ) ) ) + (call -relay- ("op" "identity") []) ) - (call -relay- ("op" "identity") []) + (call %init_peer_id% ("op" "identity") []) ) - (call %init_peer_id% ("op" "identity") []) ) ) + (call -relay- ("op" "identity") []) ) - (call -relay- ("op" "identity") []) - ) - (xor (xor - (match c true - (xor - (match d true - (xor - (fold e eEl + (xor + (match c true + (xor + (match d true + (xor + (fold e eEl + (seq + (seq + (fold g gEl + (seq + (seq + (call b ("some-id" "t") [gEl] $stream) + (call b ("some-id" "t") [eEl] $stream) + ) + (next gEl) + ) + ) + (call b ("some-id" "t") [eEl] $stream) + ) + (next eEl) + ) + ) (seq (seq - (fold g gEl - (seq - (seq - (call b ("some-id" "t") [gEl] $stream) - (call b ("some-id" "t") [eEl] $stream) - ) - (next gEl) - ) - ) - (call b ("some-id" "t") [eEl] $stream) + (call -relay- ("op" "identity") []) + (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) ) - (next eEl) - ) - ) - (seq - (seq (call -relay- ("op" "identity") []) - (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 2]) ) - (call -relay- ("op" "identity") []) ) ) + (null) ) - (null) ) + (null) ) - (null) - ) - (seq (seq (call -relay- ("op" "identity") []) (call %init_peer_id% ("errorHandlingSrv" "error") [%last_error% 3]) ) - (call -relay- ("op" "identity") []) ) ) + (call -relay- ("op" "identity") []) ) - (call -relay- ("op" "identity") []) + (call %init_peer_id% ("some-id" "multiline") [a b c] $stream) ) (xor (call %init_peer_id% ("callbackSrv" "response") [$stream]) diff --git a/src/examples/complex.ts b/src/examples/complex.ts index 5e84af6..c4e062b 100644 --- a/src/examples/complex.ts +++ b/src/examples/complex.ts @@ -8,5 +8,9 @@ export async function complexCall(client: FluenceClient) { return args[0] }) + registerServiceFunction(client, "some-id", "multiline", (args: any[], _) => { + return args[1] + }) + return await doStuff(client, client.relayPeerId!, client.selfPeerId, true, true, ["1", "2"], ["3", "4"], "some str") } diff --git a/src/run-examples.ts b/src/run-examples.ts index fb17f09..e32ef50 100644 --- a/src/run-examples.ts +++ b/src/run-examples.ts @@ -139,7 +139,7 @@ const main = async () => { checkCall("dataAliasCall", dataAliasResult, "peer id str", cb) - checkCall("complexCall", complexCallResult, ["some str", "3", "1", "4", "1", "1", "3", "2", "4", "2", "2"], cb) + checkCall("complexCall", complexCallResult, ["some str", "3", "1", "4", "1", "1", "3", "2", "4", "2", "2", client.selfPeerId], cb) checkCall("constantCall", constantCallResult, ['1', 'ab'], cb)