EXTERN_C declarations for global arrays in various
[p5sagit/p5-mst-13.2.git] / opcode.pl
index 8fa6e29..1afc2f6 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -29,10 +29,10 @@ while (<DATA>) {
 
 $i = 0;
 print <<"END";
-#define pp_i_preinc pp_preinc
-#define pp_i_predec pp_predec
-#define pp_i_postinc pp_postinc
-#define pp_i_postdec pp_postdec
+#define Perl_pp_i_preinc Perl_pp_preinc
+#define Perl_pp_i_predec Perl_pp_predec
+#define Perl_pp_i_postinc Perl_pp_postinc
+#define Perl_pp_i_postdec Perl_pp_postdec
 
 typedef enum {
 END
@@ -46,10 +46,13 @@ print "\n#define MAXO ", scalar @ops, "\n\n";
 # Emit op names and descriptions.
 
 print <<END;
+
+START_EXTERN_C
+
 #ifndef DOINIT
-EXT char *op_name[];
+EXT char *PL_op_name[];
 #else
-EXT char *op_name[] = {
+EXT char *PL_op_name[] = {
 END
 
 for (@ops) {
@@ -64,9 +67,9 @@ END
 
 print <<END;
 #ifndef DOINIT
-EXT char *op_desc[];
+EXT char *PL_op_desc[];
 #else
-EXT char *op_desc[] = {
+EXT char *PL_op_desc[] = {
 END
 
 for (@ops) {
@@ -77,22 +80,31 @@ print <<END;
 };
 #endif
 
+END_EXTERN_C
+
 #ifndef PERL_OBJECT
 START_EXTERN_C
 
-END
+#undef PERL_CKDEF
+#undef PERL_PPDEF
+#define PERL_CKDEF(s) OP *s (pTHX_ OP *o);
+#define PERL_PPDEF(s) OP *s (pTHX);
 
-# Emit function declarations.
+#include "pp_proto.h"
 
-for (sort keys %ckname) {
-    print "OP *\t", &tab(3,$_),"_((OP* o));\n";
-}
+END
 
-print "\n";
+# Emit function declarations.
 
-for (@ops) {
-    print "OP *\t", &tab(3, "pp_$_"), "_((ARGSproto));\n";
-}
+#for (sort keys %ckname) {
+#    print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
+#}
+#
+#print "\n";
+#
+#for (@ops) {
+#    print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
+#}
 
 # Emit ppcode switch array.
 
@@ -101,20 +113,20 @@ print <<END;
 END_EXTERN_C
 #endif /* PERL_OBJECT */
 
+START_EXTERN_C
+
 #ifndef DOINIT
-EXT OP * (CPERLscope(*ppaddr)[])(ARGSproto);
+EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX);
 #else
-#ifndef PERL_OBJECT
-EXT OP * (CPERLscope(*ppaddr)[])(ARGSproto) = {
+EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = {
 END
 
 for (@ops) {
-    print "\tpp_$_,\n";
+    print "\tPerl_pp_$_,\n";
 }
 
 print <<END;
 };
-#endif /* PERL_OBJECT */
 #endif
 
 END
@@ -123,19 +135,17 @@ END
 
 print <<END;
 #ifndef DOINIT
-EXT OP * (CPERLscope(*check)[]) _((OP *op));
+EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op);
 #else
-#ifndef PERL_OBJECT
-EXT OP * (CPERLscope(*check)[]) _((OP *op)) = {
+EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = {
 END
 
 for (@ops) {
-    print "\t", &tab(3, "$check{$_},"), "/* $_ */\n";
+    print "\t", &tab(3, "Perl_$check{$_},"), "/* $_ */\n";
 }
 
 print <<END;
 };
-#endif /* PERL_OBJECT */
 #endif
 
 END
@@ -144,9 +154,9 @@ END
 
 print <<END;
 #ifndef DOINIT
-EXT U32 opargs[];
+EXT U32 PL_opargs[];
 #else
-EXT U32 opargs[] = {
+EXT U32 PL_opargs[] = {
 END
 
 %argnum = (
@@ -169,7 +179,7 @@ END
     '/',  6,           # pmop
     '$',  7,           # svop
     '*',  8,           # gvop
-    '"',  9,           # pvop
+    '"',  9,           # pvop_or_svop
     '{',  10,          # loop
     ';',  11,          # cop
     '%',  12,          # baseop_or_unop
@@ -189,7 +199,7 @@ for (@ops) {
     $argsum |= 64 if $flags =~ /d/;            # danger, unknown side effects
     $argsum |= 128 if $flags =~ /u/;           # defaults to $_
 
-    $flags =~ /([^a-zA-Z])/ or die qq[Opcode "$_" has no class indicator];
+    $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
     $argsum |= $opclass{$1} << 8;
     $mul = 4096;                               # 2 ^ OASHIFT
     for $arg (split(' ',$args{$_})) {
@@ -205,16 +215,33 @@ for (@ops) {
 print <<END;
 };
 #endif
+
+END_EXTERN_C
 END
 
 close OC or die "Error closing opcode.h: $!";
 
+unlink "pp_proto.h";
+unlink "pp.sym";
 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
+open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
+
+for (sort keys %ckname) {
+    print PP "PERL_CKDEF(Perl_$_)\n";
+    print PPSYM "Perl_$_\n";
+#OP *\t", &tab(3,$_),"(OP* o);\n";
+}
+
+print PP "\n\n";
+
 for (@ops) {
-    print PP "PPDEF(pp_$_)\n";
+    next if /^i_(pre|post)(inc|dec)$/;
+    print PP "PERL_PPDEF(Perl_pp_$_)\n";
+    print PPSYM "Perl_pp_$_\n";
 }
 
 close PP or die "Error closing pp_proto.h: $!";
+close PPSYM or die "Error closing pp.sym: $!";
 
 ###########################################################################
 sub tab {
@@ -246,7 +273,7 @@ padav               private array           ck_null         d0
 padhv          private hash            ck_null         d0
 padany         private something       ck_null         d0
 
-pushre         push regexp             ck_null         /
+pushre         push regexp             ck_null         d/
 
 # References and stuff.
 
@@ -272,8 +299,10 @@ rcatline   append I/O operator     ck_null         t%
 # Bindable operators.
 
 regcmaybe      regexp comp once        ck_fun          s1      S
+regcreset      regexp reset interpolation flag ck_fun          s1      S
 regcomp                regexp compilation      ck_null         s|      S
 match          pattern match           ck_match        d/
+qr             pattern quote           ck_match        s/
 subst          substitution            ck_null         dis/    S
 substcont      substitution cont       ck_null         dis|    
 trans          character translation   ck_null         is"     S
@@ -288,7 +317,7 @@ chop                chop                    ck_spair        mts%    L
 schop          scalar chop             ck_null         stu%    S?
 chomp          safe chop               ck_spair        mts%    L
 schomp         scalar safe chop        ck_null         stu%    S?
-defined                defined operator        ck_rfun         isu%    S?
+defined                defined operator        ck_defined      isu%    S?
 undef          undef operator          ck_lfun         s%      S?
 study          study                   ck_fun          su%     S?
 pos            match position          ck_lfun         stu%    S?
@@ -428,7 +457,7 @@ anonhash    anonymous hash          ck_fun          ms@     L
 
 splice         splice                  ck_fun          m@      A S? S? L
 push           push                    ck_fun          imst@   A L
-pop            pop                     ck_shift        si%     A
+pop            pop                     ck_shift        s%      A
 shift          shift                   ck_shift        s%      A
 unshift                unshift                 ck_fun          imst@   A L
 sort           sort                    ck_sort         m@      C? L
@@ -466,7 +495,7 @@ reset               reset                   ck_fun          is%     S?
 lineseq                line sequence           ck_null         @       
 nextstate      next statement          ck_null         s;      
 dbstate                debug next statement    ck_null         s;      
-unstack                unstack                 ck_null         s0
+unstack                iteration finalizer     ck_null         s0
 enter          block entry             ck_null         0       
 leave          block exit              ck_null         @       
 scope          block                   ck_null         @       
@@ -515,7 +544,7 @@ print               print                   ck_listiob      ims@    F? L
 sysopen                sysopen                 ck_fun          s@      F S S S?
 sysseek                sysseek                 ck_fun          s@      F S S
 sysread                sysread                 ck_fun          imst@   F R S S?
-syswrite       syswrite                ck_fun          imst@   F S S S?
+syswrite       syswrite                ck_fun          imst@   F S S? S?
 
 send           send                    ck_fun          imst@   F S S S?
 recv           recv                    ck_fun          imst@   F R S S