Changeset 16344

Show
Ignore:
Timestamp:
05/17/07 23:20:11 (18 months ago)
Author:
audreyt
Message:

* Finally, circular loading of TVars.

Files:
8 modified

Legend:

Unmodified
Added
Removed
  • src/DrIFT/YAML.hs

    r16343 r16344  
    253253    fromYAMLElem = (newTVarIO =<<) . fromYAMLElem 
    254254 
     255 
    255256asYAMLanchor :: a -> EmitAs YamlNode -> EmitAs YamlNode 
    256257asYAMLanchor x m = do 
  • src/Pugs/Eval.hs

    r16341 r16344  
    274274reduceVar var@MkVar{ v_sigil = sig, v_twigil = twi, v_name = name, v_package = pkg } 
    275275    | TAttribute <- twi 
    276     = reduceSyn (show sig ++ "{}") [ Syn "{}" [_Var "&self", Val (VStr $ cast name)] ] 
     276    = reduceSyn (show sig ++ "{}") [ Syn "{}" [_Var "$__SELF__", Val (VStr $ cast name)] ] 
    277277    | TPrivate <- twi 
    278     = reduceSyn (show sig ++ "{}") [ Syn "{}" [_Var "&self", Val (VStr $ cast name)] ] 
     278    = reduceSyn (show sig ++ "{}") [ Syn "{}" [_Var "$__SELF__", Val (VStr $ cast name)] ] 
    279279    | otherwise = do 
    280280        v <- findVar var 
     
    14611461    applyMacroResult VUndef         = retEmpty 
    14621462    applyMacroResult _              = fail "Macro did not return an AST, a Str or a Code!" 
    1463     fixSub MkCode{ subType = SubPrim } env = env 
    14641463    fixSub sub env = env 
    14651464        { -- envLexical = subPad sub -- XXX - fake in-pad knowledge? 
  • src/Pugs/Monads.hs

    r16342 r16344  
    232232        runBlocks (filter (rejectKeepUndo rv . subName) . subLeaveBlocks) 
    233233 
    234         when (rv == VControl (ControlLoop LoopLast)) $ 
    235             -- We won't have a chance to run the LAST block 
    236             -- once we exit outside the lexical block, so do it now 
    237             runBlocks subLastBlocks 
    238  
    239         assertBlocks subPostBlocks "POST" 
    240         case rv of 
    241             VControl l@(ControlLeave ftyp depth val) -> do 
    242                 let depth' = if ftyp typ then depth - 1 else depth 
    243                 if depth' < 0 
    244                     then return val 
    245                     else retControl l{ leaveDepth = depth' } 
    246             VControl ControlExit{}  -> retShift rv 
    247             VError{}                -> do 
    248                 -- XXX - Implement CATCH block here 
    249                 retShift rv 
    250             _ -> return rv 
     234    when (rv == VControl (ControlLoop LoopLast)) $ 
     235        -- We won't have a chance to run the LAST block 
     236        -- once we exit outside the lexical block, so do it now 
     237        runBlocks subLastBlocks 
     238 
     239    assertBlocks subPostBlocks "POST" 
     240    case rv of 
     241        VControl l@(ControlLeave ftyp depth val) -> do 
     242            let depth' = if ftyp typ then depth - 1 else depth 
     243            if depth' < 0 
     244                then return val 
     245                else retControl l{ leaveDepth = depth' } 
     246        VControl ControlExit{}  -> retShift rv 
     247        VError{}                -> do 
     248            -- XXX - Implement CATCH block here 
     249            retShift rv 
     250        _ -> return rv 
    251251    where 
    252252    rejectKeepUndo VUndef     = (/= __"KEEP") 
  • src/Pugs/Parser.hs

    r16342 r16344  
    20672067            let methName = ('&':cast (v_name var)) 
    20682068            postApp <- ruleInvocationArguments Nothing methName False 
    2069             return $ Syn (shows (v_sigil var) "{}") [postApp (_Var "&self")] 
     2069            return $ Syn (shows (v_sigil var) "{}") [postApp (_Var "$__SELF__")] 
    20702070        _   -> return exp 
    20712071 
  • src/Pugs/Parser/Util.hs

    r16342 r16344  
    189189    , isWritable    = True 
    190190    , isLazy        = False 
    191     , paramName     = cast "&self" 
     191    , paramName     = cast "$__SELF__" 
    192192    , paramContext  = CxtItem typ 
    193193    , paramDefault  = Noop 
  • src/Pugs/Prim.hs

    r15829 r16344  
    8888    return $ VStr tmp 
    8989op0 "Pugs::Internals::pi" = const $ return $ VNum pi 
    90 op0 "self"    = const $ expToEvalVal (_Var "&self") 
     90op0 "self"    = const $ expToEvalVal (_Var "$__SELF__") 
    9191op0 "say"     = const $ op1 "IO::say" (VHandle stdout) 
    9292op0 "print"   = const $ op1 "IO::print" (VHandle stdout) 
  • src/Pugs/Run.hs

    r16343 r16344  
    277277        -- print "Loading yaml..." 
    278278        --(glob, ast) <- fromYAML yml 
     279        cleanSeen 
    279280        MkCompUnit _ glob ast <- io $ fromYAML yml 
    280281        -- print "Loading done!" 
     282        z   <- stm $ join (findSym (cast "&*__fail") glob) 
     283        -- j   <- showYaml z 
     284        -- print j 
    281285        stm $ modifyTVar (envGlobal env) (`unionPads` glob) 
    282286        runEnv env{ envBody = ast, envDebug = Nothing } 
  • third-party/HsSyck/Data/Yaml/Syck.hsc

    r16343 r16344  
    7171    deriving (Show, Ord, Eq, Enum) 
    7272 
     73maxId :: SYMID 
     74maxId = maxBound 
     75 
    7376nilNode :: YamlNode 
    74 nilNode = MkNode 0 ENil Nothing ASingleton 
     77nilNode = MkNode maxId ENil Nothing ASingleton 
    7578 
    7679{-# INLINE unpackBuf #-} 
     
    8790 
    8891mkNode :: YamlElem -> YamlNode 
    89 mkNode x = MkNode 0 x Nothing ASingleton 
     92mkNode x = MkNode maxId x Nothing ASingleton 
    9093 
    9194mkTagNode :: String -> YamlElem -> YamlNode 
    92 mkTagNode tag e = MkNode 0 e (Just $! packBuf tag) ASingleton 
     95mkTagNode tag e = MkNode maxId e (Just $! packBuf tag) ASingleton 
    9396 
    9497mkTagStrNode :: String -> String -> YamlNode 
     
    185188emitNode freeze e n | ESeq sq <- n_elem n = do 
    186189    withTag n (Ptr "array"##) $ \tag -> 
    187         syck_emit_seq e tag seqInline 
     190--      syck_emit_seq e tag seqInline 
     191        syck_emit_seq e tag seqNone 
    188192    mapM_ (syck_emit_item e) =<< mapM freeze sq 
    189193    syck_emit_end e 
     
    191195emitNode freeze e n | EMap m <- n_elem n = do 
    192196    withTag n (Ptr "map"##) $ \tag -> 
    193         syck_emit_map e tag mapInline 
     197--      syck_emit_map e tag mapInline 
     198        syck_emit_map e tag mapNone 
    194199    flip mapM_ m (\(k,v) -> do 
    195200        syck_emit_item e =<< freeze k 
     
    262267 
    263268    return (fromIntegral symId) 
     269 
     270    return symId 
    264271 
    265272badAnchorHandlerCallback :: BadAnchorTable -> SyckBadAnchorHandler