diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | src/nodes/declnode.h | 38 | ||||
-rw-r--r-- | src/nodes/functiondeclnode.h | 9 | ||||
-rw-r--r-- | src/parsers/declnode.cpp | 50 | ||||
-rw-r--r-- | src/parsers/declnode.h | 32 | ||||
-rw-r--r-- | src/parsers/functiondeclnode.cpp | 7 |
6 files changed, 137 insertions, 4 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f918b59..2ef4d42 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,10 +1,13 @@ AUTOMAKE_OPTIONS = subdir-objects -SRC = nodes/functiondeclnode.h \ +SRC = nodes/declnode.h \ + nodes/functiondeclnode.h \ nodes/functiontypenode.h \ nodes/node.h \ nodes/parmdeclnode.h \ nodes/resultdeclnode.h \ + parsers/declnode.cpp \ + parsers/declnode.h \ parsers/functiondeclnode.cpp \ parsers/functiondeclnode.h \ parsers/functiontypenode.cpp \ diff --git a/src/nodes/declnode.h b/src/nodes/declnode.h new file mode 100644 index 0000000..ba553b8 --- /dev/null +++ b/src/nodes/declnode.h @@ -0,0 +1,38 @@ +/* + * 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_DECLNODE_H +#define NODES_DECLNODE_H + +#include "nodes/node.h" + +#include <string> + +struct DeclNode : public Node +{ + DeclNode() : + Node(), + attribute(nullptr) + { + } + + Node *attribute; +}; + +#endif // NODES_DECLNODE_H diff --git a/src/nodes/functiondeclnode.h b/src/nodes/functiondeclnode.h index 871fcd8..64aac09 100644 --- a/src/nodes/functiondeclnode.h +++ b/src/nodes/functiondeclnode.h @@ -20,6 +20,7 @@ #ifndef NODES_FUNCTIONDECLNODE_H #define NODES_FUNCTIONDECLNODE_H +#include "nodes/declnode.h" #include "nodes/functiontypenode.h" #include "nodes/parmdeclnode.h" #include "nodes/resultdeclnode.h" @@ -27,10 +28,10 @@ #include <string> #include <vector> -struct FunctionDeclNode : public Node +struct FunctionDeclNode : public DeclNode { FunctionDeclNode() : - Node(), + DeclNode(), functionType(nullptr), result(nullptr), code(nullptr), @@ -40,6 +41,8 @@ struct FunctionDeclNode : public Node isAutoGenerated(false), isVirtual(false), isFinal(false), + isConst(false), + isPure(false), hasTargets(false) { } @@ -53,6 +56,8 @@ struct FunctionDeclNode : public Node bool isAutoGenerated; bool isVirtual; bool isFinal; + bool isConst; + bool isPure; bool hasTargets; }; 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 <http://www.gnu.org/licenses/>. + */ + +#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 <http://www.gnu.org/licenses/>. + */ + +#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<FunctionTypeNode*>(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); } } |