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