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