Skip to content

Commit

Permalink
Perlito5 - add Perlito5X namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Oct 17, 2012
1 parent f81758e commit 828649a
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 97 deletions.
4 changes: 2 additions & 2 deletions html/perlito5.html
Expand Up @@ -129,8 +129,8 @@ <h1><a href="http://www.perlito.org">"Perlito" Perl 5 Compiler</a></h1>
return true; return true;
}; };
p5pkg["main"]["v_^O"] = "browser"; p5pkg["main"]["v_^O"] = "browser";
p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm"; p5pkg["main"]["Hash_INC"]["strict.pm"] = "Perlito5X/strict.pm";
p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm"; p5pkg["main"]["Hash_INC"]["warnings.pm"] = "Perlito5X/warnings.pm";


var source = document.getElementById('source').value; var source = document.getElementById('source').value;
var pos = 0; var pos = 0;
Expand Down
44 changes: 22 additions & 22 deletions html/perlito5.js
Expand Up @@ -1770,30 +1770,30 @@ var p5100 = p5pkg['main'];
(function () { (function () {
var p5101 = p5make_package("Perlito5"); var p5101 = p5make_package("Perlito5");
(function () { (function () {
var p5102 = p5make_package("Perlito5::strict"); var p5102 = p5make_package("strict");
p5make_sub("Perlito5::strict", "import", function (List__, p5want) { p5make_sub("strict", "import", function (List__, p5want) {
return ((p5pkg["Perlito5"]["v_STRICT"] = (1))); return ((p5pkg["Perlito5"]["v_STRICT"] = (1)));
}); });
p5make_sub("Perlito5::strict", "unimport", function (List__, p5want) { p5make_sub("strict", "unimport", function (List__, p5want) {
return ((p5pkg["Perlito5"]["v_STRICT"] = (0))); return ((p5pkg["Perlito5"]["v_STRICT"] = (0)));
}); });
1; 1;
})() })()
; ;
// use Perlito5::strict // use strict
; ;
(function () { (function () {
var p5103 = p5make_package("Perlito5::warnings"); var p5103 = p5make_package("warnings");
p5make_sub("Perlito5::warnings", "import", function (List__, p5want) { p5make_sub("warnings", "import", function (List__, p5want) {
return ((p5pkg["Perlito5"]["v_WARNINGS"] = (1))); return ((p5pkg["Perlito5"]["v_WARNINGS"] = (1)));
}); });
p5make_sub("Perlito5::warnings", "unimport", function (List__, p5want) { p5make_sub("warnings", "unimport", function (List__, p5want) {
return ((p5pkg["Perlito5"]["v_WARNINGS"] = (0))); return ((p5pkg["Perlito5"]["v_WARNINGS"] = (0)));
}); });
1; 1;
})() })()
; ;
// use Perlito5::warnings // use warnings
; ;
(function () { (function () {
null; null;
Expand Down Expand Up @@ -9790,8 +9790,6 @@ var p5100 = p5pkg['main'];
p5pkg["Perlito5::Precedence"].add_term(['use', function (List__, p5want) { p5pkg["Perlito5::Precedence"].add_term(['use', function (List__, p5want) {
return (p5call(p5pkg["Perlito5::Grammar::Use"], "term_use", p5list_to_a(List__.p5aget(0), List__.p5aget(1)), p5want)); return (p5call(p5pkg["Perlito5::Grammar::Use"], "term_use", p5list_to_a(List__.p5aget(0), List__.p5aget(1)), p5want));
}], null); }], null);
var Hash_Perlito_internal_module = {};
(Hash_Perlito_internal_module = {'strict' : 'Perlito5::strict', 'warnings' : 'Perlito5::warnings', 'utf8' : 'Perlito5::utf8', 'bytes' : 'Perlito5::bytes', 'encoding' : 'Perlito5::encoding'});
p5make_sub("Perlito5::Grammar::Use", "use_decl", function (List__, p5want) { p5make_sub("Perlito5::Grammar::Use", "use_decl", function (List__, p5want) {
var v_grammar; var v_grammar;
(v_grammar = (List__.p5aget(0))); (v_grammar = (List__.p5aget(0)));
Expand Down Expand Up @@ -9945,7 +9943,7 @@ var p5100 = p5pkg['main'];
var r; var r;
p5pkg["main"]["v_@"] = ""; p5pkg["main"]["v_@"] = "";
try { try {
r = eval(perl5_to_js(p5str(v_list_code), "Perlito5::Grammar::Use", (new p5ArrayRef(p5list_to_a((new p5HashRef(p5a_to_h(p5list_to_a('$list_code', (new p5HashRef({'decl' : 'my'})), '$m', (new p5HashRef({'decl' : 'my'})), '@list', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$list', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef({})), (new p5HashRef(p5a_to_h(p5list_to_a('$pos1', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef({})), (new p5HashRef(p5a_to_h(p5list_to_a('$pos1', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$MATCH', (new p5HashRef({'decl' : 'my'})), '$grammar', (new p5HashRef({'decl' : 'my'})), '$pos', (new p5HashRef({'decl' : 'my'})), '$str', (new p5HashRef({'decl' : 'my'})), '$tmp', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '%Perlito_internal_module', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$@', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$^O', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$|', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%ENV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@#', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@ARGV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@_', (new p5HashRef({'decl' : 'my'}))))))))), "list")) r = eval(perl5_to_js(p5str(v_list_code), "Perlito5::Grammar::Use", (new p5ArrayRef(p5list_to_a((new p5HashRef(p5a_to_h(p5list_to_a('$list_code', (new p5HashRef({'decl' : 'my'})), '$m', (new p5HashRef({'decl' : 'my'})), '@list', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$list', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef({})), (new p5HashRef(p5a_to_h(p5list_to_a('$pos1', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef({})), (new p5HashRef(p5a_to_h(p5list_to_a('$pos1', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$MATCH', (new p5HashRef({'decl' : 'my'})), '$grammar', (new p5HashRef({'decl' : 'my'})), '$pos', (new p5HashRef({'decl' : 'my'})), '$str', (new p5HashRef({'decl' : 'my'})), '$tmp', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$@', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$^O', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$|', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%ENV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@#', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@ARGV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@_', (new p5HashRef({'decl' : 'my'}))))))))), "list"))
} }
catch(err) { catch(err) {
if ( err instanceof p5_error || err instanceof Error ) { if ( err instanceof p5_error || err instanceof Error ) {
Expand Down Expand Up @@ -10008,9 +10006,6 @@ return r;


else { else {
if ( p5bool(p5pkg["Perlito5"]["v_EXPAND_USE"]) ) { if ( p5bool(p5pkg["Perlito5"]["v_EXPAND_USE"]) ) {
if ( (Hash_Perlito_internal_module).hasOwnProperty(v_module_name) ) {
(v_module_name = (Hash_Perlito_internal_module.p5hget(p5str(v_module_name))));
};
var v_filename; var v_filename;
(v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0))); (v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0)));
p5pkg["Perlito5::Grammar::Use"]["require"]([p5str(v_filename), 0]); p5pkg["Perlito5::Grammar::Use"]["require"]([p5str(v_filename), 0]);
Expand Down Expand Up @@ -10061,12 +10056,12 @@ return r;
(v_self = (List__.shift())); (v_self = (List__.shift()));
if ( (p5str(p5call(v_self, "mod", [], 0)) == 'strict') ) { if ( (p5str(p5call(v_self, "mod", [], 0)) == 'strict') ) {
if ( (p5str(p5call(v_self, "code", [], 0)) == 'use') ) { if ( (p5str(p5call(v_self, "code", [], 0)) == 'use') ) {
return (p5call(p5pkg["Perlito5::strict"], "import", [], p5want)); return (p5call(p5pkg["strict"], "import", [], p5want));
} }


else { else {
if ( (p5str(p5call(v_self, "code", [], 0)) == 'no') ) { if ( (p5str(p5call(v_self, "code", [], 0)) == 'no') ) {
return (p5call(p5pkg["Perlito5::strict"], "unimport", [], p5want)); return (p5call(p5pkg["strict"], "unimport", [], p5want));
} }


else { else {
Expand Down Expand Up @@ -10095,6 +10090,14 @@ return r;
}; };
p5pkg["Perlito5::Grammar::Use"].die([['Compilation failed in require']], null); p5pkg["Perlito5::Grammar::Use"].die([['Compilation failed in require']], null);
}; };
p5for_lex(function (v_prefix) {
var v_realfilename;
(v_realfilename = ((p5str(v_prefix) + '/Perlito5X/' + p5str(v_filename))));
if ( p5bool(p5is_file(p5str(v_realfilename))) ) {
p5pkg["main"]["Hash_INC"].p5hset(p5str(v_filename), (v_realfilename));
throw(p5context(['todo'], p5want));
};
}, p5list_to_a(p5pkg["main"]["List_INC"], '.'), false, "");
p5for_lex(function (v_prefix) { p5for_lex(function (v_prefix) {
var v_realfilename; var v_realfilename;
(v_realfilename = ((p5str(v_prefix) + '/' + p5str(v_filename)))); (v_realfilename = ((p5str(v_prefix) + '/' + p5str(v_filename))));
Expand Down Expand Up @@ -10122,12 +10125,9 @@ return r;
(v_stmt = (List__.shift())); (v_stmt = (List__.shift()));
var v_module_name; var v_module_name;
(v_module_name = (p5call(v_stmt, "mod", [], 0))); (v_module_name = (p5call(v_stmt, "mod", [], 0)));
if ( (((p5str(v_module_name) == 'strict') || (p5str(v_module_name) == 'warnings')) || (p5str(v_module_name) == 'feature')) ) { if ( (p5str(v_module_name) == 'feature') ) {
throw(p5context([], p5want)); throw(p5context([], p5want));
}; };
if ( (Hash_Perlito_internal_module).hasOwnProperty(v_module_name) ) {
(v_module_name = (Hash_Perlito_internal_module.p5hget(p5str(v_module_name))));
};
var v_filename; var v_filename;
(v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0))); (v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0)));
if ( (p5str(p5pkg["Perlito5::Grammar::Use"].filename_lookup([v_filename], 0)) == 'done') ) { if ( (p5str(p5pkg["Perlito5::Grammar::Use"].filename_lookup([v_filename], 0)) == 'done') ) {
Expand Down Expand Up @@ -10193,7 +10193,7 @@ return r;
var r; var r;
p5pkg["main"]["v_@"] = ""; p5pkg["main"]["v_@"] = "";
try { try {
r = eval(perl5_to_js(p5str(p5pkg["Perlito5::IO"].slurp(p5list_to_a(p5pkg["main"]["Hash_INC"].p5hget(p5str(v_filename))), 0)), "Perlito5::Grammar::Use", (new p5ArrayRef(p5list_to_a((new p5HashRef(p5a_to_h(p5list_to_a('$filename', (new p5HashRef({'decl' : 'my'})), '$is_bareword', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '%Perlito_internal_module', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$@', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$^O', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$|', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%ENV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@#', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@ARGV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@_', (new p5HashRef({'decl' : 'my'}))))))))), "")) r = eval(perl5_to_js(p5str(p5pkg["Perlito5::IO"].slurp(p5list_to_a(p5pkg["main"]["Hash_INC"].p5hget(p5str(v_filename))), 0)), "Perlito5::Grammar::Use", (new p5ArrayRef(p5list_to_a((new p5HashRef(p5a_to_h(p5list_to_a('$filename', (new p5HashRef({'decl' : 'my'})), '$is_bareword', (new p5HashRef({'decl' : 'my'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5::Grammar::Use'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'Perlito5'})))))), (new p5HashRef(p5a_to_h(p5list_to_a('$@', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$AUTOLOAD', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$^O', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$_', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$a', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$b', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '$|', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%ENV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '%INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@#', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@ARGV', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@INC', (new p5HashRef({'decl' : 'our', 'namespace' : 'main'})), '@_', (new p5HashRef({'decl' : 'my'}))))))))), ""))
} }
catch(err) { catch(err) {
if ( err instanceof p5_error || err instanceof Error ) { if ( err instanceof p5_error || err instanceof Error ) {
Expand Down Expand Up @@ -12684,7 +12684,7 @@ return r;
; ;
(function () { (function () {
var p5159 = p5make_package("Perlito5::Runtime"); var p5159 = p5make_package("Perlito5::Runtime");
// use Perlito5::strict // use strict
; ;
if ( p5bool(p5pkg["main"]["v_]"]) ) { if ( p5bool(p5pkg["main"]["v_]"]) ) {
null; null;
Expand Down
33 changes: 11 additions & 22 deletions perlito5.pl
Expand Up @@ -5257,7 +5257,6 @@ package Perlito5::Grammar::Use;
Perlito5::Precedence::add_term('use', sub { Perlito5::Precedence::add_term('use', sub {
Perlito5::Grammar::Use->term_use($_[0], $_[1]) Perlito5::Grammar::Use->term_use($_[0], $_[1])
}); });
((my %Perlito_internal_module) = ('strict', 'Perlito5::strict', 'warnings', 'Perlito5::warnings', 'utf8', 'Perlito5::utf8', 'bytes', 'Perlito5::bytes', 'encoding', 'Perlito5::encoding'));
sub Perlito5::Grammar::Use::use_decl { sub Perlito5::Grammar::Use::use_decl {
((my $grammar) = $_[0]); ((my $grammar) = $_[0]);
((my $str) = $_[1]); ((my $str) = $_[1]);
Expand Down Expand Up @@ -5407,9 +5406,6 @@ sub Perlito5::Grammar::Use::parse_time_eval {
} }
else { else {
if ($Perlito5::EXPAND_USE) { if ($Perlito5::EXPAND_USE) {
if (exists($Perlito_internal_module{$module_name})) {
($module_name = $Perlito_internal_module{$module_name})
};
((my $filename) = modulename_to_filename($module_name)); ((my $filename) = modulename_to_filename($module_name));
Perlito5::Grammar::Use::require($filename); Perlito5::Grammar::Use::require($filename);
if (!($skip_import)) { if (!($skip_import)) {
Expand Down Expand Up @@ -5437,11 +5433,11 @@ sub Perlito5::Grammar::Use::emit_time_eval {
((my $self) = shift()); ((my $self) = shift());
if (($self->mod() eq 'strict')) { if (($self->mod() eq 'strict')) {
if (($self->code() eq 'use')) { if (($self->code() eq 'use')) {
Perlito5::strict->import() strict->import()
} }
else { else {
if (($self->code() eq 'no')) { if (($self->code() eq 'no')) {
Perlito5::strict->unimport() strict->unimport()
} }
} }
} }
Expand All @@ -5459,6 +5455,13 @@ sub Perlito5::Grammar::Use::filename_lookup {
}; };
die('Compilation failed in require') die('Compilation failed in require')
}; };
for my $prefix ((@INC, '.')) {
((my $realfilename) = ($prefix . '/Perlito5X/' . $filename));
if (-f($realfilename)) {
($INC{$filename} = $realfilename);
return ('todo')
}
};
for my $prefix ((@INC, '.')) { for my $prefix ((@INC, '.')) {
((my $realfilename) = ($prefix . '/' . $filename)); ((my $realfilename) = ($prefix . '/' . $filename));
if (-f($realfilename)) { if (-f($realfilename)) {
Expand All @@ -5472,12 +5475,9 @@ sub Perlito5::Grammar::Use::expand_use {
((my $comp_units) = shift()); ((my $comp_units) = shift());
((my $stmt) = shift()); ((my $stmt) = shift());
((my $module_name) = $stmt->mod()); ((my $module_name) = $stmt->mod());
if (((($module_name eq 'strict') || ($module_name eq 'warnings')) || ($module_name eq 'feature'))) { if (($module_name eq 'feature')) {
return () return ()
}; };
if (exists($Perlito_internal_module{$module_name})) {
($module_name = $Perlito_internal_module{$module_name})
};
((my $filename) = modulename_to_filename($module_name)); ((my $filename) = modulename_to_filename($module_name));
if ((filename_lookup($filename) eq 'done')) { if ((filename_lookup($filename) eq 'done')) {
return () return ()
Expand Down Expand Up @@ -11716,22 +11716,11 @@ package Perlito5::AST::Use;
; ;


# use Perlito5::Precedence # use Perlito5::Precedence
;
package main;
package Perlito5::strict;
sub Perlito5::strict::import {
($Perlito5::STRICT = 1)
};
sub Perlito5::strict::unimport {
($Perlito5::STRICT = 0)
};
1;

; ;
package main; package main;
package Perlito5::Runtime; package Perlito5::Runtime;


# use Perlito5::strict # use strict
; ;
if (${'main::]'}) { if (${'main::]'}) {


Expand Down
34 changes: 13 additions & 21 deletions src5/lib/Perlito5/Grammar/Use.pm
Expand Up @@ -7,16 +7,6 @@ use Perlito5::Grammar;
Perlito5::Precedence::add_term( 'no' => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } ); Perlito5::Precedence::add_term( 'no' => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } );
Perlito5::Precedence::add_term( 'use' => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } ); Perlito5::Precedence::add_term( 'use' => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } );



my %Perlito_internal_module = (
strict => 'Perlito5::strict',
warnings => 'Perlito5::warnings',
utf8 => 'Perlito5::utf8',
bytes => 'Perlito5::bytes',
encoding => 'Perlito5::encoding',
);


token use_decl { 'use' | 'no' }; token use_decl { 'use' | 'no' };


token term_use { token term_use {
Expand Down Expand Up @@ -88,9 +78,6 @@ sub parse_time_eval {
if ( $Perlito5::EXPAND_USE ) { if ( $Perlito5::EXPAND_USE ) {
# normal "use" is not disabled, go for it # normal "use" is not disabled, go for it


$module_name = $Perlito_internal_module{$module_name}
if exists $Perlito_internal_module{$module_name};

# "require" the module # "require" the module
my $filename = modulename_to_filename($module_name); my $filename = modulename_to_filename($module_name);
# warn "# require $filename\n"; # warn "# require $filename\n";
Expand Down Expand Up @@ -125,10 +112,10 @@ sub emit_time_eval {


if ($self->mod eq 'strict') { if ($self->mod eq 'strict') {
if ($self->code eq 'use') { if ($self->code eq 'use') {
Perlito5::strict->import(); strict->import();
} }
elsif ($self->code eq 'no') { elsif ($self->code eq 'no') {
Perlito5::strict->unimport(); strict->unimport();
} }
} }
} }
Expand All @@ -147,6 +134,14 @@ sub filename_lookup {
die "Compilation failed in require"; die "Compilation failed in require";
} }


for my $prefix (@INC, '.') {
my $realfilename = "$prefix/Perlito5X/$filename";
if (-f $realfilename) {
$INC{$filename} = $realfilename;
return "todo";
}
}

for my $prefix (@INC, '.') { for my $prefix (@INC, '.') {
my $realfilename = "$prefix/$filename"; my $realfilename = "$prefix/$filename";
if (-f $realfilename) { if (-f $realfilename) {
Expand All @@ -162,13 +157,10 @@ sub expand_use {
my $stmt = shift; my $stmt = shift;


my $module_name = $stmt->mod; my $module_name = $stmt->mod;
return
if $module_name eq 'strict'
|| $module_name eq 'warnings'
|| $module_name eq 'feature';


$module_name = $Perlito_internal_module{$module_name} # TODO - support 'use feature'
if exists $Perlito_internal_module{$module_name}; return
if $module_name eq 'feature';


my $filename = modulename_to_filename($module_name); my $filename = modulename_to_filename($module_name);


Expand Down
2 changes: 1 addition & 1 deletion src5/lib/Perlito5/Runtime.pm
@@ -1,6 +1,6 @@
package Perlito5::Runtime; package Perlito5::Runtime;


use Perlito5::strict; use strict;


$] = 5.014001 $] = 5.014001
unless $]; unless $];
Expand Down

0 comments on commit 828649a

Please sign in to comment.