Permalink
Browse files

Intraprocedural blocks start with ENTER

  • Loading branch information...
Arjun Guha
Arjun Guha committed Mar 13, 2009
1 parent 654a473 commit bff58b7dc8104a5e92783eb779989913ec8d8cef
Showing with 9 additions and 5 deletions.
  1. +1 −1 src/WebBits/JavaScript/Core.hs
  2. +8 −4 src/WebBits/JavaScript/Intraprocedural.hs
@@ -169,7 +169,7 @@ instance Functor Stmt where
instance Show (Stmt a) where
show stmt = case stmt of
SeqStmt a ss -> "Seq ..."
- EmptyStmt a -> "No-op ..."
+ EmptyStmt a -> "No-op"
AssignStmt a v e -> v ++ " := ..."
DeleteStmt a v1 v2 -> printf "%s := delete ..." v1
NewStmt a result constr args ->
@@ -168,13 +168,17 @@ intraprocGraph enterPos exitPos body = (full,graph) where
-- Small trick to turn the EnterStmt and the body into a single numbered
-- statement. It's always safe to add/remove additional enclosing blocks.
- body' = SeqStmt noPos [SeqStmt noPos [EnterStmt enterPos, body],
- ExitStmt exitPos]
- full@(SeqStmt _ [labelledBody,labelledExitStmt]) = numberStmts body'
+ body' = SeqStmt noPos [EnterStmt enterPos, body, ExitStmt exitPos]
+ full@(SeqStmt _ [labelledEnterStmt,labelledBody,labelledExitStmt]) =
+ numberStmts body'
exitNode = stmtToNode labelledExitStmt
+ enterNode = stmtToNode labelledEnterStmt
+
initialGraph :: Gr (Stmt (Int,SourcePos)) ()
- initialGraph = G.insNode exitNode G.empty
+ initialGraph = G.insEdge (fst enterNode,fst $ stmtLabel labelledBody,()) $
+ G.insNode enterNode $
+ G.insNode exitNode G.empty
graph = execState
(stmt (initStack labelledExitStmt)

0 comments on commit bff58b7

Please sign in to comment.