ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnc::ArtifactGeneratorCppDecl Class Reference

The ACL C++ artifact header file producer. More...

#include <ArtifactGeneratorCppDecl.h>

Collaboration diagram for nnc::ArtifactGeneratorCppDecl:

Public Member Functions

 ArtifactGeneratorCppDecl (std::ostream &out)
 
void visit (const ArtifactLiteral *node) override
 
void visit (const ArtifactId *node) override
 
void visit (const ArtifactRef *node) override
 
void visit (const ArtifactDeref *node) override
 
void visit (const ArtifactVariable *node) override
 
void visit (const ArtifactFunctionCall *node) override
 
void visit (const ArtifactUnaryExpr *node) override
 
void visit (const ArtifactBinaryExpr *node) override
 
void visit (const ArtifactIndex *node) override
 
void visit (const ArtifactRet *node) override
 
void visit (const ArtifactBreak *node) override
 
void visit (const ArtifactCont *node) override
 
void visit (const ArtifactBlock *node) override
 
void visit (const ArtifactForLoop *node) override
 
void visit (const ArtifactIf *node) override
 
void visit (const ArtifactFunction *node) override
 
void visit (const ArtifactClass *node) override
 
void visit (const ArtifactClassVariable *node) override
 
void visit (const ArtifactClassFunction *node) override
 
void visit (const ArtifactModule *node) override
 
- Public Member Functions inherited from nnc::IArtifactGenerator
virtual ~IArtifactGenerator ()=default
 

Detailed Description

The ACL C++ artifact header file producer.

Definition at line 31 of file ArtifactGeneratorCppDecl.h.

Constructor & Destructor Documentation

◆ ArtifactGeneratorCppDecl()

nnc::ArtifactGeneratorCppDecl::ArtifactGeneratorCppDecl ( std::ostream &  out)
explicit

Definition at line 27 of file ArtifactGeneratorCppDecl.cpp.

27: _out(out) {}

Member Function Documentation

◆ visit() [1/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactBinaryExpr node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 54 of file ArtifactGeneratorCppDecl.cpp.

54{}

◆ visit() [2/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactBlock node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 64 of file ArtifactGeneratorCppDecl.cpp.

64{}

◆ visit() [3/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactBreak node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 60 of file ArtifactGeneratorCppDecl.cpp.

60{}

◆ visit() [4/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactClass node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 88 of file ArtifactGeneratorCppDecl.cpp.

89{
90 _out << "class " << node->name() << " {" << endl;
91 _out << "public:" << endl;
92 ++_ind;
93
94 // Generate a public default constructor here.
95 _out << _ind << node->name() << "();" << endl;
96
97 // Then generate the other stuff.
98
99 for (const auto &e : node->publicFunctions())
100 {
101 _out << _ind;
102 e->accept(this);
103 }
104
105 _out << endl << "private:" << endl;
106
107 for (const auto &e : node->privateFunctions())
108 {
109 _out << _ind;
110 e->accept(this);
111 }
112
113 if (!node->privateFunctions().empty())
114 _out << endl;
115
116 // TODO add public variables
117
118 for (const auto &e : node->privateVariables())
119 {
120 _out << _ind;
121 e->accept(this);
122 }
123
124 --_ind;
125 _out << "};" << endl;
126}

References nnc::ArtifactNamed::name(), nnc::ArtifactClass::privateFunctions(), nnc::ArtifactClass::privateVariables(), and nnc::ArtifactClass::publicFunctions().

◆ visit() [5/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactClassFunction node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 133 of file ArtifactGeneratorCppDecl.cpp.

134{
135 _out << node->getRetTypeName();
136
137 if (!node->getRetTypeName().empty())
138 _out << " ";
139
140 _out << node->name() << "(";
141 bool add_comma = false;
142
143 for (const auto &p : node->getParameters())
144 {
145 if (add_comma)
146 _out << ", ";
147
148 p->accept(this);
149 add_comma = true;
150 }
151
152 _out << ");" << endl;
153}

References nnc::ArtifactFunction::getParameters(), nnc::ArtifactFunction::getRetTypeName(), and nnc::ArtifactNamed::name().

◆ visit() [6/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactClassVariable node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 128 of file ArtifactGeneratorCppDecl.cpp.

129{
130 _out << node->typeName() << " " << node->name() << ";" << endl;
131}

References nnc::ArtifactNamed::name(), and nnc::ArtifactVariable::typeName().

◆ visit() [7/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactCont node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 62 of file ArtifactGeneratorCppDecl.cpp.

62{}

◆ visit() [8/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactDeref node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 39 of file ArtifactGeneratorCppDecl.cpp.

40{
41 _out << "*";
42 node->obj()->accept(this);
43}

References nnc::ArtifactDeref::obj().

◆ visit() [9/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactForLoop node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 66 of file ArtifactGeneratorCppDecl.cpp.

66{}

◆ visit() [10/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactFunction node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 70 of file ArtifactGeneratorCppDecl.cpp.

71{
72 _out << node->getRetTypeName() << " " << node->name() << "(";
73
74 bool add_comma = false;
75
76 for (const auto &par : node->getParameters())
77 {
78 if (add_comma)
79 _out << ", ";
80
81 par->accept(this);
82 add_comma = true;
83 }
84
85 _out << ");";
86}

References nnc::ArtifactFunction::getParameters(), nnc::ArtifactFunction::getRetTypeName(), and nnc::ArtifactNamed::name().

◆ visit() [11/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactFunctionCall node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 50 of file ArtifactGeneratorCppDecl.cpp.

50{}

◆ visit() [12/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactId node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 31 of file ArtifactGeneratorCppDecl.cpp.

31{ _out << node->name(); }

References nnc::ArtifactId::name().

◆ visit() [13/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactIf node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 68 of file ArtifactGeneratorCppDecl.cpp.

68{}

◆ visit() [14/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactIndex node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 56 of file ArtifactGeneratorCppDecl.cpp.

56{}

◆ visit() [15/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactLiteral node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 29 of file ArtifactGeneratorCppDecl.cpp.

29{ _out << node->getValue(); }

References nnc::ArtifactLiteral::getValue().

◆ visit() [16/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactModule node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 155 of file ArtifactGeneratorCppDecl.cpp.

156{
157 for (const auto &i : node->headerSysIncludes())
158 _out << "#include <" << i << ">" << endl;
159
160 if (!node->headerSysIncludes().empty())
161 _out << endl;
162
163 for (const auto &i : node->headerIncludes())
164 _out << "#include \"" << i << "\"" << endl;
165
166 if (!node->headerIncludes().empty())
167 _out << endl;
168
169 for (const auto &e : node->entities())
170 e->accept(this);
171}

References nnc::ArtifactModule::entities(), nnc::ArtifactModule::headerIncludes(), and nnc::ArtifactModule::headerSysIncludes().

◆ visit() [17/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactRef node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 33 of file ArtifactGeneratorCppDecl.cpp.

34{
35 _out << "&";
36 node->obj()->accept(this);
37}

References nnc::ArtifactRef::obj().

◆ visit() [18/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactRet node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 58 of file ArtifactGeneratorCppDecl.cpp.

58{}

◆ visit() [19/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactUnaryExpr node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 52 of file ArtifactGeneratorCppDecl.cpp.

52{}

◆ visit() [20/20]

void nnc::ArtifactGeneratorCppDecl::visit ( const ArtifactVariable node)
overridevirtual

Implements nnc::IArtifactGenerator.

Definition at line 45 of file ArtifactGeneratorCppDecl.cpp.

46{
47 _out << node->typeName() << " " << node->name();
48}

References nnc::ArtifactNamed::name(), and nnc::ArtifactVariable::typeName().


The documentation for this class was generated from the following files: