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