From: Christiaan Baaij Date: Tue, 23 Jun 2009 11:45:22 +0000 (+0200) Subject: Added builtin function 'empty' X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=ff02403f76778ebab3e61a6d7a62827c6fb0a3de;p=matthijs%2Fmaster-project%2Fc%CE%BBash.git Added builtin function 'empty' --- diff --git a/Generate.hs b/Generate.hs index 8053f98..6405a6e 100644 --- a/Generate.hs +++ b/Generate.hs @@ -62,7 +62,8 @@ genUnconsVectorFuns elemTM vectorTM = , AST.SubProgBody tailSpec [AST.SPVD tailVar] [tailExpr, tailRet] , AST.SubProgBody takeSpec [AST.SPVD takeVar] [takeExpr, takeRet] , AST.SubProgBody dropSpec [AST.SPVD dropVar] [dropExpr, dropRet] - , AST.SubProgBody plusgtSpec [AST.SPVD plusgtVar] [plusgtExpr, plusgtRet] + , AST.SubProgBody plusgtSpec [AST.SPVD plusgtVar] [plusgtExpr, plusgtRet] + , AST.SubProgBody emptySpec [AST.SPVD emptyVar] [emptyExpr] ] where ixPar = AST.unsafeVHDLBasicId "ix" @@ -201,3 +202,12 @@ genUnconsVectorFuns elemTM vectorTM = ((AST.PrimName $ AST.NSimple aPar) AST.:&: (AST.PrimName $ AST.NSimple vecPar)) plusgtRet = AST.ReturnSm (Just $ AST.PrimName $ AST.NSimple resId) + emptySpec = AST.Function emptyId [] vectorTM + emptyVar = + AST.VarDec resId + (AST.SubtypeIn vectorTM + (Just $ AST.ConstraintIndex $ AST.IndexConstraint + [AST.ToRange (AST.PrimLit "0") + (AST.PrimLit "-1")])) + Nothing + emptyExpr = AST.ReturnSm (Just $ AST.PrimName (AST.NSimple resId)) \ No newline at end of file diff --git a/GlobalNameTable.hs b/GlobalNameTable.hs index cf585ea..49b717c 100644 --- a/GlobalNameTable.hs +++ b/GlobalNameTable.hs @@ -26,6 +26,7 @@ globalNameTable = mkGlobalNameTable , ("take" , (2, genExprFCall takeId ) ) , ("drop" , (2, genExprFCall dropId ) ) , ("+>" , (2, genExprFCall plusgtId ) ) + , ("empty" , (0, genExprFCall emptyId ) ) , ("hwxor" , (2, genExprOp2 AST.Xor ) ) , ("hwand" , (2, genExprOp2 AST.And ) ) , ("hwor" , (2, genExprOp2 AST.Or ) )