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