Closed master-q closed 5 years ago
int while_break() {
int a = 10, b = 10;
while(a < 20) {
a++;
if (a > 15) {
break;
}
b++;
}
return a + b;
}
int main() {
return while_break() - 16 - 15;
}
should be translated into...
#include "share/atspre_staload.hats"
fun for_break (): int =
let
var a: int = 10
var b: int = 10
fun loop_while(a : int, b : int) : (int, int) =
let
var a: int = a
var b: int = b
in
if a < 20 then
let
val () = a := a + 1
in
if a > 15 then
(a, b)
else let
val () = b := b + 1
in
loop_while(a, b)
end
end
else
(a, b)
end
val (i9a_a, i9a_b) = loop_while(a, b)
val () = a := i9a_a
val () = b := i9a_b
in
a + b
end
implement main () =
for_break() - 16 - 15
Umm... We need simplify stage...
It may become simple code using case
.
Choice A:
Modify (A.ATS $ postCondE ++ decls ++ fromMaybe [] incr'')
includes (* CBreak *)
comment at makeLoop
function
Choice B:
Modify C.CStat
and remove any break
, continue
and goto
Take A.
https://www.tutorialspoint.com/cprogramming/c_break_statement