Changed the C++ implementation of introduceSpec to fall through to the C implementation for all unhandled cases (which will remove duplicate code)
This commit is contained in:
parent
9effe37977
commit
8cd20b9906
|
@ -17,7 +17,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
-}
|
||||
|
||||
-- | Generate C code from the mangled AST.
|
||||
module GenerateC (call, CGen, cgenOps, genComma, genCPasses, generate, generateC, genLeftB, genMeta, genName, genRightB, GenOps(..), seqComma, SubscripterFunction, withIf ) where
|
||||
module GenerateC (call, CGen, cgenOps, cintroduceSpec, genComma, genCPasses, generate, generateC, genLeftB, genMeta, genName, genRightB, GenOps(..), seqComma, SubscripterFunction, withIf ) where
|
||||
|
||||
import Data.Char
|
||||
import Data.Generics
|
||||
|
|
|
@ -847,12 +847,6 @@ cppintroduceSpec ops (A.Specification _ n (A.Proc _ sm fs p))
|
|||
|
||||
-- FIXME: We could just fall through to cintroduceSpec as the last clause...
|
||||
--This clause is unchanged from GenerateC:
|
||||
cppintroduceSpec ops (A.Specification m n (A.Declaration _ t))
|
||||
= do call genDeclaration ops t n
|
||||
case call declareInit ops m t (A.Variable m n) of
|
||||
Just p -> p
|
||||
Nothing -> return ()
|
||||
--This clause is unchanged from GenerateC:
|
||||
cppintroduceSpec ops (A.Specification _ n (A.Is _ am t v))
|
||||
= do let rhs = cppabbrevVariable ops am t v
|
||||
call genDecl ops am t n
|
||||
|
@ -908,9 +902,7 @@ cppintroduceSpec ops (A.Specification _ n (A.IsChannelArray _ t cs))
|
|||
tell ["[",show index,"].access() = "] --Use the .access() function to cast a 0-dimension array into a T& for access
|
||||
call genVariable ops var
|
||||
tell [";"]
|
||||
--This clause is unchanged from GenerateC:
|
||||
cppintroduceSpec _ (A.Specification _ _ (A.DataType _ _)) = return ()
|
||||
--This clause was simplified, because the array handling could be removed:
|
||||
--This clause was simplified, because we don't need separate array sizes in C++:
|
||||
cppintroduceSpec ops (A.Specification _ n (A.RecordType _ b fs))
|
||||
= do tell ["typedef struct {\n"]
|
||||
sequence_ [call genDeclaration ops t n
|
||||
|
@ -971,8 +963,8 @@ cppintroduceSpec ops (A.Specification _ n (A.Retypes m am t v))
|
|||
_ -> return ()
|
||||
tell [");\n"]
|
||||
|
||||
--This clause is unchanged from GenerateC:
|
||||
cppintroduceSpec ops n = call genMissing ops $ "introduceSpec " ++ show n
|
||||
--For all other cases, use the C implementation:
|
||||
cppintroduceSpec ops n = cintroduceSpec ops n
|
||||
|
||||
cppgenSizeSuffix :: GenOps -> String -> CGen ()
|
||||
cppgenSizeSuffix _ dim = tell [".extent(", dim, ")"]
|
||||
|
|
Loading…
Reference in New Issue
Block a user