Changeset 15710 for src/Pugs/Eval.hs
- Timestamp:
- 03/14/07 16:33:44 (21 months ago)
- Files:
-
- 1 modified
-
src/Pugs/Eval.hs (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/Eval.hs
r15645 r15710 246 246 reduce (Pad scope lexEnv exp) = reducePad scope lexEnv exp 247 247 248 reduce (Sym scope name init exp) = reduceSym scope name init exp248 reduce (Sym scope name flags init rest) = reduceSym scope name flags init rest 249 249 250 250 -- Reduction for no-operations … … 289 289 -- '$Qualified::Var' is not found. Vivify at lvalue context. 290 290 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)) 292 292 | otherwise -> do 293 293 s <- isStrict 294 294 if s then do die "Undeclared variable" var 295 295 else do lv <- asks envLValue 296 if lv then evalExp (Sym SOur var Noop (Var var)) else retEmpty296 if lv then evalExp (Sym SOur var mempty Noop (Var var)) else retEmpty 297 297 298 298 _scalarContext :: Cxt … … 344 344 345 345 reducePad :: 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 346 reducePad scope lex exp = do 352 347 -- 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 356 356 357 357 {- … … 387 387 -} 388 388 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 389 reduceSym :: Scope -> Var -> EntryFlags -> Exp -> Exp -> Eval Val 390 reduceSym scope var flags init rest 395 391 | not (isLexicalVar var) = do 396 392 qn <- toQualified var 397 393 ref <- createRef 398 sym <- genSymScoped scope qn ref 394 sym <- genSymScoped scope qn ref flags 399 395 addGlobalSym sym 400 evalExp exp396 evalExp rest 401 397 | SOur <- scope = do 402 398 ref <- createRef 403 entry <- genPadEntryScoped scope ref 399 entry <- genPadEntryScoped scope ref flags 404 400 qn <- toQualified var 405 401 addGlobalSym (mkPadMutator qn entry ref) 406 enterLex [ mkPadMutator var entry ref ] $ evalExp exp402 enterLex [ mkPadMutator var entry ref ] $ evalExp rest 407 403 | otherwise = do 408 404 ref <- createRef 409 sym <- genSymScoped scope var ref 410 enterLex [ sym ] $ evalExp exp405 sym <- genSymScoped scope var ref flags 406 enterLex [ sym ] $ evalExp rest 411 407 where 412 408 createRef | Noop <- init = newObject (typeOfSigilVar var) … … 488 484 _ -> regenerateContent 489 485 return (var, entry') 490 clonePadEntry x@ EntryConstant{} _ = return x491 clonePadEntry x@ EntryStatic{} f = do486 clonePadEntry x@PEConstant{} _ = return x 487 clonePadEntry x@PEStatic{} f = do 492 488 tvar' <- newTVar =<< f x 493 489 return x{ pe_store = tvar' } 494 clonePadEntry x@ EntryLexical{} f = do490 clonePadEntry x@PELexical{} f = do 495 491 tvar' <- newTVar =<< f x 496 492 fresh' <- newTVar False … … 673 669 _ | isGlobalVar var || v_package var `notElem` [emptyPkg, callerPkg, outerPkg, contextPkg] -> do 674 670 -- '$Qualified::Var' is not found. Vivify at lvalue context. 675 evalExp (Sym SOur var Noop Noop)671 evalExp (Sym SOur var mempty Noop Noop) 676 672 rv' <- findVarRef var 677 673 case rv' of 678 Just EntryConstant{} -> die "Bind to constant variable" var674 Just PEConstant{} -> die "Bind to constant variable" var 679 675 Just entry -> return (entry, ref) 680 676 _ -> die "Bind to undeclared variable" var
