summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tools/slang-cpp-extractor/node.cpp')
-rw-r--r--tools/slang-cpp-extractor/node.cpp80
1 files changed, 70 insertions, 10 deletions
diff --git a/tools/slang-cpp-extractor/node.cpp b/tools/slang-cpp-extractor/node.cpp
index 2074b7c41..3fbbf9c56 100644
--- a/tools/slang-cpp-extractor/node.cpp
+++ b/tools/slang-cpp-extractor/node.cpp
@@ -294,7 +294,7 @@ ScopeNode* ScopeNode::getAnonymousNamespace()
return m_anonymousNamespace;
}
-void ScopeNode::addChild(Node* child)
+void ScopeNode::addChildIgnoringName(Node* child)
{
SLANG_ASSERT(child->m_parentScope == nullptr);
// Can't add anonymous namespace this way - should be added via getAnonymousNamespace
@@ -302,6 +302,11 @@ void ScopeNode::addChild(Node* child)
child->m_parentScope = this;
m_children.add(child);
+}
+
+void ScopeNode::addChild(Node* child)
+{
+ addChildIgnoringName(child);
if (child->m_name.hasContent())
{
@@ -316,9 +321,6 @@ Node* ScopeNode::findChild(const UnownedStringSlice& name) const
{
return *nodePtr;
}
-
-
-
return nullptr;
}
@@ -377,8 +379,7 @@ static bool _needsSpace(const Token& prevTok, const Token& tok)
auto loc = tok.getLoc();
auto prevContent = prevTok.getContent();
- auto content = tok.getContent();
-
+
if (prevLoc + prevContent.getLength() == loc)
{
return false;
@@ -494,17 +495,76 @@ void EnumNode::dump(int indent, StringBuilder& out)
out << "}\n";
}
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!! CallableNode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+void CallableNode::dump(int indent, StringBuilder& out)
+{
+ if (!isReflected())
+ {
+ return;
+ }
+
+ dumpMarkup(indent, out);
+
+ _indent(indent, out);
+
+ if (m_isStatic)
+ {
+ out << "static ";
+ }
+ if (m_isVirtual)
+ {
+ out << "virtual ";
+ }
+
+ out << m_returnType << " ";
+ out << m_name.getContent() << "(";
+
+ const Index count = m_params.getCount();
+ for (Index i = 0; i < count; ++i)
+ {
+ if (i > 0)
+ {
+ out << ", ";
+ }
+
+ const auto& param = m_params[i];
+ out << param.m_type;
+ if (param.m_name.type == TokenType::Identifier)
+ {
+ out << " " << param.m_name.getContent();
+ }
+ }
+
+ out << ")";
+
+ if (m_isPure)
+ {
+ out << " = 0";
+ }
+
+ out << "\n";
+}
+
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FieldNode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
void FieldNode::dump(int indent, StringBuilder& out)
{
- if (isReflected())
+ if (!isReflected())
{
- dumpMarkup(indent, out);
+ return;
+ }
- _indent(indent, out);
- out << m_fieldType << " " << m_name.getContent() << "\n";
+ dumpMarkup(indent, out);
+
+ _indent(indent, out);
+
+ if (m_isStatic)
+ {
+ out << "static ";
}
+
+ out << m_fieldType << " " << m_name.getContent() << "\n";
}
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ClassLikeNode !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */