-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't output continue/break blocks if they are not required
- Loading branch information
1 parent
988f1f3
commit ac5691a
Showing
135 changed files
with
11,208 additions
and
2,725 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,3 @@ | ||
export function maybeNodes<T>(condition: boolean, ...nodes: T[]): T[] { | ||
return condition ? nodes : [] | ||
} |
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 |
---|---|---|
@@ -1,9 +1,37 @@ | ||
import type { uint64 } from '@algorandfoundation/algorand-typescript' | ||
import { Uint64 } from '@algorandfoundation/algorand-typescript' | ||
import { Contract, Uint64 } from '@algorandfoundation/algorand-typescript' | ||
|
||
function test_do(stop: uint64) { | ||
let i = Uint64(0) | ||
do { | ||
i += 1 | ||
} while (i < stop) | ||
export class DoLoopsAlgo extends Contract { | ||
testDo(stop: uint64) { | ||
let i = Uint64(0) | ||
do { | ||
i += 1 | ||
} while (i < stop) | ||
return i | ||
} | ||
testDoBreak(stop: uint64, breakMod: uint64) { | ||
let total = Uint64(0) | ||
let i = Uint64(0) | ||
do { | ||
if (i > 0 && i % breakMod === 0) break | ||
|
||
i += 1 | ||
total += i | ||
} while (i < stop) | ||
return total | ||
} | ||
testDoContinue(stop: uint64, mod: uint64) { | ||
let i = Uint64(0) | ||
let total = Uint64(0) | ||
do { | ||
if (i > 0 && i % mod === 0) { | ||
total += 2 | ||
i += 1 | ||
continue | ||
} | ||
total += 1 | ||
i += 1 | ||
} while (i < stop) | ||
return total | ||
} | ||
} |
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.