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