From b97b0b653af25997c85bbd0651e09d02a84620ef Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 13 Jun 2015 20:55:18 +0300 Subject: Add way to parse *_vec nodes. Add parsing node TREE_VEC. --- scripts/addfile.py | 8 ++++---- src/Makefile.files | 7 ++++++- src/includes/nodeincludes.h | 1 + src/includes/nodeshandling.inc | 1 + src/includes/parserdefines.inc | 1 + src/nodes/base/vec.h | 35 ++++++++++++++++++++++++++++++++ src/nodes/vec/tree_vec.h | 38 ++++++++++++++++++++++++++++++++++ src/parsers/base/vec.cpp | 33 ++++++++++++++++++++++++++++++ src/parsers/base/vec.h | 29 ++++++++++++++++++++++++++ src/parsers/vec/tree_vec.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++ 10 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 src/nodes/base/vec.h create mode 100644 src/nodes/vec/tree_vec.h create mode 100644 src/parsers/base/vec.cpp create mode 100644 src/parsers/base/vec.h create mode 100644 src/parsers/vec/tree_vec.cpp 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 . + */ + +#ifndef NODES_BASE_VECNODE_H +#define NODES_BASE_VECNODE_H + +#include "nodes/base/node.h" + +#include + +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 . + */ + +#ifndef NODES_VEC_TREEVECNODE_H +#define NODES_VEC_TREEVECNODE_H + +#include "nodes/base/vec.h" + +#include + +struct TreeVecNode : public VecNode +{ + TreeVecNode() : + VecNode(), + args() + { + } + + std::vector 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 . + */ + +#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 . + */ + +#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 . + */ + +#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")); + } +} + +} -- cgit v1.2.3-60-g2f50