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: $!";
213 open PP, '>pp_proto.h' or die "Error creating pp_proto.h: $!";
215 next if /^i_(pre|post)(inc|dec)$/;
216 print PP "PPDEF(pp_$_)\n";
219 close PP or die "Error closing pp_proto.h: $!";
221 ###########################################################################
224 $t .= "\t" x ($l - (length($t) + 1) / 8);
227 ###########################################################################
232 null null operation ck_null 0
234 scalar scalar ck_fun s% S
238 pushmark pushmark ck_null s0
239 wantarray wantarray ck_null is0
241 const constant item ck_svconst s$
243 gvsv scalar variable ck_null ds*
244 gv glob value ck_null ds*
245 gelem glob elem ck_null d2 S S
246 padsv private variable ck_null ds0
247 padav private array ck_null d0
248 padhv private hash ck_null d0
249 padany private something ck_null d0
251 pushre push regexp ck_null d/
253 # References and stuff.
255 rv2gv ref-to-glob cast ck_rvconst ds1
256 rv2sv scalar deref ck_rvconst ds1
257 av2arylen array length ck_null is1
258 rv2cv subroutine deref ck_rvconst d1
259 anoncode anonymous subroutine ck_anoncode $
260 prototype subroutine prototype ck_null s% S
261 refgen reference constructor ck_spair m1 L
262 srefgen scalar ref constructor ck_null fs1 S
263 ref reference-type operator ck_fun stu% S?
264 bless bless ck_fun s@ S S?
268 backtick backticks ck_null t%
269 # glob defaults its first arg to $_
270 glob glob ck_glob t@ S? S?
271 readline <HANDLE> ck_null t%
272 rcatline append I/O operator ck_null t%
274 # Bindable operators.
276 regcmaybe regexp comp once ck_fun s1 S
277 regcreset regexp reset interpolation flag ck_fun s1 S
278 regcomp regexp compilation ck_null s| S
279 match pattern match ck_match d/
280 subst substitution ck_null dis/ S
281 substcont substitution cont ck_null dis|
282 trans character translation ck_null is" S
285 # sassign is special-cased for op class
287 sassign scalar assignment ck_null s0
288 aassign list assignment ck_null t2 L L
290 chop chop ck_spair mts% L
291 schop scalar chop ck_null stu% S?
292 chomp safe chop ck_spair mts% L
293 schomp scalar safe chop ck_null stu% S?
294 defined defined operator ck_rfun isu% S?
295 undef undef operator ck_lfun s% S?
296 study study ck_fun su% S?
297 pos match position ck_lfun stu% S?
299 preinc preincrement ck_lfun dIs1 S
300 i_preinc integer preincrement ck_lfun dis1 S
301 predec predecrement ck_lfun dIs1 S
302 i_predec integer predecrement ck_lfun dis1 S
303 postinc postincrement ck_lfun dIst1 S
304 i_postinc integer postincrement ck_lfun dist1 S
305 postdec postdecrement ck_lfun dIst1 S
306 i_postdec integer postdecrement ck_lfun dist1 S
308 # Ordinary operators.
310 pow exponentiation ck_null fst2 S S
312 multiply multiplication ck_null Ifst2 S S
313 i_multiply integer multiplication ck_null ifst2 S S
314 divide division ck_null Ifst2 S S
315 i_divide integer division ck_null ifst2 S S
316 modulo modulus ck_null Iifst2 S S
317 i_modulo integer modulus ck_null ifst2 S S
318 repeat repeat ck_repeat mt2 L S
320 add addition ck_null Ifst2 S S
321 i_add integer addition ck_null ifst2 S S
322 subtract subtraction ck_null Ifst2 S S
323 i_subtract integer subtraction ck_null ifst2 S S
324 concat concatenation ck_concat fst2 S S
325 stringify string ck_fun fst@ S
327 left_shift left bitshift ck_bitop fst2 S S
328 right_shift right bitshift ck_bitop fst2 S S
330 lt numeric lt ck_null Iifs2 S S
331 i_lt integer lt ck_null ifs2 S S
332 gt numeric gt ck_null Iifs2 S S
333 i_gt integer gt ck_null ifs2 S S
334 le numeric le ck_null Iifs2 S S
335 i_le integer le ck_null ifs2 S S
336 ge numeric ge ck_null Iifs2 S S
337 i_ge integer ge ck_null ifs2 S S
338 eq numeric eq ck_null Iifs2 S S
339 i_eq integer eq ck_null ifs2 S S
340 ne numeric ne ck_null Iifs2 S S
341 i_ne integer ne ck_null ifs2 S S
342 ncmp spaceship operator ck_null Iifst2 S S
343 i_ncmp integer spaceship ck_null ifst2 S S
345 slt string lt ck_scmp ifs2 S S
346 sgt string gt ck_scmp ifs2 S S
347 sle string le ck_scmp ifs2 S S
348 sge string ge ck_scmp ifs2 S S
349 seq string eq ck_null ifs2 S S
350 sne string ne ck_null ifs2 S S
351 scmp string comparison ck_scmp ifst2 S S
353 bit_and bitwise and ck_bitop fst2 S S
354 bit_xor bitwise xor ck_bitop fst2 S S
355 bit_or bitwise or ck_bitop fst2 S S
357 negate negate ck_null Ifst1 S
358 i_negate integer negate ck_null ifst1 S
359 not not ck_null ifs1 S
360 complement 1's complement ck_bitop fst1 S
362 # High falutin' math.
364 atan2 atan2 ck_fun fst@ S S
365 sin sin ck_fun fstu% S?
366 cos cos ck_fun fstu% S?
367 rand rand ck_fun st% S?
368 srand srand ck_fun s% S?
369 exp exp ck_fun fstu% S?
370 log log ck_fun fstu% S?
371 sqrt sqrt ck_fun fstu% S?
375 int int ck_fun fstu% S?
376 hex hex ck_fun fstu% S?
377 oct oct ck_fun fstu% S?
378 abs abs ck_fun fstu% S?
382 length length ck_lengthconst istu% S?
383 substr substr ck_fun st@ S S S? S?
384 vec vec ck_fun ist@ S S S
386 index index ck_index ist@ S S S?
387 rindex rindex ck_index ist@ S S S?
389 sprintf sprintf ck_fun_locale mfst@ S L
390 formline formline ck_fun ms@ S L
391 ord ord ck_fun ifstu% S?
392 chr chr ck_fun fstu% S?
393 crypt crypt ck_fun fst@ S S
394 ucfirst upper case first ck_fun_locale fstu% S?
395 lcfirst lower case first ck_fun_locale fstu% S?
396 uc upper case ck_fun_locale fstu% S?
397 lc lower case ck_fun_locale fstu% S?
398 quotemeta quote metachars ck_fun fstu% S?
402 rv2av array deref ck_rvconst dt1
403 aelemfast known array element ck_null s* A S
404 aelem array element ck_null s2 A S
405 aslice array slice ck_null m@ A L
409 each each ck_fun t% H
410 values values ck_fun t% H
411 keys keys ck_fun t% H
412 delete delete ck_delete % S
413 exists exists operator ck_exists is% S
414 rv2hv hash deref ck_rvconst dt1
415 helem hash elem ck_null s2@ H S
416 hslice hash slice ck_null m@ H L
418 # Explosives and implosives.
420 unpack unpack ck_fun @ S S
421 pack pack ck_fun mst@ S L
422 split split ck_split t@ S S S
423 join join ck_fun mst@ S L
427 list list ck_null m@ L
428 lslice list slice ck_null 2 H L L
429 anonlist anonymous list ck_fun ms@ L
430 anonhash anonymous hash ck_fun ms@ L
432 splice splice ck_fun m@ A S? S? L
433 push push ck_fun imst@ A L
434 pop pop ck_shift si% A
435 shift shift ck_shift s% A
436 unshift unshift ck_fun imst@ A L
437 sort sort ck_sort m@ C? L
438 reverse reverse ck_fun mt@ L
440 grepstart grep ck_grep dm@ C L
441 grepwhile grep iterator ck_null dt|
443 mapstart map ck_grep dm@ C L
444 mapwhile map iterator ck_null dt|
448 range flipflop ck_null ? S S
449 flip range (or flip) ck_null 1 S S
450 flop range (or flop) ck_null 1
454 and logical and ck_null |
455 or logical or ck_null |
456 xor logical xor ck_null fs| S S
457 cond_expr conditional expression ck_null d?
458 andassign logical and assignment ck_null s|
459 orassign logical or assignment ck_null s|
461 method method lookup ck_null d1
462 entersub subroutine entry ck_subr dmt1 L
463 leavesub subroutine exit ck_null 1
464 caller caller ck_fun t% S?
465 warn warn ck_fun imst@ L
466 die die ck_fun dimst@ L
467 reset reset ck_fun is% S?
469 lineseq line sequence ck_null @
470 nextstate next statement ck_null s;
471 dbstate debug next statement ck_null s;
472 unstack unstack ck_null s0
473 enter block entry ck_null 0
474 leave block exit ck_null @
475 scope block ck_null @
476 enteriter foreach loop entry ck_null d{
477 iter foreach loop iterator ck_null 0
478 enterloop loop entry ck_null d{
479 leaveloop loop exit ck_null 2
480 return return ck_null dm@ L
481 last last ck_null ds}
482 next next ck_null ds}
483 redo redo ck_null ds}
484 dump dump ck_null ds}
485 goto goto ck_null ds}
486 exit exit ck_fun ds% S?
488 #nswitch numeric switch ck_null d
489 #cswitch character switch ck_null d
493 open open ck_fun ist@ F S?
494 close close ck_fun is% F?
495 pipe_op pipe ck_fun is@ F F
497 fileno fileno ck_fun ist% F
498 umask umask ck_fun ist% S?
499 binmode binmode ck_fun s% F
501 tie tie ck_fun idms@ R S L
502 untie untie ck_fun is% R
503 tied tied ck_fun s% R
504 dbmopen dbmopen ck_fun is@ H S S
505 dbmclose dbmclose ck_fun is% H
507 sselect select system call ck_select t@ S S S S
508 select select ck_select st@ F?
510 getc getc ck_eof st% F?
511 read read ck_fun imst@ F R S S?
512 enterwrite write ck_fun dis% F?
513 leavewrite write exit ck_null 1
515 prtf printf ck_listiob ims@ F? L
516 print print ck_listiob ims@ F? L
518 sysopen sysopen ck_fun s@ F S S S?
519 sysseek sysseek ck_fun s@ F S S
520 sysread sysread ck_fun imst@ F R S S?
521 syswrite syswrite ck_fun imst@ F S S S?
523 send send ck_fun imst@ F S S S?
524 recv recv ck_fun imst@ F R S S
526 eof eof ck_eof is% F?
527 tell tell ck_fun st% F?
528 seek seek ck_fun s@ F S S
529 # truncate really behaves as if it had both "S S" and "F S"
530 truncate truncate ck_trunc is@ S S
532 fcntl fcntl ck_fun st@ F S S
533 ioctl ioctl ck_fun st@ F S S
534 flock flock ck_fun ist@ F S
538 socket socket ck_fun is@ F S S S
539 sockpair socketpair ck_fun is@ F F S S S
541 bind bind ck_fun is@ F S
542 connect connect ck_fun is@ F S
543 listen listen ck_fun is@ F S
544 accept accept ck_fun ist@ F F
545 shutdown shutdown ck_fun ist@ F S
547 gsockopt getsockopt ck_fun is@ F S S
548 ssockopt setsockopt ck_fun is@ F S S S
550 getsockname getsockname ck_fun is% F
551 getpeername getpeername ck_fun is% F
555 lstat lstat ck_ftst u- F
556 stat stat ck_ftst u- F
557 ftrread -R ck_ftst isu- F
558 ftrwrite -W ck_ftst isu- F
559 ftrexec -X ck_ftst isu- F
560 fteread -r ck_ftst isu- F
561 ftewrite -w ck_ftst isu- F
562 fteexec -x ck_ftst isu- F
563 ftis -e ck_ftst isu- F
564 fteowned -O ck_ftst isu- F
565 ftrowned -o ck_ftst isu- F
566 ftzero -z ck_ftst isu- F
567 ftsize -s ck_ftst istu- F
568 ftmtime -M ck_ftst stu- F
569 ftatime -A ck_ftst stu- F
570 ftctime -C ck_ftst stu- F
571 ftsock -S ck_ftst isu- F
572 ftchr -c ck_ftst isu- F
573 ftblk -b ck_ftst isu- F
574 ftfile -f ck_ftst isu- F
575 ftdir -d ck_ftst isu- F
576 ftpipe -p ck_ftst isu- F
577 ftlink -l ck_ftst isu- F
578 ftsuid -u ck_ftst isu- F
579 ftsgid -g ck_ftst isu- F
580 ftsvtx -k ck_ftst isu- F
581 fttty -t ck_ftst is- F
582 fttext -T ck_ftst isu- F
583 ftbinary -B ck_ftst isu- F
587 chdir chdir ck_fun ist% S?
588 chown chown ck_fun imst@ L
589 chroot chroot ck_fun istu% S?
590 unlink unlink ck_fun imstu@ L
591 chmod chmod ck_fun imst@ L
592 utime utime ck_fun imst@ L
593 rename rename ck_fun ist@ S S
594 link link ck_fun ist@ S S
595 symlink symlink ck_fun ist@ S S
596 readlink readlink ck_fun stu% S?
597 mkdir mkdir ck_fun ist@ S S
598 rmdir rmdir ck_fun istu% S?
602 open_dir opendir ck_fun is@ F S
603 readdir readdir ck_fun % F
604 telldir telldir ck_fun st% F
605 seekdir seekdir ck_fun s@ F S
606 rewinddir rewinddir ck_fun s% F
607 closedir closedir ck_fun is% F
611 fork fork ck_null ist0
612 wait wait ck_null ist0
613 waitpid waitpid ck_fun ist@ S S
614 system system ck_exec imst@ S? L
615 exec exec ck_exec dimst@ S? L
616 kill kill ck_fun dimst@ L
617 getppid getppid ck_null ist0
618 getpgrp getpgrp ck_fun ist% S?
619 setpgrp setpgrp ck_fun ist@ S? S?
620 getpriority getpriority ck_fun ist@ S S
621 setpriority setpriority ck_fun ist@ S S S
625 time time ck_null ist0
627 localtime localtime ck_fun t% S?
628 gmtime gmtime ck_fun t% S?
629 alarm alarm ck_fun istu% S?
630 sleep sleep ck_fun ist% S?
634 shmget shmget ck_fun imst@ S S S
635 shmctl shmctl ck_fun imst@ S S S
636 shmread shmread ck_fun imst@ S S S S
637 shmwrite shmwrite ck_fun imst@ S S S S
641 msgget msgget ck_fun imst@ S S
642 msgctl msgctl ck_fun imst@ S S S
643 msgsnd msgsnd ck_fun imst@ S S S
644 msgrcv msgrcv ck_fun imst@ S S S S S
648 semget semget ck_fun imst@ S S S
649 semctl semctl ck_fun imst@ S S S S
650 semop semop ck_fun imst@ S S
654 require require ck_require du% S?
655 dofile do 'file' ck_fun d1 S
656 entereval eval string ck_eval d% S
657 leaveeval eval exit ck_null 1 S
658 #evalonce eval constant string ck_null d1 S
659 entertry eval block ck_null |
660 leavetry eval block exit ck_null @
664 ghbyname gethostbyname ck_fun % S
665 ghbyaddr gethostbyaddr ck_fun @ S S
666 ghostent gethostent ck_null 0
667 gnbyname getnetbyname ck_fun % S
668 gnbyaddr getnetbyaddr ck_fun @ S S
669 gnetent getnetent ck_null 0
670 gpbyname getprotobyname ck_fun % S
671 gpbynumber getprotobynumber ck_fun @ S
672 gprotoent getprotoent ck_null 0
673 gsbyname getservbyname ck_fun @ S S
674 gsbyport getservbyport ck_fun @ S S
675 gservent getservent ck_null 0
676 shostent sethostent ck_fun is% S
677 snetent setnetent ck_fun is% S
678 sprotoent setprotoent ck_fun is% S
679 sservent setservent ck_fun is% S
680 ehostent endhostent ck_null is0
681 enetent endnetent ck_null is0
682 eprotoent endprotoent ck_null is0
683 eservent endservent ck_null is0
684 gpwnam getpwnam ck_fun % S
685 gpwuid getpwuid ck_fun % S
686 gpwent getpwent ck_null 0
687 spwent setpwent ck_null is0
688 epwent endpwent ck_null is0
689 ggrnam getgrnam ck_fun % S
690 ggrgid getgrgid ck_fun % S
691 ggrent getgrent ck_null 0
692 sgrent setgrent ck_null is0
693 egrent endgrent ck_null is0
694 getlogin getlogin ck_null st0
698 syscall syscall ck_fun imst@ S L
700 # For multi-threading
701 lock lock ck_rfun s% S
702 threadsv per-thread variable ck_null ds0