Changeset 21663 for perl5

Show
Ignore:
Timestamp:
08/01/08 10:38:42 (4 months ago)
Author:
fglock
Message:

[v6.pm] 0.032

Location:
perl5/Pugs-Compiler-Perl6
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • perl5/Pugs-Compiler-Perl6/ChangeLog

    r21633 r21663  
     10.032  2008-08-01 
     2- pi, Inf, NaN 
     3- more operators 
     4- IO fixes 
     5 
    160.031  2008-07-30 
    27- updated skipped tests 
  • perl5/Pugs-Compiler-Perl6/Makefile.PL

    r21650 r21663  
    144144    } 
    145145    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;   
    147147        # redo works in perl5 blocks 
    148148        $text =~ s/^([^\n]*?\; *redo\;)/ok( 0, "redo works in perl5 blocks", :todo ) ; # $1/mg; 
     
    192192); 
    193193 
    194 clean_files(map {glob File::Spec->catfile('t', ('*') x $_, '*.{t,pm}c')} 0..3); 
     194clean_files( 't/Test.pmc', map {glob File::Spec->catfile('t', ('*') x $_, '*.{t,pm}c')} 0..3); 
    195195 
    196196&WriteAll; 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Emitter/Perl6/Perl5.pm

    r21654 r21663  
    250250sub _emit_complex { 
    251251    my $n = shift; 
    252     $n =~ s/i/*i/; 
     252    $n =~ s/i/*Math::Complex::i/; 
    253253    "($n)"; 
     254} 
     255 
     256sub _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"; 
    254261} 
    255262 
     
    296303        if exists $n->{int}; 
    297304 
    298     return $n->{num} 
     305    return _emit_num( $n->{num} ) 
    299306        if exists $n->{num}; 
    300307 
     
    852859            } 
    853860 
    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' 
    860877                )  
    861878            { 
     
    933950             $n->{method}{dot_bareword} eq 'warn' ) { 
    934951            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} ); 
    937960            } 
    938961            return " print '', $s"; 
     
    940963        if ( $n->{method}{dot_bareword} eq 'say' ) { 
    941964            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} ); 
    944973            } 
    945974            return " print '', $s" . ', "\n"'; 
     
    11221151            $ret .= 'else '. emit_block( $n->{else} ) . "\n"; 
    11231152        } 
     1153        else { 
     1154            $ret .= "else { () }\n"; 
     1155        } 
    11241156        return $ret; 
    11251157    } 
    11261158 
    11271159    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} ) . ' }}'; 
    11291162    } 
    11301163    if ( $n->{statement} eq 'given' ) { 
     
    12991332                bool->import();  # True, False 
    13001333                use Quantum::Superpositions; 
    1301                 use Math::Complex; 
     1334                use Math::Complex (); 
    13021335                $attributes "; 
    13031336 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6.pm

    r21574 r21663  
    183183        } 
    184184    } 
     185 
     186    sub readline { 
     187        my $tmp = $_[0]->getline; 
     188        chomp( $tmp ); 
     189        $tmp; 
     190    } 
     191     
     192    sub say { 
     193        (+shift)->print(@_, "\n"); 
     194    } 
    185195     
    186196    sub slurp { 
    187197        if ( wantarray ) { 
    188198            my @a; 
    189             if ( ref( $_[0] ) eq 'IO::File' ) { 
     199            if ( UNIVERSAL::isa( $_[0], 'IO::Handle' ) ) { 
    190200                my $f = shift; 
    191201                @a = <$f>; 
     
    199209        } 
    200210 
    201             if ( ref( $_[0] ) eq 'IO::File' ) { 
     211            if ( UNIVERSAL::isa( $_[0], 'IO::Handle' ) ) { 
    202212                return <$_[0]>; 
    203213            } 
     
    207217            } 
    208218    } 
     219 
     220 
     221package Pugs::Runtime::Perl6::IO::File; 
     222    use base 'IO::File'; 
     223    use base 'Pugs::Runtime::Perl6::IO'; 
     224 
    209225 
    210226package Pugs::Runtime::Perl6::Routine; 
  • perl5/Pugs-Compiler-Perl6/lib/Pugs/Runtime/Perl6Prelude.pm

    r21654 r21663  
    2323# sub sleep($seconds) is export { use v5; CORE::sleep($seconds); use v6; } 
    2424 
    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; } 
     25sub 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} 
    2632 
    2733module Pugs::Internals; 
  • perl5/Pugs-Compiler-Perl6/lib/v6.pm

    r21648 r21663  
    11package v6; 
    2 $v6::VERSION = '0.031'; 
     2$v6::VERSION = '0.032'; 
    33 
    44# Documentation in the __END__ 
     
    9494        "use Scalar::Util; 
    9595         use Quantum::Superpositions; 
    96          use Math::Complex; 
     96         use Math::Complex (); 
    9797         use Pugs::Runtime::Perl6; 
    9898         use Pugs::Runtime::Perl6Prelude;