summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-13 20:55:18 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-13 20:58:12 +0300
commitb97b0b653af25997c85bbd0651e09d02a84620ef (patch)
tree535ac4acb83677e3ed47bf911cd56b1acb79cf62
parent223634cba06d72aa62f886506a2e907d1594a9fb (diff)
downloadparanucker-b97b0b653af25997c85bbd0651e09d02a84620ef.tar.gz
paranucker-b97b0b653af25997c85bbd0651e09d02a84620ef.tar.bz2
paranucker-b97b0b653af25997c85bbd0651e09d02a84620ef.tar.xz
paranucker-b97b0b653af25997c85bbd0651e09d02a84620ef.zip
Add way to parse *_vec nodes. Add parsing node TREE_VEC.
-rwxr-xr-xscripts/addfile.py8
-rw-r--r--src/Makefile.files7
-rw-r--r--src/includes/nodeincludes.h1
-rw-r--r--src/includes/nodeshandling.inc1
-rw-r--r--src/includes/parserdefines.inc1
-rw-r--r--src/nodes/base/vec.h35
-rw-r--r--src/nodes/vec/tree_vec.h38
-rw-r--r--src/parsers/base/vec.cpp33
-rw-r--r--src/parsers/base/vec.h29
-rw-r--r--src/parsers/vec/tree_vec.cpp46
10 files changed, 194 insertions, 5 deletions
diff --git a/scripts/addfile.py b/scripts/addfile.py
index e089f02..5835b44 100755
--- a/scripts/addfile.py
+++ b/scripts/addfile.py
@@ -67,14 +67,14 @@ if dirName != "":
parserAdditionalCode1 = " fillExprLocation(node);\n"
parserAdditionalCode2 = "\n fillExprOperands(node);\n"
parserBaseInclude = "#include \"parsers/base/expr.h\"\n"
- elif nodeName[-3:] == "ref":
- suffixSize = 3
- parserAdditionalCode2 = "\n fillExprOperands(node);\n"
- parserBaseInclude = "#include \"parsers/base/expr.h\"\n"
elif nodeName[-4:] == "stmt":
suffixSize = 4
parserBaseInclude = "#include \"parsers/base/stmt.h\"\n"
parserAdditionalCode2 = ""
+ elif nodeName[-3:] == "vec":
+ suffixSize = 3
+ parserBaseInclude = "#include \"parsers/base/vec.h\"\n"
+ parserAdditionalCode2 = ""
elif nodeName[-4:] == "list":
suffixSize = 4
else:
diff --git a/src/Makefile.files b/src/Makefile.files
index a522a6a..5061422 100644
--- a/src/Makefile.files
+++ b/src/Makefile.files
@@ -16,6 +16,7 @@ SRC = analysis/analysis.cpp \
nodes/base/ref.h \
nodes/base/stmt.h \
nodes/base/type.h \
+ nodes/base/vec.h \
nodes/cst/integer_cst.h \
nodes/decl/function_decl.h \
nodes/decl/parm_decl.h \
@@ -42,6 +43,8 @@ SRC = analysis/analysis.cpp \
parsers/base/stmt.h \
parsers/base/type.cpp \
parsers/base/type.h \
+ parsers/base/vec.cpp \
+ parsers/base/vec.h \
parsers/cst/integer_cst.cpp \
parsers/decl/function_decl.cpp \
parsers/decl/parm_decl.cpp \
@@ -241,4 +244,6 @@ SRC = analysis/analysis.cpp \
nodes/decl/template_decl.h \
parsers/decl/template_decl.cpp \
nodes/expr/exactdiv_expr.h \
- parsers/expr/exactdiv_expr.cpp \ No newline at end of file
+ parsers/expr/exactdiv_expr.cpp \
+ nodes/vec/tree_vec.h \
+ parsers/vec/tree_vec.cpp \ No newline at end of file
diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h
index f41b46b..f3247f6 100644
--- a/src/includes/nodeincludes.h
+++ b/src/includes/nodeincludes.h
@@ -100,3 +100,4 @@
#include "nodes/decl/const_decl.h"
#include "nodes/decl/template_decl.h"
#include "nodes/expr/exactdiv_expr.h"
+#include "nodes/vec/tree_vec.h"
diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc
index a5e50d9..ce8eb8f 100644
--- a/src/includes/nodeshandling.inc
+++ b/src/includes/nodeshandling.inc
@@ -99,3 +99,4 @@ handleNodeType(USING_DECL, UsingDecl)
handleNodeType(CONST_DECL, ConstDecl)
handleNodeType(TEMPLATE_DECL, TemplateDecl)
handleNodeType(EXACT_DIV_EXPR, ExactDivExpr)
+handleNodeType(TREE_VEC, TreeVec)
diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc
index ef52fcd..aacb166 100644
--- a/src/includes/parserdefines.inc
+++ b/src/includes/parserdefines.inc
@@ -99,3 +99,4 @@ parserDefine(UsingDecl);
parserDefine(ConstDecl);
parserDefine(TemplateDecl);
parserDefine(ExactDivExpr);
+parserDefine(TreeVec);
diff --git a/src/nodes/base/vec.h b/src/nodes/base/vec.h
new file mode 100644
index 0000000..747a7fa
--- /dev/null
+++ b/src/nodes/base/vec.h
@@ -0,0 +1,35 @@
+/*
+ * 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/>.
+ */
+
+#ifndef NODES_BASE_VECNODE_H
+#define NODES_BASE_VECNODE_H
+
+#include "nodes/base/node.h"
+
+#include <vector>
+
+struct VecNode : public Node
+{
+ VecNode() :
+ Node()
+ {
+ }
+};
+
+#endif // NODES_BASE_VECNODE_H
diff --git a/src/nodes/vec/tree_vec.h b/src/nodes/vec/tree_vec.h
new file mode 100644
index 0000000..cba66cc
--- /dev/null
+++ b/src/nodes/vec/tree_vec.h
@@ -0,0 +1,38 @@
+/*
+ * 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/>.
+ */
+
+#ifndef NODES_VEC_TREEVECNODE_H
+#define NODES_VEC_TREEVECNODE_H
+
+#include "nodes/base/vec.h"
+
+#include <vector>
+
+struct TreeVecNode : public VecNode
+{
+ TreeVecNode() :
+ VecNode(),
+ args()
+ {
+ }
+
+ std::vector<Node*> args;
+};
+
+#endif // NODES_VEC_TREEVECNODE_H
diff --git a/src/parsers/base/vec.cpp b/src/parsers/base/vec.cpp
new file mode 100644
index 0000000..3f297d5
--- /dev/null
+++ b/src/parsers/base/vec.cpp
@@ -0,0 +1,33 @@
+/*
+ * 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 "parsers/base/vec.h"
+
+#include "includes.h"
+
+#include "nodes/base/vec.h"
+
+#include "parsers/generic.h"
+
+#include "localconsts.h"
+
+namespace Generic
+{
+
+}
diff --git a/src/parsers/base/vec.h b/src/parsers/base/vec.h
new file mode 100644
index 0000000..35807c5
--- /dev/null
+++ b/src/parsers/base/vec.h
@@ -0,0 +1,29 @@
+/*
+ * 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/>.
+ */
+
+#ifndef PARSERS_BASE_VEC_H
+#define PARSERS_BASE_VEC_H
+
+struct VecNode;
+
+namespace Generic
+{
+}
+
+#endif // PARSERS_BASE_VEC_H
diff --git a/src/parsers/vec/tree_vec.cpp b/src/parsers/vec/tree_vec.cpp
new file mode 100644
index 0000000..548765e
--- /dev/null
+++ b/src/parsers/vec/tree_vec.cpp
@@ -0,0 +1,46 @@
+/*
+ * 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 "includes/parserincludes.h"
+
+parserDefine(TreeVec);
+
+#include "parsers/base/vec.h"
+
+#include "nodes/vec/tree_vec.h"
+
+namespace Generic
+{
+
+void parseTreeVecNode(TreeVecNode *node)
+{
+ fillType(node);
+ Log::dump(node);
+
+ const int sz = TREE_VEC_LENGTH(node->gccNode);
+ for (int f = 0; f < sz; f ++)
+ {
+ node->args.push_back(createParseNode(
+ node,
+ TREE_VEC_ELT (node->gccNode, f),
+ "element"));
+ }
+}
+
+}