File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 27
27
#include < algorithm>
28
28
#include < cassert>
29
29
#include < functional>
30
+ #include < print>
30
31
31
32
namespace cxx {
32
33
@@ -111,6 +112,14 @@ void Scope::addSymbol(Symbol* symbol) {
111
112
symbol->setEnclosingScope (this );
112
113
symbols_.push_back (symbol);
113
114
115
+ if (name_cast<ConversionFunctionId>(symbol->name ())) {
116
+ if (auto functionSymbol = symbol_cast<FunctionSymbol>(symbol)) {
117
+ if (auto classSymbol = symbol_cast<ClassSymbol>(owner_)) {
118
+ classSymbol->addConversionFunction (functionSymbol);
119
+ }
120
+ }
121
+ }
122
+
114
123
if (3 * symbols_.size () >= 2 * buckets_.size ()) {
115
124
rehash ();
116
125
} else {
Original file line number Diff line number Diff line change @@ -215,6 +215,15 @@ auto ClassSymbol::hasBaseClass(
215
215
return false ;
216
216
}
217
217
218
+ auto ClassSymbol::conversionFunctions () const
219
+ -> const std::vector<FunctionSymbol*>& {
220
+ return conversionFunctions_;
221
+ }
222
+
223
+ void ClassSymbol::addConversionFunction (FunctionSymbol* conversionFunction) {
224
+ conversionFunctions_.push_back (conversionFunction);
225
+ }
226
+
218
227
auto ClassSymbol::declaration () const -> SpecifierAST* { return specifier_; }
219
228
220
229
void ClassSymbol::setDeclaration (SpecifierAST* specifier) {
Original file line number Diff line number Diff line change @@ -246,6 +246,11 @@ class ClassSymbol final : public ScopedSymbol {
246
246
247
247
void addConstructor (FunctionSymbol* constructor);
248
248
249
+ [[nodiscard]] auto conversionFunctions () const
250
+ -> const std::vector<FunctionSymbol*>&;
251
+
252
+ void addConversionFunction (FunctionSymbol* conversionFunction);
253
+
249
254
[[nodiscard]] auto isFinal () const -> bool;
250
255
void setFinal (bool isFinal);
251
256
@@ -316,6 +321,7 @@ class ClassSymbol final : public ScopedSymbol {
316
321
private:
317
322
std::vector<BaseClassSymbol*> baseClasses_;
318
323
std::vector<FunctionSymbol*> constructors_;
324
+ std::vector<FunctionSymbol*> conversionFunctions_;
319
325
std::unique_ptr<TemplateInfo<ClassSymbol>> templateInfo_;
320
326
SpecifierAST* specifier_ = nullptr ;
321
327
TemplateDeclarationAST* templateDeclaration_ = nullptr ;
You can’t perform that action at this time.
0 commit comments