@@ -633,33 +633,11 @@ inlineFunctions js =
635 inlineAble :: Int -> String -> [String] -> JS -> Maybe JS
635 inlineAble :: Int -> String -> [String] -> JS -> Maybe JS
636− inlineAble 1 fun args body
636+ inlineAble 1 fun args (JSReturn body)
637 | nonRecur fun body =
637 | nonRecur fun body =
638− inlineAble' body
638+ if all (<= 1) (map ($ body) (map countIDOccurences args))
639− where
639+ then Just body
640− inlineAble' :: JS -> Maybe JS
642− JSReturn js@(JSNew "__IDRRT__Con" [JSNum _, JSArray vals])
644− | and $ map (\x -> isJSIdent x || isJSConstant x) vals = Just js
647− JSReturn js@(JSNew "__IDRRT__Cont" [JSFunction [] (
648− JSReturn (JSApp (JSIdent _) args)
651− | and $ map (\x -> isJSIdent x || isJSConstant x) args = Just js
654− JSReturn js@(JSIndex (JSProj (JSApp (JSIdent _) args) "vars") _)
656− | and $ map (\x -> isJSIdent x || isJSConstant x) args = Just js
658− inlineAble' _ = Nothing
640+ else Nothing
661− | JSIdent _ <- js = True
664 inlineAble _ _ _ _ = Nothing
642 inlineAble _ _ _ _ = Nothing
@@ -695,6 +673,16 @@ inlineFunctions js =
695 countAll name js = sum $ map (countInvokations name) js
673 countAll name js = sum $ map (countInvokations name) js
676+ countIDOccurences :: String -> JS -> Int
677+ countIDOccurences name = foldJS match (+) 0
681+ | JSIdent ident <- js
698 countInvokations :: String -> JS -> Int
686 countInvokations :: String -> JS -> Int
699 countInvokations name = foldJS match (+) 0
687 countInvokations name = foldJS match (+) 0