1N/A#!/usr/bin/perl -w
1N/A#
1N/A# Regenerate (overwriting only if changed):
1N/A#
1N/A# opcode.h
1N/A# opnames.h
1N/A# pp_proto.h
1N/A# pp.sym
1N/A#
1N/A# from information stored in the DATA section of this file, plus the
1N/A# values hardcoded into this script in @raw_alias.
1N/A#
1N/A# Accepts the standard regen_lib -q and -v args.
1N/A#
1N/A# This script is normally invoked from regen.pl.
1N/A
1N/Ause strict;
1N/A
1N/ABEGIN {
1N/A # Get function prototypes
1N/A require 'regen_lib.pl';
1N/A}
1N/A
1N/Amy $opcode_new = 'opcode.h-new';
1N/Amy $opname_new = 'opnames.h-new';
1N/Amy $oc = safer_open($opcode_new);
1N/Amy $on = safer_open($opname_new);
1N/Aselect $oc;
1N/A
1N/A# Read data.
1N/A
1N/Amy %seen;
1N/Amy (@ops, %desc, %check, %ckname, %flags, %args, %opnum);
1N/A
1N/Awhile (<DATA>) {
1N/A chop;
1N/A next unless $_;
1N/A next if /^#/;
1N/A my ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
1N/A $args = '' unless defined $args;
1N/A
1N/A warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
1N/A die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
1N/A $seen{$desc} = qq[description of opcode "$key"];
1N/A $seen{$key} = qq[opcode "$key"];
1N/A
1N/A push(@ops, $key);
1N/A $opnum{$key} = $#ops;
1N/A $desc{$key} = $desc;
1N/A $check{$key} = $check;
1N/A $ckname{$check}++;
1N/A $flags{$key} = $flags;
1N/A $args{$key} = $args;
1N/A}
1N/A
1N/A# Set up aliases
1N/A
1N/Amy %alias;
1N/A
1N/A# Format is "this function" => "does these op names"
1N/Amy @raw_alias = (
1N/A Perl_do_kv => [qw( keys values )],
1N/A Perl_unimplemented_op => [qw(padany mapstart custom)],
1N/A # All the ops with a body of { return NORMAL; }
1N/A Perl_pp_null => [qw(scalar regcmaybe lineseq scope)],
1N/A
1N/A Perl_pp_goto => ['dump'],
1N/A Perl_pp_require => ['dofile'],
1N/A Perl_pp_untie => ['dbmclose'],
1N/A Perl_pp_sysread => [qw(read recv)],
1N/A Perl_pp_sysseek => ['seek'],
1N/A Perl_pp_ioctl => ['fcntl'],
1N/A Perl_pp_ssockopt => ['gsockopt'],
1N/A Perl_pp_getpeername => ['getsockname'],
1N/A Perl_pp_stat => ['lstat'],
1N/A Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk
1N/A ftfile ftdir ftpipe ftsuid ftsgid
1N/A ftsvtx)],
1N/A Perl_pp_fttext => ['ftbinary'],
1N/A Perl_pp_gmtime => ['localtime'],
1N/A Perl_pp_semget => [qw(shmget msgget)],
1N/A Perl_pp_semctl => [qw(shmctl msgctl)],
1N/A Perl_pp_ghostent => [qw(ghbyname ghbyaddr)],
1N/A Perl_pp_gnetent => [qw(gnbyname gnbyaddr)],
1N/A Perl_pp_gprotoent => [qw(gpbyname gpbynumber)],
1N/A Perl_pp_gservent => [qw(gsbyname gsbyport)],
1N/A Perl_pp_gpwent => [qw(gpwnam gpwuid)],
1N/A Perl_pp_ggrent => [qw(ggrnam ggrgid)],
1N/A Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)],
1N/A Perl_pp_chown => [qw(unlink chmod utime kill)],
1N/A Perl_pp_link => ['symlink'],
1N/A Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite
1N/A fteexec)],
1N/A Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)],
1N/A Perl_pp_send => ['syswrite'],
1N/A Perl_pp_defined => [qw(dor dorassign)],
1N/A Perl_pp_and => ['andassign'],
1N/A Perl_pp_or => ['orassign'],
1N/A Perl_pp_ucfirst => ['lcfirst'],
1N/A Perl_pp_sle => [qw(slt sgt sge)],
1N/A Perl_pp_print => ['say'],
1N/A Perl_pp_index => ['rindex'],
1N/A Perl_pp_oct => ['hex'],
1N/A Perl_pp_shift => ['pop'],
1N/A Perl_pp_sin => [qw(cos exp log sqrt)],
1N/A Perl_pp_bit_or => ['bit_xor'],
1N/A Perl_pp_rv2av => ['rv2hv'],
1N/A Perl_pp_akeys => ['avalues'],
1N/A );
1N/A
1N/Awhile (my ($func, $names) = splice @raw_alias, 0, 2) {
1N/A $alias{$_} = $func for @$names;
1N/A}
1N/A
1N/A# Emit defines.
1N/A
1N/Aprint <<"END";
1N/A/* -*- buffer-read-only: t -*-
1N/A *
1N/A * opcode.h
1N/A *
1N/A * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
1N/A * 2001, 2002, 2003, 2004, 2005, 2006, 2007 by Larry Wall and others
1N/A *
1N/A * You may distribute under the terms of either the GNU General Public
1N/A * License or the Artistic License, as specified in the README file.
1N/A *
1N/A * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
1N/A * This file is built by opcode.pl from its data. Any changes made here
1N/A * will be lost!
1N/A */
1N/A
1N/A#ifndef PERL_GLOBAL_STRUCT_INIT
1N/A
1N/A#define Perl_pp_i_preinc Perl_pp_preinc
1N/A#define Perl_pp_i_predec Perl_pp_predec
1N/A#define Perl_pp_i_postinc Perl_pp_postinc
1N/A#define Perl_pp_i_postdec Perl_pp_postdec
1N/A
1N/APERL_PPDEF(Perl_unimplemented_op)
1N/A
1N/AEND
1N/A
1N/Aprint $on <<"END";
1N/A/* -*- buffer-read-only: t -*-
1N/A *
1N/A * opnames.h
1N/A *
1N/A * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
1N/A * 2007, 2008 by Larry Wall and others
1N/A *
1N/A * You may distribute under the terms of either the GNU General Public
1N/A * License or the Artistic License, as specified in the README file.
1N/A *
1N/A *
1N/A * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
1N/A * This file is built by opcode.pl from its data. Any changes made here
1N/A * will be lost!
1N/A */
1N/A
1N/Atypedef enum opcode {
1N/AEND
1N/A
1N/Amy $i = 0;
1N/Afor (@ops) {
1N/A # print $on "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
1N/A print $on "\t", &tab(3,"OP_\U$_"), " = ", $i++, ",\n";
1N/A}
1N/Aprint $on "\t", &tab(3,"OP_max"), "\n";
1N/Aprint $on "} opcode;\n";
1N/Aprint $on "\n#define MAXO ", scalar @ops, "\n";
1N/Aprint $on "#define OP_phoney_INPUT_ONLY -1\n";
1N/Aprint $on "#define OP_phoney_OUTPUT_ONLY -2\n\n";
1N/A
1N/A# Emit op names and descriptions.
1N/A
1N/Aprint <<END;
1N/ASTART_EXTERN_C
1N/A
1N/A#define OP_NAME(o) ((o)->op_type == OP_CUSTOM ? custom_op_name(o) : \\
1N/A PL_op_name[(o)->op_type])
1N/A#define OP_DESC(o) ((o)->op_type == OP_CUSTOM ? custom_op_desc(o) : \\
1N/A PL_op_desc[(o)->op_type])
1N/A
1N/A#ifndef DOINIT
1N/AEXTCONST char* const PL_op_name[];
1N/A#else
1N/AEXTCONST char* const PL_op_name[] = {
1N/AEND
1N/A
1N/Afor (@ops) {
1N/A print qq(\t"$_",\n);
1N/A}
1N/A
1N/Aprint <<END;
1N/A};
1N/A#endif
1N/A
1N/AEND
1N/A
1N/Aprint <<END;
1N/A#ifndef DOINIT
1N/AEXTCONST char* const PL_op_desc[];
1N/A#else
1N/AEXTCONST char* const PL_op_desc[] = {
1N/AEND
1N/A
1N/Afor (@ops) {
1N/A my($safe_desc) = $desc{$_};
1N/A
1N/A # Have to escape double quotes and escape characters.
1N/A $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g;
1N/A
1N/A print qq(\t"$safe_desc",\n);
1N/A}
1N/A
1N/Aprint <<END;
1N/A};
1N/A#endif
1N/A
1N/AEND_EXTERN_C
1N/A
1N/A#endif /* !PERL_GLOBAL_STRUCT_INIT */
1N/AEND
1N/A
1N/A# Emit function declarations.
1N/A
1N/A#for (sort keys %ckname) {
1N/A# print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
1N/A#}
1N/A#
1N/A#print "\n";
1N/A#
1N/A#for (@ops) {
1N/A# print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
1N/A#}
1N/A
1N/A# Emit ppcode switch array.
1N/A
1N/Aprint <<END;
1N/A
1N/ASTART_EXTERN_C
1N/A
1N/A#ifdef PERL_GLOBAL_STRUCT_INIT
1N/A# define PERL_PPADDR_INITED
1N/Astatic const Perl_ppaddr_t Gppaddr[]
1N/A#else
1N/A# ifndef PERL_GLOBAL_STRUCT
1N/A# define PERL_PPADDR_INITED
1N/AEXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */
1N/A# endif
1N/A#endif /* PERL_GLOBAL_STRUCT */
1N/A#if (defined(DOINIT) && !defined(PERL_GLOBAL_STRUCT)) || defined(PERL_GLOBAL_STRUCT_INIT)
1N/A# define PERL_PPADDR_INITED
1N/A= {
1N/AEND
1N/A
1N/Afor (@ops) {
1N/A if (my $name = $alias{$_}) {
1N/A print "\tMEMBER_TO_FPTR($name),\t/* Perl_pp_$_ */\n";
1N/A }
1N/A else {
1N/A print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n";
1N/A }
1N/A}
1N/A
1N/Aprint <<END;
1N/A}
1N/A#endif
1N/A#ifdef PERL_PPADDR_INITED
1N/A;
1N/A#endif
1N/A
1N/AEND
1N/A
1N/A# Emit check routines.
1N/A
1N/Aprint <<END;
1N/A#ifdef PERL_GLOBAL_STRUCT_INIT
1N/A# define PERL_CHECK_INITED
1N/Astatic const Perl_check_t Gcheck[]
1N/A#else
1N/A# ifndef PERL_GLOBAL_STRUCT
1N/A# define PERL_CHECK_INITED
1N/AEXT Perl_check_t PL_check[] /* or perlvars.h */
1N/A# endif
1N/A#endif
1N/A#if (defined(DOINIT) && !defined(PERL_GLOBAL_STRUCT)) || defined(PERL_GLOBAL_STRUCT_INIT)
1N/A# define PERL_CHECK_INITED
1N/A= {
1N/AEND
1N/A
1N/Afor (@ops) {
1N/A print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n";
1N/A}
1N/A
1N/Aprint <<END;
1N/A}
1N/A#endif
1N/A#ifdef PERL_CHECK_INITED
1N/A;
1N/A#endif /* #ifdef PERL_CHECK_INITED */
1N/A
1N/AEND
1N/A
1N/A# Emit allowed argument types.
1N/A
1N/Amy $ARGBITS = 32;
1N/A
1N/Aprint <<END;
1N/A#ifndef PERL_GLOBAL_STRUCT_INIT
1N/A
1N/A#ifndef DOINIT
1N/AEXTCONST U32 PL_opargs[];
1N/A#else
1N/AEXTCONST U32 PL_opargs[] = {
1N/AEND
1N/A
1N/Amy %argnum = (
1N/A 'S', 1, # scalar
1N/A 'L', 2, # list
1N/A 'A', 3, # array value
1N/A 'H', 4, # hash value
1N/A 'C', 5, # code value
1N/A 'F', 6, # file value
1N/A 'R', 7, # scalar reference
1N/A);
1N/A
1N/Amy %opclass = (
1N/A '0', 0, # baseop
1N/A '1', 1, # unop
1N/A '2', 2, # binop
1N/A '|', 3, # logop
1N/A '@', 4, # listop
1N/A '/', 5, # pmop
1N/A '$', 6, # svop_or_padop
1N/A '#', 7, # padop
1N/A '"', 8, # pvop_or_svop
1N/A '{', 9, # loop
1N/A ';', 10, # cop
1N/A '%', 11, # baseop_or_unop
1N/A '-', 12, # filestatop
1N/A '}', 13, # loopexop
1N/A);
1N/A
1N/Amy %opflags = (
1N/A 'm' => 1, # needs stack mark
1N/A 'f' => 2, # fold constants
1N/A 's' => 4, # always produces scalar
1N/A 't' => 8, # needs target scalar
1N/A 'T' => 8 | 256, # ... which may be lexical
1N/A 'i' => 16, # always produces integer
1N/A 'I' => 32, # has corresponding int op
1N/A 'd' => 64, # danger, unknown side effects
1N/A 'u' => 128, # defaults to $_
1N/A);
1N/A
1N/Amy %OP_IS_SOCKET;
1N/Amy %OP_IS_FILETEST;
1N/Amy %OP_IS_FT_ACCESS;
1N/Amy $OCSHIFT = 9;
1N/Amy $OASHIFT = 13;
1N/A
1N/Afor my $op (@ops) {
1N/A my $argsum = 0;
1N/A my $flags = $flags{$op};
1N/A for my $flag (keys %opflags) {
1N/A if ($flags =~ s/$flag//) {
1N/A die "Flag collision for '$op' ($flags{$op}, $flag)\n"
1N/A if $argsum & $opflags{$flag};
1N/A $argsum |= $opflags{$flag};
1N/A }
1N/A }
1N/A die qq[Opcode '$op' has no class indicator ($flags{$op} => $flags)\n]
1N/A unless exists $opclass{$flags};
1N/A $argsum |= $opclass{$flags} << $OCSHIFT;
1N/A my $argshift = $OASHIFT;
1N/A for my $arg (split(' ',$args{$op})) {
1N/A if ($arg =~ /^F/) {
1N/A # record opnums of these opnames
1N/A $OP_IS_SOCKET{$op} = $opnum{$op} if $arg =~ s/s//;
1N/A $OP_IS_FILETEST{$op} = $opnum{$op} if $arg =~ s/-//;
1N/A $OP_IS_FT_ACCESS{$op} = $opnum{$op} if $arg =~ s/\+//;
1N/A }
1N/A my $argnum = ($arg =~ s/\?//) ? 8 : 0;
1N/A die "op = $op, arg = $arg\n"
1N/A unless exists $argnum{$arg};
1N/A $argnum += $argnum{$arg};
1N/A die "Argument overflow for '$op'\n"
1N/A if $argshift >= $ARGBITS ||
1N/A $argnum > ((1 << ($ARGBITS - $argshift)) - 1);
1N/A $argsum += $argnum << $argshift;
1N/A $argshift += 4;
1N/A }
1N/A $argsum = sprintf("0x%08x", $argsum);
1N/A print "\t", &tab(3, "$argsum,"), "/* $op */\n";
1N/A}
1N/A
1N/Aprint <<END;
1N/A};
1N/A#endif
1N/A
1N/A#endif /* !PERL_GLOBAL_STRUCT_INIT */
1N/A
1N/AEND_EXTERN_C
1N/A
1N/AEND
1N/A
1N/A# Emit OP_IS_* macros
1N/A
1N/Aprint $on <<EO_OP_IS_COMMENT;
1N/A
1N/A/* the OP_IS_(SOCKET|FILETEST) macros are optimized to a simple range
1N/A check because all the member OPs are contiguous in opcode.pl
1N/A <DATA> table. opcode.pl verifies the range contiguity. */
1N/A
1N/AEO_OP_IS_COMMENT
1N/A
1N/Agen_op_is_macro( \%OP_IS_SOCKET, 'OP_IS_SOCKET');
1N/Agen_op_is_macro( \%OP_IS_FILETEST, 'OP_IS_FILETEST');
1N/Agen_op_is_macro( \%OP_IS_FT_ACCESS, 'OP_IS_FILETEST_ACCESS');
1N/A
1N/Asub gen_op_is_macro {
1N/A my ($op_is, $macname) = @_;
1N/A if (keys %$op_is) {
1N/A
1N/A # get opnames whose numbers are lowest and highest
1N/A my ($first, @rest) = sort {
1N/A $op_is->{$a} <=> $op_is->{$b}
1N/A } keys %$op_is;
1N/A
1N/A my $last = pop @rest; # @rest slurped, get its last
1N/A die "Invalid range of ops: $first .. $last\n" unless $last;
1N/A
1N/A print $on "#define $macname(op) \\\n\t(";
1N/A
1N/A # verify that op-ct matches 1st..last range (and fencepost)
1N/A # (we know there are no dups)
1N/A if ( $op_is->{$last} - $op_is->{$first} == scalar @rest + 1) {
1N/A
1N/A # contiguous ops -> optimized version
1N/A print $on "(op) >= OP_" . uc($first) . " && (op) <= OP_" . uc($last);
1N/A print $on ")\n\n";
1N/A }
1N/A else {
1N/A print $on join(" || \\\n\t ",
1N/A map { "(op) == OP_" . uc() } sort keys %$op_is);
1N/A print $on ")\n\n";
1N/A }
1N/A }
1N/A}
1N/A
1N/Aprint $oc "/* ex: set ro: */\n";
1N/Aprint $on "/* ex: set ro: */\n";
1N/A
1N/Asafer_close($oc);
1N/Asafer_close($on);
1N/A
1N/Arename_if_different $opcode_new, 'opcode.h';
1N/Arename_if_different $opname_new, 'opnames.h';
1N/A
1N/Amy $pp_proto_new = 'pp_proto.h-new';
1N/Amy $pp_sym_new = 'pp.sym-new';
1N/A
1N/Amy $pp = safer_open($pp_proto_new);
1N/Amy $ppsym = safer_open($pp_sym_new);
1N/A
1N/Aprint $pp <<"END";
1N/A/* -*- buffer-read-only: t -*-
1N/A !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
1N/A This file is built by opcode.pl from its data. Any changes made here
1N/A will be lost!
1N/A*/
1N/A
1N/AEND
1N/A
1N/Aprint $ppsym <<"END";
1N/A# -*- buffer-read-only: t -*-
1N/A#
1N/A# !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
1N/A# This file is built by opcode.pl from its data. Any changes made here
1N/A# will be lost!
1N/A#
1N/A
1N/AEND
1N/A
1N/A
1N/Afor (sort keys %ckname) {
1N/A print $pp "PERL_CKDEF(Perl_$_)\n";
1N/A print $ppsym "Perl_$_\n";
1N/A#OP *\t", &tab(3,$_),"(OP* o);\n";
1N/A}
1N/A
1N/Aprint $pp "\n\n";
1N/A
1N/Afor (@ops) {
1N/A next if /^i_(pre|post)(inc|dec)$/;
1N/A next if /^custom$/;
1N/A print $pp "PERL_PPDEF(Perl_pp_$_)\n";
1N/A print $ppsym "Perl_pp_$_\n";
1N/A}
1N/Aprint $pp "\n/* ex: set ro: */\n";
1N/Aprint $ppsym "\n# ex: set ro:\n";
1N/A
1N/Asafer_close($pp);
1N/Asafer_close($ppsym);
1N/A
1N/Arename_if_different $pp_proto_new, 'pp_proto.h';
1N/Arename_if_different $pp_sym_new, 'pp.sym';
1N/A
1N/AEND {
1N/A foreach ('opcode.h', 'opnames.h', 'pp_proto.h', 'pp.sym') {
1N/A 1 while unlink "$_-old";
1N/A }
1N/A}
1N/A
1N/A###########################################################################
1N/Asub tab {
1N/A my ($l, $t) = @_;
1N/A $t .= "\t" x ($l - (length($t) + 1) / 8);
1N/A $t;
1N/A}
1N/A###########################################################################
1N/A
1N/A# Some comments about 'T' opcode classifier:
1N/A
1N/A# Safe to set if the ppcode uses:
1N/A# tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
1N/A# SETs(TARG), XPUSHn, XPUSHu,
1N/A
1N/A# Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
1N/A
1N/A# lt and friends do SETs (including ncmp, but not scmp)
1N/A
1N/A# Additional mode of failure: the opcode can modify TARG before it "used"
1N/A# all the arguments (or may call an external function which does the same).
1N/A# If the target coincides with one of the arguments ==> kaboom.
1N/A
1N/A# pp.c pos substr each not OK (RETPUSHUNDEF)
1N/A# substr vec also not OK due to LV to target (are they???)
1N/A# ref not OK (RETPUSHNO)
1N/A# trans not OK (dTARG; TARG = sv_newmortal();)
1N/A# ucfirst etc not OK: TMP arg processed inplace
1N/A# quotemeta not OK (unsafe when TARG == arg)
1N/A# each repeat not OK too due to list context
1N/A# pack split - unknown whether they are safe
1N/A# sprintf: is calling do_sprintf(TARG,...) which can act on TARG
1N/A# before other args are processed.
1N/A
1N/A# Suspicious wrt "additional mode of failure" (and only it):
1N/A# schop, chop, postinc/dec, bit_and etc, negate, complement.
1N/A
1N/A# Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack.
1N/A
1N/A# substr/vec: doing TAINT_off()???
1N/A
1N/A# pp_hot.c
1N/A# readline - unknown whether it is safe
1N/A# match subst not OK (dTARG)
1N/A# grepwhile not OK (not always setting)
1N/A# join not OK (unsafe when TARG == arg)
1N/A
1N/A# Suspicious wrt "additional mode of failure": concat (dealt with
1N/A# in ck_sassign()), join (same).
1N/A
1N/A# pp_ctl.c
1N/A# mapwhile flip caller not OK (not always setting)
1N/A
1N/A# pp_sys.c
1N/A# backtick glob warn die not OK (not always setting)
1N/A# warn not OK (RETPUSHYES)
1N/A# open fileno getc sysread syswrite ioctl accept shutdown
1N/A# ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
1N/A# umask select not OK (XPUSHs(&PL_sv_undef);)
1N/A# fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
1N/A# sselect shm* sem* msg* syscall - unknown whether they are safe
1N/A# gmtime not OK (list context)
1N/A
1N/A# Suspicious wrt "additional mode of failure": warn, die, select.
1N/A
1N/A__END__
1N/A
1N/A# New ops always go at the end
1N/A# The restriction on having custom as the last op has been removed
1N/A
1N/A# A recapitulation of the format of this file:
1N/A# The file consists of five columns: the name of the op, an English
1N/A# description, the name of the "check" routine used to optimize this
1N/A# operation, some flags, and a description of the operands.
1N/A
1N/A# The flags consist of options followed by a mandatory op class signifier
1N/A
1N/A# The classes are:
1N/A# baseop - 0 unop - 1 binop - 2
1N/A# logop - | listop - @ pmop - /
1N/A# padop/svop - $ padop - # (unused) loop - {
1N/A# baseop/unop - % loopexop - } filestatop - -
1N/A# pvop/svop - " cop - ;
1N/A
1N/A# Other options are:
1N/A# needs stack mark - m
1N/A# needs constant folding - f
1N/A# produces a scalar - s
1N/A# produces an integer - i
1N/A# needs a target - t
1N/A# target can be in a pad - T
1N/A# has a corresponding integer version - I
1N/A# has side effects - d
1N/A# uses $_ if no argument given - u
1N/A
1N/A# Values for the operands are:
1N/A# scalar - S list - L array - A
1N/A# hash - H sub (CV) - C file - F
1N/A# socket - Fs filetest - F- filetest_access - F-+
1N/A
1N/A# reference - R
1N/A# "?" denotes an optional operand.
1N/A
1N/A# Nothing.
1N/A
1N/Anull null operation ck_null 0
1N/Astub stub ck_null 0
1N/Ascalar scalar ck_fun s% S
1N/A
1N/A# Pushy stuff.
1N/A
1N/Apushmark pushmark ck_null s0
1N/Awantarray wantarray ck_null is0
1N/A
1N/Aconst constant item ck_svconst s$
1N/A
1N/Agvsv scalar variable ck_null ds$
1N/Agv glob value ck_null ds$
1N/Agelem glob elem ck_null d2 S S
1N/Apadsv private variable ck_null ds0
1N/Apadav private array ck_null d0
1N/Apadhv private hash ck_null d0
1N/Apadany private value ck_null d0
1N/A
1N/Apushre push regexp ck_null d/
1N/A
1N/A# References and stuff.
1N/A
1N/Arv2gv ref-to-glob cast ck_rvconst ds1
1N/Arv2sv scalar dereference ck_rvconst ds1
1N/Aav2arylen array length ck_null is1
1N/Arv2cv subroutine dereference ck_rvconst d1
1N/Aanoncode anonymous subroutine ck_anoncode $
1N/Aprototype subroutine prototype ck_null s% S
1N/Arefgen reference constructor ck_spair m1 L
1N/Asrefgen single ref constructor ck_null fs1 S
1N/Aref reference-type operator ck_fun stu% S?
1N/Abless bless ck_fun s@ S S?
1N/A
1N/A# Pushy I/O.
1N/A
1N/Abacktick quoted execution (``, qx) ck_open tu% S?
1N/A# glob defaults its first arg to $_
1N/Aglob glob ck_glob t@ S?
1N/Areadline <HANDLE> ck_readline t% F?
1N/Arcatline append I/O operator ck_null t$
1N/A
1N/A# Bindable operators.
1N/A
1N/Aregcmaybe regexp internal guard ck_fun s1 S
1N/Aregcreset regexp internal reset ck_fun s1 S
1N/Aregcomp regexp compilation ck_null s| S
1N/Amatch pattern match (m//) ck_match d/
1N/Aqr pattern quote (qr//) ck_match s/
1N/Asubst substitution (s///) ck_match dis/ S
1N/Asubstcont substitution iterator ck_null dis|
1N/Atrans transliteration (tr///) ck_match is" S
1N/A
1N/A# Lvalue operators.
1N/A# sassign is special-cased for op class
1N/A
1N/Asassign scalar assignment ck_sassign s0
1N/Aaassign list assignment ck_null t2 L L
1N/A
1N/Achop chop ck_spair mts% L
1N/Aschop scalar chop ck_null stu% S?
1N/Achomp chomp ck_spair mTs% L
1N/Aschomp scalar chomp ck_null sTu% S?
1N/Adefined defined operator ck_defined isu% S?
1N/Aundef undef operator ck_lfun s% S?
1N/Astudy study ck_fun su% S?
1N/Apos match position ck_lfun stu% S?
1N/A
1N/Apreinc preincrement (++) ck_lfun dIs1 S
1N/Ai_preinc integer preincrement (++) ck_lfun dis1 S
1N/Apredec predecrement (--) ck_lfun dIs1 S
1N/Ai_predec integer predecrement (--) ck_lfun dis1 S
1N/Apostinc postincrement (++) ck_lfun dIst1 S
1N/Ai_postinc integer postincrement (++) ck_lfun disT1 S
1N/Apostdec postdecrement (--) ck_lfun dIst1 S
1N/Ai_postdec integer postdecrement (--) ck_lfun disT1 S
1N/A
1N/A# Ordinary operators.
1N/A
1N/Apow exponentiation (**) ck_null fsT2 S S
1N/A
1N/Amultiply multiplication (*) ck_null IfsT2 S S
1N/Ai_multiply integer multiplication (*) ck_null ifsT2 S S
1N/Adivide division (/) ck_null IfsT2 S S
1N/Ai_divide integer division (/) ck_null ifsT2 S S
1N/Amodulo modulus (%) ck_null IifsT2 S S
1N/Ai_modulo integer modulus (%) ck_null ifsT2 S S
1N/Arepeat repeat (x) ck_repeat mt2 L S
1N/A
1N/Aadd addition (+) ck_null IfsT2 S S
1N/Ai_add integer addition (+) ck_null ifsT2 S S
1N/Asubtract subtraction (-) ck_null IfsT2 S S
1N/Ai_subtract integer subtraction (-) ck_null ifsT2 S S
1N/Aconcat concatenation (.) or string ck_concat fsT2 S S
1N/Astringify string ck_fun fsT@ S
1N/A
1N/Aleft_shift left bitshift (<<) ck_bitop fsT2 S S
1N/Aright_shift right bitshift (>>) ck_bitop fsT2 S S
1N/A
1N/Alt numeric lt (<) ck_null Iifs2 S S
1N/Ai_lt integer lt (<) ck_null ifs2 S S
1N/Agt numeric gt (>) ck_null Iifs2 S S
1N/Ai_gt integer gt (>) ck_null ifs2 S S
1N/Ale numeric le (<=) ck_null Iifs2 S S
1N/Ai_le integer le (<=) ck_null ifs2 S S
1N/Age numeric ge (>=) ck_null Iifs2 S S
1N/Ai_ge integer ge (>=) ck_null ifs2 S S
1N/Aeq numeric eq (==) ck_null Iifs2 S S
1N/Ai_eq integer eq (==) ck_null ifs2 S S
1N/Ane numeric ne (!=) ck_null Iifs2 S S
1N/Ai_ne integer ne (!=) ck_null ifs2 S S
1N/Ancmp numeric comparison (<=>) ck_null Iifst2 S S
1N/Ai_ncmp integer comparison (<=>) ck_null ifst2 S S
1N/A
1N/Aslt string lt ck_null ifs2 S S
1N/Asgt string gt ck_null ifs2 S S
1N/Asle string le ck_null ifs2 S S
1N/Asge string ge ck_null ifs2 S S
1N/Aseq string eq ck_null ifs2 S S
1N/Asne string ne ck_null ifs2 S S
1N/Ascmp string comparison (cmp) ck_null ifst2 S S
1N/A
1N/Abit_and bitwise and (&) ck_bitop fst2 S S
1N/Abit_xor bitwise xor (^) ck_bitop fst2 S S
1N/Abit_or bitwise or (|) ck_bitop fst2 S S
1N/A
1N/Anegate negation (-) ck_null Ifst1 S
1N/Ai_negate integer negation (-) ck_null ifsT1 S
1N/Anot not ck_null ifs1 S
1N/Acomplement 1's complement (~) ck_bitop fst1 S
1N/A
1N/Asmartmatch smart match ck_smartmatch s2
1N/A
1N/A# High falutin' math.
1N/A
1N/Aatan2 atan2 ck_fun fsT@ S S
1N/Asin sin ck_fun fsTu% S?
1N/Acos cos ck_fun fsTu% S?
1N/Arand rand ck_fun sT% S?
1N/Asrand srand ck_fun s% S?
1N/Aexp exp ck_fun fsTu% S?
1N/Alog log ck_fun fsTu% S?
1N/Asqrt sqrt ck_fun fsTu% S?
1N/A
1N/A# Lowbrow math.
1N/A
1N/Aint int ck_fun fsTu% S?
1N/Ahex hex ck_fun fsTu% S?
1N/Aoct oct ck_fun fsTu% S?
1N/Aabs abs ck_fun fsTu% S?
1N/A
1N/A# String stuff.
1N/A
1N/Alength length ck_fun ifsTu% S?
1N/Asubstr substr ck_substr st@ S S S? S?
1N/Avec vec ck_fun ist@ S S S
1N/A
1N/Aindex index ck_index isT@ S S S?
1N/Arindex rindex ck_index isT@ S S S?
1N/A
1N/Asprintf sprintf ck_fun fmst@ S L
1N/Aformline formline ck_fun ms@ S L
1N/Aord ord ck_fun ifsTu% S?
1N/Achr chr ck_fun fsTu% S?
1N/Acrypt crypt ck_fun fsT@ S S
1N/Aucfirst ucfirst ck_fun fstu% S?
1N/Alcfirst lcfirst ck_fun fstu% S?
1N/Auc uc ck_fun fstu% S?
1N/Alc lc ck_fun fstu% S?
1N/Aquotemeta quotemeta ck_fun fstu% S?
1N/A
1N/A# Arrays.
1N/A
1N/Arv2av array dereference ck_rvconst dt1
1N/Aaelemfast constant array element ck_null s$ A S
1N/Aaelem array element ck_null s2 A S
1N/Aaslice array slice ck_null m@ A L
1N/A
1N/Aaeach each on array ck_each % A
1N/Aakeys keys on array ck_each t% A
1N/Aavalues values on array ck_each t% A
1N/A
1N/A# Hashes.
1N/A
1N/Aeach each ck_each % H
1N/Avalues values ck_each t% H
1N/Akeys keys ck_each t% H
1N/Adelete delete ck_delete % S
1N/Aexists exists ck_exists is% S
1N/Arv2hv hash dereference ck_rvconst dt1
1N/Ahelem hash element ck_null s2 H S
1N/Ahslice hash slice ck_null m@ H L
1N/Aboolkeys boolkeys ck_fun % H
1N/A
1N/A# Explosives and implosives.
1N/A
1N/Aunpack unpack ck_unpack @ S S?
1N/Apack pack ck_fun mst@ S L
1N/Asplit split ck_split t@ S S S
1N/Ajoin join or string ck_join mst@ S L
1N/A
1N/A# List operators.
1N/A
1N/Alist list ck_null m@ L
1N/Alslice list slice ck_null 2 H L L
1N/Aanonlist anonymous list ([]) ck_fun ms@ L
1N/Aanonhash anonymous hash ({}) ck_fun ms@ L
1N/A
1N/Asplice splice ck_fun m@ A S? S? L
1N/Apush push ck_fun imsT@ A L
1N/Apop pop ck_shift s% A?
1N/Ashift shift ck_shift s% A?
1N/Aunshift unshift ck_fun imsT@ A L
1N/Asort sort ck_sort dm@ C? L
1N/Areverse reverse ck_fun mt@ L
1N/A
1N/Agrepstart grep ck_grep dm@ C L
1N/Agrepwhile grep iterator ck_null dt|
1N/A
1N/Amapstart map ck_grep dm@ C L
1N/Amapwhile map iterator ck_null dt|
1N/A
1N/A# Range stuff.
1N/A
1N/Arange flipflop ck_null | S S
1N/Aflip range (or flip) ck_null 1 S S
1N/Aflop range (or flop) ck_null 1
1N/A
1N/A# Control.
1N/A
1N/Aand logical and (&&) ck_null |
1N/Aor logical or (||) ck_null |
1N/Axor logical xor ck_null fs2 S S
1N/Ador defined or (//) ck_null |
1N/Acond_expr conditional expression ck_null d|
1N/Aandassign logical and assignment (&&=) ck_null s|
1N/Aorassign logical or assignment (||=) ck_null s|
1N/Adorassign defined or assignment (//=) ck_null s|
1N/A
1N/Amethod method lookup ck_method d1
1N/Aentersub subroutine entry ck_subr dmt1 L
1N/Aleavesub subroutine exit ck_null 1
1N/Aleavesublv lvalue subroutine return ck_null 1
1N/Acaller caller ck_fun t% S?
1N/Awarn warn ck_fun imst@ L
1N/Adie die ck_die dimst@ L
1N/Areset symbol reset ck_fun is% S?
1N/A
1N/Alineseq line sequence ck_null @
1N/Anextstate next statement ck_null s;
1N/Adbstate debug next statement ck_null s;
1N/Aunstack iteration finalizer ck_null s0
1N/Aenter block entry ck_null 0
1N/Aleave block exit ck_null @
1N/Ascope block ck_null @
1N/Aenteriter foreach loop entry ck_null d{
1N/Aiter foreach loop iterator ck_null 0
1N/Aenterloop loop entry ck_null d{
1N/Aleaveloop loop exit ck_null 2
1N/Areturn return ck_return dm@ L
1N/Alast last ck_null ds}
1N/Anext next ck_null ds}
1N/Aredo redo ck_null ds}
1N/Adump dump ck_null ds}
1N/Agoto goto ck_null ds}
1N/Aexit exit ck_exit ds% S?
1N/Amethod_named method with known name ck_null d$
1N/A
1N/Aentergiven given() ck_null d|
1N/Aleavegiven leave given block ck_null 1
1N/Aenterwhen when() ck_null d|
1N/Aleavewhen leave when block ck_null 1
1N/Abreak break ck_null 0
1N/Acontinue continue ck_null 0
1N/A
1N/A# I/O.
1N/A
1N/Aopen open ck_open ismt@ F S? L
1N/Aclose close ck_fun is% F?
1N/Apipe_op pipe ck_fun is@ F F
1N/A
1N/Afileno fileno ck_fun ist% F
1N/Aumask umask ck_fun ist% S?
1N/Abinmode binmode ck_fun s@ F S?
1N/A
1N/Atie tie ck_fun idms@ R S L
1N/Auntie untie ck_fun is% R
1N/Atied tied ck_fun s% R
1N/Adbmopen dbmopen ck_fun is@ H S S
1N/Adbmclose dbmclose ck_fun is% H
1N/A
1N/Asselect select system call ck_select t@ S S S S
1N/Aselect select ck_select st@ F?
1N/A
1N/Agetc getc ck_eof st% F?
1N/Aread read ck_fun imst@ F R S S?
1N/Aenterwrite write ck_fun dis% F?
1N/Aleavewrite write exit ck_null 1
1N/A
1N/Aprtf printf ck_listiob ims@ F? L
1N/Aprint print ck_listiob ims@ F? L
1N/Asay say ck_listiob ims@ F? L
1N/A
1N/Asysopen sysopen ck_fun s@ F S S S?
1N/Asysseek sysseek ck_fun s@ F S S
1N/Asysread sysread ck_fun imst@ F R S S?
1N/Asyswrite syswrite ck_fun imst@ F S S? S?
1N/A
1N/Aeof eof ck_eof is% F?
1N/Atell tell ck_fun st% F?
1N/Aseek seek ck_fun s@ F S S
1N/A# truncate really behaves as if it had both "S S" and "F S"
1N/Atruncate truncate ck_trunc is@ S S
1N/A
1N/Afcntl fcntl ck_fun st@ F S S
1N/Aioctl ioctl ck_fun st@ F S S
1N/Aflock flock ck_fun isT@ F S
1N/A
1N/A# Sockets. OP_IS_SOCKET wants them consecutive (so moved 1st 2)
1N/A
1N/Asend send ck_fun imst@ Fs S S S?
1N/Arecv recv ck_fun imst@ Fs R S S
1N/A
1N/Asocket socket ck_fun is@ Fs S S S
1N/Asockpair socketpair ck_fun is@ Fs Fs S S S
1N/A
1N/Abind bind ck_fun is@ Fs S
1N/Aconnect connect ck_fun is@ Fs S
1N/Alisten listen ck_fun is@ Fs S
1N/Aaccept accept ck_fun ist@ Fs Fs
1N/Ashutdown shutdown ck_fun ist@ Fs S
1N/A
1N/Agsockopt getsockopt ck_fun is@ Fs S S
1N/Assockopt setsockopt ck_fun is@ Fs S S S
1N/A
1N/Agetsockname getsockname ck_fun is% Fs
1N/Agetpeername getpeername ck_fun is% Fs
1N/A
1N/A# Stat calls. OP_IS_FILETEST wants them consecutive.
1N/A
1N/Alstat lstat ck_ftst u- F
1N/Astat stat ck_ftst u- F
1N/Aftrread -R ck_ftst isu- F-+
1N/Aftrwrite -W ck_ftst isu- F-+
1N/Aftrexec -X ck_ftst isu- F-+
1N/Afteread -r ck_ftst isu- F-+
1N/Aftewrite -w ck_ftst isu- F-+
1N/Afteexec -x ck_ftst isu- F-+
1N/Aftis -e ck_ftst isu- F-
1N/Aftsize -s ck_ftst istu- F-
1N/Aftmtime -M ck_ftst stu- F-
1N/Aftatime -A ck_ftst stu- F-
1N/Aftctime -C ck_ftst stu- F-
1N/Aftrowned -O ck_ftst isu- F-
1N/Afteowned -o ck_ftst isu- F-
1N/Aftzero -z ck_ftst isu- F-
1N/Aftsock -S ck_ftst isu- F-
1N/Aftchr -c ck_ftst isu- F-
1N/Aftblk -b ck_ftst isu- F-
1N/Aftfile -f ck_ftst isu- F-
1N/Aftdir -d ck_ftst isu- F-
1N/Aftpipe -p ck_ftst isu- F-
1N/Aftsuid -u ck_ftst isu- F-
1N/Aftsgid -g ck_ftst isu- F-
1N/Aftsvtx -k ck_ftst isu- F-
1N/Aftlink -l ck_ftst isu- F-
1N/Afttty -t ck_ftst is- F-
1N/Afttext -T ck_ftst isu- F-
1N/Aftbinary -B ck_ftst isu- F-
1N/A
1N/A# File calls.
1N/A
1N/A# chdir really behaves as if it had both "S?" and "F?"
1N/Achdir chdir ck_chdir isT% S?
1N/Achown chown ck_fun imsT@ L
1N/Achroot chroot ck_fun isTu% S?
1N/Aunlink unlink ck_fun imsTu@ L
1N/Achmod chmod ck_fun imsT@ L
1N/Autime utime ck_fun imsT@ L
1N/Arename rename ck_fun isT@ S S
1N/Alink link ck_fun isT@ S S
1N/Asymlink symlink ck_fun isT@ S S
1N/Areadlink readlink ck_fun stu% S?
1N/Amkdir mkdir ck_fun isTu@ S? S?
1N/Armdir rmdir ck_fun isTu% S?
1N/A
1N/A# Directory calls.
1N/A
1N/Aopen_dir opendir ck_fun is@ F S
1N/Areaddir readdir ck_fun % F
1N/Atelldir telldir ck_fun st% F
1N/Aseekdir seekdir ck_fun s@ F S
1N/Arewinddir rewinddir ck_fun s% F
1N/Aclosedir closedir ck_fun is% F
1N/A
1N/A# Process control.
1N/A
1N/Afork fork ck_null ist0
1N/Await wait ck_null isT0
1N/Awaitpid waitpid ck_fun isT@ S S
1N/Asystem system ck_exec imsT@ S? L
1N/Aexec exec ck_exec dimsT@ S? L
1N/Akill kill ck_fun dimsT@ L
1N/Agetppid getppid ck_null isT0
1N/Agetpgrp getpgrp ck_fun isT% S?
1N/Asetpgrp setpgrp ck_fun isT@ S? S?
1N/Agetpriority getpriority ck_fun isT@ S S
1N/Asetpriority setpriority ck_fun isT@ S S S
1N/A
1N/A# Time calls.
1N/A
1N/A# NOTE: MacOS patches the 'i' of time() away later when the interpreter
1N/A# is created because in MacOS time() is already returning times > 2**31-1,
1N/A# that is, non-integers.
1N/A
1N/Atime time ck_null isT0
1N/Atms times ck_null 0
1N/Alocaltime localtime ck_fun t% S?
1N/Agmtime gmtime ck_fun t% S?
1N/Aalarm alarm ck_fun istu% S?
1N/Asleep sleep ck_fun isT% S?
1N/A
1N/A# Shared memory.
1N/A
1N/Ashmget shmget ck_fun imst@ S S S
1N/Ashmctl shmctl ck_fun imst@ S S S
1N/Ashmread shmread ck_fun imst@ S S S S
1N/Ashmwrite shmwrite ck_fun imst@ S S S S
1N/A
1N/A# Message passing.
1N/A
1N/Amsgget msgget ck_fun imst@ S S
1N/Amsgctl msgctl ck_fun imst@ S S S
1N/Amsgsnd msgsnd ck_fun imst@ S S S
1N/Amsgrcv msgrcv ck_fun imst@ S S S S S
1N/A
1N/A# Semaphores.
1N/A
1N/Asemop semop ck_fun imst@ S S
1N/Asemget semget ck_fun imst@ S S S
1N/Asemctl semctl ck_fun imst@ S S S S
1N/A
1N/A# Eval.
1N/A
1N/Arequire require ck_require du% S?
1N/Adofile do "file" ck_fun d1 S
1N/Ahintseval eval hints ck_svconst s$
1N/Aentereval eval "string" ck_eval d% S
1N/Aleaveeval eval "string" exit ck_null 1 S
1N/A#evalonce eval constant string ck_null d1 S
1N/Aentertry eval {block} ck_eval d%
1N/Aleavetry eval {block} exit ck_null @
1N/A
1N/A# Get system info.
1N/A
1N/Aghbyname gethostbyname ck_fun % S
1N/Aghbyaddr gethostbyaddr ck_fun @ S S
1N/Aghostent gethostent ck_null 0
1N/Agnbyname getnetbyname ck_fun % S
1N/Agnbyaddr getnetbyaddr ck_fun @ S S
1N/Agnetent getnetent ck_null 0
1N/Agpbyname getprotobyname ck_fun % S
1N/Agpbynumber getprotobynumber ck_fun @ S
1N/Agprotoent getprotoent ck_null 0
1N/Agsbyname getservbyname ck_fun @ S S
1N/Agsbyport getservbyport ck_fun @ S S
1N/Agservent getservent ck_null 0
1N/Ashostent sethostent ck_fun is% S
1N/Asnetent setnetent ck_fun is% S
1N/Asprotoent setprotoent ck_fun is% S
1N/Asservent setservent ck_fun is% S
1N/Aehostent endhostent ck_null is0
1N/Aenetent endnetent ck_null is0
1N/Aeprotoent endprotoent ck_null is0
1N/Aeservent endservent ck_null is0
1N/Agpwnam getpwnam ck_fun % S
1N/Agpwuid getpwuid ck_fun % S
1N/Agpwent getpwent ck_null 0
1N/Aspwent setpwent ck_null is0
1N/Aepwent endpwent ck_null is0
1N/Aggrnam getgrnam ck_fun % S
1N/Aggrgid getgrgid ck_fun % S
1N/Aggrent getgrent ck_null 0
1N/Asgrent setgrent ck_null is0
1N/Aegrent endgrent ck_null is0
1N/Agetlogin getlogin ck_null st0
1N/A
1N/A# Miscellaneous.
1N/A
1N/Asyscall syscall ck_fun imst@ S L
1N/A
1N/A# For multi-threading
1N/Alock lock ck_rfun s% R
1N/A
1N/A# For state support
1N/A
1N/Aonce once ck_null |
1N/A
1N/Acustom unknown custom operator ck_null 0