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