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* op));\n";
91 print "OP *\t", &tab(3, "pp_\L$_"), "_((void));\n";
94 # Emit ppcode switch array.
99 EXT OP * (*ppaddr[])();
101 EXT OP * (*ppaddr[])() = {
105 print "\tpp_\L$_,\n";
114 # Emit check routines.
118 EXT OP * (*check[]) _((OP *op));
120 EXT OP * (*check[]) _((OP *op)) = {
124 print "\t", &tab(3, "$check{$_},"), "/* \L$_ */\n";
133 # Emit allowed argument types.
149 R, 7, # scalar reference
155 $argsum |= 1 if $flags =~ /m/; # needs stack mark
156 $argsum |= 2 if $flags =~ /f/; # fold constants
157 $argsum |= 4 if $flags =~ /s/; # always produces scalar
158 $argsum |= 8 if $flags =~ /t/; # needs target scalar
159 $argsum |= 16 if $flags =~ /i/; # always produces integer
160 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
161 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
162 $argsum |= 128 if $flags =~ /u/; # defaults to $_
164 for $arg (split(' ',$args{$_})) {
165 $argnum = ($arg =~ s/\?//) ? 8 : 0;
166 $argnum += $argnum{$arg};
167 $argsum += $argnum * $mul;
170 $argsum = sprintf("0x%08x", $argsum);
171 print "\t", &tab(3, "$argsum,"), "/* \L$_ */\n";
179 ###########################################################################
182 $t .= "\t" x ($l - (length($t) + 1) / 8);
185 ###########################################################################
190 null null operation ck_null 0
192 scalar scalar ck_fun s S
196 pushmark pushmark ck_null s
197 wantarray wantarray ck_null is
199 const constant item ck_svconst s
201 gvsv scalar variable ck_null ds
202 gv glob value ck_null ds
203 gelem glob elem ck_null d S S
204 padsv private variable ck_null ds
205 padav private array ck_null d
206 padhv private hash ck_null d
207 padany private something ck_null d
209 pushre push regexp ck_null 0
211 # References and stuff.
213 rv2gv ref-to-glob cast ck_rvconst ds
214 rv2sv scalar deref ck_rvconst ds
215 av2arylen array length ck_null is
216 rv2cv subroutine deref ck_rvconst d
217 anoncode anonymous subroutine ck_anoncode 0
218 prototype subroutine prototype ck_null s S
219 refgen reference constructor ck_spair m L
220 srefgen scalar ref constructor ck_null fs S
221 ref reference-type operator ck_fun stu S?
222 bless bless ck_fun s S S?
226 backtick backticks ck_null t
227 glob glob ck_glob t S S
228 readline <HANDLE> ck_null t
229 rcatline append I/O operator ck_null t
231 # Bindable operators.
233 regcmaybe regexp comp once ck_fun s S
234 regcomp regexp compilation ck_null s S
235 match pattern match ck_match d
236 subst substitution ck_null dis S
237 substcont substitution cont ck_null dis
238 trans character translation ck_null is S
242 sassign scalar assignment ck_null s
243 aassign list assignment ck_null t L L
245 chop chop ck_spair mts L
246 schop scalar chop ck_null stu S?
247 chomp safe chop ck_spair mts L
248 schomp scalar safe chop ck_null stu S?
249 defined defined operator ck_rfun isu S?
250 undef undef operator ck_lfun s S?
251 study study ck_fun su S?
252 pos match position ck_lfun stu S?
254 preinc preincrement ck_lfun dIs S
255 i_preinc integer preincrement ck_lfun dis S
256 predec predecrement ck_lfun dIs S
257 i_predec integer predecrement ck_lfun dis S
258 postinc postincrement ck_lfun dIst S
259 i_postinc integer postincrement ck_lfun dist S
260 postdec postdecrement ck_lfun dIst S
261 i_postdec integer postdecrement ck_lfun dist S
263 # Ordinary operators.
265 pow exponentiation ck_null fst S S
267 multiply multiplication ck_null Ifst S S
268 i_multiply integer multiplication ck_null ifst S S
269 divide division ck_null Ifst S S
270 i_divide integer division ck_null ifst S S
271 modulo modulus ck_null Iifst S S
272 i_modulo integer modulus ck_null ifst S S
273 repeat repeat ck_repeat mt L S
275 add addition ck_null Ifst S S
276 i_add integer addition ck_null ifst S S
277 subtract subtraction ck_null Ifst S S
278 i_subtract integer subtraction ck_null ifst S S
279 concat concatenation ck_concat fst S S
280 stringify string ck_fun fst S
282 left_shift left bitshift ck_bitop fst S S
283 right_shift right bitshift ck_bitop fst S S
285 lt numeric lt ck_null Iifs S S
286 i_lt integer lt ck_null ifs S S
287 gt numeric gt ck_null Iifs S S
288 i_gt integer gt ck_null ifs S S
289 le numeric le ck_null Iifs S S
290 i_le integer le ck_null ifs S S
291 ge numeric ge ck_null Iifs S S
292 i_ge integer ge ck_null ifs S S
293 eq numeric eq ck_null Iifs S S
294 i_eq integer eq ck_null ifs S S
295 ne numeric ne ck_null Iifs S S
296 i_ne integer ne ck_null ifs S S
297 ncmp spaceship operator ck_null Iifst S S
298 i_ncmp integer spaceship ck_null ifst S S
300 slt string lt ck_scmp ifs S S
301 sgt string gt ck_scmp ifs S S
302 sle string le ck_scmp ifs S S
303 sge string ge ck_scmp ifs S S
304 seq string eq ck_null ifs S S
305 sne string ne ck_null ifs S S
306 scmp string comparison ck_scmp ifst S S
308 bit_and bitwise and ck_bitop fst S S
309 bit_xor bitwise xor ck_bitop fst S S
310 bit_or bitwise or ck_bitop fst S S
312 negate negate ck_null Ifst S
313 i_negate integer negate ck_null ifst S
314 not not ck_null ifs S
315 complement 1's complement ck_bitop fst S
317 # High falutin' math.
319 atan2 atan2 ck_fun fst S S
320 sin sin ck_fun fstu S?
321 cos cos ck_fun fstu S?
322 rand rand ck_fun st S?
323 srand srand ck_fun s S?
324 exp exp ck_fun fstu S?
325 log log ck_fun fstu S?
326 sqrt sqrt ck_fun fstu S?
328 int int ck_fun fstu S?
329 hex hex ck_fun istu S?
330 oct oct ck_fun istu S?
331 abs abs ck_fun fstu S?
335 length length ck_lengthconst istu S?
336 substr substr ck_fun st S S S?
337 vec vec ck_fun ist S S S
339 index index ck_index ist S S S?
340 rindex rindex ck_index ist S S S?
342 sprintf sprintf ck_fun_locale mst S L
343 formline formline ck_fun ms S L
344 ord ord ck_fun ifstu S?
345 chr chr ck_fun fstu S?
346 crypt crypt ck_fun fst S S
347 ucfirst upper case first ck_fun_locale fstu S?
348 lcfirst lower case first ck_fun_locale fstu S?
349 uc upper case ck_fun_locale fstu S?
350 lc lower case ck_fun_locale fstu S?
351 quotemeta quote metachars ck_fun fstu S?
355 rv2av array deref ck_rvconst dt
356 aelemfast known array element ck_null s A S
357 aelem array element ck_null s A S
358 aslice array slice ck_null m A L
360 # Associative arrays.
363 values values ck_fun t H
365 delete delete ck_delete 0 S
366 exists exists operator ck_exists is S
367 rv2hv associative array deref ck_rvconst dt
368 helem associative array elem ck_null s H S
369 hslice associative array slice ck_null m H L
371 # Explosives and implosives.
373 unpack unpack ck_fun 0 S S
374 pack pack ck_fun mst S L
375 split split ck_split t S S S
376 join join ck_fun mst S L
380 list list ck_null m L
381 lslice list slice ck_null 0 H L L
382 anonlist anonymous list ck_fun ms L
383 anonhash anonymous hash ck_fun ms L
385 splice splice ck_fun m A S? S? L
386 push push ck_fun imst A L
388 shift shift ck_shift s A
389 unshift unshift ck_fun imst A L
390 sort sort ck_sort m C? L
391 reverse reverse ck_fun mt L
393 grepstart grep ck_grep dm C L
394 grepwhile grep iterator ck_null dt
396 mapstart map ck_grep dm C L
397 mapwhile map iterator ck_null dt
401 range flipflop ck_null 0 S S
402 flip range (or flip) ck_null 0 S S
403 flop range (or flop) ck_null 0
407 and logical and ck_null 0
408 or logical or ck_null 0
409 xor logical xor ck_null fs S S
410 cond_expr conditional expression ck_null d
411 andassign logical and assignment ck_null s
412 orassign logical or assignment ck_null s
414 method method lookup ck_null d
415 entersub subroutine entry ck_subr dmt L
416 leavesub subroutine exit ck_null 0
417 caller caller ck_fun t S?
418 warn warn ck_fun imst L
419 die die ck_fun dimst L
420 reset reset ck_fun is S?
422 lineseq line sequence ck_null 0
423 nextstate next statement ck_null s
424 dbstate debug next statement ck_null s
425 unstack unstack ck_null s
426 enter block entry ck_null 0
427 leave block exit ck_null 0
428 scope block ck_null 0
429 enteriter foreach loop entry ck_null d
430 iter foreach loop iterator ck_null 0
431 enterloop loop entry ck_null d
432 leaveloop loop exit ck_null 0
433 return return ck_null dm L
439 exit exit ck_fun ds S?
441 #nswitch numeric switch ck_null d
442 #cswitch character switch ck_null d
446 open open ck_fun ist F S?
447 close close ck_fun is F?
448 pipe_op pipe ck_fun is F F
450 fileno fileno ck_fun ist F
451 umask umask ck_fun ist S?
452 binmode binmode ck_fun s F
454 tie tie ck_fun idms R S L
455 untie untie ck_fun is R
457 dbmopen dbmopen ck_fun is H S S
458 dbmclose dbmclose ck_fun is H
460 sselect select system call ck_select t S S S S
461 select select ck_select st F?
463 getc getc ck_eof st F?
464 read read ck_fun imst F R S S?
465 enterwrite write ck_fun dis F?
466 leavewrite write exit ck_null 0
468 prtf printf ck_listiob ims F? L
469 print print ck_listiob ims F? L
471 sysopen sysopen ck_fun s F S S S?
472 sysread sysread ck_fun imst F R S S?
473 syswrite syswrite ck_fun imst F S S S?
475 send send ck_fun imst F S S S?
476 recv recv ck_fun imst F R S S
479 tell tell ck_fun st F?
480 seek seek ck_fun s F S S
481 # truncate really behaves as if it had both "S S" and "F S"
482 truncate truncate ck_trunc is S S
484 fcntl fcntl ck_fun st F S S
485 ioctl ioctl ck_fun st F S S
486 flock flock ck_fun ist F S
490 socket socket ck_fun is F S S S
491 sockpair socketpair ck_fun is F F S S S
493 bind bind ck_fun is F S
494 connect connect ck_fun is F S
495 listen listen ck_fun is F S
496 accept accept ck_fun ist F F
497 shutdown shutdown ck_fun ist F S
499 gsockopt getsockopt ck_fun is F S S
500 ssockopt setsockopt ck_fun is F S S S
502 getsockname getsockname ck_fun is F
503 getpeername getpeername ck_fun is F
507 lstat lstat ck_ftst u F
508 stat stat ck_ftst u F
509 ftrread -R ck_ftst isu F
510 ftrwrite -W ck_ftst isu F
511 ftrexec -X ck_ftst isu F
512 fteread -r ck_ftst isu F
513 ftewrite -w ck_ftst isu F
514 fteexec -x ck_ftst isu F
515 ftis -e ck_ftst isu F
516 fteowned -O ck_ftst isu F
517 ftrowned -o ck_ftst isu F
518 ftzero -z ck_ftst isu F
519 ftsize -s ck_ftst istu F
520 ftmtime -M ck_ftst stu F
521 ftatime -A ck_ftst stu F
522 ftctime -C ck_ftst stu F
523 ftsock -S ck_ftst isu F
524 ftchr -c ck_ftst isu F
525 ftblk -b ck_ftst isu F
526 ftfile -f ck_ftst isu F
527 ftdir -d ck_ftst isu F
528 ftpipe -p ck_ftst isu F
529 ftlink -l ck_ftst isu F
530 ftsuid -u ck_ftst isu F
531 ftsgid -g ck_ftst isu F
532 ftsvtx -k ck_ftst isu F
533 fttty -t ck_ftst is F
534 fttext -T ck_ftst isu F
535 ftbinary -B ck_ftst isu F
539 chdir chdir ck_fun ist S?
540 chown chown ck_fun imst L
541 chroot chroot ck_fun istu S?
542 unlink unlink ck_fun imstu L
543 chmod chmod ck_fun imst L
544 utime utime ck_fun imst L
545 rename rename ck_fun ist S S
546 link link ck_fun ist S S
547 symlink symlink ck_fun ist S S
548 readlink readlink ck_fun stu S?
549 mkdir mkdir ck_fun ist S S
550 rmdir rmdir ck_fun istu S?
554 open_dir opendir ck_fun is F S
555 readdir readdir ck_fun 0 F
556 telldir telldir ck_fun st F
557 seekdir seekdir ck_fun s F S
558 rewinddir rewinddir ck_fun s F
559 closedir closedir ck_fun is F
563 fork fork ck_null ist
564 wait wait ck_null ist
565 waitpid waitpid ck_fun ist S S
566 system system ck_exec imst S? L
567 exec exec ck_exec dimst S? L
568 kill kill ck_fun dimst L
569 getppid getppid ck_null ist
570 getpgrp getpgrp ck_fun ist S?
571 setpgrp setpgrp ck_fun ist S? S?
572 getpriority getpriority ck_fun ist S S
573 setpriority setpriority ck_fun ist S S S
577 time time ck_null ist
579 localtime localtime ck_fun t S?
580 gmtime gmtime ck_fun t S?
581 alarm alarm ck_fun istu S?
582 sleep sleep ck_fun ist S?
586 shmget shmget ck_fun imst S S S
587 shmctl shmctl ck_fun imst S S S
588 shmread shmread ck_fun imst S S S S
589 shmwrite shmwrite ck_fun imst S S S S
593 msgget msgget ck_fun imst S S
594 msgctl msgctl ck_fun imst S S S
595 msgsnd msgsnd ck_fun imst S S S
596 msgrcv msgrcv ck_fun imst S S S S S
600 semget semget ck_fun imst S S S
601 semctl semctl ck_fun imst S S S S
602 semop semop ck_fun imst S S
606 require require ck_require du S?
607 dofile do 'file' ck_fun d S
608 entereval eval string ck_eval d S
609 leaveeval eval exit ck_null 0 S
610 #evalonce eval constant string ck_null d S
611 entertry eval block ck_null 0
612 leavetry eval block exit ck_null 0
616 ghbyname gethostbyname ck_fun 0 S
617 ghbyaddr gethostbyaddr ck_fun 0 S S
618 ghostent gethostent ck_null 0
619 gnbyname getnetbyname ck_fun 0 S
620 gnbyaddr getnetbyaddr ck_fun 0 S S
621 gnetent getnetent ck_null 0
622 gpbyname getprotobyname ck_fun 0 S
623 gpbynumber getprotobynumber ck_fun 0 S
624 gprotoent getprotoent ck_null 0
625 gsbyname getservbyname ck_fun 0 S S
626 gsbyport getservbyport ck_fun 0 S S
627 gservent getservent ck_null 0
628 shostent sethostent ck_fun is S
629 snetent setnetent ck_fun is S
630 sprotoent setprotoent ck_fun is S
631 sservent setservent ck_fun is S
632 ehostent endhostent ck_null is
633 enetent endnetent ck_null is
634 eprotoent endprotoent ck_null is
635 eservent endservent ck_null is
636 gpwnam getpwnam ck_fun 0 S
637 gpwuid getpwuid ck_fun 0 S
638 gpwent getpwent ck_null 0
639 spwent setpwent ck_null is
640 epwent endpwent ck_null is
641 ggrnam getgrnam ck_fun 0 S
642 ggrgid getgrgid ck_fun 0 S
643 ggrent getgrent ck_null 0
644 sgrent setgrent ck_null is
645 egrent endgrent ck_null is
646 getlogin getlogin ck_null st
650 syscall syscall ck_fun imst S L