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