ROSE 0.11.145.147
CxxGenerator.h
1#ifndef Rosebud_CxxGenerator_H
2#define Rosebud_CxxGenerator_H
3#include <Rosebud/Generator.h>
4
5namespace Rosebud {
6
8class CxxGenerator: public Generator {
9protected:
10 size_t outputWidth = 130; // nominal width of the generated code
11
12protected:
14 virtual std::string machineGenerated(char commentType = '/');
15
42 virtual std::string ctorInitializerExpression(const Ast::PropertyPtr&, const std::string &expr);
43
50 virtual std::string resetStatement(const Ast::PropertyPtr&);
51
55 virtual std::string propertyDataMemberType(const Ast::PropertyPtr&);
56
60 virtual std::string propertyAccessorReturnType(const Ast::PropertyPtr&);
61
65 virtual std::string propertyMutatorArgumentType(const Ast::PropertyPtr&);
66
70 virtual std::string initialValue(const Ast::PropertyPtr&);
71
89 virtual std::string valueType(const Ast::PropertyPtr&);
90
92 virtual void genDestructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&);
93
95 virtual void genDefaultConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&, Access);
96
100 virtual bool genArgsConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&, const Hierarchy&, Access);
101
103 virtual void genConstructorBody(std::ostream&, const Ast::ClassPtr&);
104
106 virtual void genInitProperties(std::ostream &header, std::ostream &impl, const Ast::ClassPtr&);
107
116 virtual std::string removePointer(const std::string&) const;
117};
118
119} // namespace
120#endif
Base class for generators that produce C++ code.
Definition CxxGenerator.h:8
virtual void genInitProperties(std::ostream &header, std::ostream &impl, const Ast::ClassPtr &)
Emit code that initializes all local properties.
virtual std::string initialValue(const Ast::PropertyPtr &)
Initial value expression for the property.
virtual void genDefaultConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr &, Access)
Emit code for the class default constructor.
virtual std::string propertyMutatorArgumentType(const Ast::PropertyPtr &)
Type for the argument for a property mutator.
virtual std::string ctorInitializerExpression(const Ast::PropertyPtr &, const std::string &expr)
Expression for initializing a property in a constructor, or empty.
virtual void genConstructorBody(std::ostream &, const Ast::ClassPtr &)
Emit code for the constructor body.
virtual std::string valueType(const Ast::PropertyPtr &)
Type of value for initializing a property.
virtual std::string machineGenerated(char commentType='/')
Return a title comment that says the file is machine generated.
virtual bool genArgsConstructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr &, const Hierarchy &, Access)
Emit code for the constructor with ctor_args property arguments.
virtual void genDestructor(std::ostream &header, std::ostream &impl, const Ast::ClassPtr &)
Emit code for the class destructor.
virtual std::string propertyDataMemberType(const Ast::PropertyPtr &)
Type for the data member for a property.
virtual std::string removePointer(const std::string &) const
Given a type name, remove the outer pointer if present.
virtual std::string resetStatement(const Ast::PropertyPtr &)
Statement to initialize a property.
virtual std::string propertyAccessorReturnType(const Ast::PropertyPtr &)
Type for the return value for a property accessor.
Base class for backend code generators.
Definition Generator.h:10
Graph containing user-defined vertices and edges.
Definition Graph.h:634
std::shared_ptr< Class > ClassPtr
Shared-ownership pointer to a Class.
std::shared_ptr< Property > PropertyPtr
Shared-ownership pointer to a Property.
Rosebud is a tool to generate abstract syntax trees.
Definition Ast.h:14
Access
Kinds of access.
Definition ud/Utility.h:20