git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
C++: handle '__unused' vars better
564dab5Andy Arvanitis
src/Language/PureScript/Pretty/Cpp.hs+4−4
@@ -130,6 +130,7 @@ literals = mkPattern' match
130 , currentIndent
130 , currentIndent
131 , return "}"
131 , return "}"
132 ]
132 ]
133+
133 match (CppFunction name args rty qs ret) =
134 match (CppFunction name args rty qs ret) =
134 fmap concat $ sequence
135 fmap concat $ sequence
135 [ return . concatMap (++ " ") . filter (not . null) $ runValueQual <$> qs
136 [ return . concatMap (++ " ") . filter (not . null) $ runValueQual <$> qs
@@ -237,12 +238,11 @@ literals = mkPattern' match
237 val' | '(' `elem` vstr || '[' `elem` vstr = parens vstr
238 val' | '(' `elem` vstr || '[' `elem` vstr = parens vstr
238 | otherwise = vstr
239 | otherwise = vstr
239
240
241+ match (CppVar ident) | ident == C.__unused = match (CppVar $ '_':ident)
240 match (CppVar ident) = return ident
242 match (CppVar ident) = return ident
241 match (CppApp v [CppNoOp]) = return (prettyPrintCpp1 v)
243 match (CppApp v [CppNoOp]) = return (prettyPrintCpp1 v)
242− match (CppVariableIntroduction (ident, _) _ (Just value))
244+ match (CppVariableIntroduction (ident, typ) qs value)
243− | ident == C.__unused = fmap concat $ sequence
245+ | ident == C.__unused = match (CppVariableIntroduction ('_':ident, typ) qs value)
244− [ prettyPrintCpp' value
245− ]
246 match (CppVariableIntroduction (ident, typ) qs value) =
246 match (CppVariableIntroduction (ident, typ) qs value) =
247 fmap concat $ sequence
247 fmap concat $ sequence
248 [ return . concatMap (++ " ") . filter (not . null) $ runValueQual <$> qs
248 [ return . concatMap (++ " ") . filter (not . null) $ runValueQual <$> qs