# mir_passes @preserve "test:main" { let x: score = val 7s; # If-assign folds if eq %x, sco "foo" "bar": set %x, sco "foo" "bar"; use %x; if not eq %x, sco "foo" "bar": set %x, sco "foo" "bar"; if gt %x, sco "foo" "bar": set %x, sco "foo" "bar"; if lt %x, sco "foo" "bar": set %x, sco "foo" "bar"; # If-boolean folds if bool sco "foo" "bar": add %x, 1s; if bool sco "foo" "bar": sub %x, 1s; if not bool sco "foo" "bar": mul %x, 0s; if not bool sco "foo" "bar": set %x, 0s; # If exists const folds let exists: score = val 0s; if exi %exists: say "Guaranteed"; # Math folds add %x, %x; use %x; sub %x, %x; use %x; div %x, 1s; use %x; mod %x, 1s; use %x; # Boolean folds or sco @s[] "foo", 0s; or sco @s[] "foo", 1s; and sco @s[] "foo", 0s; and sco @s[] "foo", 1s; and sco @s[] "foo", sco @s[] "foo"; or sco @s[] "foo", sco @s[] "foo"; # NBT folds mrg ent @s[] "name", {}; mrg ent @s[] "name", {"bar": 7nb}; # Store & get let store_get: nint = null; mdf str reg store_get, 0.5: get ent @s[] "foo", 2.0; # Don't fold this mdf str data ent "foo" "bar", float, 0.7: get ent @s[] "foo", 9.0; use %store_get; # Game instrs xpa @s[], 0, levels; tima 0.0t; wba 0.0, 0; use %x; } @preserve "test:let_cond" { let cond: bool = cond bool sco @s[] "foo"; use %cond; } @preserve "test:conditions" { let x: bool = cond not not pred "foo:bar"; use %x; } @preserve "test:if_else" { ife pred "foo:bar" { say "Hello"; } {}; ife pred "foo:bar" {} { say "Hello"; }; ife pred "foo:bar" { say "Hello"; } { say "Hello"; }; }