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