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