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