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 103 104 105 106 107
|
/* $Id$
*
* ValDeclaration: abstract representation of a signal, variable or constant
* declaration.
*
* Copyright (C) 2007-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 __VAL_DECLARATION_HPP_INCLUDDED
#define __VAL_DECLARATION_HPP_INCLUDDED
#include <string>
#include "frontend/ast/AttributableDeclaration.hpp"
#include "frontend/ast/Expression.hpp"
#include "frontend/ast/SubtypeIndication.hpp"
namespace ast {
//! A signal, variable or constant declaration.
/** This class represents a declaration of either a VHDL signal,
* a VHDL variable or a VHDL constant.
*/
class ValDeclaration : public AttributableDeclaration {
public:
/** VHDL mode attribute (in, out, inout)
*/
enum Mode {
MODE_IN, /**< access mode in */
MODE_OUT, /**< access mode out */
MODE_INOUT /**< access mode inout */
};
/** Storage class (signal, constant, variable) */
enum ObjClass {
OBJ_CLASS_SIGNAL, /**< signal */
OBJ_CLASS_VARIABLE, /**< variable */
OBJ_CLASS_CONSTANT, /**< constant */
OBJ_CLASS_UNSPECIFIED /**< unspecified */
};
/** mode in which this declaration is used */
enum UsageMode {
/** not used at all */
USAGE_NONE = 0,
/** read from VHDL */
USAGE_READ = 1 << 0,
/** written to from VHDL */
USAGE_WRITE = 1 << 1,
/** signal used in a foreign component */
USAGE_FOREIGN = 1 << 2
};
/** c'tor
* @param accessMode mode of the Signal (in, out, inout).
* @param declName the declared name
* @param varInit initializer Expression for the value.
* @param subtype subtype indication of the value.
* @param sc storage class for convenience.
* @param loc Location of the declaration.
*/
ValDeclaration(
enum Mode accessMode,
std::string *declName,
Expression *varInit,
SubtypeIndication *subtype,
enum ObjClass sc,
Location loc
) : AttributableDeclaration(declName, loc),
init(varInit),
mode(accessMode),
subtypeIndic(subtype),
storageClass(sc),
usage(USAGE_NONE) {}
/** initial value (optional) */
Expression *init;
/** access mode */
enum Mode mode;
/** subtype indication */
SubtypeIndication *subtypeIndic;
/** storage class for convenience */
enum ObjClass storageClass;
/** does the declaration denote an Unconstraint array?
* @return true if the declaration denotes an unconstraint array,
* false otherwise.
*/
bool isUnconstraint(void) const;
/** useage of the declaration */
int usage;
protected:
/** Destructor */
virtual ~ValDeclaration() {
util::MiscUtil::terminate(init);
util::MiscUtil::terminate(subtypeIndic);
}
};
}; /* namespace ast */
#endif /* __VAL_DECLARATION_HPP_INCLUDDED */
|