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