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