From: sewardj Date: Fri, 29 Sep 2000 15:59:29 +0000 (+0000) Subject: [project @ 2000-09-29 15:59:28 by sewardj] X-Git-Tag: Approximately_9120_patches~3713 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=fa869cdd81d44d9167c1a54b3adae485996a1991;p=ghc-hetmet.git [project @ 2000-09-29 15:59:28 by sewardj] New modules for GHCI. --- diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index 06abea1..ef4647b 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.92 2000/09/11 12:20:56 sewardj Exp $ +# $Id: Makefile,v 1.93 2000/09/29 15:59:28 sewardj Exp $ TOP = .. include $(TOP)/mk/boilerplate.mk @@ -41,7 +41,7 @@ $(HS_PROG) :: $(HS_SRCS) DIRS = \ utils basicTypes types hsSyn prelude rename typecheck deSugar coreSyn \ specialise simplCore stranal stgSyn simplStg codeGen absCSyn main \ - profiling parser usageSP cprAnalysis javaGen + profiling parser usageSP cprAnalysis javaGen ghci ifeq ($(GhcWithNativeCodeGen),YES) diff --git a/ghc/compiler/ghci/CmCompile.lhs b/ghc/compiler/ghci/CmCompile.lhs new file mode 100644 index 0000000..2b32e05 --- /dev/null +++ b/ghc/compiler/ghci/CmCompile.lhs @@ -0,0 +1,121 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CmCompile]{Compiler for GHCI} + +\begin{code} +module CmCompile ( cmCompile, + ModDetails, -- abstract + ModIFace, -- abstract + PCS, -- abstract + HST, -- not abstract (CM needs to see it) + HIT, -- ditto + CompResult(..) + ) +where + +#include "HsVersions.h" + +import CmLink ( Linkable ) +import Outputable ( SDoc ) +import CmFind ( Finder ) +import CmSummarise ( ModSummary ) +import CmStaticInfo ( SI ) +import FiniteMap ( FiniteMap ) + +import Module ( Module ) +import RnMonad ( Avails, GlobalRdrEnv, DeclsMap, + WhetherHasOrphans, ImportVersion, + IfaceInsts, IfaceRules, ExportItem ) +import TcEnv ( TyThing, InstEnv ) +import Name ( Name, OccName ) +import BasicTypes ( Fixity, Version ) +import Id ( Id ) +import CoreSyn ( CoreRule ) +import RdrHsSyn ( RdrNameDeprecation, RdrNameRuleDecl, RdrNameFixitySig, + RdrNameHsDecl, RdrNameInstDecl ) + + +\end{code} +\begin{code} +cmCompile :: SI -- obvious + -> Finder -- to find modules + -> ModSummary -- summary, including source + -> Maybe ModIFace -- old interface, if available + -> HST -- for home module ModDetails + -> PCS -- IN: persistent compiler state + -> IO CompResult + +cmCompile flags finder summary old_iface hst pcs + = return (error "cmCompile:unimp") + + +data CompResult + = CompOK ModDetails -- new details (HST additions) + (Maybe (ModIFace, Linkable)) + -- summary and code; Nothing => compilation not reqd + -- (old summary and code are still valid) + PCS -- updated PCS + [SDoc] -- warnings + + | CompErrs PCS -- updated PCS + [SDoc] -- warnings and errors + +newPCS :: IO PCS +newPCS = return (error "newPCS:unimp") + +-- These two are only here to avoid recursion between CmCompile and +-- CompManager. They really ought to be in the latter. +type HST = FiniteMap Module ModDetails +type HIT = FiniteMap Module ModIFace + + +data PCS = MkPCS PIT -- Package interface table + PST -- Package symbol table + HoldingPen -- pre slurped interface bits and pieces + +type PIT = FiniteMap Module ModIFace +type PST = FiniteMap Module ModDetails + +-- ModIFace is nearly the same as RnMonad.ParsedIface. +-- Right now it's identical :) +data ModIFace + = ModIFace { + mi_mod :: Module, -- Complete with package info + mi_vers :: Version, -- Module version number + mi_orphan :: WhetherHasOrphans, -- Whether this module has orphans + mi_usages :: [ImportVersion OccName], -- Usages + mi_exports :: [ExportItem], -- Exports + mi_insts :: [RdrNameInstDecl], -- Local instance declarations + mi_decls :: [(Version, RdrNameHsDecl)], -- Local definitions + mi_fixity :: (Version, [RdrNameFixitySig]), -- Local fixity declarations, + -- with their version + mi_rules :: (Version, [RdrNameRuleDecl]), -- Rules, with their version + mi_deprecs :: [RdrNameDeprecation] -- Deprecations + } + +data ModDetails + = ModDetails { + moduleExports :: Avails, + moduleEnv :: GlobalRdrEnv, -- == FM RdrName [Name] + typeEnv :: FiniteMap Name TyThing, -- TyThing is in TcEnv.lhs + instEnv :: InstEnv, + fixityEnv :: FiniteMap Name Fixity, + ruleEnv :: FiniteMap Id [CoreRule] + } + +-- This should eventually replace RnMonad.Ifaces +data HoldingPen + = HoldingPen { + iDecls :: DeclsMap, -- A single, global map of Names to decls + + iInsts :: IfaceInsts, + -- The as-yet un-slurped instance decls; this bag is depleted when we + -- slurp an instance decl so that we don't slurp the same one twice. + -- Each is 'gated' by the names that must be available before + -- this instance decl is needed. + + iRules :: IfaceRules + -- Similar to instance decls, only for rules + } +\end{code} diff --git a/ghc/compiler/ghci/CmFind.lhs b/ghc/compiler/ghci/CmFind.lhs new file mode 100644 index 0000000..25888b4 --- /dev/null +++ b/ghc/compiler/ghci/CmFind.lhs @@ -0,0 +1,31 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CmFind]{Module finder for GHCI} + +\begin{code} +module CmFind ( Path, ModName, PkgName, + ModLocation(..), Finder, newFinder ) +where + +#include "HsVersions.h" + +import Module ( Module ) +import CmStaticInfo ( PCI ) +\end{code} + +\begin{code} +type Path = String +type ModName = String +type PkgName = String + +data ModLocation + = SourceOnly Module Path -- .hs + | ObjectCode Module Path Path -- .o, .hi + | InPackage Module PkgName + +type Finder = ModName -> IO ModLocation + +newFinder :: PCI -> IO Finder +newFinder pci = return (error "newFinder:unimp") +\end{code} diff --git a/ghc/compiler/ghci/CmLink.lhs b/ghc/compiler/ghci/CmLink.lhs new file mode 100644 index 0000000..311af33 --- /dev/null +++ b/ghc/compiler/ghci/CmLink.lhs @@ -0,0 +1,56 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CmLink]{Linker for GHCI} + +\begin{code} +module CmLink ( Linkable(..), LinkResult(..), + HValue, + link, + PLS{-abstractly!-}, emptyPLS ) + +where + +import CmStaticInfo ( PCI ) +import CmFind ( Path, PkgName ) +import Module ( Module ) +import Outputable ( SDoc ) +import FiniteMap ( FiniteMap ) +import RdrName ( RdrName ) +import Addr ( Addr ) + +#include "HsVersions.h" + +\end{code} + +\begin{code} +data PLS + = MkPLS { + source_symtab :: FiniteMap RdrName HValue, + object_symtab :: FiniteMap String Addr + } + +data HValue = HValue -- fix this ... just temporary? + + +link :: PCI -> [[Linkable]] -> PLS -> IO LinkResult +link pci linkabless pls + = return (error "link:unimp") + +data LinkResult + = LinkOK PLS + | LinkErrs PLS [SDoc] + +data Unlinked + = DotO Path + | DotA Path + | DotDLL Path + -- | Trees [StgTree RdrName] + +data Linkable + = LM Module [Unlinked] + | LP PkgName + +emptyPLS :: IO PLS +emptyPLS = return (error "emptyPLS:unimp") +\end{code} diff --git a/ghc/compiler/ghci/CmStaticInfo.lhs b/ghc/compiler/ghci/CmStaticInfo.lhs new file mode 100644 index 0000000..48594f6 --- /dev/null +++ b/ghc/compiler/ghci/CmStaticInfo.lhs @@ -0,0 +1,27 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CmStaticInfo]{Session-static info for the Compilation Manager} + +\begin{code} +module CmStaticInfo ( FLAGS, PCI, + mkSI, SI -- abstract + ) +where + +#include "HsVersions.h" + +\end{code} + +\begin{code} +type FLAGS = [String] -- or some such fiction +type PCI = [PkgConfig] +data PkgConfig = PkgConfig -- add details here + +data SI = MkSI FLAGS PCI + +mkSI :: FLAGS -> PCI -> SI +mkSI = MkSI + + +\end{code} diff --git a/ghc/compiler/ghci/CmSummarise.lhs b/ghc/compiler/ghci/CmSummarise.lhs new file mode 100644 index 0000000..f7954d8 --- /dev/null +++ b/ghc/compiler/ghci/CmSummarise.lhs @@ -0,0 +1,28 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CmSummarise]{Module summariser for GHCI} + +\begin{code} +module CmSummarise ( ModSummary(..), summarise ) +where + +#include "HsVersions.h" + +import CmFind ( ModName, ModLocation ) + +\end{code} + +\begin{code} + + +data ModSummary + = ModSummary ModLocation -- location and kind + (Maybe (String, Fingerprint)) -- source and sig if .hs + [ModName] -- imports + +type Fingerprint = Int + +summarise :: ModLocation -> IO ModSummary +summarise loc = return (error "summarise:unimp") +\end{code} diff --git a/ghc/compiler/ghci/CompManager.lhs b/ghc/compiler/ghci/CompManager.lhs new file mode 100644 index 0000000..de988cc --- /dev/null +++ b/ghc/compiler/ghci/CompManager.lhs @@ -0,0 +1,73 @@ +% +% (c) The AQUA Project, Glasgow University, 1993-2000 +% +\section[CompManager]{The Compilation Manager} + +\begin{code} +module CompManager ( cmInit, cmLoadModule, + cmGetExpr, cmRunExpr, + CmState -- abstract + ) +where + +#include "HsVersions.h" + +import Outputable ( SDoc ) + +import CmStaticInfo ( FLAGS, PCI, SI, mkSI ) +import CmFind ( Finder, ModName ) +import CmSummarise ( ) +import CmCompile ( PCS, HST, HIT ) +import CmLink ( PLS, HValue, Linkable ) + + + +cmInit :: FLAGS + -> PCI + -> IO CmState +cmInit flags pkginfo + = return (error "cmInit:unimp") + +cmLoadModule :: CmState + -> ModName + -> IO (CmState, Either [SDoc] ModHandle) +cmLoadModule cmstate modname + = return (error "cmLoadModule:unimp") + +cmGetExpr :: CmState + -> ModHandle + -> String + -> IO (CmState, Either [SDoc] HValue) +cmGetExpr cmstate modhdl expr + = return (error "cmGetExpr:unimp") + +cmRunExpr :: HValue -> IO () +cmRunExpr hval + = return (error "cmRunExpr:unimp") + +type ModHandle = String -- ToDo: do better? + + +-- Persistent state just for CM, excluding link & compile subsystems +data PCMS + = PCMS HST -- home symbol table + HIT -- home interface table + UI -- the unlinked images + MG -- the module graph + +-- Persistent state for the entire system +data CmState + = CmState PCMS -- CM's persistent state + PCS -- compile's persistent state + PLS -- link's persistent state + SI -- static info, never changes + Finder -- the module finder + +-- CM internal types +type UI = [Linkable] -- the unlinked images (should be a set, really) +data MG = MG -- the module graph + + + + +\end{code}