#!/usr/bin/perl die "Usage: mkstubdefns.pl low_arg_count high_arg_count\n" if ($#ARGV != 1); $low = $ARGV[0]; $high = $ARGV[1]; for ($k = $low; $k <= $high; $k++) { print "\#undef P$k\n"; print "\#undef Q$k\n"; &output_p_defn ($k); &output_q_defn ($k); print "\#define Q_SAVED0D1A0A1_$k\tQ$k\n"; print "\#define Q_SAVED1A0A1_$k\tQ$k\n"; } sub make_list { local ($first, $last, $tmpl, $c) = @_; local ($i, $new); local ($ret); $ret = ""; for ($i = $first; $i <= $last; $i++) { $ret .= "$c " if ($i != $first); ($new = $tmpl) =~ s/\@/$i/g; $ret .= $new; } $ret; } sub output_p_defn { local ($num_args) = @_; local ($i); $leading_comma = $num_args ? ", " : ""; $arg_list = ", " . &make_list (0, $num_args, 't@, n@', ','); $a_list = &make_list (1, $num_args, 'A@', ','); $assign_list = &make_list (1, $num_args, '\%s __stub_arg_@ = (A@)', ";\\\\\\n "); $lookup_list = ($leading_comma . &make_list (1, $num_args, 'map_type_name ( #t@ )', ',')); $assign_list .= ";\\\\\\n" if ($num_args); $shared_arg_list = (&make_list (1, $num_args, '__stub_arg_@', ',')); $defn = <