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
15 #include "mc_forward.h"
16 #include "mc_location.h"
21 /** Represents a type in the program
23 * It is currently used to represent members of structs and unions as well.
28 Type(Type const& type) = default;
29 Type& operator=(Type const&) = default;
30 Type(Type&& type) = default;
31 Type& operator=(Type&&) = default;
33 /** The DWARF TAG of the type (e.g. DW_TAG_array_type) */
35 unsigned id; /* Offset in the section (in hexadecimal form) */
36 std::string name; /* Name of the type */
37 int byte_size; /* Size in bytes */
38 int element_count; /* Number of elements for array type */
39 unsigned type_id; /* DW_AT_type id */
40 std::vector<Type> members; /* if DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type*/
43 // Location (for members) is either of:
44 simgrid::mc::DwarfExpression location_expression;
46 simgrid::mc::Type* subtype; // DW_AT_type
47 simgrid::mc::Type* full_type; // The same (but more complete) type
49 bool has_offset_location() const
51 return location_expression.size() == 1 &&
52 location_expression[0].atom == DW_OP_plus_uconst;
55 // TODO, check if this shortcut is really necessary
58 xbt_assert(this->has_offset_location());
59 return this->location_expression[0].number;
62 void offset(int new_offset)
65 op.atom = DW_OP_plus_uconst;
66 op.number = new_offset;
67 this->location_expression = { op };
77 this->element_count = 0;
78 this->is_pointer_type = 0;
80 this->subtype = nullptr;
81 this->full_type = nullptr;