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