1aaad0892fe37ca575afe60287339f1ad48f670d
[m6w6/ext-psi] / scripts / gen_calc_bool.php
1 <?php
2 include __DIR__."/_include.php";
3 ?>
4
5
6 static inline token_t psi_calc_bool_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
7 {
8 (void) t2;
9 (void) v2;
10
11 switch (t1) {<?php /*nobr */ ?>
12 <?php foreach ($types as $t1 => $v1) : ?>
13 <?php if (t_is_special($t1)) :?>
14
15 #if HAVE_<?=$t1?>
16 <?php endif; ?>
17
18 case PSI_T_<?=$t1?>:
19 res->u8 = !v1-><?=$v1?>;
20 break;<?php /*nobr */ ?>
21 <?php if (t_is_special($t1)) : ?>
22
23 #endif
24 <?php endif; ?>
25 <?php endforeach; ?>
26
27 default:
28 assert(0);
29 break;
30 }
31 return PSI_T_UINT8;
32 }
33
34 static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
35 {
36 switch (t1) {<?php /*nobr */ ?>
37 <?php foreach ($types as $t1 => $v1) : ?>
38 <?php if (t_is_special($t1)) :?>
39
40 #if HAVE_<?=$t1?>
41 <?php endif; ?>
42
43 case PSI_T_<?=$t1?>:
44 if (v1-><?=$v1?>)
45 goto return_true;
46 break;<?php /*nobr */ ?>
47 <?php if (t_is_special($t1)) : ?>
48
49 #endif
50 <?php endif; ?>
51 <?php endforeach; ?>
52
53 default:
54 assert(0);
55 break;
56 }
57
58 switch (t2) {<?php /*nobr */ ?>
59 <?php foreach ($types as $t2 => $v2) : ?>
60 <?php if (t_is_special($t2)) :?>
61
62 #if HAVE_<?=$t2?>
63 <?php endif; ?>
64
65 case PSI_T_<?=$t2?>:
66 if (v2-><?=$v2?>)
67 goto return_true;
68 break;<?php /*nobr */ ?>
69 <?php if (t_is_special($t2)) : ?>
70
71 #endif
72 <?php endif; ?>
73 <?php endforeach; ?>
74
75 default:
76 assert(0);
77 break;
78 }
79
80 res->u8 = 0;
81 return PSI_T_UINT8;
82
83 return_true:
84 res->u8 = 1;
85 return PSI_T_UINT8;
86 }
87
88 static inline token_t psi_calc_bool_and(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
89 {
90 switch (t1) {<?php /*nobr */ ?>
91 <?php foreach ($types as $t1 => $v1) : ?>
92 <?php if (t_is_special($t1)) :?>
93
94 #if HAVE_<?=$t1?>
95 <?php endif; ?>
96
97 case PSI_T_<?=$t1?>:
98 if (!v1-><?=$v1?>)
99 goto return_false;
100 break;<?php /*nobr */ ?>
101 <?php if (t_is_special($t1)) : ?>
102
103 #endif
104 <?php endif; ?>
105 <?php endforeach; ?>
106
107 default:
108 assert(0);
109 break;
110 }
111
112 switch (t2) {<?php /*nobr */ ?>
113 <?php foreach ($types as $t2 => $v2) : ?>
114 <?php if (t_is_special($t2)) :?>
115
116 #if HAVE_<?=$t2?>
117 <?php endif; ?>
118
119 case PSI_T_<?=$t2?>:
120 if (!v2-><?=$v2?>)
121 goto return_false;
122 break;<?php /*nobr */ ?>
123 <?php if (t_is_special($t2)) : ?>
124
125 #endif
126 <?php endif; ?>
127 <?php endforeach; ?>
128
129 default:
130 assert(0);
131 break;
132 }
133
134 res->u8 = 1;
135 return PSI_T_UINT8;
136
137 return_false:
138 res->u8 = 0;
139 return PSI_T_UINT8;
140 }