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