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