Skip to content

Commit

Permalink
fix: "int 1" in clear program (fixes #111)
Browse files Browse the repository at this point in the history
  • Loading branch information
joe-p committed Sep 5, 2023
1 parent da3fb19 commit 8a9a60c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/simple/SimpleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const APP_SPEC: AppSpec = {
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDkKCnR4biBBcHBsaWNhdGlvbklECmludCAwCj4KaW50IDYKKgp0eG4gT25Db21wbGV0aW9uCisKc3dpdGNoIGNyZWF0ZV9Ob09wIE5PVF9JTVBMRU1FTlRFRCBOT1RfSU1QTEVNRU5URUQgTk9UX0lNUExFTUVOVEVEIE5PVF9JTVBMRU1FTlRFRCBOT1RfSU1QTEVNRU5URUQgY2FsbF9Ob09wCgpOT1RfSU1QTEVNRU5URUQ6CgllcnIKCmFiaV9yb3V0ZV9pbmNyOgoJLy8gbm8gZHVwbiBuZWVkZWQKCXR4bmEgQXBwbGljYXRpb25BcmdzIDEKCWJ0b2kKCWNhbGxzdWIgaW5jcgoJaW50IDEKCXJldHVybgoKaW5jcjoKCXByb3RvIDEgMAoKCS8vIGV4YW1wbGVzL3NpbXBsZS9zaW1wbGUuYWxnby50czo3CgkvLyB0aGlzLmNvdW50ZXIudmFsdWUgPSB0aGlzLmNvdW50ZXIudmFsdWUgKyBpCglieXRlICJjb3VudGVyIgoJYnl0ZSAiY291bnRlciIKCWFwcF9nbG9iYWxfZ2V0CglmcmFtZV9kaWcgLTEgLy8gaTogdWludDY0CgkrCglhcHBfZ2xvYmFsX3B1dAoJcmV0c3ViCgphYmlfcm91dGVfZGVjcjoKCS8vIG5vIGR1cG4gbmVlZGVkCgl0eG5hIEFwcGxpY2F0aW9uQXJncyAxCglidG9pCgljYWxsc3ViIGRlY3IKCWludCAxCglyZXR1cm4KCmRlY3I6Cglwcm90byAxIDAKCgkvLy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vLnRzOjIzCi8vIHRoaXMuY291bnRlci52YWx1ZSA9IHRoaXMuY291bnRlci52YWx1ZSArIDEKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKYnl0ZSAiY291bnRlciIKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKaW50IDEKKwphcHBfZ2xvYmFsX3B1dA=="
"clear": "I3ByYWdtYSB2ZXJzaW9uIDkKLy8gZXhhbXBsZXMvc2ltcGxlL3NpbXBsZS5hbGdvLnRzOjIzCi8vIHRoaXMuY291bnRlci52YWx1ZSA9IHRoaXMuY291bnRlci52YWx1ZSArIDEKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKYnl0ZSAiY291bnRlciIKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKaW50IDEKKwphcHBfZ2xvYmFsX3B1dAppbnQgMQ=="
},
"contract": {
"name": "Simple",
Expand Down
3 changes: 2 additions & 1 deletion examples/simple/artifacts/Simple.clear.teal
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ byte "counter"
app_global_get
int 1
+
app_global_put
app_global_put
int 1
2 changes: 1 addition & 1 deletion examples/simple/artifacts/Simple.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"source": {
"approval": "I3ByYWdtYSB2ZXJzaW9uIDkKCnR4biBBcHBsaWNhdGlvbklECmludCAwCj4KaW50IDYKKgp0eG4gT25Db21wbGV0aW9uCisKc3dpdGNoIGNyZWF0ZV9Ob09wIE5PVF9JTVBMRU1FTlRFRCBOT1RfSU1QTEVNRU5URUQgTk9UX0lNUExFTUVOVEVEIE5PVF9JTVBMRU1FTlRFRCBOT1RfSU1QTEVNRU5URUQgY2FsbF9Ob09wCgpOT1RfSU1QTEVNRU5URUQ6CgllcnIKCmFiaV9yb3V0ZV9pbmNyOgoJLy8gbm8gZHVwbiBuZWVkZWQKCXR4bmEgQXBwbGljYXRpb25BcmdzIDEKCWJ0b2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BOdW1BcHBBcmdzCglieiBhYmlfcm91dGVfZGVmYXVsdFRFQUxTY3JpcHRDcmVhdGUKCWVycgoKY2FsbF9Ob09wOgoJbWV0aG9kICJpbmNyKHVpbnQ2NCl2b2lkIgoJbWV0aG9kICJkZWNyKHVpbnQ2NCl2b2lkIgoJbWV0aG9kICJhZGQodWludDI1Nix1aW50MjU2KXVpbnQyNTYiCgltZXRob2QgInN1Yih1aW50MjU2LHVpbnQyNTYpdWludDI1NiIKCXR4bmEgQXBwbGljYXRpb25BcmdzIDAKCW1hdGNoIGFiaV9yb3V0ZV9pbmNyIGFiaV9yb3V0ZV9kZWNyIGFiaV9yb3V0ZV9hZGQgYWJpX3JvdXRlX3N1YgoJZXJy",
"clear": "I3ByYWdtYSB2ZXJzaW9uIDkKLy8gZXhhbXBsZXMvc2ltcGxlL3NpbXBsZS5hbGdvLnRzOjIzCi8vIHRoaXMuY291bnRlci52YWx1ZSA9IHRoaXMuY291bnRlci52YWx1ZSArIDEKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKYnl0ZSAiY291bnRlciIKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKaW50IDEKKwphcHBfZ2xvYmFsX3B1dA=="
"clear": "I3ByYWdtYSB2ZXJzaW9uIDkKLy8gZXhhbXBsZXMvc2ltcGxlL3NpbXBsZS5hbGdvLnRzOjIzCi8vIHRoaXMuY291bnRlci52YWx1ZSA9IHRoaXMuY291bnRlci52YWx1ZSArIDEKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKYnl0ZSAiY291bnRlciIKYnl0ZSAiY291bnRlciIKYXBwX2dsb2JhbF9nZXQKaW50IDEKKwphcHBfZ2xvYmFsX3B1dAppbnQgMQ=="
},
"contract": {
"name": "Simple",
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/artifacts/Simple.src_map.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"simple.algo.ts"
],
"names": [],
"mapp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AA;AAAA;AAAA;AAAA;AAAA;;;AAXI;AADvB;;;AASW;AART;AAIS;;;AAIA;AAAA;AAAF;AAJE;AAIA;AAJA;AARY",
"file": "Simple.approval.teal",
"sourceRoot": ""
}
Expand Down
1 change: 1 addition & 0 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3478,6 +3478,7 @@ export default class Compiler {

this.compilingApproval = false;
this.processNode(fn.body!);
this.pushVoid(fn.body!, 'int 1');
this.clearStateCompiled = true;
this.compilingApproval = true;
}
Expand Down

0 comments on commit 8a9a60c

Please sign in to comment.