diff options
author | Ian Lance Taylor <iant@google.com> | 2011-04-06 15:46:53 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-04-06 15:46:53 +0000 |
commit | db0adf823043571405db77196c8b8898212808ec (patch) | |
tree | 0dc23eb2f1b6ff20645ffb5adce44203f0b5a406 /gcc/go/go-gcc.cc | |
parent | cfebcf30eae6e2f41e61d600f129872aaa286fb3 (diff) | |
download | gcc-db0adf823043571405db77196c8b8898212808ec.zip gcc-db0adf823043571405db77196c8b8898212808ec.tar.gz gcc-db0adf823043571405db77196c8b8898212808ec.tar.bz2 |
Use backend interface for if statements.
Rename some temporary conversion functions to shorter names.
* go-gcc.cc (Gcc_backend::if_statement): New function.
(tree_to_stat): New function.
(expr_to_tree): Renamed from expression_to_tree.
(stat_to_tree): Renamed from statement_to_tree.
From-SVN: r172052
Diffstat (limited to 'gcc/go/go-gcc.cc')
-rw-r--r-- | gcc/go/go-gcc.cc | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc index ce26d4d..de689f8 100644 --- a/gcc/go/go-gcc.cc +++ b/gcc/go/go-gcc.cc @@ -176,6 +176,10 @@ class Gcc_backend : public Backend return_statement(Bfunction*, const std::vector<Bexpression*>&, source_location); + Bstatement* + if_statement(Bexpression* condition, Bstatement* then_block, + Bstatement* else_block, source_location); + // Labels. Blabel* @@ -293,6 +297,25 @@ Gcc_backend::return_statement(Bfunction* bfunction, return this->make_statement(ret); } +// If. + +Bstatement* +Gcc_backend::if_statement(Bexpression* condition, Bstatement* then_block, + Bstatement* else_block, source_location location) +{ + tree cond_tree = condition->get_tree(); + tree then_tree = then_block->get_tree(); + tree else_tree = else_block == NULL ? NULL_TREE : else_block->get_tree(); + if (cond_tree == error_mark_node + || then_tree == error_mark_node + || else_tree == error_mark_node) + return this->make_statement(error_mark_node); + tree ret = build3(COND_EXPR, void_type_node, cond_tree, then_tree, + else_tree); + SET_EXPR_LOCATION(ret, location); + return this->make_statement(ret); +} + // Make a label. Blabel* @@ -366,6 +389,12 @@ tree_to_expr(tree t) return new Bexpression(t); } +Bstatement* +tree_to_stat(tree t) +{ + return new Bstatement(t); +} + Bfunction* tree_to_function(tree t) { @@ -373,13 +402,13 @@ tree_to_function(tree t) } tree -expression_to_tree(Bexpression* be) +expr_to_tree(Bexpression* be) { return be->get_tree(); } tree -statement_to_tree(Bstatement* bs) +stat_to_tree(Bstatement* bs) { return bs->get_tree(); } |