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