Commit | Line | Data |
79072805 |
1 | #!/usr/bin/perl |
2 | |
abdd5c84 |
3 | unlink "opcode.h", "opnames.h"; |
79072805 |
4 | open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n"; |
abdd5c84 |
5 | open(ON, ">opnames.h") || die "Can't create opnames.h: $!\n"; |
79072805 |
6 | select OC; |
7 | |
8 | # Read data. |
9 | |
10 | while (<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 |
32 | print <<"END"; |
a27f85b3 |
33 | /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
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 |
43 | END |
abdd5c84 |
44 | |
45 | print ON <<"END"; |
46 | /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
47 | This file is built by opcode.pl from its data. Any changes made here |
48 | will be lost! |
49 | */ |
50 | |
51 | typedef enum opcode { |
52 | END |
53 | |
79072805 |
54 | for (@ops) { |
abdd5c84 |
55 | print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n"; |
79072805 |
56 | } |
abdd5c84 |
57 | print ON "\t", &tab(3,"OP_max"), "\n"; |
58 | print ON "} opcode;\n"; |
4c80c0b2 |
59 | print ON "\n#define MAXO ", scalar @ops, "\n"; |
60 | print ON "#define OP_phoney_INPUT_ONLY -1\n"; |
61 | print ON "#define OP_phoney_OUTPUT_ONLY -2\n\n"; |
79072805 |
62 | |
c07a80fd |
63 | # Emit op names and descriptions. |
79072805 |
64 | |
65 | print <<END; |
73c4f7a1 |
66 | |
67 | START_EXTERN_C |
68 | |
79072805 |
69 | #ifndef DOINIT |
22c35a8c |
70 | EXT char *PL_op_name[]; |
79072805 |
71 | #else |
22c35a8c |
72 | EXT char *PL_op_name[] = { |
79072805 |
73 | END |
74 | |
75 | for (@ops) { |
c07a80fd |
76 | print qq(\t"$_",\n); |
77 | } |
78 | |
79 | print <<END; |
80 | }; |
81 | #endif |
82 | |
83 | END |
84 | |
85 | print <<END; |
86 | #ifndef DOINIT |
22c35a8c |
87 | EXT char *PL_op_desc[]; |
c07a80fd |
88 | #else |
22c35a8c |
89 | EXT char *PL_op_desc[] = { |
c07a80fd |
90 | END |
91 | |
92 | for (@ops) { |
42d38218 |
93 | my($safe_desc) = $desc{$_}; |
94 | |
95 | # Have to escape double quotes and escape characters. |
96 | $safe_desc =~ s/(^|[^\\])([\\"])/$1\\$2/g; |
97 | |
98 | print qq(\t"$safe_desc",\n); |
79072805 |
99 | } |
100 | |
101 | print <<END; |
102 | }; |
103 | #endif |
104 | |
73c4f7a1 |
105 | END_EXTERN_C |
106 | |
22c35a8c |
107 | END |
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 | |
123 | print <<END; |
124 | |
73c4f7a1 |
125 | START_EXTERN_C |
126 | |
79072805 |
127 | #ifndef DOINIT |
cea2e8a9 |
128 | EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX); |
79072805 |
129 | #else |
cea2e8a9 |
130 | EXT OP * (CPERLscope(*PL_ppaddr)[])(pTHX) = { |
79072805 |
131 | END |
132 | |
133 | for (@ops) { |
2b260de0 |
134 | print "\tMEMBER_TO_FPTR(Perl_pp_$_),\n"; |
79072805 |
135 | } |
136 | |
137 | print <<END; |
138 | }; |
139 | #endif |
140 | |
141 | END |
142 | |
143 | # Emit check routines. |
144 | |
145 | print <<END; |
146 | #ifndef DOINIT |
cea2e8a9 |
147 | EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op); |
79072805 |
148 | #else |
cea2e8a9 |
149 | EXT OP * (CPERLscope(*PL_check)[]) (pTHX_ OP *op) = { |
79072805 |
150 | END |
151 | |
152 | for (@ops) { |
2b260de0 |
153 | print "\t", &tab(3, "MEMBER_TO_FPTR(Perl_$check{$_}),"), "\t/* $_ */\n"; |
79072805 |
154 | } |
155 | |
156 | print <<END; |
157 | }; |
158 | #endif |
159 | |
160 | END |
161 | |
162 | # Emit allowed argument types. |
163 | |
164 | print <<END; |
165 | #ifndef DOINIT |
22c35a8c |
166 | EXT U32 PL_opargs[]; |
79072805 |
167 | #else |
22c35a8c |
168 | EXT U32 PL_opargs[] = { |
79072805 |
169 | END |
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 |
198 | my %OP_IS_SOCKET; |
199 | my %OP_IS_FILETEST; |
200 | |
79072805 |
201 | for (@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 | |
234 | print <<END; |
235 | }; |
236 | #endif |
73c4f7a1 |
237 | |
238 | END_EXTERN_C |
79072805 |
239 | END |
240 | |
a85d93d9 |
241 | if (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 | |
248 | if (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 |
255 | close OC or die "Error closing opcode.h: $!"; |
abdd5c84 |
256 | close ON or die "Error closing opnames.h: $!"; |
735e0d5c |
257 | |
2cd61cdb |
258 | unlink "pp_proto.h"; |
22c35a8c |
259 | unlink "pp.sym"; |
735e0d5c |
260 | open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!"; |
22c35a8c |
261 | open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!"; |
262 | |
a27f85b3 |
263 | print PP <<"END"; |
264 | /* !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
265 | This file is built by opcode.pl from its data. Any changes made here |
266 | will be lost! |
267 | */ |
268 | |
269 | END |
270 | |
271 | print PPSYM <<"END"; |
272 | # |
273 | # !!!!!!! DO NOT EDIT THIS FILE !!!!!!! |
274 | # This file is built by opcode.pl from its data. Any changes made here |
275 | # will be lost! |
276 | # |
277 | |
278 | END |
279 | |
280 | |
22c35a8c |
281 | for (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 | |
287 | print PP "\n\n"; |
288 | |
735e0d5c |
289 | for (@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 | |
295 | close PP or die "Error closing pp_proto.h: $!"; |
22c35a8c |
296 | close PPSYM or die "Error closing pp.sym: $!"; |
735e0d5c |
297 | |
79072805 |
298 | ########################################################################### |
299 | sub 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 | |
79072805 |
366 | # Nothing. |
367 | |
368 | null null operation ck_null 0 |
93a17b20 |
369 | stub stub ck_null 0 |
db173bac |
370 | scalar scalar ck_fun s% S |
79072805 |
371 | |
372 | # Pushy stuff. |
373 | |
db173bac |
374 | pushmark pushmark ck_null s0 |
375 | wantarray wantarray ck_null is0 |
79072805 |
376 | |
db173bac |
377 | const constant item ck_svconst s$ |
79072805 |
378 | |
7934575e |
379 | gvsv scalar variable ck_null ds$ |
380 | gv glob value ck_null ds$ |
db173bac |
381 | gelem glob elem ck_null d2 S S |
382 | padsv private variable ck_null ds0 |
383 | padav private array ck_null d0 |
384 | padhv private hash ck_null d0 |
f1612b5c |
385 | padany private value ck_null d0 |
79072805 |
386 | |
1167e5da |
387 | pushre push regexp ck_null d/ |
79072805 |
388 | |
389 | # References and stuff. |
390 | |
db173bac |
391 | rv2gv ref-to-glob cast ck_rvconst ds1 |
b89fed5f |
392 | rv2sv scalar dereference ck_rvconst ds1 |
db173bac |
393 | av2arylen array length ck_null is1 |
b89fed5f |
394 | rv2cv subroutine dereference ck_rvconst d1 |
db173bac |
395 | anoncode anonymous subroutine ck_anoncode $ |
396 | prototype subroutine prototype ck_null s% S |
5d11ae5e |
397 | refgen reference constructor ck_spair m1 L |
dfa0f641 |
398 | srefgen single ref constructor ck_null fs1 S |
db173bac |
399 | ref reference-type operator ck_fun stu% S? |
400 | bless bless ck_fun s@ S S? |
79072805 |
401 | |
402 | # Pushy I/O. |
403 | |
16fe6d59 |
404 | backtick quoted execution (``, qx) ck_open t% |
0a753a76 |
405 | # glob defaults its first arg to $_ |
649da076 |
406 | glob glob ck_glob t@ S? |
db173bac |
407 | readline <HANDLE> ck_null t% |
408 | rcatline append I/O operator ck_null t% |
79072805 |
409 | |
410 | # Bindable operators. |
411 | |
f1612b5c |
412 | regcmaybe regexp internal guard ck_fun s1 S |
413 | regcreset regexp internal reset ck_fun s1 S |
414 | regcomp regexp compilation ck_null s| S |
415 | match pattern match (m//) ck_match d/ |
416 | qr pattern quote (qr//) ck_match s/ |
417 | subst substitution (s///) ck_null dis/ S |
418 | substcont substitution iterator ck_null dis| |
419 | trans transliteration (tr///) ck_null is" S |
79072805 |
420 | |
421 | # Lvalue operators. |
db173bac |
422 | # sassign is special-cased for op class |
423 | |
b162f9ea |
424 | sassign scalar assignment ck_sassign s0 |
db173bac |
425 | aassign list assignment ck_null t2 L L |
426 | |
21f5b33c |
427 | chop chop ck_spair mts% L |
428 | schop scalar chop ck_null stu% S? |
f1612b5c |
429 | chomp chomp ck_spair mTs% L |
430 | schomp scalar chomp ck_null sTu% S? |
69794302 |
431 | defined defined operator ck_defined isu% S? |
db173bac |
432 | undef undef operator ck_lfun s% S? |
433 | study study ck_fun su% S? |
434 | pos match position ck_lfun stu% S? |
435 | |
42d38218 |
436 | preinc preincrement (++) ck_lfun dIs1 S |
437 | i_preinc integer preincrement (++) ck_lfun dis1 S |
438 | predec predecrement (--) ck_lfun dIs1 S |
439 | i_predec integer predecrement (--) ck_lfun dis1 S |
21f5b33c |
440 | postinc postincrement (++) ck_lfun dIst1 S |
42d38218 |
441 | i_postinc integer postincrement (++) ck_lfun disT1 S |
21f5b33c |
442 | postdec postdecrement (--) ck_lfun dIst1 S |
42d38218 |
443 | i_postdec integer postdecrement (--) ck_lfun disT1 S |
79072805 |
444 | |
445 | # Ordinary operators. |
446 | |
42d38218 |
447 | pow exponentiation (**) ck_null fsT2 S S |
448 | |
f1612b5c |
449 | multiply multiplication (*) ck_null IfsT2 S S |
42d38218 |
450 | i_multiply integer multiplication (*) ck_null ifsT2 S S |
451 | divide division (/) ck_null IfsT2 S S |
452 | i_divide integer division (/) ck_null ifsT2 S S |
453 | modulo modulus (%) ck_null IifsT2 S S |
454 | i_modulo integer modulus (%) ck_null ifsT2 S S |
455 | repeat repeat (x) ck_repeat mt2 L S |
456 | |
457 | add addition (+) ck_null IfsT2 S S |
458 | i_add integer addition (+) ck_null ifsT2 S S |
459 | subtract subtraction (-) ck_null IfsT2 S S |
460 | i_subtract integer subtraction (-) ck_null ifsT2 S S |
297b36dc |
461 | concat concatenation (.) or string ck_concat fsT2 S S |
b162f9ea |
462 | stringify string ck_fun fsT@ S |
db173bac |
463 | |
42d38218 |
464 | left_shift left bitshift (<<) ck_bitop fsT2 S S |
465 | right_shift right bitshift (>>) ck_bitop fsT2 S S |
466 | |
467 | lt numeric lt (<) ck_null Iifs2 S S |
468 | i_lt integer lt (<) ck_null ifs2 S S |
469 | gt numeric gt (>) ck_null Iifs2 S S |
470 | i_gt integer gt (>) ck_null ifs2 S S |
471 | le numeric le (<=) ck_null Iifs2 S S |
472 | i_le integer le (<=) ck_null ifs2 S S |
473 | ge numeric ge (>=) ck_null Iifs2 S S |
474 | i_ge integer ge (>=) ck_null ifs2 S S |
475 | eq numeric eq (==) ck_null Iifs2 S S |
476 | i_eq integer eq (==) ck_null ifs2 S S |
477 | ne numeric ne (!=) ck_null Iifs2 S S |
478 | i_ne integer ne (!=) ck_null ifs2 S S |
479 | ncmp numeric comparison (<=>) ck_null Iifst2 S S |
480 | i_ncmp integer comparison (<=>) ck_null ifst2 S S |
db173bac |
481 | |
482 | slt string lt ck_scmp ifs2 S S |
483 | sgt string gt ck_scmp ifs2 S S |
484 | sle string le ck_scmp ifs2 S S |
485 | sge string ge ck_scmp ifs2 S S |
486 | seq string eq ck_null ifs2 S S |
487 | sne string ne ck_null ifs2 S S |
f1612b5c |
488 | scmp string comparison (cmp) ck_scmp ifst2 S S |
db173bac |
489 | |
21f5b33c |
490 | bit_and bitwise and (&) ck_bitop fst2 S S |
491 | bit_xor bitwise xor (^) ck_bitop fst2 S S |
492 | bit_or bitwise or (|) ck_bitop fst2 S S |
db173bac |
493 | |
21f5b33c |
494 | negate negation (-) ck_null Ifst1 S |
f1612b5c |
495 | i_negate integer negation (-) ck_null ifsT1 S |
db173bac |
496 | not not ck_null ifs1 S |
21f5b33c |
497 | complement 1's complement (~) ck_bitop fst1 S |
79072805 |
498 | |
499 | # High falutin' math. |
500 | |
f1612b5c |
501 | atan2 atan2 ck_fun fsT@ S S |
502 | sin sin ck_fun fsTu% S? |
503 | cos cos ck_fun fsTu% S? |
504 | rand rand ck_fun sT% S? |
505 | srand srand ck_fun s% S? |
506 | exp exp ck_fun fsTu% S? |
507 | log log ck_fun fsTu% S? |
508 | sqrt sqrt ck_fun fsTu% S? |
79072805 |
509 | |
cf26c822 |
510 | # Lowbrow math. |
511 | |
b162f9ea |
512 | int int ck_fun fsTu% S? |
513 | hex hex ck_fun fsTu% S? |
514 | oct oct ck_fun fsTu% S? |
515 | abs abs ck_fun fsTu% S? |
79072805 |
516 | |
517 | # String stuff. |
518 | |
b162f9ea |
519 | length length ck_lengthconst isTu% S? |
35fba0d9 |
520 | substr substr ck_substr st@ S S S? S? |
db173bac |
521 | vec vec ck_fun ist@ S S S |
79072805 |
522 | |
b162f9ea |
523 | index index ck_index isT@ S S S? |
524 | rindex rindex ck_index isT@ S S S? |
79072805 |
525 | |
dae78bb1 |
526 | sprintf sprintf ck_fun_locale mfst@ S L |
db173bac |
527 | formline formline ck_fun ms@ S L |
b162f9ea |
528 | ord ord ck_fun ifsTu% S? |
529 | chr chr ck_fun fsTu% S? |
530 | crypt crypt ck_fun fsT@ S S |
42d38218 |
531 | ucfirst ucfirst ck_fun_locale fstu% S? |
532 | lcfirst lcfirst ck_fun_locale fstu% S? |
533 | uc uc ck_fun_locale fstu% S? |
534 | lc lc ck_fun_locale fstu% S? |
69b47968 |
535 | quotemeta quotemeta ck_fun fstu% S? |
79072805 |
536 | |
537 | # Arrays. |
538 | |
f1612b5c |
539 | rv2av array dereference ck_rvconst dt1 |
7934575e |
540 | aelemfast constant array element ck_null s$ A S |
db173bac |
541 | aelem array element ck_null s2 A S |
542 | aslice array slice ck_null m@ A L |
79072805 |
543 | |
aa689395 |
544 | # Hashes. |
79072805 |
545 | |
59af0135 |
546 | each each ck_fun % H |
db173bac |
547 | values values ck_fun t% H |
548 | keys keys ck_fun t% H |
549 | delete delete ck_delete % S |
42d38218 |
550 | exists exists ck_exists is% S |
f1612b5c |
551 | rv2hv hash dereference ck_rvconst dt1 |
552 | helem hash element ck_null s2@ H S |
db173bac |
553 | hslice hash slice ck_null m@ H L |
79072805 |
554 | |
555 | # Explosives and implosives. |
556 | |
db173bac |
557 | unpack unpack ck_fun @ S S |
558 | pack pack ck_fun mst@ S L |
559 | split split ck_split t@ S S S |
297b36dc |
560 | join join or string ck_join mst@ S L |
79072805 |
561 | |
562 | # List operators. |
563 | |
db173bac |
564 | list list ck_null m@ L |
565 | lslice list slice ck_null 2 H L L |
42d38218 |
566 | anonlist anonymous list ([]) ck_fun ms@ L |
567 | anonhash anonymous hash ({}) ck_fun ms@ L |
79072805 |
568 | |
db173bac |
569 | splice splice ck_fun m@ A S? S? L |
b162f9ea |
570 | push push ck_fun imsT@ A L |
a9f58cad |
571 | pop pop ck_shift s% A |
db173bac |
572 | shift shift ck_shift s% A |
b162f9ea |
573 | unshift unshift ck_fun imsT@ A L |
db173bac |
574 | sort sort ck_sort m@ C? L |
575 | reverse reverse ck_fun mt@ L |
79072805 |
576 | |
f1612b5c |
577 | grepstart grep ck_grep dm@ C L |
578 | grepwhile grep iterator ck_null dt| |
79072805 |
579 | |
f1612b5c |
580 | mapstart map ck_grep dm@ C L |
581 | mapwhile map iterator ck_null dt| |
a0d0e21e |
582 | |
79072805 |
583 | # Range stuff. |
584 | |
1a67a97c |
585 | range flipflop ck_null | S S |
db173bac |
586 | flip range (or flip) ck_null 1 S S |
587 | flop range (or flop) ck_null 1 |
79072805 |
588 | |
589 | # Control. |
590 | |
42d38218 |
591 | and logical and (&&) ck_null | |
f1612b5c |
592 | or logical or (||) ck_null | |
593 | xor logical xor ck_null fs2 S S |
594 | cond_expr conditional expression ck_null d| |
42d38218 |
595 | andassign logical and assignment (&&=) ck_null s| |
596 | orassign logical or assignment (||=) ck_null s| |
db173bac |
597 | |
f5d5a27c |
598 | method method lookup ck_method d1 |
db173bac |
599 | entersub subroutine entry ck_subr dmt1 L |
600 | leavesub subroutine exit ck_null 1 |
cd06dffe |
601 | leavesublv lvalue subroutine exit ck_null 1 |
db173bac |
602 | caller caller ck_fun t% S? |
603 | warn warn ck_fun imst@ L |
604 | die die ck_fun dimst@ L |
f1612b5c |
605 | reset symbol reset ck_fun is% S? |
db173bac |
606 | |
607 | lineseq line sequence ck_null @ |
608 | nextstate next statement ck_null s; |
609 | dbstate debug next statement ck_null s; |
e9c54c90 |
610 | unstack iteration finalizer ck_null s0 |
79072805 |
611 | enter block entry ck_null 0 |
db173bac |
612 | leave block exit ck_null @ |
613 | scope block ck_null @ |
614 | enteriter foreach loop entry ck_null d{ |
79072805 |
615 | iter foreach loop iterator ck_null 0 |
db173bac |
616 | enterloop loop entry ck_null d{ |
617 | leaveloop loop exit ck_null 2 |
618 | return return ck_null dm@ L |
619 | last last ck_null ds} |
620 | next next ck_null ds} |
621 | redo redo ck_null ds} |
622 | dump dump ck_null ds} |
623 | goto goto ck_null ds} |
d98f61e7 |
624 | exit exit ck_exit ds% S? |
7399586d |
625 | # continued below |
79072805 |
626 | |
f1612b5c |
627 | #nswitch numeric switch ck_null d |
628 | #cswitch character switch ck_null d |
79072805 |
629 | |
630 | # I/O. |
631 | |
16fe6d59 |
632 | open open ck_open ist@ F S? L |
db173bac |
633 | close close ck_fun is% F? |
634 | pipe_op pipe ck_fun is@ F F |
79072805 |
635 | |
db173bac |
636 | fileno fileno ck_fun ist% F |
637 | umask umask ck_fun ist% S? |
1c1fc3ea |
638 | binmode binmode ck_fun s@ F S? |
79072805 |
639 | |
db173bac |
640 | tie tie ck_fun idms@ R S L |
641 | untie untie ck_fun is% R |
642 | tied tied ck_fun s% R |
643 | dbmopen dbmopen ck_fun is@ H S S |
644 | dbmclose dbmclose ck_fun is% H |
79072805 |
645 | |
db173bac |
646 | sselect select system call ck_select t@ S S S S |
647 | select select ck_select st@ F? |
79072805 |
648 | |
db173bac |
649 | getc getc ck_eof st% F? |
d1a002d4 |
650 | read read ck_fun imst@ F R S S? |
db173bac |
651 | enterwrite write ck_fun dis% F? |
652 | leavewrite write exit ck_null 1 |
79072805 |
653 | |
db173bac |
654 | prtf printf ck_listiob ims@ F? L |
655 | print print ck_listiob ims@ F? L |
79072805 |
656 | |
db173bac |
657 | sysopen sysopen ck_fun s@ F S S S? |
658 | sysseek sysseek ck_fun s@ F S S |
d1a002d4 |
659 | sysread sysread ck_fun imst@ F R S S? |
145d37e2 |
660 | syswrite syswrite ck_fun imst@ F S S? S? |
79072805 |
661 | |
a85d93d9 |
662 | send send ck_fun imst@ Fs S S S? |
663 | recv recv ck_fun imst@ Fs R S S |
79072805 |
664 | |
db173bac |
665 | eof eof ck_eof is% F? |
666 | tell tell ck_fun st% F? |
667 | seek seek ck_fun s@ F S S |
9b01e405 |
668 | # truncate really behaves as if it had both "S S" and "F S" |
db173bac |
669 | truncate truncate ck_trunc is@ S S |
79072805 |
670 | |
db173bac |
671 | fcntl fcntl ck_fun st@ F S S |
672 | ioctl ioctl ck_fun st@ F S S |
b162f9ea |
673 | flock flock ck_fun isT@ F S |
79072805 |
674 | |
675 | # Sockets. |
676 | |
a85d93d9 |
677 | socket socket ck_fun is@ Fs S S S |
678 | sockpair socketpair ck_fun is@ Fs Fs S S S |
79072805 |
679 | |
a85d93d9 |
680 | bind bind ck_fun is@ Fs S |
681 | connect connect ck_fun is@ Fs S |
682 | listen listen ck_fun is@ Fs S |
683 | accept accept ck_fun ist@ Fs Fs |
684 | shutdown shutdown ck_fun ist@ Fs S |
79072805 |
685 | |
a85d93d9 |
686 | gsockopt getsockopt ck_fun is@ Fs S S |
687 | ssockopt setsockopt ck_fun is@ Fs S S S |
79072805 |
688 | |
a85d93d9 |
689 | getsockname getsockname ck_fun is% Fs |
690 | getpeername getpeername ck_fun is% Fs |
79072805 |
691 | |
692 | # Stat calls. |
693 | |
db173bac |
694 | lstat lstat ck_ftst u- F |
695 | stat stat ck_ftst u- F |
a85d93d9 |
696 | ftrread -R ck_ftst isu- F- |
697 | ftrwrite -W ck_ftst isu- F- |
698 | ftrexec -X ck_ftst isu- F- |
699 | fteread -r ck_ftst isu- F- |
700 | ftewrite -w ck_ftst isu- F- |
701 | fteexec -x ck_ftst isu- F- |
702 | ftis -e ck_ftst isu- F- |
703 | fteowned -O ck_ftst isu- F- |
704 | ftrowned -o ck_ftst isu- F- |
705 | ftzero -z ck_ftst isu- F- |
706 | ftsize -s ck_ftst istu- F- |
707 | ftmtime -M ck_ftst stu- F- |
708 | ftatime -A ck_ftst stu- F- |
709 | ftctime -C ck_ftst stu- F- |
710 | ftsock -S ck_ftst isu- F- |
711 | ftchr -c ck_ftst isu- F- |
712 | ftblk -b ck_ftst isu- F- |
713 | ftfile -f ck_ftst isu- F- |
714 | ftdir -d ck_ftst isu- F- |
715 | ftpipe -p ck_ftst isu- F- |
716 | ftlink -l ck_ftst isu- F- |
717 | ftsuid -u ck_ftst isu- F- |
718 | ftsgid -g ck_ftst isu- F- |
719 | ftsvtx -k ck_ftst isu- F- |
720 | fttty -t ck_ftst is- F- |
721 | fttext -T ck_ftst isu- F- |
722 | ftbinary -B ck_ftst isu- F- |
79072805 |
723 | |
724 | # File calls. |
725 | |
b162f9ea |
726 | chdir chdir ck_fun isT% S? |
727 | chown chown ck_fun imsT@ L |
728 | chroot chroot ck_fun isTu% S? |
729 | unlink unlink ck_fun imsTu@ L |
730 | chmod chmod ck_fun imsT@ L |
731 | utime utime ck_fun imsT@ L |
732 | rename rename ck_fun isT@ S S |
733 | link link ck_fun isT@ S S |
734 | symlink symlink ck_fun isT@ S S |
db173bac |
735 | readlink readlink ck_fun stu% S? |
5a211162 |
736 | mkdir mkdir ck_fun isT@ S S? |
b162f9ea |
737 | rmdir rmdir ck_fun isTu% S? |
79072805 |
738 | |
739 | # Directory calls. |
740 | |
db173bac |
741 | open_dir opendir ck_fun is@ F S |
742 | readdir readdir ck_fun % F |
743 | telldir telldir ck_fun st% F |
744 | seekdir seekdir ck_fun s@ F S |
745 | rewinddir rewinddir ck_fun s% F |
746 | closedir closedir ck_fun is% F |
79072805 |
747 | |
748 | # Process control. |
749 | |
db173bac |
750 | fork fork ck_null ist0 |
b162f9ea |
751 | wait wait ck_null isT0 |
752 | waitpid waitpid ck_fun isT@ S S |
753 | system system ck_exec imsT@ S? L |
754 | exec exec ck_exec dimsT@ S? L |
755 | kill kill ck_fun dimsT@ L |
756 | getppid getppid ck_null isT0 |
757 | getpgrp getpgrp ck_fun isT% S? |
758 | setpgrp setpgrp ck_fun isT@ S? S? |
759 | getpriority getpriority ck_fun isT@ S S |
760 | setpriority setpriority ck_fun isT@ S S S |
79072805 |
761 | |
762 | # Time calls. |
763 | |
cd39f2b6 |
764 | # NOTE: MacOS patches the 'i' of time() away later when the interpreter |
765 | # is created because in MacOS time() is already returning times > 2**31-1, |
766 | # that is, non-integers. |
767 | |
b162f9ea |
768 | time time ck_null isT0 |
79072805 |
769 | tms times ck_null 0 |
db173bac |
770 | localtime localtime ck_fun t% S? |
771 | gmtime gmtime ck_fun t% S? |
772 | alarm alarm ck_fun istu% S? |
b162f9ea |
773 | sleep sleep ck_fun isT% S? |
79072805 |
774 | |
775 | # Shared memory. |
776 | |
db173bac |
777 | shmget shmget ck_fun imst@ S S S |
778 | shmctl shmctl ck_fun imst@ S S S |
779 | shmread shmread ck_fun imst@ S S S S |
780 | shmwrite shmwrite ck_fun imst@ S S S S |
79072805 |
781 | |
782 | # Message passing. |
783 | |
db173bac |
784 | msgget msgget ck_fun imst@ S S |
785 | msgctl msgctl ck_fun imst@ S S S |
786 | msgsnd msgsnd ck_fun imst@ S S S |
787 | msgrcv msgrcv ck_fun imst@ S S S S S |
79072805 |
788 | |
789 | # Semaphores. |
790 | |
db173bac |
791 | semget semget ck_fun imst@ S S S |
792 | semctl semctl ck_fun imst@ S S S S |
793 | semop semop ck_fun imst@ S S |
79072805 |
794 | |
795 | # Eval. |
796 | |
db173bac |
797 | require require ck_require du% S? |
b3f4d674 |
798 | dofile do "file" ck_fun d1 S |
799 | entereval eval "string" ck_eval d% S |
800 | leaveeval eval "string" exit ck_null 1 S |
db173bac |
801 | #evalonce eval constant string ck_null d1 S |
42d38218 |
802 | entertry eval {block} ck_null | |
f1612b5c |
803 | leavetry eval {block} exit ck_null @ |
79072805 |
804 | |
805 | # Get system info. |
806 | |
db173bac |
807 | ghbyname gethostbyname ck_fun % S |
808 | ghbyaddr gethostbyaddr ck_fun @ S S |
79072805 |
809 | ghostent gethostent ck_null 0 |
db173bac |
810 | gnbyname getnetbyname ck_fun % S |
811 | gnbyaddr getnetbyaddr ck_fun @ S S |
79072805 |
812 | gnetent getnetent ck_null 0 |
db173bac |
813 | gpbyname getprotobyname ck_fun % S |
814 | gpbynumber getprotobynumber ck_fun @ S |
79072805 |
815 | gprotoent getprotoent ck_null 0 |
db173bac |
816 | gsbyname getservbyname ck_fun @ S S |
817 | gsbyport getservbyport ck_fun @ S S |
79072805 |
818 | gservent getservent ck_null 0 |
db173bac |
819 | shostent sethostent ck_fun is% S |
820 | snetent setnetent ck_fun is% S |
821 | sprotoent setprotoent ck_fun is% S |
822 | sservent setservent ck_fun is% S |
823 | ehostent endhostent ck_null is0 |
824 | enetent endnetent ck_null is0 |
825 | eprotoent endprotoent ck_null is0 |
826 | eservent endservent ck_null is0 |
827 | gpwnam getpwnam ck_fun % S |
828 | gpwuid getpwuid ck_fun % S |
79072805 |
829 | gpwent getpwent ck_null 0 |
db173bac |
830 | spwent setpwent ck_null is0 |
831 | epwent endpwent ck_null is0 |
832 | ggrnam getgrnam ck_fun % S |
833 | ggrgid getgrgid ck_fun % S |
79072805 |
834 | ggrent getgrent ck_null 0 |
db173bac |
835 | sgrent setgrent ck_null is0 |
836 | egrent endgrent ck_null is0 |
837 | getlogin getlogin ck_null st0 |
79072805 |
838 | |
839 | # Miscellaneous. |
840 | |
db173bac |
841 | syscall syscall ck_fun imst@ S L |
c0329465 |
842 | |
843 | # For multi-threading |
db173bac |
844 | lock lock ck_rfun s% S |
f1612b5c |
845 | threadsv per-thread value ck_null ds0 |
7399586d |
846 | |
847 | # Control (contd.) |
3f872cb9 |
848 | setstate set statement info ck_null s; |
f5d5a27c |
849 | method_named method with known name ck_null d$ |