Skip to content

Commit

Permalink
docs: add default= keyword to GlobalState.get() usage to make exa…
Browse files Browse the repository at this point in the history
…mple clearer
  • Loading branch information
achidlow committed Mar 22, 2024
1 parent 017f3b8 commit 61e9bef
Show file tree
Hide file tree
Showing 12 changed files with 636 additions and 618 deletions.
626 changes: 313 additions & 313 deletions examples/tictactoe/out/TicTacToeContract.approval.mir

Large diffs are not rendered by default.

58 changes: 33 additions & 25 deletions examples/tictactoe/out/TicTacToeContract.approval.teal
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,11 @@ join_game:

// examples.tictactoe.tictactoe.TicTacToeContract.make_move(player: bytes, move.0: uint64, move.1: uint64) -> void:
make_move:
// tictactoe/tictactoe.py:58-59
// tictactoe/tictactoe.py:60-61
// @subroutine
// def make_move(self, player: arc4.UInt8, move: Move) -> None:
proto 3 0
// tictactoe/tictactoe.py:61
// tictactoe/tictactoe.py:63
// assert column < 3 and row < 3, "Move must be in range"
frame_dig -2
int 3
Expand All @@ -266,10 +266,10 @@ make_move_bool_false@3:
int 0

make_move_bool_merge@4:
// tictactoe/tictactoe.py:61
// tictactoe/tictactoe.py:63
// assert column < 3 and row < 3, "Move must be in range"
assert // Move must be in range
// tictactoe/tictactoe.py:62
// tictactoe/tictactoe.py:64
// assert self.game[row][column] == EMPTY, "Square is already taken"
int 0
byte "game"
Expand All @@ -294,7 +294,7 @@ make_move_bool_merge@4:
byte 0x00
b==
assert // Square is already taken
// tictactoe/tictactoe.py:63
// tictactoe/tictactoe.py:65
// self.game[row][column] = player
int 0
byte "game"
Expand All @@ -315,7 +315,7 @@ make_move_bool_merge@4:
byte "game"
swap
app_global_put
// tictactoe/tictactoe.py:64
// tictactoe/tictactoe.py:66
// self.turns += 1
int 0
byte "turns"
Expand All @@ -326,22 +326,22 @@ make_move_bool_merge@4:
byte "turns"
swap
app_global_put
// tictactoe/tictactoe.py:65
// tictactoe/tictactoe.py:67
// if self.did_win(player, column=column, row=row):
frame_dig -3
frame_dig -2
frame_dig -1
callsub did_win
bz make_move_else_body@6
// tictactoe/tictactoe.py:66
// tictactoe/tictactoe.py:68
// self.winner.value = player
byte "winner"
frame_dig -3
app_global_put
b make_move_after_if_else@9

make_move_else_body@6:
// tictactoe/tictactoe.py:67
// tictactoe/tictactoe.py:69
// elif self.turns == 9:
int 0
byte "turns"
Expand All @@ -350,7 +350,7 @@ make_move_else_body@6:
int 9
==
bz make_move_after_if_else@9
// tictactoe/tictactoe.py:68
// tictactoe/tictactoe.py:70
// self.winner.value = arc4.UInt8(DRAW)
byte "winner"
byte 0x03
Expand All @@ -362,12 +362,12 @@ make_move_after_if_else@9:

// examples.tictactoe.tictactoe.TicTacToeContract.did_win(player: bytes, column: uint64, row: uint64) -> uint64:
did_win:
// tictactoe/tictactoe.py:70-71
// tictactoe/tictactoe.py:72-73
// @subroutine
// def did_win(self, player: arc4.UInt8, column: UInt64, row: UInt64) -> bool:
proto 3 1
int 0
// tictactoe/tictactoe.py:72
// tictactoe/tictactoe.py:74
// g = self.game.copy()
dupn 3
byte "game"
Expand All @@ -376,7 +376,7 @@ did_win:
dup
uncover 2
assert // check game exists
// tictactoe/tictactoe.py:74
// tictactoe/tictactoe.py:76
// if g[row][0] == g[row][1] == g[row][2]:
frame_dig -1
int 3
Expand All @@ -400,14 +400,14 @@ did_win:
frame_dig 5
b==
bz did_win_after_if_else@3
// tictactoe/tictactoe.py:75
// tictactoe/tictactoe.py:77
// return True
int 1
frame_bury 0
retsub

did_win_after_if_else@3:
// tictactoe/tictactoe.py:77
// tictactoe/tictactoe.py:79
// if g[0][column] == g[1][column] == g[2][column]:
frame_dig 3
dup
Expand Down Expand Up @@ -440,22 +440,22 @@ did_win_after_if_else@3:
frame_dig 0
b==
bz did_win_after_if_else@6
// tictactoe/tictactoe.py:78
// tictactoe/tictactoe.py:80
// return True
int 1
frame_bury 0
retsub

did_win_after_if_else@6:
// tictactoe/tictactoe.py:80-81
// tictactoe/tictactoe.py:82-83
// # if player owns center, check diagonals
// if player == g[1][1]:
frame_dig 2
extract 1 1
frame_dig -3
b==
bz did_win_after_if_else@14
// tictactoe/tictactoe.py:82
// tictactoe/tictactoe.py:84
// if g[0][0] == player == g[2][2]:
frame_dig 1
extract 0 1
Expand All @@ -468,14 +468,14 @@ did_win_after_if_else@6:
frame_dig -3
b==
bz did_win_after_if_else@10
// tictactoe/tictactoe.py:83
// tictactoe/tictactoe.py:85
// return True
int 1
frame_bury 0
retsub

did_win_after_if_else@10:
// tictactoe/tictactoe.py:84
// tictactoe/tictactoe.py:86
// if g[0][2] == player == g[2][0]:
frame_dig 1
extract 2 1
Expand All @@ -488,14 +488,14 @@ did_win_after_if_else@10:
frame_dig -3
b==
bz did_win_after_if_else@14
// tictactoe/tictactoe.py:85
// tictactoe/tictactoe.py:87
// return True
int 1
frame_bury 0
retsub

did_win_after_if_else@14:
// tictactoe/tictactoe.py:86
// tictactoe/tictactoe.py:88
// return False
int 0
frame_bury 0
Expand Down Expand Up @@ -570,21 +570,29 @@ play:

play_else_body@2:
// tictactoe/tictactoe.py:54
// assert Txn.sender == self.challenger.get(Account()), "It is the challenger's turn"
// assert Txn.sender == self.challenger.get(
txn Sender
// tictactoe/tictactoe.py:55
// default=Account()
global ZeroAddress
// tictactoe/tictactoe.py:54
// assert Txn.sender == self.challenger.get(
int 0
byte "challenger"
// tictactoe/tictactoe.py:54-56
// assert Txn.sender == self.challenger.get(
// default=Account()
// ), "It is the challenger's turn"
app_global_get_ex
select
==
assert // It is the challenger's turn
// tictactoe/tictactoe.py:55
// tictactoe/tictactoe.py:57
// player = arc4.UInt8(CHALLENGER)
byte 0x02

play_after_if_else@3:
// tictactoe/tictactoe.py:56
// tictactoe/tictactoe.py:58
// self.make_move(player, move)
frame_dig -2
frame_dig -1
Expand Down
2 changes: 1 addition & 1 deletion examples/tictactoe/out/TicTacToeContract.arc32.json

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions examples/tictactoe/out/TicTacToeContract.destructured.ir

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 61e9bef

Please sign in to comment.