source: trunk/essentials/dev-lang/perl/bytecode.pl@ 3208

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

perl 5.8.8

File size: 14.2 KB
Line 
1BEGIN {
2 push @INC, './lib';
3 require 'regen_lib.pl';
4}
5use strict;
6my %alias_to = (
7 U32 => [qw(line_t)],
8 PADOFFSET => [qw(STRLEN SSize_t)],
9 U16 => [qw(OPCODE short)],
10 U8 => [qw(char)],
11);
12
13my @optype= qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP);
14
15# Nullsv *must* come first in the following so that the condition
16# ($$sv == 0) can continue to be used to test (sv == Nullsv).
17my @specialsv = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no pWARN_ALL pWARN_NONE);
18
19my (%alias_from, $from, $tos);
20while (($from, $tos) = each %alias_to) {
21 map { $alias_from{$_} = $from } @$tos;
22}
23
24my $c_header = <<'EOT';
25/* -*- buffer-read-only: t -*-
26 *
27 * Copyright (c) 1996-1999 Malcolm Beattie
28 *
29 * You may distribute under the terms of either the GNU General Public
30 * License or the Artistic License, as specified in the README file.
31 *
32 */
33/*
34 * This file is autogenerated from bytecode.pl. Changes made here will be lost.
35 */
36EOT
37
38my $perl_header;
39($perl_header = $c_header) =~ s{[/ ]?\*/?}{#}g;
40
41safer_unlink "ext/ByteLoader/byterun.c", "ext/ByteLoader/byterun.h", "ext/B/B/Asmdata.pm";
42
43#
44# Start with boilerplate for Asmdata.pm
45#
46open(ASMDATA_PM, ">ext/B/B/Asmdata.pm") or die "ext/B/B/Asmdata.pm: $!";
47binmode ASMDATA_PM;
48print ASMDATA_PM $perl_header, <<'EOT';
49package B::Asmdata;
50
51our $VERSION = '1.01';
52
53use Exporter;
54@ISA = qw(Exporter);
55@EXPORT_OK = qw(%insn_data @insn_name @optype @specialsv_name);
56our(%insn_data, @insn_name, @optype, @specialsv_name);
57
58EOT
59print ASMDATA_PM <<"EOT";
60\@optype = qw(@optype);
61\@specialsv_name = qw(@specialsv);
62
63# XXX insn_data is initialised this way because with a large
64# %insn_data = (foo => [...], bar => [...], ...) initialiser
65# I get a hard-to-track-down stack underflow and segfault.
66EOT
67
68#
69# Boilerplate for byterun.c
70#
71open(BYTERUN_C, ">ext/ByteLoader/byterun.c") or die "ext/ByteLoader/byterun.c: $!";
72binmode BYTERUN_C;
73print BYTERUN_C $c_header, <<'EOT';
74
75#define PERL_NO_GET_CONTEXT
76#include "EXTERN.h"
77#include "perl.h"
78#define NO_XSLOCKS
79#include "XSUB.h"
80
81#include "byterun.h"
82#include "bytecode.h"
83
84
85static const int optype_size[] = {
86EOT
87my $i = 0;
88for ($i = 0; $i < @optype - 1; $i++) {
89 printf BYTERUN_C " sizeof(%s),\n", $optype[$i], $i;
90}
91printf BYTERUN_C " sizeof(%s)\n", $optype[$i], $i;
92print BYTERUN_C <<'EOT';
93};
94
95void *
96bset_obj_store(pTHX_ struct byteloader_state *bstate, void *obj, I32 ix)
97{
98 if (ix > bstate->bs_obj_list_fill) {
99 Renew(bstate->bs_obj_list, ix + 32, void*);
100 bstate->bs_obj_list_fill = ix + 31;
101 }
102 bstate->bs_obj_list[ix] = obj;