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