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