Allison Randal wrote:
Patrick R. Michaud wrote:
In pdd15oo, there seems to be an issue about using load_bytecode
to load :method subs after a class has been created.

Working now for both load_bytecode and the eval case.

One problem: with this change, every named method is inserted into the class associated with its namespace. As specified, it throws an exception when you try to readd a method of the same name, unless you explicitly tell it to override the old method (this metamodel enforces more than the previous one).

That's all good, except that PGE::P6Regex has a routine 'compile_p6regex' that regenerates the same method named '_regex' in the PGE::Grammar namespace for every anonymous rule (every rule that has no name and no grammar specified). PGE::P5Regex has the same problem.

The attached patch creates the rule's method in a randomly numbered faux-anonymous class, instead of PGE::Grammar. This gets the tests to pass again, but it's not a permanent solution. You probably want to use :anon methods, or delete the '_regex' method from the class when you're done with it.

There's a similar problem in t/compilers/pge/06-grammar.t, which keeps recompiling a test rule named 'main', into the class Simple::Test.

I'll look at it more tomorrow.

Allison
Index: compilers/pge/PGE/P6Regex.pir
===================================================================
--- compilers/pge/PGE/P6Regex.pir       (revision 21905)
+++ compilers/pge/PGE/P6Regex.pir       (working copy)
@@ -36,7 +36,12 @@
     adverbs['grammar'] = $S0
     goto with_grammar
   adverb_grammar_1:
-    adverbs['grammar'] = 'PGE::Grammar'
+    $P0 = new 'Random'
+    $I0 = $P0
+    $S0 = $I0
+    $S0 = 'PGE::Grammar::Anon' . $S0
+    adverbs['grammar'] = $S0
+#    adverbs['grammar'] = 'PGE::Grammar'
   with_grammar:
     $I0 = exists adverbs['name']
     if $I0 goto with_name

Reply via email to