This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
[perl5.git] / opcode.pl
1 #!/usr/bin/perl
2 BEGIN {
3     # Get function prototypes
4     require 'regen_lib.pl';
5 }
6
7 $opcode_new = 'opcode.h-new';
8 $opname_new = 'opnames.h-new';
9 open(OC, ">$opcode_new") || die "Can't create $opcode_new: $!\n";
10 binmode OC;
11 open(ON, ">$opname_new") || die "Can't create $opname_new: $!\n";
12 binmode ON;
13 select OC;
14
15 # Read data.
16
17 while (<DATA>) {
18     chop;
19     next unless $_;
20     next if /^#/;
21     ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
22
23     warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
24     die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
25     $seen{$desc} = qq[description of opcode "$key"];
26     $seen{$key} = qq[opcode "$key"];
27
28     push(@ops, $key);
29     $desc{$key} = $desc;
30     $check{$key} = $check;
31     $ckname{$check}++;
32     $flags{$key} = $flags;
33     $args{$key} = $args;
34 }
35
36 # Set up aliases
37
38 my %alias;
39
40 # Format is "this function" => "does these op names"
41 my @raw_alias = (
42                  Perl_do_kv => [qw( keys values )],
43                  Perl_unimplemented_op => [qw(padany threadsv mapstart)],
44                  # All the ops with a body of { return NORMAL; }
45                  Perl_pp_null => [qw(scalar regcmaybe lineseq scope)],
46
47                  Perl_pp_goto => ['dump'],
48                  Perl_pp_require => ['dofile'],
49                  Perl_pp_untie => ['dbmclose'],
50                  Perl_pp_sysread => [qw(read recv)],
51                  Perl_pp_sysseek => ['seek'],
52                  Perl_pp_ioctl => ['fcntl'],
53                  Perl_pp_ssockopt => ['gsockopt'],
54                  Perl_pp_getpeername => ['getsockname'],
55                  Perl_pp_stat => ['lstat'],
56                  Perl_pp_ftrowned => [qw(fteowned ftzero ftsock ftchr ftblk
57                                          ftfile ftdir ftpipe ftsuid ftsgid
58                                          ftsvtx)],
59                  Perl_pp_fttext => ['ftbinary'],
60                  Perl_pp_gmtime => ['localtime'],
61                  Perl_pp_semget => [qw(shmget msgget)],
62                  Perl_pp_semctl => [qw(shmctl msgctl)],
63                  Perl_pp_ghostent => [qw(ghbyname ghbyaddr)],
64                  Perl_pp_gnetent => [qw(gnbyname gnbyaddr)],
65                  Perl_pp_gprotoent => [qw(gpbyname gpbynumber)],
66                  Perl_pp_gservent => [qw(gsbyname gsbyport)],
67                  Perl_pp_gpwent => [qw(gpwnam gpwuid)],
68                  Perl_pp_ggrent => [qw(ggrnam ggrgid)],
69                  Perl_pp_ftis => [qw(ftsize ftmtime ftatime ftctime)],
70                  Perl_pp_chown => [qw(unlink chmod utime kill)],
71                  Perl_pp_link => ['symlink'],
72                  Perl_pp_ftrread => [qw(ftrwrite ftrexec fteread ftewrite
73                                         fteexec)],
74                  Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)],
75                  Perl_pp_send => ['syswrite'],
76                  Perl_pp_and => ['andassign'],
77                  Perl_pp_or => ['orassign'],
78                  Perl_pp_ucfirst => ['lcfirst'],
79                  Perl_pp_sle => [qw(slt sgt sge)],
80                  Perl_pp_index => ['rindex'],
81                  Perl_pp_oct => ['hex'],
82                  Perl_pp_shift => ['pop'],
83                  Perl_pp_sin => [qw(cos exp log sqrt)],
84                 );
85
86 while (my ($func, $names) = splice @raw_alias, 0, 2) {
87     $alias{$_} = $func for @$names;
88 }
89
90 # Emit defines.
91
92 $i = 0;
93 print <<"END";
94 /* -*- buffer-read-only: t -*-
95  *
96  *    opcode.h
97  *
98  *    Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
99  *    2001, 2002, 2003, 2004, 2005, 2006, 2007 by Larry Wall and others
100  *
101  *    You may distribute under the terms of either the GNU General Public
102  *    License or the Artistic License, as specified in the README file.
103  *
104  * !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
105  *  This file is built by opcode.pl from its data.  Any changes made here
106  *  will be lost!
107  */
108
109 #define Perl_pp_i_preinc Perl_pp_preinc
110 #define Perl_pp_i_predec Perl_pp_predec
111 #define Perl_pp_i_postinc Perl_pp_postinc
112 #define Perl_pp_i_postdec Perl_pp_postdec
113
114 PERL_PPDEF(Perl_unimplemented_op)
115
116 END
117
118 print ON <<"END";
119 /* -*- buffer-read-only: t -*-
120  *
121  *    opnames.h
122  *
123  *    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
124  *    2007 by Larry Wall and others
125  *
126  *    You may distribute under the terms of either the GNU General Public
127  *    License or the Artistic License, as specified in the README file.
128  *
129  *
130  * !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
131  *  This file is built by opcode.pl from its data.  Any changes made here
132  *  will be lost!
133  */
134
135 typedef enum opcode {
136 END
137
138 for (@ops) {
139     print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
140 }
141 print ON "\t", &tab(3,"OP_max"), "\n";
142 print ON "} opcode;\n";
143 print ON "\n#define MAXO ", scalar @ops, "\n";
144 print ON "#define OP_phoney_INPUT_ONLY -1\n";
145 print ON "#define OP_phoney_OUTPUT_ONLY -2\n\n";
146
147 # Emit op names and descriptions.
148
149 print <<END;
150
151 START_EXTERN_C
152
153
154 #define OP_NAME(o) ((o)->op_type == OP_CUSTOM ? custom_op_name(o) : \\
155                     PL_op_name[(o)->op_type])
156 #define OP_DESC(o) ((o)->op_type == OP_CUSTOM ? custom_op_desc(o) : \\
157                     PL_op_desc[(o)->op_type])
158
159 #ifndef DOINIT
160 EXT char *PL_op_name[];
161 #else
162 EXT char *PL_op_name[] = {
163 END
164
165 for (@ops) {
166     print qq(\t"$_",\n);
167 }
168
169 print <<END;
170 };
171 #endif
172
173 END
174
175 print <<END;
176 #ifndef DOINIT
177 EXT char *PL_op_desc[];
178 #else
179 EXT char *PL_op_desc[] = {
180 END
181
182 for (@ops) {
183     my($safe_desc) = $desc{$_};
184
185     # Have to escape double quotes and escape characters.
186     $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g;
187
188     print qq(\t"$safe_desc",\n);
189 }
190
191 print <<END;
192 };
193 #endif
194
195 END_EXTERN_C
196
197 END
198
199 # Emit function declarations.
200
201 #for (sort keys %ckname) {
202 #    print "OP *\t", &tab(3,$_),"(pTHX_ OP* o);\n";
203 #}
204 #
205 #print "\n";
206 #
207 #for (@ops) {
208 #    print "OP *\t", &tab(3, "pp_$_"), "(pTHX);\n";
209 #}
210
211 # Emit ppcode switch array.
212
213 print <<END;
214
215 START_EXTERN_C
216
217 #ifndef DOINIT
218 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX);
219 #else
220 EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = {
221 END
222
223 for (@ops) {
224     $_ eq "custom" and next;
225     if ($_ eq threadsv) {
226         # Big threadsv special case
227         my $name = $alias{$_};
228         print <<"EOT";
229 #ifdef USE_5005THREADS
230 \tMEMBER_TO_FPTR(Perl_pp_$_),
231 #else
232 \tMEMBER_TO_FPTR($name),\t/* Perl_pp_$_ */
233 #endif
234 EOT
235     } elsif (my $name = $alias{$_}) {
236         print "\tMEMBER_TO_FPTR($name),\t/* Perl_pp_$_ */\n";
237     }
238     else {
239         print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n";
240     }
241 }
242
243 print <<END;
244 };
245 #endif
246
247 END
248
249 # Emit check routines.
250
251 print <<END;
252 #ifndef DOINIT
253 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op);
254 #else
255 EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = {
256 END
257
258 for (@ops) {
259     print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n";
260 }
261
262 print <<END;
263 };
264 #endif
265
266 END
267
268 # Emit allowed argument types.
269
270 print <<END;
271 #ifndef DOINIT
272 EXT U32 PL_opargs[];
273 #else
274 EXT U32 PL_opargs[] = {
275 END
276
277 %argnum = (
278     S,  1,              # scalar
279     L,  2,              # list
280     A,  3,              # array value
281     H,  4,              # hash value
282     C,  5,              # code value
283     F,  6,              # file value
284     R,  7,              # scalar reference
285 );
286
287 %opclass = (
288     '0',  0,            # baseop
289     '1',  1,            # unop
290     '2',  2,            # binop
291     '|',  3,            # logop
292     '@',  4,            # listop
293     '/',  5,            # pmop
294     '$',  6,            # svop_or_padop
295     '#',  7,            # padop
296     '"',  8,            # pvop_or_svop
297     '{',  9,            # loop
298     ';',  10,           # cop
299     '%',  11,           # baseop_or_unop
300     '-',  12,           # filestatop
301     '}',  13,           # loopexop
302 );
303
304 my %OP_IS_SOCKET;
305 my %OP_IS_FILETEST;
306
307 for (@ops) {
308     $argsum = 0;
309     $flags = $flags{$_};
310     $argsum |= 1 if $flags =~ /m/;              # needs stack mark
311     $argsum |= 2 if $flags =~ /f/;              # fold constants
312     $argsum |= 4 if $flags =~ /s/;              # always produces scalar
313     $argsum |= 8 if $flags =~ /t/;              # needs target scalar
314     $argsum |= (8|256) if $flags =~ /T/;        # ... which may be lexical
315     $argsum |= 16 if $flags =~ /i/;             # always produces integer
316     $argsum |= 32 if $flags =~ /I/;             # has corresponding int op
317     $argsum |= 64 if $flags =~ /d/;             # danger, unknown side effects
318     $argsum |= 128 if $flags =~ /u/;            # defaults to $_
319     $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
320     $argsum |= $opclass{$1} << 9;
321     $mul = 0x2000;                              # 2 ^ OASHIFT
322     for $arg (split(' ',$args{$_})) {
323         if ($arg =~ /^F/) {
324            $OP_IS_SOCKET{$_}   = 1 if $arg =~ s/s//;
325            $OP_IS_FILETEST{$_} = 1 if $arg =~ s/-//;
326         }
327         $argnum = ($arg =~ s/\?//) ? 8 : 0;
328         die "op = $_, arg = $arg\n" unless length($arg) == 1;
329         $argnum += $argnum{$arg};
330         warn "# Conflicting bit 32 for '$_'.\n"
331             if $argnum & 8 and $mul == 0x10000000;
332         $argsum += $argnum * $mul;
333         $mul <<= 4;
334     }
335     $argsum = sprintf("0x%08x", $argsum);
336     print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
337 }
338
339 print <<END;
340 };
341 #endif
342
343 END_EXTERN_C
344 END
345
346 if (keys %OP_IS_SOCKET) {
347     print ON "\n#define OP_IS_SOCKET(op)        \\\n\t(";
348     print ON join(" || \\\n\t ",
349                map { "(op) == OP_" . uc() } sort keys %OP_IS_SOCKET);
350     print ON ")\n\n";
351 }
352
353 if (keys %OP_IS_FILETEST) {
354     print ON "\n#define OP_IS_FILETEST(op)      \\\n\t(";
355     print ON join(" || \\\n\t ",
356                map { "(op) == OP_" . uc() } sort keys %OP_IS_FILETEST);
357     print ON ")\n\n";
358 }
359
360 print OC "/* ex: set ro: */\n";
361 print ON "/* ex: set ro: */\n";
362
363 close OC or die "Error closing opcode.h: $!";
364 close ON or die "Error closing opnames.h: $!";
365
366 foreach ('opcode.h', 'opnames.h') {
367     safer_rename_silent $_, "$_-old";
368 }
369 safer_rename $opcode_new, 'opcode.h';
370 safer_rename $opname_new, 'opnames.h';
371
372 $pp_proto_new = 'pp_proto.h-new';
373 $pp_sym_new  = 'pp.sym-new';
374
375 open PP, ">$pp_proto_new" or die "Error creating $pp_proto_new: $!";
376 binmode PP;
377 open PPSYM, ">$pp_sym_new" or die "Error creating $pp_sym_new: $!";
378 binmode PPSYM;
379
380 print PP <<"END";
381 /* -*- buffer-read-only: t -*-
382    !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
383    This file is built by opcode.pl from its data.  Any changes made here
384    will be lost!
385 */
386
387 END
388
389 print PPSYM <<"END";
390 # -*- buffer-read-only: t -*-
391 #
392 # !!!!!!!   DO NOT EDIT THIS FILE   !!!!!!!
393 #   This file is built by opcode.pl from its data.  Any changes made here
394 #   will be lost!
395 #
396
397 END
398
399
400 for (sort keys %ckname) {
401     print PP "PERL_CKDEF(Perl_$_)\n";
402     print PPSYM "Perl_$_\n";
403 #OP *\t", &tab(3,$_),"(OP* o);\n";
404 }
405
406 print PP "\n\n";
407
408 for (@ops) {
409     next if /^i_(pre|post)(inc|dec)$/;
410     next if /^custom$/;
411     print PP "PERL_PPDEF(Perl_pp_$_)\n";
412     print PPSYM "Perl_pp_$_\n";
413 }
414 print PP "\n/* ex: set ro: */\n";
415 print PPSYM "\n# ex: set ro:\n";
416
417 close PP or die "Error closing pp_proto.h: $!";
418 close PPSYM or die "Error closing pp.sym: $!";
419
420 foreach ('pp_proto.h', 'pp.sym') {
421     safer_rename_silent $_, "$_-old";
422 }
423 safer_rename $pp_proto_new, 'pp_proto.h';
424 safer_rename $pp_sym_new, 'pp.sym';
425
426 END {
427   foreach ('opcode.h', 'opnames.h', 'pp_proto.h', 'pp.sym') {
428     1 while unlink "$_-old";
429   }
430 }
431
432 ###########################################################################
433 sub tab {
434     local($l, $t) = @_;
435     $t .= "\t" x ($l - (length($t) + 1) / 8);
436     $t;
437 }
438 ###########################################################################
439
440 # Some comments about 'T' opcode classifier:
441
442 # Safe to set if the ppcode uses:
443 #       tryAMAGICbin, tryAMAGICun, SETn, SETi, SETu, PUSHn, PUSHTARG, SETTARG,
444 #       SETs(TARG), XPUSHn, XPUSHu,
445
446 # Unsafe to set if the ppcode uses dTARG or [X]RETPUSH[YES|NO|UNDEF]
447
448 # lt and friends do SETs (including ncmp, but not scmp)
449
450 # Additional mode of failure: the opcode can modify TARG before it "used"
451 # all the arguments (or may call an external function which does the same).
452 # If the target coincides with one of the arguments ==> kaboom.
453
454 # pp.c  pos substr each not OK (RETPUSHUNDEF)
455 #       substr vec also not OK due to LV to target (are they???)
456 #       ref not OK (RETPUSHNO)
457 #       trans not OK (dTARG; TARG = sv_newmortal();)
458 #       ucfirst etc not OK: TMP arg processed inplace
459 #       quotemeta not OK (unsafe when TARG == arg)
460 #       each repeat not OK too due to list context
461 #       pack split - unknown whether they are safe
462 #       sprintf: is calling do_sprintf(TARG,...) which can act on TARG
463 #         before other args are processed.
464
465 #       Suspicious wrt "additional mode of failure" (and only it):
466 #       schop, chop, postinc/dec, bit_and etc, negate, complement.
467
468 #       Also suspicious: 4-arg substr, sprintf, uc/lc (POK_only), reverse, pack.
469
470 #       substr/vec: doing TAINT_off()???
471
472 # pp_hot.c
473 #       readline - unknown whether it is safe
474 #       match subst not OK (dTARG)
475 #       grepwhile not OK (not always setting)
476 #       join not OK (unsafe when TARG == arg)
477
478 #       Suspicious wrt "additional mode of failure": concat (dealt with
479 #       in ck_sassign()), join (same).
480
481 # pp_ctl.c
482 #       mapwhile flip caller not OK (not always setting)
483
484 # pp_sys.c
485 #       backtick glob warn die not OK (not always setting)
486 #       warn not OK (RETPUSHYES)
487 #       open fileno getc sysread syswrite ioctl accept shutdown
488 #        ftsize(etc) readlink telldir fork alarm getlogin not OK (RETPUSHUNDEF)
489 #       umask select not OK (XPUSHs(&PL_sv_undef);)
490 #       fileno getc sysread syswrite tell not OK (meth("FILENO" "GETC"))
491 #       sselect shm* sem* msg* syscall - unknown whether they are safe
492 #       gmtime not OK (list context)
493
494 #       Suspicious wrt "additional mode of failure": warn, die, select.
495
496 __END__
497
498 # New ops always go at the end, just before 'custom'
499
500 # A recapitulation of the format of this file:
501 # The file consists of five columns: the name of the op, an English
502 # description, the name of the "check" routine used to optimize this
503 # operation, some flags, and a description of the operands.
504
505 # The flags consist of options followed by a mandatory op class signifier
506
507 # The classes are:
508 # baseop      - 0            unop     - 1            binop      - 2
509 # logop       - |            listop   - @            pmop       - /
510 # padop/svop  - $            padop    - # (unused)   loop       - {
511 # baseop/unop - %            loopexop - }            filestatop - -
512 # pvop/svop   - "            cop      - ;
513
514 # Other options are:
515 #   needs stack mark                    - m
516 #   needs constant folding              - f
517 #   produces a scalar                   - s
518 #   produces an integer                 - i
519 #   needs a target                      - t
520 #   target can be in a pad              - T
521 #   has a corresponding integer version - I
522 #   has side effects                    - d
523 #   uses $_ if no argument given        - u
524
525 # Values for the operands are:
526 # scalar      - S            list     - L            array     - A
527 # hash        - H            sub (CV) - C            file      - F
528 # socket      - Fs           filetest - F-           reference - R
529 # "?" denotes an optional operand.
530
531 # Nothing.
532
533 null            null operation          ck_null         0       
534 stub            stub                    ck_null         0
535 scalar          scalar                  ck_fun          s%      S
536
537 # Pushy stuff.
538
539 pushmark        pushmark                ck_null         s0      
540 wantarray       wantarray               ck_null         is0     
541
542 const           constant item           ck_svconst      s$      
543
544 gvsv            scalar variable         ck_null         ds$     
545 gv              glob value              ck_null         ds$     
546 gelem           glob elem               ck_null         d2      S S
547 padsv           private variable        ck_null         ds0
548 padav           private array           ck_null         d0
549 padhv           private hash            ck_null         d0
550 padany          private value           ck_null         d0
551
552 pushre          push regexp             ck_null         d/
553
554 # References and stuff.
555
556 rv2gv           ref-to-glob cast        ck_rvconst      ds1     
557 rv2sv           scalar dereference      ck_rvconst      ds1     
558 av2arylen       array length            ck_null         is1     
559 rv2cv           subroutine dereference  ck_rvconst      d1
560 anoncode        anonymous subroutine    ck_anoncode     $       
561 prototype       subroutine prototype    ck_null         s%      S
562 refgen          reference constructor   ck_spair        m1      L
563 srefgen         single ref constructor  ck_null         fs1     S
564 ref             reference-type operator ck_fun          stu%    S?
565 bless           bless                   ck_fun          s@      S S?
566
567 # Pushy I/O.
568
569 backtick        quoted execution (``, qx)       ck_open         t%      
570 # glob defaults its first arg to $_
571 glob            glob                    ck_glob         t@      S?
572 readline        <HANDLE>                ck_null         t%      F?
573 rcatline        append I/O operator     ck_null         t$
574
575 # Bindable operators.
576
577 regcmaybe       regexp internal guard   ck_fun          s1      S
578 regcreset       regexp internal reset   ck_fun          s1      S
579 regcomp         regexp compilation      ck_null         s|      S
580 match           pattern match (m//)     ck_match        d/
581 qr              pattern quote (qr//)    ck_match        s/
582 subst           substitution (s///)     ck_null         dis/    S
583 substcont       substitution iterator   ck_null         dis|    
584 trans           transliteration (tr///) ck_null         is"     S
585
586 # Lvalue operators.
587 # sassign is special-cased for op class
588
589 sassign         scalar assignment       ck_sassign      s0
590 aassign         list assignment         ck_null         t2      L L
591
592 chop            chop                    ck_spair        mts%    L
593 schop           scalar chop             ck_null         stu%    S?
594 chomp           chomp                   ck_spair        mTs%    L
595 schomp          scalar chomp            ck_null         sTu%    S?
596 defined         defined operator        ck_defined      isu%    S?
597 undef           undef operator          ck_lfun         s%      S?
598 study           study                   ck_fun          su%     S?
599 pos             match position          ck_lfun         stu%    S?
600
601 preinc          preincrement (++)               ck_lfun         dIs1    S
602 i_preinc        integer preincrement (++)       ck_lfun         dis1    S
603 predec          predecrement (--)               ck_lfun         dIs1    S
604 i_predec        integer predecrement (--)       ck_lfun         dis1    S
605 postinc         postincrement (++)              ck_lfun         dIst1   S
606 i_postinc       integer postincrement (++)      ck_lfun         disT1   S
607 postdec         postdecrement (--)              ck_lfun         dIst1   S
608 i_postdec       integer postdecrement (--)      ck_lfun         disT1   S
609
610 # Ordinary operators.
611
612 pow             exponentiation (**)     ck_null         fsT2    S S
613
614 multiply        multiplication (*)      ck_null         IfsT2   S S
615 i_multiply      integer multiplication (*)      ck_null         ifsT2   S S
616 divide          division (/)            ck_null         IfsT2   S S
617 i_divide        integer division (/)    ck_null         ifsT2   S S
618 modulo          modulus (%)             ck_null         IifsT2  S S
619 i_modulo        integer modulus (%)     ck_null         ifsT2   S S
620 repeat          repeat (x)              ck_repeat       mt2     L S
621
622 add             addition (+)            ck_null         IfsT2   S S
623 i_add           integer addition (+)    ck_null         ifsT2   S S
624 subtract        subtraction (-)         ck_null         IfsT2   S S
625 i_subtract      integer subtraction (-) ck_null         ifsT2   S S
626 concat          concatenation (.) or string     ck_concat       fsT2    S S
627 stringify       string                  ck_fun          fsT@    S
628
629 left_shift      left bitshift (<<)      ck_bitop        fsT2    S S
630 right_shift     right bitshift (>>)     ck_bitop        fsT2    S S
631
632 lt              numeric lt (<)          ck_null         Iifs2   S S
633 i_lt            integer lt (<)          ck_null         ifs2    S S
634 gt              numeric gt (>)          ck_null         Iifs2   S S
635 i_gt            integer gt (>)          ck_null         ifs2    S S
636 le              numeric le (<=)         ck_null         Iifs2   S S
637 i_le            integer le (<=)         ck_null         ifs2    S S
638 ge              numeric ge (>=)         ck_null         Iifs2   S S
639 i_ge            integer ge (>=)         ck_null         ifs2    S S
640 eq              numeric eq (==)         ck_null         Iifs2   S S
641 i_eq            integer eq (==)         ck_null         ifs2    S S
642 ne              numeric ne (!=)         ck_null         Iifs2   S S
643 i_ne            integer ne (!=)         ck_null         ifs2    S S
644 ncmp            numeric comparison (<=>)        ck_null         Iifst2  S S
645 i_ncmp          integer comparison (<=>)        ck_null         ifst2   S S
646
647 slt             string lt               ck_null         ifs2    S S
648 sgt             string gt               ck_null         ifs2    S S
649 sle             string le               ck_null         ifs2    S S
650 sge             string ge               ck_null         ifs2    S S
651 seq             string eq               ck_null         ifs2    S S
652 sne             string ne               ck_null         ifs2    S S
653 scmp            string comparison (cmp) ck_null         ifst2   S S
654
655 bit_and         bitwise and (&)         ck_bitop        fst2    S S
656 bit_xor         bitwise xor (^)         ck_bitop        fst2    S S
657 bit_or          bitwise or (|)          ck_bitop        fst2    S S
658
659 negate          negation (-)            ck_null         Ifst1   S
660 i_negate        integer negation (-)    ck_null         ifsT1   S
661 not             not                     ck_null         ifs1    S
662 complement      1's complement (~)      ck_bitop        fst1    S
663
664 # High falutin' math.
665
666 atan2           atan2                   ck_fun          fsT@    S S
667 sin             sin                     ck_fun          fsTu%   S?
668 cos             cos                     ck_fun          fsTu%   S?
669 rand            rand                    ck_fun          sT%     S?
670 srand           srand                   ck_fun          s%      S?
671 exp             exp                     ck_fun          fsTu%   S?
672 log             log                     ck_fun          fsTu%   S?
673 sqrt            sqrt                    ck_fun          fsTu%   S?
674
675 # Lowbrow math.
676
677 int             int                     ck_fun          fsTu%   S?
678 hex             hex                     ck_fun          fsTu%   S?
679 oct             oct                     ck_fun          fsTu%   S?
680 abs             abs                     ck_fun          fsTu%   S?
681
682 # String stuff.
683
684 length          length                  ck_lengthconst  isTu%   S?
685 substr          substr                  ck_substr       st@     S S S? S?
686 vec             vec                     ck_fun          ist@    S S S
687
688 index           index                   ck_index        isT@    S S S?
689 rindex          rindex                  ck_index        isT@    S S S?
690
691 sprintf         sprintf                 ck_fun          mst@    S L
692 formline        formline                ck_fun          ms@     S L
693 ord             ord                     ck_fun          ifsTu%  S?
694 chr             chr                     ck_fun          fsTu%   S?
695 crypt           crypt                   ck_fun          fsT@    S S
696 ucfirst         ucfirst                 ck_fun          fstu%   S?
697 lcfirst         lcfirst                 ck_fun          fstu%   S?
698 uc              uc                      ck_fun          fstu%   S?
699 lc              lc                      ck_fun          fstu%   S?
700 quotemeta       quotemeta               ck_fun          fstu%   S?
701
702 # Arrays.
703
704 rv2av           array dereference       ck_rvconst      dt1     
705 aelemfast       constant array element  ck_null         s$      A S
706 aelem           array element           ck_null         s2      A S
707 aslice          array slice             ck_null         m@      A L
708
709 # Hashes.
710
711 each            each                    ck_fun          %       H
712 values          values                  ck_fun          t%      H
713 keys            keys                    ck_fun          t%      H
714 delete          delete                  ck_delete       %       S
715 exists          exists                  ck_exists       is%     S
716 rv2hv           hash dereference        ck_rvconst      dt1     
717 helem           hash element            ck_null         s2@     H S
718 hslice          hash slice              ck_null         m@      H L
719
720 # Explosives and implosives.
721
722 unpack          unpack                  ck_fun          @       S S
723 pack            pack                    ck_fun          mst@    S L
724 split           split                   ck_split        t@      S S S
725 join            join or string          ck_join         mst@    S L
726
727 # List operators.
728
729 list            list                    ck_null         m@      L
730 lslice          list slice              ck_null         2       H L L
731 anonlist        anonymous list ([])     ck_fun          ms@     L
732 anonhash        anonymous hash ({})     ck_fun          ms@     L
733
734 splice          splice                  ck_fun          m@      A S? S? L
735 push            push                    ck_fun          imsT@   A L
736 pop             pop                     ck_shift        s%      A?
737 shift           shift                   ck_shift        s%      A?
738 unshift         unshift                 ck_fun          imsT@   A L
739 sort            sort                    ck_sort         dm@     C? L
740 reverse         reverse                 ck_fun          mt@     L
741
742 grepstart       grep                    ck_grep         dm@     C L
743 grepwhile       grep iterator           ck_null         dt|     
744
745 mapstart        map                     ck_grep         dm@     C L
746 mapwhile        map iterator            ck_null         dt|
747
748 # Range stuff.
749
750 range           flipflop                ck_null         |       S S
751 flip            range (or flip)         ck_null         1       S S
752 flop            range (or flop)         ck_null         1
753
754 # Control.
755
756 and             logical and (&&)                ck_null         |       
757 or              logical or (||)                 ck_null         |       
758 xor             logical xor                     ck_null         fs2     S S     
759 cond_expr       conditional expression          ck_null         d|      
760 andassign       logical and assignment (&&=)    ck_null         s|      
761 orassign        logical or assignment (||=)     ck_null         s|      
762
763 method          method lookup           ck_method       d1
764 entersub        subroutine entry        ck_subr         dmt1    L
765 leavesub        subroutine exit         ck_null         1       
766 leavesublv      lvalue subroutine return        ck_null         1       
767 caller          caller                  ck_fun          t%      S?
768 warn            warn                    ck_fun          imst@   L
769 die             die                     ck_die          dimst@  L
770 reset           symbol reset            ck_fun          is%     S?
771
772 lineseq         line sequence           ck_null         @       
773 nextstate       next statement          ck_null         s;      
774 dbstate         debug next statement    ck_null         s;      
775 unstack         iteration finalizer     ck_null         s0
776 enter           block entry             ck_null         0       
777 leave           block exit              ck_null         @       
778 scope           block                   ck_null         @       
779 enteriter       foreach loop entry      ck_null         d{      
780 iter            foreach loop iterator   ck_null         0       
781 enterloop       loop entry              ck_null         d{      
782 leaveloop       loop exit               ck_null         2       
783 return          return                  ck_return       dm@     L
784 last            last                    ck_null         ds}     
785 next            next                    ck_null         ds}     
786 redo            redo                    ck_null         ds}     
787 dump            dump                    ck_null         ds}     
788 goto            goto                    ck_null         ds}     
789 exit            exit                    ck_exit         ds%     S?
790 # continued below
791
792 #nswitch        numeric switch          ck_null         d       
793 #cswitch        character switch        ck_null         d       
794
795 # I/O.
796
797 open            open                    ck_open         ismt@   F S? L
798 close           close                   ck_fun          is%     F?
799 pipe_op         pipe                    ck_fun          is@     F F
800
801 fileno          fileno                  ck_fun          ist%    F
802 umask           umask                   ck_fun          ist%    S?
803 binmode         binmode                 ck_fun          s@      F S?
804
805 tie             tie                     ck_fun          idms@   R S L
806 untie           untie                   ck_fun          is%     R
807 tied            tied                    ck_fun          s%      R
808 dbmopen         dbmopen                 ck_fun          is@     H S S
809 dbmclose        dbmclose                ck_fun          is%     H
810
811 sselect         select system call      ck_select       t@      S S S S
812 select          select                  ck_select       st@     F?
813
814 getc            getc                    ck_eof          st%     F?
815 read            read                    ck_fun          imst@   F R S S?
816 enterwrite      write                   ck_fun          dis%    F?
817 leavewrite      write exit              ck_null         1       
818
819 prtf            printf                  ck_listiob      ims@    F? L
820 print           print                   ck_listiob      ims@    F? L
821
822 sysopen         sysopen                 ck_fun          s@      F S S S?
823 sysseek         sysseek                 ck_fun          s@      F S S
824 sysread         sysread                 ck_fun          imst@   F R S S?
825 syswrite        syswrite                ck_fun          imst@   F S S? S?
826
827 send            send                    ck_fun          imst@   Fs S S S?
828 recv            recv                    ck_fun          imst@   Fs R S S
829
830 eof             eof                     ck_eof          is%     F?
831 tell            tell                    ck_fun          st%     F?
832 seek            seek                    ck_fun          s@      F S S
833 # truncate really behaves as if it had both "S S" and "F S"
834 truncate        truncate                ck_trunc        is@     S S
835
836 fcntl           fcntl                   ck_fun          st@     F S S
837 ioctl           ioctl                   ck_fun          st@     F S S
838 flock           flock                   ck_fun          isT@    F S
839
840 # Sockets.
841
842 socket          socket                  ck_fun          is@     Fs S S S
843 sockpair        socketpair              ck_fun          is@     Fs Fs S S S
844
845 bind            bind                    ck_fun          is@     Fs S
846 connect         connect                 ck_fun          is@     Fs S
847 listen          listen                  ck_fun          is@     Fs S
848 accept          accept                  ck_fun          ist@    Fs Fs
849 shutdown        shutdown                ck_fun          ist@    Fs S
850
851 gsockopt        getsockopt              ck_fun          is@     Fs S S
852 ssockopt        setsockopt              ck_fun          is@     Fs S S S
853
854 getsockname     getsockname             ck_fun          is%     Fs
855 getpeername     getpeername             ck_fun          is%     Fs
856
857 # Stat calls.
858
859 lstat           lstat                   ck_ftst         u-      F
860 stat            stat                    ck_ftst         u-      F
861 ftrread         -R                      ck_ftst         isu-    F-
862 ftrwrite        -W                      ck_ftst         isu-    F-
863 ftrexec         -X                      ck_ftst         isu-    F-
864 fteread         -r                      ck_ftst         isu-    F-
865 ftewrite        -w                      ck_ftst         isu-    F-
866 fteexec         -x                      ck_ftst         isu-    F-
867 ftis            -e                      ck_ftst         isu-    F-
868 fteowned        -o                      ck_ftst         isu-    F-
869 ftrowned        -O                      ck_ftst         isu-    F-
870 ftzero          -z                      ck_ftst         isu-    F-
871 ftsize          -s                      ck_ftst         istu-   F-
872 ftmtime         -M                      ck_ftst         stu-    F-
873 ftatime         -A                      ck_ftst         stu-    F-
874 ftctime         -C                      ck_ftst         stu-    F-
875 ftsock          -S                      ck_ftst         isu-    F-
876 ftchr           -c                      ck_ftst         isu-    F-
877 ftblk           -b                      ck_ftst         isu-    F-
878 ftfile          -f                      ck_ftst         isu-    F-
879 ftdir           -d                      ck_ftst         isu-    F-
880 ftpipe          -p                      ck_ftst         isu-    F-
881 ftlink          -l                      ck_ftst         isu-    F-
882 ftsuid          -u                      ck_ftst         isu-    F-
883 ftsgid          -g                      ck_ftst         isu-    F-
884 ftsvtx          -k                      ck_ftst         isu-    F-
885 fttty           -t                      ck_ftst         is-     F-
886 fttext          -T                      ck_ftst         isu-    F-
887 ftbinary        -B                      ck_ftst         isu-    F-
888
889 # File calls.
890
891 chdir           chdir                   ck_fun          isT%    S?
892 chown           chown                   ck_fun          imsT@   L
893 chroot          chroot                  ck_fun          isTu%   S?
894 unlink          unlink                  ck_fun          imsTu@  L
895 chmod           chmod                   ck_fun          imsT@   L
896 utime           utime                   ck_fun          imsT@   L
897 rename          rename                  ck_fun          isT@    S S
898 link            link                    ck_fun          isT@    S S
899 symlink         symlink                 ck_fun          isT@    S S
900 readlink        readlink                ck_fun          stu%    S?
901 mkdir           mkdir                   ck_fun          isT@    S S?
902 rmdir           rmdir                   ck_fun          isTu%   S?
903
904 # Directory calls.
905
906 open_dir        opendir                 ck_fun          is@     F S
907 readdir         readdir                 ck_fun          %       F
908 telldir         telldir                 ck_fun          st%     F
909 seekdir         seekdir                 ck_fun          s@      F S
910 rewinddir       rewinddir               ck_fun          s%      F
911 closedir        closedir                ck_fun          is%     F
912
913 # Process control.
914
915 fork            fork                    ck_null         ist0    
916 wait            wait                    ck_null         isT0    
917 waitpid         waitpid                 ck_fun          isT@    S S
918 system          system                  ck_exec         imsT@   S? L
919 exec            exec                    ck_exec         dimsT@  S? L
920 kill            kill                    ck_fun          dimsT@  L
921 getppid         getppid                 ck_null         isT0    
922 getpgrp         getpgrp                 ck_fun          isT%    S?
923 setpgrp         setpgrp                 ck_fun          isT@    S? S?
924 getpriority     getpriority             ck_fun          isT@    S S
925 setpriority     setpriority             ck_fun          isT@    S S S
926
927 # Time calls.
928
929 # NOTE: MacOS patches the 'i' of time() away later when the interpreter
930 # is created because in MacOS time() is already returning times > 2**31-1,
931 # that is, non-integers.
932
933 time            time                    ck_null         isT0    
934 tms             times                   ck_null         0       
935 localtime       localtime               ck_fun          t%      S?
936 gmtime          gmtime                  ck_fun          t%      S?
937 alarm           alarm                   ck_fun          istu%   S?
938 sleep           sleep                   ck_fun          isT%    S?
939
940 # Shared memory.
941
942 shmget          shmget                  ck_fun          imst@   S S S
943 shmctl          shmctl                  ck_fun          imst@   S S S
944 shmread         shmread                 ck_fun          imst@   S S S S
945 shmwrite        shmwrite                ck_fun          imst@   S S S S
946
947 # Message passing.
948
949 msgget          msgget                  ck_fun          imst@   S S
950 msgctl          msgctl                  ck_fun          imst@   S S S
951 msgsnd          msgsnd                  ck_fun          imst@   S S S
952 msgrcv          msgrcv                  ck_fun          imst@   S S S S S
953
954 # Semaphores.
955
956 semget          semget                  ck_fun          imst@   S S S
957 semctl          semctl                  ck_fun          imst@   S S S S
958 semop           semop                   ck_fun          imst@   S S
959
960 # Eval.
961
962 require         require                 ck_require      du%     S?
963 dofile          do "file"               ck_fun          d1      S
964 entereval       eval "string"           ck_eval         d%      S
965 leaveeval       eval "string" exit      ck_null         1       S
966 #evalonce       eval constant string    ck_null         d1      S
967 entertry        eval {block}            ck_null         |       
968 leavetry        eval {block} exit       ck_null         @       
969
970 # Get system info.
971
972 ghbyname        gethostbyname           ck_fun          %       S
973 ghbyaddr        gethostbyaddr           ck_fun          @       S S
974 ghostent        gethostent              ck_null         0       
975 gnbyname        getnetbyname            ck_fun          %       S
976 gnbyaddr        getnetbyaddr            ck_fun          @       S S
977 gnetent         getnetent               ck_null         0       
978 gpbyname        getprotobyname          ck_fun          %       S
979 gpbynumber      getprotobynumber        ck_fun          @       S
980 gprotoent       getprotoent             ck_null         0       
981 gsbyname        getservbyname           ck_fun          @       S S
982 gsbyport        getservbyport           ck_fun          @       S S
983 gservent        getservent              ck_null         0       
984 shostent        sethostent              ck_fun          is%     S
985 snetent         setnetent               ck_fun          is%     S
986 sprotoent       setprotoent             ck_fun          is%     S
987 sservent        setservent              ck_fun          is%     S
988 ehostent        endhostent              ck_null         is0     
989 enetent         endnetent               ck_null         is0     
990 eprotoent       endprotoent             ck_null         is0     
991 eservent        endservent              ck_null         is0     
992 gpwnam          getpwnam                ck_fun          %       S
993 gpwuid          getpwuid                ck_fun          %       S
994 gpwent          getpwent                ck_null         0       
995 spwent          setpwent                ck_null         is0     
996 epwent          endpwent                ck_null         is0     
997 ggrnam          getgrnam                ck_fun          %       S
998 ggrgid          getgrgid                ck_fun          %       S
999 ggrent          getgrent                ck_null         0       
1000 sgrent          setgrent                ck_null         is0     
1001 egrent          endgrent                ck_null         is0     
1002 getlogin        getlogin                ck_null         st0     
1003
1004 # Miscellaneous.
1005
1006 syscall         syscall                 ck_fun          imst@   S L
1007
1008 # For multi-threading
1009 lock            lock                    ck_rfun         s%      R
1010 threadsv        per-thread value        ck_null         ds0
1011
1012 # Control (contd.)
1013 setstate        set statement info      ck_null         s;
1014 method_named    method with known name  ck_null         d$
1015
1016 # Add new ops before this, the custom operator.
1017
1018 custom          unknown custom operator         ck_null         0