source: trunk/essentials/dev-lang/perl/opcode.pl@ 3314

Last change on this file since 3314 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 24.8 KB
Line 
1#!/usr/bin/perl
2BEGIN {
3 # Get function prototypes
4 require 'regen_lib.pl';
5}
6
7$opcode_new = 'opcode.h-new';
8$opname_new = 'opnames.h-new';
9open(OC, ">$opcode_new") || die "Can't create $opcode_new: $!\n";
10binmode OC;
11open(ON, ">$opname_new") || die "Can't create $opname_new: $!\n";
12binmode ON;
13select OC;
14
15# Read data.
16
17while (<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;
39print <<"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
60END
61
62print 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
79typedef enum opcode {
80END
81
82for (@ops) {
83 print ON "\t", &tab(3,"OP_\U$_,"), "/* ", $i++, " */\n";
84}
85print ON "\t", &tab(3,"OP_max"), "\n";
86print ON "} opcode;\n";
87print ON "\n#define MAXO ", scalar @ops, "\n";
88print ON "#define OP_phoney_INPUT_ONLY -1\n";
89print ON "#define OP_phoney_OUTPUT_ONLY -2\n\n";
90
91# Emit op names and descriptions.
92
93print <<END;
94
95START_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
104EXT char *PL_op_name[];
105#else