Skip to content

Commit dd0751f

Browse files
committed
Ported the analysis to the new lens interface of annotations
1 parent dfb4140 commit dd0751f

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

language-ecmascript-analysis.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Library
3636
, uniplate >= 1.6 && < 1.7
3737
, parsec >= 3 && < 4
3838
, containers >= 0.1 && < 0.6
39+
, lens-simple
3940
hs-source-dirs:
4041
src
4142
exposed-modules:

src/Language/ECMAScript5/Analysis/LabelSet.hs

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Data.Generics.Uniplate.Data
1414
import Data.Data (Data)
1515
import Control.Applicative
1616
import Data.Typeable (Typeable)
17+
import Lens.Simple
1718

1819
-- | Labels are either strings (identifiers) or /empty/ (see 12.12 of
1920
-- the spec)
@@ -81,14 +82,14 @@ annotateStatement :: Data a =>
8182
annotateStatement r w s = case s of
8283
LabelledStmt ann lab stmt ->
8384
let labelset = Set.insert (id2Label lab) (r ann)
84-
newstmt = annotateStatement r w $ withAnnotation (w labelset) stmt
85+
newstmt = annotateStatement r w $ stmt&annotation %~ w labelset
8586
in LabelledStmt ann lab newstmt
8687
SwitchStmt {} ->
8788
let labelset = Set.insert EmptyLabel (r $ getAnnotation s)
88-
in descend (annotateStatement r w) $ withAnnotation (w labelset) s
89+
in descend (annotateStatement r w) $ s&annotation %~ w labelset
8990
_ | isIterationStmt s ->
9091
let labelset = Set.insert EmptyLabel (r $ getAnnotation s)
91-
in descend (annotateStatement r w) (withAnnotation (w labelset) s)
92+
in descend (annotateStatement r w) (s&annotation %~ w labelset)
9293
_ -> descend (annotateStatement r w) s
9394

9495
id2Label :: Id a -> Label

0 commit comments

Comments
 (0)