Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
first crude shot at importing with positional args
Also crude implementation of lib.pm
  • Loading branch information
moritz committed May 8, 2012
1 parent 64c2fdb commit 6bd95b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions lib/lib.pm
@@ -0,0 +1,4 @@
module lib { };
our sub EXPORT(*@a) {
@*INC.unshift: @a;
}
11 changes: 10 additions & 1 deletion src/Perl6/Grammar.pm
Expand Up @@ -788,6 +788,7 @@ grammar Perl6::Grammar is HLL::Grammar {
if pir::exists($module, 'EXPORT') {
my $EXPORT := $module<EXPORT>.WHO;
my @to_import := ['MANDATORY'];
my @positional_imports := [];
if pir::defined($arglist) {
my $Pair := $*W.find_symbol(['Pair']);
for $arglist -> $tag {
Expand All @@ -802,7 +803,7 @@ grammar Perl6::Grammar is HLL::Grammar {
}
}
else {
nqp::die('Can only import named tags for now');
nqp::push(@positional_imports, $tag);
}
}
}
Expand All @@ -814,6 +815,14 @@ grammar Perl6::Grammar is HLL::Grammar {
$*W.import($EXPORT{$tag}, $package_source_name);
}
}
if +@positional_imports {
if pir::exists($module, '&EXPORT') {
$module<&EXPORT>(|@positional_imports);
}
else {
nqp::die("Error while importing from '$package_source_name': no EXPORT sub, but you provided positional argument in the 'use' statement");
}
}
}
}

Expand Down
8 changes: 7 additions & 1 deletion tools/build/Makefile.in
Expand Up @@ -246,6 +246,7 @@ CLEANUPS = \
perl6$(O) \
perl6_group.* \
lib/Test.pir \
lib/lib.pir \
lib/Pod/To/Text.pir \
rakudo_test_run.tar.gz \
$(DYNEXT_DIR)/*$(LOAD_EXT) \
Expand Down Expand Up @@ -278,7 +279,7 @@ HARNESS_WITH_FUDGE = $(PERL) t/harness --fudge --keep-exit-code --icu=$(HAS_ICU)
STAGESTATS = @stagestats@

# the default target, TODO: make libraries in 'lib' a variable.
all: check-versions $(PERL6_EXE) $(SETTING) $(S_SETTING) lib/Test.pir lib/Pod/To/Text.pir
all: check-versions $(PERL6_EXE) $(SETTING) $(S_SETTING) lib/lib.pir lib/Test.pir lib/Pod/To/Text.pir

# the install target
install: all
Expand All @@ -297,6 +298,8 @@ install: all
$(CP) perl6.pbc $(DESTDIR)$(PERL6_LANG_DIR)
$(CP) lib/Test.pm $(DESTDIR)$(PERL6_LANG_DIR)/lib
$(CP) lib/Test.pir $(DESTDIR)$(PERL6_LANG_DIR)/lib
$(CP) lib/lib.pm $(DESTDIR)$(PERL6_LANG_DIR)/lib
$(CP) lib/lib.pir $(DESTDIR)$(PERL6_LANG_DIR)/lib
$(MKPATH) $(DESTDIR)$(PERL6_LANG_DIR)/lib/Pod/To
$(CP) lib/Pod/To/Text.pm $(DESTDIR)$(PERL6_LANG_DIR)/lib/Pod/To
$(CP) CORE.setting.pbc $(DESTDIR)$(PERL6_LANG_DIR)/lib/CORE.setting.pbc
Expand Down Expand Up @@ -395,6 +398,9 @@ $(S_SETTING): $(PERL6_B_PBC) $(PERL6_EXE) $(SETTING) src/SAFE.setting
lib/Test.pir: lib/Test.pm $(PERL6_EXE) $(SETTING)
./$(PERL6_EXE) --target=pir --output=lib/Test.pir lib/Test.pm

lib/lib.pir: lib/lib.pm $(PERL6_EXE) $(SETTING)
./$(PERL6_EXE) --target=pir --output=lib/lib.pir lib/lib.pm

lib/Pod/To/Text.pir: lib/Pod/To/Text.pm $(PERL6_EXE) $(SETTING)
./$(PERL6_EXE) --target=pir --output=lib/Pod/To/Text.pir lib/Pod/To/Text.pm

Expand Down

0 comments on commit 6bd95b3

Please sign in to comment.