git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: more cases for optimizing accessors for typeclass dicts
a5bc8dcAndy Arvanitis
src/Language/PureScript/CodeGen/Cpp.hs+9−2
@@ -426,7 +426,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
426
426
427 valueToCpp (ObjectUpdate _ _ _) = error $ "Bad Type in object update!"
427 valueToCpp (ObjectUpdate _ _ _) = error $ "Bad Type in object update!"
428
428
429− valueToCpp (Abs _ arg body) = do
429+ valueToCpp (Abs (_, _, ty, _) arg body) = do
430 cpp <- valueToCpp body
430 cpp <- valueToCpp body
431 let cpp' = convertNestedLambdas cpp
431 let cpp' = convertNestedLambdas cpp
432 return $
432 return $
@@ -434,7 +434,14 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
434 []
434 []
435 [(identToCpp arg, Just $ CppAny [CppConst, CppRef])]
435 [(identToCpp arg, Just $ CppAny [CppConst, CppRef])]
436 (Just $ CppAny [])
436 (Just $ CppAny [])
437− (asReturnBlock cpp')
437+ (asReturnBlock $ convertDictIndexers cpp')
438+ where
439+ arg' = identToCpp arg
440+ args' = identToCpp <$> (fst $ unAbs body [])
441+ classes = qualifiedToCpp (Ident . runProperName) . fst <$>
442+ maybe [] extractConstraints ty
443+ dictClasses = zip (CppVar <$> arg' : args') classes
444+ convertDictIndexers = everywhereOnCpp (dictIndexerToEnum dictClasses)
438 valueToCpp e@App{} = do
445 valueToCpp e@App{} = do
439 let (f, args) = unApp e []
446 let (f, args) = unApp e []
440 args' <- mapM valueToCpp args
447 args' <- mapM valueToCpp args