Made names for loop variables unique in Rain, and made their abbreviation mode Abbrev
This commit is contained in:
parent
6b04b6d944
commit
43b77ff1a0
|
@ -93,6 +93,9 @@ transformInt = everywhereM (mkM transformInt')
|
|||
--
|
||||
-- This may seem like three passes in one, but if you try to separate them out, it just ends up
|
||||
-- with more confusion and more code.
|
||||
--
|
||||
-- This pass works because everywhereM goes bottom-up, so declarations are
|
||||
--resolved from the bottom upwards.
|
||||
uniquifyAndResolveVars :: Data t => t -> PassM t
|
||||
uniquifyAndResolveVars = everywhereM (mk1M uniquifyAndResolveVars')
|
||||
where
|
||||
|
@ -134,6 +137,13 @@ uniquifyAndResolveVars = everywhereM (mk1M uniquifyAndResolveVars')
|
|||
A.ndAbbrevMode = am, A.ndPlacement = A.Unplaced}
|
||||
let scope' = everywhere (mkT $ replaceNameName (A.nameName n) n') scope
|
||||
return (A.Formal am t newName, scope')
|
||||
|
||||
-- replicator names have their types recorded later, but are
|
||||
-- uniquified and resolved here
|
||||
uniquifyAndResolveVars' (A.Rep m (A.ForEach m' n e) scope)
|
||||
= do n' <- makeNonce $ A.nameName n
|
||||
let scope' = everywhere (mkT $ replaceNameName (A.nameName n) n') scope
|
||||
return $ A.Rep m (A.ForEach m' (n {A.nameName = n'}) e) scope'
|
||||
--Other:
|
||||
uniquifyAndResolveVars' s = return s
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ recordInfNameTypes = everywhereM (mkM recordInfNameTypes')
|
|||
_ -> diePC m $ formatCode "Cannot do a foreach loop over a non-list type: %" arrType
|
||||
defineName n A.NameDef {A.ndMeta = m, A.ndName = A.nameName n, A.ndOrigName = A.nameName n,
|
||||
A.ndNameType = A.VariableName, A.ndType = (A.Declaration m innerT),
|
||||
A.ndAbbrevMode = A.Original, A.ndPlacement = A.Unplaced}
|
||||
A.ndAbbrevMode = A.Abbrev, A.ndPlacement = A.Unplaced}
|
||||
return input
|
||||
recordInfNameTypes' r = return r
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user