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