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