-
Notifications
You must be signed in to change notification settings - Fork 1
/
destination_struct_layout.txt
86 lines (72 loc) · 986 Bytes
/
destination_struct_layout.txt
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
struct class_name_vtable {
super virtual function ponters
.
.
.
virtual function pointers
.
.
.
}
struct class_name {
class_name_vtable* vtable;
recursive super fields/pointers
.
.
.
fields
.
.
.
function pointers
.
.
.
}
example:
class P {
private int f1;
private double f2;
virtual int m1() {
return 1;
}
int m2() {
return 1;
}
}
class D : P {
private int f3;
int m2() {
return 2;
}
virtual double m3(int input) {
return 2.0 * input;
}
}
results in
struct P_vtable {
int (*m1)() = P::m1;
}
struct D_vtable {
int (*m1)() = P::m1;
double (*m3)(int) = D::m3;
}
struct P {
P_vtable* vtable = &P_vtable;
int f1;
double f2;
int (*P::m2)();
}
struct D {
D_vtable* vtable = &D_vtable;
int f1;
double f2;
int (*P::m2)();
int f3;
int (*D::m2)();
double (*m3)(int);
}
struct class_child_node* new_class_child_node() {
struct class_child_node* output = malloc(sizeof(struct class_child_node));
return output;
}