Commit 16c57fe2 by Roberto Lublinerman Committed by Ian Lance Taylor

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
parent 44e7bfcb
2011-08-02 Roberto Lublinerman <rluble@gmail.com>
* 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.
2011-07-06 Richard Guenther <rguenther@suse.de> 2011-07-06 Richard Guenther <rguenther@suse.de>
* go-lang.c (go_langhook_init): * go-lang.c (go_langhook_init):
......
...@@ -45,6 +45,7 @@ gccgo$(exeext): $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS) ...@@ -45,6 +45,7 @@ gccgo$(exeext): $(GCCGO_OBJS) $(EXTRA_GCC_OBJS) libcommon-target.a $(LIBDEPS)
go-warn = $(STRICT_WARN) go-warn = $(STRICT_WARN)
GO_OBJS = \ GO_OBJS = \
go/ast-dump.o \
go/dataflow.o \ go/dataflow.o \
go/export.o \ go/export.o \
go/expressions.o \ go/expressions.o \
...@@ -247,6 +248,9 @@ go/go-gcc.o: go/go-gcc.cc $(GO_SYSTEM_H) $(TREE_H) tree-iterator.h \ ...@@ -247,6 +248,9 @@ go/go-gcc.o: go/go-gcc.cc $(GO_SYSTEM_H) $(TREE_H) tree-iterator.h \
go/%.o: go/gofrontend/%.cc go/%.o: go/gofrontend/%.cc
$(CXX) -c $(GOINCLUDES) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $< $(OUTPUT_OPTION) $(CXX) -c $(GOINCLUDES) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $< $(OUTPUT_OPTION)
go/ast-dump.o: go/gofrontend/ast-dump.cc $(GO_SYSTME_H) $(GO_GOGO_H) \
$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) $(GO_TYPES_H) \
go/gofrontend/ast-dump.h $(GO_C_H) go/gofrontend/go-dump.h
go/dataflow.o: go/gofrontend/dataflow.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \ go/dataflow.o: go/gofrontend/dataflow.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \
$(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) go/gofrontend/dataflow.h $(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) go/gofrontend/dataflow.h
go/export.o: go/gofrontend/export.cc $(GO_SYSTEM_H) \ go/export.o: go/gofrontend/export.cc $(GO_SYSTEM_H) \
...@@ -256,7 +260,8 @@ go/expressions.o: go/gofrontend/expressions.cc $(GO_SYSTEM_H) $(TOPLEV_H) \ ...@@ -256,7 +260,8 @@ go/expressions.o: go/gofrontend/expressions.cc $(GO_SYSTEM_H) $(TOPLEV_H) \
intl.h $(TREE_H) $(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) \ intl.h $(TREE_H) $(GIMPLE_H) tree-iterator.h convert.h $(REAL_H) \
realmpfr.h $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \ realmpfr.h $(GO_C_H) $(GO_GOGO_H) $(GO_TYPES_H) \
go/gofrontend/export.h $(GO_IMPORT_H) $(GO_STATEMENTS_H) $(GO_LEX_H) \ go/gofrontend/export.h $(GO_IMPORT_H) $(GO_STATEMENTS_H) $(GO_LEX_H) \
$(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_EXPRESSIONS_H) $(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_EXPRESSIONS_H) \
go/gofrontend/ast-dump.h
go/go.o: go/gofrontend/go.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_LEX_H) \ go/go.o: go/gofrontend/go.cc $(GO_SYSTEM_H) $(GO_C_H) $(GO_LEX_H) \
$(GO_PARSE_H) go/gofrontend/backend.h $(GO_GOGO_H) $(GO_PARSE_H) go/gofrontend/backend.h $(GO_GOGO_H)
go/go-dump.o: go/gofrontend/go-dump.cc $(GO_SYSTEM_H) $(GO_C_H) \ go/go-dump.o: go/gofrontend/go-dump.cc $(GO_SYSTEM_H) $(GO_C_H) \
...@@ -285,7 +290,8 @@ go/runtime.o: go/gofrontend/runtime.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \ ...@@ -285,7 +290,8 @@ go/runtime.o: go/gofrontend/runtime.cc $(GO_SYSTEM_H) $(GO_GOGO_H) \
go/gofrontend/runtime.def go/gofrontend/runtime.def
go/statements.o: go/gofrontend/statements.cc $(GO_SYSTEM_H) \ go/statements.o: go/gofrontend/statements.cc $(GO_SYSTEM_H) \
$(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) \ $(GO_C_H) $(GO_TYPES_H) $(GO_EXPRESSIONS_H) $(GO_GOGO_H) \
$(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_STATEMENTS_H) $(GO_RUNTIME_H) go/gofrontend/backend.h $(GO_STATEMENTS_H) \
go/gofrontend/ast-dump.h
go/types.o: go/gofrontend/types.cc $(GO_SYSTEM_H) $(TOPLEV_H) intl.h $(TREE_H) \ go/types.o: go/gofrontend/types.cc $(GO_SYSTEM_H) $(TOPLEV_H) intl.h $(TREE_H) \
$(GIMPLE_H) $(REAL_H) convert.h $(GO_C_H) $(GO_GOGO_H) \ $(GIMPLE_H) $(REAL_H) convert.h $(GO_C_H) $(GO_GOGO_H) \
go/gofrontend/operator.h $(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) \ go/gofrontend/operator.h $(GO_EXPRESSIONS_H) $(GO_STATEMENTS_H) \
......
// ast-dump.h -- AST debug dump. -*- C++ -*-
// Copyright 2011 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef GO_AST_DUMP_H
#define GO_AST_DUMP_H
class Expression;
class Expression_list;
class Named_object;
class Statement;
class Gogo;
// This class implements fgo-dump-ast. the
// Abstract syntax tree dump of the Go program.
class Ast_dump_context
{
public:
Ast_dump_context();
// Initialize the dump context.
void
dump(Gogo*, const char* basename);
// Dump spaces to dumpfile as indentation.
void
print_indent();
// Increase current indentation for print_indent().
void
indent()
{ ++this->indent_;}
// Decrease current indentation for print_indent().
void
unindent()
{ --this->indent_;}
// Get dump output stream.
std::ostream&
ostream()
{ return *this->ostream_;}
// Dump a Block to dump file.
void
dump_block(Block*);
// Dump a type to dump file.
void
dump_type(const Type*);
// Dump an expression to dump file.
void
dump_expression(const Expression*);
// Dump an expression list to dump file.
void
dump_expression_list(const Expression_list*);
// Dump a typed identifier to dump file.
void
dump_typed_identifier(const Typed_identifier*);
// Dump a typed identifier list to dump file.
void
dump_typed_identifier_list(const Typed_identifier_list*);
// Dump temporary variable name to dump file.
void
dump_temp_variable_name(const Statement*);
// Dump unamed lable name to dump file.
void
dump_label_name(const Unnamed_label*);
// Dump operator symbol to dump file.
void
dump_operator(Operator);
private:
// Current indent level.
int indent_;
// Indentation offset.
static const int offset_;
// Stream on output dump file.
std::ostream* ostream_;
Gogo* gogo_;
};
#endif // GO_AST_DUMP_H
...@@ -42,6 +42,7 @@ class Export; ...@@ -42,6 +42,7 @@ class Export;
class Import; class Import;
class Temporary_statement; class Temporary_statement;
class Label; class Label;
class Ast_dump_context;
// The base class for all expressions. // The base class for all expressions.
...@@ -635,6 +636,10 @@ class Expression ...@@ -635,6 +636,10 @@ class Expression
static tree static tree
check_bounds(tree val, tree bound_type, tree sofar, source_location); 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: protected:
// May be implemented by child class: traverse the expressions. // May be implemented by child class: traverse the expressions.
virtual int virtual int
...@@ -731,6 +736,10 @@ class Expression ...@@ -731,6 +736,10 @@ class Expression
void void
report_error(const char*); report_error(const char*);
// Child class implements dumping to a dump context.
virtual void
do_dump_expression(Ast_dump_context*) const = 0;
private: private:
// Convert to the desired statement classification, or return NULL. // Convert to the desired statement classification, or return NULL.
// This is a controlled dynamic cast. // This is a controlled dynamic cast.
...@@ -934,6 +943,9 @@ class Var_expression : public Expression ...@@ -934,6 +943,9 @@ class Var_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The variable we are referencing. // The variable we are referencing.
Named_object* variable_; Named_object* variable_;
...@@ -978,6 +990,9 @@ class Temporary_reference_expression : public Expression ...@@ -978,6 +990,9 @@ class Temporary_reference_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The statement where the temporary variable is defined. // The statement where the temporary variable is defined.
Temporary_statement* statement_; Temporary_statement* statement_;
...@@ -1031,6 +1046,9 @@ class String_expression : public Expression ...@@ -1031,6 +1046,9 @@ class String_expression : public Expression
void void
do_export(Export*) const; do_export(Export*) const;
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The string value. This is immutable. // The string value. This is immutable.
const std::string val_; const std::string val_;
...@@ -1154,6 +1172,9 @@ class Binary_expression : public Expression ...@@ -1154,6 +1172,9 @@ class Binary_expression : public Expression
void void
do_export(Export*) const; do_export(Export*) const;
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The binary operator to apply. // The binary operator to apply.
Operator op_; Operator op_;
...@@ -1290,6 +1311,9 @@ class Call_expression : public Expression ...@@ -1290,6 +1311,9 @@ class Call_expression : public Expression
bool bool
determining_types(); determining_types();
void
do_dump_expression(Ast_dump_context*) const;
private: private:
bool bool
check_argument_type(int, const Type*, const Type*, source_location, bool); check_argument_type(int, const Type*, const Type*, source_location, bool);
...@@ -1384,6 +1408,9 @@ class Func_expression : public Expression ...@@ -1384,6 +1408,9 @@ class Func_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The function itself. // The function itself.
Named_object* function_; Named_object* function_;
...@@ -1432,6 +1459,9 @@ class Unknown_expression : public Parser_expression ...@@ -1432,6 +1459,9 @@ class Unknown_expression : public Parser_expression
do_copy() do_copy()
{ return new Unknown_expression(this->named_object_, this->location()); } { return new Unknown_expression(this->named_object_, this->location()); }
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The unknown name. // The unknown name.
Named_object* named_object_; Named_object* named_object_;
...@@ -1456,6 +1486,12 @@ class Index_expression : public Parser_expression ...@@ -1456,6 +1486,12 @@ class Index_expression : public Parser_expression
set_is_lvalue() set_is_lvalue()
{ this->is_lvalue_ = true; } { 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: protected:
int int
do_traverse(Traverse*); do_traverse(Traverse*);
...@@ -1473,6 +1509,9 @@ class Index_expression : public Parser_expression ...@@ -1473,6 +1509,9 @@ class Index_expression : public Parser_expression
this->location()); this->location());
} }
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The expression being indexed. // The expression being indexed.
Expression* left_; Expression* left_;
...@@ -1572,6 +1611,9 @@ class Map_index_expression : public Expression ...@@ -1572,6 +1611,9 @@ class Map_index_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The map we are looking into. // The map we are looking into.
Expression* map_; Expression* map_;
...@@ -1641,6 +1683,9 @@ class Bound_method_expression : public Expression ...@@ -1641,6 +1683,9 @@ class Bound_method_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The object used to find the method. This is passed to the method // The object used to find the method. This is passed to the method
// as the first argument. // as the first argument.
...@@ -1712,6 +1757,9 @@ class Field_reference_expression : public Expression ...@@ -1712,6 +1757,9 @@ class Field_reference_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The expression we are looking into. This should have a type of // The expression we are looking into. This should have a type of
// struct. // struct.
...@@ -1777,6 +1825,9 @@ class Interface_field_reference_expression : public Expression ...@@ -1777,6 +1825,9 @@ class Interface_field_reference_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The expression for the interface object. This should have a type // The expression for the interface object. This should have a type
// of interface or pointer to interface. // of interface or pointer to interface.
...@@ -1830,6 +1881,9 @@ class Type_guard_expression : public Expression ...@@ -1830,6 +1881,9 @@ class Type_guard_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The expression to convert. // The expression to convert.
Expression* expr_; Expression* expr_;
...@@ -1889,6 +1943,9 @@ class Receive_expression : public Expression ...@@ -1889,6 +1943,9 @@ class Receive_expression : public Expression
tree tree
do_get_tree(Translate_context*); do_get_tree(Translate_context*);
void
do_dump_expression(Ast_dump_context*) const;
private: private:
// The channel from which we are receiving. // The channel from which we are receiving.
Expression* channel_; Expression* channel_;
......
...@@ -133,6 +133,9 @@ go_parse_input_files(const char** filenames, unsigned int filename_count, ...@@ -133,6 +133,9 @@ go_parse_input_files(const char** filenames, unsigned int filename_count,
// Convert complicated go and defer statements into simpler ones. // Convert complicated go and defer statements into simpler ones.
::gogo->simplify_thunk_statements(); ::gogo->simplify_thunk_statements();
// Dump ast, use filename[0] as the base name
::gogo->dump_ast(filenames[0]);
} }
// Write out globals. // Write out globals.
......
...@@ -422,6 +422,10 @@ class Gogo ...@@ -422,6 +422,10 @@ class Gogo
void void
simplify_thunk_statements(); simplify_thunk_statements();
// Dump AST if -fgo-dump-ast is set
void
dump_ast(const char* basename);
// Convert named types to the backend representation. // Convert named types to the backend representation.
void void
convert_named_types(); convert_named_types();
...@@ -512,7 +516,6 @@ class Gogo ...@@ -512,7 +516,6 @@ class Gogo
receive_as_64bit_integer(tree type, tree channel, bool blocking, receive_as_64bit_integer(tree type, tree channel, bool blocking,
bool for_select); bool for_select);
// Make a trampoline which calls FNADDR passing CLOSURE. // Make a trampoline which calls FNADDR passing CLOSURE.
tree tree
make_trampoline(tree fnaddr, tree closure, source_location); make_trampoline(tree fnaddr, tree closure, source_location);
......
...@@ -43,6 +43,7 @@ class Typed_identifier_list; ...@@ -43,6 +43,7 @@ class Typed_identifier_list;
class Bexpression; class Bexpression;
class Bstatement; class Bstatement;
class Bvariable; class Bvariable;
class Ast_dump_context;
// This class is used to traverse assignments made by a statement // This class is used to traverse assignments made by a statement
// which makes assignments. // which makes assignments.
...@@ -374,6 +375,10 @@ class Statement ...@@ -374,6 +375,10 @@ class Statement
Bstatement* Bstatement*
get_backend(Translate_context*); get_backend(Translate_context*);
// Dump AST representation of a statement to a dump context.
void
dump_statement(Ast_dump_context*) const;
protected: protected:
// Implemented by child class: traverse the tree. // Implemented by child class: traverse the tree.
virtual int virtual int
...@@ -414,6 +419,10 @@ class Statement ...@@ -414,6 +419,10 @@ class Statement
virtual Bstatement* virtual Bstatement*
do_get_backend(Translate_context*) = 0; do_get_backend(Translate_context*) = 0;
// Implemented by child class: dump ast representation.
virtual void
do_dump_statement(Ast_dump_context*) const = 0;
// Traverse an expression in a statement. // Traverse an expression in a statement.
int int
traverse_expression(Traverse*, Expression**); traverse_expression(Traverse*, Expression**);
...@@ -507,6 +516,9 @@ class Temporary_statement : public Statement ...@@ -507,6 +516,9 @@ class Temporary_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The type of the temporary variable. // The type of the temporary variable.
Type* type_; Type* type_;
...@@ -544,6 +556,9 @@ class Variable_declaration_statement : public Statement ...@@ -544,6 +556,9 @@ class Variable_declaration_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
Named_object* var_; Named_object* var_;
}; };
...@@ -581,6 +596,9 @@ class Return_statement : public Statement ...@@ -581,6 +596,9 @@ class Return_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// Return values. This may be NULL. // Return values. This may be NULL.
Expression_list* vals_; Expression_list* vals_;
...@@ -617,6 +635,9 @@ class Send_statement : public Statement ...@@ -617,6 +635,9 @@ class Send_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The channel on which to send the value. // The channel on which to send the value.
Expression* channel_; Expression* channel_;
...@@ -678,6 +699,10 @@ class Select_clauses ...@@ -678,6 +699,10 @@ class Select_clauses
Bstatement* Bstatement*
get_backend(Translate_context*, Unnamed_label* break_label, source_location); get_backend(Translate_context*, Unnamed_label* break_label, source_location);
// Dump AST representation.
void
dump_clauses(Ast_dump_context*) const;
private: private:
// A single clause. // A single clause.
class Select_clause class Select_clause
...@@ -748,6 +773,10 @@ class Select_clauses ...@@ -748,6 +773,10 @@ class Select_clauses
Bstatement* Bstatement*
get_statements_backend(Translate_context*); get_statements_backend(Translate_context*);
// Dump AST representation.
void
dump_clause(Ast_dump_context*) const;
private: private:
// The channel. // The channel.
Expression* channel_; Expression* channel_;
...@@ -825,6 +854,9 @@ class Select_statement : public Statement ...@@ -825,6 +854,9 @@ class Select_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The select clauses. // The select clauses.
Select_clauses* clauses_; Select_clauses* clauses_;
...@@ -844,7 +876,7 @@ class Thunk_statement : public Statement ...@@ -844,7 +876,7 @@ class Thunk_statement : public Statement
// Return the call expression. // Return the call expression.
Expression* Expression*
call() call() const
{ return this->call_; } { return this->call_; }
// Simplify a go or defer statement so that it only uses a single // Simplify a go or defer statement so that it only uses a single
...@@ -914,6 +946,9 @@ class Go_statement : public Thunk_statement ...@@ -914,6 +946,9 @@ class Go_statement : public Thunk_statement
protected: protected:
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
}; };
// A defer statement. // A defer statement.
...@@ -928,6 +963,9 @@ class Defer_statement : public Thunk_statement ...@@ -928,6 +963,9 @@ class Defer_statement : public Thunk_statement
protected: protected:
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
}; };
// A label statement. // A label statement.
...@@ -952,6 +990,9 @@ class Label_statement : public Statement ...@@ -952,6 +990,9 @@ class Label_statement : public Statement
Bstatement* Bstatement*
do_get_backend(Translate_context*); do_get_backend(Translate_context*);
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The label. // The label.
Label* label_; Label* label_;
...@@ -1005,6 +1046,9 @@ class For_statement : public Statement ...@@ -1005,6 +1046,9 @@ class For_statement : public Statement
do_get_backend(Translate_context*) do_get_backend(Translate_context*)
{ go_unreachable(); } { go_unreachable(); }
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The initialization statements. This may be NULL. // The initialization statements. This may be NULL.
Block* init_; Block* init_;
...@@ -1063,6 +1107,9 @@ class For_range_statement : public Statement ...@@ -1063,6 +1107,9 @@ class For_range_statement : public Statement
do_get_backend(Translate_context*) do_get_backend(Translate_context*)
{ go_unreachable(); } { go_unreachable(); }
void
do_dump_statement(Ast_dump_context*) const;
private: private:
Expression* Expression*
make_range_ref(Named_object*, Temporary_statement*, source_location); make_range_ref(Named_object*, Temporary_statement*, source_location);
...@@ -1167,6 +1214,10 @@ class Case_clauses ...@@ -1167,6 +1214,10 @@ class Case_clauses
std::vector<std::vector<Bexpression*> >* all_cases, std::vector<std::vector<Bexpression*> >* all_cases,
std::vector<Bstatement*>* all_statements) const; std::vector<Bstatement*>* all_statements) const;
// Dump the AST representation to a dump context.
void
dump_clauses(Ast_dump_context*) const;
private: private:
// For a constant switch we need to keep a record of constants we // For a constant switch we need to keep a record of constants we
// have already seen. // have already seen.
...@@ -1237,6 +1288,10 @@ class Case_clauses ...@@ -1237,6 +1288,10 @@ class Case_clauses
get_backend(Translate_context*, Unnamed_label* break_label, get_backend(Translate_context*, Unnamed_label* break_label,
Case_constants*, std::vector<Bexpression*>* cases) const; Case_constants*, std::vector<Bexpression*>* cases) const;
// Dump the AST representation to a dump context.
void
dump_clause(Ast_dump_context*) const;
private: private:
// The list of case expressions. // The list of case expressions.
Expression_list* cases_; Expression_list* cases_;
...@@ -1292,6 +1347,9 @@ class Switch_statement : public Statement ...@@ -1292,6 +1347,9 @@ class Switch_statement : public Statement
do_get_backend(Translate_context*) do_get_backend(Translate_context*)
{ go_unreachable(); } { go_unreachable(); }
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The value to switch on. This may be NULL. // The value to switch on. This may be NULL.
Expression* val_; Expression* val_;
...@@ -1342,6 +1400,10 @@ class Type_case_clauses ...@@ -1342,6 +1400,10 @@ class Type_case_clauses
lower(Block*, Temporary_statement* descriptor_temp, lower(Block*, Temporary_statement* descriptor_temp,
Unnamed_label* break_label) const; Unnamed_label* break_label) const;
// Dump the AST representation to a dump context.
void
dump_clauses(Ast_dump_context*) const;
private: private:
// One type case clause. // One type case clause.
class Type_case_clause class Type_case_clause
...@@ -1382,6 +1444,10 @@ class Type_case_clauses ...@@ -1382,6 +1444,10 @@ class Type_case_clauses
lower(Block*, Temporary_statement* descriptor_temp, lower(Block*, Temporary_statement* descriptor_temp,
Unnamed_label* break_label, Unnamed_label** stmts_label) const; Unnamed_label* break_label, Unnamed_label** stmts_label) const;
// Dump the AST representation to a dump context.
void
dump_clause(Ast_dump_context*) const;
private: private:
// The type for this type clause. // The type for this type clause.
Type* type_; Type* type_;
...@@ -1438,6 +1504,9 @@ class Type_switch_statement : public Statement ...@@ -1438,6 +1504,9 @@ class Type_switch_statement : public Statement
do_get_backend(Translate_context*) do_get_backend(Translate_context*)
{ go_unreachable(); } { go_unreachable(); }
void
do_dump_statement(Ast_dump_context*) const;
private: private:
// The variable holding the value we are switching on. // The variable holding the value we are switching on.
Named_object* var_; Named_object* var_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment