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