Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first crude shot at importing with positional args

Also crude implementation of lib.pm
  • Loading branch information...
commit 6bd95b3bdca7cb5b4bc356b9abb5def96b1f9537 1 parent 64c2fdb
@moritz moritz authored
Showing with 21 additions and 2 deletions.
  1. +4 −0 lib/lib.pm
  2. +10 −1 src/Perl6/Grammar.pm
  3. +7 −1 tools/build/Makefile.in
View
4 lib/lib.pm
@@ -0,0 +1,4 @@
+module lib { };
+our sub EXPORT(*@a) {
+ @*INC.unshift: @a;
+}
View
11 src/Perl6/Grammar.pm
@@ -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 {
@@ -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);
}
}
}
@@ -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");
+ }
+ }
}
}
View
8 tools/build/Makefile.in
@@ -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) \
@@ -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
@@ -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
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.