summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-01-03 16:49:02 +0000
committerDavid Mitchell <davem@iabyn.com>2011-01-03 17:13:25 +0000
commitc4ac9b44187717c7530f3bc3c6329b26e61c1f0b (patch)
tree5f0e0c8a9791803382ea56038ae9b553a9db9c62
parent2c17609f30aa451f45b0a17ed14e5c53245180a3 (diff)
downloadperl-c4ac9b44187717c7530f3bc3c6329b26e61c1f0b.tar.gz
regen/overload.pl: add comments to overload.[ch]
In the auto-generated overload.c and overload.h files, add a comment to each line mapping from the method name to the enumeration name and vice-versa.
-rw-r--r--overload.c140
-rw-r--r--overload.h142
-rw-r--r--regen/overload.pl22
3 files changed, 159 insertions, 145 deletions
diff --git a/overload.c b/overload.c
index acd400355a..4ccba19b63 100644
--- a/overload.c
+++ b/overload.c
@@ -2,8 +2,8 @@
*
* overload.c
*
- * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
- * and others
+ * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007, 2011
+ * by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
@@ -93,73 +93,73 @@ static const char * const PL_AMG_names[NofAMmeth] = {
this convention is AMG_id2name (used for debugging output and
'nomethod' only), the only other place which has it hardwired is
overload.pm. */
- "()",
- "(${}",
- "(@{}",
- "(%{}",
- "(*{}",
- "(&{}",
- "(++",
- "(--",
- "(bool",
- "(0+",
- "(\"\"",
- "(!",
- "(=",
- "(abs",
- "(neg",
- "(<>",
- "(int",
- "(<",
- "(<=",
- "(>",
- "(>=",
- "(==",
- "(!=",
- "(lt",
- "(le",
- "(gt",
- "(ge",
- "(eq",
- "(ne",
- "(nomethod",
- "(+",
- "(+=",
- "(-",
- "(-=",
- "(*",
- "(*=",
- "(/",
- "(/=",
- "(%",
- "(%=",
- "(**",
- "(**=",
- "(<<",
- "(<<=",
- "(>>",
- "(>>=",
- "(&",
- "(&=",
- "(|",
- "(|=",
- "(^",
- "(^=",
- "(<=>",
- "(cmp",
- "(~",
- "(atan2",
- "(cos",
- "(sin",
- "(exp",
- "(log",
- "(sqrt",
- "(x",
- "(x=",
- "(.",
- "(.=",
- "(~~",
- "(-X",
- "(qr",
+ "()", /* fallback */
+ "(${}", /* to_sv */
+ "(@{}", /* to_av */
+ "(%{}", /* to_hv */
+ "(*{}", /* to_gv */
+ "(&{}", /* to_cv */
+ "(++", /* inc */
+ "(--", /* dec */
+ "(bool", /* bool_ */
+ "(0+", /* numer */
+ "(\"\"", /* string */
+ "(!", /* not */
+ "(=", /* copy */
+ "(abs", /* abs */
+ "(neg", /* neg */
+ "(<>", /* iter */
+ "(int", /* int */
+ "(<", /* lt */
+ "(<=", /* le */
+ "(>", /* gt */
+ "(>=", /* ge */
+ "(==", /* eq */
+ "(!=", /* ne */
+ "(lt", /* slt */
+ "(le", /* sle */
+ "(gt", /* sgt */
+ "(ge", /* sge */
+ "(eq", /* seq */
+ "(ne", /* sne */
+ "(nomethod", /* nomethod */
+ "(+", /* add */
+ "(+=", /* add_ass */
+ "(-", /* subtr */
+ "(-=", /* subtr_ass */
+ "(*", /* mult */
+ "(*=", /* mult_ass */
+ "(/", /* div */
+ "(/=", /* div_ass */
+ "(%", /* modulo */
+ "(%=", /* modulo_ass */
+ "(**", /* pow */
+ "(**=", /* pow_ass */
+ "(<<", /* lshift */
+ "(<<=", /* lshift_ass */
+ "(>>", /* rshift */
+ "(>>=", /* rshift_ass */
+ "(&", /* band */
+ "(&=", /* band_ass */
+ "(|", /* bor */
+ "(|=", /* bor_ass */
+ "(^", /* bxor */
+ "(^=", /* bxor_ass */
+ "(<=>", /* ncmp */
+ "(cmp", /* scmp */
+ "(~", /* compl */
+ "(atan2", /* atan2 */
+ "(cos", /* cos */
+ "(sin", /* sin */
+ "(exp", /* exp */
+ "(log", /* log */
+ "(sqrt", /* sqrt */
+ "(x", /* repeat */
+ "(x=", /* repeat_ass */
+ "(.", /* concat */
+ "(.=", /* concat_ass */
+ "(~~", /* smart */
+ "(-X", /* ftest */
+ "(qr", /* regexp */
"DESTROY"
};
diff --git a/overload.h b/overload.h
index 8d74b48444..87c22fdb41 100644
--- a/overload.h
+++ b/overload.h
@@ -2,8 +2,8 @@
*
* overload.h
*
- * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
- * and others
+ * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007, 2011
+ * by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
@@ -13,75 +13,75 @@
*/
enum {
- fallback_amg,
- to_sv_amg,
- to_av_amg,
- to_hv_amg,
- to_gv_amg,
- to_cv_amg,
- inc_amg,
- dec_amg,
- bool__amg,
- numer_amg,
- string_amg,
- not_amg,
- copy_amg,
- abs_amg,
- neg_amg,
- iter_amg,
- int_amg,
- lt_amg,
- le_amg,
- gt_amg,
- ge_amg,
- eq_amg,
- ne_amg,
- slt_amg,
- sle_amg,
- sgt_amg,
- sge_amg,
- seq_amg,
- sne_amg,
- nomethod_amg,
- add_amg,
- add_ass_amg,
- subtr_amg,
- subtr_ass_amg,
- mult_amg,
- mult_ass_amg,
- div_amg,
- div_ass_amg,
- modulo_amg,
- modulo_ass_amg,
- pow_amg,
- pow_ass_amg,
- lshift_amg,
- lshift_ass_amg,
- rshift_amg,
- rshift_ass_amg,
- band_amg,
- band_ass_amg,
- bor_amg,
- bor_ass_amg,
- bxor_amg,
- bxor_ass_amg,
- ncmp_amg,
- scmp_amg,
- compl_amg,
- atan2_amg,
- cos_amg,
- sin_amg,
- exp_amg,
- log_amg,
- sqrt_amg,
- repeat_amg,
- repeat_ass_amg,
- concat_amg,
- concat_ass_amg,
- smart_amg,
- ftest_amg,
- regexp_amg,
- DESTROY_amg,
+ fallback_amg, /* fallback */
+ to_sv_amg, /* ${} */
+ to_av_amg, /* @{} */
+ to_hv_amg, /* %{} */
+ to_gv_amg, /* *{} */
+ to_cv_amg, /* &{} */
+ inc_amg, /* ++ */
+ dec_amg, /* -- */
+ bool__amg, /* bool */
+ numer_amg, /* 0+ */
+ string_amg, /* "" */
+ not_amg, /* ! */
+ copy_amg, /* = */
+ abs_amg, /* abs */
+ neg_amg, /* neg */
+ iter_amg, /* <> */
+ int_amg, /* int */
+ lt_amg, /* < */
+ le_amg, /* <= */
+ gt_amg, /* > */
+ ge_amg, /* >= */
+ eq_amg, /* == */
+ ne_amg, /* != */
+ slt_amg, /* lt */
+ sle_amg, /* le */
+ sgt_amg, /* gt */
+ sge_amg, /* ge */
+ seq_amg, /* eq */
+ sne_amg, /* ne */
+ nomethod_amg, /* nomethod */
+ add_amg, /* + */
+ add_ass_amg, /* += */
+ subtr_amg, /* - */
+ subtr_ass_amg, /* -= */
+ mult_amg, /* * */
+ mult_ass_amg, /* *= */
+ div_amg, /* / */
+ div_ass_amg, /* /= */
+ modulo_amg, /* % */
+ modulo_ass_amg, /* %= */
+ pow_amg, /* ** */
+ pow_ass_amg, /* **= */
+ lshift_amg, /* << */
+ lshift_ass_amg, /* <<= */
+ rshift_amg, /* >> */
+ rshift_ass_amg, /* >>= */
+ band_amg, /* & */
+ band_ass_amg, /* &= */
+ bor_amg, /* | */
+ bor_ass_amg, /* |= */
+ bxor_amg, /* ^ */
+ bxor_ass_amg, /* ^= */
+ ncmp_amg, /* <=> */
+ scmp_amg, /* cmp */
+ compl_amg, /* ~ */
+ atan2_amg, /* atan2 */
+ cos_amg, /* cos */
+ sin_amg, /* sin */
+ exp_amg, /* exp */
+ log_amg, /* log */
+ sqrt_amg, /* sqrt */
+ repeat_amg, /* x */
+ repeat_ass_amg, /* x= */
+ concat_amg, /* . */
+ concat_ass_amg, /* .= */
+ smart_amg, /* ~~ */
+ ftest_amg, /* -X */
+ regexp_amg, /* qr */
+ DESTROY_amg, /* DESTROY */
max_amg_code
/* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
};
diff --git a/regen/overload.pl b/regen/overload.pl
index 67a30cad0b..a41c820e3b 100644
--- a/regen/overload.pl
+++ b/regen/overload.pl
@@ -80,8 +80,8 @@ sub print_header {
*
* $file
*
- * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
- * and others
+ * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007, 2011
+ * by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
@@ -102,7 +102,15 @@ print <<'EOF';
enum {
EOF
-print map " ${_}_amg,\n", @enums;
+for (0..$#enums) {
+ my $op = $names[$_];
+ $op = 'fallback' if $op eq '()';
+ $op =~ s/^\(//;
+ die if $op =~ m{\*/};
+ my $l = 3 - int((length($enums[$_]) + 9) / 8);
+ $l = 1 if $l < 1;
+ printf " %s_amg,%s/* %-8s */\n", $enums[$_], ("\t" x $l), $op;
+}
print <<'EOF';
max_amg_code
@@ -138,7 +146,13 @@ static const char * const PL_AMG_names[NofAMmeth] = {
overload.pm. */
EOT
-print $c map { s/(["\\"])/\\$1/g; " \"$_\",\n" } @names;
+for (0..$#names) {
+ my $n = $names[$_];
+ $n =~ s/(["\\])/\\$1/g;
+ my $l = 3 - int((length($n) + 7) / 8);
+ $l = 1 if $l < 1;
+ printf $c " \"%s\",%s/* %-10s */\n", $n, ("\t" x $l), $enums[$_];
+}
print $c <<"EOT";
"$last"