diff --git a/fco2/AST.hs b/fco2/AST.hs index fe98897..8ae8538 100644 --- a/fco2/AST.hs +++ b/fco2/AST.hs @@ -30,7 +30,8 @@ data NameDef = NameDef { ndOrigName :: String, ndNameType :: NameType, ndType :: SpecType, - ndAbbrevMode :: AbbrevMode + ndAbbrevMode :: AbbrevMode, + ndPlacement :: Placement } deriving (Show, Eq, Typeable, Data) @@ -54,6 +55,13 @@ data Dimension = | UnknownDimension deriving (Show, Eq, Typeable, Data) +data Placement = + Unplaced + | PlaceInWorkspace + | PlaceInVecspace + | PlaceAt Expression + deriving (Show, Eq, Typeable, Data) + data ConversionMode = DefaultConversion | Round diff --git a/fco2/LANGUAGE b/fco2/LANGUAGE index 5dac2b7..49d720c 100644 --- a/fco2/LANGUAGE +++ b/fco2/LANGUAGE @@ -17,3 +17,5 @@ Intrinsics: Simple versions of #USE and #INCLUDE that only work in a process context (i.e. you can't #INCLUDE the body of a nested block). + +PLACE IN WORKSPACE and PLACE IN VECSPACE, both currently ignored. diff --git a/fco2/Parse.hs b/fco2/Parse.hs index d245448..6f87bac 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -87,6 +87,7 @@ occamStyle "FROM", "FUNCTION", "IF", + "IN", "INLINE", "INT", "INT16", @@ -130,6 +131,8 @@ occamStyle "VAL", "VALOF", "WHILE", + "WORKSPACE", + "VECSPACE", "#INCLUDE", "#USE", indentMarker, @@ -196,6 +199,7 @@ sFROM = reserved "FROM" sFUNCTION = reserved "FUNCTION" sIF = reserved "IF" sINLINE = reserved "INLINE" +sIN = reserved "IN" sINT = reserved "INT" sINT16 = reserved "INT16" sINT32 = reserved "INT32" @@ -238,6 +242,8 @@ sTYPE = reserved "TYPE" sVAL = reserved "VAL" sVALOF = reserved "VALOF" sWHILE = reserved "WHILE" +sWORKSPACE = reserved "WORKSPACE" +sVECSPACE = reserved "VECSPACE" sppINCLUDE = reserved "#INCLUDE" sppUSE = reserved "#USE" --}}} @@ -499,7 +505,8 @@ scopeIn n@(A.Name m nt s) t am A.ndOrigName = s, A.ndNameType = A.nameType n', A.ndType = t, - A.ndAbbrevMode = am + A.ndAbbrevMode = am, + A.ndPlacement = A.Unplaced } defineName n' nd modify $ (\st -> st { @@ -1125,9 +1132,28 @@ replicator --{{{ specifications, declarations, allocations allocation :: OccParser [A.Specification] allocation - = do { m <- md; sPLACE; n <- variableName; sAT; e <- intExpr; sColon; eol; return [A.Specification m n (A.Place m e)] } + = do m <- md + sPLACE + n <- try variableName <|> try channelName <|> portName + p <- placement + sColon + eol + nd <- lookupName n + defineName n $ nd { A.ndPlacement = p } + return [] "allocation" +placement :: OccParser A.Placement +placement + = do sAT + e <- intExpr + return $ A.PlaceAt e + <|> do tryXX sIN sWORKSPACE + return $ A.PlaceInWorkspace + <|> do tryXX sIN sVECSPACE + return $ A.PlaceInVecspace + "placement" + specification :: OccParser [A.Specification] specification = do { m <- md; (ns, d) <- declaration; return [A.Specification m n d | n <- ns] } diff --git a/fco2/ParseState.hs b/fco2/ParseState.hs index 33b21e7..c1bd0b4 100644 --- a/fco2/ParseState.hs +++ b/fco2/ParseState.hs @@ -162,7 +162,8 @@ defineNonce m s st nt am A.ndOrigName = ns, A.ndNameType = nt, A.ndType = st, - A.ndAbbrevMode = am + A.ndAbbrevMode = am, + A.ndPlacement = A.Unplaced } defineName n nd return $ A.Specification m n st diff --git a/fco2/SimplifyExprs.hs b/fco2/SimplifyExprs.hs index 5f65830..fc18b32 100644 --- a/fco2/SimplifyExprs.hs +++ b/fco2/SimplifyExprs.hs @@ -45,7 +45,8 @@ functionsToProcs = doGeneric `extM` doSpecification A.ndOrigName = A.nameName n, A.ndNameType = A.ProcName, A.ndType = st, - A.ndAbbrevMode = A.Original + A.ndAbbrevMode = A.Original, + A.ndPlacement = A.Unplaced } defineName n nd doGeneric spec diff --git a/fco2/TODO b/fco2/TODO index c0c3d95..eb2de25 100644 --- a/fco2/TODO +++ b/fco2/TODO @@ -78,6 +78,8 @@ Real-to-integer conversions don't work correctly. Slice checks should not be generated if the slice is known to be safe. +PLACE should work. + ## Long-term If we have constant folding, we're three-quarters of the way towards having an