Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds warnings to the generated files.
A warning message can be inserted between the pragmas and the module, which is used to warn against editing. The default is not to add any text, but this has been overriden in testrun.sh Simple haskell warnings and deprecation texts can be added, this is used in the compatibility modules, the default is on. (Fixes #5)
- Loading branch information
Showing
11 changed files
with
111 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
----------------------------------------- | ||
-- GENERATED MODULE DO NOT EDIT -- | ||
----------------------------------------- | ||
-- Any changes made to this module are -- | ||
-- discarded when generating the files -- | ||
----------------------------------------- |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
----------------------------------------------------------------------------- | ||
-- | ||
-- Module : Code.PostProcessing | ||
-- Copyright : (c) 2013 Lars Corbijn | ||
-- License : BSD-style (see the file /LICENSE) | ||
-- | ||
-- Maintainer : | ||
-- Stability : | ||
-- Portability : | ||
-- | ||
-- | Post processing of generated sources. | ||
-- | ||
----------------------------------------------------------------------------- | ||
module Code.PostProcessing ( | ||
postProcessModule | ||
) where | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
import Main.Monad | ||
import Main.Options | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
postProcessModule :: String -> RawGen String | ||
postProcessModule = addModuleHeader . replaceCallConv "CALLCONV" | ||
|
||
----------------------------------------------------------------------------- | ||
|
||
-- | Replace every occurence of a certain calling convention by the given | ||
-- string. | ||
replaceCallConv | ||
:: String -- The replacing calling convention | ||
-> String -- The source of the module | ||
-> String | ||
replaceCallConv r = go | ||
where | ||
go [] = [] | ||
go ('s':'t':'d':'c':'a':'l':'l':xs) = r ++ go xs | ||
go (x :xs) = x : go xs | ||
|
||
-- | Adds a header to all modules. | ||
addModuleHeader :: String -> RawGen String | ||
addModuleHeader src = do | ||
hdr <- asksOptions moduleHeader | ||
return $ maybe src addHeader hdr | ||
where | ||
addHeader hdr = go src | ||
where go [] = hdr | ||
go ('m':'o':'d':'u':'l':'e':' ':xs) = hdr ++ "module " ++ xs | ||
go (x :xs) = x : go xs | ||
|
||
----------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters