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