diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.files | 4 | ||||
-rw-r--r-- | src/includes/nodeincludes.h | 1 | ||||
-rw-r--r-- | src/includes/nodeshandling.inc | 1 | ||||
-rw-r--r-- | src/includes/parserdefines.inc | 1 | ||||
-rw-r--r-- | src/nodes/type/array_type.h | 48 | ||||
-rw-r--r-- | src/parsers/type/array_type.cpp | 62 |
6 files changed, 116 insertions, 1 deletions
diff --git a/src/Makefile.files b/src/Makefile.files index 86ffffa..bf2770e 100644 --- a/src/Makefile.files +++ b/src/Makefile.files @@ -181,4 +181,6 @@ SRC = analysis/analysis.cpp \ nodes/expr/lshift_expr.h \ parsers/expr/lshift_expr.cpp \ nodes/expr/postincrement_expr.h \ - parsers/expr/postincrement_expr.cpp
\ No newline at end of file + parsers/expr/postincrement_expr.cpp \ + nodes/type/array_type.h \ + parsers/type/array_type.cpp
\ No newline at end of file diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h index 918ca6c..f04a7f2 100644 --- a/src/includes/nodeincludes.h +++ b/src/includes/nodeincludes.h @@ -70,3 +70,4 @@ #include "nodes/expr/rshift_expr.h" #include "nodes/expr/lshift_expr.h" #include "nodes/expr/postincrement_expr.h" +#include "nodes/type/array_type.h" diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc index 67f8176..9ad8380 100644 --- a/src/includes/nodeshandling.inc +++ b/src/includes/nodeshandling.inc @@ -69,3 +69,4 @@ handleNodeType(TRY_CATCH_EXPR, TryCatchExpr) handleNodeType(RSHIFT_EXPR, RShiftExpr) handleNodeType(LSHIFT_EXPR, LShiftExpr) handleNodeType(POSTINCREMENT_EXPR, PostIncrementExpr) +handleNodeType(ARRAY_TYPE, ArrayType) diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc index 53d0c7b..53ede88 100644 --- a/src/includes/parserdefines.inc +++ b/src/includes/parserdefines.inc @@ -69,3 +69,4 @@ parserDefine(TryCatchExpr); parserDefine(RShiftExpr); parserDefine(LShiftExpr); parserDefine(PostIncrementExpr); +parserDefine(ArrayType); diff --git a/src/nodes/type/array_type.h b/src/nodes/type/array_type.h new file mode 100644 index 0000000..3a5d714 --- /dev/null +++ b/src/nodes/type/array_type.h @@ -0,0 +1,48 @@ +/* + * 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_ARRAYTYPENODE_H +#define NODES_TYPE_ARRAYTYPENODE_H + +#include "nodes/base/type.h" + +#include "nodes/cst/integer_cst.h" + +#include <string> + +struct ArrayTypeNode : public TypeNode +{ + ArrayTypeNode() : + TypeNode(), + domain(nullptr), + elementType(nullptr), + minIndex(nullptr), + maxIndex(nullptr), + isString(false) + { + } + + TypeNode *domain; + TypeNode *elementType; + IntegerCstNode *minIndex; + IntegerCstNode *maxIndex; + bool isString; +}; + +#endif // NODES_TYPE_ARRAYTYPENODE_H diff --git a/src/parsers/type/array_type.cpp b/src/parsers/type/array_type.cpp new file mode 100644 index 0000000..a1594a7 --- /dev/null +++ b/src/parsers/type/array_type.cpp @@ -0,0 +1,62 @@ +/* + * 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(ArrayType); + +#include "parsers/base/type.h" + +#include "nodes/type/array_type.h" + +namespace Generic +{ + +void parseArrayTypeNode(ArrayTypeNode *node) +{ + fillType(node); + Log::dump(node); + + setPrintField(node, TYPE_STRING_FLAG, isString); + + fillTypeName(node); + fillTypeAttributes(node); + + node->elementType = static_cast<TypeNode*>(createParseNode( + node, + TREE_TYPE(node->gccNode), + "element type")); + + node->domain = static_cast<TypeNode*>(createParseNode( + node, + TYPE_DOMAIN(node->gccNode), + "domain")); + node->minIndex = static_cast<IntegerCstNode*>(createParseNode( + node, + TYPE_MIN_VALUE(node->gccNode), + INTEGER_CST, + "min index")); + node->maxIndex = static_cast<IntegerCstNode*>(createParseNode( + node, + TYPE_MAX_VALUE(node->gccNode), + INTEGER_CST, + "max index")); +} + +} |