| 1 | #!/usr/bin/perl
|
|---|
| 2 | BEGIN {
|
|---|
| 3 | # Get function prototypes
|
|---|
| 4 | require 'regen_lib.pl';
|
|---|
| 5 | }
|
|---|
| 6 |
|
|---|
| 7 | $opcode_new = 'opcode.h-new';
|
|---|
| 8 | $opname_new = 'opnames.h-new';
|
|---|
| 9 | open(OC, ">$opcode_new") || die "Can't create $opcode_new: $!\n";
|
|---|
| 10 | binmode OC;
|
|---|
| 11 | open(ON, ">$opname_new") || die "Can't create $opname_new: $!\n";
|
|---|
| 12 | binmode ON;
|
|---|
| 13 | select OC;
|
|---|
| 14 |
|
|---|
| 15 | # Read data.
|
|---|
| 16 |
|
|---|
| 17 | while (<DATA>) {
|
|---|
| 18 | chop;
|
|---|
| 19 | next unless $_;
|
|---|
| 20 | next if /^#/;
|
|---|
| 21 | ($key, $desc, $check, $flags, $args) = split(/\t+/, $_, 5);
|
|---|
| 22 |
|
|---|
| 23 | warn qq[Description "$desc" duplicates $seen{$desc}\n] if $seen{$desc};
|
|---|
| 24 | die qq[Opcode "$key" duplicates $seen{$key}\n] if $seen{$key};
|
|---|
| 25 | $seen{$desc} = qq[description of opcode "$key"];
|
|---|
| 26 | $seen{$key} = qq[opcode "$key"];
|
|---|
| 27 |
|
|---|
| 28 | push(@ops, $key);
|
|---|
| 29 | $desc{$key} = $desc;
|
|---|
| 30 | $check{$key} = $check;
|
|---|
| 31 | $ckname{$check}++;
|
|---|
| 32 | $flags{$key} = $flags;
|
|---|
| 33 | $args{$key} = $args;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | # Emit defines.
|
|---|
| 37 |
|
|---|
| 38 | $i = 0;
|
|---|
| 39 | print <<"END";
|
|---|
| 40 | /* -*- buffer-read-only: t -*-
|
|---|
| 41 | *
|
|---|
| 42 | * opcode.h
|
|---|
| 43 | *
|
|---|
| 44 | * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|---|
| 45 | * 2000, 2001, 2002, 2003, 2004, 2005, 2006 by Larry Wall and others
|
|---|
| 46 | *
|
|---|
| 47 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 48 | * License or the Artistic License, as specified in the README file.
|
|---|
| 49 | *
|
|---|
| 50 | * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
|
|---|
| 51 | * This file is built by opcode.pl from its data. Any changes made here
|
|---|
| 52 | * will be lost!
|
|---|
| 53 | */
|
|---|
| 54 |
|
|---|
| 55 | #define Perl_pp_i_preinc Perl_pp_preinc
|
|---|
| 56 | #define Perl_pp_i_predec Perl_pp_predec
|
|---|
| 57 | #define Perl_pp_i_postinc Perl_pp_postinc
|
|---|
| 58 | #define Perl_pp_i_postdec Perl_pp_postdec
|
|---|
| 59 |
|
|---|
| 60 | END
|
|---|
| 61 |
|
|---|
| 62 | print ON <<"END";
|
|---|
| 63 | /* -*- buffer-read-only: t -*-
|
|---|
| 64 | *
|
|---|
| 65 | * opnames.h
|
|---|
| 66 | *
|
|---|
| 67 | * Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
|---|
| 68 | * by Larry Wall and others
|
|---|
| 69 | *
|
|---|
| 70 | * You may distribute under the terms of either the GNU General Public
|
|---|
| 71 | * License or the Artistic License, as specified in the README file.
|
|---|
| 72 | *
|
|---|
| 73 | *
|
|---|
| 74 | * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
|
|---|
| 75 | * This file is built by opcode.pl from its data. Any changes made here
|
|---|
| 76 | * will be lost!
|
|---|
| 77 | */
|
|---|
| 78 |
|
|---|
| 79 | typedef enum opcode {
|
|---|
| 80 | END
|
|---|
| 81 |
|
|---|
| 82 | for (@ops) {
|
|---|
| 83 | print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
|
|---|
| 84 | }
|
|---|
| 85 | print ON "\t", &tab(3,"OP_max"), "\n";
|
|---|
| 86 | print ON "} opcode;\n";
|
|---|
| 87 | print ON "\n#define MAXO ", scalar @ops, "\n";
|
|---|
| 88 | print ON "#define OP_phoney_INPUT_ONLY -1\n";
|
|---|
| 89 | print ON "#define OP_phoney_OUTPUT_ONLY -2\n\n";
|
|---|
| 90 |
|
|---|
| 91 | # Emit op names and descriptions.
|
|---|
| 92 |
|
|---|
| 93 | print <<END;
|
|---|
| 94 |
|
|---|
| 95 | START_EXTERN_C
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|
| 98 | #define OP_NAME(o) ((o)->op_type == OP_CUSTOM ? custom_op_name(o) : \\
|
|---|
| 99 | PL_op_name[(o)->op_type])
|
|---|
| 100 | #define OP_DESC(o) ((o)->op_type == OP_CUSTOM ? custom_op_desc(o) : \\
|
|---|
| 101 | PL_op_desc[(o)->op_type])
|
|---|
| 102 |
|
|---|
| 103 | #ifndef DOINIT
|
|---|
| 104 | EXT char *PL_op_name[];
|
|---|
| 105 | #else
|
|---|
|
|---|