summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-12 17:10:43 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-12 17:10:43 +0300
commit5523103f7f9d0331c65b3c931533519d2d18c838 (patch)
tree526257773105c5a6b426fd916def6d31c6b02758
parent935220297043e59853d54697bdf51c96ac1d1812 (diff)
downloadparanucker-5523103f7f9d0331c65b3c931533519d2d18c838.tar.gz
paranucker-5523103f7f9d0331c65b3c931533519d2d18c838.tar.bz2
paranucker-5523103f7f9d0331c65b3c931533519d2d18c838.tar.xz
paranucker-5523103f7f9d0331c65b3c931533519d2d18c838.zip
Add parsing node FIELD_DECL.
-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/field_decl.h56
-rw-r--r--src/nodes/decl/var_decl.h4
-rw-r--r--src/parsers/decl/field_decl.cpp75
-rw-r--r--src/parsers/decl/var_decl.cpp1
8 files changed, 141 insertions, 2 deletions
diff --git a/src/Makefile.files b/src/Makefile.files
index c53f6d4..7d166e6 100644
--- a/src/Makefile.files
+++ b/src/Makefile.files
@@ -126,4 +126,6 @@ SRC = analysis/analysis.cpp \
nodes/expr/target_expr.h \
parsers/expr/target_expr.cpp \
nodes/block/ehspec_block.h \
- parsers/block/ehspec_block.cpp \ No newline at end of file
+ parsers/block/ehspec_block.cpp \
+ nodes/decl/field_decl.h \
+ parsers/decl/field_decl.cpp \ No newline at end of file
diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h
index b83d3c8..8f34475 100644
--- a/src/includes/nodeincludes.h
+++ b/src/includes/nodeincludes.h
@@ -44,3 +44,4 @@
#include "nodes/type/record_type.h"
#include "nodes/expr/target_expr.h"
#include "nodes/block/ehspec_block.h"
+#include "nodes/decl/field_decl.h"
diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc
index 4fb4b33..b649c05 100644
--- a/src/includes/nodeshandling.inc
+++ b/src/includes/nodeshandling.inc
@@ -43,3 +43,4 @@ handleNodeType(NULLPTR_TYPE, NullPtrType)
handleNodeType(RECORD_TYPE, RecordType)
handleNodeType(TARGET_EXPR, TargetExpr)
handleNodeType(EH_SPEC_BLOCK, EhSpecBlock)
+handleNodeType(FIELD_DECL, FieldDecl)
diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc
index 782a6c3..907c211 100644
--- a/src/includes/parserdefines.inc
+++ b/src/includes/parserdefines.inc
@@ -43,3 +43,4 @@ parserDefine(NullPtrType);
parserDefine(RecordType);
parserDefine(TargetExpr);
parserDefine(EhSpecBlock);
+parserDefine(FieldDecl);
diff --git a/src/nodes/decl/field_decl.h b/src/nodes/decl/field_decl.h
new file mode 100644
index 0000000..4129b4b
--- /dev/null
+++ b/src/nodes/decl/field_decl.h
@@ -0,0 +1,56 @@
+/*
+ * 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_FIELDDECLNODE_H
+#define NODES_DECL_FIELDDECLNODE_H
+
+#include "nodes/base/decl.h"
+
+#include "nodes/base/type.h"
+
+#include "nodes/cst/integer_cst.h"
+
+#include <string>
+
+struct FieldDeclNode : public DeclNode
+{
+ FieldDeclNode() :
+ DeclNode(),
+ declSize(nullptr),
+ declBitType(nullptr),
+ initial(nullptr),
+ qualifier(nullptr),
+ isBitField(false),
+ isUnsigned(false),
+ isVirtual(false),
+ isBitPacked(false)
+ {
+ }
+
+ IntegerCstNode *declSize;
+ TypeNode *declBitType;
+ Node *initial;
+ Node *qualifier;
+ bool isBitField;
+ bool isUnsigned;
+ bool isVirtual;
+ bool isBitPacked;
+};
+
+#endif // NODES_DECL_FIELDDECLNODE_H
diff --git a/src/nodes/decl/var_decl.h b/src/nodes/decl/var_decl.h
index 05a3efe..3b34e46 100644
--- a/src/nodes/decl/var_decl.h
+++ b/src/nodes/decl/var_decl.h
@@ -36,7 +36,8 @@ struct VarDeclNode : public DeclNode
initial(nullptr),
isStatic(false),
isRegister(false),
- isUsed(false)
+ isUsed(false),
+ isVirtual(false)
{
}
@@ -46,6 +47,7 @@ struct VarDeclNode : public DeclNode
bool isStatic;
bool isRegister;
bool isUsed;
+ bool isVirtual;
};
#endif // NODES_DECL_VARDECLNODE_H
diff --git a/src/parsers/decl/field_decl.cpp b/src/parsers/decl/field_decl.cpp
new file mode 100644
index 0000000..14b8789
--- /dev/null
+++ b/src/parsers/decl/field_decl.cpp
@@ -0,0 +1,75 @@
+/*
+ * 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(FieldDecl);
+
+#include "parsers/base/decl.h"
+
+#include "nodes/decl/field_decl.h"
+
+namespace Generic
+{
+
+void parseFieldDeclNode(FieldDeclNode *node)
+{
+ fillType(node);
+ fillLocation(node);
+ fillDeclLabel(node);
+ Log::dump(node);
+
+ setPrintField(node, DECL_C_BIT_FIELD, isBitField);
+ node->isUnsigned = DECL_UNSIGNED(node->gccNode);
+ if (node->isUnsigned)
+ Log::dumpRaw(node, "- unsigned");
+ else
+ Log::dumpRaw(node, "- signed");
+ setPrintField(node, DECL_VIRTUAL_P, isVirtual);
+ setPrintField(node, DECL_PACKED, isBitPacked);
+
+ fillDeclAutoGenerated(node);
+ fillDeclAttributes(node);
+
+ if (node->isBitField)
+ {
+ node->declBitType = static_cast<TypeNode*>(createParseNode(
+ node,
+ DECL_BIT_FIELD_TYPE(node->gccNode),
+ "decl bit type"));
+ }
+
+ node->declSize = static_cast<IntegerCstNode*>(createParseNode(
+ node,
+ DECL_SIZE(node->gccNode),
+ INTEGER_CST,
+ "decl size"));
+
+ node->initial = createParseNode(
+ node,
+ DECL_INITIAL(node->gccNode),
+ "initial");
+
+ node->qualifier = createParseNode(
+ node,
+ DECL_QUALIFIER(node->gccNode),
+ "qualifier");
+}
+
+}
diff --git a/src/parsers/decl/var_decl.cpp b/src/parsers/decl/var_decl.cpp
index 1d03446..09afed1 100644
--- a/src/parsers/decl/var_decl.cpp
+++ b/src/parsers/decl/var_decl.cpp
@@ -41,6 +41,7 @@ void parseVarDeclNode(VarDeclNode *node)
setPrintField(node, DECL_THIS_STATIC, isStatic);
setPrintField(node, DECL_REGISTER, isRegister);
setPrintField(node, TREE_USED, isUsed);
+ setPrintField(node, DECL_VIRTUAL_P, isVirtual);
fillDeclAutoGenerated(node);