summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-13 22:49:13 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-13 22:49:13 +0300
commit49a697cb7d536f09bc3c8791eb6f1808e6e0a8d6 (patch)
treed1e3886dfb1ebeeb0aa19e1f8055c7da5883b866
parent0f84327ef128f4990651d8385117a05e887ce29f (diff)
downloadparanucker-49a697cb7d536f09bc3c8791eb6f1808e6e0a8d6.tar.gz
paranucker-49a697cb7d536f09bc3c8791eb6f1808e6e0a8d6.tar.bz2
paranucker-49a697cb7d536f09bc3c8791eb6f1808e6e0a8d6.tar.xz
paranucker-49a697cb7d536f09bc3c8791eb6f1808e6e0a8d6.zip
Add parsing ENUMERAL_TYPE.
-rw-r--r--src/Makefile.files4
-rw-r--r--src/includes/nodeincludes.h1
-rw-r--r--src/includes/nodeshandling.inc1
-rw-r--r--src/includes/parserdefines.inc1
-rw-r--r--src/nodes/type/enumeral_type.h50
-rw-r--r--src/parsers/type/enumeral_type.cpp63
6 files changed, 119 insertions, 1 deletions
diff --git a/src/Makefile.files b/src/Makefile.files
index 9437936..fc02518 100644
--- a/src/Makefile.files
+++ b/src/Makefile.files
@@ -252,4 +252,6 @@ SRC = analysis/analysis.cpp \
nodes/expr/cast_expr.h \
parsers/expr/cast_expr.cpp \
nodes/handler.h \
- parsers/handler.cpp \ No newline at end of file
+ parsers/handler.cpp \
+ nodes/type/enumeral_type.h \
+ parsers/type/enumeral_type.cpp \ No newline at end of file
diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h
index 65a3cff..88a11c1 100644
--- a/src/includes/nodeincludes.h
+++ b/src/includes/nodeincludes.h
@@ -104,3 +104,4 @@
#include "nodes/block/try_block.h"
#include "nodes/expr/cast_expr.h"
#include "nodes/handler.h"
+#include "nodes/type/enumeral_type.h"
diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc
index 3d8c552..d98a115 100644
--- a/src/includes/nodeshandling.inc
+++ b/src/includes/nodeshandling.inc
@@ -103,3 +103,4 @@ handleNodeType(TREE_VEC, TreeVec)
handleNodeType(TRY_BLOCK, TryBlock)
handleNodeType(CAST_EXPR, CastExpr)
handleNodeType(HANDLER, Handler)
+handleNodeType(ENUMERAL_TYPE, EnumeralType)
diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc
index 91a7da0..05f1086 100644
--- a/src/includes/parserdefines.inc
+++ b/src/includes/parserdefines.inc
@@ -103,3 +103,4 @@ parserDefine(TreeVec);
parserDefine(TryBlock);
parserDefine(CastExpr);
parserDefine(Handler);
+parserDefine(EnumeralType);
diff --git a/src/nodes/type/enumeral_type.h b/src/nodes/type/enumeral_type.h
new file mode 100644
index 0000000..ab57adb
--- /dev/null
+++ b/src/nodes/type/enumeral_type.h
@@ -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/>.
+ */
+
+#ifndef NODES_TYPE_ENUMERALTYPENODE_H
+#define NODES_TYPE_ENUMERALTYPENODE_H
+
+#include "nodes/base/type.h"
+
+#include "nodes/cst/integer_cst.h"
+
+#include "nodes/list/tree_list.h"
+
+#include <string>
+
+struct EnumeralTypeNode : public TypeNode
+{
+ EnumeralTypeNode() :
+ TypeNode(),
+ minValue(nullptr),
+ maxValue(nullptr),
+ values(nullptr),
+ precisionBits(0),
+ isUnsigned(false)
+ {
+ }
+
+ IntegerCstNode *minValue;
+ IntegerCstNode *maxValue;
+ TreeListNode *values;
+ int precisionBits;
+ bool isUnsigned;
+};
+
+#endif // NODES_TYPE_ENUMERALTYPENODE_H
diff --git a/src/parsers/type/enumeral_type.cpp b/src/parsers/type/enumeral_type.cpp
new file mode 100644
index 0000000..b609fa9
--- /dev/null
+++ b/src/parsers/type/enumeral_type.cpp
@@ -0,0 +1,63 @@
+/*
+ * 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(EnumeralType);
+
+#include "parsers/base/type.h"
+
+#include "nodes/type/enumeral_type.h"
+
+namespace Generic
+{
+
+void parseEnumeralTypeNode(EnumeralTypeNode *node)
+{
+ fillType(node);
+ Log::dump(node);
+
+ setPrintField(node, TYPE_PRECISION, precisionBits);
+ node->isUnsigned = TYPE_UNSIGNED(node->gccNode);
+ if (node->isUnsigned)
+ Log::dumpRaw(node, "- unsigned");
+ else
+ Log::dumpRaw(node, "- signed");
+
+ fillTypeName(node);
+ fillTypeAttributes(node);
+
+ node->minValue = static_cast<IntegerCstNode*>(createParseNode(
+ node,
+ TYPE_MIN_VALUE(node->gccNode),
+ INTEGER_CST,
+ "min value"));
+ node->maxValue = static_cast<IntegerCstNode*>(createParseNode(
+ node,
+ TYPE_MAX_VALUE(node->gccNode),
+ INTEGER_CST,
+ "max value"));
+ node->values = static_cast<TreeListNode*>(createParseNode(
+ node,
+ TYPE_VALUES(node->gccNode),
+ TREE_LIST,
+ "values"));
+}
+
+}