// be put into a unique section if possible; this is intended to
// permit the linker to garbage collect the variable if it is not
// referenced. LOCATION is where the variable was defined.
- virtual Bvariable *
- global_variable (const std::string &name, const std::string &asm_name,
- tree btype, bool is_external, bool is_hidden,
- bool in_unique_section, location_t location)
- = 0;
+ Bvariable *global_variable (const std::string &name,
+ const std::string &asm_name, tree btype,
+ bool is_external, bool is_hidden,
+ bool in_unique_section, location_t location);
// A global variable will 1) be initialized to zero, or 2) be
// initialized to a constant value, or 3) be initialized in the init
// global_variable_set_init to set the initial value. If this is
// not called, the backend should initialize a global variable to 0.
// The init function may then assign a value to it.
- virtual void global_variable_set_init (Bvariable *, tree) = 0;
+ void global_variable_set_init (Bvariable *, tree);
// Create a local variable. The frontend will create the local
// variables first, and then create the block which contains them.
// the function, as otherwise the variable would be on the heap).
// LOCATION is where the variable is defined. For each local variable
// the frontend will call init_statement to set the initial value.
- virtual Bvariable *local_variable (tree function, const std::string &name,
- tree type, Bvariable *decl_var,
- location_t location)
- = 0;
+ Bvariable *local_variable (tree function, const std::string &name, tree type,
+ Bvariable *decl_var, location_t location);
// Create a function parameter. This is an incoming parameter, not
// a result parameter (result parameters are treated as local
// variables). The arguments are as for local_variable.
- virtual Bvariable *parameter_variable (tree function, const std::string &name,
- tree type, location_t location)
- = 0;
+ Bvariable *parameter_variable (tree function, const std::string &name,
+ tree type, location_t location);
// Create a static chain parameter. This is the closure parameter.
- virtual Bvariable *static_chain_variable (tree function,
- const std::string &name, tree type,
- location_t location)
- = 0;
+ Bvariable *static_chain_variable (tree function, const std::string &name,
+ tree type, location_t location);
// Create a temporary variable. A temporary variable has no name,
// just a type. We pass in FUNCTION and BLOCK in case they are
// variable, and may not be very useful. This function should
// return a variable which can be referenced later and should set
// *PSTATEMENT to a statement which initializes the variable.
- virtual Bvariable *temporary_variable (tree fndecl, tree bind_tree, tree type,
- tree init, bool address_is_taken,
- location_t location, tree *pstatement)
- = 0;
+ Bvariable *temporary_variable (tree fndecl, tree bind_tree, tree type,
+ tree init, bool address_is_taken,
+ location_t location, tree *pstatement);
// Labels.
tree fill_in_fields (tree, const std::vector<typed_identifier> &);
tree fill_in_array (tree, tree, tree);
+
+ tree non_zero_size_type (tree);
+
+ tree convert_tree (tree, tree, location_t);
};
class Gcc_backend : public Backend
void block_add_statements (tree, const std::vector<tree> &);
- // Variables.
-
- Bvariable *global_variable (const std::string &var_name,
- const std::string &asm_name, tree type,
- bool is_external, bool is_hidden,
- bool in_unique_section, location_t location);
-
- void global_variable_set_init (Bvariable *, tree);
-
- Bvariable *local_variable (tree, const std::string &, tree, Bvariable *,
- location_t);
-
- Bvariable *parameter_variable (tree, const std::string &, tree, location_t);
-
- Bvariable *static_chain_variable (tree, const std::string &, tree,
- location_t);
-
- Bvariable *temporary_variable (tree, tree, tree, tree, bool, location_t,
- tree *);
-
// Functions.
tree function (tree fntype, const std::string &name,
const std::vector<Bvariable *> &);
void write_export_data (const char *bytes, unsigned int size);
-
-private:
- tree non_zero_size_type (tree);
-
- tree convert_tree (tree, tree, location_t);
};
#endif // RUST_BACKEND_H
// Return a type corresponding to TYPE with non-zero size.
tree
-Gcc_backend::non_zero_size_type (tree type)
+Backend::non_zero_size_type (tree type)
{
if (int_size_in_bytes (type) != 0)
return type;
// representations. Make sure this does not confuse the middle-end.
tree
-Gcc_backend::convert_tree (tree type_tree, tree expr_tree, location_t location)
+Backend::convert_tree (tree type_tree, tree expr_tree, location_t location)
{
if (type_tree == TREE_TYPE (expr_tree))
return expr_tree;
// Make a global variable.
Bvariable *
-Gcc_backend::global_variable (const std::string &var_name,
- const std::string &asm_name, tree type_tree,
- bool is_external, bool is_hidden,
- bool in_unique_section, location_t location)
+Backend::global_variable (const std::string &var_name,
+ const std::string &asm_name, tree type_tree,
+ bool is_external, bool is_hidden,
+ bool in_unique_section, location_t location)
{
if (type_tree == error_mark_node)
return Bvariable::error_variable ();
// Set the initial value of a global variable.
void
-Gcc_backend::global_variable_set_init (Bvariable *var, tree expr_tree)
+Backend::global_variable_set_init (Bvariable *var, tree expr_tree)
{
if (expr_tree == error_mark_node)
return;
// Make a local variable.
Bvariable *
-Gcc_backend::local_variable (tree function, const std::string &name,
- tree type_tree, Bvariable *decl_var,
- location_t location)
+Backend::local_variable (tree function, const std::string &name, tree type_tree,
+ Bvariable *decl_var, location_t location)
{
if (type_tree == error_mark_node)
return Bvariable::error_variable ();
// Make a function parameter variable.
Bvariable *
-Gcc_backend::parameter_variable (tree function, const std::string &name,
- tree type_tree, location_t location)
+Backend::parameter_variable (tree function, const std::string &name,
+ tree type_tree, location_t location)
{
if (type_tree == error_mark_node)
return Bvariable::error_variable ();
// Make a static chain variable.
Bvariable *
-Gcc_backend::static_chain_variable (tree fndecl, const std::string &name,
- tree type_tree, location_t location)
+Backend::static_chain_variable (tree fndecl, const std::string &name,
+ tree type_tree, location_t location)
{
if (type_tree == error_mark_node)
return Bvariable::error_variable ();
// Make a temporary variable.
Bvariable *
-Gcc_backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
- tree init_tree, bool is_address_taken,
- location_t location, tree *pstatement)
+Backend::temporary_variable (tree fndecl, tree bind_tree, tree type_tree,
+ tree init_tree, bool is_address_taken,
+ location_t location, tree *pstatement)
{
gcc_assert (fndecl != NULL_TREE);
if (type_tree == error_mark_node || init_tree == error_mark_node