3 open(OC, ">opcode.h") || die "Can't create opcode.h: $!\n";
12 ($key, $name, $check, $flags, $args) = split(/\t+/, $_, 5);
15 $check{$key} = $check;
17 $flags{$key} = $flags;
24 print "typedef enum {\n";
26 print "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
28 print "\t", &tab(3,"OP_max"), "\n";
30 print "\n#define MAXO ", scalar @ops, "\n\n";
36 extern char *op_name[];
42 print qq(\t"$name{$_}",\n);
51 # Emit function declarations.
53 for (sort keys %ckname) {
54 print "OP *\t", &tab(3,$_),"P((OP* op));\n";
60 print "OP *\t", &tab(3, "pp_\L$_"), "P((void));\n";
63 # Emit ppcode switch array.
68 extern OP * (*ppaddr[])();
70 OP * (*ppaddr[])() = {
83 # Emit check routines.
87 extern OP * (*check[])();
93 print "\t", &tab(3, "$check{$_},"), "/* \L$_ */\n";
102 # Emit allowed argument types.
118 R, 7, # scalar reference
124 $argsum |= 1 if $flags =~ /m/; # needs stack mark
125 $argsum |= 2 if $flags =~ /f/; # fold constants
126 $argsum |= 4 if $flags =~ /s/; # always produces scalar
127 $argsum |= 8 if $flags =~ /t/; # needs target scalar
128 $argsum |= 16 if $flags =~ /i/; # always produces integer
129 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
130 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
132 for $arg (split(' ',$args{$_})) {
133 $argnum = ($arg =~ s/\?//) ? 8 : 0;
134 $argnum += $argnum{$arg};
135 $argsum += $argnum * $mul;
138 $argsum = sprintf("0x%08x", $argsum);
139 print "\t", &tab(3, "$argsum,"), "/* \L$_ */\n";
147 ###########################################################################
150 $t .= "\t" x ($l - (length($t) + 1) / 8);
153 ###########################################################################
158 null null operation ck_null 0
160 scalar scalar ck_fun s S
164 pushmark pushmark ck_null s
165 wantarray wantarray ck_null is
167 const constant item ck_svconst s
168 interp interpreted string ck_null 0
170 gvsv scalar variable ck_null ds
171 gv glob value ck_null ds
172 padsv private variable ck_null 0
173 padav private array ck_null 0
174 padhv private hash ck_null 0
175 padany private something ck_null 0
177 pushre push regexp ck_null 0
179 # References and stuff.
181 rv2gv ref-to-glob cast ck_rvconst ds
182 sv2len scalar value length ck_null ist
183 rv2sv ref-to-scalar cast ck_rvconst ds
184 av2arylen array length ck_null is
185 rv2cv subroutine reference ck_rvconst d
186 refgen reference constructor ck_null fst L
187 ref reference-type operator ck_fun st S?
188 bless bless ck_fun s S S?
192 backtick backticks ck_null t
194 readline <HANDLE> ck_null t
195 rcatline append I/O operator ck_null t
197 # Bindable operators.
199 regcmaybe regexp comp once ck_fun s S
200 regcomp regexp compilation ck_null s S
201 match pattern match ck_match d
202 subst substitution ck_null dis S
203 substcont substitution cont ck_null dis
204 trans character translation ck_null is S
208 sassign scalar assignment ck_null s
209 aassign list assignment ck_null t L L
211 schop scalar chop ck_null t
212 chop chop ck_chop mt L
213 defined defined operator ck_rfun is S?
214 undef undef operator ck_lfun s S?
215 study study ck_fun st S?
217 preinc preincrement ck_lfun Is S
218 i_preinc integer preincrement ck_lfun is S
219 predec predecrement ck_lfun Is S
220 i_predec integer predecrement ck_lfun is S
221 postinc postincrement ck_lfun Ist S
222 i_postinc integer postincrement ck_lfun ist S
223 postdec postdecrement ck_lfun Ist S
224 i_postdec integer postdecrement ck_lfun ist S
226 # Ordinary operators.
228 pow exponentiation ck_null Ifst S S
230 multiply multiplication ck_null Ifst S S
231 i_multiply integer multiplication ck_null ifst S S
232 divide division ck_null Ifst S S
233 i_divide integer division ck_null ifst S S
234 modulo modulus ck_null Iifst S S
235 i_modulo integer modulus ck_null ifst S S
236 repeat repeat ck_repeat mt L S
238 add addition ck_null Ifst S S
239 i_add integer addition ck_null ifst S S
240 subtract subtraction ck_null Ifst S S
241 i_subtract integer subtraction ck_null ifst S S
242 concat concatenation ck_concat fst S S
244 left_shift left bitshift ck_null ifst S S
245 right_shift right bitshift ck_null ifst S S
247 lt numeric lt ck_null Iifs S S
248 i_lt integer lt ck_null ifs S S
249 gt numeric gt ck_null Iifs S S
250 i_gt integer gt ck_null ifs S S
251 le numeric le ck_null Iifs S S
252 i_le integer le ck_null ifs S S
253 ge numeric ge ck_null Iifs S S
254 i_ge integer ge ck_null ifs S S
255 eq numeric eq ck_null Iifs S S
256 i_eq integer eq ck_null ifs S S
257 ne numeric ne ck_null Iifs S S
258 i_ne integer ne ck_null ifs S S
259 ncmp spaceship ck_null Iifst S S
260 i_ncmp integer spaceship ck_null ifst S S
262 slt string lt ck_null ifs S S
263 sgt string gt ck_null ifs S S
264 sle string le ck_null ifs S S
265 sge string ge ck_null ifs S S
266 seq string eq ck_null ifs S S
267 sne string ne ck_null ifs S S
268 scmp string comparison ck_null ifst S S
270 bit_and bit and ck_null fst S S
271 xor xor ck_null fst S S
272 bit_or bit or ck_null fst S S
274 negate negate ck_null Ifst S
275 i_negate integer negate ck_null ifst S
276 not not ck_null ifs S
277 complement 1's complement ck_null fst S
279 # High falutin' math.
281 atan2 atan2 ck_fun fst S S
282 sin sin ck_fun fst S?
283 cos cos ck_fun fst S?
284 rand rand ck_fun st S?
285 srand srand ck_fun s S?
286 exp exp ck_fun fst S?
287 log log ck_fun fst S?
288 sqrt sqrt ck_fun fst S?
290 int int ck_fun fst S?
291 hex hex ck_fun ist S?
292 oct oct ck_fun ist S?
293 abs abs ck_fun fst S?
297 length length ck_lengthconst ist S
298 substr substr ck_fun st S S S?
299 vec vec ck_fun ist S S S
301 index index ck_index ist S S S?
302 rindex rindex ck_index ist S S S?
304 sprintf sprintf ck_fun mst S L
305 formline formline ck_formline ms S L
306 ord ord ck_fun ifst S?
307 chr chr ck_fun fst S?
308 crypt crypt ck_fun fst S S
309 ucfirst upper case first ck_fun ft S
310 lcfirst lower case first ck_fun ft S
311 uc upper case ck_fun ft S
312 lc lower case ck_fun ft S
316 rv2av array deref ck_rvconst dt
317 aelemfast known array element ck_null s A S
318 aelem array element ck_null s A S
319 aslice array slice ck_null m A L
321 # Associative arrays.
324 values values ck_fun t H
326 delete delete ck_null s H S
327 rv2hv associative array deref ck_rvconst dt
328 helem associative array elem ck_null s H S
329 hslice associative array slice ck_null m H L
331 # Explosives and implosives.
333 unpack unpack ck_fun 0 S S
334 pack pack ck_fun mst S L
335 split split ck_split t S S S
336 join join ck_fun mst S L
340 list list ck_null m L
341 lslice list slice ck_null 0 H L L
342 anonlist anonymous list ck_null m L
343 anonhash anonymous hash ck_null m L
345 splice splice ck_fun m A S S? L
346 push push ck_fun imst A L
348 shift shift ck_shift s A
349 unshift unshift ck_fun imst A L
350 sort sort ck_sort m C? L
351 reverse reverse ck_fun mt L
353 grepstart grep ck_grep dm C L
354 grepwhile grep iterator ck_null dt
358 range flipflop ck_null 0 S S
359 flip range (or flip) ck_null 0 S S
360 flop range (or flop) ck_null 0
364 and logical and ck_null 0
365 or logical or ck_null 0
366 cond_expr conditional expression ck_null 0
367 andassign logical and assignment ck_null s
368 orassign logical or assignment ck_null s
370 method method lookup ck_null d
371 entersubr subroutine entry ck_subr dm L
372 leavesubr subroutine exit ck_null 0
373 caller caller ck_fun t S?
374 warn warn ck_fun imst L
375 die die ck_fun dimst L
376 reset reset ck_fun is S?
378 lineseq line sequence ck_null 0
379 nextstate next statement ck_null s
380 dbstate debug next statement ck_null s
381 unstack unstack ck_null s
382 enter block entry ck_null 0
383 leave block exit ck_null 0
384 scope block ck_null 0
385 enteriter foreach loop entry ck_null d
386 iter foreach loop iterator ck_null 0
387 enterloop loop entry ck_null d
388 leaveloop loop exit ck_null s
389 return return ck_fun dm L
395 exit exit ck_fun ds S?
397 nswitch numeric switch ck_null d
398 cswitch character switch ck_null d
402 open open ck_fun ist F S?
403 close close ck_fun is F?
404 pipe_op pipe ck_fun is F F
406 fileno fileno ck_fun ist F
407 umask umask ck_fun ist S?
408 binmode binmode ck_fun s F
410 tie tie ck_fun idms R S L
411 untie untie ck_fun is R
412 dbmopen dbmopen ck_fun is H S S
413 dbmclose dbmclose ck_fun is H
415 sselect select system call ck_select t S S S S
416 select select ck_select st F?
418 getc getc ck_eof st F?
419 read read ck_fun imst F R S S?
420 enterwrite write ck_fun dis F?
421 leavewrite write exit ck_null 0
423 prtf printf ck_listiob ims F? L
424 print print ck_listiob ims F? L
426 sysread sysread ck_fun imst F R S S?
427 syswrite syswrite ck_fun imst F S S S?
429 send send ck_fun imst F S S S?
430 recv recv ck_fun imst F R S S
433 tell tell ck_fun st F?
434 seek seek ck_fun s F S S
435 truncate truncate ck_trunc is S S
437 fcntl fcntl ck_fun st F S S
438 ioctl ioctl ck_fun st F S S
439 flock flock ck_fun ist F S
443 socket socket ck_fun is F S S S
444 sockpair socketpair ck_fun is F F S S S
446 bind bind ck_fun is F S
447 connect connect ck_fun is F S
448 listen listen ck_fun is F S
449 accept accept ck_fun ist F F
450 shutdown shutdown ck_fun ist F S
452 gsockopt getsockopt ck_fun is F S S
453 ssockopt setsockopt ck_fun is F S S S
455 getsockname getsockname ck_fun is F
456 getpeername getpeername ck_fun is F
460 lstat lstat ck_ftst 0 F
461 stat stat ck_ftst 0 F
462 ftrread -R ck_ftst is F
463 ftrwrite -W ck_ftst is F
464 ftrexec -X ck_ftst is F
465 fteread -r ck_ftst is F
466 ftewrite -w ck_ftst is F
467 fteexec -x ck_ftst is F
469 fteowned -O ck_ftst is F
470 ftrowned -o ck_ftst is F
471 ftzero -z ck_ftst is F
472 ftsize -s ck_ftst ist F
473 ftmtime -M ck_ftst st F
474 ftatime -A ck_ftst st F
475 ftctime -C ck_ftst st F
476 ftsock -S ck_ftst is F
477 ftchr -c ck_ftst is F
478 ftblk -b ck_ftst is F
479 ftfile -f ck_ftst is F
480 ftdir -d ck_ftst is F
481 ftpipe -p ck_ftst is F
482 ftlink -l ck_ftst is F
483 ftsuid -u ck_ftst is F
484 ftsgid -g ck_ftst is F
485 ftsvtx -k ck_ftst is F
486 fttty -t ck_ftst is F
487 fttext -T ck_ftst is F
488 ftbinary -B ck_ftst is F
492 chdir chdir ck_fun ist S?
493 chown chown ck_fun imst L
494 chroot chroot ck_fun ist S?
495 unlink unlink ck_fun imst L
496 chmod chmod ck_fun imst L
497 utime utime ck_fun imst L
498 rename rename ck_fun ist S S
499 link link ck_fun ist S S
500 symlink symlink ck_fun ist S S
501 readlink readlink ck_fun st S?
502 mkdir mkdir ck_fun ist S S
503 rmdir rmdir ck_fun ist S?
507 open_dir opendir ck_fun is F S
508 readdir readdir ck_fun 0 F
509 telldir telldir ck_fun st F
510 seekdir seekdir ck_fun s F S
511 rewinddir rewinddir ck_fun s F
512 closedir closedir ck_fun is F
516 fork fork ck_null ist
517 wait wait ck_null ist
518 waitpid waitpid ck_fun ist S S
519 system system ck_exec imst S? L
520 exec exec ck_exec dimst S? L
521 kill kill ck_fun dimst L
522 getppid getppid ck_null ist
523 getpgrp getpgrp ck_fun ist S?
524 setpgrp setpgrp ck_fun ist S S
525 getpriority getpriority ck_fun ist S S
526 setpriority setpriority ck_fun ist S S S
530 time time ck_null ist
532 localtime localtime ck_fun t S?
533 gmtime gmtime ck_fun t S?
534 alarm alarm ck_fun ist S?
535 sleep sleep ck_fun ist S?
539 shmget shmget ck_fun imst S S S
540 shmctl shmctl ck_fun imst S S S
541 shmread shmread ck_fun imst S S S S
542 shmwrite shmwrite ck_fun ist S S S S
546 msgget msgget ck_fun imst S S
547 msgctl msgctl ck_fun imst S S S
548 msgsnd msgsnd ck_fun imst S S S
549 msgrcv msgrcv ck_fun imst S S S S S
553 semget semget ck_fun imst S S S
554 semctl semctl ck_fun imst S S S S
555 semop semop ck_fun imst S S S
559 require require ck_require d S?
560 dofile do 'file' ck_fun d S
561 entereval eval string ck_eval d S
562 leaveeval eval exit ck_null 0 S
563 evalonce eval constant string ck_null d S
564 entertry eval block ck_null 0
565 leavetry eval block exit ck_null 0
569 ghbyname gethostbyname ck_fun 0 S
570 ghbyaddr gethostbyaddr ck_fun 0 S S
571 ghostent gethostent ck_null 0
572 gnbyname getnetbyname ck_fun 0 S
573 gnbyaddr getnetbyaddr ck_fun 0 S S
574 gnetent getnetent ck_null 0
575 gpbyname getprotobyname ck_fun 0 S
576 gpbynumber getprotobynumber ck_fun 0 S
577 gprotoent getprotoent ck_null 0
578 gsbyname getservbyname ck_fun 0 S S
579 gsbyport getservbyport ck_fun 0 S S
580 gservent getservent ck_null 0
581 shostent sethostent ck_fun is S
582 snetent setnetent ck_fun is S
583 sprotoent setprotoent ck_fun is S
584 sservent setservent ck_fun is S
585 ehostent endhostent ck_null is
586 enetent endnetent ck_null is
587 eprotoent endprotoent ck_null is
588 eservent endservent ck_null is
589 gpwnam getpwnam ck_fun 0 S
590 gpwuid getpwuid ck_fun 0 S
591 gpwent getpwent ck_null 0
592 spwent setpwent ck_null ist
593 epwent endpwent ck_null ist
594 ggrnam getgrnam ck_fun 0 S
595 ggrgid getgrgid ck_fun 0 S
596 ggrent getgrent ck_null 0
597 sgrent setgrent ck_null ist
598 egrent endgrent ck_null ist
599 getlogin getlogin ck_null st
603 syscall syscall ck_fun ist S L