From 054e89055decdf6b61a5f9430fc430b5704b4539 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 15 Jun 2015 00:56:22 +0300 Subject: Add parsing ARRAY_REF. --- src/Makefile.files | 4 ++- src/includes/nodeincludes.h | 1 + src/includes/nodeshandling.inc | 1 + src/includes/parserdefines.inc | 1 + src/nodes/ref/array_ref.h | 40 ++++++++++++++++++++++++++++++ src/parsers/ref/array_ref.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 src/nodes/ref/array_ref.h create mode 100644 src/parsers/ref/array_ref.cpp diff --git a/src/Makefile.files b/src/Makefile.files index 25e03ae..8e4eb68 100644 --- a/src/Makefile.files +++ b/src/Makefile.files @@ -266,4 +266,6 @@ SRC = analysis/analysis.cpp \ nodes/expr/asm_expr.h \ parsers/expr/asm_expr.cpp \ nodes/expr/throw_expr.h \ - parsers/expr/throw_expr.cpp \ No newline at end of file + parsers/expr/throw_expr.cpp \ + nodes/ref/array_ref.h \ + parsers/ref/array_ref.cpp \ No newline at end of file diff --git a/src/includes/nodeincludes.h b/src/includes/nodeincludes.h index 0d6e963..6748aa0 100644 --- a/src/includes/nodeincludes.h +++ b/src/includes/nodeincludes.h @@ -111,3 +111,4 @@ #include "nodes/ref/objtype_ref.h" #include "nodes/expr/asm_expr.h" #include "nodes/expr/throw_expr.h" +#include "nodes/ref/array_ref.h" diff --git a/src/includes/nodeshandling.inc b/src/includes/nodeshandling.inc index ae0234a..a6e4e21 100644 --- a/src/includes/nodeshandling.inc +++ b/src/includes/nodeshandling.inc @@ -110,3 +110,4 @@ handleNodeType(FIX_TRUNC_EXPR, FixTruncExpr) handleNodeType(OBJ_TYPE_REF, ObjTypeRef) handleNodeType(ASM_EXPR, AsmExpr) handleNodeType(THROW_EXPR, ThrowExpr) +handleNodeType(ARRAY_REF, ArrayRef) diff --git a/src/includes/parserdefines.inc b/src/includes/parserdefines.inc index 9571365..9d72b0d 100644 --- a/src/includes/parserdefines.inc +++ b/src/includes/parserdefines.inc @@ -110,3 +110,4 @@ parserDefine(FixTruncExpr); parserDefine(ObjTypeRef); parserDefine(AsmExpr); parserDefine(ThrowExpr); +parserDefine(ArrayRef); diff --git a/src/nodes/ref/array_ref.h b/src/nodes/ref/array_ref.h new file mode 100644 index 0000000..48f619e --- /dev/null +++ b/src/nodes/ref/array_ref.h @@ -0,0 +1,40 @@ +/* + * 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 NODES_REF_ARRAYREFNODE_H +#define NODES_REF_ARRAYREFNODE_H + +#include "nodes/base/ref.h" + +#include + +struct ArrayRefNode : public RefNode +{ + ArrayRefNode() : + RefNode(), + elementSize(nullptr), + lowBound(nullptr) + { + } + + Node *elementSize; + Node *lowBound; +}; + +#endif // NODES_REF_ARRAYREFNODE_H diff --git a/src/parsers/ref/array_ref.cpp b/src/parsers/ref/array_ref.cpp new file mode 100644 index 0000000..584b65b --- /dev/null +++ b/src/parsers/ref/array_ref.cpp @@ -0,0 +1,56 @@ +/* + * 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 "includes/parserincludes.h" + +parserDefine(ArrayRef); + +#include "parsers/base/ref.h" + +#include "nodes/ref/array_ref.h" + +#include "rtl.h" +#include "expr.h" + +namespace Generic +{ + +void parseArrayRefNode(ArrayRefNode *node) +{ + fillType(node); + fillRefLocation(node); + Log::dump(node); + + node->lowBound = createParseNode( + node, + array_ref_low_bound(node->gccNode), + "low bound"); + + node->elementSize = createParseNode( + node, + array_ref_element_size(node->gccNode), + "element size"); + + fillRefOperands(node); + + // args 0 array + // args 1 index +} + +} -- cgit v1.2.3-70-g09d2