Front page | perl.perl6.internals |
Postings from November 2001
[PMC] Patch to combine core.ops and vtable.ops into core_ops.{c,h,pm}
From:
Jeff G
Date:
November 22, 2001 17:22
Subject:
[PMC] Patch to combine core.ops and vtable.ops into core_ops.{c,h,pm}
Message ID:
3BFDA500.540C6C1A@speakeasy.net
Slightly cleaner patch than the crude method of cat'ing the ops files
into one .ops file.
Also doesn't require patching all the places dependent upon 'core'.
-Jeff
<jgoff@speakeasy.net>
---cut here---
diff -ru parrot_orig/Makefile.in parrot/Makefile.in
--- parrot_orig/Makefile.in Thu Nov 22 16:52:23 2001
+++ parrot/Makefile.in Thu Nov 22 19:44:11 2001
@@ -7,12 +7,12 @@
$(INC)/register.h $(INC)/string.h $(INC)/events.h $(INC)/interpreter.h
\
$(INC)/memory.h $(INC)/parrot.h $(INC)/stacks.h $(INC)/packfile.h \
$(INC)/global_setup.h $(INC)/vtable.h $(INC)/oplib/core_ops.h \
-$(INC)/runops_cores.h $(INC)/trace.h $(INC)/oplib/vtable_ops.h \
+$(INC)/runops_cores.h $(INC)/trace.h \
$(INC)/pmc.h $(INC)/resources.h $(INC)/platform.h
O_FILES = global_setup$(O) interpreter$(O) parrot$(O) register$(O) \
core_ops$(O) memory$(O) packfile$(O) stacks$(O) string$(O) encoding$(O)
\
-chartype$(O) runops_cores$(O) trace$(O) vtable_ops$(O) pmc$(O) \
+chartype$(O) runops_cores$(O) trace$(O) pmc$(O) \
encodings/singlebyte$(O) encodings/utf8$(O) encodings/utf16$(O) \
encodings/utf32$(O) chartypes/unicode$(O) chartypes/usascii$(O)
resources$(O) \
platform$(O) classes/perlint$(O) classes/perlstring$(O)
classes/perlnum$(O)
@@ -54,10 +54,7 @@
cd examples/assembly; make mops.pbc PERL=$(PERL)
Parrot/OpLib/core.pm: core.ops ops2pm.pl
- $(PERL) ops2pm.pl core.ops
-
-Parrot/OpLib/vtable.pm: vtable.ops ops2pm.pl
- $(PERL) ops2pm.pl vtable.ops
+ $(PERL) ops2pm.pl core.ops vtable.ops
examples/assembly/mops.c: examples/assembly/mops.pbc pbc2c.pl
$(PERL) pbc2c.pl examples/assembly/mops.pbc >
examples/assembly/mops.c
@@ -111,15 +108,12 @@
core_ops$(O): $(H_FILES) core_ops.c
-core_ops.c $(INC)/oplib/core_ops.h: core.ops ops2c.pl
- $(PERL) ops2c.pl core.ops
+core_ops.c $(INC)/oplib/core_ops.h: core.ops vtable.ops ops2c.pl
+ $(PERL) ops2c.pl core.ops vtable.ops
vtable.ops: make_vtable_ops.pl
$(PERL) make_vtable_ops.pl > vtable.ops
-vtable_ops.c $(INC)/oplib/vtable_ops.h: vtable.ops ops2c.pl
- $(PERL) ops2c.pl vtable.ops
-
$(INC)/config.h: Configure.pl config_h.in
$(PERL) Configure.pl
@@ -136,7 +130,7 @@
$(RM_F) *.s core_ops.c $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) $(INC)/vtable.h
$(RM_F) $(INC)/oplib/core_ops.h
- $(RM_F) $(INC)/oplib/vtable_ops.h vtable_ops.c vtable.ops
+ $(RM_F) vtable.ops
$(RM_F) $(TEST_PROG) $(PDISASM) $(PDUMP)
$(RM_F) t/op/*.pasm t/op/*.pbc t/op/*.out
$(RM_F) examples/assembly/mops$(EXE) examples/assembly/mops.c
diff -ru parrot_orig/ops2c.pl parrot/ops2c.pl
--- parrot_orig/ops2c.pl Thu Nov 22 16:52:23 2001
+++ parrot/ops2c.pl Thu Nov 22 19:42:10 2001
@@ -9,16 +9,20 @@
use strict;
use Parrot::OpsFile;
+sub Usage {
+ print STDERR <<_EOF_;
+usage: $0 input.ops [input2.ops ...]\n";
+_EOF_
+ exit 1;
+}
#
# Process command-line argument:
#
-if (@ARGV != 1) {
- die "ops2c.pl: usage: perl ops2c.pl input.ops\n";
-}
+Usage() unless @ARGV;
-my $file = $ARGV[0];
+my $file = 'core.ops';
my $base = $file;
$base =~ s/\.ops$//;
@@ -32,10 +36,22 @@
#
# Read the input file:
#
+$file = shift @ARGV;
+die "$0: Could not read ops file '$file'!\n" unless -e $file;
my $ops = new Parrot::OpsFile $file;
-die "ops2c.pl: Could not read ops file '$file'!\n" unless $ops;
+for $file (@ARGV) {
+ die "$0: Could not read ops file '$file'!\n" unless -e $file;
+ my $temp_ops = new Parrot::OpsFile $file;
+ for(@{$temp_ops->{OPS}}) {
+ push @{$ops->{OPS}},$_;
+ }
+}
+my $cur_code = 0;
+for(@{$ops->{OPS}}) {
+ $_->{CODE}=$cur_code++;
+}
my $num_ops = scalar $ops->ops;
my $num_entries = $num_ops + 1; # For trailing NULL
diff -ru parrot_orig/ops2pm.pl parrot/ops2pm.pl
--- parrot_orig/ops2pm.pl Thu Nov 22 16:52:23 2001
+++ parrot/ops2pm.pl Thu Nov 22 19:42:10 2001
@@ -13,16 +13,21 @@
#$Data::Dumper::Terse = 1;
#$Data::Dumper::Indent = 0;
+sub Usage {
+ print STDERR <<_EOF_;
+usage: $0 input.ops [input2.ops ...]
+_EOF_
+ exit;
+}
+
#
# Process command-line argument:
#
-if (@ARGV != 1) {
- die "ops2c.pl: usage: perl ops2pm.pl input.ops\n";
-}
+Usage() unless @ARGV;
-my $file = $ARGV[0];
+my $file = 'core.ops';
my $base = $file;
$base =~ s/\.ops$//;
@@ -33,12 +38,27 @@
#
-# Read the input file:
+# Read the first input file:
#
+use Data::Dumper;
+
+$file = shift @ARGV;
+die "$0: Could not read ops file '$file'!\n" unless -e $file;
my $ops = new Parrot::OpsFile $file;
-die "ops2pm.pl: Could not read ops file '$file'!\n" unless $ops;
+for $file (@ARGV) {
+ die "$0: Could not read ops file '$file'!\n" unless -e $file;
+ my $temp_ops = new Parrot::OpsFile $file;
+ for(@{$temp_ops->{OPS}}) {
+ push @{$ops->{OPS}},$_;
+ }
+}
+my $cur_code = 0;
+for(@{$ops->{OPS}}) {
+ $_->{CODE}=$cur_code++;
+}
+
my $num_ops = scalar $ops->ops;
my $num_entries = $num_ops + 1; # For trailing NULL
@@ -49,10 +69,10 @@
#
if (! -d $moddir) {
- mkdir($moddir, 0755) or die "ops2pm.pl: Could not mkdir $moddir:
$!!\n";
+ mkdir($moddir, 0755) or die "$0: Could not mkdir $moddir: $!!\n";
}
open MODULE, ">$module"
- or die "ops2pm.pl: Could not open module file '$module' for writing:
$!!\n";
+ or die "$0: Could not open module file '$module' for writing: $!!\n";
#
---cut here---
-
[PMC] Patch to combine core.ops and vtable.ops into core_ops.{c,h,pm}
by Jeff G