Skip to content
This repository
Browse code

Revert "Perlito5 - add Perlito5X namespace"

This reverts commit 828649a.
this breaks 'make'
  • Loading branch information...
commit 1f09a806cac684620b40716f904202317d45f6cb 1 parent b62fba5
Flavio S. Glock authored October 18, 2012
4  html/perlito5.html
@@ -129,8 +129,8 @@
129 129
                 return true;
130 130
             };
131 131
             p5pkg["main"]["v_^O"] = "browser";
132  
-            p5pkg["main"]["Hash_INC"]["strict.pm"] = "Perlito5X/strict.pm";
133  
-            p5pkg["main"]["Hash_INC"]["warnings.pm"] = "Perlito5X/warnings.pm";
  132
+            p5pkg["main"]["Hash_INC"]["Perlito5/strict.pm"] = "Perlito5/strict.pm";
  133
+            p5pkg["main"]["Hash_INC"]["Perlito5/warnings.pm"] = "Perlito5/warnings.pm";
134 134
 
135 135
 			var source = document.getElementById('source').value;
136 136
             var pos = 0;
44  html/perlito5.js
@@ -1770,30 +1770,30 @@ var p5100 = p5pkg['main'];
1770 1770
 (function () {
1771 1771
 	var p5101 = p5make_package("Perlito5");
1772 1772
 	(function () {
1773  
-		var p5102 = p5make_package("strict");
1774  
-		p5make_sub("strict", "import", function (List__, p5want) {
  1773
+		var p5102 = p5make_package("Perlito5::strict");
  1774
+		p5make_sub("Perlito5::strict", "import", function (List__, p5want) {
1775 1775
 				return ((p5pkg["Perlito5"]["v_STRICT"] = (1)));
1776 1776
 		});
1777  
-		p5make_sub("strict", "unimport", function (List__, p5want) {
  1777
+		p5make_sub("Perlito5::strict", "unimport", function (List__, p5want) {
1778 1778
 				return ((p5pkg["Perlito5"]["v_STRICT"] = (0)));
1779 1779
 		});
1780 1780
 		1;
1781 1781
 	})()
1782 1782
 ;
1783  
-	// use strict
  1783
+	// use Perlito5::strict
1784 1784
 ;
1785 1785
 	(function () {
1786  
-		var p5103 = p5make_package("warnings");
1787  
-		p5make_sub("warnings", "import", function (List__, p5want) {
  1786
+		var p5103 = p5make_package("Perlito5::warnings");
  1787
+		p5make_sub("Perlito5::warnings", "import", function (List__, p5want) {
1788 1788
 				return ((p5pkg["Perlito5"]["v_WARNINGS"] = (1)));
1789 1789
 		});
1790  
-		p5make_sub("warnings", "unimport", function (List__, p5want) {
  1790
+		p5make_sub("Perlito5::warnings", "unimport", function (List__, p5want) {
1791 1791
 				return ((p5pkg["Perlito5"]["v_WARNINGS"] = (0)));
1792 1792
 		});
1793 1793
 		1;
1794 1794
 	})()
1795 1795
 ;
1796  
-	// use warnings
  1796
+	// use Perlito5::warnings
1797 1797
 ;
1798 1798
 	(function () {
1799 1799
 		null;
@@ -9790,6 +9790,8 @@ var p5100 = p5pkg['main'];
9790 9790
 		p5pkg["Perlito5::Precedence"].add_term(['use', function (List__, p5want) {
9791 9791
 		return (p5call(p5pkg["Perlito5::Grammar::Use"], "term_use", p5list_to_a(List__.p5aget(0), List__.p5aget(1)), p5want));
9792 9792
 }], null);
  9793
+		var Hash_Perlito_internal_module = {};
  9794
+		(Hash_Perlito_internal_module = {'strict' : 'Perlito5::strict', 'warnings' : 'Perlito5::warnings', 'utf8' : 'Perlito5::utf8', 'bytes' : 'Perlito5::bytes', 'encoding' : 'Perlito5::encoding'});
9793 9795
 		p5make_sub("Perlito5::Grammar::Use", "use_decl", function (List__, p5want) {
9794 9796
 				var v_grammar;
9795 9797
 				(v_grammar = (List__.p5aget(0)));
@@ -9943,7 +9945,7 @@ var p5100 = p5pkg['main'];
9943 9945
 var r;
9944 9946
 p5pkg["main"]["v_@"] = "";
9945 9947
 try {
9946  
-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"))
  9948
+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"))
9947 9949
 }
9948 9950
 catch(err) {
9949 9951
 if ( err instanceof p5_error || err instanceof Error ) {
@@ -10006,6 +10008,9 @@ return r;
10006 10008
 				
10007 10009
 				else {
10008 10010
 					if ( p5bool(p5pkg["Perlito5"]["v_EXPAND_USE"]) ) {
  10011
+						if ( (Hash_Perlito_internal_module).hasOwnProperty(v_module_name) ) {
  10012
+							(v_module_name = (Hash_Perlito_internal_module.p5hget(p5str(v_module_name))));
  10013
+						};
10009 10014
 						var v_filename;
10010 10015
 						(v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0)));
10011 10016
 						p5pkg["Perlito5::Grammar::Use"]["require"]([p5str(v_filename), 0]);
@@ -10056,12 +10061,12 @@ return r;
10056 10061
 				(v_self = (List__.shift()));
10057 10062
 				if ( (p5str(p5call(v_self, "mod", [], 0)) == 'strict') ) {
10058 10063
 					if ( (p5str(p5call(v_self, "code", [], 0)) == 'use') ) {
10059  
-						return (p5call(p5pkg["strict"], "import", [], p5want));
  10064
+						return (p5call(p5pkg["Perlito5::strict"], "import", [], p5want));
10060 10065
 					}
10061 10066
 					
10062 10067
 					else {
10063 10068
 						if ( (p5str(p5call(v_self, "code", [], 0)) == 'no') ) {
10064  
-							return (p5call(p5pkg["strict"], "unimport", [], p5want));
  10069
+							return (p5call(p5pkg["Perlito5::strict"], "unimport", [], p5want));
10065 10070
 						}
10066 10071
 						
10067 10072
 						else {
@@ -10092,14 +10097,6 @@ return r;
10092 10097
 				};
10093 10098
 				p5for_lex(function (v_prefix) {
10094 10099
 						var v_realfilename;
10095  
-						(v_realfilename = ((p5str(v_prefix) + '/Perlito5X/' + p5str(v_filename))));
10096  
-						if ( p5bool(p5is_file(p5str(v_realfilename))) ) {
10097  
-							p5pkg["main"]["Hash_INC"].p5hset(p5str(v_filename), (v_realfilename));
10098  
-							throw(p5context(['todo'], p5want));
10099  
-						};
10100  
-					}, p5list_to_a(p5pkg["main"]["List_INC"], '.'), false, "");
10101  
-				p5for_lex(function (v_prefix) {
10102  
-						var v_realfilename;
10103 10100
 						(v_realfilename = ((p5str(v_prefix) + '/' + p5str(v_filename))));
10104 10101
 						if ( p5bool(p5is_file(p5str(v_realfilename))) ) {
10105 10102
 							p5pkg["main"]["Hash_INC"].p5hset(p5str(v_filename), (v_realfilename));
@@ -10125,9 +10122,12 @@ return r;
10125 10122
 				(v_stmt = (List__.shift()));
10126 10123
 				var v_module_name;
10127 10124
 				(v_module_name = (p5call(v_stmt, "mod", [], 0)));
10128  
-				if ( (p5str(v_module_name) == 'feature') ) {
  10125
+				if ( (((p5str(v_module_name) == 'strict') || (p5str(v_module_name) == 'warnings')) || (p5str(v_module_name) == 'feature')) ) {
10129 10126
 					throw(p5context([], p5want));
10130 10127
 				};
  10128
+				if ( (Hash_Perlito_internal_module).hasOwnProperty(v_module_name) ) {
  10129
+					(v_module_name = (Hash_Perlito_internal_module.p5hget(p5str(v_module_name))));
  10130
+				};
10131 10131
 				var v_filename;
10132 10132
 				(v_filename = (p5pkg["Perlito5::Grammar::Use"].modulename_to_filename([v_module_name], 0)));
10133 10133
 				if ( (p5str(p5pkg["Perlito5::Grammar::Use"].filename_lookup([v_filename], 0)) == 'done') ) {
@@ -10193,7 +10193,7 @@ return r;
10193 10193
 var r;
10194 10194
 p5pkg["main"]["v_@"] = "";
10195 10195
 try {
10196  
-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'}))))))))), ""))
  10196
+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'}))))))))), ""))
10197 10197
 }
10198 10198
 catch(err) {
10199 10199
 if ( err instanceof p5_error || err instanceof Error ) {
@@ -12684,7 +12684,7 @@ return r;
12684 12684
 ;
12685 12685
 	(function () {
12686 12686
 		var p5159 = p5make_package("Perlito5::Runtime");
12687  
-		// use strict
  12687
+		// use Perlito5::strict
12688 12688
 ;
12689 12689
 		if ( p5bool(p5pkg["main"]["v_]"]) ) {
12690 12690
 			null;
33  perlito5.pl
@@ -5257,6 +5257,7 @@ package Perlito5::Grammar::Use;
5257 5257
 Perlito5::Precedence::add_term('use', sub {
5258 5258
     Perlito5::Grammar::Use->term_use($_[0], $_[1])
5259 5259
 });
  5260
+((my  %Perlito_internal_module) = ('strict', 'Perlito5::strict', 'warnings', 'Perlito5::warnings', 'utf8', 'Perlito5::utf8', 'bytes', 'Perlito5::bytes', 'encoding', 'Perlito5::encoding'));
5260 5261
 sub Perlito5::Grammar::Use::use_decl {
5261 5262
     ((my  $grammar) = $_[0]);
5262 5263
     ((my  $str) = $_[1]);
@@ -5406,6 +5407,9 @@ sub Perlito5::Grammar::Use::parse_time_eval {
5406 5407
     }
5407 5408
     else {
5408 5409
         if ($Perlito5::EXPAND_USE) {
  5410
+            if (exists($Perlito_internal_module{$module_name})) {
  5411
+                ($module_name = $Perlito_internal_module{$module_name})
  5412
+            };
5409 5413
             ((my  $filename) = modulename_to_filename($module_name));
5410 5414
 Perlito5::Grammar::Use::require($filename);
5411 5415
             if (!($skip_import)) {
@@ -5433,11 +5437,11 @@ sub Perlito5::Grammar::Use::emit_time_eval {
5433 5437
     ((my  $self) = shift());
5434 5438
     if (($self->mod() eq 'strict')) {
5435 5439
         if (($self->code() eq 'use')) {
5436  
-            strict->import()
  5440
+            Perlito5::strict->import()
5437 5441
         }
5438 5442
         else {
5439 5443
             if (($self->code() eq 'no')) {
5440  
-                strict->unimport()
  5444
+                Perlito5::strict->unimport()
5441 5445
             }
5442 5446
         }
5443 5447
     }
@@ -5456,13 +5460,6 @@ sub Perlito5::Grammar::Use::filename_lookup {
5456 5460
         die('Compilation failed in require')
5457 5461
     };
5458 5462
     for my $prefix ((@INC, '.')) {
5459  
-        ((my  $realfilename) = ($prefix . '/Perlito5X/' . $filename));
5460  
-        if (-f($realfilename)) {
5461  
-            ($INC{$filename} = $realfilename);
5462  
-            return ('todo')
5463  
-        }
5464  
-    };
5465  
-    for my $prefix ((@INC, '.')) {
5466 5463
         ((my  $realfilename) = ($prefix . '/' . $filename));
5467 5464
         if (-f($realfilename)) {
5468 5465
             ($INC{$filename} = $realfilename);
@@ -5475,9 +5472,12 @@ sub Perlito5::Grammar::Use::expand_use {
5475 5472
     ((my  $comp_units) = shift());
5476 5473
     ((my  $stmt) = shift());
5477 5474
     ((my  $module_name) = $stmt->mod());
5478  
-    if (($module_name eq 'feature')) {
  5475
+    if (((($module_name eq 'strict') || ($module_name eq 'warnings')) || ($module_name eq 'feature'))) {
5479 5476
         return ()
5480 5477
     };
  5478
+    if (exists($Perlito_internal_module{$module_name})) {
  5479
+        ($module_name = $Perlito_internal_module{$module_name})
  5480
+    };
5481 5481
     ((my  $filename) = modulename_to_filename($module_name));
5482 5482
     if ((filename_lookup($filename) eq 'done')) {
5483 5483
         return ()
@@ -11718,9 +11718,20 @@ package Perlito5::AST::Use;
11718 11718
 # use Perlito5::Precedence
11719 11719
 ;
11720 11720
 package main;
  11721
+package Perlito5::strict;
  11722
+sub Perlito5::strict::import {
  11723
+    ($Perlito5::STRICT = 1)
  11724
+};
  11725
+sub Perlito5::strict::unimport {
  11726
+    ($Perlito5::STRICT = 0)
  11727
+};
  11728
+1;
  11729
+
  11730
+;
  11731
+package main;
11721 11732
 package Perlito5::Runtime;
11722 11733
 
11723  
-# use strict
  11734
+# use Perlito5::strict
11724 11735
 ;
11725 11736
 if (${'main::]'}) {
11726 11737
 
34  src5/lib/Perlito5/Grammar/Use.pm
@@ -7,6 +7,16 @@ use Perlito5::Grammar;
7 7
 Perlito5::Precedence::add_term( 'no'  => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } );
8 8
 Perlito5::Precedence::add_term( 'use' => sub { Perlito5::Grammar::Use->term_use($_[0], $_[1]) } );
9 9
 
  10
+
  11
+my %Perlito_internal_module = (
  12
+    strict   => 'Perlito5::strict',
  13
+    warnings => 'Perlito5::warnings',
  14
+    utf8     => 'Perlito5::utf8',
  15
+    bytes    => 'Perlito5::bytes',
  16
+    encoding => 'Perlito5::encoding',
  17
+);
  18
+
  19
+
10 20
 token use_decl { 'use' | 'no' };
11 21
 
12 22
 token term_use {
@@ -78,6 +88,9 @@ sub parse_time_eval {
78 88
         if ( $Perlito5::EXPAND_USE ) {
79 89
             # normal "use" is not disabled, go for it
80 90
 
  91
+            $module_name = $Perlito_internal_module{$module_name}
  92
+                if exists $Perlito_internal_module{$module_name};
  93
+
81 94
             # "require" the module
82 95
             my $filename = modulename_to_filename($module_name);
83 96
             # warn "# require $filename\n";
@@ -112,10 +125,10 @@ sub emit_time_eval {
112 125
 
113 126
     if ($self->mod eq 'strict') {
114 127
         if ($self->code eq 'use') {
115  
-            strict->import();
  128
+            Perlito5::strict->import();
116 129
         }
117 130
         elsif ($self->code eq 'no') {
118  
-            strict->unimport();
  131
+            Perlito5::strict->unimport();
119 132
         }
120 133
     }
121 134
 }
@@ -135,14 +148,6 @@ sub filename_lookup {
135 148
     }
136 149
 
137 150
     for my $prefix (@INC, '.') {
138  
-        my $realfilename = "$prefix/Perlito5X/$filename";
139  
-        if (-f $realfilename) {
140  
-            $INC{$filename} = $realfilename;
141  
-            return "todo";
142  
-        }
143  
-    }
144  
-
145  
-    for my $prefix (@INC, '.') {
146 151
         my $realfilename = "$prefix/$filename";
147 152
         if (-f $realfilename) {
148 153
             $INC{$filename} = $realfilename;
@@ -157,10 +162,13 @@ sub expand_use {
157 162
     my $stmt = shift;
158 163
 
159 164
     my $module_name = $stmt->mod;
160  
-
161  
-    # TODO - support 'use feature'
162 165
     return
163  
-        if $module_name eq 'feature';
  166
+        if $module_name eq 'strict'
  167
+        || $module_name eq 'warnings'
  168
+        || $module_name eq 'feature';
  169
+
  170
+    $module_name = $Perlito_internal_module{$module_name}
  171
+        if exists $Perlito_internal_module{$module_name};
164 172
 
165 173
     my $filename = modulename_to_filename($module_name);
166 174
 
2  src5/lib/Perlito5/Runtime.pm
... ...
@@ -1,6 +1,6 @@
1 1
 package Perlito5::Runtime;
2 2
 
3  
-use strict;
  3
+use Perlito5::strict;
4 4
 
5 5
 $] = 5.014001
6 6
     unless $];
38  src5/lib/Perlito5X/Test.pm → src5/lib/Perlito5/Test.pm
... ...
@@ -1,4 +1,4 @@
1  
-package Test;
  1
+package Perlito5::Test;
2 2
 
3 3
 ### GLOBALS
4 4
 
@@ -26,7 +26,7 @@ sub ok {
26 26
     my $desc    = shift;
27 27
     my $todo    = shift;
28 28
     my $depends = shift;
29  
-    Test::proclaim( $cond, 'ok! ' . $desc, $todo, $depends );
  29
+    Perlito5::Test::proclaim( $cond, 'ok! ' . $desc, $todo, $depends );
30 30
 }
31 31
 
32 32
 sub is {
@@ -37,7 +37,7 @@ sub is {
37 37
     my $depends  = shift;
38 38
 
39 39
     my $test = $got eq $expected;
40  
-    Test::proclaim( $test, 'is! ' . $desc, $todo, $got, $expected, $depends );
  40
+    Perlito5::Test::proclaim( $test, 'is! ' . $desc, $todo, $got, $expected, $depends );
41 41
 }
42 42
 
43 43
 sub is_deeply {
@@ -52,7 +52,7 @@ sub is_deeply {
52 52
     my $expected_perl = $expected;
53 53
     my $test          = ( $got_perl eq $expected_perl );
54 54
 
55  
-    Test::proclaim( $test, "is deeply! $desc", $todo, $got_perl, $expected_perl, $depends );
  55
+    Perlito5::Test::proclaim( $test, "is deeply! $desc", $todo, $got_perl, $expected_perl, $depends );
56 56
 }
57 57
 
58 58
 sub isnt {
@@ -63,7 +63,7 @@ sub isnt {
63 63
     my $depends  = shift;
64 64
 
65 65
     my $test = !( $got eq $expected );
66  
-    Test::proclaim( $test, "isnt! $desc", $todo, $got, $expected, $depends, { negate => 1 } );
  66
+    Perlito5::Test::proclaim( $test, "isnt! $desc", $todo, $got, $expected, $depends, { negate => 1 } );
67 67
 }
68 68
 
69 69
 sub cmp_ok {
@@ -74,39 +74,39 @@ sub cmp_ok {
74 74
     my $todo         = shift;
75 75
     my $depends      = shift;
76 76
 
77  
-    say "### Test::cmp_ok not implemented";
  77
+    say "### Perlito5::Test::cmp_ok not implemented";
78 78
 }
79 79
 
80 80
 sub like {
81  
-    say "### Test::like not implemented";
  81
+    say "### Perlito5::Test::like not implemented";
82 82
 }
83 83
 
84 84
 sub unlike {
85  
-    say "### Test::unlike not implemented";
  85
+    say "### Perlito5::Test::unlike not implemented";
86 86
 }
87 87
 
88 88
 sub eval_dies_ok {
89  
-    say "### Test::eval_dies_ok not implemented";
  89
+    say "### Perlito5::Test::eval_dies_ok not implemented";
90 90
 }
91 91
 
92 92
 sub isa_ok {
93  
-    say "### Test::isa_ok not implemented";
  93
+    say "### Perlito5::Test::isa_ok not implemented";
94 94
 }
95 95
 
96 96
 sub use_ok {
97  
-    say "### Test::use_ok not implemented";
  97
+    say "### Perlito5::Test::use_ok not implemented";
98 98
 }
99 99
 
100 100
 sub throws_ok {
101  
-    say "### Test::throws_ok not implemented";
  101
+    say "### Perlito5::Test::throws_ok not implemented";
102 102
 }
103 103
 
104 104
 sub dies_ok {
105  
-    say "### Test::dies_ok not implemented";
  105
+    say "### Perlito5::Test::dies_ok not implemented";
106 106
 }
107 107
 
108 108
 sub lives_ok {
109  
-    say "### Test::lives_ok not implemented";
  109
+    say "### Perlito5::Test::lives_ok not implemented";
110 110
 }
111 111
 
112 112
 ## misc. test utilities
@@ -114,12 +114,12 @@ sub lives_ok {
114 114
 sub skip {
115 115
     my $reason  = shift;
116 116
     my $depends = shift;
117  
-    Test::proclaim( 1, '', "skip " . $reason, $depends );
  117
+    Perlito5::Test::proclaim( 1, '', "skip " . $reason, $depends );
118 118
 }
119 119
 
120 120
 sub pass {
121 121
     my $desc = shift;
122  
-    Test::proclaim( 1, 'pass! ' . $desc );
  122
+    Perlito5::Test::proclaim( 1, 'pass! ' . $desc );
123 123
 }
124 124
 
125 125
 sub flunk {
@@ -127,7 +127,7 @@ sub flunk {
127 127
     my $todo    = shift;
128 128
     my $depends = shift;
129 129
 
130  
-    Test::proclaim( 0, 'flunk! ' . $desc, $todo, $depends );
  130
+    Perlito5::Test::proclaim( 0, 'flunk! ' . $desc, $todo, $depends );
131 131
 }
132 132
 
133 133
 ## 'private' subs
@@ -149,7 +149,7 @@ sub proclaim {
149 149
     }
150 150
     else {
151 151
         say "not ok ", $num_of_tests_run;
152  
-        Test::report_failure( $todo, $got, $expected, $negate );
  152
+        Perlito5::Test::report_failure( $todo, $got, $expected, $negate );
153 153
     }
154 154
 
155 155
     return $cond;
@@ -161,7 +161,7 @@ sub report_failure {
161 161
     my $expected = shift;
162 162
     my $negate   = shift;
163 163
 
164  
-    say "### Test::report_failure not implemented";
  164
+    say "### Perlito5::Test::report_failure not implemented";
165 165
 }
166 166
 
167 167
 sub test_ends {
2  src5/lib/Perlito5X/bytes.pm → src5/lib/Perlito5/bytes.pm
... ...
@@ -1,4 +1,4 @@
1  
-package bytes;
  1
+package Perlito5::bytes;
2 2
 
3 3
 sub import {
4 4
     $Perlito5::BYTES = 1;
2  src5/lib/Perlito5X/encoding.pm → src5/lib/Perlito5/encoding.pm
... ...
@@ -1,4 +1,4 @@
1  
-package encoding;
  1
+package Perlito5::encoding;
2 2
 
3 3
 sub import {
4 4
     $Perlito5::ENCODING = undef;
2  src5/lib/Perlito5X/strict.pm → src5/lib/Perlito5/strict.pm
... ...
@@ -1,4 +1,4 @@
1  
-package strict;
  1
+package Perlito5::strict;
2 2
 
3 3
 sub import {
4 4
     $Perlito5::STRICT = 1;
2  src5/lib/Perlito5X/utf8.pm → src5/lib/Perlito5/utf8.pm
... ...
@@ -1,4 +1,4 @@
1  
-package utf8;
  1
+package Perlito5::utf8;
2 2
 
3 3
 sub import {
4 4
     $Perlito5::UTF8 = 1;
2  src5/lib/Perlito5X/warnings.pm → src5/lib/Perlito5/warnings.pm
... ...
@@ -1,4 +1,4 @@
1  
-package warnings;
  1
+package Perlito5::warnings;
2 2
 
3 3
 sub import {
4 4
     $Perlito5::WARNINGS = 1;
4  src5/util/perlito5-browser.pl
... ...
@@ -1,7 +1,7 @@
1 1
 package Perlito5;
2 2
 
3  
-use strict ();
4  
-use warnings ();
  3
+use Perlito5::strict ();
  4
+use Perlito5::warnings ();
5 5
 
6 6
 use Perlito5::Match;
7 7
 use Perlito5::Javascript2::Emitter;
7  t5/01-perlito/21-test.t
... ...
@@ -1,5 +1,4 @@
1  
-use Test;
2  
-
3  
-Test::plan 1;
4  
-Test::ok( 1==1, "Test.pm works");
  1
+use Perlito5::Test;
5 2
 
  3
+Perlito5::Test::plan 1;
  4
+Perlito5::Test::ok( 1==1, "Perlito::Test works");

0 notes on commit 1f09a80

Please sign in to comment.
Something went wrong with that request. Please try again.