@@ -366,11 +366,15 @@ void addStandardGetSizeFuncDefs(std::string& code) {
366
366
}
367
367
)" ;
368
368
}
369
+ } // namespace
369
370
370
- void getClassSizeFuncDecl (const Class& c, std::string& code) {
371
+ void CodeGen::getClassSizeFuncDecl (const Class& c, std::string& code) const {
372
+ if (config_.features [Feature::PolymorphicInheritance] && c.isDynamic ()) {
373
+ code += " void getSizeTypeConcrete(const " + c.name () +
374
+ " &t, size_t &returnArg);\n " ;
375
+ }
371
376
code += " void getSizeType(const " + c.name () + " &t, size_t &returnArg);\n " ;
372
377
}
373
- } // namespace
374
378
375
379
/*
376
380
* Generates a getSizeType function for the given concrete class.
@@ -421,7 +425,7 @@ void CodeGen::getClassSizeFuncConcrete(std::string_view funcName,
421
425
code += " }\n " ;
422
426
}
423
427
424
- void CodeGen::getClassSizeFuncDef (const Class& c, std::string& code) {
428
+ void CodeGen::getClassSizeFuncDef (const Class& c, std::string& code) const {
425
429
if (!config_.features [Feature::PolymorphicInheritance] || !c.isDynamic ()) {
426
430
// Just directly use the concrete size function as this class' getSizeType()
427
431
getClassSizeFuncConcrete (" getSizeType" , c, code);
@@ -438,9 +442,7 @@ void CodeGen::getClassSizeFuncDef(const Class& c, std::string& code) {
438
442
if (childClass == nullptr ) {
439
443
abort (); // TODO
440
444
}
441
- // TODO:
442
- // auto fqChildName = *fullyQualifiedName(child);
443
- auto fqChildName = " TODO - implement me" ;
445
+ auto fqChildName = childClass->fqName ();
444
446
445
447
// We must split this assignment and append because the C++ standard lacks
446
448
// an operator for concatenating std::string and std::string_view...
@@ -511,8 +513,10 @@ void getContainerSizeFuncDef(std::unordered_set<const ContainerInfo*>& used,
511
513
boost::format (c.containerInfo_ .codegen .func ) % c.containerInfo_ .typeName ;
512
514
code += fmt.str ();
513
515
}
516
+ } // namespace
514
517
515
- void addGetSizeFuncDecls (const TypeGraph& typeGraph, std::string& code) {
518
+ void CodeGen::addGetSizeFuncDecls (const TypeGraph& typeGraph,
519
+ std::string& code) const {
516
520
for (const Type& t : typeGraph.finalTypes ) {
517
521
if (const auto * c = dynamic_cast <const Class*>(&t)) {
518
522
getClassSizeFuncDecl (*c, code);
@@ -522,8 +526,6 @@ void addGetSizeFuncDecls(const TypeGraph& typeGraph, std::string& code) {
522
526
}
523
527
}
524
528
525
- } // namespace
526
-
527
529
void CodeGen::addGetSizeFuncDefs (const TypeGraph& typeGraph,
528
530
std::string& code) {
529
531
for (const Type& t : typeGraph.finalTypes ) {
0 commit comments