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