diff options
author | Roberto Lublinerman <rluble@gmail.com> | 2011-08-03 00:37:26 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-08-03 00:37:26 +0000 |
commit | 16c57fe28099740e06cb761b928b62a5a028bf66 (patch) | |
tree | 923d669821360649dcc148d547ce22a850f344c1 /gcc/go/gofrontend/expressions.h | |
parent | 44e7bfcb6fcfb7382b97f0b0793b1fd26c054e1d (diff) | |
download | gcc-16c57fe28099740e06cb761b928b62a5a028bf66.zip gcc-16c57fe28099740e06cb761b928b62a5a028bf66.tar.gz gcc-16c57fe28099740e06cb761b928b62a5a028bf66.tar.bz2 |
gccgo: Added code to dump the AST tree.
gccgo: Added code to dump the AST tree. The AST dump is
activated with -fgo-dump-ast.
Initial version, it only dumps (most) constructs that
are expected after the lowering transformation.
* Make-lang.in (GO_OBJS): Add go/ast-dump.o.
(go/ast-dump.o): New target.
(go/expressions.o): Depend on go/gofrontend/ast-dump.h.
(go/statements.o): Likewise.
From-SVN: r177225
Diffstat (limited to 'gcc/go/gofrontend/expressions.h')
-rw-r--r-- | gcc/go/gofrontend/expressions.h | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/expressions.h b/gcc/go/gofrontend/expressions.h index da31f14..6f74f73 100644 --- a/gcc/go/gofrontend/expressions.h +++ b/gcc/go/gofrontend/expressions.h @@ -42,6 +42,7 @@ class Export; class Import; class Temporary_statement; class Label; +class Ast_dump_context; // The base class for all expressions. @@ -635,6 +636,10 @@ class Expression static tree check_bounds(tree val, tree bound_type, tree sofar, source_location); + // Dump an expression to a dump constext. + void + dump_expression(Ast_dump_context*) const; + protected: // May be implemented by child class: traverse the expressions. virtual int @@ -731,6 +736,10 @@ class Expression void report_error(const char*); + // Child class implements dumping to a dump context. + virtual void + do_dump_expression(Ast_dump_context*) const = 0; + private: // Convert to the desired statement classification, or return NULL. // This is a controlled dynamic cast. @@ -934,6 +943,9 @@ class Var_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The variable we are referencing. Named_object* variable_; @@ -978,6 +990,9 @@ class Temporary_reference_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The statement where the temporary variable is defined. Temporary_statement* statement_; @@ -1031,6 +1046,9 @@ class String_expression : public Expression void do_export(Export*) const; + void + do_dump_expression(Ast_dump_context*) const; + private: // The string value. This is immutable. const std::string val_; @@ -1154,6 +1172,9 @@ class Binary_expression : public Expression void do_export(Export*) const; + void + do_dump_expression(Ast_dump_context*) const; + private: // The binary operator to apply. Operator op_; @@ -1290,6 +1311,9 @@ class Call_expression : public Expression bool determining_types(); + void + do_dump_expression(Ast_dump_context*) const; + private: bool check_argument_type(int, const Type*, const Type*, source_location, bool); @@ -1384,6 +1408,9 @@ class Func_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The function itself. Named_object* function_; @@ -1432,6 +1459,9 @@ class Unknown_expression : public Parser_expression do_copy() { return new Unknown_expression(this->named_object_, this->location()); } + void + do_dump_expression(Ast_dump_context*) const; + private: // The unknown name. Named_object* named_object_; @@ -1456,6 +1486,12 @@ class Index_expression : public Parser_expression set_is_lvalue() { this->is_lvalue_ = true; } + // Dump an index expression, i.e. an expression of the form + // expr[expr] or expr[expr:expr], to a dump context. + static void + dump_index_expression(Ast_dump_context*, const Expression* expr, + const Expression* start, const Expression* end); + protected: int do_traverse(Traverse*); @@ -1473,6 +1509,9 @@ class Index_expression : public Parser_expression this->location()); } + void + do_dump_expression(Ast_dump_context*) const; + private: // The expression being indexed. Expression* left_; @@ -1572,6 +1611,9 @@ class Map_index_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The map we are looking into. Expression* map_; @@ -1641,6 +1683,9 @@ class Bound_method_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The object used to find the method. This is passed to the method // as the first argument. @@ -1712,6 +1757,9 @@ class Field_reference_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The expression we are looking into. This should have a type of // struct. @@ -1777,6 +1825,9 @@ class Interface_field_reference_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The expression for the interface object. This should have a type // of interface or pointer to interface. @@ -1830,6 +1881,9 @@ class Type_guard_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The expression to convert. Expression* expr_; @@ -1889,6 +1943,9 @@ class Receive_expression : public Expression tree do_get_tree(Translate_context*); + void + do_dump_expression(Ast_dump_context*) const; + private: // The channel from which we are receiving. Expression* channel_; |