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";
29 print "\n#define MAXO ", scalar @ops, "\n\n";
35 extern char *op_name[];
41 print qq(\t"$name{$_}",\n);
50 # Emit function declarations.
52 for (sort keys %ckname) {
53 print "OP *\t", &tab(3,$_),"P((OP* op));\n";
59 print "OP *\t", &tab(3, "pp_\L$_"), "P((ARGSproto));\n";
62 # Emit ppcode switch array.
67 extern OP * (*ppaddr[])();
69 OP * (*ppaddr[])() = {
82 # Emit check routines.
86 extern OP * (*check[])();
92 print "\t", &tab(3, "$check{$_},"), "/* \L$_ */\n";
101 # Emit allowed argument types.
117 R, 7, # scalar reference
123 $argsum |= 1 if $flags =~ /m/; # needs stack mark
124 $argsum |= 2 if $flags =~ /f/; # fold constants
125 $argsum |= 4 if $flags =~ /s/; # always produces scalar
126 $argsum |= 8 if $flags =~ /t/; # needs target scalar
127 $argsum |= 16 if $flags =~ /i/; # always produces integer
128 $argsum |= 32 if $flags =~ /I/; # has corresponding int op
129 $argsum |= 64 if $flags =~ /d/; # danger, unknown side effects
131 for $arg (split(' ',$args{$_})) {
132 $argnum = ($arg =~ s/\?//) ? 8 : 0;
133 $argnum += $argnum{$arg};
134 $argsum += $argnum * $mul;
137 $argsum = sprintf("0x%08x", $argsum);
138 print "\t", &tab(3, "$argsum,"), "/* \L$_ */\n";
146 ###########################################################################
149 $t .= "\t" x ($l - (length($t) + 1) / 8);
152 ###########################################################################
157 null null operation ck_null 0
159 scalar scalar ck_fun s S
163 pushmark pushmark ck_null s
164 wantarray wantarray ck_null is
166 const constant item ck_null s
167 interp interpreted string ck_null 0
169 gvsv scalar variable ck_null ds
170 gv glob value ck_null ds
171 padsv private variable ck_null 0
172 padav private array ck_null 0
173 padhv private hash ck_null 0
175 pushre push regexp ck_null 0
177 # References and stuff.
179 rv2gv ref-to-glob cast ck_rvconst ds
180 sv2len scalar value length ck_null ist
181 rv2sv ref-to-scalar cast ck_rvconst ds
182 av2arylen array length ck_null is
183 rv2cv subroutine reference ck_rvconst d
184 refgen backslash reference ck_null fst L
185 ref reference-type operator ck_fun st S
186 bless bless ck_fun s S
190 backtick backticks ck_null t
192 readline <HANDLE> ck_null t
193 rcatline append I/O operator ck_null t
195 # Bindable operators.
197 regcomp regexp compilation ck_null s S
198 match pattern match ck_match d
199 subst substitution ck_null dis S
200 substcont substitution cont ck_null dis
201 trans character translation ck_null is S
205 sassign scalar assignment ck_null s
206 aassign list assignment ck_null t L L
208 schop scalar chop ck_null t
209 chop chop ck_chop mt L
210 defined defined operator ck_lfun is S?
211 undef undef operator ck_lfun s S?
212 study study ck_fun st S?
214 preinc preincrement ck_lfun s S
215 predec predecrement ck_lfun s S
216 postinc postincrement ck_lfun st S
217 postdec postdecrement ck_lfun st S
219 # Ordinary operators.
221 pow exponentiation ck_null fst S S
223 multiply multiplication ck_null fst S S
224 divide division ck_null fst S S
225 modulo modulus ck_null ifst S S
226 repeat repeat ck_repeat mt L S
228 add addition ck_null Ifst S S
229 intadd integer addition ck_null ifst S S
230 subtract subtraction ck_null fst S S
231 concat concatenation ck_concat fst S S
233 left_shift left bitshift ck_null ifst S S
234 right_shift right bitshift ck_null ifst S S
236 lt numeric lt ck_null ifs S S
237 gt numeric gt ck_null ifs S S
238 le numeric le ck_null ifs S S
239 ge numeric ge ck_null ifs S S
240 eq numeric eq ck_null ifs S S
241 ne numeric ne ck_null ifs S S
242 ncmp spaceship ck_null ifst S S
244 slt string lt ck_null ifs S S
245 sgt string gt ck_null ifs S S
246 sle string le ck_null ifs S S
247 sge string ge ck_null ifs S S
248 seq string eq ck_null ifs S S
249 sne string ne ck_null ifs S S
250 scmp string comparison ck_null ifst S S
252 bit_and bit and ck_null fst S S
253 xor xor ck_null fst S S
254 bit_or bit or ck_null fst S S
256 negate negate ck_null fst S
257 not not ck_null ifs S
258 complement 1's complement ck_null fst S
260 # High falutin' math.
262 atan2 atan2 ck_fun fst S S
263 sin sin ck_fun fst S?
264 cos cos ck_fun fst S?
265 rand rand ck_fun st S?
266 srand srand ck_fun s S?
267 exp exp ck_fun fst S?
268 log log ck_fun fst S?
269 sqrt sqrt ck_fun fst S?
271 int int ck_fun fst S?
272 hex hex ck_fun ist S?
273 oct oct ck_fun ist S?
277 length length ck_lengthconst ist S
278 substr substr ck_fun st S S S?
279 vec vec ck_fun ist S S S
281 index index ck_index ist S S S?
282 rindex rindex ck_index ist S S S?
284 sprintf sprintf ck_fun mst S L
285 formline formline ck_formline ms S L
286 ord ord ck_fun ifst S?
287 crypt crypt ck_fun fst S S
288 ucfirst upper case first ck_fun ft S
289 lcfirst lower case first ck_fun ft S
290 uc upper case ck_fun ft S
291 lc lower case ck_fun ft S
295 rv2av array deref ck_rvconst dt
296 aelemfast known array element ck_null s A S
297 aelem array element ck_aelem s A S
298 aslice array slice ck_null m A L
300 # Associative arrays.
303 values values ck_fun t H
305 delete delete ck_null s H S
306 rv2hv associative array deref ck_rvconst dt
307 helem associative array elem ck_null s H S
308 hslice associative array slice ck_null m H L
310 # Explosives and implosives.
312 unpack unpack ck_fun 0 S S
313 pack pack ck_fun mst S L
314 split split ck_split t S S S
315 join join ck_fun mst S L
319 list list ck_null m L
320 lslice list slice ck_null 0 H L L
321 anonlist anonymous list ck_null m L
322 anonhash anonymous hash ck_null m L
324 splice splice ck_fun m A S S? L
325 push push ck_fun imst A L
327 shift shift ck_shift s A
328 unshift unshift ck_fun imst A L
329 sort sort ck_sort m C? L
330 reverse reverse ck_fun mt L
332 grepstart grep ck_grep dm C L
333 grepwhile grep iterator ck_null dt
337 range flipflop ck_null 0 S S
338 flip range (or flip) ck_null 0 S S
339 flop range (or flop) ck_null 0
343 and logical and ck_null 0
344 or logical or ck_null 0
345 cond_expr conditional expression ck_null 0
346 andassign logical and assignment ck_null s
347 orassign logical or assignment ck_null s
349 method method lookup ck_null dt
350 entersubr subroutine entry ck_subr dm L
351 leavesubr subroutine exit ck_null 0
352 caller caller ck_fun t S?
353 warn warn ck_fun imst L
354 die die ck_fun dimst L
355 reset reset ck_fun is S?
357 lineseq line sequence ck_null 0
358 nextstate next statement ck_null s
359 dbstate debug next statement ck_null s
360 unstack unstack ck_null s
361 enter block entry ck_null 0
362 leave block exit ck_null 0
363 enteriter foreach loop entry ck_null d
364 iter foreach loop iterator ck_null 0
365 enterloop loop entry ck_null d
366 leaveloop loop exit ck_null s
367 return return ck_fun dm L
373 exit exit ck_fun ds S?
375 nswitch numeric switch ck_null d
376 cswitch character switch ck_null d
380 open open ck_fun ist F S?
381 close close ck_fun is F?
382 pipe_op pipe ck_fun is F F
384 fileno fileno ck_fun ist F
385 umask umask ck_fun ist S?
386 binmode binmode ck_fun s F
388 dbmopen dbmopen ck_fun ist H S S
389 dbmclose dbmclose ck_fun is H
391 sselect select system call ck_select t S S S S
392 select select ck_select st F?
394 getc getc ck_eof st F?
395 read read ck_fun imst F R S S?
396 enterwrite write ck_fun dis F?
397 leavewrite write exit ck_null 0
399 prtf prtf ck_listiob ims F? L
400 print print ck_listiob ims F? L
402 sysread sysread ck_fun imst F R S S?
403 syswrite syswrite ck_fun imst F S S S?
405 send send ck_fun imst F S S S?
406 recv recv ck_fun imst F R S S
409 tell tell ck_fun st F?
410 seek seek ck_fun s F S S
411 truncate truncate ck_trunc is S S
413 fcntl fcntl ck_fun st F S S
414 ioctl ioctl ck_fun st F S S
415 flock flock ck_fun ist F S
419 socket socket ck_fun is F S S S
420 sockpair socketpair ck_fun is F F S S S
422 bind bind ck_fun is F S
423 connect connect ck_fun is F S
424 listen listen ck_fun is F S
425 accept accept ck_fun ist F F
426 shutdown shutdown ck_fun ist F S
428 gsockopt getsockopt ck_fun is F S S
429 ssockopt setsockopt ck_fun is F S S S
431 getsockname getsockname ck_fun is F
432 getpeername getpeername ck_fun is F
436 lstat lstat ck_ftst 0 F
437 stat stat ck_ftst 0 F
438 ftrread -R ck_ftst is F
439 ftrwrite -W ck_ftst is F
440 ftrexec -X ck_ftst is F
441 fteread -r ck_ftst is F
442 ftewrite -w ck_ftst is F
443 fteexec -x ck_ftst is F
445 fteowned -O ck_ftst is F
446 ftrowned -o ck_ftst is F
447 ftzero -z ck_ftst is F
448 ftsize -s ck_ftst ist F
449 ftmtime -M ck_ftst st F
450 ftatime -A ck_ftst st F
451 ftctime -C ck_ftst st F
452 ftsock -S ck_ftst is F
453 ftchr -c ck_ftst is F
454 ftblk -b ck_ftst is F
455 ftfile -f ck_ftst is F
456 ftdir -d ck_ftst is F
457 ftpipe -p ck_ftst is F
458 ftlink -l ck_ftst is F
459 ftsuid -u ck_ftst is F
460 ftsgid -g ck_ftst is F
461 ftsvtx -k ck_ftst is F
462 fttty -t ck_ftst is F
463 fttext -T ck_ftst is F
464 ftbinary -B ck_ftst is F
468 chdir chdir ck_fun ist S?
469 chown chown ck_fun imst L
470 chroot chroot ck_fun ist S?
471 unlink unlink ck_fun imst L
472 chmod chmod ck_fun imst L
473 utime utime ck_fun imst L
474 rename rename ck_fun ist S S
475 link link ck_fun ist S S
476 symlink symlink ck_fun ist S S
477 readlink readlink ck_fun st S?
478 mkdir mkdir ck_fun ist S S
479 rmdir rmdir ck_fun ist S?
483 open_dir opendir ck_fun is F S
484 readdir readdir ck_fun 0 F
485 telldir telldir ck_fun st F
486 seekdir seekdir ck_fun s F S
487 rewinddir rewinddir ck_fun s F
488 closedir closedir ck_fun is F
492 fork fork ck_null ist
493 wait wait ck_null ist
494 waitpid waitpid ck_fun ist S S
495 system system ck_exec imst S? L
496 exec exec ck_exec dimst S? L
497 kill kill ck_fun dimst L
498 getppid getppid ck_null ist
499 getpgrp getpgrp ck_fun ist S?
500 setpgrp setpgrp ck_fun ist S S
501 getpriority getpriority ck_fun ist S S
502 setpriority setpriority ck_fun ist S S S
506 time time ck_null ist
508 localtime localtime ck_fun t S?
509 gmtime gmtime ck_fun t S?
510 alarm alarm ck_fun ist S?
511 sleep sleep ck_fun ist S?
515 shmget shmget ck_fun imst S S S
516 shmctl shmctl ck_fun imst S S S
517 shmread shmread ck_fun imst S S S S
518 shmwrite shmwrite ck_fun ist S S S S
522 msgget msgget ck_fun imst S S
523 msgctl msgctl ck_fun imst S S S
524 msgsnd msgsnd ck_fun imst S S S
525 msgrcv msgrcv ck_fun imst S S S S S
529 semget semget ck_fun imst S S S
530 semctl semctl ck_fun imst S S S S
531 semop semop ck_fun imst S S S
535 require require ck_fun d S
536 dofile do 'file' ck_fun d S
537 entereval eval string ck_eval d S
538 leaveeval eval exit ck_null 0 S
539 evalonce eval constant string ck_null d S
540 entertry eval block ck_null 0
541 leavetry eval block exit ck_null 0
545 ghbyname gethostbyname ck_fun 0 S
546 ghbyaddr gethostbyaddr ck_fun 0 S S
547 ghostent gethostent ck_null 0
548 gnbyname getnetbyname ck_fun 0 S
549 gnbyaddr getnetbyaddr ck_fun 0 S S
550 gnetent getnetent ck_null 0
551 gpbyname getprotobyname ck_fun 0 S
552 gpbynumber getprotobynumber ck_fun 0 S
553 gprotoent getprotoent ck_null 0
554 gsbyname getservbyname ck_fun 0 S S
555 gsbyport getservbyport ck_fun 0 S S
556 gservent getservent ck_null 0
557 shostent sethostent ck_fun is S
558 snetent setnetent ck_fun is S
559 sprotoent setprotoent ck_fun is S
560 sservent setservent ck_fun is S
561 ehostent endhostent ck_null is
562 enetent endnetent ck_null is
563 eprotoent endprotoent ck_null is
564 eservent endservent ck_null is
565 gpwnam getpwnam ck_fun 0 S
566 gpwuid getpwuid ck_fun 0 S
567 gpwent getpwent ck_null 0
568 spwent setpwent ck_null ist
569 epwent endpwent ck_null ist
570 ggrnam getgrnam ck_fun 0 S
571 ggrgid getgrgid ck_fun 0 S
572 ggrent getgrent ck_null 0
573 sgrent setgrent ck_null ist
574 egrent endgrent ck_null ist
575 getlogin getlogin ck_null st
579 syscall syscall ck_fun ist S L