perl6-internals
[Top] [All Lists]

[perl #58452] Re: [PGE][BUG][PATCH] Apostrophes in optables are compiled

Subject: [perl #58452] Re: [PGE][BUG][PATCH] Apostrophes in optables are compiled to broken pir
From: "Patrick R. Michaud via RT" <bugs-parrot-track@netlabs.develooper.com>
Date: Fri, 29 Aug 2008 13:35:14 -0700
Cc: perl6-internals@perl.org
Delivered-to: mailing list perl6-all@perl.org
Delivered-to: perl6-all-poster@perl.org
Delivered-to: mailing list perl6-internals@perl.org
Delivered-to: perl6-internals@perl.org
In-reply-to: <48B7EE9D.1060805@casella.verplant.org>
List-help: <mailto:perl6-all-help@perl.org>
List-id: <perl6-all.perl.org>
List-id: <perl6-internals.perl.org>
List-post: <mailto:perl6-all@perl.org>
List-subscribe: <mailto:perl6-all-subscribe@perl.org>
List-unsubscribe: <mailto:perl6-all-unsubscribe@perl.org>
Mailing-list: contact perl6-all-help@perl.org; run by ezmlm
Managed-by: RT 3.6.HEAD (http://www.bestpractical.com/rt/)
References: <RT-Ticket-58452@perl.org> <K6BHM6$732881925E9B92BA38AD2B2FAAE0384B@multidominios> <48B7EE9D.1060805@casella.verplant.org>
Reply-to: bugs-parrot-track@netlabs.develooper.com
Rt-originator: pmichaud@pobox.com
Rt-ticket: perl #58452
Correct that this is a bug, but the patch using Data/Escape.pbc is
a bit problematic.  Data/Escape.pbc is woefully out of date, and also
has problems in that it doesn't correctly generate PIR constants for
unicode strings, as would be the case with:

    proto prefix:<«> { ... }

So, the solution is to use the 'escape' method of the CodeString PMC,
which is what other parts of PGE and PCT use when they need to
generate PIR constant literals from string values (including
unicode and binary strings).  For reference I've copied the resulting
patch below.

Problem fixed in r....., many thanks for the report and patch, both
of which made it very easy to see what needed to be fixed.

Pm


===================================================================
--- runtime/parrot/library/PGE/Perl6Grammar.pir (revision 30633)
+++ runtime/parrot/library/PGE/Perl6Grammar.pir (working copy)
@@ -366,8 +366,7 @@
     goto trait_sub
   trait_arg:
     if trait == 'parsed' goto trait_sub
-    arg = concat "'", arg
-    arg = concat arg, "'"
+    arg = optable.'escape'(arg)
     goto trait_arg_done
   trait_sub:
     optable.emit("          $P0 = get_hll_global ['%0'], '%1'",
namespace, arg)
@@ -382,7 +381,8 @@
     concat traitlist, arg
     goto trait_loop
   trait_end:
-    optable.emit("          optable.newtok('%0'%1)", name, traitlist)
+    name = optable.'escape'(name)
+    optable.emit("          optable.newtok(%0%1)", name, traitlist)
   .return ()
 .end



<Prev in Thread] Current Thread [Next in Thread>