[svn:parrot] r46882 - in branches/ops_pct/compilers/opsc: . src/Ops
cotto at svn.parrot.org
cotto at svn.parrot.org
Sat May 22 08:36:22 UTC 2010
Author: cotto
Date: Sat May 22 08:36:22 2010
New Revision: 46882
URL: https://trac.parrot.org/parrot/changeset/46882
Log:
[opsc] add untested, incomplete and misplaced code to regenerate ops.num and opsenum.h
Modified:
branches/ops_pct/compilers/opsc/ops2c.nqp
branches/ops_pct/compilers/opsc/src/Ops/Renumberer.pm
Modified: branches/ops_pct/compilers/opsc/ops2c.nqp
==============================================================================
--- branches/ops_pct/compilers/opsc/ops2c.nqp Sat May 22 08:34:29 2010 (r46881)
+++ branches/ops_pct/compilers/opsc/ops2c.nqp Sat May 22 08:36:22 2010 (r46882)
@@ -84,7 +84,11 @@
$renum := Ops::Renumberer.new( :ops_file($f) );
if $renum.needs_renumbering {
- say("renumbering ops.num...");
+ say("# renumbering ops.num...");
+ $renum.renumber_ops();
+ }
+ else {
+ say("# ops.num looks fine: no renumbering needed");
}
}
else {
Modified: branches/ops_pct/compilers/opsc/src/Ops/Renumberer.pm
==============================================================================
--- branches/ops_pct/compilers/opsc/src/Ops/Renumberer.pm Sat May 22 08:34:29 2010 (r46881)
+++ branches/ops_pct/compilers/opsc/src/Ops/Renumberer.pm Sat May 22 08:36:22 2010 (r46882)
@@ -90,28 +90,45 @@
method renumber_ops() {
#grab all ops in ops.num
- #record which ones are fixed and which just need to be somewhere
- #iterate through ops::file's ops
- #if this op is fixed
- #give it the fixed number
- #record the fixed number
- #else
- #give this op ++fixed
+ my %fixed_ops := hash();
+ my %numbered_ops := hash();
+ my $found_dynamic := 0;
+ my $max_op_num := 0;
+ my $ops_num_fh := pir::open__PSs(self<ops_file>.oplib.num_file, 'w')
+ || die("Can't open "~ self<ops_file>.oplib.num_file);
+
+ #record which ones have fixed numbers and which just need to be somewhere in ops.num
+ for self<ops_file>.oplib.num_file_lines -> $line {
+
+ #copy all lines through ###DYNAMIC### into the new ops.num verbatim
+ unless $found_dynamic {
+ $ops_num_fh.print(~$line);
+ }
+
+ if $line<op> {
+ if $found_dynamic {
+ %numbered_ops{ $line<op><name> } := 1;
+ }
+ else {
+ %fixed_ops{ $line<op><name> } := +$line<op><number>;
+ $max_op_num := +$line<op><number>;
+ }
+ }
+ elsif $line<dynamic> {
+ $found_dynamic := 1;
+ }
+ }
+
+ #XXX: print header to include/parrot/opsenum.h (ignore fixed ops)
+
+ for self<ops_file>.ops -> $op {
+ if %numbered_ops.exists( $op.full_name ) {
+ $max_op_num++;
+ $ops_num_fh.print($op.full_name ~ " " ~ $max_op_num ~ "\n");
+ }
+ }
}
-=begin ACCESSORS
-
-Various methods for accessing internals.
-
-=over 4
-
-=item * C<skiptable>
-
-=end ACCESSORS
-
-method skiptable() { self<skiptable>; }
-
-
# Local Variables:
# mode: perl6
# fill-column: 100
More information about the parrot-commits
mailing list