~gcrosswhite/privateer/trunk

« back to all changes in this revision

Viewing changes to src/privateer.hs

  • Committer: Gregory Crosswhite
  • Date: 2009-04-20 08:18:04 UTC
  • Revision ID: gcross@phys.washington.edu-20090420081804-w930alxu97hg323h
Added another test, and made lots of changes to fix the bug it found with the way arrays are handled by adding a flag to let the processing code know when it is dealing with an array type and hence should not add the extra level of pointer indirection that it normally adds.  (The need to do this arises from the fact that C conflates pointers and arrays, so when returning a pointer to the start of the array you need to return the array variable itself and not its address, and likewise when accessing the array you just index it as normal and should *not* dereference it first.  Sigh...)

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
import Data.Sequence
15
15
import qualified Data.Sequence as Sequence
16
16
import qualified Data.Foldable as Foldable
 
17
import qualified Data.Map as Map
17
18
import qualified Data.Set as Set
18
19
import qualified Data.ByteString as BS
19
20
 
28
29
import Text.PrettyPrint
29
30
import Text.Printf
30
31
 
 
32
import Common
31
33
import FileProcessing
32
34
import qualified Privatization
33
35
-- @-node:gcross.20090417185927.5:<< Imports >>
144
146
    -- Do pass 2
145
147
    putStrLn "Pass2..."
146
148
    global_variables <- atomically $ readTVar global_variables_tvar
147
 
    let global_variable_names = Set.fromList [name | (name,_,_) <- Foldable.toList global_variables]
 
149
    let global_variable_names = Map.fromList [
 
150
            (name
 
151
            ,case typ of
 
152
                ExpandedType _ _ ((CArrDeclr _ _ _):_) -> True
 
153
                _ -> False
 
154
            )
 
155
          | (name,typ,_) <- Foldable.toList global_variables]
148
156
    doPass $ pass2 module_name global_variable_names
149
157
    -- Create X_manager.c
150
158
    let manager_c_name = module_name ++ "_manager.c"