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