[svn:parrot] r38407 - in branches/pmc_pct/compilers/pmc: src t tools

bacek at svn.parrot.org bacek at svn.parrot.org
Wed Apr 29 12:20:20 UTC 2009


Author: bacek
Date: Wed Apr 29 12:20:20 2009
New Revision: 38407
URL: https://trac.parrot.org/parrot/changeset/38407

Log:
Build VTable hash

Modified:
   branches/pmc_pct/compilers/pmc/src/vtable_info.pm
   branches/pmc_pct/compilers/pmc/t/05-vtable-info.t
   branches/pmc_pct/compilers/pmc/tools/vtable_pm.pl

Modified: branches/pmc_pct/compilers/pmc/src/vtable_info.pm
==============================================================================
--- branches/pmc_pct/compilers/pmc/src/vtable_info.pm	Wed Apr 29 12:19:58 2009	(r38406)
+++ branches/pmc_pct/compilers/pmc/src/vtable_info.pm	Wed Apr 29 12:20:20 2009	(r38407)
@@ -11,7 +11,7 @@
 
 # Ordered list of VTable methods
 our @?VTABLES := build_vtable_list();
-our %?VTABLES;
+our %?VTABLES := build_vtable_hash();
 
 sub build_vtable_list() {
     my @res;
@@ -1720,11 +1720,27 @@
     @res;
 }
 
+# Generate hash from list
+sub build_vtable_hash() {
+    my %res;
+    our @?VTABLES;
+    for (@?VTABLES) {
+        my $name    := $_.name;
+        %res{$name} := $_;
+    }
+    %res;
+}
+
 sub vtable_list() {
     our @?VTABLES;
     @?VTABLES;
 }
 
+sub vtable_hash() {
+    our %?VTABLES;
+    %?VTABLES;
+}
+
 # Local Variables:
 #   mode: perl6
 #   fill-column: 100

Modified: branches/pmc_pct/compilers/pmc/t/05-vtable-info.t
==============================================================================
--- branches/pmc_pct/compilers/pmc/t/05-vtable-info.t	Wed Apr 29 12:19:58 2009	(r38406)
+++ branches/pmc_pct/compilers/pmc/t/05-vtable-info.t	Wed Apr 29 12:20:20 2009	(r38407)
@@ -6,13 +6,20 @@
 .include 'test_more.pir'
     load_bytecode 'compilers/pmc/pmc.pbc'
 
-    plan(1)
+    plan(2)
 
     $P0 = get_hll_global ["PMC"; "VTableInfo"], 'vtable_list'
     $P1 = $P0()
 
     $I0 = elements $P1
-    ok($I0, "We've got some vtables")
+    ok($I0, "We've got some vtables in list")
+    
+    $P0 = get_hll_global ["PMC"; "VTableInfo"], 'vtable_hash'
+    $P1 = $P0()
+
+    $I0 = elements $P1
+    say $I0
+    ok($I0, "We've got some vtables in hash")
 .end
 
 

Modified: branches/pmc_pct/compilers/pmc/tools/vtable_pm.pl
==============================================================================
--- branches/pmc_pct/compilers/pmc/tools/vtable_pm.pl	Wed Apr 29 12:19:58 2009	(r38406)
+++ branches/pmc_pct/compilers/pmc/tools/vtable_pm.pl	Wed Apr 29 12:20:20 2009	(r38407)
@@ -29,7 +29,7 @@
 
 # Ordered list of VTable methods
 our @?VTABLES := build_vtable_list();
-our %?VTABLES;
+our %?VTABLES := build_vtable_hash();
 
 HEADER
 
@@ -53,11 +53,27 @@
 
 print <<'FOOTER';
 
+# Generate hash from list
+sub build_vtable_hash() {
+    my %res;
+    our @?VTABLES;
+    for (@?VTABLES) {
+        my $name    := $_.name;
+        %res{$name} := $_;
+    }
+    %res;
+}
+
 sub vtable_list() {
     our @?VTABLES;
     @?VTABLES;
 }
 
+sub vtable_hash() {
+    our %?VTABLES;
+    %?VTABLES;
+}
+
 # Local Variables:
 #   mode: perl6
 #   fill-column: 100


More information about the parrot-commits mailing list