1 /* Copyright (c) 2007-2015. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #ifndef SIMGRID_MC_TYPE_HPP
8 #define SIMGRID_MC_TYPE_HPP
13 #include "mc_forward.h"
14 #include "mc_location.h"
19 /** Represents a type in the program
21 * It is currently used to represent members of structs and unions as well.
26 Type(Type const& type) = default;
27 Type& operator=(Type const&) = default;
28 Type(Type&& type) = default;
29 Type& operator=(Type&&) = default;
31 /** The DWARF TAG of the type (e.g. DW_TAG_array_type) */
33 unsigned id; /* Offset in the section (in hexadecimal form) */
34 std::string name; /* Name of the type */
35 int byte_size; /* Size in bytes */
36 int element_count; /* Number of elements for array type */
37 unsigned type_id; /* DW_AT_type id */
38 std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
41 // Location (for members) is either of:
42 simgrid::mc::DwarfExpression location_expression;
44 simgrid::mc::Type* subtype; // DW_AT_type
45 simgrid::mc::Type* full_type; // The same (but more complete) type
47 bool has_offset_location() const
49 return location_expression.size() == 1 &&
50 location_expression[0].atom == DW_OP_plus_uconst;
53 // TODO, check if this shortcut is really necessary
56 xbt_assert(this->has_offset_location());
57 return this->location_expression[0].number;
60 void offset(int new_offset)
63 op.atom = DW_OP_plus_uconst;
64 op.number = new_offset;
65 this->location_expression = { op };
75 this->element_count = 0;
76 this->is_pointer_type = 0;
78 this->subtype = nullptr;
79 this->full_type = nullptr;