4 open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
13 ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
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"];
22 $check{$key} = $check;
24 $flags{$key} = $flags;
32 #define pp_i_preinc pp_preinc
33 #define pp_i_predec pp_predec
34 #define pp_i_postinc pp_postinc
35 #define pp_i_postdec pp_postdec
40 print "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
42 print "\t", &tab(3,"OP_max"), "\n";
44 print "\n#define MAXO ", scalar @ops, "\n\n";
46 # Emit op names and descriptions.
52 EXT char *op_name[] = {
69 EXT char *op_desc[] = {
73 print qq(\t"$desc{$_}",\n);
82 # Emit function declarations.
84 for (sort keys %ckname) {
85 print "OP *\t", &tab(3,$_),"_((OP* o));\n";
91 print "OP *\t", &tab(3, "pp_$_"), "_((ARGSproto));\n";
94 # Emit ppcode switch array.
99 EXT OP * (*ppaddr[])();
101 EXT OP * (*ppaddr[])() = {
114 # Emit check routines.
118 EXT OP * (*check[]) _((OP *op));
120 EXT OP * (*check[]) _((OP *op)) = {
124 print "\t", &tab(3, "$check{$_},"), "/* $_ */\n";
133 # Emit allowed argument types.
149 R, 7, # scalar reference
165 '%', 12, # baseop_or_unop
166 '-', 13, # filestatop
173 $argsum |= 1 if $flags =~ /m/; # needs stack mark
174 $argsum |= 2 if $flags =~ /f/; # fold constants
175 $argsum |= 4 if $flags =~ /s/; # always produces scalar
176 $argsum |= 8 if $flags =~ /t/; # needs target scalar
177 $argsum |= 16 if $flags =~ /i/; # always produces integer
178 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
179 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
180 $argsum |= 128 if $flags =~ /u/; # defaults to $_
182 $flags =~ /([^a-zA-Z])/ or die qq[Opcode "$_" has no class indicator];
183 $argsum |= $opclass{$1} << 8;
184 $mul = 4096; # 2 ^ OASHIFT
185 for $arg (split(' ',$args{$_})) {
186 $argnum = ($arg =~ s/\?//) ? 8 : 0;
187 $argnum += $argnum{$arg};
188 $argsum += $argnum * $mul;
191 $argsum = sprintf("0x%08x", $argsum);
192 print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
200 ###########################################################################
203 $t .= "\t" x ($l - (length($t) + 1) / 8);
206 ###########################################################################
211 null null operation ck_null 0
213 scalar scalar ck_fun s% S
217 pushmark pushmark ck_null s0
218 wantarray wantarray ck_null is0
220 const constant item ck_svconst s$
222 gvsv scalar variable ck_null ds*
223 gv glob value ck_null ds*
224 gelem glob elem ck_null d2 S S
225 padsv private variable ck_null ds0
226 padav private array ck_null d0
227 padhv private hash ck_null d0
228 padany private something ck_null d0
230 pushre push regexp ck_null /
232 # References and stuff.
234 rv2gv ref-to-glob cast ck_rvconst ds1
235 rv2sv scalar deref ck_rvconst ds1
236 av2arylen array length ck_null is1
237 rv2cv subroutine deref ck_rvconst d1
238 anoncode anonymous subroutine ck_anoncode $
239 prototype subroutine prototype ck_null s% S
240 refgen reference constructor ck_spair m0 L
241 srefgen scalar ref constructor ck_null fs0 S
242 ref reference-type operator ck_fun stu% S?
243 bless bless ck_fun s@ S S?
247 backtick backticks ck_null t%
248 # glob defaults its first arg to $_
249 glob glob ck_glob t@ S? S?
250 readline <HANDLE> ck_null t%
251 rcatline append I/O operator ck_null t%
253 # Bindable operators.
255 regcmaybe regexp comp once ck_fun s1 S
256 regcomp regexp compilation ck_null s| S
257 match pattern match ck_match d/
258 subst substitution ck_null dis/ S
259 substcont substitution cont ck_null dis|
260 trans character translation ck_null is" S
263 # sassign is special-cased for op class
265 sassign scalar assignment ck_null s0
266 aassign list assignment ck_null t2 L L
268 chop chop ck_spair mts% L
269 schop scalar chop ck_null stu% S?
270 chomp safe chop ck_spair mts% L
271 schomp scalar safe chop ck_null stu% S?
272 defined defined operator ck_rfun isu% S?
273 undef undef operator ck_lfun s% S?
274 study study ck_fun su% S?
275 pos match position ck_lfun stu% S?
277 preinc preincrement ck_lfun dIs1 S
278 i_preinc integer preincrement ck_lfun dis1 S
279 predec predecrement ck_lfun dIs1 S
280 i_predec integer predecrement ck_lfun dis1 S
281 postinc postincrement ck_lfun dIst1 S
282 i_postinc integer postincrement ck_lfun dist1 S
283 postdec postdecrement ck_lfun dIst1 S
284 i_postdec integer postdecrement ck_lfun dist1 S
286 # Ordinary operators.
288 pow exponentiation ck_null fst2 S S
290 multiply multiplication ck_null Ifst2 S S
291 i_multiply integer multiplication ck_null ifst2 S S
292 divide division ck_null Ifst2 S S
293 i_divide integer division ck_null ifst2 S S
294 modulo modulus ck_null Iifst2 S S
295 i_modulo integer modulus ck_null ifst2 S S
296 repeat repeat ck_repeat mt2 L S
298 add addition ck_null Ifst2 S S
299 i_add integer addition ck_null ifst2 S S
300 subtract subtraction ck_null Ifst2 S S
301 i_subtract integer subtraction ck_null ifst2 S S
302 concat concatenation ck_concat fst2 S S
303 stringify string ck_fun fst@ S
305 left_shift left bitshift ck_bitop fst2 S S
306 right_shift right bitshift ck_bitop fst2 S S
308 lt numeric lt ck_null Iifs2 S S
309 i_lt integer lt ck_null ifs2 S S
310 gt numeric gt ck_null Iifs2 S S
311 i_gt integer gt ck_null ifs2 S S
312 le numeric le ck_null Iifs2 S S
313 i_le integer le ck_null ifs2 S S
314 ge numeric ge ck_null Iifs2 S S
315 i_ge integer ge ck_null ifs2 S S
316 eq numeric eq ck_null Iifs2 S S
317 i_eq integer eq ck_null ifs2 S S
318 ne numeric ne ck_null Iifs2 S S
319 i_ne integer ne ck_null ifs2 S S
320 ncmp spaceship operator ck_null Iifst2 S S
321 i_ncmp integer spaceship ck_null ifst2 S S
323 slt string lt ck_scmp ifs2 S S
324 sgt string gt ck_scmp ifs2 S S
325 sle string le ck_scmp ifs2 S S
326 sge string ge ck_scmp ifs2 S S
327 seq string eq ck_null ifs2 S S
328 sne string ne ck_null ifs2 S S
329 scmp string comparison ck_scmp ifst2 S S
331 bit_and bitwise and ck_bitop fst2 S S
332 bit_xor bitwise xor ck_bitop fst2 S S
333 bit_or bitwise or ck_bitop fst2 S S
335 negate negate ck_null Ifst1 S
336 i_negate integer negate ck_null ifst1 S
337 not not ck_null ifs1 S
338 complement 1's complement ck_bitop fst1 S
340 # High falutin' math.
342 atan2 atan2 ck_fun fst@ S S
343 sin sin ck_fun fstu% S?
344 cos cos ck_fun fstu% S?
345 rand rand ck_fun st% S?
346 srand srand ck_fun s% S?
347 exp exp ck_fun fstu% S?
348 log log ck_fun fstu% S?
349 sqrt sqrt ck_fun fstu% S?
353 int int ck_fun fstu% S?
354 hex hex ck_fun fstu% S?
355 oct oct ck_fun fstu% S?
356 abs abs ck_fun fstu% S?
360 length length ck_lengthconst istu% S?
361 substr substr ck_fun st@ S S S?
362 vec vec ck_fun ist@ S S S
364 index index ck_index ist@ S S S?
365 rindex rindex ck_index ist@ S S S?
367 sprintf sprintf ck_fun_locale mfst@ S L
368 formline formline ck_fun ms@ S L
369 ord ord ck_fun ifstu% S?
370 chr chr ck_fun fstu% S?
371 crypt crypt ck_fun fst@ S S
372 ucfirst upper case first ck_fun_locale fstu% S?
373 lcfirst lower case first ck_fun_locale fstu% S?
374 uc upper case ck_fun_locale fstu% S?
375 lc lower case ck_fun_locale fstu% S?
376 quotemeta quote metachars ck_fun fstu% S?
380 rv2av array deref ck_rvconst dt1
381 aelemfast known array element ck_null s* A S
382 aelem array element ck_null s2 A S
383 aslice array slice ck_null m@ A L
387 each each ck_fun t% H
388 values values ck_fun t% H
389 keys keys ck_fun t% H
390 delete delete ck_delete % S
391 exists exists operator ck_exists is% S
392 rv2hv hash deref ck_rvconst dt1
393 helem hash elem ck_null s2@ H S
394 hslice hash slice ck_null m@ H L
396 # Explosives and implosives.
398 unpack unpack ck_fun @ S S
399 pack pack ck_fun mst@ S L
400 split split ck_split t@ S S S
401 join join ck_fun mst@ S L
405 list list ck_null m@ L
406 lslice list slice ck_null 2 H L L
407 anonlist anonymous list ck_fun ms@ L
408 anonhash anonymous hash ck_fun ms@ L
410 splice splice ck_fun m@ A S? S? L
411 push push ck_fun imst@ A L
412 pop pop ck_shift si% A
413 shift shift ck_shift s% A
414 unshift unshift ck_fun imst@ A L
415 sort sort ck_sort m@ C? L
416 reverse reverse ck_fun mt@ L
418 grepstart grep ck_grep dm@ C L
419 grepwhile grep iterator ck_null dt|
421 mapstart map ck_grep dm@ C L
422 mapwhile map iterator ck_null dt|
426 range flipflop ck_null ? S S
427 flip range (or flip) ck_null 1 S S
428 flop range (or flop) ck_null 1
432 and logical and ck_null |
433 or logical or ck_null |
434 xor logical xor ck_null fs| S S
435 cond_expr conditional expression ck_null d?
436 andassign logical and assignment ck_null s|
437 orassign logical or assignment ck_null s|
439 method method lookup ck_null d1
440 entersub subroutine entry ck_subr dmt1 L
441 leavesub subroutine exit ck_null 1
442 caller caller ck_fun t% S?
443 warn warn ck_fun imst@ L
444 die die ck_fun dimst@ L
445 reset reset ck_fun is% S?
447 lineseq line sequence ck_null @
448 nextstate next statement ck_null s;
449 dbstate debug next statement ck_null s;
450 unstack unstack ck_null s0
451 enter block entry ck_null 0
452 leave block exit ck_null @
453 scope block ck_null @
454 enteriter foreach loop entry ck_null d{
455 iter foreach loop iterator ck_null 0
456 enterloop loop entry ck_null d{
457 leaveloop loop exit ck_null 2
458 return return ck_null dm@ L
459 last last ck_null ds}
460 next next ck_null ds}
461 redo redo ck_null ds}
462 dump dump ck_null ds}
463 goto goto ck_null ds}
464 exit exit ck_fun ds% S?
466 #nswitch numeric switch ck_null d
467 #cswitch character switch ck_null d
471 open open ck_fun ist@ F S?
472 close close ck_fun is% F?
473 pipe_op pipe ck_fun is@ F F
475 fileno fileno ck_fun ist% F
476 umask umask ck_fun ist% S?
477 binmode binmode ck_fun s% F
479 tie tie ck_fun idms@ R S L
480 untie untie ck_fun is% R
481 tied tied ck_fun s% R
482 dbmopen dbmopen ck_fun is@ H S S
483 dbmclose dbmclose ck_fun is% H
485 sselect select system call ck_select t@ S S S S
486 select select ck_select st@ F?
488 getc getc ck_eof st% F?
489 read read ck_fun imst@ F R S S?
490 enterwrite write ck_fun dis% F?
491 leavewrite write exit ck_null 1
493 prtf printf ck_listiob ims@ F? L
494 print print ck_listiob ims@ F? L
496 sysopen sysopen ck_fun s@ F S S S?
497 sysseek sysseek ck_fun s@ F S S
498 sysread sysread ck_fun imst@ F R S S?
499 syswrite syswrite ck_fun imst@ F S S S?
501 send send ck_fun imst@ F S S S?
502 recv recv ck_fun imst@ F R S S
504 eof eof ck_eof is% F?
505 tell tell ck_fun st% F?
506 seek seek ck_fun s@ F S S
507 # truncate really behaves as if it had both "S S" and "F S"
508 truncate truncate ck_trunc is@ S S
510 fcntl fcntl ck_fun st@ F S S
511 ioctl ioctl ck_fun st@ F S S
512 flock flock ck_fun ist@ F S
516 socket socket ck_fun is@ F S S S
517 sockpair socketpair ck_fun is@ F F S S S
519 bind bind ck_fun is@ F S
520 connect connect ck_fun is@ F S
521 listen listen ck_fun is@ F S
522 accept accept ck_fun ist@ F F
523 shutdown shutdown ck_fun ist@ F S
525 gsockopt getsockopt ck_fun is@ F S S
526 ssockopt setsockopt ck_fun is@ F S S S
528 getsockname getsockname ck_fun is% F
529 getpeername getpeername ck_fun is% F
533 lstat lstat ck_ftst u- F
534 stat stat ck_ftst u- F
535 ftrread -R ck_ftst isu- F
536 ftrwrite -W ck_ftst isu- F
537 ftrexec -X ck_ftst isu- F
538 fteread -r ck_ftst isu- F
539 ftewrite -w ck_ftst isu- F
540 fteexec -x ck_ftst isu- F
541 ftis -e ck_ftst isu- F
542 fteowned -O ck_ftst isu- F
543 ftrowned -o ck_ftst isu- F
544 ftzero -z ck_ftst isu- F
545 ftsize -s ck_ftst istu- F
546 ftmtime -M ck_ftst stu- F
547 ftatime -A ck_ftst stu- F
548 ftctime -C ck_ftst stu- F
549 ftsock -S ck_ftst isu- F
550 ftchr -c ck_ftst isu- F
551 ftblk -b ck_ftst isu- F
552 ftfile -f ck_ftst isu- F
553 ftdir -d ck_ftst isu- F
554 ftpipe -p ck_ftst isu- F
555 ftlink -l ck_ftst isu- F
556 ftsuid -u ck_ftst isu- F
557 ftsgid -g ck_ftst isu- F
558 ftsvtx -k ck_ftst isu- F
559 fttty -t ck_ftst is- F
560 fttext -T ck_ftst isu- F
561 ftbinary -B ck_ftst isu- F
565 chdir chdir ck_fun ist% S?
566 chown chown ck_fun imst@ L
567 chroot chroot ck_fun istu% S?
568 unlink unlink ck_fun imstu@ L
569 chmod chmod ck_fun imst@ L
570 utime utime ck_fun imst@ L
571 rename rename ck_fun ist@ S S
572 link link ck_fun ist@ S S
573 symlink symlink ck_fun ist@ S S
574 readlink readlink ck_fun stu% S?
575 mkdir mkdir ck_fun ist@ S S
576 rmdir rmdir ck_fun istu% S?
580 open_dir opendir ck_fun is@ F S
581 readdir readdir ck_fun % F
582 telldir telldir ck_fun st% F
583 seekdir seekdir ck_fun s@ F S
584 rewinddir rewinddir ck_fun s% F
585 closedir closedir ck_fun is% F
589 fork fork ck_null ist0
590 wait wait ck_null ist0
591 waitpid waitpid ck_fun ist@ S S
592 system system ck_exec imst@ S? L
593 exec exec ck_exec dimst@ S? L
594 kill kill ck_fun dimst@ L
595 getppid getppid ck_null ist0
596 getpgrp getpgrp ck_fun ist% S?
597 setpgrp setpgrp ck_fun ist@ S? S?
598 getpriority getpriority ck_fun ist@ S S
599 setpriority setpriority ck_fun ist@ S S S
603 time time ck_null ist0
605 localtime localtime ck_fun t% S?
606 gmtime gmtime ck_fun t% S?
607 alarm alarm ck_fun istu% S?
608 sleep sleep ck_fun ist% S?
612 shmget shmget ck_fun imst@ S S S
613 shmctl shmctl ck_fun imst@ S S S
614 shmread shmread ck_fun imst@ S S S S
615 shmwrite shmwrite ck_fun imst@ S S S S
619 msgget msgget ck_fun imst@ S S
620 msgctl msgctl ck_fun imst@ S S S
621 msgsnd msgsnd ck_fun imst@ S S S
622 msgrcv msgrcv ck_fun imst@ S S S S S
626 semget semget ck_fun imst@ S S S
627 semctl semctl ck_fun imst@ S S S S
628 semop semop ck_fun imst@ S S
632 require require ck_require du% S?
633 dofile do 'file' ck_fun d1 S
634 entereval eval string ck_eval d% S
635 leaveeval eval exit ck_null 1 S
636 #evalonce eval constant string ck_null d1 S
637 entertry eval block ck_null |
638 leavetry eval block exit ck_null @
642 ghbyname gethostbyname ck_fun % S
643 ghbyaddr gethostbyaddr ck_fun @ S S
644 ghostent gethostent ck_null 0
645 gnbyname getnetbyname ck_fun % S
646 gnbyaddr getnetbyaddr ck_fun @ S S
647 gnetent getnetent ck_null 0
648 gpbyname getprotobyname ck_fun % S
649 gpbynumber getprotobynumber ck_fun @ S
650 gprotoent getprotoent ck_null 0
651 gsbyname getservbyname ck_fun @ S S
652 gsbyport getservbyport ck_fun @ S S
653 gservent getservent ck_null 0
654 shostent sethostent ck_fun is% S
655 snetent setnetent ck_fun is% S
656 sprotoent setprotoent ck_fun is% S
657 sservent setservent ck_fun is% S
658 ehostent endhostent ck_null is0
659 enetent endnetent ck_null is0
660 eprotoent endprotoent ck_null is0
661 eservent endservent ck_null is0
662 gpwnam getpwnam ck_fun % S
663 gpwuid getpwuid ck_fun % S
664 gpwent getpwent ck_null 0
665 spwent setpwent ck_null is0
666 epwent endpwent ck_null is0
667 ggrnam getgrnam ck_fun % S
668 ggrgid getgrgid ck_fun % S
669 ggrent getgrent ck_null 0
670 sgrent setgrent ck_null is0
671 egrent endgrent ck_null is0
672 getlogin getlogin ck_null st0
676 syscall syscall ck_fun imst@ S L
678 # For multi-threading
679 lock lock ck_rfun s% S
680 threadsv per-thread variable ck_null ds0