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