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&
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.
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
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();
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.
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)
bool is_receiver, source_location);
// Get the type of the variable.
+ Type*
+ type();
+
Type*
type() const;
// 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
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.
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_;
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;