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