~gcrosswhite/privateer/1.0

« back to all changes in this revision

Viewing changes to src/Pass2.hs

  • Committer: Gregory Crosswhite
  • Date: 2009-04-20 23:22:32 UTC
  • Revision ID: gcross@phys.washington.edu-20090420232232-ph1u9fmudz66pylp
 Modified the code to use the stream fusion library, and also to kill lines in the source starting with "#" so that they don't confuse the parser.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 
7
7
-- @<< Imports >>
8
8
-- @+node:gcross.20090205185536.8:<< Imports >>
 
9
import Prelude hiding ((++),map,zip,repeat,concat)
 
10
 
9
11
import Common
10
12
 
11
13
import Language.C
12
14
import Data.Generics
13
15
import Data.Generics.Aliases
14
16
import Data.Generics.Text
15
 
import Data.List
 
17
import Data.List.Stream
16
18
import Data.Map (Map)
17
19
import qualified Data.Map as Map
18
20
 
37
39
            if functionDeclaratorTest declarator
38
40
            then declarator
39
41
            else
40
 
                let (Just (CDeclr (Just ident) indirections Nothing [] nodeInfo),Nothing,Nothing) = declarator
 
42
                let (Just (CDeclr (Just ident) indirections maybe_asmlit attrs nodeInfo),Nothing,Nothing) = declarator
41
43
                    name = identToString ident
42
44
                    new_ident = (internalIdent.accessorMangle) name
43
45
                in case Map.lookup name global_variable_names of
46
48
                        let new_indirections = [CFunDeclr (Right ([],False)) [] internalNode,
47
49
                                                CPtrDeclr [] internalNode
48
50
                                                ] ++ indirections
49
 
                        in (Just (CDeclr (Just new_ident) new_indirections Nothing [] nodeInfo),Nothing,Nothing)
 
51
                        in (Just (CDeclr (Just new_ident) new_indirections maybe_asmlit attrs nodeInfo),Nothing,Nothing)
50
52
                    Just True ->
51
53
                        let new_indirections = [CFunDeclr (Right ([],False)) [] internalNode
52
54
                                                ] ++ indirections
53
 
                        in (Just (CDeclr (Just new_ident) new_indirections Nothing [] nodeInfo),Nothing,Nothing)
 
55
                        in (Just (CDeclr (Just new_ident) new_indirections maybe_asmlit attrs nodeInfo),Nothing,Nothing)
54
56
-- @-node:gcross.20090205185536.10:processDecl
55
57
-- @+node:gcross.20090205185536.12:blockTransformer
56
58
blockTransformer :: (String -> String) -> Map String Bool -> Map String () -> [CBlockItem] -> [CBlockItem]