- Timestamp:
- 08/01/08 10:38:42 (5 months ago)
- Location:
- perl5/Pugs-Compiler-Perl6
- Files:
-
- 6 modified
-
ChangeLog (modified) (1 diff)
-
Makefile.PL (modified) (2 diffs)
-
lib/Pugs/Emitter/Perl6/Perl5.pm (modified) (7 diffs)
-
lib/Pugs/Runtime/Perl6.pm (modified) (3 diffs)
-
lib/Pugs/Runtime/Perl6Prelude.pm (modified) (1 diff)
-
lib/v6.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
perl5/Pugs-Compiler-Perl6/ChangeLog
r21633 r21663 1 0.032 2008-08-01 2 - pi, Inf, NaN 3 - more operators 4 - IO fixes 5 1 6 0.031 2008-07-30 2 7 - updated skipped tests -
perl5/Pugs-Compiler-Perl6/Makefile.PL
r21650 r21663 144 144 } 145 145 if ( $out eq 't/spec/S04-statements/do.t' ) { 146 $text = "force_todo(1.. 8,10..16,20..23);\n" . $text;146 $text = "force_todo(1..6,10,11,20..22);\n" . $text; 147 147 # redo works in perl5 blocks 148 148 $text =~ s/^([^\n]*?\; *redo\;)/ok( 0, "redo works in perl5 blocks", :todo ) ; # $1/mg; … … 192 192 ); 193 193 194 clean_files( map {glob File::Spec->catfile('t', ('*') x $_, '*.{t,pm}c')} 0..3);194 clean_files( 't/Test.pmc', map {glob File::Spec->catfile('t', ('*') x $_, '*.{t,pm}c')} 0..3); 195 195 196 196 &WriteAll; -
perl5/Pugs-Compiler-Perl6/lib/Pugs/Emitter/Perl6/Perl5.pm
r21654 r21663 250 250 sub _emit_complex { 251 251 my $n = shift; 252 $n =~ s/i/* i/;252 $n =~ s/i/*Math::Complex::i/; 253 253 "($n)"; 254 } 255 256 sub _emit_num { 257 my $n = shift; 258 return '$Math::Complex::Inf' if $n eq 'Inf'; 259 return '($Math::Complex::Inf - $Math::Complex::Inf)' if $n eq 'NaN'; 260 "$n"; 254 261 } 255 262 … … 296 303 if exists $n->{int}; 297 304 298 return $n->{num}305 return _emit_num( $n->{num} ) 299 306 if exists $n->{num}; 300 307 … … 852 859 } 853 860 854 if ( $subname eq 'any' || $subname eq 'all' 855 || $subname eq 'substr' || $subname eq 'split' || $subname eq 'die' || $subname eq 'return' 856 || $subname eq 'push' || $subname eq 'pop' || $subname eq 'shift' || $subname eq 'join' 857 || $subname eq 'index' || $subname eq 'undef' || $subname eq 'rand' || $subname eq 'int' 858 || $subname eq 'splice' || $subname eq 'keys' || $subname eq 'values' || $subname eq 'sort' 859 || $subname eq 'chomp' || $subname eq 'lc' || $subname eq 'abs' || $subname eq 'sleep' 861 if ($subname eq 'readline') { 862 my $param = _emit( $n->{param} ); 863 return "Pugs::Runtime::Perl6::IO::readline( $param )"; 864 } 865 866 if ($subname eq 'pi') { 867 return "Math::Complex::pi()"; 868 } 869 870 if ( $subname eq 'any' || $subname eq 'all' 871 || $subname eq 'substr' || $subname eq 'split' || $subname eq 'die' || $subname eq 'return' 872 || $subname eq 'push' || $subname eq 'pop' || $subname eq 'shift' || $subname eq 'join' 873 || $subname eq 'index' || $subname eq 'undef' || $subname eq 'rand' || $subname eq 'int' 874 || $subname eq 'splice' || $subname eq 'keys' || $subname eq 'values' || $subname eq 'sort' 875 || $subname eq 'chomp' || $subname eq 'lc' || $subname eq 'abs' || $subname eq 'sleep' 876 || $subname eq 'unlink' || $subname eq 'close' || $subname eq 'sqrt' 860 877 ) 861 878 { … … 933 950 $n->{method}{dot_bareword} eq 'warn' ) { 934 951 my $s = _emit( $n->{self} ); 935 if ( $s eq Pugs::Runtime::Common::mangle_var('$*ERR') ) { 936 return " print STDERR '', " . _emit( $n->{param} ); 952 if ( exists $n->{self}{scalar} && $n->{self}{scalar} eq '$*ERR' ) { 953 return " print STDERR " . ( $n->{param} ? _emit( $n->{param} ) : "''" ); 954 } 955 if ( exists $n->{self}{scalar} && $n->{self}{scalar} eq '$*OUT' ) { 956 return " print STDOUT " . ( $n->{param} ? _emit( $n->{param} ) : "''" ); 957 } 958 if ( exists $n->{self}{scalar} && $n->{self}{scalar} ) { 959 return "$s->print" . emit_parenthesis( $n->{param} ); 937 960 } 938 961 return " print '', $s"; … … 940 963 if ( $n->{method}{dot_bareword} eq 'say' ) { 941 964 my $s = _emit( $n->{self} ); 942 if ( $s eq Pugs::Runtime::Common::mangle_var('$*ERR') ) { 943 return " print STDERR '', " . _emit( $n->{param} ) . ', "\n"'; 965 if ( exists $n->{self}{scalar} && $n->{self}{scalar} eq '$*OUT' ) { 966 return " print STDOUT " . ( $n->{param} ? _emit( $n->{param} ) : "''" ) . ', "\n"'; 967 } 968 if ( exists $n->{self}{scalar} && $n->{self}{scalar} eq '$*ERR' ) { 969 return " print STDERR " . ( $n->{param} ? _emit( $n->{param} ) : "''" ) . ', "\n"'; 970 } 971 if ( exists $n->{self}{scalar} && $n->{self}{scalar} ) { 972 return "$s->say" . emit_parenthesis( $n->{param} ); 944 973 } 945 974 return " print '', $s" . ', "\n"'; … … 1122 1151 $ret .= 'else '. emit_block( $n->{else} ) . "\n"; 1123 1152 } 1153 else { 1154 $ret .= "else { () }\n"; 1155 } 1124 1156 return $ret; 1125 1157 } 1126 1158 1127 1159 if ( $n->{statement} eq 'do' ) { 1128 return 'do { for($_) ' . emit_block( $n->{exp1} ) . ' }'; 1160 # double braces in 'do' allow for 'next/last' 1161 return 'do {{ ' . emit_block( $n->{exp1} ) . ' }}'; 1129 1162 } 1130 1163 if ( $n->{statement} eq 'given' ) { … … 1299 1332 bool->import(); # True, False 1300 1333 use Quantum::Superpositions; 1301 use Math::Complex ;1334 use Math::Complex (); 1302 1335 $attributes "; 1303 1336 -
perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6.pm
r21574 r21663 183 183 } 184 184 } 185 186 sub readline { 187 my $tmp = $_[0]->getline; 188 chomp( $tmp ); 189 $tmp; 190 } 191 192 sub say { 193 (+shift)->print(@_, "\n"); 194 } 185 195 186 196 sub slurp { 187 197 if ( wantarray ) { 188 198 my @a; 189 if ( ref( $_[0] ) eq 'IO::File') {199 if ( UNIVERSAL::isa( $_[0], 'IO::Handle' ) ) { 190 200 my $f = shift; 191 201 @a = <$f>; … … 199 209 } 200 210 201 if ( ref( $_[0] ) eq 'IO::File') {211 if ( UNIVERSAL::isa( $_[0], 'IO::Handle' ) ) { 202 212 return <$_[0]>; 203 213 } … … 207 217 } 208 218 } 219 220 221 package Pugs::Runtime::Perl6::IO::File; 222 use base 'IO::File'; 223 use base 'Pugs::Runtime::Perl6::IO'; 224 209 225 210 226 package Pugs::Runtime::Perl6::Routine; -
perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6Prelude.pm
r21654 r21663 23 23 # sub sleep($seconds) is export { use v5; CORE::sleep($seconds); use v6; } 24 24 25 sub open($file, :$w? ) { use v5; my $fh = IO::File->new; $fh->open($file, ($w ? 'w' : ()) ) || warn "can't open file $file"; $fh; use v6; } 25 sub open($file, :$w? ) { 26 use v5; 27 my $fh = Pugs::Runtime::Perl6::IO::File->new; 28 $fh->open($file, ($w ? 'w' : ()) ) || warn "can't open file $file"; 29 $fh; 30 use v6; 31 } 26 32 27 33 module Pugs::Internals; -
perl5/Pugs-Compiler-Perl6/lib/v6.pm
r21648 r21663 1 1 package v6; 2 $v6::VERSION = '0.03 1';2 $v6::VERSION = '0.032'; 3 3 4 4 # Documentation in the __END__ … … 94 94 "use Scalar::Util; 95 95 use Quantum::Superpositions; 96 use Math::Complex ;96 use Math::Complex (); 97 97 use Pugs::Runtime::Perl6; 98 98 use Pugs::Runtime::Perl6Prelude;
