@@ -4,7 +4,6 @@
44module Language.PureScript.CodeGen.JS.Optimizer.Inliner
55 ( inlineVariables
66 , inlineCommonValues
7− , inlineOperator
87 , inlineCommonOperators
98 , inlineFnComposition
109 , etaConvert
@@ -100,13 +99,13 @@ inlineCommonValues = everywhereOnJS convert
10099 fnSubtract = (C.dataRing, C.sub)
101100 intOp ss op x y = JSBinary ss BitwiseOr (JSBinary ss op x y) (JSNumericLiteral ss (Left 0))
102101
103−inlineOperator :: (String, String) -> (JS -> JS -> JS) -> JS -> JS
104−inlineOperator (m, op) f = everywhereOnJS convert
102+inlineNonClassFunction :: (String, String) -> (JS -> JS -> JS) -> JS -> JS
103+inlineNonClassFunction (m, op) f = everywhereOnJS convert
105104 where
106105 convert :: JS -> JS
107106 convert (JSApp _ (JSApp _ op' [x]) [y]) | isOp op' = f x y
108107 convert other = other
109− isOp (JSIndexer _ (JSStringLiteral _ op') (JSVar _ m')) = m == m' && op == op'
108+ isOp (JSAccessor _ op' (JSVar _ m')) = m == m' && op == op'
110109 isOp _ = False
111110
112111inlineCommonOperators :: JS -> JS
@@ -167,6 +166,10 @@ inlineCommonOperators = applyAll $
167166 , binary' C.dataIntBits C.shr ShiftRight
168167 , binary' C.dataIntBits C.zshr ZeroFillShiftRight
169168 , unary' C.dataIntBits C.complement BitwiseNot
169+
170+ , inlineNonClassFunction (C.dataFunction, C.apply) $ \f x -> JSApp Nothing f [x]
171+ , inlineNonClassFunction (C.dataFunction, C.applyFlipped) $ \x f -> JSApp Nothing f [x]
172+ , inlineNonClassFunction (C.dataArrayUnsafe, C.unsafeIndex) $ flip (JSIndexer Nothing)
170173 ] ++
171174 [ fn | i <- [0..10], fn <- [ mkFn i, runFn i ] ]
172175 where