Changeset 4871

Show
Ignore:
Timestamp:
06/20/05 16:11:39 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
6641
Message:

* repair pugs -C tests.
* Pugs.Compile.Parrot is now gone; -CParrot etc becomes an

alias to -CPIR etc.

Files:
1 removed
4 modified

Legend:

Unmodified
Added
Removed
  • src/Emit/PIR.hs

    r4861 r4871  
    489489vop1ss :: SubName -> PrimName -> Decl 
    490490vop1ss p6name opname = vop1x p6name opname tempSTR tempSTR 
     491{-| Wrapper for a opcode which returns a @S@ register and accepts a @I@ register. -} 
     492vop1si :: SubName -> PrimName -> Decl 
     493vop1si p6name opname = vop1x p6name opname tempSTR tempINT 
     494{-| Wrapper for a opcode which returns a @I@ register and accepts a @S@ register. -} 
     495vop1is :: SubName -> PrimName -> Decl 
     496vop1is p6name opname = vop1x p6name opname tempINT tempSTR 
     497{-| Wrapper for a opcode which returns a @I@ register and accepts a @P@ register. -} 
     498vop1ip :: SubName -> PrimName -> Decl 
     499vop1ip p6name opname = vop1x p6name opname tempINT tempPMC 
    491500 
    492501{-| Wrapper for a opcode which accepts and returns @I@ registers. -} 
     
    635644        , "exit" .- [tempINT] 
    636645        ] 
     646    , vop1is "&system" "spawnw" 
    637647 
    638648    -- Operators 
     
    701711 
    702712    -- Strings 
    703     , vop1x "&chars" "length"     tempINT tempSTR 
    704     , vop1x "&bytes" "bytelength" tempINT tempSTR 
     713    , vop1is "&chars" "length" 
     714    , vop1is "&bytes" "bytelength" 
    705715    , sub "&prefix:\\" [arg0] 
    706716        [ tempPMC   <-- "new" $ [lit PerlRef, arg0] 
     
    728738        , rv        <:= tempSTR2 
    729739        ] --> [rv] 
    730     , vop1x "&chr" "chr" tempSTR tempINT 
    731     , vop1x "&ord" "ord" tempINT tempSTR 
     740    , vop1si "&chr" "chr" 
     741    , vop1is "&ord" "ord" 
    732742    , vop2x "&infix:x" "repeat" tempSTR tempSTR tempINT 
    733743    , vop1ss "&lc" "downcase" 
     
    742752        , arg0 <== tempPMC 
    743753        ] --> [arg0] 
    744     , vop1x "&defined" "defined" tempINT tempPMC 
     754    , vop1ip "&defined" "defined" 
    745755{- XXX saying  hash 
    746756-- causes error:imcc:syntax error, unexpected IREG, expecting '(' 
  • src/Pugs/Compile.hs

    r4655 r4871  
    1313import Pugs.AST 
    1414import Pugs.Internals 
     15import Pugs.Compile.PIR (genPIR) 
    1516import Pugs.Compile.Pugs (genPugs) 
    16 import Pugs.Compile.Pugs2 (genPugs2) 
    17 import Pugs.Compile.Parrot (genPIR) 
    18 import Pugs.Compile.PIR (genPIR') 
    1917import Pugs.Compile.Haskell (genGHC) 
    2018 
    2119compile :: String -> Env -> IO String 
     20compile "GHC"     env = fmap vCast $ runEvalIO env genGHC 
     21compile "Ghc"     env = fmap vCast $ runEvalIO env genGHC 
    2222compile "Haskell" env = fmap vCast $ runEvalIO env genGHC 
     23compile "Parrot"  env = fmap vCast $ runEvalIO env genPIR 
     24compile "Pir"     env = fmap vCast $ runEvalIO env genPIR 
     25compile "PIR"     env = fmap vCast $ runEvalIO env genPIR 
    2326compile "Pugs"    env = fmap vCast $ runEvalIO env genPugs 
    24 compile "Pugs2"   env = fmap vCast $ runEvalIO env genPugs2 
    25 compile "Parrot"  env = fmap vCast $ runEvalIO env genPIR 
    26 compile "Pir"     env = fmap vCast $ runEvalIO env genPIR' 
    27 compile "PIR"     env = fmap vCast $ runEvalIO env genPIR' 
    2827compile s _ = fail $ "Cannot compile to " ++ s 
    2928 
  • src/Pugs/Compile/PIR.hs

    r4869 r4871  
    11{-# OPTIONS_GHC -fglasgow-exts -fno-warn-orphans -funbox-strict-fields -fallow-undecidable-instances -cpp #-} 
    22 
    3 module Pugs.Compile.PIR (genPIR') where 
    4 import Pugs.Compile.Parrot 
     3module Pugs.Compile.PIR (genPIR) where 
    54import Pugs.Internals 
    65import Pugs.AST 
     
    2019    PNoop       :: PIL Stmt 
    2120 
    22     PRaw        :: !Exp -> PIL Stmt -- XXX HACK! 
    2321    PRawName    :: !VarName -> PIL Expression -- XXX HACK! 
    2422 
     
    7977    show (PThunk x) = "(PThunk " ++ show x ++ ")" 
    8078    show (PBlock x) = "(PBlock " ++ show x ++ ")" 
    81     show (PRaw x) = "(PRaw " ++ show x ++ ")" 
    8279    show (PRawName x) = "(PRawName " ++ show x ++ ")" 
    8380    show (PSub x y z) = "(PSub " ++ show x ++ " " ++ show y ++ " " ++ show z ++ ")" 
     
    175172    compile (Stmts (Pad SMy pad exp) rest) = do 
    176173        expC    <- compile $ mergeStmts exp rest 
    177         padC    <- mapM compile (padToList pad) 
     174        padC    <- compile $ padToList pad 
    178175        return $ PPad ((map fst (padToList pad)) `zip` padC) expC 
    179176    compile exp = compileStmts exp 
     
    494491        tellLabel endC 
    495492        return (ExpLV this) 
    496     trans (PRaw exp) = do 
    497         env <- asks tEnv 
    498         raw <- liftIO $ runEvalIO env{ envStash = "$P0" } $ do 
    499             doc <- compile' exp 
    500             return $ VStr (render doc) 
    501         return $ StmtRaw (text $ vCast raw) 
    502493    trans (PRawName name) = do 
    503494        -- generate fresh supply and things... 
     
    597588    return $ reg (VAR var) 
    598589 
     590padSort :: (Var, [(TVar Bool, TVar VRef)]) -> (String, [(a, b)]) -> Ordering 
     591padSort ((a::[Char]), [(_, _)]) ((b::[Char]), [(_, _)]) 
     592    | (head a == ':' && head b == '&') = LT 
     593    | (head b == ':' && head a == '&') = GT 
     594    | otherwise = GT 
     595padSort _ _ = EQ 
     596 
    599597varText :: String -> Doc 
    600598varText ('$':name)  = text $ "s__" ++ escaped name 
     
    611609 
    612610{-| Compiles the current environment to PIR code. -} 
    613 genPIR' :: Eval Val 
    614 genPIR' = do 
     611genPIR :: Eval Val 
     612genPIR = do 
    615613    tenv        <- initTEnv 
    616614    -- Load the PIR Prelude. 
    617     local (\env -> env{envDebug = Nothing}) $ do 
     615    local (\env -> env{ envDebug = Nothing }) $ do 
    618616        opEval style "<prelude-pir>" preludeStr 
    619617    glob        <- askGlobal 
    620618    main        <- asks envBody 
    621     globPIL    <- compile glob 
    622     mainPIL    <- compile main 
     619    globPIL     <- compile glob 
     620    mainPIL     <- compile main 
    623621    globPIR     <- runTransGlob tenv globPIL :: Eval [Decl] 
    624622    mainPIR     <- runTransMain tenv mainPIL :: Eval [Stmt] 
  • t/pugsrun/09-dash-uppercase-c.t

    r4549 r4871  
    1515my @t_good = map &flatten, ( 
    1616  any('-C') 
    17     ~ any('Pugs', 'pugs', 'pUGs') 
     17    ~ any('Pugs', 'pUGs') 
    1818    ~ ' ' 
    1919    ~ any('-e1', map { "examples/$_.p6" } < 
     
    2727>), 
    2828  any('-C') 
    29     ~ any('Parrot', 'parrot', 'paRRot') 
     29    ~ any('Parrot', 'paRRot') 
    3030    ~ ' ' 
    3131    ~ any('-e1', map {"examples/$_.p6"} < 
     
    3636  junctions/all-all 
    3737  junctions/grades 
     38  functional/fp 
     39  algorithms/hanoi 
     40  junctions/all-any 
    3841>) 
    3942); 
    4043 
    41 my @t_todo = map &flatten, ( 
    42   '-C' 
    43     ~ any('Parrot', 'parrot', 'paRRot') 
    44     ~ ' examples/' 
    45     ~ any(< 
    46   functional/fp 
    47   algorithms/hanoi 
    48   junctions/all-any 
    49   >) ~ '.p6' 
    50 ); 
    51  
    5244# I don't know (yet) how to force a junction into expansion 
    53 my (@tests_ok,@tests_todo); 
     45my (@tests_ok); 
    5446for @t_good -> $test { 
    5547  push @tests_ok, $test; 
    5648}; 
    5749 
    58 for @t_todo -> $test { 
    59   push @tests_todo, $test; 
    60 }; 
    6150 
    62  
    63 plan ((+@tests_ok+@tests_todo)*3); 
     51plan ((+@tests_ok)*2); 
    6452 
    6553diag "Running under $*OS"; 
    6654 
    6755# 2>&1 only works on WinNT upwards (cmd.exe) ! 
    68 my ($pugs,$redir, $redir_stderr) = ("./pugs", ">", "2>&1"); 
     56my ($pugs,$redir, $redir_stderr) = ("./pugs", ">"); 
    6957if($*OS eq any(<MSWin32 mingw msys cygwin>)) { 
    7058  $pugs = 'pugs.exe'; 
     
    7462sub run_pugs ($c) { 
    7563  my $tempfile = "temp-ex-output" ~ nonce; 
    76   my $command = "$pugs $c $redir $tempfile $redir_stderr"; 
     64  my $command = "$pugs $c $redir $tempfile"; 
    7765  diag $command; 
    7866  system $command; 
     
    8977  $fh.close(); 
    9078 
    91   my $output = run_pugs($test); 
    92   is( $output, "", "No error output"); 
    93  
    94   my $f = slurp $dump_file; 
    95   ok( defined $f, "dump.ast was created" ); 
     79  my $f = run_pugs($test); 
     80  ok( defined $f, "dump file was created" ); 
    9681  ok( $f ~~ rx:perl5/.../, "... and it contains some output" ); 
    9782 
     
    10085}; 
    10186 
    102 for @tests_todo -> $test { 
    103  
    104   my $fh = open("$dump_file", :w); 
    105   $fh.close(); 
    106  
    107   my $output = run_pugs($test); 
    108   if (is( $output, "", "No error output", :todo)) { 
    109  
    110     my $f = slurp $dump_file; 
    111     ok( defined $f, "dump.ast was created" ); 
    112     ok( $f ~~ rx:perl5/.../, "... and it contains some output" , :todo); 
    113   } else { 
    114     fail("No clean compile", :todo); 
    115     fail("No clean compile", :todo); 
    116   }; 
    117  
    118   unlink($dump_file) 
    119     or diag "$dump_file was not removed for next run"; 
    120 };