From de6244d0df34e203a51e24cbdb4e126b6146d321 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 3 Jun 2015 23:38:19 +0300 Subject: Create base DeclNode and parser for it. --- src/parsers/declnode.cpp | 50 ++++++++++++++++++++++++++++++++++++++++ src/parsers/declnode.h | 32 +++++++++++++++++++++++++ src/parsers/functiondeclnode.cpp | 7 +++++- 3 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 src/parsers/declnode.cpp create mode 100644 src/parsers/declnode.h (limited to 'src/parsers') diff --git a/src/parsers/declnode.cpp b/src/parsers/declnode.cpp new file mode 100644 index 0000000..019be7b --- /dev/null +++ b/src/parsers/declnode.cpp @@ -0,0 +1,50 @@ +/* + * 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 "parsers/declnode.h" + +#include "includes.h" +#include "logger.h" + +#include "nodes/declnode.h" + +#include "localconsts.h" + +namespace Generic +{ + +void fillDeclLabel(DeclNode *node) +{ + if (!node || node->gccNode == NULL_TREE) + { + return; + } + if (DECL_NAME(node->gccNode)) + node->label = IDENTIFIER_POINTER(DECL_NAME(node->gccNode)); +} + +void fillDeclAttributes(DeclNode *node) +{ + if (!node || node->gccNode == NULL_TREE) + { + return; + } +} + +} diff --git a/src/parsers/declnode.h b/src/parsers/declnode.h new file mode 100644 index 0000000..5764fad --- /dev/null +++ b/src/parsers/declnode.h @@ -0,0 +1,32 @@ +/* + * 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 PARSERS_DECLNODE_H +#define PARSERS_DECLNODE_H + +struct DeclNode; + +namespace Generic +{ + void fillDeclLabel(DeclNode *node); + + void fillDeclAttributes(DeclNode *node); +} + +#endif // PARSERS_DECLNODE_H diff --git a/src/parsers/functiondeclnode.cpp b/src/parsers/functiondeclnode.cpp index fbd5919..e5a0773 100644 --- a/src/parsers/functiondeclnode.cpp +++ b/src/parsers/functiondeclnode.cpp @@ -21,6 +21,7 @@ #include "logger.h" +#include "parsers/declnode.h" #include "parsers/generic.h" #include "nodes/functiondeclnode.h" @@ -35,6 +36,8 @@ void parseFunctionDeclNode(FunctionDeclNode *node) { fillType(node); fillLocation(node); + fillDeclLabel(node); + fillDeclAttributes(node); Log::log(node); node->functionType = static_cast(createParseNode( node, @@ -60,13 +63,15 @@ void parseFunctionDeclNode(FunctionDeclNode *node) node, DECL_FUNCTION_SPECIFIC_TARGET(node->gccNode), "target"); - node->hasTargets = DECL_FUNCTION_VERSIONED(node->gccNode) ? true : false; + node->hasTargets = DECL_FUNCTION_VERSIONED(node->gccNode); node->optimisation = createParseNode( node, DECL_FUNCTION_SPECIFIC_OPTIMIZATION(node->gccNode), "optiomisations"); node->isVirtual = DECL_VIRTUAL_P(node->gccNode); node->isFinal = DECL_FINAL_P(node->gccNode); + node->isConst = TREE_READONLY(node->gccNode); + node->isPure = DECL_PURE_P(node->gccNode); } } -- cgit v1.2.3-60-g2f50