|
@@ -37,6 +37,7 @@ type output_options =
|
|
| OODecreaseIndent
|
|
| OODecreaseIndent
|
|
| OOBeginBlock
|
|
| OOBeginBlock
|
|
| OOEndBlock
|
|
| OOEndBlock
|
|
|
|
+ | OOBreak
|
|
|
|
|
|
type function_entry = {
|
|
type function_entry = {
|
|
mutable fe_name : string;
|
|
mutable fe_name : string;
|
|
@@ -606,6 +607,7 @@ let generate_function ctx f =
|
|
| OOLabel -> sline "%s:" (label i)
|
|
| OOLabel -> sline "%s:" (label i)
|
|
| OOCase i -> sline "case %i:" i
|
|
| OOCase i -> sline "case %i:" i
|
|
| OODefault -> line "default:"
|
|
| OODefault -> line "default:"
|
|
|
|
+ | OOBreak -> line "break;";
|
|
| OOIncreaseIndent -> block()
|
|
| OOIncreaseIndent -> block()
|
|
| OODecreaseIndent -> unblock()
|
|
| OODecreaseIndent -> unblock()
|
|
| OOBeginBlock -> line "{"
|
|
| OOBeginBlock -> line "{"
|
|
@@ -940,12 +942,17 @@ let generate_function ctx f =
|
|
| OSwitch (r,idx,eend) ->
|
|
| OSwitch (r,idx,eend) ->
|
|
sline "switch(%s) {" (reg r);
|
|
sline "switch(%s) {" (reg r);
|
|
block();
|
|
block();
|
|
- output_at2 (i + 1) [OODefault;OOIncreaseIndent];
|
|
|
|
- Array.iteri (fun k delta -> output_at2 (delta + i + 1) [OODecreaseIndent;OOCase k;OOIncreaseIndent]) idx;
|
|
|
|
let pend = i+1+eend in
|
|
let pend = i+1+eend in
|
|
(* insert at end if we have another switch case here *)
|
|
(* insert at end if we have another switch case here *)
|
|
let old = output_options.(pend) in
|
|
let old = output_options.(pend) in
|
|
output_options.(pend) <- [];
|
|
output_options.(pend) <- [];
|
|
|
|
+ (* insert cases *)
|
|
|
|
+ output_at2 (i + 1) [OODefault;OOIncreaseIndent];
|
|
|
|
+ Array.iteri (fun k delta ->
|
|
|
|
+ output_at2 (delta + i + 1) [OODecreaseIndent;OOCase k;OOIncreaseIndent];
|
|
|
|
+ if delta = eend then output_at pend OOBreak;
|
|
|
|
+ ) idx;
|
|
|
|
+ (* insert end switch *)
|
|
output_at2 pend ([OODecreaseIndent;OODecreaseIndent;OOEndBlock] @ List.rev old);
|
|
output_at2 pend ([OODecreaseIndent;OODecreaseIndent;OOEndBlock] @ List.rev old);
|
|
| ONullCheck r ->
|
|
| ONullCheck r ->
|
|
sexpr "if( %s == NULL ) hl_null_access()" (reg r)
|
|
sexpr "if( %s == NULL ) hl_null_access()" (reg r)
|