summaryrefslogtreecommitdiff
path: root/src/parsers
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-03 23:38:19 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-03 23:38:19 +0300
commitde6244d0df34e203a51e24cbdb4e126b6146d321 (patch)
tree9bcc7c53deea25660dd0f07e4cdcbf0051333ac3 /src/parsers
parent342f6ec4820d3087e1c16204c7a788a165a00f48 (diff)
downloadparanucker-de6244d0df34e203a51e24cbdb4e126b6146d321.tar.gz
paranucker-de6244d0df34e203a51e24cbdb4e126b6146d321.tar.bz2
paranucker-de6244d0df34e203a51e24cbdb4e126b6146d321.tar.xz
paranucker-de6244d0df34e203a51e24cbdb4e126b6146d321.zip
Create base DeclNode and parser for it.
Diffstat (limited to 'src/parsers')
-rw-r--r--src/parsers/declnode.cpp50
-rw-r--r--src/parsers/declnode.h32
-rw-r--r--src/parsers/functiondeclnode.cpp7
3 files changed, 88 insertions, 1 deletions
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);
}
}