summaryrefslogtreecommitdiff
path: root/examples/if.pipa
diff options
context:
space:
mode:
authorCarlos Maniero <carlos@maniero.me>2023-05-10 01:43:40 -0300
committerCarlos Maniero <carlos@maniero.me>2023-05-10 12:18:17 -0300
commit88630ebbea03e85119cf9795320a83cb846bdd20 (patch)
treeecf1f46ce6d9048c5d51ff70413e992936ebf28f /examples/if.pipa
parent3065f54e3a122dd3d8c2deffdec72ec48ea4f165 (diff)
gas: Implement && and || for if statements
Now if statements are complete! The function %gas_assembly_generator_compile_condition% is generic and will be used for any other flow-control statment. The only requirement to it work is having two labels: One to jump when the condition is true, and another one when the condition is false. Signed-off-by: Carlos Maniero <carlos@maniero.me>
Diffstat (limited to 'examples/if.pipa')
-rw-r--r--examples/if.pipa50
1 files changed, 49 insertions, 1 deletions
diff --git a/examples/if.pipa b/examples/if.pipa
index b7cadcb..d65fc24 100644
--- a/examples/if.pipa
+++ b/examples/if.pipa
@@ -7,12 +7,60 @@ fn main(): i32 {
if n <= 11 {
if n > 10 {
if n >= 11 {
- return 42;
+ if n >= 11 || n < 11 {
+ if n > 11 || n < 11 {
+ return 199;
+ }
+ if n > 11 || n <= 11 {
+ if false || false {
+ return 199;
+ }
+
+ if true || false {
+ if false || true {
+ if true && false {
+ return 197;
+ }
+ if false && true {
+ return 196;
+ }
+ if true && true {
+ if n >= 11 && n < 11 || n == 11 {
+ if false || n == 11 && n > 11 {
+ return 195;
+ }
+ if false || n >= 11 && n <= 11 {
+ if false || false && false && false || true {
+ if n + 1 > 11 && n - 1 < 11 {
+ return 42;
+ }
+ return 13;
+ }
+ return 12;
+ }
+ return 11;
+ }
+ return 10;
+ }
+ return 9;
+ }
+ return 8;
+ }
+ return 7;
+ }
+ return 6;
+ }
+ return 5;
}
+ return 4;
}
+ return 3;
}
+ return 2;
}
+ return 1;
}
+ return 0;
}
return n;