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