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