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.
50 EXT char *PL_op_name[];
52 EXT char *PL_op_name[] = {
67 EXT char *PL_op_desc[];
69 EXT char *PL_op_desc[] = {
73 print qq(\t"$desc{$_}",\n);
85 #define PERL_CKDEF(s) OP *s _((OP *o));
86 #define PERL_PPDEF(s) OP *s _((ARGSproto));
92 # Emit function declarations.
94 #for (sort keys %ckname) {
95 # print "OP *\t", &tab(3,$_),"_((OP* o));\n";
101 # print "OP *\t", &tab(3, "pp_$_"), "_((ARGSproto));\n";
104 # Emit ppcode switch array.
109 #endif /* PERL_OBJECT */
112 EXT OP * (CPERLscope(*PL_ppaddr)[])(ARGSproto);
114 EXT OP * (CPERLscope(*PL_ppaddr)[])(ARGSproto) = {
127 # Emit check routines.
131 EXT OP * (CPERLscope(*PL_check)[]) _((OP *op));
133 EXT OP * (CPERLscope(*PL_check)[]) _((OP *op)) = {
137 print "\t", &tab(3, "$check{$_},"), "/* $_ */\n";
146 # Emit allowed argument types.
152 EXT U32 PL_opargs[] = {
162 R, 7, # scalar reference
178 '%', 12, # baseop_or_unop
179 '-', 13, # filestatop
186 $argsum |= 1 if $flags =~ /m/; # needs stack mark
187 $argsum |= 2 if $flags =~ /f/; # fold constants
188 $argsum |= 4 if $flags =~ /s/; # always produces scalar
189 $argsum |= 8 if $flags =~ /t/; # needs target scalar
190 $argsum |= 16 if $flags =~ /i/; # always produces integer
191 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
192 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
193 $argsum |= 128 if $flags =~ /u/; # defaults to $_
195 $flags =~ /([\W\d_])/ or die qq[Opcode "$_" has no class indicator];
196 $argsum |= $opclass{$1} << 8;
197 $mul = 4096; # 2 ^ OASHIFT
198 for $arg (split(' ',$args{$_})) {
199 $argnum = ($arg =~ s/\?//) ? 8 : 0;
200 $argnum += $argnum{$arg};
201 $argsum += $argnum * $mul;
204 $argsum = sprintf("0x%08x", $argsum);
205 print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
213 close OC or die "Error closing opcode.h: $!";
217 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
218 open PPSYM, '>pp.sym' or die "Error creating pp.sym: $!";
220 for (sort keys %ckname) {
221 print PP "PERL_CKDEF($_)\n";
222 #OP *\t", &tab(3,$_),"_((OP* o));\n";
228 next if /^i_(pre|post)(inc|dec)$/;
229 print PP "PERL_PPDEF(pp_$_)\n";
230 print PPSYM "pp_$_\n";
233 close PP or die "Error closing pp_proto.h: $!";
234 close PPSYM or die "Error closing pp.sym: $!";
236 ###########################################################################
239 $t .= "\t" x ($l - (length($t) + 1) / 8);
242 ###########################################################################
247 null null operation ck_null 0
249 scalar scalar ck_fun s% S
253 pushmark pushmark ck_null s0
254 wantarray wantarray ck_null is0
256 const constant item ck_svconst s$
258 gvsv scalar variable ck_null ds*
259 gv glob value ck_null ds*
260 gelem glob elem ck_null d2 S S
261 padsv private variable ck_null ds0
262 padav private array ck_null d0
263 padhv private hash ck_null d0
264 padany private something ck_null d0
266 pushre push regexp ck_null d/
268 # References and stuff.
270 rv2gv ref-to-glob cast ck_rvconst ds1
271 rv2sv scalar deref ck_rvconst ds1
272 av2arylen array length ck_null is1
273 rv2cv subroutine deref ck_rvconst d1
274 anoncode anonymous subroutine ck_anoncode $
275 prototype subroutine prototype ck_null s% S
276 refgen reference constructor ck_spair m1 L
277 srefgen scalar ref constructor ck_null fs1 S
278 ref reference-type operator ck_fun stu% S?
279 bless bless ck_fun s@ S S?
283 backtick backticks ck_null t%
284 # glob defaults its first arg to $_
285 glob glob ck_glob t@ S? S?
286 readline <HANDLE> ck_null t%
287 rcatline append I/O operator ck_null t%
289 # Bindable operators.
291 regcmaybe regexp comp once ck_fun s1 S
292 regcreset regexp reset interpolation flag ck_fun s1 S
293 regcomp regexp compilation ck_null s| S
294 match pattern match ck_match d/
295 qr pattern quote ck_match s/
296 subst substitution ck_null dis/ S
297 substcont substitution cont ck_null dis|
298 trans character translation ck_null is" S
301 # sassign is special-cased for op class
303 sassign scalar assignment ck_null s0
304 aassign list assignment ck_null t2 L L
306 chop chop ck_spair mts% L
307 schop scalar chop ck_null stu% S?
308 chomp safe chop ck_spair mts% L
309 schomp scalar safe chop ck_null stu% S?
310 defined defined operator ck_rfun isu% S?
311 undef undef operator ck_lfun s% S?
312 study study ck_fun su% S?
313 pos match position ck_lfun stu% S?
315 preinc preincrement ck_lfun dIs1 S
316 i_preinc integer preincrement ck_lfun dis1 S
317 predec predecrement ck_lfun dIs1 S
318 i_predec integer predecrement ck_lfun dis1 S
319 postinc postincrement ck_lfun dIst1 S
320 i_postinc integer postincrement ck_lfun dist1 S
321 postdec postdecrement ck_lfun dIst1 S
322 i_postdec integer postdecrement ck_lfun dist1 S
324 # Ordinary operators.
326 pow exponentiation ck_null fst2 S S
328 multiply multiplication ck_null Ifst2 S S
329 i_multiply integer multiplication ck_null ifst2 S S
330 divide division ck_null Ifst2 S S
331 i_divide integer division ck_null ifst2 S S
332 modulo modulus ck_null Iifst2 S S
333 i_modulo integer modulus ck_null ifst2 S S
334 repeat repeat ck_repeat mt2 L S
336 add addition ck_null Ifst2 S S
337 i_add integer addition ck_null ifst2 S S
338 subtract subtraction ck_null Ifst2 S S
339 i_subtract integer subtraction ck_null ifst2 S S
340 concat concatenation ck_concat fst2 S S
341 stringify string ck_fun fst@ S
343 left_shift left bitshift ck_bitop fst2 S S
344 right_shift right bitshift ck_bitop fst2 S S
346 lt numeric lt ck_null Iifs2 S S
347 i_lt integer lt ck_null ifs2 S S
348 gt numeric gt ck_null Iifs2 S S
349 i_gt integer gt ck_null ifs2 S S
350 le numeric le ck_null Iifs2 S S
351 i_le integer le ck_null ifs2 S S
352 ge numeric ge ck_null Iifs2 S S
353 i_ge integer ge ck_null ifs2 S S
354 eq numeric eq ck_null Iifs2 S S
355 i_eq integer eq ck_null ifs2 S S
356 ne numeric ne ck_null Iifs2 S S
357 i_ne integer ne ck_null ifs2 S S
358 ncmp spaceship operator ck_null Iifst2 S S
359 i_ncmp integer spaceship ck_null ifst2 S S
361 slt string lt ck_scmp ifs2 S S
362 sgt string gt ck_scmp ifs2 S S
363 sle string le ck_scmp ifs2 S S
364 sge string ge ck_scmp ifs2 S S
365 seq string eq ck_null ifs2 S S
366 sne string ne ck_null ifs2 S S
367 scmp string comparison ck_scmp ifst2 S S
369 bit_and bitwise and ck_bitop fst2 S S
370 bit_xor bitwise xor ck_bitop fst2 S S
371 bit_or bitwise or ck_bitop fst2 S S
373 negate negate ck_null Ifst1 S
374 i_negate integer negate ck_null ifst1 S
375 not not ck_null ifs1 S
376 complement 1's complement ck_bitop fst1 S
378 # High falutin' math.
380 atan2 atan2 ck_fun fst@ S S
381 sin sin ck_fun fstu% S?
382 cos cos ck_fun fstu% S?
383 rand rand ck_fun st% S?
384 srand srand ck_fun s% S?
385 exp exp ck_fun fstu% S?
386 log log ck_fun fstu% S?
387 sqrt sqrt ck_fun fstu% S?
391 int int ck_fun fstu% S?
392 hex hex ck_fun fstu% S?
393 oct oct ck_fun fstu% S?
394 abs abs ck_fun fstu% S?
398 length length ck_lengthconst istu% S?
399 substr substr ck_fun st@ S S S? S?
400 vec vec ck_fun ist@ S S S
402 index index ck_index ist@ S S S?
403 rindex rindex ck_index ist@ S S S?
405 sprintf sprintf ck_fun_locale mfst@ S L
406 formline formline ck_fun ms@ S L
407 ord ord ck_fun ifstu% S?
408 chr chr ck_fun fstu% S?
409 crypt crypt ck_fun fst@ S S
410 ucfirst upper case first ck_fun_locale fstu% S?
411 lcfirst lower case first ck_fun_locale fstu% S?
412 uc upper case ck_fun_locale fstu% S?
413 lc lower case ck_fun_locale fstu% S?
414 quotemeta quote metachars ck_fun fstu% S?
418 rv2av array deref ck_rvconst dt1
419 aelemfast known array element ck_null s* A S
420 aelem array element ck_null s2 A S
421 aslice array slice ck_null m@ A L
425 each each ck_fun t% H
426 values values ck_fun t% H
427 keys keys ck_fun t% H
428 delete delete ck_delete % S
429 exists exists operator ck_exists is% S
430 rv2hv hash deref ck_rvconst dt1
431 helem hash elem ck_null s2@ H S
432 hslice hash slice ck_null m@ H L
434 # Explosives and implosives.
436 unpack unpack ck_fun @ S S
437 pack pack ck_fun mst@ S L
438 split split ck_split t@ S S S
439 join join ck_fun mst@ S L
443 list list ck_null m@ L
444 lslice list slice ck_null 2 H L L
445 anonlist anonymous list ck_fun ms@ L
446 anonhash anonymous hash ck_fun ms@ L
448 splice splice ck_fun m@ A S? S? L
449 push push ck_fun imst@ A L
450 pop pop ck_shift s% A
451 shift shift ck_shift s% A
452 unshift unshift ck_fun imst@ A L
453 sort sort ck_sort m@ C? L
454 reverse reverse ck_fun mt@ L
456 grepstart grep ck_grep dm@ C L
457 grepwhile grep iterator ck_null dt|
459 mapstart map ck_grep dm@ C L
460 mapwhile map iterator ck_null dt|
464 range flipflop ck_null ? S S
465 flip range (or flip) ck_null 1 S S
466 flop range (or flop) ck_null 1
470 and logical and ck_null |
471 or logical or ck_null |
472 xor logical xor ck_null fs| S S
473 cond_expr conditional expression ck_null d?
474 andassign logical and assignment ck_null s|
475 orassign logical or assignment ck_null s|
477 method method lookup ck_null d1
478 entersub subroutine entry ck_subr dmt1 L
479 leavesub subroutine exit ck_null 1
480 caller caller ck_fun t% S?
481 warn warn ck_fun imst@ L
482 die die ck_fun dimst@ L
483 reset reset ck_fun is% S?
485 lineseq line sequence ck_null @
486 nextstate next statement ck_null s;
487 dbstate debug next statement ck_null s;
488 unstack unstack ck_null s0
489 enter block entry ck_null 0
490 leave block exit ck_null @
491 scope block ck_null @
492 enteriter foreach loop entry ck_null d{
493 iter foreach loop iterator ck_null 0
494 enterloop loop entry ck_null d{
495 leaveloop loop exit ck_null 2
496 return return ck_null dm@ L
497 last last ck_null ds}
498 next next ck_null ds}
499 redo redo ck_null ds}
500 dump dump ck_null ds}
501 goto goto ck_null ds}
502 exit exit ck_fun ds% S?
504 #nswitch numeric switch ck_null d
505 #cswitch character switch ck_null d
509 open open ck_fun ist@ F S?
510 close close ck_fun is% F?
511 pipe_op pipe ck_fun is@ F F
513 fileno fileno ck_fun ist% F
514 umask umask ck_fun ist% S?
515 binmode binmode ck_fun s% F
517 tie tie ck_fun idms@ R S L
518 untie untie ck_fun is% R
519 tied tied ck_fun s% R
520 dbmopen dbmopen ck_fun is@ H S S
521 dbmclose dbmclose ck_fun is% H
523 sselect select system call ck_select t@ S S S S
524 select select ck_select st@ F?
526 getc getc ck_eof st% F?
527 read read ck_fun imst@ F R S S?
528 enterwrite write ck_fun dis% F?
529 leavewrite write exit ck_null 1
531 prtf printf ck_listiob ims@ F? L
532 print print ck_listiob ims@ F? L
534 sysopen sysopen ck_fun s@ F S S S?
535 sysseek sysseek ck_fun s@ F S S
536 sysread sysread ck_fun imst@ F R S S?
537 syswrite syswrite ck_fun imst@ F S S? S?
539 send send ck_fun imst@ F S S S?
540 recv recv ck_fun imst@ F R S S
542 eof eof ck_eof is% F?
543 tell tell ck_fun st% F?
544 seek seek ck_fun s@ F S S
545 # truncate really behaves as if it had both "S S" and "F S"
546 truncate truncate ck_trunc is@ S S
548 fcntl fcntl ck_fun st@ F S S
549 ioctl ioctl ck_fun st@ F S S
550 flock flock ck_fun ist@ F S
554 socket socket ck_fun is@ F S S S
555 sockpair socketpair ck_fun is@ F F S S S
557 bind bind ck_fun is@ F S
558 connect connect ck_fun is@ F S
559 listen listen ck_fun is@ F S
560 accept accept ck_fun ist@ F F
561 shutdown shutdown ck_fun ist@ F S
563 gsockopt getsockopt ck_fun is@ F S S
564 ssockopt setsockopt ck_fun is@ F S S S
566 getsockname getsockname ck_fun is% F
567 getpeername getpeername ck_fun is% F
571 lstat lstat ck_ftst u- F
572 stat stat ck_ftst u- F
573 ftrread -R ck_ftst isu- F
574 ftrwrite -W ck_ftst isu- F
575 ftrexec -X ck_ftst isu- F
576 fteread -r ck_ftst isu- F
577 ftewrite -w ck_ftst isu- F
578 fteexec -x ck_ftst isu- F
579 ftis -e ck_ftst isu- F
580 fteowned -O ck_ftst isu- F
581 ftrowned -o ck_ftst isu- F
582 ftzero -z ck_ftst isu- F
583 ftsize -s ck_ftst istu- F
584 ftmtime -M ck_ftst stu- F
585 ftatime -A ck_ftst stu- F
586 ftctime -C ck_ftst stu- F
587 ftsock -S ck_ftst isu- F
588 ftchr -c ck_ftst isu- F
589 ftblk -b ck_ftst isu- F
590 ftfile -f ck_ftst isu- F
591 ftdir -d ck_ftst isu- F
592 ftpipe -p ck_ftst isu- F
593 ftlink -l ck_ftst isu- F
594 ftsuid -u ck_ftst isu- F
595 ftsgid -g ck_ftst isu- F
596 ftsvtx -k ck_ftst isu- F
597 fttty -t ck_ftst is- F
598 fttext -T ck_ftst isu- F
599 ftbinary -B ck_ftst isu- F
603 chdir chdir ck_fun ist% S?
604 chown chown ck_fun imst@ L
605 chroot chroot ck_fun istu% S?
606 unlink unlink ck_fun imstu@ L
607 chmod chmod ck_fun imst@ L
608 utime utime ck_fun imst@ L
609 rename rename ck_fun ist@ S S
610 link link ck_fun ist@ S S
611 symlink symlink ck_fun ist@ S S
612 readlink readlink ck_fun stu% S?
613 mkdir mkdir ck_fun ist@ S S
614 rmdir rmdir ck_fun istu% S?
618 open_dir opendir ck_fun is@ F S
619 readdir readdir ck_fun % F
620 telldir telldir ck_fun st% F
621 seekdir seekdir ck_fun s@ F S
622 rewinddir rewinddir ck_fun s% F
623 closedir closedir ck_fun is% F
627 fork fork ck_null ist0
628 wait wait ck_null ist0
629 waitpid waitpid ck_fun ist@ S S
630 system system ck_exec imst@ S? L
631 exec exec ck_exec dimst@ S? L
632 kill kill ck_fun dimst@ L
633 getppid getppid ck_null ist0
634 getpgrp getpgrp ck_fun ist% S?
635 setpgrp setpgrp ck_fun ist@ S? S?
636 getpriority getpriority ck_fun ist@ S S
637 setpriority setpriority ck_fun ist@ S S S
641 time time ck_null ist0
643 localtime localtime ck_fun t% S?
644 gmtime gmtime ck_fun t% S?
645 alarm alarm ck_fun istu% S?
646 sleep sleep ck_fun ist% S?
650 shmget shmget ck_fun imst@ S S S
651 shmctl shmctl ck_fun imst@ S S S
652 shmread shmread ck_fun imst@ S S S S
653 shmwrite shmwrite ck_fun imst@ S S S S
657 msgget msgget ck_fun imst@ S S
658 msgctl msgctl ck_fun imst@ S S S
659 msgsnd msgsnd ck_fun imst@ S S S
660 msgrcv msgrcv ck_fun imst@ S S S S S
664 semget semget ck_fun imst@ S S S
665 semctl semctl ck_fun imst@ S S S S
666 semop semop ck_fun imst@ S S
670 require require ck_require du% S?
671 dofile do 'file' ck_fun d1 S
672 entereval eval string ck_eval d% S
673 leaveeval eval exit ck_null 1 S
674 #evalonce eval constant string ck_null d1 S
675 entertry eval block ck_null |
676 leavetry eval block exit ck_null @
680 ghbyname gethostbyname ck_fun % S
681 ghbyaddr gethostbyaddr ck_fun @ S S
682 ghostent gethostent ck_null 0
683 gnbyname getnetbyname ck_fun % S
684 gnbyaddr getnetbyaddr ck_fun @ S S
685 gnetent getnetent ck_null 0
686 gpbyname getprotobyname ck_fun % S
687 gpbynumber getprotobynumber ck_fun @ S
688 gprotoent getprotoent ck_null 0
689 gsbyname getservbyname ck_fun @ S S
690 gsbyport getservbyport ck_fun @ S S
691 gservent getservent ck_null 0
692 shostent sethostent ck_fun is% S
693 snetent setnetent ck_fun is% S
694 sprotoent setprotoent ck_fun is% S
695 sservent setservent ck_fun is% S
696 ehostent endhostent ck_null is0
697 enetent endnetent ck_null is0
698 eprotoent endprotoent ck_null is0
699 eservent endservent ck_null is0
700 gpwnam getpwnam ck_fun % S
701 gpwuid getpwuid ck_fun % S
702 gpwent getpwent ck_null 0
703 spwent setpwent ck_null is0
704 epwent endpwent ck_null is0
705 ggrnam getgrnam ck_fun % S
706 ggrgid getgrgid ck_fun % S
707 ggrent getgrent ck_null 0
708 sgrent setgrent ck_null is0
709 egrent endgrent ck_null is0
710 getlogin getlogin ck_null st0
714 syscall syscall ck_fun imst@ S L
716 # For multi-threading
717 lock lock ck_rfun s% S
718 threadsv per-thread variable ck_null ds0