class Gogo;
class Traverse;
+class Statement_inserter;
class Block;
class Function;
class Unnamed_label;
class Bexpression;
class Bstatement;
class Bvariable;
+class Ast_dump_context;
// This class is used to traverse assignments made by a statement
// which makes assignments.
// simplify statements for further processing. It returns the same
// Statement or a new one. FUNCTION is the function containing this
// statement. BLOCK is the block containing this statement.
+ // INSERTER can be used to insert new statements before this one.
Statement*
- lower(Gogo* gogo, Named_object* function, Block* block)
- { return this->do_lower(gogo, function, block); }
+ lower(Gogo* gogo, Named_object* function, Block* block,
+ Statement_inserter* inserter)
+ { return this->do_lower(gogo, function, block, inserter); }
// Set type information for unnamed constants.
void
Bstatement*
get_backend(Translate_context*);
+ // Dump AST representation of a statement to a dump context.
+ void
+ dump_statement(Ast_dump_context*) const;
+
protected:
// Implemented by child class: traverse the tree.
virtual int
// Implemented by the child class: lower this statement to a simpler
// one.
virtual Statement*
- do_lower(Gogo*, Named_object*, Block*)
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*)
{ return this; }
// Implemented by child class: set type information for unnamed
virtual Bstatement*
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.
int
traverse_expression(Traverse*, Expression**);
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The type of the temporary variable.
Type* type_;
bool
do_traverse_assignments(Traverse_assignments*);
+ Statement*
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
+
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
Named_object* var_;
};
do_traverse_assignments(Traverse_assignments*);
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
bool
do_may_fall_through() const
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// Return values. This may be NULL.
Expression_list* vals_;
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The channel on which to send the value.
Expression* channel_;
Bstatement*
get_backend(Translate_context*, Unnamed_label* break_label, source_location);
+ // Dump AST representation.
+ void
+ dump_clauses(Ast_dump_context*) const;
+
private:
// A single clause.
class Select_clause
Bstatement*
get_statements_backend(Translate_context*);
+ // Dump AST representation.
+ void
+ dump_clause(Ast_dump_context*) const;
+
private:
// The channel.
Expression* channel_;
{ return this->clauses_->traverse(traverse); }
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
void
do_determine_types()
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The select clauses.
Select_clauses* clauses_;
// Return the call expression.
Expression*
- call()
+ call() const
{ return this->call_; }
// Simplify a go or defer statement so that it only uses a single
bool
is_simple(Function_type*) const;
+ // Return whether the thunk function is a constant.
+ bool
+ is_constant_function() const;
+
// Build the struct to use for a complex case.
Struct_type*
build_struct(Function_type* fntype);
// Build the thunk.
void
- build_thunk(Gogo*, const std::string&, Function_type* fntype);
-
- // The field name used in the thunk structure for the function
- // pointer.
- static const char* const thunk_field_fn;
-
- // The field name used in the thunk structure for the receiver, if
- // there is one.
- static const char* const thunk_field_receiver;
+ build_thunk(Gogo*, const std::string&);
// Set the name to use for thunk field N.
void
protected:
Bstatement*
do_get_backend(Translate_context*);
+
+ void
+ do_dump_statement(Ast_dump_context*) const;
};
// A defer statement.
protected:
Bstatement*
do_get_backend(Translate_context*);
+
+ void
+ do_dump_statement(Ast_dump_context*) const;
};
// A label statement.
Bstatement*
do_get_backend(Translate_context*);
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The label.
Label* label_;
{ go_unreachable(); }
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
Bstatement*
do_get_backend(Translate_context*)
{ go_unreachable(); }
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The initialization statements. This may be NULL.
Block* init_;
{ go_unreachable(); }
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
Bstatement*
do_get_backend(Translate_context*)
{ go_unreachable(); }
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
Expression*
make_range_ref(Named_object*, Temporary_statement*, source_location);
std::vector<std::vector<Bexpression*> >* all_cases,
std::vector<Bstatement*>* all_statements) const;
+ // Dump the AST representation to a dump context.
+ void
+ dump_clauses(Ast_dump_context*) const;
+
private:
// For a constant switch we need to keep a record of constants we
// have already seen.
get_backend(Translate_context*, Unnamed_label* break_label,
Case_constants*, std::vector<Bexpression*>* cases) const;
+ // Dump the AST representation to a dump context.
+ void
+ dump_clause(Ast_dump_context*) const;
+
private:
// The list of case expressions.
Expression_list* cases_;
do_traverse(Traverse*);
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
Bstatement*
do_get_backend(Translate_context*)
{ go_unreachable(); }
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The value to switch on. This may be NULL.
Expression* val_;
lower(Block*, Temporary_statement* descriptor_temp,
Unnamed_label* break_label) const;
+ // Dump the AST representation to a dump context.
+ void
+ dump_clauses(Ast_dump_context*) const;
+
private:
// One type case clause.
class Type_case_clause
lower(Block*, Temporary_statement* descriptor_temp,
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:
// The type for this type clause.
Type* type_;
do_traverse(Traverse*);
Statement*
- do_lower(Gogo*, Named_object*, Block*);
+ do_lower(Gogo*, Named_object*, Block*, Statement_inserter*);
Bstatement*
do_get_backend(Translate_context*)
{ go_unreachable(); }
+ void
+ do_dump_statement(Ast_dump_context*) const;
+
private:
// The variable holding the value we are switching on.
Named_object* var_;