git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: some naming cleanup
commit28a5981e659fbd016496d7cc16bc15edb75506fa authorAndy Arvanitis <andyarvanitis@gmail.com> dateThu 10 Nov 2016, 20:13 (10 years ago) parenta9fe668
1 file changed+28−28
src/Language/PureScript/CodeGen/Cpp.hs+28−28
src/Language/PureScript/CodeGen/Cpp.hs+28−28
@@ -142,26 +142,26 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
142142 let args'' = zip argNames (repeat aty)
143143 if isTypeClassMember
144144 then do -- typeclass member functions are stored curried
145− body' <- nestedLambdas . optimizeIndexers classes <$> valueToCpp (snd abs')
145+ body' <- innerLambdas . optIndexers classes <$> valueToCpp (snd abs')
146146 return $ CppNamespace ""
147147 [ CppFunction
148148 (curriedName name)
149149 [arg']
150150 rty
151151 [Inline]
152− (asReturnBlock body')
152+ (returnBlock body')
153153 , CppFunction
154154 name
155155 (arg' : args' ++ args'')
156156 rty
157157 (vqs ++ if isAccessor (snd abs') then [Inline] else [])
158− (asReturnBlock $
158+ (returnBlock $
159159 foldl (\fn a -> CppApp fn [a])
160160 body'
161161 (CppVar . fst <$> (args' ++ args'')))
162162 ]
163163 else do
164− body' <- nestedLambdas . optimizeIndexers classes <$> valueToCpp
164+ body' <- innerLambdas . optIndexers classes <$> valueToCpp
165165 (if null argNames
166166 then snd abs'
167167 else curriedApp
@@ -176,26 +176,26 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
176176 (arg' : args' ++ args'')
177177 rty
178178 (vqs ++ if isAccessor (snd abs') then [Inline] else [])
179− (asReturnBlock body')
179+ (returnBlock body')
180180 , CppFunction
181181 (curriedName name)
182182 [arg']
183183 rty
184184 (if arity' == 1 then [Inline] else [])
185− (asReturnBlock $
185+ (returnBlock $
186186 curriedLambda
187187 (fst <$> args' ++ args'')
188188 (CppApp (CppVar name)
189189 (CppVar . fst <$> (arg' : args' ++ args''))))
190190 ]
191191 else do
192− body' <- nestedLambdas . optimizeIndexers classes <$> valueToCpp body
192+ body' <- innerLambdas . optIndexers classes <$> valueToCpp body
193193 return $ CppFunction
194194 name
195195 [arg']
196196 rty
197197 (vqs ++ if isIndexer body' then [Inline] else [])
198− (asReturnBlock body')
198+ (returnBlock body')
199199 return (CppComment com $ convertIfPrimFn ty' fn)
200200 where
201201 ty' | Just t <- ty = Just t
@@ -226,7 +226,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
226226 []
227227 (Just $ Any [])
228228 [Inline]
229− (asReturnBlock $
229+ (returnBlock $
230230 CppDataLiteral [CppAccessor (CppVar $ identToCpp ident) (CppVar "data")])
231231
232232 declToCpp _ (_, ident) (Constructor _ _ (ProperName _) fields) =
@@ -236,7 +236,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
236236 (farg <$> fields')
237237 (Just $ Any [])
238238 [Inline]
239− (asReturnBlock $
239+ (returnBlock $
240240 CppDataLiteral $
241241 CppAccessor (CppVar name) (CppVar "data") : (CppVar <$> fields'))
242242 ] ++
@@ -281,7 +281,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
281281 [(head argNames, Just $ Any [Const, Ref])]
282282 rty
283283 []
284− (asReturnBlock $
284+ (returnBlock $
285285 curriedLambda
286286 (tail argNames)
287287 (CppApp (CppVar name)
@@ -292,7 +292,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
292292 (zip argNames $ repeat aty)
293293 rty
294294 []
295− (asReturnBlock body')
295+ (returnBlock body')
296296 ] ++ if arity' > 0
297297 then [fn']
298298 else []
@@ -333,9 +333,9 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
333333 fnToLambda _ = error "Not a function!"
334334
335335 -------------------------------------------------------------------------------------------------
336− nestedLambdas :: Cpp -> Cpp
336+ innerLambdas :: Cpp -> Cpp
337337 -------------------------------------------------------------------------------------------------
338− nestedLambdas = everywhereOnCpp go
338+ innerLambdas = everywhereOnCpp go
339339 where
340340 go :: Cpp -> Cpp
341341 go f@(CppFunction {}) = maybeRemCaps $ fnToLambda f
@@ -420,7 +420,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
420420 [CaptureAll]
421421 [(localdict, Just $ Any [Const, Ref])]
422422 (Just $ Any [])
423− (asReturnBlock cpp')
423+ (returnBlock cpp')
424424 topdict :: String
425425 topdict = "_$dict$_"
426426 localdict :: String
@@ -487,13 +487,13 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
487487
488488 valueToCpp (Abs (_, _, ty, _) arg body) = do
489489 cpp <- valueToCpp body
490− let cpp' = nestedLambdas cpp
490+ let cpp' = innerLambdas cpp
491491 return $
492492 CppLambda
493493 []
494494 [(identToCpp arg, Just $ Any [Const, Ref])]
495495 (Just $ Any [])
496− (asReturnBlock $ optimizeIndexers classes cpp')
496+ (returnBlock $ optIndexers classes cpp')
497497 where
498498 arg' = identToCpp arg
499499 args' = identToCpp <$> (fst $ unAbs body [])
@@ -528,7 +528,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
528528 let rs = if hasRecursion ds''
529529 then convertRecursiveFns ds'' ret
530530 else ds''
531− let cpps = nestedLambdas <$> rs
531+ let cpps = innerLambdas <$> rs
532532 return $ CppApp
533533 (CppLambda [] [] Nothing (CppBlock (cpps ++ [CppReturn ret])))
534534 []
@@ -609,7 +609,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
609609 guardsToCpp (Left gs) = forM gs $ \(cond, val) -> do
610610 cond' <- valueToCpp cond
611611 done <- valueToCpp val
612− return $ CppIfElse cond' (asReturnBlock done) Nothing
612+ return $ CppIfElse cond' (returnBlock done) Nothing
613613 guardsToCpp (Right v) = return . CppReturn <$> valueToCpp v
614614
615615 -- |
@@ -842,7 +842,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
842842 [(head argNames, Just $ Any [Const, Ref])]
843843 (Just $ Any [])
844844 (if arity' == 1 then [Inline] else [])
845− (asReturnBlock $
845+ (returnBlock $
846846 curriedLambda
847847 (tail argNames)
848848 (CppApp (CppVar name)
@@ -856,9 +856,9 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
856856 M.toList $ E.names env
857857
858858---------------------------------------------------------------------------------------------------
859−asReturnBlock :: Cpp -> Cpp
859+returnBlock :: Cpp -> Cpp
860860---------------------------------------------------------------------------------------------------
861−asReturnBlock cpp = CppBlock [CppReturn cpp]
861+returnBlock cpp = CppBlock [CppReturn cpp]
862862
863863---------------------------------------------------------------------------------------------------
864864curriedLambda :: [String] -> Cpp -> Cpp
@@ -867,7 +867,7 @@ curriedLambda args ret = foldr (\arg ret' -> CppLambda
867867 [CaptureAll]
868868 [(arg, Just $ Any [Const, Ref])]
869869 (Just $ Any [])
870− (asReturnBlock ret')
870+ (returnBlock ret')
871871 ) ret args
872872
873873---------------------------------------------------------------------------------------------------
@@ -900,9 +900,9 @@ extractConstraints = go []
900900 go cs _ = cs
901901
902902---------------------------------------------------------------------------------------------------
903−optimizeIndexers :: [(Cpp,Cpp)] -> Cpp -> Cpp
903+optIndexers :: [(Cpp,Cpp)] -> Cpp -> Cpp
904904---------------------------------------------------------------------------------------------------
905−optimizeIndexers classes = everywhereOnCpp dictIndexerToEnum
905+optIndexers classes = everywhereOnCpp dictIndexerToEnum
906906 where
907907 dictIndexerToEnum :: Cpp -> Cpp
908908 dictIndexerToEnum (CppIndexer (CppSymbol prop) dict)
@@ -965,10 +965,10 @@ allSymbols cpps = nub $ concatMap (everythingOnCpp (++) symbols) cpps
965965symbolDefs :: [String] -> Cpp
966966---------------------------------------------------------------------------------------------------
967967symbolDefs [] = CppNoOp
968−symbolDefs syms = CppNamespace "PureScript" [CppNamespace "symbol" (asFunc <$> syms)]
968+symbolDefs syms = CppNamespace "PureScript" [CppNamespace "symbol" (asStruct <$> syms)]
969969 where
970− asFunc :: String -> Cpp
971− asFunc s = CppStruct s []
970+ asStruct :: String -> Cpp
971+ asStruct s = CppStruct s []
972972
973973---------------------------------------------------------------------------------------------------
974974filterInlineFuncs :: Cpp -> Cpp