-
-
Notifications
You must be signed in to change notification settings - Fork 266
Expand file tree
/
Copy pathEduCfrontTest22.expect
More file actions
98 lines (77 loc) · 2.18 KB
/
EduCfrontTest22.expect
File metadata and controls
98 lines (77 loc) · 2.18 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
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
88
89
90
91
92
93
94
95
96
97
/*************************************************************************************
* NOTE: This an educational hand-rolled transformation. Things can be incorrect or *
* buggy. *
*************************************************************************************/
void __cxa_start(void);
void __cxa_atexit(void);
typedef int (*__vptp)();
struct __mptr
{
short d;
short i;
__vptp f;
};
extern struct __mptr* __vtbl_array[];
#include <cstdio>
typedef struct Fruit
{
__mptr * __vptrFruit;
} Fruit;
inline Fruit * Constructor_Fruit(Fruit * __this)
{
__this->__vptrFruit = __vtbl_array[0];
(*((void (*)(const Fruit *))((__this)->__vptrFruit[1]).f))((((const Fruit *)(char *)(__this)) + ((__this)->__vptrFruit[1]).d));
return __this;
}
inline void Destructor_Fruit(Fruit * __this)
{
__this->__vptrFruit = __vtbl_array[0];
(*((void (*)(const Fruit *))((__this)->__vptrFruit[1]).f))((((const Fruit *)(char *)(__this)) + ((__this)->__vptrFruit[1]).d));
}
inline void PrintFruit(const Fruit * __this)
{
puts("Base");
}
typedef struct Apple
{
__mptr * __vptrFruit;
} Apple;
inline Apple * Constructor_Apple(Apple * __this)
{
Constructor_Fruit((Fruit *)__this);
__this->__vptrFruit = __vtbl_array[1];
return __this;
}
inline void Destructor_Apple(Apple * __this)
{
(*((void (*)(const Apple *))((__this)->__vptrFruit[1]).f))((((const Apple *)(char *)(__this)) + ((__this)->__vptrFruit[1]).d));
Destructor_Fruit((Fruit *)__this);
}
inline void PrintApple(const Apple * __this)
{
puts("Apple");
}
int __main(void)
{
Apple x;
Constructor_Apple((Apple *)&x);
return 0;
(*((void (*)(Apple *))((&x)->__vptrFruit[0]).f))((((Apple *)(char *)(&x)) + ((&x)->__vptrFruit[0]).d));
}
int main(void)
{
__cxa_start();
int ret = __main();
__cxa_atexit();
return ret;
/* ret // lifetime ends here */
}
__mptr __vtbl_Fruit[2] = {{0, 0, (__vptp)Destructor_Fruit}, {0, 0, (__vptp)PrintFruit}};
__mptr __vtbl_Apple[2] = {{0, 0, (__vptp)Destructor_Apple}, {0, 0, (__vptp)PrintApple}};
__mptr * __vtbl_array[2] = {__vtbl_Fruit, __vtbl_Apple};
void __cxa_start(void)
{
}
void __cxa_atexit(void)
{
}