git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Clean up comments
4198e2bAndy Arvanitis
src/CodeGen/Cpp.hs+12−12
@@ -41,7 +41,7 @@ import CodeGen.Cpp.Printer
41
41
42data DeclType = ModuleDecl | LetDecl | RecLetDecl deriving (Eq)
42data DeclType = ModuleDecl | LetDecl | RecLetDecl deriving (Eq)
43
43
44−-- | Generate code in the simplified Objective-C intermediate representation for all declarations in a
44+-- | Generate code in the simplified intermediate representation for all declarations in a
45-- module.
45-- module.
46moduleToCpp
46moduleToCpp
47 :: forall m
47 :: forall m
@@ -93,7 +93,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
93 then freshModuleName (i + 1) mn' used
93 then freshModuleName (i + 1) mn' used
94 else newName
94 else newName
95
95
96− -- | Generates Objective-C code for a module import, binding the required module
96+ -- | Generates C++ code for a module import, binding the required module
97 -- to the alternative
97 -- to the alternative
98 importToCpp :: M.Map ModuleName (Ann, ModuleName) -> ModuleName -> m Text
98 importToCpp :: M.Map ModuleName (Ann, ModuleName) -> ModuleName -> m Text
99 importToCpp mnLookup mn' = do
99 importToCpp mnLookup mn' = do
@@ -121,7 +121,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
121 renameQual q = q
121 renameQual q = q
122
122
123 -- |
123 -- |
124− -- Generate code in the simplified Objective-C intermediate representation for a declaration
124+ -- Generate code in the simplified intermediate representation for a declaration
125 --
125 --
126 bindToCpp :: DeclType -> Bind Ann -> m [AST]
126 bindToCpp :: DeclType -> Bind Ann -> m [AST]
127 bindToCpp dt (NonRec ann ident val) = return <$> nonRecToCpp dt ann ident val
127 bindToCpp dt (NonRec ann ident val) = return <$> nonRecToCpp dt ann ident val
@@ -129,7 +129,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
129 where
129 where
130 dt' = if dt == LetDecl then RecLetDecl else dt
130 dt' = if dt == LetDecl then RecLetDecl else dt
131
131
132− -- | Generate code in the simplified Objective-C intermediate representation for a single non-recursive
132+ -- | Generate code in the simplified intermediate representation for a single non-recursive
133 -- declaration.
133 -- declaration.
134 --
134 --
135 -- The main purpose of this function is to handle code generation for comments.
135 -- The main purpose of this function is to handle code generation for comments.
@@ -166,13 +166,13 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
166 cpp <- valueToCpp val
166 cpp <- valueToCpp val
167 pure $ AST.VariableIntroduction Nothing (identToCpp ident) (Just cpp)
167 pure $ AST.VariableIntroduction Nothing (identToCpp ident) (Just cpp)
168
168
169− -- | Generate code in the simplified Objective-C intermediate representation for a variable based on a
169+ -- | Generate code in the simplified intermediate representation for a variable based on a
170 -- PureScript identifier.
170 -- PureScript identifier.
171 var :: Ident -> AST
171 var :: Ident -> AST
172 var = AST.Var Nothing . identToCpp
172 var = AST.Var Nothing . identToCpp
173
173
174− -- | Generate code in the simplified Objective-C intermediate representation for an accessor based on
174+ -- | Generate code in the simplified intermediate representation for an accessor based on
175− -- a PureScript identifier. If the name is not valid in Objective-C (symbol based, reserved name) an
175+ -- a PureScript identifier. If the name is not valid in C++ (symbol based, reserved name) an
176 -- indexer is returned.
176 -- indexer is returned.
177 accessor :: Ident -> AST -> AST
177 accessor :: Ident -> AST -> AST
178 accessor (Ident prop) = accessorString $ mkString prop
178 accessor (Ident prop) = accessorString $ mkString prop
@@ -182,7 +182,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
182 accessorString :: PSString -> AST -> AST
182 accessorString :: PSString -> AST -> AST
183 accessorString prop = AST.Indexer Nothing (AST.StringLiteral Nothing prop)
183 accessorString prop = AST.Indexer Nothing (AST.StringLiteral Nothing prop)
184
184
185− -- | Generate code in the simplified Objective-C intermediate representation for a value or expression.
185+ -- | Generate code in the simplified intermediate representation for a value or expression.
186
186
187 valueToCpp :: Expr Ann -> m AST
187 valueToCpp :: Expr Ann -> m AST
188 valueToCpp (Literal (pos, _, _, _) l) = literalToValueCpp pos l
188 valueToCpp (Literal (pos, _, _, _) l) = literalToValueCpp pos l
@@ -266,13 +266,13 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
266 literalToValueCpp ss (ArrayLiteral xs) = AST.ArrayLiteral (Just ss) <$> mapM valueToCpp xs
266 literalToValueCpp ss (ArrayLiteral xs) = AST.ArrayLiteral (Just ss) <$> mapM valueToCpp xs
267 literalToValueCpp ss (ObjectLiteral ps) = AST.ObjectLiteral (Just ss) <$> mapM (sndM valueToCpp) ps
267 literalToValueCpp ss (ObjectLiteral ps) = AST.ObjectLiteral (Just ss) <$> mapM (sndM valueToCpp) ps
268
268
269− -- | Generate code in the simplified Objective-C intermediate representation for a reference to a
269+ -- | Generate code in the simplified intermediate representation for a reference to a
270 -- variable.
270 -- variable.
271 varToCpp :: Qualified Ident -> AST
271 varToCpp :: Qualified Ident -> AST
272 varToCpp (Qualified Nothing ident) = var ident
272 varToCpp (Qualified Nothing ident) = var ident
273 varToCpp qual = qualifiedToCpp id qual
273 varToCpp qual = qualifiedToCpp id qual
274
274
275− -- | Generate code in the simplified Objective-C intermediate representation for a reference to a
275+ -- | Generate code in the simplified intermediate representation for a reference to a
276 -- variable that may have a qualified name.
276 -- variable that may have a qualified name.
277 qualifiedToCpp :: (a -> Ident) -> Qualified a -> AST
277 qualifiedToCpp :: (a -> Ident) -> Qualified a -> AST
278 qualifiedToCpp f (Qualified (Just (ModuleName [ProperName mn'])) a) | mn' == C.prim = AST.Var Nothing . runIdent $ f a
278 qualifiedToCpp f (Qualified (Just (ModuleName [ProperName mn'])) a) | mn' == C.prim = AST.Var Nothing . runIdent $ f a
@@ -282,7 +282,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
282 -- foreignIdent :: Ident -> AST
282 -- foreignIdent :: Ident -> AST
283 -- foreignIdent ident = accessorString (mkString $ runIdent ident) (AST.Var Nothing "$foreign")
283 -- foreignIdent ident = accessorString (mkString $ runIdent ident) (AST.Var Nothing "$foreign")
284
284
285− -- | Generate code in the simplified Objective-C intermediate representation for pattern match binders
285+ -- | Generate code in the simplified intermediate representation for pattern match binders
286 -- and guards.
286 -- and guards.
287 bindersToCpp :: SourceSpan -> [CaseAlternative Ann] -> [AST] -> m AST
287 bindersToCpp :: SourceSpan -> [CaseAlternative Ann] -> [AST] -> m AST
288 bindersToCpp ss binders vals = do
288 bindersToCpp ss binders vals = do
@@ -315,7 +315,7 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
315
315
316 guardsToCpp (Right v) = return . AST.Return Nothing <$> valueToCpp v
316 guardsToCpp (Right v) = return . AST.Return Nothing <$> valueToCpp v
317
317
318− -- | Generate code in the simplified Objective-C intermediate representation for a pattern match
318+ -- | Generate code in the simplified intermediate representation for a pattern match
319 -- binder.
319 -- binder.
320 binderToCpp :: Text -> [AST] -> Binder Ann -> m [AST]
320 binderToCpp :: Text -> [AST] -> Binder Ann -> m [AST]
321 binderToCpp _ done NullBinder{} = return done
321 binderToCpp _ done NullBinder{} = return done