From: Christiaan Baaij Date: Tue, 23 Jun 2009 13:55:00 +0000 (+0200) Subject: Added builtin copy function X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=6a5acc4caca3af4f44ae476f457a78a274fe681a;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Added builtin copy function --- diff --git a/Generate.hs b/Generate.hs index 9a3a48c..5c1ca08 100644 --- a/Generate.hs +++ b/Generate.hs @@ -76,6 +76,7 @@ genUnconsVectorFuns elemTM vectorTM = , AST.SubProgBody plusgtSpec [AST.SPVD plusgtVar] [plusgtExpr, plusgtRet] , AST.SubProgBody emptySpec [AST.SPVD emptyVar] [emptyExpr] , AST.SubProgBody singletonSpec [AST.SPVD singletonVar] [singletonRet] + , AST.SubProgBody copySpec [AST.SPVD copyVar] [copyExpr] ] where ixPar = AST.unsafeVHDLBasicId "ix" @@ -233,4 +234,18 @@ genUnconsVectorFuns elemTM vectorTM = [AST.ToRange (AST.PrimLit "0") (AST.PrimLit "0")])) (Just $ AST.Aggregate [AST.ElemAssoc (Just AST.Others) (AST.PrimName $ AST.NSimple aPar)]) - singletonRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) \ No newline at end of file + singletonRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) + copySpec = AST.Function copyId [AST.IfaceVarDec nPar naturalTM, + AST.IfaceVarDec aPar elemTM ] vectorTM + -- variable res : fsvec_x (0 to n-1) := (others => a); + copyVar = + AST.VarDec resId + (AST.SubtypeIn vectorTM + (Just $ AST.ConstraintIndex $ AST.IndexConstraint + [AST.ToRange (AST.PrimLit "0") + ((AST.PrimName (AST.NSimple nPar)) AST.:-: + (AST.PrimLit "1")) ])) + (Just $ AST.Aggregate [AST.ElemAssoc (Just AST.Others) + (AST.PrimName $ AST.NSimple aPar)]) + -- return res + copyExpr = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) \ No newline at end of file diff --git a/GlobalNameTable.hs b/GlobalNameTable.hs index 429b966..45eed89 100644 --- a/GlobalNameTable.hs +++ b/GlobalNameTable.hs @@ -29,6 +29,7 @@ globalNameTable = mkGlobalNameTable , ("map" , (2, Right $ genMapCall ) ) , ("empty" , (0, Left $ genExprFCall emptyId ) ) , ("singleton" , (1, Left $ genExprFCall singletonId ) ) + , ("copy" , (2, Left $ genExprFCall copyId ) ) , ("hwxor" , (2, Left $ genExprOp2 AST.Xor ) ) , ("hwand" , (2, Left $ genExprOp2 AST.And ) ) , ("hwor" , (2, Left $ genExprOp2 AST.Or ) )