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