// Types.
// Get the wchar type
- virtual tree wchar_type () = 0;
+ tree wchar_type ();
// Get the Host pointer size in bits
- virtual int get_pointer_size () = 0;
+ int get_pointer_size ();
// Get the raw str type const char*
- virtual tree raw_str_type () = 0;
+ tree raw_str_type ();
// Get an unnamed integer type with the given signedness and number
// of bits.
- virtual tree integer_type (bool is_unsigned, int bits) = 0;
+ tree integer_type (bool is_unsigned, int bits);
// Get an unnamed floating point type with the given number of bits
// (32 or 64).
- virtual tree float_type (int bits) = 0;
+ tree float_type (int bits);
// Get an unnamed complex type with the given number of bits (64 or 128).
- virtual tree complex_type (int bits) = 0;
+ tree complex_type (int bits);
// Get a pointer type.
- virtual tree pointer_type (tree to_type) = 0;
+ tree pointer_type (tree to_type);
// Get a reference type.
- virtual tree reference_type (tree to_type) = 0;
+ tree reference_type (tree to_type);
// make type immutable
- virtual tree immutable_type (tree base) = 0;
+ tree immutable_type (tree base);
// Get a function type. The receiver, parameter, and results are
// generated from the types in the Function_type. The Function_type
// one result, RESULT_STRUCT is a struct type to hold the results,
// and RESULTS may be ignored; if there are zero or one results,
// RESULT_STRUCT is NULL.
- virtual tree function_type (const typed_identifier &receiver,
+ tree function_type (const typed_identifier &receiver,
+ const std::vector<typed_identifier> ¶meters,
+ const std::vector<typed_identifier> &results,
+ tree result_struct, location_t location);
+
+ tree function_type_varadic (const typed_identifier &receiver,
const std::vector<typed_identifier> ¶meters,
const std::vector<typed_identifier> &results,
- tree result_struct, location_t location)
- = 0;
+ tree result_struct, location_t location);
- virtual tree
- function_type_varadic (const typed_identifier &receiver,
- const std::vector<typed_identifier> ¶meters,
- const std::vector<typed_identifier> &results,
- tree result_struct, location_t location)
- = 0;
-
- virtual tree function_ptr_type (tree result,
- const std::vector<tree> &praameters,
- location_t location)
- = 0;
+ tree function_ptr_type (tree result, const std::vector<tree> &praameters,
+ location_t location);
// Get a struct type.
- virtual tree struct_type (const std::vector<typed_identifier> &fields) = 0;
+ tree struct_type (const std::vector<typed_identifier> &fields);
// Get a union type.
- virtual tree union_type (const std::vector<typed_identifier> &fields) = 0;
+ tree union_type (const std::vector<typed_identifier> &fields);
// Get an array type.
- virtual tree array_type (tree element_type, tree length) = 0;
+ tree array_type (tree element_type, tree length);
// Return a named version of a type. The location is the location
// of the type definition. This will not be called for a type
// created via placeholder_pointer_type, placeholder_struct_type, or
// placeholder_array_type.. (It may be called for a pointer,
// struct, or array type in a case like "type P *byte; type Q P".)
- virtual tree named_type (const std::string &name, tree, location_t) = 0;
+ tree named_type (const std::string &name, tree, location_t);
// Return the size of a type.
- virtual int64_t type_size (tree) = 0;
+ int64_t type_size (tree);
// Return the alignment of a type.
- virtual int64_t type_alignment (tree) = 0;
+ int64_t type_alignment (tree);
// Return the alignment of a struct field of this type. This is
// normally the same as type_alignment, but not always.
- virtual int64_t type_field_alignment (tree) = 0;
+ int64_t type_field_alignment (tree);
// Return the offset of field INDEX in a struct type. INDEX is the
// entry in the FIELDS std::vector parameter of struct_type or
// set_placeholder_struct_type.
- virtual int64_t type_field_offset (tree, size_t index) = 0;
+ int64_t type_field_offset (tree, size_t index);
// Expressions.
// Write SIZE bytes of export data from BYTES to the proper
// section in the output object file.
virtual void write_export_data (const char *bytes, unsigned int size) = 0;
+
+protected:
+ tree fill_in_fields (tree, const std::vector<typed_identifier> &);
+
+ tree fill_in_array (tree, tree, tree);
};
class Gcc_backend : public Backend
tree get_identifier_node (const std::string &str);
- // Types.
-
- tree wchar_type ();
-
- int get_pointer_size ();
-
- tree raw_str_type ();
-
- tree integer_type (bool, int);
-
- tree float_type (int);
-
- tree complex_type (int);
-
- tree pointer_type (tree);
-
- tree reference_type (tree);
-
- tree immutable_type (tree);
-
- tree function_type (const typed_identifier &,
- const std::vector<typed_identifier> &,
- const std::vector<typed_identifier> &, tree,
- const location_t);
-
- tree function_type_varadic (const typed_identifier &,
- const std::vector<typed_identifier> &,
- const std::vector<typed_identifier> &, tree,
- const location_t);
-
- tree function_ptr_type (tree, const std::vector<tree> &, location_t);
-
- tree struct_type (const std::vector<typed_identifier> &);
-
- tree union_type (const std::vector<typed_identifier> &);
-
- tree array_type (tree, tree);
-
- tree named_type (const std::string &, tree, location_t);
-
- int64_t type_size (tree);
-
- int64_t type_alignment (tree);
-
- int64_t type_field_alignment (tree);
-
- int64_t type_field_offset (tree, size_t index);
-
// Expressions.
tree zero_expression (tree);
void write_export_data (const char *bytes, unsigned int size);
private:
- 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);
}
tree
-Gcc_backend::wchar_type ()
+Backend::wchar_type ()
{
tree wchar = make_unsigned_type (32);
TYPE_STRING_FLAG (wchar) = 1;
// Get an unnamed integer type.
int
-Gcc_backend::get_pointer_size ()
+Backend::get_pointer_size ()
{
return POINTER_SIZE;
}
tree
-Gcc_backend::raw_str_type ()
+Backend::raw_str_type ()
{
tree char_ptr = build_pointer_type (char_type_node);
tree const_char_type = build_qualified_type (char_ptr, TYPE_QUAL_CONST);
}
tree
-Gcc_backend::integer_type (bool is_unsigned, int bits)
+Backend::integer_type (bool is_unsigned, int bits)
{
tree type;
if (is_unsigned)
// Get an unnamed float type.
tree
-Gcc_backend::float_type (int bits)
+Backend::float_type (int bits)
{
tree type;
if (bits == FLOAT_TYPE_SIZE)
// Get an unnamed complex type.
tree
-Gcc_backend::complex_type (int bits)
+Backend::complex_type (int bits)
{
tree type;
if (bits == FLOAT_TYPE_SIZE * 2)
// Get a pointer type.
tree
-Gcc_backend::pointer_type (tree to_type)
+Backend::pointer_type (tree to_type)
{
if (to_type == error_mark_node)
return error_mark_node;
// Get a reference type.
tree
-Gcc_backend::reference_type (tree to_type)
+Backend::reference_type (tree to_type)
{
if (to_type == error_mark_node)
return error_mark_node;
// Get immutable type
tree
-Gcc_backend::immutable_type (tree base)
+Backend::immutable_type (tree base)
{
if (base == error_mark_node)
return error_mark_node;
// Make a function type.
tree
-Gcc_backend::function_type (const typed_identifier &receiver,
- const std::vector<typed_identifier> ¶meters,
- const std::vector<typed_identifier> &results,
- tree result_struct, location_t)
+Backend::function_type (const typed_identifier &receiver,
+ const std::vector<typed_identifier> ¶meters,
+ const std::vector<typed_identifier> &results,
+ tree result_struct, location_t)
{
tree args = NULL_TREE;
tree *pp = &args;
}
tree
-Gcc_backend::function_type_varadic (
- const typed_identifier &receiver,
- const std::vector<typed_identifier> ¶meters,
- const std::vector<typed_identifier> &results, tree result_struct, location_t)
+Backend::function_type_varadic (const typed_identifier &receiver,
+ const std::vector<typed_identifier> ¶meters,
+ const std::vector<typed_identifier> &results,
+ tree result_struct, location_t)
{
size_t n = parameters.size () + (receiver.type != NULL_TREE ? 1 : 0);
tree *args = XALLOCAVEC (tree, n);
}
tree
-Gcc_backend::function_ptr_type (tree result_type,
- const std::vector<tree> ¶meters,
- location_t /* locus */)
+Backend::function_ptr_type (tree result_type,
+ const std::vector<tree> ¶meters,
+ location_t /* locus */)
{
tree args = NULL_TREE;
tree *pp = &args;
// Make a struct type.
tree
-Gcc_backend::struct_type (const std::vector<typed_identifier> &fields)
+Backend::struct_type (const std::vector<typed_identifier> &fields)
{
return fill_in_fields (make_node (RECORD_TYPE), fields);
}
// Make a union type.
tree
-Gcc_backend::union_type (const std::vector<typed_identifier> &fields)
+Backend::union_type (const std::vector<typed_identifier> &fields)
{
return fill_in_fields (make_node (UNION_TYPE), fields);
}
// Fill in the fields of a struct or union type.
tree
-Gcc_backend::fill_in_fields (tree fill,
- const std::vector<typed_identifier> &fields)
+Backend::fill_in_fields (tree fill, const std::vector<typed_identifier> &fields)
{
tree field_trees = NULL_TREE;
tree *pp = &field_trees;
// Make an array type.
tree
-Gcc_backend::array_type (tree element_type, tree length)
+Backend::array_type (tree element_type, tree length)
{
return fill_in_array (make_node (ARRAY_TYPE), element_type, length);
}
// Fill in an array type.
tree
-Gcc_backend::fill_in_array (tree fill, tree element_type, tree length_tree)
+Backend::fill_in_array (tree fill, tree element_type, tree length_tree)
{
if (element_type == error_mark_node || length_tree == error_mark_node)
return error_mark_node;
// Return a named version of a type.
tree
-Gcc_backend::named_type (const std::string &name, tree type,
- location_t location)
+Backend::named_type (const std::string &name, tree type, location_t location)
{
if (type == error_mark_node)
return error_mark_node;
// Return the size of a type.
int64_t
-Gcc_backend::type_size (tree t)
+Backend::type_size (tree t)
{
if (t == error_mark_node)
return 1;
// Return the alignment of a type.
int64_t
-Gcc_backend::type_alignment (tree t)
+Backend::type_alignment (tree t)
{
if (t == error_mark_node)
return 1;
// Return the alignment of a struct field of type BTYPE.
int64_t
-Gcc_backend::type_field_alignment (tree t)
+Backend::type_field_alignment (tree t)
{
if (t == error_mark_node)
return 1;
// Return the offset of a field in a struct.
int64_t
-Gcc_backend::type_field_offset (tree struct_tree, size_t index)
+Backend::type_field_offset (tree struct_tree, size_t index)
{
if (struct_tree == error_mark_node)
return 0;