Added a few more mobile things (DEFINED keyword, an intrinsic)

This commit is contained in:
Neil Brown 2009-03-20 20:53:51 +00:00
parent 1d43b9d7bd
commit 03f1b2d115
5 changed files with 21 additions and 9 deletions

View File

@ -153,6 +153,9 @@ intrinsicProcs =
, (A.ValAbbrev, A.Array [A.UnknownDimension] A.Byte, "string")
])
]
++ [("RESIZE.MOBILE.ARRAY.1D", [(A.Abbrev, A.Mobile A.Infer, "mobile")
,(A.ValAbbrev, A.Int, "count")
])]
rainIntrinsicFunctions :: [(String, ([A.Type], [(A.Type, String)]))]
rainIntrinsicFunctions =

View File

@ -293,6 +293,7 @@ typeOfExpression e
A.OffsetOf m t n -> return A.Int
A.AllocMobile _ t _ -> return t
A.CloneMobile _ e -> typeOfExpression e
A.IsDefined {} -> return A.Bool
--}}}
-- | Gets the return type(s) of a function call from the 'CompState'.

View File

@ -283,6 +283,9 @@ data Expression =
-- | A CLONE operation. The inner expression should have a Mobile type, and
-- this will have the same type as the inner component:
| CloneMobile Meta Expression
-- | The DEFINED operator. Returns a boolean as to whether the mobile type is
-- defined or not.
| IsDefined Meta Expression
deriving (Show, Eq, Typeable, Data)
-- | A list of expressions.

View File

@ -54,7 +54,7 @@ $vertSpace = [\r\n]
| "AFTER" | "ALT" | "AND" | "ANY" | "AT"
| "BITAND" | "BITNOT" | "BITOR" | "BOOL" | "BYTE" | "BYTESIN"
| "CASE" | "CHAN" | "CLONE"
| "DATA"
| "DATA" | "DEFINED"
| "ELSE"
| "FALSE" | "FOR" | "FROM" | "FUNCTION"
| "IF" | "IN" | "INITIAL" | "INLINE" | "INT" | "INT16" | "INT32" | "INT64"

View File

@ -111,13 +111,13 @@ sSemi = reserved ";"
--}}}
--{{{ keywords
sAFTER, sALT, sAND, sANY, sAT, sBITAND, sBITNOT, sBITOR, sBOOL, sBYTE,
sBYTESIN, sCASE, sCHAN, sCLONE, sDATA, sELSE, sFALSE, sFOR, sFROM, sFUNCTION, sIF,
sINLINE, sIN, sINITIAL, sINT, sINT16, sINT32, sINT64, sIS, sMINUS, sMOBILE, sMOSTNEG,
sMOSTPOS, sNOT, sOF, sOFFSETOF, sOR, sPACKED, sPAR, sPLACE, sPLACED, sPLUS,
sPORT, sPRI, sPROC, sPROCESSOR, sPROTOCOL, sREAL32, sREAL64, sRECORD,
sREC_RECURSIVE, sREM, sRESHAPES, sRESULT, sRETYPES, sROUND, sSEQ, sSIZE,
sSKIP, sSTEP, sSTOP, sTIMER, sTIMES, sTRUE, sTRUNC, sTYPE, sVAL, sVALOF,
sWHILE, sWORKSPACE, sVECSPACE
sBYTESIN, sCASE, sCHAN, sCLONE, sDATA, sDEFINED, sELSE, sFALSE, sFOR, sFROM,
sFUNCTION, sIF, sINLINE, sIN, sINITIAL, sINT, sINT16, sINT32, sINT64, sIS,
sMINUS, sMOBILE, sMOSTNEG, sMOSTPOS, sNOT, sOF, sOFFSETOF, sOR, sPACKED,
sPAR, sPLACE, sPLACED, sPLUS, sPORT, sPRI, sPROC, sPROCESSOR, sPROTOCOL,
sREAL32, sREAL64, sRECORD, sREC_RECURSIVE, sREM, sRESHAPES, sRESULT,
sRETYPES, sROUND, sSEQ, sSIZE, sSKIP, sSTEP, sSTOP, sTIMER, sTIMES, sTRUE,
sTRUNC, sTYPE, sVAL, sVALOF, sWHILE, sWORKSPACE, sVECSPACE
:: OccParser ()
sAFTER = reserved "AFTER"
@ -135,6 +135,7 @@ sCASE = reserved "CASE"
sCHAN = reserved "CHAN"
sCLONE = reserved "CLONE"
sDATA = reserved "DATA"
sDEFINED = reserved "DEFINED"
sELSE = reserved "ELSE"
sFALSE = reserved "FALSE"
sFOR = reserved "FOR"
@ -535,7 +536,9 @@ dataType
<|> do { sREAL32; return A.Real32 }
<|> do { sREAL64; return A.Real64 }
<|> arrayType dataType
<|> do { sMOBILE; dataType >>* A.Mobile }
-- Mobile arrays can lack dimensions:
<|> do { tryXV sMOBILE (specArrayType dataType) >>* A.Mobile }
<|> do { tryXV sMOBILE dataType >>* A.Mobile }
<|> do { n <- try dataTypeName; return $ A.UserDataType n }
<|> do { n <- try recordName; return $ A.Record n }
<?> "data type"
@ -706,6 +709,8 @@ expression
<|> do { m <- md; sMOSTPOS; t <- dataType; return $ A.MostPos m t }
<|> do { m <- md; sMOSTNEG; t <- dataType; return $ A.MostNeg m t }
<|> do { m <- md; sCLONE; e <- expression; return $ A.CloneMobile m e }
<|> do { m <- md; sMOBILE; t <- dataType ; return $ A.AllocMobile m (A.Mobile t) Nothing }
<|> do { m <- md; sDEFINED; e <- expression; return $ A.IsDefined m e }
<|> sizeExpr
<|> do m <- md
(l, o) <- tryVV operand dyadicOperator