X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=opcode.pl;h=1c8245c92c61d58413e39185a55f8e688cc5fe9e;hb=e40b81a3dd247b1a29fc78399677b77b78b5f183;hp=b2bcf90e2823229d88b27feec8575fa400cd5cfc;hpb=cfc85103a5b0d727dc80c47d60e05c15a3ee03e8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/opcode.pl b/opcode.pl index b2bcf90..1c8245c 100755 --- a/opcode.pl +++ b/opcode.pl @@ -1,11 +1,13 @@ -#!/usr/bin/perl +#!/usr/bin/perl -w +use strict; + BEGIN { # Get function prototypes require 'regen_lib.pl'; } -$opcode_new = 'opcode.h-new'; -$opname_new = 'opnames.h-new'; +my $opcode_new = 'opcode.h-new'; +my $opname_new = 'opnames.h-new'; open(OC, ">$opcode_new") || die "Can't create $opcode_new: $!\n"; binmode OC; open(ON, ">$opname_new") || die "Can't create $opname_new: $!\n"; @@ -14,11 +16,15 @@ select OC; # Read data. +my %seen; +my (@ops, %desc, %check, %ckname, %flags, %args); + while () { chop; next unless $_; next if /^#/; - ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5); + my ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5); + $args = '' unless defined $args; warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc}; die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key}; @@ -40,7 +46,7 @@ my %alias; # Format is "this function" => "does these op names" my @raw_alias = ( Perl_do_kv => [qw( keys values )], - Perl_unimplemented_op => [qw(padany threadsv mapstart)], + Perl_unimplemented_op => [qw(padany mapstart)], # All the ops with a body of { return NORMAL; } Perl_pp_null => [qw(scalar regcmaybe lineseq scope)], @@ -79,6 +85,12 @@ my @raw_alias = ( Perl_pp_ucfirst => ['lcfirst'], Perl_pp_sle => [qw(slt sgt sge)], Perl_pp_print => ['say'], + Perl_pp_index => ['rindex'], + Perl_pp_oct => ['hex'], + Perl_pp_shift => ['pop'], + Perl_pp_sin => [qw(cos exp log sqrt)], + Perl_pp_bit_or => ['bit_xor'], + Perl_pp_rv2av => ['rv2hv'], ); while (my ($func, $names) = splice @raw_alias, 0, 2) { @@ -87,14 +99,13 @@ while (my ($func, $names) = splice @raw_alias, 0, 2) { # Emit defines. -$i = 0; print <<"END"; /* -*- buffer-read-only: t -*- * * opcode.h * - * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, 2005, 2006 by Larry Wall and others + * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + * 2001, 2002, 2003, 2004, 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. @@ -121,7 +132,7 @@ print ON <<"END"; * opnames.h * * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - * by Larry Wall and others + * 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. @@ -135,6 +146,7 @@ print ON <<"END"; typedef enum opcode { END +my $i = 0; for (@ops) { print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n"; } @@ -282,22 +294,22 @@ print <$pp_proto_new" or die "Error creating $pp_proto_new: $!"; binmode PP; @@ -446,7 +458,7 @@ END { ########################################################################### sub tab { - local($l, $t) = @_; + my ($l, $t) = @_; $t .= "\t" x ($l - (length($t) + 1) / 8); $t; } @@ -581,7 +593,7 @@ bless bless ck_fun s@ S S? # Pushy I/O. -backtick quoted execution (``, qx) ck_open t% +backtick quoted execution (``, qx) ck_open t% S # glob defaults its first arg to $_ glob glob ck_glob t@ S? readline ck_null t% F? @@ -880,30 +892,31 @@ fteread -r ck_ftst isu- F- ftewrite -w ck_ftst isu- F- fteexec -x ck_ftst isu- F- ftis -e ck_ftst isu- F- -fteowned -o ck_ftst isu- F- -ftrowned -O ck_ftst isu- F- -ftzero -z ck_ftst isu- F- ftsize -s ck_ftst istu- F- ftmtime -M ck_ftst stu- F- ftatime -A ck_ftst stu- F- ftctime -C ck_ftst stu- F- +ftrowned -O ck_ftst isu- F- +fteowned -o ck_ftst isu- F- +ftzero -z ck_ftst isu- F- ftsock -S ck_ftst isu- F- ftchr -c ck_ftst isu- F- ftblk -b ck_ftst isu- F- ftfile -f ck_ftst isu- F- ftdir -d ck_ftst isu- F- ftpipe -p ck_ftst isu- F- -ftlink -l ck_ftst isu- F- ftsuid -u ck_ftst isu- F- ftsgid -g ck_ftst isu- F- ftsvtx -k ck_ftst isu- F- +ftlink -l ck_ftst isu- F- fttty -t ck_ftst is- F- fttext -T ck_ftst isu- F- ftbinary -B ck_ftst isu- F- # File calls. -chdir chdir ck_fun isT% S? +# chdir really behaves as if it had both "S?" and "F?" +chdir chdir ck_chdir isT% S? chown chown ck_fun imsT@ L chroot chroot ck_fun isTu% S? unlink unlink ck_fun imsTu@ L @@ -968,9 +981,9 @@ msgrcv msgrcv ck_fun imst@ S S S S S # Semaphores. +semop semop ck_fun imst@ S S semget semget ck_fun imst@ S S S semctl semctl ck_fun imst@ S S S S -semop semop ck_fun imst@ S S # Eval. @@ -1022,7 +1035,6 @@ syscall syscall ck_fun imst@ S L # For multi-threading lock lock ck_rfun s% R -threadsv per-thread value ck_null ds0 # Control (contd.) setstate set statement info ck_null s; @@ -1039,7 +1051,7 @@ break break ck_null 0 continue continue ck_null 0 smartmatch smart match ck_smartmatch s2 -say say ck_say ims@ F? L +say say ck_listiob ims@ F? L # Add new ops before this, the custom operator.