Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
jberryman
GHC
Commits
ffe3daa2
Commit
ffe3daa2
authored
Aug 14, 1998
by
sof
Browse files
[project @ 1998-08-14 11:47:29 by sof]
Renaming foreign decls
parent
83f1f583
Changes
6
Hide whitespace changes
Inline
Side-by-side
ghc/compiler/rename/RnBinds.lhs
View file @
ffe3daa2
...
...
@@ -26,7 +26,7 @@ import RnHsSyn
import RnMonad
import RnExpr ( rnMatch, rnGRHSsAndBinds, rnPat, checkPrecMatch )
import RnEnv ( bindLocatedLocalsRn, lookupBndrRn, lookupOccRn, lookupGlobalOccRn,
newLocalNames,
isUnboundName, warnUnusedBinds
isUnboundName, warnUnusedBinds
)
import CmdLineOpts ( opt_SigsRequired )
import Digraph ( stronglyConnComp, SCC(..) )
...
...
ghc/compiler/rename/RnEnv.lhs
View file @
ffe3daa2
...
...
@@ -709,7 +709,7 @@ fixityClashErr (rdr_name, ((_,how_in_scope1), (_, how_in_scope2)))
ppr how_in_scope2])
shadowedNameWarn shadow
= h
cat
[ptext SLIT("This binding for"),
= h
sep
[ptext SLIT("This binding for"),
quotes (ppr shadow),
ptext SLIT("shadows an existing binding")]
...
...
ghc/compiler/rename/RnHsSyn.lhs
View file @
ffe3daa2
...
...
@@ -31,6 +31,7 @@ type RenamedContext = Context Name
type RenamedHsDecl = HsDecl Unused Name RenamedPat
type RenamedSpecDataSig = SpecDataSig Name
type RenamedDefaultDecl = DefaultDecl Name
type RenamedForeignDecl = ForeignDecl Name
type RenamedFixityDecl = FixityDecl Name
type RenamedGRHS = GRHS Unused Name RenamedPat
type RenamedGRHSsAndBinds = GRHSsAndBinds Unused Name RenamedPat
...
...
ghc/compiler/rename/RnIfaces.lhs
View file @
ffe3daa2
...
...
@@ -917,6 +917,7 @@ getDeclBinders new_name (SigD (IfaceSig var ty prags src_loc))
= new_name var src_loc `thenRn` \ var_name ->
returnRn (Avail var_name)
getDeclBinders new_name (ForD _) = returnRn NotAvailable
getDeclBinders new_name (DefD _) = returnRn NotAvailable
getDeclBinders new_name (InstD _) = returnRn NotAvailable
...
...
ghc/compiler/rename/RnNames.lhs
View file @
ffe3daa2
...
...
@@ -15,7 +15,8 @@ import CmdLineOpts ( opt_NoImplicitPrelude, opt_WarnDuplicateExports,
)
import HsSyn ( HsModule(..), ImportDecl(..), HsDecl(..),
IE(..), ieName,
IE(..), ieName,
ForeignDecl(..), ExtName(..),
FixityDecl(..),
collectTopBinders
)
...
...
@@ -224,6 +225,16 @@ importsFromLocalDecls rec_exp_fn (HsModule mod _ _ _ fix_decls decls _)
= mapRn do_one (bagToList (collectTopBinders binds)) `thenRn` \ val_avails ->
returnRn (val_avails ++ avails)
-- foreign import declaration
getLocalDeclBinders avails (ForD (ForeignDecl nm (Just _) _ _ _ loc))
= do_one (nm,loc) `thenRn` \ for_avail ->
returnRn (for_avail : avails)
-- foreign export dynamic declaration
getLocalDeclBinders avails (ForD (ForeignDecl nm Nothing _ Dynamic _ loc))
= do_one (nm,loc) `thenRn` \ for_avail ->
returnRn (for_avail : avails)
getLocalDeclBinders avails decl
= getDeclBinders newLocalName decl `thenRn` \ avail ->
case avail of
...
...
ghc/compiler/rename/RnSource.lhs
View file @
ffe3daa2
...
...
@@ -20,9 +20,10 @@ import CmdLineOpts ( opt_IgnoreIfacePragmas )
import RnBinds ( rnTopBinds, rnMethodBinds, renameSigs )
import RnEnv ( bindTyVarsRn, lookupBndrRn, lookupOccRn, lookupImplicitOccRn, bindLocalsRn,
newDfunName, checkDupOrQualNames, checkDupNames,
newDfunName, checkDupOrQualNames, checkDupNames,
lookupGlobalOccRn,
newLocallyDefinedGlobalName, newImportedGlobalName, ifaceFlavour,
listType_RDR, tupleType_RDR )
listType_RDR, tupleType_RDR, addImplicitOccRn
)
import RnMonad
import Name ( Name, OccName(..), occNameString, prefixOccName,
...
...
@@ -298,6 +299,28 @@ rnDecl (DefD (DefaultDecl tys src_loc))
returnRn (DefD (DefaultDecl tys' src_loc))
\end{code}
%*********************************************************
%* *
\subsection{Foreign declarations}
%* *
%*********************************************************
\begin{code}
rnDecl (ForD (ForeignDecl name imp_exp ty ext_nm cconv src_loc))
= pushSrcLocRn src_loc $
lookupBndrRn name `thenRn` \ name' ->
(if is_export then
addImplicitOccRn name'
else
returnRn name') `thenRn_`
rnHsSigType fo_decl_msg ty `thenRn` \ ty' ->
returnRn (ForD (ForeignDecl name' imp_exp ty' ext_nm cconv src_loc))
where
fo_decl_msg = ptext SLIT("a foreign declaration")
is_export = not (maybeToBool imp_exp) && not (isDynamic ext_nm)
\end{code}
%*********************************************************
%* *
\subsection{Support code for type/data declarations}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment