compiler: don't pass iota value to lowering pass

It is no longer used.  The iota value is now handled in the
determine-types pass.

Change-Id: I321802161f7d922dacaa2427da72e90c869e6f64
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/536644
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
Ian Lance Taylor 2023-10-19 20:03:14 -07:00
Родитель 61b29a99da
Коммит ddf3758e4a
3 изменённых файлов: 36 добавлений и 39 удалений

Просмотреть файл

@ -1007,7 +1007,7 @@ Expression::make_type(Type* type, Location location)
Expression*
Var_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
if (this->variable_->is_variable())
{
@ -1158,7 +1158,7 @@ Enclosed_var_expression::do_traverse(Traverse*)
Expression*
Enclosed_var_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
gogo->lower_expression(function, inserter, &this->reference_);
return this;
@ -2097,7 +2097,7 @@ Unknown_expression::do_is_addressable() const
// Lower a reference to an unknown name.
Expression*
Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
Unknown_expression::do_lower(Gogo*, Named_object*, Statement_inserter*)
{
if (this->is_error_expression())
return Expression::make_error(this->location());
@ -3642,7 +3642,7 @@ Const_expression::do_is_zero_value() const
// predeclared constant iota into an integer value.
Expression*
Const_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*, int)
Const_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*)
{
Location loc = this->location();
@ -4120,7 +4120,7 @@ class Iota_expression : public Parser_expression
{ }
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int)
do_lower(Gogo*, Named_object*, Statement_inserter*)
{ go_unreachable(); }
// There should only ever be one of these.
@ -4171,7 +4171,7 @@ Type_conversion_expression::do_type()
Expression*
Type_conversion_expression::do_lower(Gogo* gogo, Named_object*,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
Type* type = this->type_;
Expression* val = this->expr_;
@ -4997,7 +4997,7 @@ Unary_expression::check_operand_address_taken(Gogo*)
// instead.
Expression*
Unary_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*, int)
Unary_expression::do_lower(Gogo* gogo, Named_object*, Statement_inserter*)
{
Location loc = this->location();
@ -6677,7 +6677,7 @@ Binary_expression::eval_complex(Operator op, const Numeric_constant* left_nc,
Expression*
Binary_expression::do_lower(Gogo* gogo, Named_object*,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
Location location = this->location();
@ -8955,7 +8955,7 @@ class Selector_expression : public Parser_expression
do_issue_nil_check();
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_copy()
@ -9030,7 +9030,7 @@ Selector_expression::do_issue_nil_check()
// Lower a selector expression to the resolved value.
Expression*
Selector_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
Selector_expression::do_lower(Gogo*, Named_object*, Statement_inserter*)
{
if (this->is_error_expression() || this->resolved_ == NULL)
return Expression::make_error(this->location());
@ -9360,7 +9360,7 @@ Builtin_call_expression::do_set_recover_arg(Expression* arg)
Expression*
Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
if (this->is_error_expression())
return this;
@ -12564,7 +12564,7 @@ Call_expression::do_discarding_value()
Expression*
Call_expression::do_lower(Gogo* gogo, Named_object*,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
if (this->lowered_ != NULL)
return this->lowered_;
@ -14836,7 +14836,7 @@ Index_expression::do_issue_nil_check()
// expression into an array index, a string index, or a map index.
Expression*
Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*, int)
Index_expression::do_lower(Gogo*, Named_object*, Statement_inserter*)
{
if (this->is_error_expression())
return Expression::make_error(this->location());
@ -16211,7 +16211,7 @@ Expression::make_map_index(Expression* map, Expression* index,
Expression*
Field_reference_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
Struct_type* struct_type = this->expr_->type()->struct_type();
if (struct_type == NULL)
@ -18018,7 +18018,7 @@ class Composite_literal_key_expression : public Parser_expression
do_determine_type(Gogo*, const Type_context*);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_copy()
@ -18084,7 +18084,7 @@ Composite_literal_key_expression::do_type()
Expression*
Composite_literal_key_expression::do_lower(Gogo*, Named_object*,
Statement_inserter*, int)
Statement_inserter*)
{
if (this->is_error_expression())
return Expression::make_error(this->location());
@ -18658,7 +18658,7 @@ Composite_literal_expression::do_check_types(Gogo* gogo)
Expression*
Composite_literal_expression::do_lower(Gogo* gogo, Named_object* function,
Statement_inserter* inserter, int)
Statement_inserter* inserter)
{
if (this->is_error_expression() || this->type_->is_error())
return Expression::make_error(this->location());

Просмотреть файл

@ -990,9 +990,8 @@ class Expression
// which could not be fully parsed into their final form. It
// returns the same Expression or a new one.
Expression*
lower(Gogo* gogo, Named_object* function, Statement_inserter* inserter,
int iota_value)
{ return this->do_lower(gogo, function, inserter, iota_value); }
lower(Gogo* gogo, Named_object* function, Statement_inserter* inserter)
{ return this->do_lower(gogo, function, inserter); }
// Flatten an expression. This is called after order_evaluation.
// FUNCTION is the function we are in; it will be NULL for an
@ -1162,7 +1161,7 @@ class Expression
// Return a lowered expression.
virtual Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int)
do_lower(Gogo*, Named_object*, Statement_inserter*)
{ return this; }
// Return a flattened expression.
@ -1472,7 +1471,7 @@ class Parser_expression : public Expression
protected:
virtual Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int) = 0;
do_lower(Gogo*, Named_object*, Statement_inserter*) = 0;
Bexpression*
do_get_backend(Translate_context*)
@ -1511,7 +1510,7 @@ class Const_expression : public Expression
do_traverse(Traverse*);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
bool
do_is_constant() const
@ -1599,7 +1598,7 @@ class Var_expression : public Expression
protected:
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Type*
do_type();
@ -1663,7 +1662,7 @@ class Enclosed_var_expression : public Expression
do_traverse(Traverse*);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -1953,7 +1952,7 @@ class Type_conversion_expression : public Expression
do_traverse(Traverse* traverse);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -2154,7 +2153,7 @@ class Unary_expression : public Expression
{ return Expression::traverse(&this->expr_, traverse); }
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -2315,7 +2314,7 @@ class Binary_expression : public Expression
do_traverse(Traverse* traverse);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -2440,7 +2439,7 @@ class String_concat_expression : public Expression
{ return this->exprs_->traverse(traverse); }
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int)
do_lower(Gogo*, Named_object*, Statement_inserter*)
{ return this; }
Expression*
@ -2628,7 +2627,7 @@ class Call_expression : public Expression
do_traverse(Traverse*);
virtual Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
virtual Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -2823,7 +2822,7 @@ class Builtin_call_expression : public Call_expression
protected:
// This overrides Call_expression::do_lower.
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_flatten(Gogo*, Named_object*, Statement_inserter*);
@ -3169,7 +3168,7 @@ class Unknown_expression : public Parser_expression
do_is_addressable() const;
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_copy()
@ -3238,7 +3237,7 @@ class Index_expression : public Parser_expression
do_is_addressable() const;
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*s);
Expression*
do_copy()
@ -3739,7 +3738,7 @@ class Field_reference_expression : public Expression
{ return Expression::traverse(&this->expr_, traverse); }
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Type*
do_type();
@ -3965,7 +3964,7 @@ class Composite_literal_expression : public Parser_expression
do_check_types(Gogo*);
Expression*
do_lower(Gogo*, Named_object*, Statement_inserter*, int);
do_lower(Gogo*, Named_object*, Statement_inserter*);
Expression*
do_copy();

Просмотреть файл

@ -2914,7 +2914,7 @@ class Lower_parse_tree : public Traverse
| traverse_functions
| traverse_statements
| traverse_expressions),
gogo_(gogo), function_(function), iota_value_(-1), inserter_()
gogo_(gogo), function_(function), inserter_()
{ }
void
@ -2941,8 +2941,6 @@ class Lower_parse_tree : public Traverse
Gogo* gogo_;
// The function we are traversing.
Named_object* function_;
// Value to use for the predeclared constant iota.
int iota_value_;
// Current statement inserter for use by expressions.
Statement_inserter inserter_;
};
@ -3086,7 +3084,7 @@ Lower_parse_tree::expression(Expression** pexpr)
{
Expression* e = *pexpr;
Expression* enew = e->lower(this->gogo_, this->function_,
&this->inserter_, this->iota_value_);
&this->inserter_);
if (enew == e)
break;
if (enew->traverse_subexpressions(this) == TRAVERSE_EXIT)