source: vendor/perl/5.8.8/opcode.pl@ 3251

Last change on this file since 3251 was 3181, checked in by bird, 18 years ago

perl 5.8.8

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