From 5523103f7f9d0331c65b3c931533519d2d18c838 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 12 Jun 2015 17:10:43 +0300 Subject: Add parsing node FIELD_DECL. --- src/parsers/decl/field_decl.cpp | 75 +++++++++++++++++++++++++++++++++++++++++ src/parsers/decl/var_decl.cpp | 1 + 2 files changed, 76 insertions(+) create mode 100644 src/parsers/decl/field_decl.cpp (limited to 'src/parsers/decl') 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 . + */ + +#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(createParseNode( + node, + DECL_BIT_FIELD_TYPE(node->gccNode), + "decl bit type")); + } + + node->declSize = static_cast(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); -- cgit v1.2.3-60-g2f50