1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
|
/* $Id$
*
* Resolve ranges of positional and named aggregates, where the type
* is an unconstraint array.
*
* Copyright (C) 2009 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#ifndef __UNCONSTRAINT_BOUNDS_HPP_INCLUDED
#define __UNCONSTRAINT_BOUNDS_HPP_INCLUDED
#include "frontend/visitor/NullVisitor.hpp"
#include "frontend/ast/Types.hpp"
namespace ast {
//! Resolve the bounds of an unconstraint array aggregate.
/** This visitor can be used to determine the bounds of an unconstraint
* Array Aggregate.
*
* It is useful wherever a an unconstraint variable/parameter/port
* will get its actual constraints from the initializer.
*
* In contrast to ResolveAggregates, this visitor will not set element
* position number, but only determine the bounds and direction.
*
* This visitor should be used only on small portions of the syntax
* tree, i.e. only Aggregates should accept it.
*
* Important: This visitor assumes that the type of the Aggregate has been
* determined already, but that it is an unconstraint type.
* It is definitely wrong to use this visitor for a constraint
* type.
*/
class UnconstraintBounds : public NullVisitor {
public:
//! dummy c'tor
UnconstraintBounds();
//! dummy d'tor
virtual ~UnconstraintBounds() {}
//! picked up bounds (if any)
DiscreteRange *bounds;
private:
/** Visit an Aggregate node.
* @param node Aggregate node that get's visited.
*/
virtual void visit(Aggregate &node);
/** visit a ElementAssociation
* @param node node that get's visited.
*/
virtual void visit(ElementAssociation &node);
/** Visit an Others node.
* @param node Others node that get's visited.
*/
virtual void visit(Others &node);
/** Visit a ConstInteger node.
* @param node ConstInteger node that get's visited.
*/
virtual void visit(ConstInteger &node);
/** Visit a DiscreteRange
* @param node DiscreteRange node that get's visited.
*/
virtual void visit(DiscreteRange &node);
//! Process a generic AstNode.
/** Failmatch method. Must not be called.
*
* @param node AstNode
*/
virtual void process(AstNode &node);
/** determine the index range of the unconstraint array at by
* the index type.
* @param at unconstraint array type.
* @return index range of the index subtype of at
*/
static DiscreteRange *
findIndexRange(const UnconstrainedArrayType *at);
/** low bound of determined index */
universal_integer low;
/** high bound of determined index */
universal_integer high;
/** number of elements for positional aggregates */
size_t numElements;
/** is it a positional aggregate? */
bool positional;
};
}; /* namespace ast */
#endif /* __UNCONSTRAINT_BOUNDS_HPP_INCLUDED */
|