Skip to content
Permalink
Browse files

With this commit 'use v6.e.PREVIEW' is now available

Added warnings on use of PREVIEW with released specifications and on
missing PREVIEW when used on unreleased specifications.
  • Loading branch information...
vrurg committed Apr 18, 2019
1 parent 8d2fade commit 7467ab1dfd2b77b5734671d9b133539cc935e02b
Showing with 62 additions and 24 deletions.
  1. +11 −1 src/Perl6/ModuleLoader.nqp
  2. +50 −22 src/Perl6/World.nqp
  3. +1 −1 tools/templates/PERL6_SPECS
@@ -211,12 +211,22 @@ class Perl6::ModuleLoader does Perl6::ModuleLoaderVMConfig {
}
}

# Transforms NULL.<release> into CORE.<previos-release>
method transform_setting_name ($setting_name) {
my $m := $setting_name ~~ /NULL '.' ( <[c..z]> )/;
if $m {
my $rev := ~nqp::atpos($m, 0);
$setting_name := 'CORE' ~ ($rev le 'd' ?? '' !! '.' ~ nqp::chr(nqp::ord($rev) - 1));
}
$setting_name
}

method load_setting($setting_name) {
my $setting;

if $setting_name ne 'NULL' {
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := 'CORE' if $setting_name eq 'NULL.d';
$setting_name := self.transform_setting_name($setting_name);
# Unless we already did so, locate and load the setting.
unless nqp::defined(%settings_loaded{$setting_name}) {
DEBUG("Loading settings $setting_name") if $DEBUG;
@@ -530,44 +530,72 @@ class Perl6::World is HLL::World {
$want
) == -1
}

method !check-for-PREVIEW ($ver-match, $rev, $default_rev, $rev_mod) {
$ver-match.PRECURSOR.worry('PREVIEW modificator is used with a production specification 6.' ~ $rev)
if nqp::isle_s($rev, $default_rev) && nqp::iseq_s($rev_mod, 'PREVIEW');

$ver-match.PRECURSOR.worry(
'Language specification 6.' ~ $rev ~ ' is not released yet, PREVIEW modifiecor is expected'
) if nqp::isgt_s($rev, $default_rev) && nqp::isne_s($rev_mod, 'PREVIEW');
}

method load-lang-ver($ver-match, $comp) {
$*MAIN := 'MAIN';
$*STRICT := 1 if $*begin_compunit;

my str $version := ~$ver-match;
# fast-path the common cases
if $version eq 'v6.c' {
$comp.set_language_version: '6.c';
$*CAN_LOWER_TOPIC := 0;
# CORE.c is currently our lowest core, which we don't "load"
return;
}
my @vparts := nqp::split('.', $version);
my $default_rev := nqp::substr($comp.config<language-version>, 2, 1);

if $version eq 'v6' ?? nqp::substr($comp.language_version, 2, 1)
!! $version eq 'v6.d' ?? 'd'
!! $version eq 'v6.d.PREVIEW' ?? 'd'
!! '' -> $lang {
$comp.set_language_version: '6.' ~ $lang;
self.load_setting: $ver-match, 'CORE.' ~ $lang;
return;
# Do we have dot-splitted version string?
if (@vparts > 1) || ($version eq 'v6') {
my $revision := @vparts[1] || $default_rev;
my $lang_ver := '6.' ~ $revision;

self."!check-for-PREVIEW"($ver-match, $revision, $default_rev, @vparts[2] || '')
if ($revision eq 'c') || ($lang_ver eq $comp.config<language-version>);

$comp.set_language_version: $lang_ver;
# fast-path the common cases
if $revision eq 'c' {
$*CAN_LOWER_TOPIC := 0;
# CORE.c is currently our lowest core, which we don't "load"
return;
}

# Does this makes any sense besides of speeding up loading assuming that the default language version would be
# the most used one?
if $lang_ver eq $comp.config<language-version> {
self.load_setting: $ver-match, 'CORE.' ~ $revision;
return;
}
}

my $Version := self.find_symbol: ['Version'];
my $vWant := $ver-match.ast.compile_time_value;
my $rev := $vWant.parts.AT-POS(1);
my str $rev_mod := $vWant.parts.elems > 2 ?? $vWant.parts.AT-POS(2) !! '';

self."!check-for-PREVIEW"($ver-match, $rev, $default_rev, $rev_mod);

for $comp.can_language_versions -> $can-ver {
next unless $vWant.ACCEPTS: my $vCan := $Version.new: $can-ver;

my $lang := $vCan.parts.AT-POS: 1;
$comp.set_language_version: '6.' ~ $lang;
$*CAN_LOWER_TOPIC := 0 if $lang eq 'c';
my $can_rev := $vCan.parts.AT-POS: 1;
$comp.set_language_version: '6.' ~ $can_rev;

# CORE.c is currently our lowest core, which we don't "load"
self.load_setting: $ver-match, 'CORE.' ~ $lang
unless $lang eq 'c';
if $can_rev eq 'c' {
$*CAN_LOWER_TOPIC := 0;
# CORE.c is currently our lowest core, which we don't "load"
}
else {
self.load_setting: $ver-match, 'CORE.' ~ $can_rev
}
return;
}

$/.typed_panic: 'X::Language::Unsupported', :$version;
$ver-match.typed_panic: 'X::Language::Unsupported', :$version;
}

method RAKUDO_MODULE_DEBUG() {
@@ -842,7 +870,7 @@ class Perl6::World is HLL::World {
# Do nothing for the NULL setting.
if $setting_name ne 'NULL' {
# XXX TODO: see https://github.com/rakudo/rakudo/issues/2432
$setting_name := 'CORE' if $setting_name eq 'NULL.d';
$setting_name := Perl6::ModuleLoader.transform_setting_name($setting_name);
# Load it immediately, so the compile time info is available.
# Once it's loaded, set it as the outer context of the code
# being compiled.
@@ -2,4 +2,4 @@
# * defines the current spec
c
*d PREVIEW # TODO: It's about time to drop PREVIEW
#e PREVIEW
e PREVIEW

0 comments on commit 7467ab1

Please sign in to comment.
You can’t perform that action at this time.