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