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,
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

View File

@ -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.

View File

@ -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] }

View File

@ -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

View File

@ -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

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.
PLACE should work.
## Long-term
If we have constant folding, we're three-quarters of the way towards having an