develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34075 - in branches/main/languages/perl6/src: builtins parser

From:
pmichaud
Date:
December 18, 2008 11:20
Subject:
[svn:parrot] r34075 - in branches/main/languages/perl6/src: builtins parser
Message ID:
20081218192017.1D763CBA12@x12.develooper.com
Author: pmichaud
Date: Thu Dec 18 11:20:16 2008
New Revision: 34075

Modified:
   branches/main/languages/perl6/src/builtins/eval.pir
   branches/main/languages/perl6/src/parser/actions.pm

Log:
[rakudo]:  Refactor 'use' statement.


Modified: branches/main/languages/perl6/src/builtins/eval.pir
==============================================================================
--- branches/main/languages/perl6/src/builtins/eval.pir	(original)
+++ branches/main/languages/perl6/src/builtins/eval.pir	Thu Dec 18 11:20:16 2008
@@ -40,6 +40,10 @@
     .tailcall compiler.'evalfiles'(filename)
 
   lang_parrot:
+    ##  load_bytecode currently doesn't accept non-ascii filenames (TT #65)
+    ##  so we'll force it to ascii for now.
+    $I0 = find_charset 'ascii'
+    filename = trans_charset filename, $I0
     load_bytecode filename
     .return (1)
 .end

Modified: branches/main/languages/perl6/src/parser/actions.pm
==============================================================================
--- branches/main/languages/perl6/src/parser/actions.pm	(original)
+++ branches/main/languages/perl6/src/parser/actions.pm	Thu Dec 18 11:20:16 2008
@@ -324,30 +324,19 @@
 method use_statement($/) {
     my $name := ~$<name>;
     my $past;
-    if $name eq 'v6' || $name eq 'lib' {
-        $past := PAST::Stmts.new( :node($/) );
-    }
-    else {
-        $past := PAST::Op.new(
-            PAST::Val.new( :value($name) ),
-            :name('use'),
-            :pasttype('call'),
-            :node( $/ )
-        );
-
-        # What we'd really like to do now is something like:
-        # my $sub := PAST::Compiler.compile( $past );
-        # $sub();
-        # Which would include it at compile time. But for now, that breaks
-        # pre-compiled PIR modules (we'd also need to emit something to load
-        # modules from the pre-compiled PIR, somehow). But we can't just emit
-        # a call straight into the output code, because then we load the
-        # module too late to inherit from any classes in it. So for now we
-        # stick the use call into $?INIT.
+    if $name ne 'v6' && $name ne 'lib' {
         our $?BLOCK;
-        $?BLOCK.loadinit().push($past);
-        $past := PAST::Stmts.new( :node($/) );
+        $?BLOCK.loadinit().push(
+            PAST::Op.new(
+                PAST::Val.new( :value($name) ),
+                :name('use'),
+                :pasttype('call'),
+                :node( $/ )
+            )
+        );
+        use($name);
     }
+    $past := PAST::Stmts.new( :node($/) );
     make $past;
 }
 



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About