This repository was archived by the owner on Sep 29, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefine.h
More file actions
50 lines (44 loc) · 1.44 KB
/
define.h
File metadata and controls
50 lines (44 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef DEFINE_H
#define DEFINE_H
#include <QString>
#include <QVector>
/// @beief Struct for variable declaration
///
/// A variable declaration may contain 4 parts
/// (take this statement as example: char* argv[2]):
/// - data_type: char
/// - var_name: argv
/// - array_size: 2
/// - is_pointer: true
/// @note Only one-demension array is supported here, but it's easy to extend
/// with this awareness
///
struct VariableDeclaration {
QString data_type; ///< name of a data type, either basic type or
///< user-defined type
QString var_name; ///< variable name
size_t offset = 0; ///< member offset in struct: -1 for non-struct
size_t bit_size = 0; // int v : bit_size , 0 for no bit_size exists
struct {
size_t shift = 0;
size_t mask = std::numeric_limits<size_t>::max(); // mask for bit_field
} op;
QVector<size_t> array_dims; ///< array size: empty for non-array
bool is_pointer = false; ///< true when it's a pointer
size_t var_size = 0; ///< total size in bytes
size_t element_count = 1; ///< cached element_count
};
enum class MsgType { Error, Warn };
struct MsgInfo {
MsgType type = MsgType::Error;
size_t line = 0;
size_t charPositionInLine = 0;
QString info;
};
struct StructUnionDecl {
QString name;
bool isStruct = true;
int alignment = 0;
QVector<VariableDeclaration> members;
};
#endif // DEFINE_H