-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## How it works - we transform AST `ForE` loops by `Construct.whileE` _while_ lowering to IR - the transformation kicks in when a `DotE` expression is applied to a value with an array type, by projecting out the `vals` accessor - we get hold of the expression in the `DotE` node and use that (i.e. its constituents) as the starting point to obtain the array's size, and then index into it (for `keys` accessor the indexing is trivial) - we build a classic `while` loop with an index running from zero below the size - we don't distinguish between immutable/mutable arrays and also cater for potentially effectful loop bodies, as well as array expressions (and unit expressions passed to the call) - we always CBV-bind the array expression to a variable (even if it is already a `VarE`, otherwise we end up in name capture hell) ## Pain points We lose a bunch of source locations in the process of conversion to IR. This is not really a problem now, but will make the debugging experience less enjoyable some day. ## TODOs: - [x] `FileCheck` on final IR - [x] `async` (talk to @crusso) - [x] `S.`-only transformation? - [x] Are parens interfering? — No - [x] test all combinations - [ ] check why we have a perf regression ## Further optimisation opportunities - eliminate unknown call following `call $@(im)mut_array_size` - use `u32` arithmetic and indexing (currently _bignum_ calls) - [x] we could optimise `DotE(..., "keys")` similarly — DONE
- Loading branch information
Showing
18 changed files
with
291 additions
and
13 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ingress Completed: Reply: 0x4449444c016c01b3c4b1f204680100010a00000000000000000101 | ||
ingress Completed: Reply: 0x4449444c0000 | ||
debug.print: effect | ||
debug.print: hello | ||
debug.print: world | ||
debug.print: hello | ||
debug.print: world | ||
debug.print: effect | ||
debug.print: hello | ||
debug.print: bound | ||
debug.print: world | ||
debug.print: hello | ||
debug.print: bound | ||
debug.print: world | ||
ingress Completed: Reply: 0x4449444c0000 |
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,18 @@ | ||
→ update create_canister(record {settings = null}) | ||
← replied: (record {hymijyo = principal "cvccv-qqaaq-aaaaa-aaaaa-c"}) | ||
→ update install_code(record {arg = blob ""; kca_xin = blob "\00asm\01\00\00\00\0… | ||
← replied: () | ||
→ update go() | ||
debug.print: effect | ||
debug.print: hello | ||
debug.print: world | ||
debug.print: hello | ||
debug.print: world | ||
debug.print: effect | ||
debug.print: hello | ||
debug.print: bound | ||
debug.print: world | ||
debug.print: hello | ||
debug.print: bound | ||
debug.print: world | ||
← replied: () |
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,12 @@ | ||
effect | ||
hello | ||
world | ||
hello | ||
world | ||
effect | ||
hello | ||
bound | ||
world | ||
hello | ||
bound | ||
world |
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,12 @@ | ||
effect | ||
hello | ||
world | ||
hello | ||
world | ||
effect | ||
hello | ||
bound | ||
world | ||
hello | ||
bound | ||
world |
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,12 @@ | ||
effect | ||
hello | ||
world | ||
hello | ||
world | ||
effect | ||
hello | ||
bound | ||
world | ||
hello | ||
bound | ||
world |
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,18 @@ | ||
import Prim "mo:⛔"; | ||
|
||
actor a { | ||
public func go() : async () { | ||
for (check1 in (await async ["effect", "hello", "world"]).vals()) { Prim.debugPrint check1 }; | ||
|
||
for (check2 in ["hello", "world", "effect"].vals()) { await async { Prim.debugPrint check2 } }; | ||
|
||
let array = ["hello", "bound", "world"]; | ||
|
||
for (check3 in (await async array).vals()) { Prim.debugPrint check3 }; | ||
|
||
for (check4 in array.vals()) { await async { Prim.debugPrint check4 } }; | ||
|
||
for (_ in array.vals(await async ())) { } | ||
} | ||
}; | ||
a.go(); //OR-CALL ingress go "DIDL\x00\x00" |
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,12 @@ | ||
hello | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
immutable | ||
world | ||
want to see you |
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,12 @@ | ||
hello | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
immutable | ||
world | ||
want to see you |
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,12 @@ | ||
hello | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
immutable | ||
world | ||
want to see you |
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,12 @@ | ||
hello | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
mutable | ||
world | ||
hello | ||
immutable | ||
world | ||
want to see you |
Oops, something went wrong.