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