-
Notifications
You must be signed in to change notification settings - Fork 2
/
record_context.cpp
87 lines (75 loc) · 1.48 KB
/
record_context.cpp
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <iostream>
#include <vector>
#include <gcc-plugin.h>
#include <coretypes.h>
#include <tree.h>
#include "record_context.hpp"
#include "identifier_node.hpp"
using namespace std;
void
RecordContext::record_begin (const char *pname)
{
class_name = pname;
classcount++;
if (pname)
{
cout << pname;
}
else
{
cout << "unnamed";
}
cout << "() { " << endl;
cout << "\t define_generic_class_name<"
<< pname << ">(\"" << pname << "\");" << endl;
}
const char *
RecordContext::type_name (TC_IDENTIFIER_NODE * cb, tree_node * t)
{
const char *n = cb->id (t);
return n;
};
const char *
RecordContext::field_name (TC_IDENTIFIER_NODE * cb, tree_node * t)
{
const char *n = cb->id (t);
//std::cerr << "Field Name:" << n << std::endl;
return n;
}
void
RecordContext::field_begin (Field & fld)
{
cerr << "RecordContext::field_begin(";
if (fld.bit_field)
{
cout << "\t define_generic_bitfield<";
cout << class_name;
cout << ">(";
if (fld.name)
{
cout << "\"" << fld.name << "\",";
}
}
else
{
cout << "\t define_generic_field (";
cout << "&" << class_name << "::";
if (fld.name)
{
cout << fld.name;
cout << ",";
cout << "\"" << fld.name << "\",";
}
}
cout << fld.bit_field << ","
<< fld.offset << ","
<< fld.bit_offset << "," << fld.bit_size << ");" << endl;
cerr << ")";
}
void
RecordContext::record_end ()
{
cout << "}; " << endl;
}
int
RecordContext::classcount = 0;