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