Rewrite expression code.
[pspp-builds.git] / src / expressions / evaluate.h.pl
1 do 'generate.pl';
2
3 sub generate_output {
4     print "#include \"helpers.h\"\n\n";
5
6     for my $opname (@order) {
7         my ($op) = $ops{$opname};
8         next if $op->{UNIMPLEMENTED};
9
10         my (@args);
11         for my $arg (@{$op->{ARGS}}) {
12             if (!defined $arg->{IDX}) {
13                 push (@args, c_type ($arg->{TYPE}) . $arg->{NAME});
14             } else {
15                 push (@args, c_type ($arg->{TYPE}) . "$arg->{NAME}" . "[]");
16                 push (@args, "size_t $arg->{IDX}");
17             }
18         }
19         for my $aux (@{$op->{AUX}}) {
20             push (@args, c_type ($aux->{TYPE}) . $aux->{NAME});
21         }
22         push (@args, "void") if !@args;
23
24         my ($statements) = $op->{BLOCK} || "  return $op->{EXPRESSION};\n";
25
26         print "static inline ", c_type ($op->{RETURNS}), "\n";
27         print "eval_$opname (", join (', ', @args), ")\n";
28         print "{\n";
29         print "$statements";
30         print "}\n\n";
31     }
32 }