From: Matthijs Kooijman Date: Thu, 25 Jun 2009 12:46:28 +0000 (+0200) Subject: Add mkIndexedName utility function. X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=49191910156ccec4bb69ae24c69182a702691c60;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Add mkIndexedName utility function. --- diff --git a/VHDLTools.hs b/VHDLTools.hs index d6034e7..9462a13 100644 --- a/VHDLTools.hs +++ b/VHDLTools.hs @@ -228,6 +228,14 @@ mkSelectedName :: AST.VHDLName -> AST.VHDLId -> AST.VHDLName mkSelectedName name label = AST.NSelected $ name AST.:.: (AST.SSimple label) +-- Create an indexed name that selects a given element from a vector. +mkIndexedName :: AST.VHDLName -> AST.Expr -> AST.VHDLName +-- Special case for already indexed names. Just add an index +mkIndexedName (AST.NIndexed (AST.IndexedName name indexes)) index = + AST.NIndexed (AST.IndexedName name (indexes++[index])) +-- General case for other names +mkIndexedName name index = AST.NIndexed (AST.IndexedName name [index]) + ----------------------------------------------------------------------------- -- Functions dealing with VHDL types -----------------------------------------------------------------------------