perl 5.003_03: writemain.SH
[p5sagit/p5-mst-13.2.git] / opcode.pl
index 1a2d5a7..2c2bc50 100755 (executable)
--- a/opcode.pl
+++ b/opcode.pl
@@ -9,9 +9,15 @@ while (<DATA>) {
     chop;
     next unless $_;
     next if /^#/;
-    ($key, $name, $check, $flags, $args) = split(/\t+/, $_, 5);
+    ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
+
+    warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
+    die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
+    $seen{$desc} = qq[description of opcode "$key"];
+    $seen{$key} = qq[opcode "$key"];
+
     push(@ops, $key);
-    $name{$key} = $name;
+    $desc{$key} = $desc;
     $check{$key} = $check;
     $ckname{$check}++;
     $flags{$key} = $flags;
@@ -21,7 +27,14 @@ while (<DATA>) {
 # Emit defines.
 
 $i = 0;
-print "typedef enum {\n";
+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
+
+typedef enum {
+END
 for (@ops) {
     print "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
 }
@@ -29,7 +42,7 @@ print "\t", &tab(3,"OP_max"), "\n";
 print "} opcode;\n";
 print "\n#define MAXO ", scalar @ops, "\n\n"; 
 
-# Emit opnames.
+# Emit op names and descriptions.
 
 print <<END;
 #ifndef DOINIT
@@ -39,7 +52,24 @@ EXT char *op_name[] = {
 END
 
 for (@ops) {
-    print qq(\t"$name{$_}",\n);
+    print qq(\t"$_",\n);
+}
+
+print <<END;
+};
+#endif
+
+END
+
+print <<END;
+#ifndef DOINIT
+EXT char *op_desc[];
+#else
+EXT char *op_desc[] = {
+END
+
+for (@ops) {
+    print qq(\t"$desc{$_}",\n);
 }
 
 print <<END;
@@ -169,21 +199,22 @@ const             constant item           ck_svconst      s
 
 gvsv           scalar variable         ck_null         ds      
 gv             glob value              ck_null         ds      
-padsv          private variable        ck_null         s
-padav          private array           ck_null         0
-padhv          private hash            ck_null         0
-padany         private something       ck_null         0
+gelem          glob elem               ck_null         d       S S
+padsv          private variable        ck_null         ds
+padav          private array           ck_null         d
+padhv          private hash            ck_null         d
+padany         private something       ck_null         d
 
 pushre         push regexp             ck_null         0
 
 # References and stuff.
 
 rv2gv          ref-to-glob cast        ck_rvconst      ds      
-sv2len         scalar value length     ck_null         ist     
 rv2sv          scalar deref            ck_rvconst      ds      
 av2arylen      array length            ck_null         is      
 rv2cv          subroutine deref        ck_rvconst      d
 anoncode       anonymous subroutine    ck_null         0       
+prototype      subroutine prototype    ck_null         s       S
 refgen         reference constructor   ck_spair        m       L
 srefgen                scalar ref constructor  ck_null         fs      S
 ref            reference-type operator ck_fun          stu     S?
@@ -216,7 +247,7 @@ chomp               safe chop               ck_spair        mts     L
 schomp         scalar safe chop        ck_null         stu     S?
 defined                defined operator        ck_rfun         isu     S?
 undef          undef operator          ck_lfun         s       S?
-study          study                   ck_fun          stu     S?
+study          study                   ck_fun          su      S?
 pos            match position          ck_lfun         stu     S?
 
 preinc         preincrement            ck_lfun         dIs     S
@@ -375,7 +406,7 @@ flop                range (or flop)         ck_null         0
 and            logical and             ck_null         0       
 or             logical or              ck_null         0       
 xor            logical xor             ck_null         fs      S S     
-cond_expr      conditional expression  ck_null         0       
+cond_expr      conditional expression  ck_null         d       
 andassign      logical and assignment  ck_null         s       
 orassign       logical or assignment   ck_null         s       
 
@@ -398,7 +429,7 @@ enteriter   foreach loop entry      ck_null         d
 iter           foreach loop iterator   ck_null         0       
 enterloop      loop entry              ck_null         d       
 leaveloop      loop exit               ck_null         0       
-return         return                  ck_fun          dm      L
+return         return                  ck_null         dm      L
 last           last                    ck_null         ds      
 next           next                    ck_null         ds      
 redo           redo                    ck_null         ds      
@@ -421,6 +452,7 @@ binmode             binmode                 ck_fun          s       F
 
 tie            tie                     ck_fun          idms    R S L
 untie          untie                   ck_fun          is      R
+tied           tied                    ck_fun          s       R
 dbmopen                dbmopen                 ck_fun          is      H S S
 dbmclose       dbmclose                ck_fun          is      H
 
@@ -435,6 +467,7 @@ leavewrite  write exit              ck_null         0
 prtf           printf                  ck_listiob      ims     F? L
 print          print                   ck_listiob      ims     F? L
 
+sysopen                sysopen                 ck_fun          s       F S S S?
 sysread                sysread                 ck_fun          imst    F R S S?
 syswrite       syswrite                ck_fun          imst    F S S S?
 
@@ -444,7 +477,7 @@ recv                recv                    ck_fun          imst    F R S S
 eof            eof                     ck_eof          is      F?
 tell           tell                    ck_fun          st      F?
 seek           seek                    ck_fun          s       F S S
-truncate       truncate                ck_trunc        is      S S
+truncate       truncate                ck_trunc        is      F S
 
 fcntl          fcntl                   ck_fun          st      F S S
 ioctl          ioctl                   ck_fun          st      F S S
@@ -551,7 +584,7 @@ sleep               sleep                   ck_fun          ist     S?
 shmget         shmget                  ck_fun          imst    S S S
 shmctl         shmctl                  ck_fun          imst    S S S
 shmread                shmread                 ck_fun          imst    S S S S
-shmwrite       shmwrite                ck_fun          ist     S S S S
+shmwrite       shmwrite                ck_fun          imst    S S S S
 
 # Message passing.