2014-07-23 22:39:29 +02:00
|
|
|
#ifndef IVL_vtype_H
|
|
|
|
|
#define IVL_vtype_H
|
2011-02-07 05:55:31 +01:00
|
|
|
/*
|
2014-07-23 22:39:29 +02:00
|
|
|
* Copyright (c) 2011-2014 Stephen Williams (steve@icarus.com)
|
2014-08-25 17:29:35 +02:00
|
|
|
* Copyright CERN 2014 / Stephen Williams (steve@icarus.com),
|
2014-08-06 15:00:35 +02:00
|
|
|
* Maciej Suminski (maciej.suminski@cern.ch)
|
2011-02-07 05:55:31 +01:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* 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, write to the Free Software
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-02-07 05:55:31 +01:00
|
|
|
*/
|
|
|
|
|
|
2011-02-14 04:01:21 +01:00
|
|
|
# include <iostream>
|
2011-10-02 02:04:04 +02:00
|
|
|
# include <list>
|
2012-05-13 03:38:49 +02:00
|
|
|
# include <map>
|
2011-02-14 01:37:10 +01:00
|
|
|
# include <vector>
|
|
|
|
|
# include <climits>
|
2011-04-18 02:19:09 +02:00
|
|
|
# include <inttypes.h>
|
2011-02-07 05:55:31 +01:00
|
|
|
# include "StringHeap.h"
|
|
|
|
|
|
2013-06-08 00:47:14 +02:00
|
|
|
class Architecture;
|
2015-01-26 15:00:51 +01:00
|
|
|
class ScopeBase;
|
2013-06-08 00:47:14 +02:00
|
|
|
class Entity;
|
2011-10-16 02:41:48 +02:00
|
|
|
class Expression;
|
2011-11-05 23:55:17 +01:00
|
|
|
class prange_t;
|
2012-05-13 03:38:49 +02:00
|
|
|
class VTypeDef;
|
2015-01-26 11:15:57 +01:00
|
|
|
class ScopeBase;
|
2012-05-13 03:38:49 +02:00
|
|
|
|
|
|
|
|
typedef enum typedef_topo_e { NONE=0, PENDING, MARKED } typedef_topo_t;
|
|
|
|
|
typedef std::map<const VTypeDef*, typedef_topo_t> typedef_context_t;
|
2011-10-16 02:41:48 +02:00
|
|
|
|
2011-02-14 01:37:10 +01:00
|
|
|
/*
|
|
|
|
|
* A description of a VHDL type consists of a graph of VType
|
|
|
|
|
* objects. Derived types are specific kinds of types, and those that
|
|
|
|
|
* are compound may in turn reference other types.
|
|
|
|
|
*/
|
2011-02-07 05:55:31 +01:00
|
|
|
class VType {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
VType() { }
|
|
|
|
|
virtual ~VType() =0;
|
2011-02-14 04:01:21 +01:00
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
virtual VType*clone() const =0;
|
|
|
|
|
|
2013-06-08 00:47:14 +02:00
|
|
|
// This is rarely used, but some types may have expressions
|
|
|
|
|
// that need to be elaborated.
|
2015-01-26 15:00:51 +01:00
|
|
|
virtual int elaborate(Entity*end, ScopeBase*scope) const;
|
2013-06-08 00:47:14 +02:00
|
|
|
|
2013-05-19 02:36:29 +02:00
|
|
|
// This virtual method returns true if that is equivalent to
|
|
|
|
|
// this type. This method is used for example to compare
|
|
|
|
|
// function prototypes.
|
|
|
|
|
virtual bool type_match(const VType*that) const;
|
|
|
|
|
|
2011-07-20 04:19:27 +02:00
|
|
|
// This virtual method writes a VHDL-accurate representation
|
|
|
|
|
// of this type to the designated stream. This is used for
|
|
|
|
|
// writing parsed types to library files.
|
|
|
|
|
virtual void write_to_stream(std::ostream&fd) const;
|
2015-02-26 13:27:47 +01:00
|
|
|
|
2012-05-06 00:15:45 +02:00
|
|
|
// This is like the above, but is the root function called
|
|
|
|
|
// directly after the "type <name> is..." when writing type
|
|
|
|
|
// definitions. Most types accept the default definition of this.
|
|
|
|
|
virtual void write_type_to_stream(std::ostream&fd) const;
|
2011-07-20 04:19:27 +02:00
|
|
|
|
2011-10-02 02:04:04 +02:00
|
|
|
// This virtual method writes a human-readable version of the
|
|
|
|
|
// type to a given file for debug purposes. (Question: is this
|
|
|
|
|
// really necessary given the write_to_stream method?)
|
2011-02-14 04:01:21 +01:00
|
|
|
virtual void show(std::ostream&) const;
|
2011-03-27 21:01:58 +02:00
|
|
|
|
2011-10-10 00:25:35 +02:00
|
|
|
// This virtual method emits a definition for the specific
|
|
|
|
|
// type. It is used to emit typedef's.
|
2014-08-22 10:49:55 +02:00
|
|
|
virtual int emit_def(std::ostream&out, perm_string name) const =0;
|
2011-10-10 00:25:35 +02:00
|
|
|
|
2012-05-13 03:38:49 +02:00
|
|
|
// This virtual method causes VTypeDef types to emit typedefs
|
|
|
|
|
// of themselves. The VTypeDef implementation of this method
|
|
|
|
|
// uses this method recursively to do a depth-first emit of
|
|
|
|
|
// all the types that it emits.
|
|
|
|
|
virtual int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
|
|
|
|
|
2014-08-22 10:45:02 +02:00
|
|
|
// Determines if a type can be used in Verilog packed array.
|
|
|
|
|
virtual bool can_be_packed() const { return false; }
|
|
|
|
|
|
2015-01-22 11:17:33 +01:00
|
|
|
// Returns true if the type has an undefined dimension.
|
|
|
|
|
virtual bool is_unbounded() const { return false; }
|
|
|
|
|
|
2015-01-23 17:24:00 +01:00
|
|
|
// Checks if the variable length is dependent on other expressions, that
|
|
|
|
|
// cannot be evaluated (e.g. 'length, 'left, 'right).
|
2015-01-26 11:15:57 +01:00
|
|
|
virtual bool is_variable_length(ScopeBase*) const { return false; }
|
2015-01-23 17:24:00 +01:00
|
|
|
|
2015-01-22 11:32:28 +01:00
|
|
|
// Returns a perm_string that can be used in automatically created
|
|
|
|
|
// typedefs (i.e. not ones defined by the user).
|
|
|
|
|
perm_string get_generic_typename() const;
|
|
|
|
|
|
2015-02-26 13:27:47 +01:00
|
|
|
// Returns the type width in bits or negative number if it is impossible
|
|
|
|
|
// to evaluate.
|
2015-03-02 14:33:26 +01:00
|
|
|
virtual int get_width(ScopeBase*) const { return -1; }
|
2015-02-26 13:27:47 +01:00
|
|
|
|
2011-10-10 00:25:35 +02:00
|
|
|
private:
|
2014-09-29 16:05:26 +02:00
|
|
|
friend struct decl_t;
|
2011-10-10 00:25:35 +02:00
|
|
|
// This virtual method is called to emit the declaration. This
|
|
|
|
|
// is used by the decl_t object to emit variable/wire/port declarations.
|
2012-04-29 03:37:22 +02:00
|
|
|
virtual int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;
|
2011-10-10 00:25:35 +02:00
|
|
|
|
2011-03-27 21:01:58 +02:00
|
|
|
public:
|
2011-10-02 19:56:00 +02:00
|
|
|
// A couple places use the VType along with a few
|
|
|
|
|
// per-declaration details, so provide a common structure for
|
|
|
|
|
// holding that stuff together.
|
2011-03-27 21:01:58 +02:00
|
|
|
struct decl_t {
|
2011-10-02 19:56:00 +02:00
|
|
|
decl_t() : type(0), reg_flag(false) { }
|
2011-03-27 21:01:58 +02:00
|
|
|
int emit(std::ostream&out, perm_string name) const;
|
2011-10-02 19:56:00 +02:00
|
|
|
|
|
|
|
|
const VType*type;
|
2011-05-16 01:17:51 +02:00
|
|
|
bool reg_flag;
|
2011-03-27 21:01:58 +02:00
|
|
|
};
|
2011-10-02 19:56:00 +02:00
|
|
|
|
2014-08-25 16:57:27 +02:00
|
|
|
protected:
|
|
|
|
|
inline void emit_name(std::ostream&out, perm_string name) const
|
|
|
|
|
{
|
|
|
|
|
if(name != empty_perm_string)
|
|
|
|
|
out << " \\" << name << " ";
|
|
|
|
|
}
|
2011-02-07 05:55:31 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-14 04:01:21 +01:00
|
|
|
inline std::ostream&operator << (std::ostream&out, const VType&item)
|
|
|
|
|
{
|
|
|
|
|
item.show(out);
|
|
|
|
|
return out;
|
|
|
|
|
}
|
|
|
|
|
|
2011-02-07 05:55:31 +01:00
|
|
|
extern void preload_global_types(void);
|
2011-02-19 22:08:26 +01:00
|
|
|
|
2012-11-03 03:30:12 +01:00
|
|
|
/*
|
|
|
|
|
* This type is a placeholder for ERROR types.
|
|
|
|
|
*/
|
|
|
|
|
class VTypeERROR : public VType {
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return NULL; }
|
|
|
|
|
|
2012-11-03 03:30:12 +01:00
|
|
|
public:
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2012-11-03 03:30:12 +01:00
|
|
|
};
|
|
|
|
|
|
2011-02-07 05:55:31 +01:00
|
|
|
/*
|
2012-05-14 18:58:49 +02:00
|
|
|
* This class represents the primitive types that are available to the
|
2011-02-07 05:55:31 +01:00
|
|
|
* type subsystem.
|
|
|
|
|
*/
|
|
|
|
|
class VTypePrimitive : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
2015-02-17 14:58:33 +01:00
|
|
|
enum type_t { BOOLEAN, BIT, INTEGER, NATURAL, REAL, STDLOGIC, CHARACTER };
|
2011-02-07 05:55:31 +01:00
|
|
|
|
|
|
|
|
public:
|
2014-08-22 10:45:02 +02:00
|
|
|
VTypePrimitive(type_t tt, bool packed = false);
|
2011-02-07 05:55:31 +01:00
|
|
|
~VTypePrimitive();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return new VTypePrimitive(*this); }
|
|
|
|
|
|
2011-07-20 04:19:27 +02:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2011-02-14 04:01:21 +01:00
|
|
|
void show(std::ostream&) const;
|
2015-03-02 14:33:26 +01:00
|
|
|
int get_width(ScopeBase*scope) const;
|
2011-02-14 04:01:21 +01:00
|
|
|
|
2011-02-07 05:55:31 +01:00
|
|
|
type_t type() const { return type_; }
|
|
|
|
|
|
2011-10-02 19:56:00 +02:00
|
|
|
int emit_primitive_type(std::ostream&fd) const;
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2011-10-02 19:56:00 +02:00
|
|
|
|
2014-08-22 10:45:02 +02:00
|
|
|
bool can_be_packed() const { return packed_; }
|
|
|
|
|
|
2011-02-07 05:55:31 +01:00
|
|
|
private:
|
|
|
|
|
type_t type_;
|
2014-08-22 10:45:02 +02:00
|
|
|
bool packed_;
|
2011-02-07 05:55:31 +01:00
|
|
|
};
|
|
|
|
|
|
2014-08-06 15:01:28 +02:00
|
|
|
extern const VTypePrimitive primitive_BOOLEAN;
|
|
|
|
|
extern const VTypePrimitive primitive_BIT;
|
|
|
|
|
extern const VTypePrimitive primitive_INTEGER;
|
2015-02-17 14:58:33 +01:00
|
|
|
extern const VTypePrimitive primitive_NATURAL;
|
2014-08-06 15:01:28 +02:00
|
|
|
extern const VTypePrimitive primitive_REAL;
|
|
|
|
|
extern const VTypePrimitive primitive_STDLOGIC;
|
|
|
|
|
extern const VTypePrimitive primitive_CHARACTER;
|
2011-02-07 05:55:31 +01:00
|
|
|
|
2011-02-14 01:37:10 +01:00
|
|
|
/*
|
|
|
|
|
* An array is a compound N-dimensional array of element type. The
|
|
|
|
|
* construction of the array is from an element type and a vector of
|
|
|
|
|
* ranges. The array type can be left incomplete by leaving some
|
|
|
|
|
* ranges as "box" ranges, meaning present but not defined.
|
|
|
|
|
*/
|
2011-02-07 05:55:31 +01:00
|
|
|
class VTypeArray : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
2011-02-14 01:37:10 +01:00
|
|
|
class range_t {
|
|
|
|
|
public:
|
2015-03-27 11:41:55 +01:00
|
|
|
range_t(Expression*m = NULL, Expression*l = NULL, bool down_to = true) :
|
|
|
|
|
msb_(m), lsb_(l), direction_(down_to) { }
|
2011-02-14 01:37:10 +01:00
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
range_t*clone() const;
|
|
|
|
|
|
2014-09-10 14:32:02 +02:00
|
|
|
inline bool is_box() const { return msb_==0 && lsb_==0; }
|
|
|
|
|
inline bool is_downto() const { return direction_; }
|
2011-02-14 01:37:10 +01:00
|
|
|
|
2014-09-10 14:32:02 +02:00
|
|
|
inline Expression* msb() const { return msb_; }
|
|
|
|
|
inline Expression* lsb() const { return lsb_; }
|
2011-02-14 01:37:10 +01:00
|
|
|
|
|
|
|
|
private:
|
2011-10-16 02:41:48 +02:00
|
|
|
Expression* msb_;
|
|
|
|
|
Expression* lsb_;
|
2014-09-10 14:32:02 +02:00
|
|
|
bool direction_;
|
2011-02-14 01:37:10 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
2015-03-27 13:56:59 +01:00
|
|
|
VTypeArray(const VType*etype, const std::vector<range_t>&r, bool signed_vector = false);
|
|
|
|
|
VTypeArray(const VType*etype, std::list<prange_t*>*r, bool signed_vector = false);
|
|
|
|
|
VTypeArray(const VType*etype, int msb, int lsb, bool signed_vector = false);
|
2011-02-07 05:55:31 +01:00
|
|
|
~VTypeArray();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const;
|
|
|
|
|
|
2015-01-26 15:00:51 +01:00
|
|
|
int elaborate(Entity*ent, ScopeBase*scope) const;
|
2011-07-20 04:19:27 +02:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2014-10-09 10:37:33 +02:00
|
|
|
void write_type_to_stream(std::ostream&fd) const;
|
2011-02-14 04:01:21 +01:00
|
|
|
void show(std::ostream&) const;
|
2015-03-02 14:33:26 +01:00
|
|
|
int get_width(ScopeBase*scope) const;
|
2011-02-14 04:01:21 +01:00
|
|
|
|
2014-09-10 16:02:59 +02:00
|
|
|
inline size_t dimensions() const { return ranges_.size(); };
|
2011-02-14 04:01:21 +01:00
|
|
|
const range_t&dimension(size_t idx) const
|
|
|
|
|
{ return ranges_[idx]; }
|
|
|
|
|
|
2014-09-10 16:02:59 +02:00
|
|
|
inline bool signed_vector() const { return signed_flag_; }
|
2011-02-26 05:09:31 +01:00
|
|
|
|
2014-09-10 16:02:59 +02:00
|
|
|
// returns the type of element held in the array
|
2015-01-23 17:07:19 +01:00
|
|
|
inline const VType* element_type() const { return parent_ ? parent_->element_type() : etype_; }
|
2011-02-07 05:55:31 +01:00
|
|
|
|
2014-09-15 11:08:14 +02:00
|
|
|
// returns the basic type of element held in the array
|
|
|
|
|
// (unfolds typedefs and multidimensional arrays)
|
|
|
|
|
// typedef_allowed decides if VTypeDef can be returned or should
|
|
|
|
|
// it be unfolded
|
|
|
|
|
const VType* basic_type(bool typedef_allowed = true) const;
|
|
|
|
|
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2012-05-13 03:38:49 +02:00
|
|
|
int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
2011-10-02 19:56:00 +02:00
|
|
|
|
2014-08-22 10:45:02 +02:00
|
|
|
bool can_be_packed() const { return etype_->can_be_packed(); }
|
|
|
|
|
|
2015-01-22 11:17:33 +01:00
|
|
|
bool is_unbounded() const;
|
|
|
|
|
|
2015-01-26 11:15:57 +01:00
|
|
|
bool is_variable_length(ScopeBase*scope) const;
|
2015-01-23 17:24:00 +01:00
|
|
|
|
2015-01-23 17:07:19 +01:00
|
|
|
// To handle subtypes
|
|
|
|
|
inline void set_parent_type(const VTypeArray*parent) { parent_ = parent; }
|
|
|
|
|
|
2015-01-26 17:51:42 +01:00
|
|
|
// Wherever it is possible, replaces range lsb & msb expressions with
|
|
|
|
|
// constant integers.
|
|
|
|
|
void evaluate_ranges(ScopeBase*scope);
|
|
|
|
|
|
2011-02-07 05:55:31 +01:00
|
|
|
private:
|
2015-01-19 17:33:15 +01:00
|
|
|
int emit_with_dims_(std::ostream&out, bool packed, perm_string name) const;
|
|
|
|
|
|
2014-09-10 14:32:02 +02:00
|
|
|
void write_range_to_stream_(std::ostream&fd) const;
|
2011-02-14 01:37:10 +01:00
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
const VType*etype_;
|
2011-02-14 01:37:10 +01:00
|
|
|
std::vector<range_t> ranges_;
|
2011-02-26 05:09:31 +01:00
|
|
|
bool signed_flag_;
|
2015-01-23 17:07:19 +01:00
|
|
|
const VTypeArray*parent_;
|
2011-02-07 05:55:31 +01:00
|
|
|
};
|
|
|
|
|
|
2011-04-18 02:19:09 +02:00
|
|
|
class VTypeRange : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
VTypeRange(const VType*base, int64_t max_val, int64_t min_val);
|
|
|
|
|
~VTypeRange();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return new VTypeRange(base_->clone(), max_, min_); }
|
|
|
|
|
|
2013-06-08 00:49:19 +02:00
|
|
|
// Get the type that is limited by the range.
|
|
|
|
|
inline const VType* base_type() const { return base_; }
|
|
|
|
|
|
|
|
|
|
public: // Virtual methods
|
2012-03-18 19:21:23 +01:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2011-04-18 02:19:09 +02:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const VType*base_;
|
|
|
|
|
int64_t max_, min_;
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-02 02:04:04 +02:00
|
|
|
class VTypeEnum : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
VTypeEnum(const std::list<perm_string>*names);
|
|
|
|
|
~VTypeEnum();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return new VTypeEnum(*this); }
|
|
|
|
|
|
2014-09-05 14:58:48 +02:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2011-10-10 00:25:35 +02:00
|
|
|
void show(std::ostream&) const;
|
2015-03-02 14:33:26 +01:00
|
|
|
int get_width(ScopeBase*) const { return 32; }
|
2015-02-26 13:27:47 +01:00
|
|
|
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2011-10-02 02:04:04 +02:00
|
|
|
|
2015-02-06 10:44:22 +01:00
|
|
|
// Checks if the name is stored in the enum.
|
|
|
|
|
bool has_name(perm_string name) const;
|
|
|
|
|
|
2011-10-02 02:04:04 +02:00
|
|
|
private:
|
|
|
|
|
std::vector<perm_string>names_;
|
|
|
|
|
};
|
|
|
|
|
|
2012-03-17 23:03:19 +01:00
|
|
|
class VTypeRecord : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
class element_t {
|
|
|
|
|
public:
|
|
|
|
|
element_t(perm_string name, const VType*type);
|
|
|
|
|
|
2012-03-18 19:21:23 +01:00
|
|
|
void write_to_stream(std::ostream&) const;
|
2012-03-17 23:03:19 +01:00
|
|
|
|
2012-04-02 03:48:19 +02:00
|
|
|
inline perm_string peek_name() const { return name_; }
|
|
|
|
|
inline const VType* peek_type() const { return type_; }
|
|
|
|
|
|
2012-03-17 23:03:19 +01:00
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
|
|
|
|
const VType*type_;
|
|
|
|
|
|
|
|
|
|
private:// Not implement
|
|
|
|
|
element_t(const element_t&);
|
|
|
|
|
element_t& operator= (const element_t);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
explicit VTypeRecord(std::list<element_t*>*elements);
|
|
|
|
|
~VTypeRecord();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return new VTypeRecord(*this); }
|
|
|
|
|
|
2012-03-18 19:21:23 +01:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2012-03-17 23:03:19 +01:00
|
|
|
void show(std::ostream&) const;
|
2015-03-02 14:33:26 +01:00
|
|
|
int get_width(ScopeBase*scope) const;
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2012-04-02 03:48:19 +02:00
|
|
|
|
2014-08-25 16:55:26 +02:00
|
|
|
bool can_be_packed() const { return true; }
|
2014-09-17 16:32:56 +02:00
|
|
|
const element_t* element_by_name(perm_string name, int*index = NULL) const;
|
2015-02-24 16:06:55 +01:00
|
|
|
inline const std::vector<element_t*> get_elements() const { return elements_; }
|
2012-04-02 03:48:19 +02:00
|
|
|
|
2012-03-17 23:03:19 +01:00
|
|
|
private:
|
|
|
|
|
std::vector<element_t*> elements_;
|
|
|
|
|
};
|
|
|
|
|
|
2011-10-10 00:25:35 +02:00
|
|
|
class VTypeDef : public VType {
|
|
|
|
|
|
|
|
|
|
public:
|
2012-05-06 00:15:45 +02:00
|
|
|
explicit VTypeDef(perm_string name);
|
|
|
|
|
explicit VTypeDef(perm_string name, const VType*is);
|
2011-10-10 00:25:35 +02:00
|
|
|
~VTypeDef();
|
|
|
|
|
|
2015-02-02 11:00:59 +01:00
|
|
|
VType*clone() const { return new VTypeDef(*this); }
|
|
|
|
|
|
2012-09-01 23:51:04 +02:00
|
|
|
inline perm_string peek_name() const { return name_; }
|
|
|
|
|
|
2012-05-06 00:15:45 +02:00
|
|
|
// If the type is not given a definition in the constructor,
|
|
|
|
|
// then this must be used to set the definition later.
|
|
|
|
|
void set_definition(const VType*is);
|
|
|
|
|
|
2012-05-06 01:55:29 +02:00
|
|
|
// In some situations, we only need the definition of the
|
|
|
|
|
// type, and this method gets it for us.
|
|
|
|
|
inline const VType* peek_definition(void) const { return type_; }
|
|
|
|
|
|
2012-05-06 00:15:45 +02:00
|
|
|
void write_to_stream(std::ostream&fd) const;
|
2014-10-09 10:37:33 +02:00
|
|
|
void write_type_to_stream(std::ostream&fd) const;
|
2015-03-02 14:33:26 +01:00
|
|
|
int get_width(ScopeBase*scope) const { return type_->get_width(scope); }
|
2012-05-13 03:38:49 +02:00
|
|
|
int emit_typedef(std::ostream&out, typedef_context_t&ctx) const;
|
2011-10-10 00:25:35 +02:00
|
|
|
|
2014-08-22 10:49:55 +02:00
|
|
|
int emit_def(std::ostream&out, perm_string name) const;
|
2014-08-25 16:55:26 +02:00
|
|
|
|
|
|
|
|
bool can_be_packed() const { return type_->can_be_packed(); }
|
2015-01-22 11:17:33 +01:00
|
|
|
|
|
|
|
|
bool is_unbounded() const { return type_->is_unbounded(); }
|
2011-10-10 00:25:35 +02:00
|
|
|
private:
|
|
|
|
|
int emit_decl(std::ostream&out, perm_string name, bool reg_flag) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
perm_string name_;
|
|
|
|
|
const VType*type_;
|
|
|
|
|
};
|
|
|
|
|
|
2014-07-23 22:39:29 +02:00
|
|
|
#endif /* IVL_vtype_H */
|