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