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