@@ -8,6 +8,7 @@ Maintainer : The Idris Community.
88{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, StandaloneDeriving #-}
99
1010module IRTS.JavaScript.LangTransforms( removeDeadCode
11+ , globlToCon
1112 ) where
1213
1314
@@ -94,3 +95,15 @@ removeDeadCode dcls start =
9495 remCons = removeUnusedBranches (getUsedConstructors used) used
9596 in if Map.keys remCons == Map.keys dcls then remCons
9697 else removeDeadCode remCons start
98+
99+
100+globlToCon :: Map Name LDecl -> Map Name LDecl
101+globlToCon x =
102+ transformBi (f x) x
103+ where
104+ f :: Map Name LDecl -> LExp -> LExp
105+ f y x@(LV (Glob n)) =
106+ case Map.lookup n y of
107+ Just (LConstructor _ conId arity) -> LCon Nothing conId n []
108+ _ -> x
109+ f y x = x