~ubuntu-branches/ubuntu/precise/ghc/precise

« back to all changes in this revision

Viewing changes to compiler/typecheck/TcAnnotations.lhs

  • Committer: Bazaar Package Importer
  • Author(s): Joachim Breitner
  • Date: 2011-01-17 12:49:24 UTC
  • Revision ID: james.westby@ubuntu.com-20110117124924-do1pym1jlf5o636m
Tags: upstream-7.0.1
ImportĀ upstreamĀ versionĀ 7.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
%
 
2
% (c) The University of Glasgow 2006
 
3
% (c) The AQUA Project, Glasgow University, 1993-1998
 
4
%
 
5
\section[TcAnnotations]{Typechecking annotations}
 
6
 
 
7
\begin{code}
 
8
module TcAnnotations ( tcAnnotations ) where
 
9
 
 
10
import HsSyn
 
11
import Annotations
 
12
import Name
 
13
import TcRnMonad
 
14
import SrcLoc
 
15
import Outputable
 
16
 
 
17
#ifdef GHCI
 
18
import Module
 
19
import TcExpr
 
20
import {-# SOURCE #-} TcSplice ( runAnnotation )
 
21
import FastString
 
22
#endif
 
23
\end{code}
 
24
 
 
25
\begin{code}
 
26
tcAnnotations :: [LAnnDecl Name] -> TcM [Annotation]
 
27
tcAnnotations = mapM tcAnnotation
 
28
 
 
29
tcAnnotation :: LAnnDecl Name -> TcM Annotation
 
30
#ifndef GHCI
 
31
-- TODO: modify lexer so ANN pragmas are parsed as comments in a stage1 compiler, so developers don't see this error
 
32
tcAnnotation (L _ (HsAnnotation _ expr)) = pprPanic "Cant do annotations without GHCi" (ppr expr)
 
33
#else
 
34
tcAnnotation ann@(L loc (HsAnnotation provenance expr)) = do
 
35
    -- Work out what the full target of this annotation was
 
36
    mod <- getModule
 
37
    let target = annProvenanceToTarget mod provenance
 
38
    
 
39
    -- Run that annotation and construct the full Annotation data structure
 
40
    setSrcSpan loc $ addErrCtxt (annCtxt ann) $ addExprErrCtxt expr $ runAnnotation target expr
 
41
 
 
42
annProvenanceToTarget :: Module -> AnnProvenance Name -> AnnTarget Name
 
43
annProvenanceToTarget _   (ValueAnnProvenance name) = NamedTarget name
 
44
annProvenanceToTarget _   (TypeAnnProvenance name)  = NamedTarget name
 
45
annProvenanceToTarget mod ModuleAnnProvenance       = ModuleTarget mod
 
46
 
 
47
annCtxt :: OutputableBndr id => LAnnDecl id -> SDoc
 
48
annCtxt ann
 
49
  = hang (ptext (sLit "In the annotation:")) 2 (ppr ann)
 
50
#endif
 
51
\end{code}
 
 
b'\\ No newline at end of file'