diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.files | 4 | ||||
-rw-r--r-- | src/includes/nodeincludes.h | 1 | ||||
-rw-r--r-- | src/includes/nodeshandling.inc | 1 | ||||
-rw-r--r-- | src/includes/parserdefines.inc | 1 | ||||
-rw-r--r-- | src/nodes/decl/field_decl.h | 56 | ||||
-rw-r--r-- | src/nodes/decl/var_decl.h | 4 | ||||
-rw-r--r-- | src/parsers/decl/field_decl.cpp | 75 | ||||
-rw-r--r-- | src/parsers/decl/var_decl.cpp | 1 |
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); |