3 # Regenerate (overwriting only if changed):
7 # lib/overload/numbers.pm
9 # from information stored in the DATA section of this file.
11 # This allows the order of overloading constants to be changed.
13 # Accepts the standard regen_lib -q and -v args.
15 # This script is normally invoked from regen.pl.
18 # Get function prototypes
19 require './regen/regen_lib.pl';
28 my ($enum, $name) = /^(\S+)\s+(\S+)/ or die "Can't parse $_";
35 { by => 'regen/overload.pl', file => $_, style => '*',
36 copyright => [1997, 1998, 2000, 2001, 2005 .. 2007, 2011] });
37 } 'overload.inc', 'overload.h';
39 mkdir("lib/overload", 0777) unless -d 'lib/overload';
40 my $p = open_new('lib/overload/numbers.pm', '>',
41 { by => 'regen/overload.pl',
42 file => 'lib/overload/numbers.pm', copyright => [2008] });
47 package overload::numbers;
57 { my \$i = 0; our %names = map { \$_ => \$i++ } \@names }
59 { my \$i = 0; our %enums = map { \$_ => \$i++ } \@enums }
67 $op = 'fallback' if $op eq '()';
70 my $l = 3 - int((length($enums[$_]) + 9) / 8);
72 printf $h " %s_amg,%s/* 0x%02x %-8s */\n", $enums[$_],
78 /* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
81 #define NofAMmeth max_amg_code
85 #define AMG_id2name(id) (PL_AMG_names[id]+1)
86 #define AMG_id2namelen(id) (PL_AMG_namelens[id]-1)
88 static const U8 PL_AMG_namelens[NofAMmeth] = {
91 my $last = pop @names;
93 print $c map { " " . (length $_) . ",\n" } @names;
95 my $lastlen = length $last;
100 static const char * const PL_AMG_names[NofAMmeth] = {
101 /* Names kept in the symbol table. fallback => "()", the rest has
102 "(" prepended. The only other place in perl which knows about
103 this convention is AMG_id2name (used for debugging output and
104 'nomethod' only), the only other place which has it hardwired is
110 $n =~ s/(["\\])/\\$1/g;
111 my $l = 3 - int((length($n) + 7) / 8);
113 printf $c " \"%s\",%s/* %-10s */\n", $n, ("\t" x $l), $enums[$_];
121 foreach ($h, $c, $p) {
122 read_only_bottom_close_and_rename($_);
125 # Fallback should be the first
128 # These 5 are the most common in the fallback switch statement in amagic_call
135 # These have non-default cases in that switch statement
148 # These 12 feature in the next switch statement