-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): Generate stream restriction for scoped exprs [fixes LN…
…G-222] (#841) * Add show for AST * Update ForSem * Fix if and try * Fix else, otherwise, catch, add tests * Add integration tests
- Loading branch information
1 parent
f562bd4
commit eb4cdb0
Showing
17 changed files
with
406 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
aqua StreamExports | ||
|
||
export FailureSrv, streamIf, streamTry, streamFor, streamComplex | ||
|
||
service FailureSrv("failure"): | ||
fail(msg: string) | ||
|
||
func streamIf() -> i8: | ||
on HOST_PEER_ID: | ||
if true: | ||
stream: *i8 | ||
stream <<- 1 | ||
else: | ||
stream: *i8 | ||
stream <<- 2 | ||
|
||
if false: | ||
stream: *i8 | ||
stream <<- 3 | ||
else: | ||
stream: *i8 | ||
stream <<- 4 | ||
|
||
stream: *i8 | ||
stream <<- 5 | ||
|
||
<- stream! | ||
|
||
func streamTry() -> i8: | ||
on HOST_PEER_ID: | ||
try: | ||
stream: *i8 | ||
stream <<- 1 | ||
FailureSrv.fail("try") | ||
catch e: | ||
stream: *i8 | ||
stream <<- 2 | ||
FailureSrv.fail("catch") | ||
otherwise: | ||
stream: *i8 | ||
stream <<- 3 | ||
|
||
stream: *i8 | ||
stream <<- 4 | ||
|
||
<- stream! | ||
|
||
func streamFor() -> i8: | ||
on HOST_PEER_ID: | ||
for i <- [1, 2, 3]: | ||
stream: *i8 | ||
stream <<- i | ||
|
||
stream: *i8 | ||
stream <<- 4 | ||
|
||
<- stream! | ||
|
||
func streamComplex() -> i8: | ||
on HOST_PEER_ID: | ||
for i <- [1, 2, 3]: | ||
try: | ||
if i == 2: | ||
stream: *i8 | ||
stream <<- i | ||
FailureSrv.fail("if") | ||
else: | ||
stream: *i8 | ||
stream <<- i | ||
|
||
stream: *i8 | ||
stream <<- i + 3 | ||
catch e: | ||
stream: *i8 | ||
stream <<- i + 6 | ||
|
||
stream: *i8 | ||
stream <<- i + 9 | ||
|
||
stream: *i8 | ||
stream <<- 13 | ||
|
||
<- stream! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { | ||
streamIf, | ||
streamTry, | ||
streamFor, | ||
streamComplex, | ||
registerFailureSrv, | ||
} from '../compiled/examples/streamScopes.js'; | ||
|
||
export async function streamIfCall() { | ||
return await streamIf(); | ||
} | ||
|
||
export async function streamTryCall() { | ||
registerFailureSrv({ | ||
fail: (msg) => { | ||
return Promise.reject(msg); | ||
}, | ||
}); | ||
|
||
return await streamTry(); | ||
} | ||
|
||
export async function streamForCall() { | ||
return await streamFor(); | ||
} | ||
|
||
export async function streamComplexCall() { | ||
registerFailureSrv({ | ||
fail: (msg) => { | ||
return Promise.reject(msg); | ||
}, | ||
}); | ||
|
||
return await streamComplex(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.