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";
38 EXT char *op_name[] = {
42 print qq(\t"$name{$_}",\n);
51 # Emit function declarations.
53 for (sort keys %ckname) {
54 print "OP *\t", &tab(3,$_),"_((OP* op));\n";
60 print "OP *\t", &tab(3, "pp_\L$_"), "_((void));\n";
63 # Emit ppcode switch array.
68 EXT OP * (*ppaddr[])();
70 EXT OP * (*ppaddr[])() = {
83 # Emit check routines.
87 EXT OP * (*check[])();
89 EXT 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
131 $argsum |= 128 if $flags =~ /u/; # defaults to $_
133 for $arg (split(' ',$args{$_})) {
134 $argnum = ($arg =~ s/\?//) ? 8 : 0;
135 $argnum += $argnum{$arg};
136 $argsum += $argnum * $mul;
139 $argsum = sprintf("0x%08x", $argsum);
140 print "\t", &tab(3, "$argsum,"), "/* \L$_ */\n";
148 ###########################################################################
151 $t .= "\t" x ($l - (length($t) + 1) / 8);
154 ###########################################################################
159 null null operation ck_null 0
161 scalar scalar ck_fun s S
165 pushmark pushmark ck_null s
166 wantarray wantarray ck_null is
168 const constant item ck_svconst s
170 gvsv scalar variable ck_null ds
171 gv glob value ck_null ds
172 padsv private variable ck_null s
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 scalar deref ck_rvconst ds
184 av2arylen array length ck_null is
185 rv2cv subroutine deref ck_rvconst d
186 anoncode anonymous subroutine ck_null 0
187 refgen reference constructor ck_spair m L
188 srefgen scalar ref constructor ck_null fs S
189 ref reference-type operator ck_fun stu S?
190 bless bless ck_fun s S S?
194 backtick backticks ck_null t
195 glob glob ck_glob t S S
196 readline <HANDLE> ck_null t
197 rcatline append I/O operator ck_null t
199 # Bindable operators.
201 regcmaybe regexp comp once ck_fun s S
202 regcomp regexp compilation ck_null s S
203 match pattern match ck_match d
204 subst substitution ck_null dis S
205 substcont substitution cont ck_null dis
206 trans character translation ck_null is S
210 sassign scalar assignment ck_null s
211 aassign list assignment ck_null t L L
213 chop chop ck_spair mts L
214 schop scalar chop ck_null stu S?
215 chomp safe chop ck_spair mts L
216 schomp scalar safe chop ck_null stu S?
217 defined defined operator ck_rfun isu S?
218 undef undef operator ck_lfun s S?
219 study study ck_fun stu S?
220 pos match position ck_lfun stu S?
222 preinc preincrement ck_lfun dIs S
223 i_preinc integer preincrement ck_lfun dis S
224 predec predecrement ck_lfun dIs S
225 i_predec integer predecrement ck_lfun dis S
226 postinc postincrement ck_lfun dIst S
227 i_postinc integer postincrement ck_lfun dist S
228 postdec postdecrement ck_lfun dIst S
229 i_postdec integer postdecrement ck_lfun dist S
231 # Ordinary operators.
233 pow exponentiation ck_null fst S S
235 multiply multiplication ck_null Ifst S S
236 i_multiply integer multiplication ck_null ifst S S
237 divide division ck_null Ifst S S
238 i_divide integer division ck_null ifst S S
239 modulo modulus ck_null Iifst S S
240 i_modulo integer modulus ck_null ifst S S
241 repeat repeat ck_repeat mt L S
243 add addition ck_null Ifst S S
244 i_add integer addition ck_null ifst S S
245 subtract subtraction ck_null Ifst S S
246 i_subtract integer subtraction ck_null ifst S S
247 concat concatenation ck_concat fst S S
248 stringify string ck_fun fst S
250 left_shift left bitshift ck_null ifst S S
251 right_shift right bitshift ck_null ifst S S
253 lt numeric lt ck_null Iifs S S
254 i_lt integer lt ck_null ifs S S
255 gt numeric gt ck_null Iifs S S
256 i_gt integer gt ck_null ifs S S
257 le numeric le ck_null Iifs S S
258 i_le integer le ck_null ifs S S
259 ge numeric ge ck_null Iifs S S
260 i_ge integer ge ck_null ifs S S
261 eq numeric eq ck_null Iifs S S
262 i_eq integer eq ck_null ifs S S
263 ne numeric ne ck_null Iifs S S
264 i_ne integer ne ck_null ifs S S
265 ncmp spaceship operator ck_null Iifst S S
266 i_ncmp integer spaceship ck_null ifst S S
268 slt string lt ck_null ifs S S
269 sgt string gt ck_null ifs S S
270 sle string le ck_null ifs S S
271 sge string ge ck_null ifs S S
272 seq string eq ck_null ifs S S
273 sne string ne ck_null ifs S S
274 scmp string comparison ck_null ifst S S
276 bit_and bitwise and ck_null fst S S
277 bit_xor bitwise xor ck_null fst S S
278 bit_or bitwise or ck_null fst S S
280 negate negate ck_null Ifst S
281 i_negate integer negate ck_null ifst S
282 not not ck_null ifs S
283 complement 1's complement ck_null fst S
285 # High falutin' math.
287 atan2 atan2 ck_fun fst S S
288 sin sin ck_fun fstu S?
289 cos cos ck_fun fstu S?
290 rand rand ck_fun st S?
291 srand srand ck_fun s S?
292 exp exp ck_fun fstu S?
293 log log ck_fun fstu S?
294 sqrt sqrt ck_fun fstu S?
296 int int ck_fun fstu S?
297 hex hex ck_fun istu S?
298 oct oct ck_fun istu S?
299 abs abs ck_fun fstu S?
303 length length ck_lengthconst istu S?
304 substr substr ck_fun st S S S?
305 vec vec ck_fun ist S S S
307 index index ck_index ist S S S?
308 rindex rindex ck_index ist S S S?
310 sprintf sprintf ck_fun mst S L
311 formline formline ck_formline ms S L
312 ord ord ck_fun ifstu S?
313 chr chr ck_fun fstu S?
314 crypt crypt ck_fun fst S S
315 ucfirst upper case first ck_fun fst S
316 lcfirst lower case first ck_fun fst S
317 uc upper case ck_fun fst S
318 lc lower case ck_fun fst S
319 quotemeta quote metachars ck_fun fst S
323 rv2av array deref ck_rvconst dt
324 aelemfast known array element ck_null s A S
325 aelem array element ck_null s A S
326 aslice array slice ck_null m A L
328 # Associative arrays.
331 values values ck_fun t H
333 delete delete ck_delete s S
334 exists exists operator ck_delete is S
335 rv2hv associative array deref ck_rvconst dt
336 helem associative array elem ck_null s H S
337 hslice associative array slice ck_null m H L
339 # Explosives and implosives.
341 unpack unpack ck_fun 0 S S
342 pack pack ck_fun mst S L
343 split split ck_split t S S S
344 join join ck_fun mst S L
348 list list ck_null m L
349 lslice list slice ck_null 0 H L L
350 anonlist anonymous list ck_fun ms L
351 anonhash anonymous hash ck_fun ms L
353 splice splice ck_fun m A S? S? L
354 push push ck_fun imst A L
356 shift shift ck_shift s A
357 unshift unshift ck_fun imst A L
358 sort sort ck_sort m C? L
359 reverse reverse ck_fun mt L
361 grepstart grep ck_grep dm C L
362 grepwhile grep iterator ck_null dt
364 mapstart map ck_grep dm C L
365 mapwhile map iterator ck_null dt
369 range flipflop ck_null 0 S S
370 flip range (or flip) ck_null 0 S S
371 flop range (or flop) ck_null 0
375 and logical and ck_null 0
376 or logical or ck_null 0
377 xor logical xor ck_null fs S S
378 cond_expr conditional expression ck_null 0
379 andassign logical and assignment ck_null s
380 orassign logical or assignment ck_null s
382 method method lookup ck_null d
383 entersub subroutine entry ck_subr dmt L
384 leavesub subroutine exit ck_null 0
385 caller caller ck_fun t S?
386 warn warn ck_fun imst L
387 die die ck_fun dimst L
388 reset reset ck_fun is S?
390 lineseq line sequence ck_null 0
391 nextstate next statement ck_null s
392 dbstate debug next statement ck_null s
393 unstack unstack ck_null s
394 enter block entry ck_null 0
395 leave block exit ck_null 0
396 scope block ck_null 0
397 enteriter foreach loop entry ck_null d
398 iter foreach loop iterator ck_null 0
399 enterloop loop entry ck_null d
400 leaveloop loop exit ck_null 0
401 return return ck_fun dm L
407 exit exit ck_fun ds S?
409 #nswitch numeric switch ck_null d
410 #cswitch character switch ck_null d
414 open open ck_fun ist F S?
415 close close ck_fun is F?
416 pipe_op pipe ck_fun is F F
418 fileno fileno ck_fun ist F
419 umask umask ck_fun ist S?
420 binmode binmode ck_fun s F
422 tie tie ck_fun idms R S L
423 untie untie ck_fun is R
424 dbmopen dbmopen ck_fun is H S S
425 dbmclose dbmclose ck_fun is H
427 sselect select system call ck_select t S S S S
428 select select ck_select st F?
430 getc getc ck_eof st F?
431 read read ck_fun imst F R S S?
432 enterwrite write ck_fun dis F?
433 leavewrite write exit ck_null 0
435 prtf printf ck_listiob ims F? L
436 print print ck_listiob ims F? L
438 sysread sysread ck_fun imst F R S S?
439 syswrite syswrite ck_fun imst F S S S?
441 send send ck_fun imst F S S S?
442 recv recv ck_fun imst F R S S
445 tell tell ck_fun st F?
446 seek seek ck_fun s F S S
447 truncate truncate ck_trunc is S S
449 fcntl fcntl ck_fun st F S S
450 ioctl ioctl ck_fun st F S S
451 flock flock ck_fun ist F S
455 socket socket ck_fun is F S S S
456 sockpair socketpair ck_fun is F F S S S
458 bind bind ck_fun is F S
459 connect connect ck_fun is F S
460 listen listen ck_fun is F S
461 accept accept ck_fun ist F F
462 shutdown shutdown ck_fun ist F S
464 gsockopt getsockopt ck_fun is F S S
465 ssockopt setsockopt ck_fun is F S S S
467 getsockname getsockname ck_fun is F
468 getpeername getpeername ck_fun is F
472 lstat lstat ck_ftst u F
473 stat stat ck_ftst u F
474 ftrread -R ck_ftst isu F
475 ftrwrite -W ck_ftst isu F
476 ftrexec -X ck_ftst isu F
477 fteread -r ck_ftst isu F
478 ftewrite -w ck_ftst isu F
479 fteexec -x ck_ftst isu F
480 ftis -e ck_ftst isu F
481 fteowned -O ck_ftst isu F
482 ftrowned -o ck_ftst isu F
483 ftzero -z ck_ftst isu F
484 ftsize -s ck_ftst istu F
485 ftmtime -M ck_ftst stu F
486 ftatime -A ck_ftst stu F
487 ftctime -C ck_ftst stu F
488 ftsock -S ck_ftst isu F
489 ftchr -c ck_ftst isu F
490 ftblk -b ck_ftst isu F
491 ftfile -f ck_ftst isu F
492 ftdir -d ck_ftst isu F
493 ftpipe -p ck_ftst isu F
494 ftlink -l ck_ftst isu F
495 ftsuid -u ck_ftst isu F
496 ftsgid -g ck_ftst isu F
497 ftsvtx -k ck_ftst isu F
498 fttty -t ck_ftst is F
499 fttext -T ck_ftst isu F
500 ftbinary -B ck_ftst isu F
504 chdir chdir ck_fun ist S?
505 chown chown ck_fun imst L
506 chroot chroot ck_fun istu S?
507 unlink unlink ck_fun imstu L
508 chmod chmod ck_fun imst L
509 utime utime ck_fun imst L
510 rename rename ck_fun ist S S
511 link link ck_fun ist S S
512 symlink symlink ck_fun ist S S
513 readlink readlink ck_fun stu S?
514 mkdir mkdir ck_fun ist S S
515 rmdir rmdir ck_fun istu S?
519 open_dir opendir ck_fun is F S
520 readdir readdir ck_fun 0 F
521 telldir telldir ck_fun st F
522 seekdir seekdir ck_fun s F S
523 rewinddir rewinddir ck_fun s F
524 closedir closedir ck_fun is F
528 fork fork ck_null ist
529 wait wait ck_null ist
530 waitpid waitpid ck_fun ist S S
531 system system ck_exec imst S? L
532 exec exec ck_exec dimst S? L
533 kill kill ck_fun dimst L
534 getppid getppid ck_null ist
535 getpgrp getpgrp ck_fun ist S?
536 setpgrp setpgrp ck_fun ist S? S?
537 getpriority getpriority ck_fun ist S S
538 setpriority setpriority ck_fun ist S S S
542 time time ck_null ist
544 localtime localtime ck_fun t S?
545 gmtime gmtime ck_fun t S?
546 alarm alarm ck_fun istu S?
547 sleep sleep ck_fun ist S?
551 shmget shmget ck_fun imst S S S
552 shmctl shmctl ck_fun imst S S S
553 shmread shmread ck_fun imst S S S S
554 shmwrite shmwrite ck_fun ist S S S S
558 msgget msgget ck_fun imst S S
559 msgctl msgctl ck_fun imst S S S
560 msgsnd msgsnd ck_fun imst S S S
561 msgrcv msgrcv ck_fun imst S S S S S
565 semget semget ck_fun imst S S S
566 semctl semctl ck_fun imst S S S S
567 semop semop ck_fun imst S S
571 require require ck_require du S?
572 dofile do 'file' ck_fun d S
573 entereval eval string ck_eval d S
574 leaveeval eval exit ck_null 0 S
575 #evalonce eval constant string ck_null d S
576 entertry eval block ck_null 0
577 leavetry eval block exit ck_null 0
581 ghbyname gethostbyname ck_fun 0 S
582 ghbyaddr gethostbyaddr ck_fun 0 S S
583 ghostent gethostent ck_null 0
584 gnbyname getnetbyname ck_fun 0 S
585 gnbyaddr getnetbyaddr ck_fun 0 S S
586 gnetent getnetent ck_null 0
587 gpbyname getprotobyname ck_fun 0 S
588 gpbynumber getprotobynumber ck_fun 0 S
589 gprotoent getprotoent ck_null 0
590 gsbyname getservbyname ck_fun 0 S S
591 gsbyport getservbyport ck_fun 0 S S
592 gservent getservent ck_null 0
593 shostent sethostent ck_fun is S
594 snetent setnetent ck_fun is S
595 sprotoent setprotoent ck_fun is S
596 sservent setservent ck_fun is S
597 ehostent endhostent ck_null is
598 enetent endnetent ck_null is
599 eprotoent endprotoent ck_null is
600 eservent endservent ck_null is
601 gpwnam getpwnam ck_fun 0 S
602 gpwuid getpwuid ck_fun 0 S
603 gpwent getpwent ck_null 0
604 spwent setpwent ck_null is
605 epwent endpwent ck_null is
606 ggrnam getgrnam ck_fun 0 S
607 ggrgid getgrgid ck_fun 0 S
608 ggrent getgrent ck_null 0
609 sgrent setgrent ck_null is
610 egrent endgrent ck_null is
611 getlogin getlogin ck_null st
615 syscall syscall ck_fun imst S L