From b75b5c111c562fd5e6ded579de683753c4a5ca18 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 13 Jun 2015 20:17:51 +0300 Subject: Add parsing node TEMPLATE_DECL. --- src/Makefile.files | 4 ++- src/includes/nodeincludes.h | 1 + src/includes/nodeshandling.inc | 1 + src/includes/parserdefines.inc | 1 + src/nodes/decl/template_decl.h | 42 +++++++++++++++++++++++++++++ src/parsers/decl/template_decl.cpp | 54 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/nodes/decl/template_decl.h create mode 100644 src/parsers/decl/template_decl.cpp (limited to 'src') diff --git a/src/Makefile.files b/src/Makefile.files index 8625cb2..903232a 100644 --- a/src/Makefile.files +++ b/src/Makefile.files @@ -237,4 +237,6 @@ SRC = analysis/analysis.cpp \ nodes/decl/using_decl.h \ parsers/decl/using_decl.cpp \ nodes/decl/const_decl.h \ - parsers/decl/const_decl.cpp \ No newline at end of file + parsers/decl/const_decl.cpp \ + nodes/decl/template_decl.h \ + parsers/decl/template_decl.cpp \ No newline at end of file diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h index 1904773..6f91892 100644 --- a/src/includes/nodeincludes.h +++ b/src/includes/nodeincludes.h @@ -98,3 +98,4 @@ #include "nodes/decl/label_decl.h" #include "nodes/decl/using_decl.h" #include "nodes/decl/const_decl.h" +#include "nodes/decl/template_decl.h" diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc index 32d910b..7591aaf 100644 --- a/src/includes/nodeshandling.inc +++ b/src/includes/nodeshandling.inc @@ -97,3 +97,4 @@ handleNodeType(COMPOUND_EXPR, CompoundExpr) handleNodeType(LABEL_DECL, LabelDecl) handleNodeType(USING_DECL, UsingDecl) handleNodeType(CONST_DECL, ConstDecl) +handleNodeType(TEMPLATE_DECL, TemplateDecl) diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc index 204c43e..454f9a4 100644 --- a/src/includes/parserdefines.inc +++ b/src/includes/parserdefines.inc @@ -97,3 +97,4 @@ parserDefine(CompoundExpr); parserDefine(LabelDecl); parserDefine(UsingDecl); parserDefine(ConstDecl); +parserDefine(TemplateDecl); diff --git a/src/nodes/decl/template_decl.h b/src/nodes/decl/template_decl.h new file mode 100644 index 0000000..15975f4 --- /dev/null +++ b/src/nodes/decl/template_decl.h @@ -0,0 +1,42 @@ +/* + * 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_DECL_TEMPLATEDECLNODE_H +#define NODES_DECL_TEMPLATEDECLNODE_H + +#include "nodes/base/decl.h" + +#include "nodes/list/tree_list.h" + +#include + +struct TemplateDeclNode : public DeclNode +{ + TemplateDeclNode() : + DeclNode(), + instantiations(nullptr), + specializations(nullptr) + { + } + + TreeListNode *instantiations; + TreeListNode *specializations; +}; + +#endif // NODES_DECL_TEMPLATEDECLNODE_H diff --git a/src/parsers/decl/template_decl.cpp b/src/parsers/decl/template_decl.cpp new file mode 100644 index 0000000..46a71ac --- /dev/null +++ b/src/parsers/decl/template_decl.cpp @@ -0,0 +1,54 @@ +/* + * 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(TemplateDecl); + +#include "parsers/base/decl.h" + +#include "nodes/decl/template_decl.h" + +namespace Generic +{ + +void parseTemplateDeclNode(TemplateDeclNode *node) +{ + fillType(node); + fillLocation(node); + fillDeclLabel(node); + Log::dump(node); + + fillDeclAutoGenerated(node); + fillDeclAttributes(node); + + node->specializations = static_cast(createParseNode( + node, + DECL_TEMPLATE_SPECIALIZATIONS(node->gccNode), + TREE_LIST, + "specialisation")); + + node->instantiations = static_cast(createParseNode( + node, + DECL_TEMPLATE_INSTANTIATIONS(node->gccNode), + TREE_LIST, + "instantiations")); +} + +} -- cgit v1.2.3-70-g09d2