X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;f=Translator.hs;h=cccac4c08047178ec368a5a992d3c0eac48f4a0d;hb=f8f2ec1ccc1821b4b0f0f80d5a28e49b413a6e19;hp=37a812b2bceca493cf1e95824c6b7ea4b4484d4e;hpb=5f9b7f3e0c999e765f75b0c48b0f675d99842cea;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git diff --git a/Translator.hs b/Translator.hs index 37a812b..cccac4c 100644 --- a/Translator.hs +++ b/Translator.hs @@ -37,6 +37,7 @@ import HsValueMap import Pretty import Flatten import FlattenTypes +import VHDLTypes import qualified VHDL main = @@ -211,13 +212,20 @@ type PortMap = HsValueMap (String, AST.TypeMark) -- | A consise representation of a builtin function data BuiltIn = BuiltIn String [PortMap] PortMap +-- | Map a port specification of a builtin function to a VHDL Signal to put in +-- a VHDLSignalMap +toVHDLSignalMap :: HsValueMap (String, AST.TypeMark) -> VHDLSignalMap +toVHDLSignalMap = fmap (\(name, ty) -> (VHDL.mkVHDLId name, ty)) + -- | Translate a concise representation of a builtin function to something -- that can be put into FuncMap directly. addBuiltIn :: BuiltIn -> VHDLState () addBuiltIn (BuiltIn name args res) = do addFunc hsfunc + setEntity hsfunc entity where hsfunc = HsFunction name (map useAsPort args) (useAsPort res) + entity = Entity (VHDL.mkVHDLId name) (map toVHDLSignalMap args) (toVHDLSignalMap res) Nothing builtin_funcs = [