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