Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] OOify DWARF stack/evaluation expression
[simgrid.git] / src / mc / Type.hpp
index 032ad2c..42978af 100644 (file)
 namespace simgrid {
 namespace mc {
 
+/** Represent a member of  a structure (or inheritance) */
+class Member {
+public:
+  Member() : inheritance(false), byte_size(0), type_id(0) {}
+
+  bool inheritance;
+  std::string name;
+  simgrid::dwarf::DwarfExpression location_expression;
+  std::size_t byte_size; // Do we really need this?
+  unsigned type_id;
+  simgrid::mc::Type* type;
+
+  bool has_offset_location() const
+  {
+    return location_expression.size() == 1 &&
+      location_expression[0].atom == DW_OP_plus_uconst;
+  }
+
+  // TODO, check if this shortcut is really necessary
+  int offset() const
+  {
+    xbt_assert(this->has_offset_location());
+    return this->location_expression[0].number;
+  }
+
+  void offset(int new_offset)
+  {
+    Dwarf_Op op;
+    op.atom = DW_OP_plus_uconst;
+    op.number = new_offset;
+    this->location_expression = { op };
+  }
+};
+
 /** Represents a type in the program
  *
  *  It is currently used to represent members of structs and unions as well.
@@ -37,35 +71,11 @@ public:
   int byte_size; /* Size in bytes */
   int element_count; /* Number of elements for array type */
   unsigned type_id; /* DW_AT_type id */
-  std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
+  std::vector<Member> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
   int is_pointer_type;
 
-  // Location (for members) is either of:
-  simgrid::mc::DwarfExpression location_expression;
-
   simgrid::mc::Type* subtype; // DW_AT_type
   simgrid::mc::Type* full_type; // The same (but more complete) type
-
-  bool has_offset_location() const
-  {
-    return location_expression.size() == 1 &&
-      location_expression[0].atom == DW_OP_plus_uconst;
-  }
-
-  // TODO, check if this shortcut is really necessary
-  int offset() const
-  {
-    xbt_assert(this->has_offset_location());
-    return this->location_expression[0].number;
-  }
-
-  void offset(int new_offset)
-  {
-    DwarfInstruction op;
-    op.atom = DW_OP_plus_uconst;
-    op.number = new_offset;
-    this->location_expression = { op };
-  }
 };
 
 inline