summaryrefslogtreecommitdiffstats
path: root/tools/slang-cpp-extractor/node.h
diff options
context:
space:
mode:
Diffstat (limited to 'tools/slang-cpp-extractor/node.h')
-rw-r--r--tools/slang-cpp-extractor/node.h49
1 files changed, 46 insertions, 3 deletions
diff --git a/tools/slang-cpp-extractor/node.h b/tools/slang-cpp-extractor/node.h
index f649f1adb..db9a10e36 100644
--- a/tools/slang-cpp-extractor/node.h
+++ b/tools/slang-cpp-extractor/node.h
@@ -41,6 +41,11 @@ public:
TypeDef,
+ Callable, ///< Functions/methods
+
+ Other, ///< Used 'other' parsing like for TYPE
+ Unknown, ///< Used for marking tokens consumed but usage is not known
+
CountOf,
};
@@ -64,7 +69,7 @@ public:
/// Returns true if kind can cast to this type
/// Used for implementing as<T> casting
- static bool isOfKind(Kind type) { return true; }
+ static bool isOfKind(Kind kind) { SLANG_UNUSED(kind); return true; }
static bool isKindScope(Kind kind) { return int(kind) >= int(KindRange::ScopeStart) && int(kind) <= int(KindRange::ScopeEnd); }
static bool isKindClassLike(Kind kind) { return int(kind) >= int(KindRange::ClassLikeStart) && int(kind) <= int(KindRange::ClassLikeEnd); }
@@ -95,7 +100,10 @@ public:
return false;
}
+ bool isNamespace() const { return m_kind == Kind::Namespace; }
bool isClassLike() const { return isKindClassLike(m_kind); }
+ bool isScope() const { return isKindScope(m_kind); }
+ bool isEnumLike() const { return isKindEnumLike(m_kind); }
/// These are useful for the filter
static bool isClassLikeAndReflected(Node* node) { return node->isClassLike() && node->isReflected(); }
@@ -175,8 +183,12 @@ struct ScopeNode : public Node
virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE;
virtual void calcScopeDepthFirst(List<Node*>& outNodes) SLANG_OVERRIDE;
+ /// True if can contain callable entries
+ bool canContainCallable() const { return isClassLike() || isNamespace(); }
+
/// True if can accept fields (class like types can)
bool canContainFields() const { return isClassLike(); }
+
/// True if the scope can accept types
bool canContainTypes() const { return canKindContainTypes(m_kind); }
@@ -185,6 +197,8 @@ struct ScopeNode : public Node
/// Add a child node to this nodes scope
void addChild(Node* child);
+ /// Adds the child but does not add the name to the map
+ void addChildIgnoringName(Node* child);
/// Find a child node in this scope with the specified name. Return nullptr if not found
Node* findChild(const UnownedStringSlice& name) const;
@@ -216,7 +230,7 @@ struct FieldNode : public Node
{
typedef Node Super;
- static bool isOfKind(Kind type) { return type == Kind::Field; }
+ static bool isOfKind(Kind kind) { return kind == Kind::Field; }
virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE;
@@ -227,7 +241,9 @@ struct FieldNode : public Node
UnownedStringSlice m_fieldType;
- // We may want to add initializer tokens
+ bool m_isStatic = false;
+
+ /// TODO(JS): We may want to add initializer tokens
};
struct ClassLikeNode : public ScopeNode
@@ -281,6 +297,33 @@ struct ClassLikeNode : public ScopeNode
ClassLikeNode* m_superNode; ///< If this is a class/struct, the type it is derived from (or nullptr if base)
};
+struct CallableNode : public Node
+{
+ typedef Node Super;
+
+ static bool isOfKind(Kind kind) { return kind == Kind::Callable; }
+
+ virtual void dump(int indent, StringBuilder& out) SLANG_OVERRIDE;
+
+ CallableNode() :Super(Kind::Callable) {}
+
+ struct Param
+ {
+ UnownedStringSlice m_type;
+ Token m_name;
+ };
+
+ UnownedStringSlice m_returnType;
+
+ CallableNode* m_nextOverload = nullptr;
+
+ List<Param> m_params;
+
+ bool m_isStatic = false;
+ bool m_isVirtual = false;
+ bool m_isPure = false;
+};
+
struct EnumCaseNode : public Node
{
typedef Node Super;