Rewrite conversion of named types to backend representation.
[gcc.git] / gcc / go / gofrontend / gogo.h
index 49f1be51468519347bba9016940b20cb7461226e..8db802ea53e34881dc8ba645423f9dd5450bd052 100644 (file)
@@ -100,9 +100,9 @@ operator<(const Import_init& i1, const Import_init& i2)
 class Gogo
 {
  public:
-  // Create the IR, passing in the sizes of the types "int", "float",
-  // and "uintptr" in bits.
-  Gogo(int int_type_size, int float_type_size, int pointer_size);
+  // Create the IR, passing in the sizes of the types "int" and
+  // "uintptr" in bits.
+  Gogo(int int_type_size, int pointer_size);
 
   // Get the package name.
   const std::string&
@@ -112,6 +112,10 @@ class Gogo
   void
   set_package_name(const std::string&, source_location);
 
+  // Return whether this is the "main" package.
+  bool
+  is_main_package() const;
+
   // If necessary, adjust the name to use for a hidden symbol.  We add
   // a prefix of the package name, so that hidden symbols in different
   // packages do not collide.
@@ -318,6 +322,11 @@ class Gogo
   void
   record_interface_type(Interface_type*);
 
+  // Note that we need an initialization function.
+  void
+  set_need_init_fn()
+  { this->need_init_fn_ = true; }
+
   // Clear out all names in file scope.  This is called when we start
   // parsing a new file.
   void
@@ -396,6 +405,20 @@ class Gogo
   void
   simplify_thunk_statements();
 
+  // Convert named types to the backend representation.
+  void
+  convert_named_types();
+
+  // Convert named types in a list of bindings.
+  void
+  convert_named_types_in_bindings(Bindings*);
+
+  // True if named types have been converted to the backend
+  // representation.
+  bool
+  named_types_are_converted() const
+  { return this->named_types_are_converted_; }
+
   // Write out the global values.
   void
   write_globals();
@@ -648,8 +671,12 @@ class Gogo
   std::set<Import_init> imported_init_fns_;
   // The unique prefix used for all global symbols.
   std::string unique_prefix_;
+  // Whether an explicit unique prefix was set by -fgo-prefix.
+  bool unique_prefix_specified_;
   // A list of interface types defined while parsing.
   std::vector<Interface_type*> interface_types_;
+  // Whether named types have been converted.
+  bool named_types_are_converted_;
 };
 
 // A block of statements.
@@ -787,6 +814,11 @@ class Function
   void
   create_named_result_variables(Gogo*);
 
+  // Update the named result variables when cloning a function which
+  // calls recover.
+  void
+  update_named_result_variables();
+
   // Add a new field to the closure variable.
   void
   add_closure_field(Named_object* var, source_location loc)
@@ -1038,6 +1070,9 @@ class Variable
           bool is_receiver, source_location);
 
   // Get the type of the variable.
+  Type*
+  type();
+
   Type*
   type() const;
 
@@ -1135,12 +1170,12 @@ class Variable
   // Get the preinit block, a block of statements to be run before the
   // initialization expression.
   Block*
-  preinit_block();
+  preinit_block(Gogo*);
 
   // Add a statement to be run before the initialization expression.
   // This is only used for global variables.
   void
-  add_preinit_statement(Statement*);
+  add_preinit_statement(Gogo*, Statement*);
 
   // Lower the initialization expression after parsing is complete.
   void
@@ -1258,6 +1293,8 @@ class Variable
   bool is_varargs_parameter_ : 1;
   // Whether something takes the address of this variable.
   bool is_address_taken_ : 1;
+  // True if we have seen this variable in a traversal.
+  bool seen_ : 1;
   // True if we have lowered the initialization expression.
   bool init_is_lowered_ : 1;
   // True if init is a tuple used to set the type.
@@ -1313,6 +1350,12 @@ class Result_variable
   is_in_heap() const
   { return this->is_address_taken_; }
 
+  // Set the function.  This is used when cloning functions which call
+  // recover.
+  void
+  set_function(Function* function)
+  { this->function_ = function; }
+
  private:
   // Type of result variable.
   Type* type_;
@@ -1810,6 +1853,10 @@ class Named_object
   void
   set_function_value(Function*);
 
+  // Declare an unknown name as a type declaration.
+  void
+  declare_as_type();
+
   // Export this object.
   void
   export_named_object(Export*) const;