@@ -21,8 +21,8 @@ namespace pl::cli::sub {
2121
2222 namespace {
2323
24- std::string getTypeEndian (const core::ast::ASTNodeTypeDecl *typeDecl ) {
25- auto endian = typeDecl ->getEndian ();
24+ std::string getTypeEndian (const core::ast::ASTNodeTypeApplication *typeApp ) {
25+ auto endian = typeApp ->getEndian ();
2626
2727 if (!endian.has_value ())
2828 return " " ;
@@ -35,15 +35,12 @@ namespace pl::cli::sub {
3535 }
3636
3737 std::string getTypeName (const core::ast::ASTNode *type) {
38- if (auto builtinType = dynamic_cast <const core::ast::ASTNodeBuiltinType*>(type))
39- return core::Token::getTypeName (builtinType->getType ());
40- else if (auto typeDecl = dynamic_cast <const core::ast::ASTNodeTypeDecl*>(type)) {
41- if (typeDecl->getName ().empty ())
42- return getTypeEndian (typeDecl) + getTypeName (typeDecl->getType ().get ());
43- else
44- return getTypeEndian (typeDecl) + typeDecl->getName ();
38+ if (auto typeApp = dynamic_cast <const core::ast::ASTNodeTypeApplication*>(type); typeApp != nullptr ) {
39+ return fmt::format (" {}{}" , getTypeEndian (typeApp), getTypeName (typeApp->getType ().get ()));
40+ } else if (auto typeDecl = dynamic_cast <const core::ast::ASTNodeTypeDecl*>(type); typeDecl != nullptr ) {
41+ return typeDecl->getName ();
4542 } else {
46- return " ??? " ;
43+ return " " ;
4744 }
4845 }
4946
@@ -72,12 +69,10 @@ namespace pl::cli::sub {
7269
7370 std::string result = " <" ;
7471 for (const auto &templateParam : templateParams) {
75- if (auto typeDecl = dynamic_cast <const core::ast::ASTNodeTypeDecl*>(templateParam.get ()); typeDecl != nullptr )
76- result += typeDecl->getName ();
77- else if (auto lvalue = dynamic_cast <const core::ast::ASTNodeLValueAssignment*>(templateParam.get ()); lvalue != nullptr )
78- result += fmt::format (" auto {}" , lvalue->getLValueName ());
79- else
80- continue ;
72+ if (templateParam->isType ())
73+ result += templateParam->getName ().get ();
74+ else
75+ result += fmt::format (" auto {}" , templateParam->getName ().get ());
8176
8277 result += " , " ;
8378 }
@@ -89,8 +84,8 @@ namespace pl::cli::sub {
8984 }
9085
9186 std::string generateTypeDocumentation (const std::string &name, const core::ast::ASTNodeTypeDecl *type) {
92- if (auto typeDecl = dynamic_cast <core::ast::ASTNodeTypeDecl *>(type->getType ().get ())) {
93- return fmt::format (" ```rust\n using {}{} = {}{};\n ```" , name, generateTemplateParams (type), getTypeName (typeDecl ), generateAttributes (typeDecl ));
87+ if (auto typeApp = dynamic_cast <core::ast::ASTNodeTypeApplication *>(type->getType ().get ())) {
88+ return fmt::format (" ```rust\n using {}{} = {}{};\n ```" , name, generateTemplateParams (type), getTypeName (typeApp ), generateAttributes (type ));
9489 } else if (dynamic_cast <core::ast::ASTNodeStruct*>(type->getType ().get ())) {
9590 return fmt::format (" ```rust\n struct {}{} {{ ... }}{};\n ```" , name, generateTemplateParams (type), generateAttributes (type));
9691 } else if (dynamic_cast <core::ast::ASTNodeUnion*>(type->getType ().get ())) {
0 commit comments