Changeset 15710 for src/Pugs/Eval.hs

Show
Ignore:
Timestamp:
03/14/07 16:33:44 (21 months ago)
Author:
audreyt
Message:

* Chase "is context" pad structure changes in other modules.

This concludes the contextual-declarations batch.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/Eval.hs

    r15645 r15710  
    246246reduce (Pad scope lexEnv exp) = reducePad scope lexEnv exp 
    247247 
    248 reduce (Sym scope name init exp) = reduceSym scope name init exp 
     248reduce (Sym scope name flags init rest) = reduceSym scope name flags init rest 
    249249 
    250250-- Reduction for no-operations 
     
    289289                    -- '$Qualified::Var' is not found.  Vivify at lvalue context. 
    290290                    lv <- asks envLValue 
    291                     if not lv then retEmpty else evalExp (Sym SOur var Noop (Var var)) 
     291                    if not lv then retEmpty else evalExp (Sym SOur var mempty Noop (Var var)) 
    292292                | otherwise -> do 
    293293                    s <- isStrict 
    294294                    if s then do die "Undeclared variable" var 
    295295                         else do lv <- asks envLValue 
    296                                  if lv then evalExp (Sym SOur var Noop (Var var)) else retEmpty 
     296                                 if lv then evalExp (Sym SOur var mempty Noop (Var var)) else retEmpty 
    297297 
    298298_scalarContext :: Cxt 
     
    344344 
    345345reducePad :: Scope -> Pad -> Exp -> Eval Val 
    346 {- 
    347 reducePad SEnv lex@(MkPad lex') exp = do 
    348     local (\e -> e{ envImplicit = Map.map (const ()) lex' `Map.union` envImplicit e }) $ 
    349         reducePad SMy lex exp 
    350 -} 
    351 reducePad SMy lex exp = do 
     346reducePad scope lex exp = do 
    352347    -- heuristics: if we are repeating ourselves, generate a new TVar. 
    353     lex' <- refreshPad lex 
    354     local (\e -> e{ envLexical = lex' `unionPads` envLexical e }) $ do 
    355         evalExp exp 
     348    lex' <- case scope of 
     349        SMy -> refreshPad lex 
     350        _   -> return lex 
     351    let implicits = Map.map (const ()) . Map.filter (ef_isContext . pe_flags) $ padEntries lex' 
     352    local (\e -> e 
     353        { envLexical    = lex' `unionPads` envLexical e 
     354        , envImplicit   = implicits `Map.union` envImplicit e 
     355        }) $ evalExp exp 
    356356 
    357357{- 
     
    387387-} 
    388388 
    389 reducePad _ lex exp = do 
    390     local (\e -> e{ envLexical = lex `unionPads` envLexical e }) $ do 
    391         evalExp exp 
    392          
    393 reduceSym :: Scope -> Var -> Exp -> Exp -> Eval Val 
    394 reduceSym scope var init exp 
     389reduceSym :: Scope -> Var -> EntryFlags -> Exp -> Exp -> Eval Val 
     390reduceSym scope var flags init rest 
    395391    | not (isLexicalVar var) = do 
    396392        qn  <- toQualified var 
    397393        ref <- createRef 
    398         sym <- genSymScoped scope qn ref 
     394        sym <- genSymScoped scope qn ref flags 
    399395        addGlobalSym sym 
    400         evalExp exp 
     396        evalExp rest 
    401397    | SOur <- scope = do 
    402398        ref     <- createRef 
    403         entry   <- genPadEntryScoped scope ref 
     399        entry   <- genPadEntryScoped scope ref flags 
    404400        qn      <- toQualified var 
    405401        addGlobalSym (mkPadMutator qn entry ref) 
    406         enterLex [ mkPadMutator var entry ref ] $ evalExp exp 
     402        enterLex [ mkPadMutator var entry ref ] $ evalExp rest 
    407403    | otherwise = do 
    408404        ref <- createRef 
    409         sym <- genSymScoped scope var ref 
    410         enterLex [ sym ] $ evalExp exp 
     405        sym <- genSymScoped scope var ref flags 
     406        enterLex [ sym ] $ evalExp rest 
    411407    where 
    412408    createRef | Noop <- init = newObject (typeOfSigilVar var) 
     
    488484                _           -> regenerateContent 
    489485            return (var, entry') 
    490     clonePadEntry x@EntryConstant{} _ = return x 
    491     clonePadEntry x@EntryStatic{} f = do 
     486    clonePadEntry x@PEConstant{} _ = return x 
     487    clonePadEntry x@PEStatic{} f = do 
    492488        tvar'   <- newTVar =<< f x 
    493489        return x{ pe_store = tvar' } 
    494     clonePadEntry x@EntryLexical{} f = do 
     490    clonePadEntry x@PELexical{} f = do 
    495491        tvar'   <- newTVar =<< f x 
    496492        fresh'  <- newTVar False 
     
    673669                _ | isGlobalVar var || v_package var `notElem` [emptyPkg, callerPkg, outerPkg, contextPkg] -> do 
    674670                    -- '$Qualified::Var' is not found.  Vivify at lvalue context. 
    675                     evalExp (Sym SOur var Noop Noop) 
     671                    evalExp (Sym SOur var mempty Noop Noop) 
    676672                    rv' <- findVarRef var 
    677673                    case rv' of 
    678                         Just EntryConstant{}    -> die "Bind to constant variable" var 
     674                        Just PEConstant{}    -> die "Bind to constant variable" var 
    679675                        Just entry              -> return (entry, ref) 
    680676                        _                       -> die "Bind to undeclared variable" var