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