Support (but ignore in the code generator for now) PLACE AT/IN

This commit is contained in:
Adam Sampson 2007-04-30 23:24:37 +00:00
parent 618ad6d55f
commit 5ffe4de9ad
6 changed files with 45 additions and 5 deletions

View File

@ -30,7 +30,8 @@ data NameDef = NameDef {
ndOrigName :: String, ndOrigName :: String,
ndNameType :: NameType, ndNameType :: NameType,
ndType :: SpecType, ndType :: SpecType,
ndAbbrevMode :: AbbrevMode ndAbbrevMode :: AbbrevMode,
ndPlacement :: Placement
} }
deriving (Show, Eq, Typeable, Data) deriving (Show, Eq, Typeable, Data)
@ -54,6 +55,13 @@ data Dimension =
| UnknownDimension | UnknownDimension
deriving (Show, Eq, Typeable, Data) deriving (Show, Eq, Typeable, Data)
data Placement =
Unplaced
| PlaceInWorkspace
| PlaceInVecspace
| PlaceAt Expression
deriving (Show, Eq, Typeable, Data)
data ConversionMode = data ConversionMode =
DefaultConversion DefaultConversion
| Round | Round

View File

@ -17,3 +17,5 @@ Intrinsics:
Simple versions of #USE and #INCLUDE that only work in a process context (i.e. 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). you can't #INCLUDE the body of a nested block).
PLACE IN WORKSPACE and PLACE IN VECSPACE, both currently ignored.

View File

@ -87,6 +87,7 @@ occamStyle
"FROM", "FROM",
"FUNCTION", "FUNCTION",
"IF", "IF",
"IN",
"INLINE", "INLINE",
"INT", "INT",
"INT16", "INT16",
@ -130,6 +131,8 @@ occamStyle
"VAL", "VAL",
"VALOF", "VALOF",
"WHILE", "WHILE",
"WORKSPACE",
"VECSPACE",
"#INCLUDE", "#INCLUDE",
"#USE", "#USE",
indentMarker, indentMarker,
@ -196,6 +199,7 @@ sFROM = reserved "FROM"
sFUNCTION = reserved "FUNCTION" sFUNCTION = reserved "FUNCTION"
sIF = reserved "IF" sIF = reserved "IF"
sINLINE = reserved "INLINE" sINLINE = reserved "INLINE"
sIN = reserved "IN"
sINT = reserved "INT" sINT = reserved "INT"
sINT16 = reserved "INT16" sINT16 = reserved "INT16"
sINT32 = reserved "INT32" sINT32 = reserved "INT32"
@ -238,6 +242,8 @@ sTYPE = reserved "TYPE"
sVAL = reserved "VAL" sVAL = reserved "VAL"
sVALOF = reserved "VALOF" sVALOF = reserved "VALOF"
sWHILE = reserved "WHILE" sWHILE = reserved "WHILE"
sWORKSPACE = reserved "WORKSPACE"
sVECSPACE = reserved "VECSPACE"
sppINCLUDE = reserved "#INCLUDE" sppINCLUDE = reserved "#INCLUDE"
sppUSE = reserved "#USE" sppUSE = reserved "#USE"
--}}} --}}}
@ -499,7 +505,8 @@ scopeIn n@(A.Name m nt s) t am
A.ndOrigName = s, A.ndOrigName = s,
A.ndNameType = A.nameType n', A.ndNameType = A.nameType n',
A.ndType = t, A.ndType = t,
A.ndAbbrevMode = am A.ndAbbrevMode = am,
A.ndPlacement = A.Unplaced
} }
defineName n' nd defineName n' nd
modify $ (\st -> st { modify $ (\st -> st {
@ -1125,9 +1132,28 @@ replicator
--{{{ specifications, declarations, allocations --{{{ specifications, declarations, allocations
allocation :: OccParser [A.Specification] allocation :: OccParser [A.Specification]
allocation 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" <?> "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 :: OccParser [A.Specification]
specification specification
= do { m <- md; (ns, d) <- declaration; return [A.Specification m n d | n <- ns] } = do { m <- md; (ns, d) <- declaration; return [A.Specification m n d | n <- ns] }

View File

@ -162,7 +162,8 @@ defineNonce m s st nt am
A.ndOrigName = ns, A.ndOrigName = ns,
A.ndNameType = nt, A.ndNameType = nt,
A.ndType = st, A.ndType = st,
A.ndAbbrevMode = am A.ndAbbrevMode = am,
A.ndPlacement = A.Unplaced
} }
defineName n nd defineName n nd
return $ A.Specification m n st return $ A.Specification m n st

View File

@ -45,7 +45,8 @@ functionsToProcs = doGeneric `extM` doSpecification
A.ndOrigName = A.nameName n, A.ndOrigName = A.nameName n,
A.ndNameType = A.ProcName, A.ndNameType = A.ProcName,
A.ndType = st, A.ndType = st,
A.ndAbbrevMode = A.Original A.ndAbbrevMode = A.Original,
A.ndPlacement = A.Unplaced
} }
defineName n nd defineName n nd
doGeneric spec doGeneric spec

View File

@ -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. Slice checks should not be generated if the slice is known to be safe.
PLACE should work.
## Long-term ## Long-term
If we have constant folding, we're three-quarters of the way towards having an If we have constant folding, we're three-quarters of the way towards having an