From 60c572c3f5b06d48ca18ee7041bbd67d9b1fd873 Mon Sep 17 00:00:00 2001 From: Moritz Lenz Date: Sun, 6 Jan 2013 18:32:05 +0100 Subject: [PATCH] crude implementation of "require ::($modulename) only works for a single chunk, e.g. "require Test::($name) <&symbols>" does not work --- src/Perl6/Actions.pm | 2 +- src/Perl6/World.pm | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Perl6/Actions.pm b/src/Perl6/Actions.pm index ae8a96eb777..c1e1a95ba21 100644 --- a/src/Perl6/Actions.pm +++ b/src/Perl6/Actions.pm @@ -960,7 +960,7 @@ class Perl6::Actions is HLL::Actions does STDActions { method statement_control:sym($/) { my $past := QAST::Stmts.new(:node($/)); my $name_past := $ - ?? QAST::SVal.new(:value($.Str)) + ?? $*W.disect_longname($).name_past() !! $[0].ast; $past.push(QAST::Op.new( diff --git a/src/Perl6/World.pm b/src/Perl6/World.pm index ef7b9e288e7..93799080ad6 100644 --- a/src/Perl6/World.pm +++ b/src/Perl6/World.pm @@ -1544,6 +1544,24 @@ class Perl6::World is HLL::World { nqp::join('::', @parts) ~ ($with_adverbs ?? nqp::join('', @!colonpairs) !! ''); } + + # returns a QAST tree that represents the name + # currently needed for 'require ::($modulename) ' + # ignore adverbs for now + method name_past() { + if self.contains_indirect_lookup() { + if @!components == 1 { + return @!components[0]; + } + else { + nqp::die("Not yet implemented :("); + } + } + else { + my $value := nqp::join('::', @!components); + QAST::SVal.new(:$value); + } + } # Gets the individual components, which may be PAST nodes for # unknown pieces.