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