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