From: Matthijs Kooijman Date: Mon, 16 Feb 2009 12:01:43 +0000 (+0100) Subject: Add Entities for builtin functions. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=454503106eef8deb32481d4f67a3d510950118e5;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add Entities for builtin functions. --- 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 = [