-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow flattening ifs when a branch ends in return
- Loading branch information
1 parent
7168960
commit 21c007e
Showing
9 changed files
with
221 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
int isEven (int arg0) { | ||
if (arg0 == 0) { | ||
return 1; | ||
} | ||
if (arg0 == 1) { | ||
return 0; | ||
} | ||
if (arg0 == 2) { | ||
return 1; | ||
} | ||
if (arg0 == 3) { | ||
return 0; | ||
} | ||
if (arg0 == 4) { | ||
return 1; | ||
} | ||
if (arg0 == 5) { | ||
return 0; | ||
} | ||
if (arg0 == 6) { | ||
return 1; | ||
} | ||
if (arg0 == 7) { | ||
return 0; | ||
} | ||
if (arg0 == 8) { | ||
return 1; | ||
} | ||
if (arg0 == 9) { | ||
return 0; | ||
} | ||
if (arg0 == 10) { | ||
return 1; | ||
} | ||
if (arg0 == 11) { | ||
return 0; | ||
} | ||
if (arg0 == 12) { | ||
return 1; | ||
} | ||
if (arg0 == 13) { | ||
return 0; | ||
} | ||
if (arg0 == 14) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
int isEven (int arg0) { | ||
if (arg0 == 0) { | ||
return 1; | ||
} | ||
if (arg0 == 1) { | ||
return 0; | ||
} | ||
if (arg0 == 2) { | ||
return 1; | ||
} | ||
if (arg0 == 3) { | ||
return 0; | ||
} | ||
if (arg0 == 4) { | ||
return 1; | ||
} | ||
if (arg0 == 5) { | ||
return 0; | ||
} | ||
if (arg0 == 6) { | ||
return 1; | ||
} | ||
if (arg0 == 7) { | ||
return 0; | ||
} | ||
if (arg0 == 8) { | ||
return 1; | ||
} | ||
if (arg0 == 9) { | ||
return 0; | ||
} | ||
if (arg0 == 10) { | ||
return 1; | ||
} | ||
if (arg0 == 11) { | ||
return 0; | ||
} | ||
if (arg0 == 12) { | ||
return 1; | ||
} | ||
if (arg0 == 13) { | ||
return 0; | ||
} | ||
if (arg0 == 14) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
int isEven (int arg0) { | ||
if (arg0 == 0) { | ||
return 1; | ||
} | ||
if (arg0 == 1) { | ||
return 0; | ||
} | ||
if (arg0 == 2) { | ||
return 1; | ||
} | ||
if (arg0 == 3) { | ||
return 0; | ||
} | ||
if (arg0 == 4) { | ||
return 1; | ||
} | ||
if (arg0 == 5) { | ||
return 0; | ||
} | ||
if (arg0 == 6) { | ||
return 1; | ||
} | ||
if (arg0 == 7) { | ||
return 0; | ||
} | ||
if (arg0 == 8) { | ||
return 1; | ||
} | ||
if (arg0 == 9) { | ||
return 0; | ||
} | ||
if (arg0 == 10) { | ||
return 1; | ||
} | ||
if (arg0 == 11) { | ||
return 0; | ||
} | ||
if (arg0 == 12) { | ||
return 1; | ||
} | ||
if (arg0 == 13) { | ||
return 0; | ||
} | ||
if (arg0 == 14) { | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Include the headers | ||
#include "blocks/c_code_generator.h" | ||
#include "builder/dyn_var.h" | ||
#include "builder/lib/utils.h" | ||
#include "builder/static_var.h" | ||
#include <iostream> | ||
|
||
// Include the BuildIt types | ||
using builder::dyn_var; | ||
using builder::static_var; | ||
|
||
static dyn_var<int> isEven(dyn_var<int> x) { | ||
static_var<int> xs = builder::up_cast_range(x, 16); | ||
return (xs % 2) == 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
builder::builder_context context; | ||
context.run_rce = true; | ||
block::c_code_generator::generate_code(context.extract_function_ast(isEven, "isEven"), std::cout, 0); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters