Changeset 15828

Show
Ignore:
Timestamp:
04/04/07 19:51:21 (20 months ago)
Author:
audreyt
Message:

* Snapshot merge of the pad branch into trunk.

Tests mostly passes; YAML compression is turned off for now
which results in slower startups, but otherwise it's functioning
as specced.

However, need another two solid days of work before the entire
separate-compilation model and class/role composers work, for
releng to start and the tree to be labelled as Pugs 6.28.0.

Problem is: I'm probably not getting two solid days of sanity for
work any time soon, so the next commit will revert this merge.
This commit is merely for safeguard so the code lives in somewhere
else than my (dangerously ephemeral) laptop. Sorry.

Files:
1 added
31 modified

Legend:

Unmodified
Added
Removed
  • Makefile.PL

    r15812 r15828  
    621621#    } 
    622622 
     623    my @ghci_flags = qw( -hide-all-packages -package base -package parsec -package template-haskell  -package readline -package unix -package haskell98 -package mtl -package stm -package network -package pugs-HsSyck -package pugs-filepath ); 
     624 
    623625    postamble(fixpaths(<< ".")); 
    624626$config_h : lib/Perl6/Pugs.pm util/config_h.pl 
     
    787789        $ghc @{[ dethread_flags($ghc_flags) ]} $ghc_output -DPUGS_UNDER_GHCI -no-link --make -O0 -fglasgow-exts -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Prereqs.hs @prereqs 
    788790        \@\$(RM_RF) src/Pugs/*/*_stub.* 
    789         $ghc @{[ dethread_flags($ghc_flags) ]} $ghc_output -DPUGS_UNDER_GHCI --interactive -fglasgow-exts $ghci_debugging -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
     791        $ghc @{[ dethread_flags($ghc_flags) ]} @ghci_flags $ghc_output -DPUGS_UNDER_GHCI --interactive -fglasgow-exts $ghci_debugging -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
    790792 
    791793ctags : @prereqs @derived_srcfiles 
    792         echo ":ctags" | $ghc $ghc_flags $ghc_output --interactive -osuf moose -hisuf miise -fglasgow-exts -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
     794        echo ":ctags" | $ghc $ghc_flags @ghci_flags $ghc_output --interactive -osuf moose -hisuf miise -fglasgow-exts -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
    793795         
    794796etags : @prereqs @derived_srcfiles 
    795         echo ":etags" | $ghc $ghc_flags $ghc_output --interactive -osuf moose -hisuf miise -fglasgow-exts -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
     797        echo ":etags" | $ghc $ghc_flags @ghci_flags $ghc_output --interactive -osuf moose -hisuf miise -fglasgow-exts -L. -idist/build -Ldist/build -idist/build/src -Ldist/build/src -isrc src/Main.hs @prereqs 
    796798 
    797799pil$Config{_exe} : $config_h $pcre @srcfiles src/PIL/Native/Bootstrap.hs src/PIL/Native/Syntax.hs 
  • src/DrIFT/RuleYAML.hs

    r15753 r15828  
    3030caseHead _ = text "fromYAML MkNode{n_tag=Just t, n_elem=e} | 't':'a':'g':':':'h':'s':':':tag <- unpackBuf t = case tag of" 
    3131caseTail bodies = nest 4 (text $ "_ -> fail $ \"unhandled tag: \" ++ show t ++ \", expecting \" ++ show " ++ show (map constructor bodies) ++ " ++ \" in node \" ++ show e") 
    32        $+$ text "fromYAML _ = fail \"no tag found\"" 
     32       $+$ (text $ "fromYAML e = fail $ \"no tag found: expecting \" ++ show " ++ show (map constructor bodies) ++ " ++ \" in node \" ++ show e") 
    3333 
    3434makeFromYAML, makeAsYAML :: AlwaysPositional -> IFunction 
  • src/DrIFT/YAML.hs

    r15777 r15828  
    99import Control.Exception 
    1010import Control.Concurrent.STM 
    11 import Foreign.StablePtr 
    1211import Foreign.Ptr 
    1312import Control.Monad.Reader 
    1413import GHC.PArr 
     14import System.IO.Unsafe 
    1515import Data.IORef 
    16 import Foreign.C.Types 
    1716import Data.Bits 
    1817import Data.List        ( foldl' ) 
    1918import Data.Int         ( Int32, Int64 ) 
    20 import Pugs.Internals (encodeUTF8, decodeUTF8) 
     19import Pugs.Internals (encodeUTF8, decodeUTF8, addressOf, safeMode) 
    2120import Data.HashTable (HashTable) 
    2221import qualified UTF8 as Buf 
    2322import qualified Data.ByteString as Bytes 
    24 import qualified Data.IntMap as IntMap 
     23import qualified Data.IntSet as IntSet 
    2524import qualified Data.HashTable as Hash 
    2625 
     
    3029type YAMLKey = String 
    3130type YAMLVal = YamlNode 
    32 type SeenCache = IORef (IntMap.IntMap (Ptr ())) 
     31type SeenCache = IORef IntSet.IntSet 
    3332 
    3433toYamlNode :: YAML a => a -> IO YamlNode 
    3534toYamlNode x = do 
    36     cache   <- newIORef IntMap.empty  
     35    cache   <- newIORef IntSet.empty  
    3736    runReaderT (asYAML x) cache 
    3837 
     
    4342 
    4443showYamlCompressed :: YAML a => a -> IO String 
    45 showYamlCompressed x = do 
     44showYamlCompressed x = if safeMode then showYaml x else do 
    4645    node    <- toYamlNode x 
    4746    node'   <- compressYamlNode node 
     
    8988        return (k', v') 
    9089 
    91 fromYAMLseq :: YAML a => YamlNode -> IO [a] 
     90fromYAMLseq :: forall a. YAML a => YamlNode -> IO [a] 
    9291fromYAMLseq MkNode{n_elem=ESeq m} = mapM fromYAML m 
    93 fromYAMLseq e = fail $ "no parse: " ++ show e 
    94  
    95 fromYAMLmap :: YAML a => YamlNode -> IO [(String, a)] 
     92fromYAMLseq e = fail $ "no parse: " ++ show e ++ ", expecting seq of " ++ show (typeOf (undefined :: a)) 
     93 
     94fromYAMLmap :: forall a. YAML a => YamlNode -> IO [(String, a)] 
    9695fromYAMLmap MkNode{n_elem=EMap m} = mapM fromYAMLpair m 
    9796    where 
     
    10099        return (unpackBuf k, v') 
    101100    fromYAMLpair e = fail $ "no parse: " ++ show e 
    102 fromYAMLmap e = fail $ "no parse: " ++ show e 
    103  
    104 fromYAMLmapBuf :: YAML a => YamlNode -> IO [(Buf.ByteString, a)] 
     101fromYAMLmap e = fail $ "no parse: " ++ show e ++ ", expecting map of " ++ show (typeOf (undefined :: a)) 
     102 
     103fromYAMLmapBuf :: forall a. YAML a => YamlNode -> IO [(Buf.ByteString, a)] 
    105104fromYAMLmapBuf MkNode{n_elem=EMap m} = mapM fromYAMLpair m 
    106105    where 
     
    108107        v' <- fromYAML v 
    109108        return (k, v') 
    110     fromYAMLpair e = fail $ "no parse: " ++ show e 
    111 fromYAMLmapBuf e = fail $ "no parse: " ++ show e 
     109    fromYAMLpair e = fail $ "no parse: " ++ show e ++ ", expecting pair of " ++ show (typeOf (undefined :: a)) 
     110fromYAMLmapBuf e = fail $ "no parse: " ++ show e ++ ", expecting mapping of " ++ show (typeOf (undefined :: a)) 
    112111 
    113112asYAMLcls :: YAMLClass -> EmitAs YamlNode 
     
    194193 
    195194instance (YAML a) => YAML [a] where 
    196     asYAML xs = asYAMLanchor xs $ do 
     195    asYAML xs = do -- asYAMLanchor xs $ do 
    197196        xs' <- mapM asYAML xs 
    198197        (return . mkNode . ESeq) xs' 
     198    fromYAML MkNode{n_elem=(ESeq s)} = mapM fromYAML s 
     199    fromYAML n = fail $ "no parse: " ++ show n ++ ", expecting list of " ++ show (typeOf (undefined :: a)) 
    199200    fromYAMLElem (ESeq s) = mapM fromYAML s 
    200     fromYAMLElem e = fail $ "no parse: " ++ show e 
     201    fromYAMLElem e = fail $ "no parse: " ++ show e ++ ", expecting list of " ++ show (typeOf (undefined :: a)) 
    201202 
    202203instance (YAML a) => YAML [:a:] where 
    203     asYAML xs = asYAMLanchor xs $ do 
     204    asYAML xs = do -- asYAMLanchor xs $ do 
    204205        xs' <- mapM asYAML (fromP xs) 
    205206        (return . mkNode . ESeq) xs' 
    206207    fromYAMLElem (ESeq s) = fmap toP (mapM fromYAML s) 
    207     fromYAMLElem e = fail $ "no parse: " ++ show e 
     208    fromYAMLElem e = fail $ "no parse: " ++ show e ++ ", expecting array of " ++ show (typeOf (undefined :: a)) 
    208209 
    209210instance (YAML a, YAML b) => YAML (a, b) where 
     
    216217        y' <- fromYAML y 
    217218        return (x', y') 
    218     fromYAMLElem e = fail $ "no parse: " ++ show e 
     219    fromYAMLElem e = fail $ "no parse: " ++ show e ++ ", expecting " ++ show (typeOf (undefined :: (a, b))) 
    219220 
    220221instance (YAML a, YAML b, YAML c) => YAML (a, b, c) where 
     
    229230        z' <- fromYAML z 
    230231        return (x', y', z') 
    231     fromYAMLElem e = fail $ "no parse: " ++ show e 
     232    fromYAMLElem e = fail $ "no parse: " ++ show e ++ ", expecting " ++ show (typeOf (undefined :: (a, b, c))) 
     233 
     234{-# NOINLINE seen #-} 
     235seen :: Hash.HashTable SYMID Any 
     236seen = unsafePerformIO (Hash.new (==) fromIntegral) 
     237 
     238cleanSeen :: IO () 
     239cleanSeen = do 
     240    kvs <- Hash.toList seen 
     241    mapM_ (Hash.delete seen . fst) kvs 
    232242 
    233243instance (Typeable a, YAML a) => YAML (TVar a) where 
    234     asYAML = asYAMLwith (lift . atomically . readTVar) 
    235     fromYAML = (newTVarIO =<<) . fromYAML 
    236     fromYAMLElem = (newTVarIO =<<) . fromYAMLElem 
     244    asYAML x = asYAMLanchor x $ do 
     245        asYAMLseq "TVar" . (:[]) $ do 
     246            content <- (lift . atomically . readTVar) x 
     247            asYAML content 
     248    fromYAML MkNode{n_id=nid, n_elem=(ESeq [aa])} = do 
     249        -- If this node is seen, then don't bother -- just read from it. 
     250        rv  <- Hash.lookup seen nid 
     251        case rv of 
     252            Just x  -> do 
     253                -- print ("hit", nid) 
     254                return (unsafeCoerce# x) 
     255            _       -> do 
     256                -- print ("stored", nid) 
     257                tv  <- newTVarIO (error $ "value of TV demanded before cycle completes: " ++ show (typeOf (undefined :: a))) 
     258                Hash.insert seen nid (unsafeCoerce# tv) 
     259                j   <- fromYAML aa 
     260                atomically (writeTVar tv j) 
     261                return tv 
     262    fromYAML node = do 
     263        fail $ "Want (TVar " ++ show node ++ "|" ++ show (typeOf (undefined :: a)) ++ "), got moose: " ++ show node 
     264 
    237265 
    238266asYAMLanchor :: a -> EmitAs YamlNode -> EmitAs YamlNode 
    239 asYAMLanchor _ m = m 
    240 {-do 
     267asYAMLanchor x m = do 
    241268    cache   <- ask 
    242269    seen    <- liftIO $ readIORef cache 
    243     ref     <- liftIO $ fmap castStablePtrToPtr (newStablePtr x) 
    244     let ptr = ref `minusPtr` nullPtr 
    245     if IntMap.member ptr seen 
     270    let ptr = 1000 + fromEnum (addressOf x) 
     271    if IntSet.member ptr seen 
    246272        then return nilNode{ n_anchor = AReference ptr }  
    247273        else do 
    248             liftIO $ modifyIORef cache (IntMap.insert ptr ref) 
     274            liftIO $ modifyIORef cache (IntSet.insert ptr) 
    249275            rv  <- m 
    250276            return rv{ n_anchor = AAnchor ptr } 
    251 -} 
    252277 
    253278asYAMLwith :: (YAML a, YAML b) => (a -> EmitAs b) -> a -> EmitAs YamlNode 
     
    286311 
    287312eqNode :: YamlNode -> YamlNode -> Bool 
    288 eqNode x y = (n_tag x == n_tag y) && eqElem (n_elem x) (n_elem y) 
     313eqNode MkNode{ n_id = x } MkNode{ n_id = y } | x > 0, x == y = True 
     314eqNode x@MkNode{ n_anchor = ASingleton } y@MkNode{ n_anchor = ASingleton } = (n_tag x == n_tag y) && eqElem (n_elem x) (n_elem y) 
     315eqNode _ _ = False 
    289316 
    290317eqElem :: YamlElem -> YamlElem -> Bool 
     
    324351 
    325352markNode :: (?seenHash :: SeenHash, ?duplHash :: DuplHash) => YamlNode -> IO YamlNode 
    326 markNode node = do 
     353markNode node@MkNode{ n_anchor = AReference r } = {-# SCC "ref" #-} do 
     354    -- All we need to do is to write this into duplHash. 
     355    let symid   = fromIntegral r 
     356        node'   = node{ n_anchor = ASingleton, n_id = symid } 
     357    rv  <- Hash.lookup ?seenHash symid 
     358    case rv of 
     359        Just (Just prevNode)    -> return prevNode 
     360        _                       -> do 
     361            Hash.insert ?seenHash symid Nothing 
     362            return node' 
     363markNode node@MkNode{ n_anchor = AAnchor r } = {-# SCC "anc" #-} do 
     364    -- All we need to do is to write this into duplHash. 
     365    -- XXX - But maybe also descend deeper? 
     366    (_, elem')    <- markElem (n_elem node) 
     367    let symid   = fromIntegral r 
     368        node'   = node{ n_anchor = ASingleton, n_id = symid, n_elem = elem' } 
     369    Hash.insert ?seenHash symid (Just node') 
     370    Hash.insert ?duplHash node' 0 
     371    return node' 
     372markNode node = {-# SCC "reg" #-} do 
    327373    (symid32, elem')    <- markElem (n_elem node) 
    328374    let node' = node{ n_id = symid } 
     
    331377    rv  <- Hash.lookup ?seenHash symid 
    332378    case rv of 
    333         Just (Just prevNode)   -> do 
    334             Hash.update ?duplHash node' 0 
    335             Hash.update ?duplHash prevNode 0 
     379        Just (Just _)   -> {-# SCC "reg1" #-} do 
     380            Hash.insert ?duplHash node' 0 
     381--          Hash.update ?duplHash prevNode 0 
    336382            Hash.update ?seenHash symid Nothing 
    337         Just _  -> Hash.update ?duplHash node' 0 
    338         _       -> Hash.update ?seenHash symid (Just node') 
     383            return () 
     384        Just _  -> return () -- {-# SCC "reg2" #-} Hash.update ?duplHash node' 0 
     385        _       -> {-# SCC "reg3" #-} do 
     386            Hash.insert ?seenHash symid (Just undefined) 
     387            return () 
    339388    return node'{ n_elem = elem' } 
    340389 
    341390markElem :: (?seenHash :: SeenHash, ?duplHash :: DuplHash) => YamlElem -> IO (Int32, YamlElem) 
    342 markElem ENil           = return (0, ENil) 
     391markElem ENil           = return (10000, ENil) 
    343392markElem n@(EStr buf)   = return (Buf.hash buf, n) 
    344393markElem (ESeq ns)      = do 
     
    346395    return (hashIDs (map n_id ns'), ESeq ns') 
    347396markElem (EMap ps)      = do 
    348     (symid, ps') <- foldM markPair (0, []) ps 
     397    (symid, ps') <- foldM markPair (20000, []) ps 
    349398    return (symid, EMap ps') 
    350399    where 
     
    355404 
    356405hashIDs :: [SYMID] -> Int32 
    357 hashIDs = foldl' iterIDs 0 
     406hashIDs = foldl' iterIDs 30000 
    358407 
    359408iterIDs :: Int32 -> SYMID -> Int32 
  • src/Pugs.hs

    r15777 r15828  
    369369    makeDumpEnv (Stmts x exp)   = Stmts x   $ makeDumpEnv exp 
    370370    makeDumpEnv (Ann ann exp)   = Ann ann   $ makeDumpEnv exp 
    371     makeDumpEnv (Pad x y exp)   = Pad x y   $ makeDumpEnv exp 
     371--  makeDumpEnv (Pad x y exp)   = Pad x y   $ makeDumpEnv exp 
    372372    makeDumpEnv (Sym x y z w exp) = Sym x y z w $ makeDumpEnv exp 
    373373    makeDumpEnv exp             = Stmts (Ann (Cxt cxtItemAny) exp) (Syn "continuation" []) 
  • src/Pugs/AST.hs

    r15777 r15828  
    1616    genSym, genMultiSym, genSymScoped, genPadEntryScoped, mkPadMutator, 
    1717    strRangeInf, strRange, strInc, 
    18     mergeStmts, isEmptyParams, 
     18    mergeStmts, isEmptyParams, isCompileTime, 
    1919    newPackage, newType, newMetaType, typeMacro, isScalarLValue, 
    2020    filterPrim, filterUserDefinedPad, typeOfParam, listVal, isImmediateMatchContext, 
     
    168168    | otherwise = stm $ do 
    169169        tvar    <- newTVar ref 
    170         fresh   <- newTVar True 
    171         return (PELexical typ ref flags tvar fresh) 
     170        return (PELexical typ ref flags tvar) 
    172171    where 
    173172    typ = refType ref 
     
    231230    Ann Parens _    -> False 
    232231    Ann _ exp       -> isScalarLValue exp 
    233     Pad _ _ exp     -> isScalarLValue exp 
    234232    Sym _ _ _ _ exp -> isScalarLValue exp 
    235233    Var var | SScalar <- v_sigil var -> True 
     
    301299mergeStmts Noop y@(Stmts _ _) = y 
    302300mergeStmts (Sym scope name flag init x) y = Sym scope name flag init (mergeStmts x y) 
    303 mergeStmts (Pad scope lex x) y = Pad scope lex (mergeStmts x y) 
    304301mergeStmts (Syn "package" [kind, pkg@(Val (VStr _))]) y = 
    305302    Syn "namespace" [kind, pkg, y] 
     
    378375    { isMulti       = True 
    379376    , subName       = cast name 
    380     , subEnv        = Nothing 
     377    , subOuterPads  = [] 
     378    , subInnerPad   = emptyPad 
     379    , subLexical    = emptyPad 
     380    , subStarted    = Nothing 
     381    , subPackage    = emptyPkg 
    381382    , subType       = SubMacro 
    382383    , subAssoc      = ANil 
     
    491492    readCodesFromRef (MkRef (ICode (code :: VCode))) 
    492493 
     494isCompileTime :: Env -> Bool 
     495isCompileTime = isJust . envCompPad 
     496 
  • src/Pugs/AST/Internals.hs

    r15777 r15828  
    1111    SubAssoc(..), TraitBlocks(..), emptyTraitBlocks, 
    1212 
    13     Pad(..), PadEntry(..), EntryFlags(..), PadMutator, -- uses Var, TVar, VRef 
     13    MPad, LexPad(..), LexPads, Pad(..), PadEntry(..), EntryFlags(..), PadMutator, -- uses Var, TVar, VRef 
    1414    Param(..), -- uses Cxt, Exp 
    1515    Params, -- uses Param 
     
    1717    SlurpLimit, -- VInt, Exp 
    1818     
     19    emptyPad, 
     20 
    1921    VRef(..), -- uses IVar 
    2022    VOpaque(..), -- uses Value 
     
    10231025    mappend x    _ = x 
    10241026 
     1027type MPad = TVar Pad 
     1028 
    10251029-- | Represents a sub, method, closure etc. -- basically anything callable. 
    10261030data VCode = MkCode 
    1027     { isMulti           :: !Bool        -- ^ Is this a multi sub\/method? 
    1028     , subName           :: !ByteString  -- ^ Name of the closure 
    1029     , subType           :: !SubType     -- ^ Type of the closure 
    1030     , subEnv            :: !(Maybe Env) -- ^ Lexical pad for sub\/method 
    1031     , subAssoc          :: !SubAssoc    -- ^ Associativity 
    1032     , subParams         :: !Params      -- ^ Parameters list 
    1033     , subBindings       :: !Bindings    -- ^ Currently assumed bindings 
    1034     , subSlurpLimit     :: !SlurpLimit  -- ^ Max. number of slurpy arguments 
    1035     , subReturns        :: !Type        -- ^ Return type 
    1036     , subLValue         :: !Bool        -- ^ Is this a lvalue sub? 
    1037     , subBody           :: !Exp         -- ^ Body of the closure 
     1031    { isMulti           :: !Bool                  -- ^ Is this a multi sub\/method? 
     1032    , subName           :: !ByteString            -- ^ Name of the closure 
     1033    , subType           :: !SubType               -- ^ Type of the closure 
     1034    , subOuterPads      :: !LexPads               -- ^ Lexical pads for this scope 
     1035    , subInnerPad       :: !Pad                   -- ^ Inner lexical pad (immutable) 
     1036    , subLexical        :: !Pad                   -- ^ Cached merged pads 
     1037    , subPackage        :: !Pkg                   -- ^ Package of the subroutine 
     1038    , subAssoc          :: !SubAssoc              -- ^ Associativity 
     1039    , subParams         :: !Params                -- ^ Parameters list 
     1040    , subBindings       :: !Bindings              -- ^ Currently assumed bindings 
     1041    , subSlurpLimit     :: !SlurpLimit            -- ^ Max. number of slurpy arguments 
     1042    , subReturns        :: !Type                  -- ^ Return type 
     1043    , subLValue         :: !Bool                  -- ^ Is this a lvalue sub? 
     1044    , subBody           :: !Exp                   -- ^ Body of the closure 
    10381045    , subCont           :: !(Maybe (TVar VThunk)) -- ^ Coroutine re-entry point 
     1046    , subStarted        :: !(Maybe (TVar Bool))   -- ^ Whether START was run 
    10391047    , subTraitBlocks    :: !TraitBlocks 
    10401048    } 
     
    10661074mkPrim :: VCode 
    10671075mkPrim = MkCode 
    1068     { isMulti = True 
    1069     , subName = cast "&" 
    1070     , subType = SubPrim 
    1071     , subEnv = Nothing 
    1072     , subAssoc = ANil 
    1073     , subParams = [] 
    1074     , subBindings = [] 
    1075     , subSlurpLimit = [] 
    1076     , subReturns = anyType 
    1077     , subBody = emptyExp 
    1078     , subLValue = False 
    1079     , subCont = Nothing 
     1076    { isMulti        = True 
     1077    , subName        = cast "&" 
     1078    , subType        = SubPrim 
     1079    , subOuterPads   = [] 
     1080    , subInnerPad    = emptyPad 
     1081    , subLexical     = emptyPad 
     1082    , subPackage     = emptyPkg 
     1083    , subAssoc       = ANil 
     1084    , subParams      = [] 
     1085    , subBindings    = [] 
     1086    , subSlurpLimit  = [] 
     1087    , subReturns     = anyType 
     1088    , subBody        = emptyExp 
     1089    , subLValue      = False 
     1090    , subCont        = Nothing 
     1091    , subStarted     = Nothing 
    10801092    , subTraitBlocks = emptyTraitBlocks 
    10811093    } 
     
    10831095mkSub :: VCode 
    10841096mkSub = MkCode 
    1085     { isMulti = False 
    1086     , subName = cast "&" 
    1087     , subType = SubBlock 
    1088     , subEnv = Nothing 
    1089     , subAssoc = ANil 
    1090     , subParams = [] 
    1091     , subBindings = [] 
    1092     , subSlurpLimit = [] 
    1093     , subReturns = anyType 
    1094     , subBody = emptyExp 
    1095     , subLValue = False 
    1096     , subCont = Nothing 
     1097    { isMulti        = False 
     1098    , subName        = cast "&" 
     1099    , subType        = SubBlock 
     1100    , subOuterPads   = [] 
     1101    , subInnerPad    = emptyPad 
     1102    , subLexical     = emptyPad 
     1103    , subPackage     = emptyPkg 
     1104    , subAssoc       = ANil 
     1105    , subParams      = [] 
     1106    , subBindings    = [] 
     1107    , subSlurpLimit  = [] 
     1108    , subReturns     = anyType 
     1109    , subBody        = emptyExp 
     1110    , subLValue      = False 
     1111    , subCont        = Nothing 
     1112    , subStarted     = Nothing 
    10971113    , subTraitBlocks = emptyTraitBlocks 
    10981114    } 
     
    11001116mkCode :: VCode 
    11011117mkCode = MkCode 
    1102     { isMulti = False 
    1103     , subName = cast "&" 
    1104     , subType = SubBlock 
    1105     , subEnv = Nothing 
    1106     , subAssoc = ANil 
    1107     , subParams = [] 
    1108     , subBindings = [] 
    1109     , subSlurpLimit = [] 
    1110     , subReturns = anyType 
    1111     , subBody = emptyExp 
    1112     , subLValue = False 
    1113     , subCont = Nothing 
     1118    { isMulti        = False 
     1119    , subName        = cast "&" 
     1120    , subType        = SubBlock 
     1121    , subOuterPads   = [] 
     1122    , subInnerPad    = emptyPad 
     1123    , subLexical     = emptyPad 
     1124    , subPackage     = emptyPkg 
     1125    , subAssoc       = ANil 
     1126    , subParams      = [] 
     1127    , subBindings    = [] 
     1128    , subSlurpLimit  = [] 
     1129    , subReturns     = anyType 
     1130    , subBody        = emptyExp 
     1131    , subLValue      = False 
     1132    , subCont        = Nothing 
     1133    , subStarted     = Nothing 
    11141134    , subTraitBlocks = emptyTraitBlocks 
    11151135    }  
     
    11521172                                        --     be represented by 'App'. 
    11531173    | Ann !Ann !Exp                     -- ^ Annotation (see @Ann@) 
    1154     | Pad !Scope !Pad !Exp              -- ^ Lexical pad 
     1174--  | Pad !Scope !Pad !Exp              -- ^ Lexical pad 
    11551175    | Sym !Scope !Var !EntryFlags !Exp !Exp -- ^ Symbol declaration 
    11561176    | Stmts !Exp !Exp                   -- ^ Multiple statements 
     
    11871207transformExp f (Syn t es) = f =<< liftM (Syn t) (mapM (transformExp f) es) 
    11881208transformExp f (Ann a e) = f =<< liftM (Ann a) (transformExp f e) 
    1189 transformExp f (Pad s p e) = f =<< liftM (Pad s p) (transformExp f e) 
     1209-- transformExp f (Pad s p e) = f =<< liftM (Pad s p) (transformExp f e) 
    11901210transformExp f (Sym s v c i e) = f =<< liftM (Sym s v c i) (transformExp f e) 
    11911211transformExp f (Stmts e1 e2) = do  
     
    12131233instance Unwrap Exp where 
    12141234    unwrap (Ann _ exp)      = unwrap exp 
    1215     unwrap (Pad _ _ exp)    = unwrap exp 
     1235    -- unwrap (Pad _ _ exp)    = unwrap exp 
    12161236    unwrap (Sym _ _ _ _ exp)= unwrap exp 
    12171237    unwrap x                = x 
     
    12661286    where 
    12671287    (ex', vs') = extractPlaceholderVars ex vs 
    1268 extractPlaceholderVars (Pad scope pad ex) vs = ((Pad scope pad ex'), vs') 
    1269     where 
    1270     (ex', vs') = extractPlaceholderVars ex vs 
     1288-- extractPlaceholderVars (Pad scope pad ex) vs = ((Pad scope pad ex'), vs') 
     1289--     where 
     1290--     (ex', vs') = extractPlaceholderVars ex vs 
    12711291extractPlaceholderVars (Sym scope var flags ini ex) vs = ((Sym scope var flags ini ex'), vs') 
    12721292    where 
     
    13011321defaultArrayParam   = buildParam "" "*" "@_" (Val VUndef) 
    13021322defaultHashParam    = buildParam "" "*" "%_" (Val VUndef) 
    1303 defaultScalarParam  = buildParam "" "?" "$_" (Var $ cast "$_") 
     1323defaultScalarParam  = buildParam "" "?" "$_" (Var $ cast "$OUTER::_") 
    13041324 
    13051325type DebugInfo = Maybe (TVar (Map ID String)) 
     1326 
     1327type LexPads = [LexPad] 
     1328data LexPad 
     1329    = PRuntime      { pr_pad :: !Pad } 
     1330    | PCompiling    { pc_pad :: !MPad } 
     1331    deriving (Show, Eq, Ord, Typeable) {-!derive: YAML_Pos!-} 
    13061332 
    13071333{-| 
     
    13131339-} 
    13141340data Env = MkEnv 
    1315     { envContext :: !Cxt                 -- ^ Current context 
    1316                                          -- ('CxtVoid', 'CxtItem' or 'CxtSlurpy') 
    1317     , envLValue  :: !Bool                -- ^ Are we in an LValue context? 
    1318     , envLexical :: !Pad                 -- ^ Lexical pad for variable lookup 
    1319     , envImplicit:: !(Map Var ())        -- ^ Set of implicit variables 
    1320     , envGlobal  :: !(TVar Pad)          -- ^ Global pad for variable lookup 
    1321     , envPackage :: !Pkg                 -- ^ Current package 
    1322     , envEval    :: !(Exp -> Eval Val)   -- ^ Active evaluator 
    1323     , envCaller  :: !(Maybe Env)         -- ^ Caller's "env" pad 
    1324     , envOuter   :: !(Maybe Env)         -- ^ Outer block's env 
    1325     , envBody    :: !Exp                 -- ^ Current AST expression 
    1326     , envFrames  :: !(Set Frame)         -- ^ Recursion depth