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);
85 # Emit function declarations.
87 for (sort keys %ckname) {
88 print "OP *\t", &tab(3,$_),"_((OP* o));\n";
94 print "OP *\t", &tab(3, "pp_$_"), "_((ARGSproto));\n";
97 # Emit ppcode switch array.
102 #endif /* PERL_OBJECT */
105 EXT OP * (CPERLscope(*ppaddr)[])(ARGSproto);
108 EXT OP * (CPERLscope(*ppaddr)[])(ARGSproto) = {
117 #endif /* PERL_OBJECT */
122 # Emit check routines.
126 EXT OP * (CPERLscope(*check)[]) _((OP *op));
129 EXT OP * (CPERLscope(*check)[]) _((OP *op)) = {
133 print "\t", &tab(3, "$check{$_},"), "/* $_ */\n";
138 #endif /* PERL_OBJECT */
143 # Emit allowed argument types.
159 R, 7, # scalar reference
175 '%', 12, # baseop_or_unop
176 '-', 13, # filestatop
183 $argsum |= 1 if $flags =~ /m/; # needs stack mark
184 $argsum |= 2 if $flags =~ /f/; # fold constants
185 $argsum |= 4 if $flags =~ /s/; # always produces scalar
186 $argsum |= 8 if $flags =~ /t/; # needs target scalar
187 $argsum |= 16 if $flags =~ /i/; # always produces integer
188 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
189 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
190 $argsum |= 128 if $flags =~ /u/; # defaults to $_
192 $flags =~ /([^a-zA-Z])/ or die qq[Opcode "$_" has no class indicator];
193 $argsum |= $opclass{$1} << 8;
194 $mul = 4096; # 2 ^ OASHIFT
195 for $arg (split(' ',$args{$_})) {
196 $argnum = ($arg =~ s/\?//) ? 8 : 0;
197 $argnum += $argnum{$arg};
198 $argsum += $argnum * $mul;
201 $argsum = sprintf("0x%08x", $argsum);
202 print "\t", &tab(3, "$argsum,"), "/* $_ */\n";
210 close OC or die "Error closing opcode.h: $!";
212 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
214 next if /^i_(pre|post)(inc|dec)$/;
215 print PP "PPDEF(pp_$_)\n";
218 close PP or die "Error closing pp_proto.h: $!";
220 ###########################################################################
223 $t .= "\t" x ($l - (length($t) + 1) / 8);
226 ###########################################################################
231 null null operation ck_null 0
233 scalar scalar ck_fun s% S
237 pushmark pushmark ck_null s0
238 wantarray wantarray ck_null is0
240 const constant item ck_svconst s$
242 gvsv scalar variable ck_null ds*
243 gv glob value ck_null ds*
244 gelem glob elem ck_null d2 S S
245 padsv private variable ck_null ds0
246 padav private array ck_null d0
247 padhv private hash ck_null d0
248 padany private something ck_null d0
250 pushre push regexp ck_null /
252 # References and stuff.
254 rv2gv ref-to-glob cast ck_rvconst ds1
255 rv2sv scalar deref ck_rvconst ds1
256 av2arylen array length ck_null is1
257 rv2cv subroutine deref ck_rvconst d1
258 anoncode anonymous subroutine ck_anoncode $
259 prototype subroutine prototype ck_null s% S
260 refgen reference constructor ck_spair m1 L
261 srefgen scalar ref constructor ck_null fs1 S
262 ref reference-type operator ck_fun stu% S?
263 bless bless ck_fun s@ S S?
267 backtick backticks ck_null t%
268 # glob defaults its first arg to $_
269 glob glob ck_glob t@ S? S?
270 readline <HANDLE> ck_null t%
271 rcatline append I/O operator ck_null t%
273 # Bindable operators.
275 regcmaybe regexp comp once ck_fun s1 S
276 regcomp regexp compilation ck_null s| S
277 match pattern match ck_match d/
278 subst substitution ck_null dis/ S
279 substcont substitution cont ck_null dis|
280 trans character translation ck_null is" S
283 # sassign is special-cased for op class
285 sassign scalar assignment ck_null s0
286 aassign list assignment ck_null t2 L L
288 chop chop ck_spair mts% L
289 schop scalar chop ck_null stu% S?
290 chomp safe chop ck_spair mts% L
291 schomp scalar safe chop ck_null stu% S?
292 defined defined operator ck_rfun isu% S?
293 undef undef operator ck_lfun s% S?
294 study study ck_fun su% S?
295 pos match position ck_lfun stu% S?
297 preinc preincrement ck_lfun dIs1 S
298 i_preinc integer preincrement ck_lfun dis1 S
299 predec predecrement ck_lfun dIs1 S
300 i_predec integer predecrement ck_lfun dis1 S
301 postinc postincrement ck_lfun dIst1 S
302 i_postinc integer postincrement ck_lfun dist1 S
303 postdec postdecrement ck_lfun dIst1 S
304 i_postdec integer postdecrement ck_lfun dist1 S
306 # Ordinary operators.
308 pow exponentiation ck_null fst2 S S
310 multiply multiplication ck_null Ifst2 S S
311 i_multiply integer multiplication ck_null ifst2 S S
312 divide division ck_null Ifst2 S S
313 i_divide integer division ck_null ifst2 S S
314 modulo modulus ck_null Iifst2 S S
315 i_modulo integer modulus ck_null ifst2 S S
316 repeat repeat ck_repeat mt2 L S
318 add addition ck_null Ifst2 S S
319 i_add integer addition ck_null ifst2 S S
320 subtract subtraction ck_null Ifst2 S S
321 i_subtract integer subtraction ck_null ifst2 S S
322 concat concatenation ck_concat fst2 S S
323 stringify string ck_fun fst@ S
325 left_shift left bitshift ck_bitop fst2 S S
326 right_shift right bitshift ck_bitop fst2 S S
328 lt numeric lt ck_null Iifs2 S S
329 i_lt integer lt ck_null ifs2 S S
330 gt numeric gt ck_null Iifs2 S S
331 i_gt integer gt ck_null ifs2 S S
332 le numeric le ck_null Iifs2 S S
333 i_le integer le ck_null ifs2 S S
334 ge numeric ge ck_null Iifs2 S S
335 i_ge integer ge ck_null ifs2 S S
336 eq numeric eq ck_null Iifs2 S S
337 i_eq integer eq ck_null ifs2 S S
338 ne numeric ne ck_null Iifs2 S S
339 i_ne integer ne ck_null ifs2 S S
340 ncmp spaceship operator ck_null Iifst2 S S
341 i_ncmp integer spaceship ck_null ifst2 S S
343 slt string lt ck_scmp ifs2 S S
344 sgt string gt ck_scmp ifs2 S S
345 sle string le ck_scmp ifs2 S S
346 sge string ge ck_scmp ifs2 S S
347 seq string eq ck_null ifs2 S S
348 sne string ne ck_null ifs2 S S
349 scmp string comparison ck_scmp ifst2 S S
351 bit_and bitwise and ck_bitop fst2 S S
352 bit_xor bitwise xor ck_bitop fst2 S S
353 bit_or bitwise or ck_bitop fst2 S S
355 negate negate ck_null Ifst1 S
356 i_negate integer negate ck_null ifst1 S
357 not not ck_null ifs1 S
358 complement 1's complement ck_bitop fst1 S
360 # High falutin' math.
362 atan2 atan2 ck_fun fst@ S S
363 sin sin ck_fun fstu% S?
364 cos cos ck_fun fstu% S?
365 rand rand ck_fun st% S?
366 srand srand ck_fun s% S?
367 exp exp ck_fun fstu% S?
368 log log ck_fun fstu% S?
369 sqrt sqrt ck_fun fstu% S?
373 int int ck_fun fstu% S?
374 hex hex ck_fun fstu% S?
375 oct oct ck_fun fstu% S?
376 abs abs ck_fun fstu% S?
380 length length ck_lengthconst istu% S?
381 substr substr ck_fun st@ S S S? S?
382 vec vec ck_fun ist@ S S S
384 index index ck_index ist@ S S S?
385 rindex rindex ck_index ist@ S S S?
387 sprintf sprintf ck_fun_locale mfst@ S L
388 formline formline ck_fun ms@ S L
389 ord ord ck_fun ifstu% S?
390 chr chr ck_fun fstu% S?
391 crypt crypt ck_fun fst@ S S
392 ucfirst upper case first ck_fun_locale fstu% S?
393 lcfirst lower case first ck_fun_locale fstu% S?
394 uc upper case ck_fun_locale fstu% S?
395 lc lower case ck_fun_locale fstu% S?
396 quotemeta quote metachars ck_fun fstu% S?
400 rv2av array deref ck_rvconst dt1
401 aelemfast known array element ck_null s* A S
402 aelem array element ck_null s2 A S
403 aslice array slice ck_null m@ A L
407 each each ck_fun t% H
408 values values ck_fun t% H
409 keys keys ck_fun t% H
410 delete delete ck_delete % S
411 exists exists operator ck_exists is% S
412 rv2hv hash deref ck_rvconst dt1
413 helem hash elem ck_null s2@ H S
414 hslice hash slice ck_null m@ H L
416 # Explosives and implosives.
418 unpack unpack ck_fun @ S S
419 pack pack ck_fun mst@ S L
420 split split ck_split t@ S S S
421 join join ck_fun mst@ S L
425 list list ck_null m@ L
426 lslice list slice ck_null 2 H L L
427 anonlist anonymous list ck_fun ms@ L
428 anonhash anonymous hash ck_fun ms@ L
430 splice splice ck_fun m@ A S? S? L
431 push push ck_fun imst@ A L
432 pop pop ck_shift si% A
433 shift shift ck_shift s% A
434 unshift unshift ck_fun imst@ A L
435 sort sort ck_sort m@ C? L
436 reverse reverse ck_fun mt@ L
438 grepstart grep ck_grep dm@ C L
439 grepwhile grep iterator ck_null dt|
441 mapstart map ck_grep dm@ C L
442 mapwhile map iterator ck_null dt|
446 range flipflop ck_null ? S S
447 flip range (or flip) ck_null 1 S S
448 flop range (or flop) ck_null 1
452 and logical and ck_null |
453 or logical or ck_null |
454 xor logical xor ck_null fs| S S
455 cond_expr conditional expression ck_null d?
456 andassign logical and assignment ck_null s|
457 orassign logical or assignment ck_null s|
459 method method lookup ck_null d1
460 entersub subroutine entry ck_subr dmt1 L
461 leavesub subroutine exit ck_null 1
462 caller caller ck_fun t% S?
463 warn warn ck_fun imst@ L
464 die die ck_fun dimst@ L
465 reset reset ck_fun is% S?
467 lineseq line sequence ck_null @
468 nextstate next statement ck_null s;
469 dbstate debug next statement ck_null s;
470 unstack unstack ck_null s0
471 enter block entry ck_null 0
472 leave block exit ck_null @
473 scope block ck_null @
474 enteriter foreach loop entry ck_null d{
475 iter foreach loop iterator ck_null 0
476 enterloop loop entry ck_null d{
477 leaveloop loop exit ck_null 2
478 return return ck_null dm@ L
479 last last ck_null ds}
480 next next ck_null ds}
481 redo redo ck_null ds}
482 dump dump ck_null ds}
483 goto goto ck_null ds}
484 exit exit ck_fun ds% S?
486 #nswitch numeric switch ck_null d
487 #cswitch character switch ck_null d
491 open open ck_fun ist@ F S?
492 close close ck_fun is% F?
493 pipe_op pipe ck_fun is@ F F
495 fileno fileno ck_fun ist% F
496 umask umask ck_fun ist% S?
497 binmode binmode ck_fun s% F
499 tie tie ck_fun idms@ R S L
500 untie untie ck_fun is% R
501 tied tied ck_fun s% R
502 dbmopen dbmopen ck_fun is@ H S S
503 dbmclose dbmclose ck_fun is% H
505 sselect select system call ck_select t@ S S S S
506 select select ck_select st@ F?
508 getc getc ck_eof st% F?
509 read read ck_fun imst@ F R S S?
510 enterwrite write ck_fun dis% F?
511 leavewrite write exit ck_null 1
513 prtf printf ck_listiob ims@ F? L
514 print print ck_listiob ims@ F? L
516 sysopen sysopen ck_fun s@ F S S S?
517 sysseek sysseek ck_fun s@ F S S
518 sysread sysread ck_fun imst@ F R S S?
519 syswrite syswrite ck_fun imst@ F S S S?
521 send send ck_fun imst@ F S S S?
522 recv recv ck_fun imst@ F R S S
524 eof eof ck_eof is% F?
525 tell tell ck_fun st% F?
526 seek seek ck_fun s@ F S S
527 # truncate really behaves as if it had both "S S" and "F S"
528 truncate truncate ck_trunc is@ S S
530 fcntl fcntl ck_fun st@ F S S
531 ioctl ioctl ck_fun st@ F S S
532 flock flock ck_fun ist@ F S
536 socket socket ck_fun is@ F S S S
537 sockpair socketpair ck_fun is@ F F S S S
539 bind bind ck_fun is@ F S
540 connect connect ck_fun is@ F S
541 listen listen ck_fun is@ F S
542 accept accept ck_fun ist@ F F
543 shutdown shutdown ck_fun ist@ F S
545 gsockopt getsockopt ck_fun is@ F S S
546 ssockopt setsockopt ck_fun is@ F S S S
548 getsockname getsockname ck_fun is% F
549 getpeername getpeername ck_fun is% F
553 lstat lstat ck_ftst u- F
554 stat stat ck_ftst u- F
555 ftrread -R ck_ftst isu- F
556 ftrwrite -W ck_ftst isu- F
557 ftrexec -X ck_ftst isu- F
558 fteread -r ck_ftst isu- F
559 ftewrite -w ck_ftst isu- F
560 fteexec -x ck_ftst isu- F
561 ftis -e ck_ftst isu- F
562 fteowned -O ck_ftst isu- F
563 ftrowned -o ck_ftst isu- F
564 ftzero -z ck_ftst isu- F
565 ftsize -s ck_ftst istu- F
566 ftmtime -M ck_ftst stu- F
567 ftatime -A ck_ftst stu- F
568 ftctime -C ck_ftst stu- F
569 ftsock -S ck_ftst isu- F
570 ftchr -c ck_ftst isu- F
571 ftblk -b ck_ftst isu- F
572 ftfile -f ck_ftst isu- F
573 ftdir -d ck_ftst isu- F
574 ftpipe -p ck_ftst isu- F
575 ftlink -l ck_ftst isu- F
576 ftsuid -u ck_ftst isu- F
577 ftsgid -g ck_ftst isu- F
578 ftsvtx -k ck_ftst isu- F
579 fttty -t ck_ftst is- F
580 fttext -T ck_ftst isu- F
581 ftbinary -B ck_ftst isu- F
585 chdir chdir ck_fun ist% S?
586 chown chown ck_fun imst@ L
587 chroot chroot ck_fun istu% S?
588 unlink unlink ck_fun imstu@ L
589 chmod chmod ck_fun imst@ L
590 utime utime ck_fun imst@ L
591 rename rename ck_fun ist@ S S
592 link link ck_fun ist@ S S
593 symlink symlink ck_fun ist@ S S
594 readlink readlink ck_fun stu% S?
595 mkdir mkdir ck_fun ist@ S S
596 rmdir rmdir ck_fun istu% S?
600 open_dir opendir ck_fun is@ F S
601 readdir readdir ck_fun % F
602 telldir telldir ck_fun st% F
603 seekdir seekdir ck_fun s@ F S
604 rewinddir rewinddir ck_fun s% F
605 closedir closedir ck_fun is% F
609 fork fork ck_null ist0
610 wait wait ck_null ist0
611 waitpid waitpid ck_fun ist@ S S
612 system system ck_exec imst@ S? L
613 exec exec ck_exec dimst@ S? L
614 kill kill ck_fun dimst@ L
615 getppid getppid ck_null ist0
616 getpgrp getpgrp ck_fun ist% S?
617 setpgrp setpgrp ck_fun ist@ S? S?
618 getpriority getpriority ck_fun ist@ S S
619 setpriority setpriority ck_fun ist@ S S S
623 time time ck_null ist0
625 localtime localtime ck_fun t% S?
626 gmtime gmtime ck_fun t% S?
627 alarm alarm ck_fun istu% S?
628 sleep sleep ck_fun ist% S?
632 shmget shmget ck_fun imst@ S S S
633 shmctl shmctl ck_fun imst@ S S S
634 shmread shmread ck_fun imst@ S S S S
635 shmwrite shmwrite ck_fun imst@ S S S S
639 msgget msgget ck_fun imst@ S S
640 msgctl msgctl ck_fun imst@ S S S
641 msgsnd msgsnd ck_fun imst@ S S S
642 msgrcv msgrcv ck_fun imst@ S S S S S
646 semget semget ck_fun imst@ S S S
647 semctl semctl ck_fun imst@ S S S S
648 semop semop ck_fun imst@ S S
652 require require ck_require du% S?
653 dofile do 'file' ck_fun d1 S
654 entereval eval string ck_eval d% S
655 leaveeval eval exit ck_null 1 S
656 #evalonce eval constant string ck_null d1 S
657 entertry eval block ck_null |
658 leavetry eval block exit ck_null @
662 ghbyname gethostbyname ck_fun % S
663 ghbyaddr gethostbyaddr ck_fun @ S S
664 ghostent gethostent ck_null 0
665 gnbyname getnetbyname ck_fun % S
666 gnbyaddr getnetbyaddr ck_fun @ S S
667 gnetent getnetent ck_null 0
668 gpbyname getprotobyname ck_fun % S
669 gpbynumber getprotobynumber ck_fun @ S
670 gprotoent getprotoent ck_null 0
671 gsbyname getservbyname ck_fun @ S S
672 gsbyport getservbyport ck_fun @ S S
673 gservent getservent ck_null 0
674 shostent sethostent ck_fun is% S
675 snetent setnetent ck_fun is% S
676 sprotoent setprotoent ck_fun is% S
677 sservent setservent ck_fun is% S
678 ehostent endhostent ck_null is0
679 enetent endnetent ck_null is0
680 eprotoent endprotoent ck_null is0
681 eservent endservent ck_null is0
682 gpwnam getpwnam ck_fun % S
683 gpwuid getpwuid ck_fun % S
684 gpwent getpwent ck_null 0
685 spwent setpwent ck_null is0
686 epwent endpwent ck_null is0
687 ggrnam getgrnam ck_fun % S
688 ggrgid getgrgid ck_fun % S
689 ggrent getgrent ck_null 0
690 sgrent setgrent ck_null is0
691 egrent endgrent ck_null is0
692 getlogin getlogin ck_null st0
696 syscall syscall ck_fun imst@ S L
698 # For multi-threading
699 lock lock ck_rfun s% S
700 threadsv per-thread variable ck_null ds0