Skip to content

Commit

Permalink
crude implementation of "require ::($modulename) <importlist>
Browse files Browse the repository at this point in the history
only works for a single chunk, e.g. "require Test::($name) <&symbols>" does not work
  • Loading branch information
moritz committed Jan 6, 2013
1 parent a930588 commit 60c572c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Perl6/Actions.pm
Expand Up @@ -960,7 +960,7 @@ class Perl6::Actions is HLL::Actions does STDActions {
method statement_control:sym<require>($/) {
my $past := QAST::Stmts.new(:node($/));
my $name_past := $<module_name>
?? QAST::SVal.new(:value($<module_name><longname><name>.Str))
?? $*W.disect_longname($<module_name><longname>).name_past()
!! $<EXPR>[0].ast;

$past.push(QAST::Op.new(
Expand Down
18 changes: 18 additions & 0 deletions src/Perl6/World.pm
Expand Up @@ -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) <importlist>'
# 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.
Expand Down

0 comments on commit 60c572c

Please sign in to comment.