Changeset 342

Show
Ignore:
Timestamp:
02/28/05 20:25:26 (4 years ago)
Author:
autrijus
svk:copy_cache_prev:
1619
Message:

* Isaac (SyntaxNinja?)'s massive -Wall cleanup landed; also move S03.t into 03operator.t

Files:
1 removed
119 modified

Legend:

Unmodified
Added
Removed
  • AUTHORS

    • Property svn:eol-style set to native
  • ChangeLog

    • Property svn:eol-style set to native
  • LICENSE/Artistic-2

    • Property svn:eol-style set to native
  • LICENSE/GPL-2

    • Property svn:eol-style set to native
  • MANIFEST

    • Property svn:eol-style set to native
  • MANIFEST.SKIP

    • Property svn:eol-style set to native
  • META.yml

    • Property svn:eol-style set to native
  • Makefile.PL

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r321 r342  
    115115postamble(<< "."); 
    116116$pugs: @{[glob("src/*.hs"), glob("src/Rule/*.hs")]} $version_h 
    117         ghc --make -o pugs src/Main.hs -isrc 
     117        ghc --make -Wall -fno-warn-missing-signatures -fno-warn-name-shadowing -o pugs src/Main.hs -isrc 
    118118 
    119119tags :: 
  • README

    • Property svn:eol-style set to native
  • SIGNATURE

    • Property svn:eol-style set to native
  • docs/01Overview.html

    • Property svn:eol-style set to native
  • examples/fp.p6

    • Property svn:eol-style set to native
  • examples/life.p6

    • Property svn:eol-style set to native
  • examples/mandel.p6

    • Property svn:eol-style set to native
  • examples/quicksort.p6

    • Property svn:eol-style set to native
  • examples/sendmoremoney.p6

    • Property svn:eol-style set to native
  • examples/shuffle.p6

    • Property svn:eol-style set to native
  • inc/Module/Install.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Base.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Can.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Fetch.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Makefile.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Metadata.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Scripts.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/Win32.pm

    • Property svn:eol-style set to native
  • inc/Module/Install/WriteAll.pm

    • Property svn:eol-style set to native
  • inc/Test/Harness.pm

    • Property svn:eol-style set to native
  • inc/Test/Harness/Assert.pm

    • Property svn:eol-style set to native
  • inc/Test/Harness/Iterator.pm

    • Property svn:eol-style set to native
  • inc/Test/Harness/Straps.pm

    • Property svn:eol-style set to native
  • inc/Test/Harness/TAP.pod

    • Property svn:eol-style set to native
  • lib/Perl6/Pugs.pm

    • Property svn:eol-style set to native
  • lib/Perl6/lib/Kwid.pm

    • Property svn:eol-style set to native
  • lib/Perl6/lib/Test.pm

    • Property svn:eol-style set to native
  • lib/Perl6/lib/perlkwid.kwid

    • Property svn:eol-style set to native
  • src/AST.hs

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r222 r342  
    2727    vCast v             = doCast v 
    2828    castV :: n -> Val 
    29     castV v = error $ "cannot cast into Val" 
     29    castV _ = error $ "cannot cast into Val" 
    3030    doCast :: Val -> n 
    3131    doCast v = error $ "cannot cast from Val: " ++ (show v) 
     
    4040    vCast v             = case vCast v of 
    4141        [x, y]  -> (x, y) 
    42         other   -> error $ "cannot cast into VPair: " ++ (show v) 
     42        _       -> error $ "cannot cast into VPair: " ++ (show v) 
    4343 
    4444instance Value VHash where 
     
    9595    = (1 ==) . length . filter vCast $ setToList vs 
    9696 
     97readMVal :: MonadIO m => Val -> m Val 
    9798readMVal (MVal mv) = readMVal =<< liftIO (readIORef mv) 
    9899readMVal v         = return v 
     
    129130    doCast (VArray (MkArray a))    = genericLength a 
    130131    doCast (VHash (MkHash h))    = fromIntegral $ sizeFM h 
    131     doCast x            = 0/0 -- error $ "cannot cast as Num: " ++ (show x) 
     132    doCast _            = 0/0 -- error $ "cannot cast as Num: " ++ (show x) 
    132133 
    133134instance Value VComplex where 
     
    141142    vCast (VBool b)     = if b then "1" else "" 
    142143    vCast (VInt i)      = show i 
    143     vCast (VRat r)      = showNum $ realToFrac r 
     144    vCast (VRat r)      = showNum $ (realToFrac r :: Double) 
    144145    vCast (VNum n)      = showNum n 
    145146    vCast (VList l)     = unwords $ map vCast l 
     
    151152    vCast x             = error $ "cannot cast as Str: " ++ (show x) 
    152153 
     154showNum :: Show a => a -> String 
    153155showNum x 
    154156    | (i, ".0") <- break (== '.') str 
     
    163165 
    164166instance Value MVal where 
    165     castV ref = error "bye~" --unsafePerformIO $ readIORef ref 
     167    castV _ = error "Cannot cast MVal into Value!" 
    166168    vCast (MVal x)      = x 
    167169    vCast (VRef v)      = vCast v 
     
    209211    castV = id -- XXX not really correct; need to referencify things 
    210212 
     213strRangeInf :: String -> [String] 
    211214strRangeInf s = (s:strRangeInf (strInc s)) 
    212215 
     216strRange :: String -> String -> [String] 
    213217strRange s1 s2 
    214218    | s1 == s2              = [s2] 
     
    216220    | otherwise             = (s1:strRange (strInc s1) s2) 
    217221 
     222strInc :: String -> String 
    218223strInc []       = "1" 
    219224strInc "z"      = "aa" 
     
    229234    xs  = init str 
    230235 
     236charInc :: Char -> Char 
    231237charInc x   = chr $ 1 + ord x 
    232238 
     239intCast :: Num b => Val -> b 
    233240intCast x   = fromIntegral (vCast x :: VInt) 
    234241 
     
    272279    deriving (Show, Eq, Ord) 
    273280 
     281valType :: Val -> String 
    274282valType VUndef          = "Any" 
    275283valType (VRef v)        = valType v 
     
    342350instance (Ord a, Ord b) => Ord (FiniteMap a b) 
    343351instance Ord MVal where 
    344     compare x y = LT -- compare (castV x) (castV y) 
     352    compare _ _ = EQ -- compare (castV x) (castV y) 
    345353instance Show MVal where 
    346354    show _ = "<mval>" 
     
    369377instance Eq (CharParser Env Exp) 
    370378instance Ord (CharParser Env Exp) where 
    371     compare _ _ = LT 
     379    compare _ _ = EQ 
    372380 
    373381extractExp :: Exp -> ([Exp], [String]) -> ([Exp], [String]) 
    374 extractExp exp (exps, vs) = (exp':exps, vs') 
    375     where 
    376     (exp', vs') = extract (exp, vs) 
     382extractExp ex (exps, vs) = (ex':exps, vs') 
     383    where 
     384    (ex', vs') = extract (ex, vs) 
    377385 
    378386extract :: (Exp, [String]) -> (Exp, [String]) 
     
    398406    | otherwise 
    399407    = (Var name, vs) 
    400 extract ((Parens exp), vs) = ((Parens exp'), vs') 
    401     where 
    402     (exp', vs') = extract (exp, vs) 
     408extract ((Parens ex), vs) = ((Parens ex'), vs') 
     409    where 
     410    (ex', vs') = extract (ex, vs) 
    403411extract other = other 
    404412 
     413cxtOfSigil :: Char -> String 
    405414cxtOfSigil '$'  = "Scalar" 
    406415cxtOfSigil '@'  = "Array" 
    407416cxtOfSigil '%'  = "Hash" 
    408417cxtOfSigil '&'  = "Code" 
     418cxtOfSigil x    = internalError $ "cxtOfSigil: unexpected character: " ++ (show x) 
    409419 
    410420--- cxtOf '*' '$'   = "List" 
     421cxtOf :: Char -> Char -> String 
    411422cxtOf '*' '@'   = "List" 
    412423cxtOf _   _     = "Scalar" 
    413424 
    414 buildParam cxt sigil name exp = Param 
     425buildParam :: String -> String -> String -> Exp -> Param 
     426buildParam cxt sigil name e = Param 
    415427    { isInvocant    = False 
    416428    , isSlurpy      = (sigil == "*") 
     
    420432    , paramName     = name 
    421433    , paramContext  = if null cxt then defaultCxt else cxt 
    422     , paramDefault  = exp 
     434    , paramDefault  = e 
    423435    } 
    424436    where 
    425437    sig = if null sigil then ' ' else head sigil 
    426438    defaultCxt = cxtOf sig (head name)  
     439 
     440defaultArrayParam :: Param 
     441defaultHashParam :: Param 
     442defaultScalarParam :: Param 
    427443 
    428444defaultArrayParam   = buildParam "" "*" "@_" (Val VUndef) 
  • src/Bind.hs

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r334 r342  
    3535 
    3636bindHash :: [Exp] -> [Param] -> MaybeError [(Param, Exp)] 
    37 bindHash vs []          = return [] 
     37bindHash _ []          = return [] 
    3838bindHash [] [p]         = return [ (p, emptyHashExp) ] 
    3939bindHash vs (p:ps@(_:_))= do 
     
    5959doBindArray :: Exp -> ([(Param, Exp)], VInt) -> (Param, Char) -> MaybeError ([(Param, Exp)], VInt) 
    6060doBindArray _ (xs, -1) (p, '@') = return (((p, emptyArrayExp):xs), -1) 
    61 doBindArray _ (xs, -1) (p, '$') = fail $ "Slurpy array followed by slurpy scalar: " ++ show p 
     61doBindArray _ (_, -1) (p, '$') = fail $ "Slurpy array followed by slurpy scalar: " ++ show p 
    6262doBindArray v (xs, n)  (p, '@') = return (((p, doSlice v [n..]):xs), -1) 
    6363doBindArray v (xs, n)  (p, '$') = case v of 
    6464    (Syn "," [])    -> fail $ "Insufficient arguments for slurpy scalar" 
    6565    _               -> return (((p, doIndex v n):xs), n+1) 
     66doBindArray _ (_, _)  (_, x) = internalError $ "doBindArray: unexpected char: " ++ (show x) 
    6667 
    6768bindEmpty :: Param -> MaybeError (Param, Exp) 
     
    6970    ('@':_) -> return (p, emptyArrayExp) 
    7071    ('$':_) -> fail $ "Unbound slurpy scalar: " ++ show p 
    71     other   -> error $ "Impossible - unknown slurpy sigil in param: " ++ other 
     72    (x:_)   -> internalError $ "bindEmpty: unexpected char: " ++ (show x) 
     73    []      -> internalError $ "bindEmpty: empty string encountered" 
    7274 
    7375isPair :: Exp -> Bool 
    74 isPair (Syn "=>" [(Val v), _])   = True 
    75 isPair (Val (VPair (_, _)))             = True 
    76 isPair _                                = False 
     76isPair (Syn "=>" [(Val _), _])   = True 
     77isPair (Val (VPair (_, _)))      = True 
     78isPair _                         = False 
    7779 
    7880unPair :: Exp -> (String, Exp) 
  • src/Cont.hs

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r23 r342  
    1 {-# OPTIONS -fglasgow-exts #-} 
     1{-# OPTIONS -fglasgow-exts -fno-warn-unused-binds #-} 
    22 
    33{- 
  • src/Context.hs

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r190 r342  
    1515type Cxt = String 
    1616 
     17countTree :: Tree Type -> Int 
    1718countTree (Node _ []) = 0 
    1819countTree (Node _ cs) = 1 + sum (map countTree cs) 
     
    3940    l2 = findList target tree 
    4041 
     42castOk :: a -> b -> Bool 
    4143castOk _ _ = True 
    4244 
     45compareList :: (Eq a) => [a] -> [a] -> Int 
    4346compareList [] _ = 0 
    4447compareList _ [] = 0 
     
    4851    | otherwise = compareList l1 (init l2) 
    4952 
     53findList :: Eq [a] => [a] -> Tree [a] -> [[a]] 
    5054findList [] _ = [] 
    5155findList base (Node l cs) 
     
    5660    found = map (findList base) cs 
    5761 
     62prettyTypes :: String 
    5863prettyTypes = drawTree initTree 
    5964 
  • src/Eval.hs

    • Property svn:mime-type set to text/plain; charset=UTF-8
    • Property svn:eol-style set to native
    r332 r342  
    7070evaluate (Val v@(MVal mv)) = do 
    7171    lvalue  <- asks envLValue 
    72     cxt     <- asks envContext 
     72         <- asks envContext 
    7373    if lvalue 
    7474        then return v 
     
    122122    shiftT $ \_ -> return $ VError str exp 
    123123 
    124 newMVal val@(MVal r) = newMVal =<< liftIO (readIORef r) 
     124newMVal (MVal r) = newMVal =<< liftIO (readIORef r) 
    125125newMVal val = do 
    126126    mval <- liftIO $ newIORef val 
    127127    return $ MVal mval 
    128128 
    129 writeMVal l (MVal r)    = writeMVal l =<< liftIO (readIORef r) 
    130 writeMVal (MVal l) r    = liftIO $ writeIORef l r 
    131 writeMVal l@(VError s e) _ = retError s e 
    132 writeMVal _ l@(VError s e) = retError s e 
    133 writeMVal x y           = retError "Can't write a constant item" (Val x) 
     129writeMVal l (MVal r)     = writeMVal l =<< liftIO (readIORef r) 
     130writeMVal (MVal l) r     = liftIO $ writeIORef l r 
     131writeMVal (VError s e) _ = retError s e 
     132writeMVal _ (VError s e) = retError s e 
     133writeMVal x _            = retError "Can't write a constant item" (Val x) 
    134134 
    135135-- readMVal (MVal mv) =  liftIO $ readIORef mv 
     
    144144reduceStatements ([], exp) = reduceExp exp 
    145145reduceStatements (((exp, pos):rest), lastVal) 
    146     | Syn "sym" (Sym sym@(Symbol _ _ vexp@(Syn "sub" [sub])):other) <- exp = do 
     146    | Syn "sym" (Sym sym@(Symbol _ _ vexp@(Syn "sub" [_])):other) <- exp = do 
    147147        (VSub sub) <- enterEvalContext "Code" vexp 
    148148        lex <- asks envLexical 
     
    178178        reduceStatements ((app, pos):rest, lastVal) 
    179179    | null rest = do 
    180         cxt <- asks envContext 
     180        <- asks envContext 
    181181        val <- enterLex (posSyms pos) $ reduceExp exp 
    182182        retVal val 
     
    204204 
    205205evalVar name = do 
    206     env <- ask 
     206    <- ask 
    207207    val <- local (\e -> e{ envLValue = True }) $ do 
    208208        rv <- findVar name 
     
    246246 
    247247-- Reduction for mutables 
    248 reduce env exp@(Val val@(MVal mv)) = do 
     248reduce _ (Val val@(MVal _)) = do 
    249249    lvalue  <- asks envLValue 
    250250    if lvalue 
     
    255255 
    256256-- Reduction for constants 
    257 reduce env exp@(Val v) = do 
     257reduce _ (Val v) = do 
    258258    return v 
    259259 
    260260-- Reduction for variables 
    261 reduce env exp@(Var name) = do 
     261reduce _ exp@(Var name) = do 
    262262    rv <- findVar name 
    263263    case rv of 
     
    266266        _ -> retError ("Undefined variable " ++ name) exp 
    267267 
    268 reduce env (Statements stmts) = do 
     268reduce _ (Statements stmts) = do 
    269269    let (global, local) = partition isGlobalExp stmts 
    270270    reduceStatements (global ++ local, Val VUndef) 
     
    348348        retVal val 
    349349    "::=" -> do -- XXX wrong 
    350         let [Var name, exp] = exps 
    351         val     <- evalExp exp 
     350        let [Var _, exp] = exps 
     351        evalExp exp 
    352352        retVal VUndef -- XXX wrong 
    353353    "=>" -> do 
     
    420420        retVal val 
    421421 
    422 reduce env@Env{ envClasses = cls, envContext = cxt, envLexical = lex, envGlobal = glob } exp@(App name invs args) = do 
     422reduce Env{ envClasses = cls, envContext = cxt, envLexical = lex, envGlobal = glob } exp@(App name invs args) = do 
    423423    syms    <- liftIO $ readIORef glob 
    424424    subSyms <- mapM evalSym 
     
    428428        ] 
    429429    lens    <- mapM argSlurpLen (invs ++ args) 
    430     case findSub (sum lens) subSyms name of 
     430    case findSub (sum lens) subSyms of 
    431431        Just sub    -> applySub subSyms sub invs args 
    432         otherwise   -> retError ("No compatible subroutine found: " ++ name) exp 
     432        Nothing     -> retError ("No compatible subroutine found: " ++ name) exp 
    433433    where