summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-10-16 16:02:35 +0000
committerNicholas Clark <nick@ccl4.org>2007-10-16 16:02:35 +0000
commit8261f8eb698db59828f3e3dd7a1ee82976ab259e (patch)
tree3ea5346f672c31284bdb8657b4e964ff2a29eb4b
parent20773dcda05c239bb7300f7eed1a0ff4ef022a0a (diff)
downloadperl-8261f8eb698db59828f3e3dd7a1ee82976ab259e.tar.gz
PL_AMG_names is only used by gv.c (as far as Google code search can
see), so it can easily be a static variable inside gv.c. This allows the implementation to be changed in future Perls within the 5.10.x series. p4raw-id: //depot/perl@32116
-rw-r--r--MANIFEST3
-rw-r--r--globvar.sym1
-rw-r--r--gv.c1
-rw-r--r--overload.c90
-rw-r--r--overload.h84
-rw-r--r--overload.pl37
6 files changed, 120 insertions, 96 deletions
diff --git a/MANIFEST b/MANIFEST
index 69fe3145b0..d85ca32c4f 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -3038,7 +3038,8 @@ os2/OS2/typemap Common typemap for OS/2 types
os2/perl2cmd.pl Corrects installed binaries under OS/2
os2/perlrexx.c Support perl interpreter embedded in REXX
os2/perlrexx.cmd Test perl interpreter embedded in REXX
-overload.h generated overload enum and name table
+overload.c generated overload enum (public)
+overload.h generated overload name table (implementation)
overload.pl generate overload.h
pad.c Scratchpad functions
pad.h Scratchpad headers
diff --git a/globvar.sym b/globvar.sym
index d98b4d306f..24f8bcd4e7 100644
--- a/globvar.sym
+++ b/globvar.sym
@@ -3,7 +3,6 @@
# *** Only structures/arrays with constant initializers should go here.
# *** Usual globals initialized at runtime should be added in *var*.h.
-AMG_names
block_type
check
fold
diff --git a/gv.c b/gv.c
index 156f2fbf44..8c0b4e10bd 100644
--- a/gv.c
+++ b/gv.c
@@ -33,6 +33,7 @@ Perl stores its global variables.
#include "EXTERN.h"
#define PERL_IN_GV_C
#include "perl.h"
+#include "overload.c"
static const char S_autoload[] = "AUTOLOAD";
static const STRLEN S_autolen = sizeof(S_autoload)-1;
diff --git a/overload.c b/overload.c
new file mode 100644
index 0000000000..0a220cc4de
--- /dev/null
+++ b/overload.c
@@ -0,0 +1,90 @@
+/* -*- buffer-read-only: t -*-
+ *
+ * overload.c
+ *
+ * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 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.
+ *
+ * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
+ * This file is built by overload.pl
+ */
+
+#define AMG_id2name(id) (PL_AMG_names[id]+1)
+
+char * const PL_AMG_names[NofAMmeth] = {
+ /* Names kept in the symbol table. fallback => "()", the rest has
+ "(" prepended. The only other place in perl which knows about
+ 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=",
+ "(.",
+ "(.=",
+ "(~~",
+ "DESTROY"
+};
diff --git a/overload.h b/overload.h
index adf1feae2d..1750585122 100644
--- a/overload.h
+++ b/overload.h
@@ -2,8 +2,8 @@
*
* overload.h
*
- * Copyright (C) 1997, 1998, 2000, 2001, 2005 and 2006 by Larry Wall and
- * others
+ * Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 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.
@@ -84,85 +84,5 @@ enum {
/* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
};
-
#define NofAMmeth max_amg_code
-#define AMG_id2name(id) (PL_AMG_names[id]+1)
-#ifdef DOINIT
-EXTCONST char * const PL_AMG_names[NofAMmeth] = {
- /* Names kept in the symbol table. fallback => "()", the rest has
- "(" prepended. The only other place in perl which knows about
- 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=",
- "(.",
- "(.=",
- "(~~",
- "DESTROY"
-};
-#else
-EXTCONST char * PL_AMG_names[NofAMmeth];
-#endif /* def INITAMAGIC */
diff --git a/overload.pl b/overload.pl
index 295c837102..9def29f429 100644
--- a/overload.pl
+++ b/overload.pl
@@ -21,14 +21,18 @@ while (<DATA>) {
push @names, $name;
}
-safer_unlink 'overload.h';
+safer_unlink ('overload.h', 'overload.c');
+die "overload.h: $!" unless open(C, ">overload.c");
+binmode C;
die "overload.h: $!" unless open(H, ">overload.h");
binmode H;
-select H;
-print <<'EOF';
+
+sub print_header {
+ my $file = shift;
+ print <<"EOF";
/* -*- buffer-read-only: t -*-
*
- * overload.h
+ * $file
*
* Copyright (C) 1997, 1998, 2000, 2001, 2005, 2006, 2007 by Larry Wall
* and others
@@ -39,6 +43,15 @@ print <<'EOF';
* !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
* This file is built by overload.pl
*/
+EOF
+}
+
+select C;
+print_header('overload.c');
+
+select H;
+print_header('overload.h');
+print <<'EOF';
enum {
EOF
@@ -50,12 +63,15 @@ print <<'EOF';
/* Do not leave a trailing comma here. C9X allows it, C89 doesn't. */
};
-
#define NofAMmeth max_amg_code
+
+EOF
+
+print C <<'EOF';
+
#define AMG_id2name(id) (PL_AMG_names[id]+1)
-#ifdef DOINIT
-EXTCONST char * const PL_AMG_names[NofAMmeth] = {
+char * const PL_AMG_names[NofAMmeth] = {
/* Names kept in the symbol table. fallback => "()", the rest has
"(" prepended. The only other place in perl which knows about
this convention is AMG_id2name (used for debugging output and
@@ -64,14 +80,11 @@ EXTCONST char * const PL_AMG_names[NofAMmeth] = {
EOF
my $last = pop @names;
-print " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
+print C " \"$_\",\n" foreach map { s/(["\\"])/\\$1/g; $_ } @names;
-print <<"EOT";
+print C <<"EOT";
"$last"
};
-#else
-EXTCONST char * PL_AMG_names[NofAMmeth];
-#endif /* def INITAMAGIC */
EOT
close H or die $!;