summaryrefslogtreecommitdiff
path: root/src/nodes
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodes')
-rw-r--r--src/nodes/base/node.cpp30
-rw-r--r--src/nodes/base/node.h4
2 files changed, 34 insertions, 0 deletions
diff --git a/src/nodes/base/node.cpp b/src/nodes/base/node.cpp
new file mode 100644
index 0000000..b26dfb1
--- /dev/null
+++ b/src/nodes/base/node.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2015 Andrei Karas
+ *
+ * This file is part of AstDumper.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "nodes/base/node.h"
+
+bool operator ==(const Node *const node, const tree_code &code)
+{
+ return node && node->nodeType == code;
+}
+
+bool operator !=(const Node *const node, const tree_code &code)
+{
+ return !node || node->nodeType != code;
+}
diff --git a/src/nodes/base/node.h b/src/nodes/base/node.h
index e8d89ce..83b4314 100644
--- a/src/nodes/base/node.h
+++ b/src/nodes/base/node.h
@@ -80,4 +80,8 @@ struct Node
bool complete;
};
+bool operator ==(const Node *const node, const tree_code &code);
+
+bool operator !=(const Node *const node, const tree_code &code);
+
#endif // NODES_BASE_NODE_H