summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-07 02:25:35 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-07 02:25:35 +0300
commit070a91cfa376da74c781bd7a152785b103e00eea (patch)
tree55cdf71a4f80644ff549d2ba2dd96226fb773900 /src
parent7eb56f6af85b0bbbea17d0265ac489373cfbfd2d (diff)
downloadparanucker-070a91cfa376da74c781bd7a152785b103e00eea.tar.gz
paranucker-070a91cfa376da74c781bd7a152785b103e00eea.tar.bz2
paranucker-070a91cfa376da74c781bd7a152785b103e00eea.tar.xz
paranucker-070a91cfa376da74c781bd7a152785b103e00eea.zip
Add node type VAR_DECL.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.files4
-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/decl/var_decl.h47
-rw-r--r--src/parsers/decl/var_decl.cpp63
6 files changed, 116 insertions, 1 deletions
diff --git a/src/Makefile.files b/src/Makefile.files
index b785ed3..378d9c7 100644
--- a/src/Makefile.files
+++ b/src/Makefile.files
@@ -57,4 +57,6 @@ SRC = nodes/base/cst.h \
nodes/expr/convert_expr.h \
parsers/expr/convert_expr.cpp \
nodes/expr/cleanuppoint_expr.h \
- parsers/expr/cleanuppoint_expr.cpp \ No newline at end of file
+ parsers/expr/cleanuppoint_expr.cpp \
+ nodes/decl/var_decl.h \
+ parsers/decl/var_decl.cpp \ No newline at end of file
diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h
index 4331da8..0d497a7 100644
--- a/src/includes/nodeincludes.h
+++ b/src/includes/nodeincludes.h
@@ -17,3 +17,4 @@
#include "nodes/expr/init_expr.h"
#include "nodes/expr/convert_expr.h"
#include "nodes/expr/cleanuppoint_expr.h"
+#include "nodes/decl/var_decl.h"
diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc
index b1fef81..6e753ee 100644
--- a/src/includes/nodeshandling.inc
+++ b/src/includes/nodeshandling.inc
@@ -16,3 +16,4 @@ handleNodeType(DECL_EXPR, DeclExpr)
handleNodeType(INIT_EXPR, InitExpr)
handleNodeType(CONVERT_EXPR, ConvertExpr)
handleNodeType(CLEANUP_POINT_EXPR, CleanupPointExpr)
+handleNodeType(VAR_DECL, VarDecl)
diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc
index 01f309e..098b6fc 100644
--- a/src/includes/parserdefines.inc
+++ b/src/includes/parserdefines.inc
@@ -16,3 +16,4 @@ parserDefine(DeclExpr);
parserDefine(InitExpr);
parserDefine(ConvertExpr);
parserDefine(CleanupPointExpr);
+parserDefine(VarDecl);
diff --git a/src/nodes/decl/var_decl.h b/src/nodes/decl/var_decl.h
new file mode 100644
index 0000000..1e309d3
--- /dev/null
+++ b/src/nodes/decl/var_decl.h
@@ -0,0 +1,47 @@
+/*
+ * 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_DECL_VARDECLNODE_H
+#define NODES_DECL_VARDECLNODE_H
+
+#include "nodes/cst/integer_cst.h"
+
+#include "nodes/base/decl.h"
+#include "nodes/base/type.h"
+
+#include <string>
+
+struct VarDeclNode : public DeclNode
+{
+ VarDeclNode() :
+ DeclNode(),
+ declSize(nullptr),
+ varType(nullptr),
+ initial(nullptr),
+ isStatic(false)
+ {
+ }
+
+ IntegerCstNode *declSize;
+ TypeNode *varType;
+ Node *initial;
+ bool isStatic;
+};
+
+#endif // NODES_DECL_VARDECLNODE_H
diff --git a/src/parsers/decl/var_decl.cpp b/src/parsers/decl/var_decl.cpp
new file mode 100644
index 0000000..99b1fe0
--- /dev/null
+++ b/src/parsers/decl/var_decl.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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(VarDecl);
+
+#include "parsers/base/decl.h"
+
+#include "nodes/decl/var_decl.h"
+
+#include "cp/cp-tree.h"
+
+namespace Generic
+{
+
+void parseVarDeclNode(VarDeclNode *node)
+{
+ fillType(node);
+ fillLocation(node);
+ fillDeclLabel(node);
+ setPrintField(node, DECL_THIS_STATIC, isStatic);
+
+ Log::log(node);
+
+ fillDeclAutoGenerated(node);
+ fillDeclAttributes(node);
+
+ node->declSize = static_cast<IntegerCstNode*>(createParseNode(
+ node,
+ DECL_SIZE(node->gccNode),
+ INTEGER_CST,
+ "decl size"));
+
+ node->varType = static_cast<TypeNode*>(createParseNode(
+ node,
+ TREE_TYPE(node->gccNode),
+ "var type"));
+
+
+ node->initial = createParseNode(
+ node,
+ DECL_INITIAL(node->gccNode),
+ "initial");
+}
+
+}