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