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