Remove the now obsolete getOwnStates.
[matthijs/master-project/cλash.git] / Flatten.hs
index 11738c70f5803509056662013ee711b6fec93c54..325f742bec2970155ad53093a04354324c7a62a4 100644 (file)
@@ -157,13 +157,18 @@ flattenExpr binds var@(Var id) =
           Left sig_use -> return ([], sig_use)
           Right _ -> error "Higher order functions not supported."
     IdInfo.DataConWorkId datacon -> do
-      lit <- dataConToLiteral datacon
-      let ty = CoreUtils.exprType var
-      sig_id <- genSignalId SigInternal ty
-      -- Add a name hint to the signal
-      addNameHint (Name.getOccString id) sig_id
-      addDef (UncondDef (Right $ Literal lit) sig_id)
-      return ([], Single sig_id)
+      if DataCon.isTupleCon datacon && (null $ DataCon.dataConAllTyVars datacon)
+        then do
+          -- Empty tuple construction
+          return ([], Tuple [])
+        else do
+          lit <- dataConToLiteral datacon
+          let ty = CoreUtils.exprType var
+          sig_id <- genSignalId SigInternal ty
+          -- Add a name hint to the signal
+          addNameHint (Name.getOccString id) sig_id
+          addDef (UncondDef (Right $ Literal lit) sig_id)
+          return ([], Single sig_id)
     otherwise ->
       error $ "Ids other than local vars and dataconstructors not supported: " ++ (showSDoc $ ppr id)
 
@@ -437,28 +442,4 @@ stateList ::
 stateList uses signals =
     Maybe.catMaybes $ Foldable.toList $ zipValueMapsWith filterState signals uses
   
--- | Returns pairs of signals that should be mapped to state in this function.
-getOwnStates ::
-  HsFunction                      -- | The function to look at
-  -> FlatFunction                 -- | The function to look at
-  -> [(StateId, SignalInfo, SignalInfo)]   
-        -- | The state signals. The first is the state number, the second the
-        --   signal to assign the current state to, the last is the signal
-        --   that holds the new state.
-
-getOwnStates hsfunc flatfunc =
-  [(old_num, old_info, new_info) 
-    | (old_num, old_info) <- args_states
-    , (new_num, new_info) <- res_states
-    , old_num == new_num]
-  where
-    sigs = flat_sigs flatfunc
-    -- Translate args and res to lists of (statenum, sigid)
-    args = concat $ zipWith stateList (hsFuncArgs hsfunc) (flat_args flatfunc)
-    res = stateList (hsFuncRes hsfunc) (flat_res flatfunc)
-    -- Replace the second tuple element with the corresponding SignalInfo
-    args_states = map (Arrow.second $ signalInfo sigs) args
-    res_states = map (Arrow.second $ signalInfo sigs) res
-
-    
 -- vim: set ts=8 sw=2 sts=2 expandtab: