set psi as module for register functions
[m6w6/ext-psi] / scripts / gen_calc_cmp.php
1 <?php
2
3 include __DIR__."/_include.php";
4
5 $ops = [
6 "eq" => "==",
7 "ne" => "!=",
8 "lt" => "<",
9 "gt" => ">",
10 "le" => "<=",
11 "ge" => ">="
12 ];
13
14 ?>
15
16 <?php foreach ($ops as $op_name => $op) : ?>
17
18 static inline token_t psi_calc_cmp_<?=$op_name?>(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
19 {
20 switch (t1) {<?php /*nobr*/ ?>
21 <?php foreach ($types as $t1 => $v1) : ?>
22 <?php if (t_is_special($t1)) : ?>
23
24 #if HAVE_<?=$t1?>
25 <?php endif; ?>
26
27 case PSI_T_<?=$t1?>:
28 switch (t2) {<?php /*nobr*/ ?>
29 <?php foreach ($types as $t2 => $v2) : ?>
30 <?php if (t_is_special($t2)) :?>
31
32 # if HAVE_<?=$t2?>
33 <?php endif; ?>
34
35 case PSI_T_<?=$t2?>:
36 res->u8 = v1-><?=$v1?> <?=$op?> v2-><?=$v2?>;
37 break;<?php /*nobr*/ ?>
38 <?php if (t_is_special($t2)) : ?>
39
40 # endif
41 <?php endif; ?>
42 <?php endforeach; ?>
43
44 default:
45 assert(0);
46 break;
47 }
48 break;<?php /*nobr*/ ?>
49 <?php if (t_is_special($t1)) : ?>
50
51 #endif
52 <?php endif; ?>
53 <?php endforeach; ?>
54
55 default:
56 assert(0);
57 break;
58 }
59 return PSI_T_UINT8;
60 }
61 <?php endforeach; ?>