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