vhdlpp: Elaborate and emit functions work with ScopeBase instead of Architecture.

This commit is contained in:
Maciej Suminski 2015-01-26 15:00:51 +01:00
parent 90293d8e0a
commit 25c3798248
13 changed files with 439 additions and 431 deletions

View File

@ -31,7 +31,6 @@
class prange_t;
class Entity;
class Architecture;
class ScopeBase;
class Subprogram;
class VType;
@ -56,13 +55,13 @@ class Expression : public LineInfo {
// assignment. This generates an error for most cases, but
// expressions that are valid l-values return 0 and set any
// flags needed to indicate their status as writable variables.
virtual int elaborate_lval(Entity*ent, Architecture*arc,
virtual int elaborate_lval(Entity*ent, ScopeBase*scope,
bool is_sequ);
// This virtual method probes the expression to get the most
// constrained type for the expression. For a given instance,
// this may be called before the elaborate_expr method.
virtual const VType*probe_type(Entity*ent, Architecture*arc) const;
virtual const VType*probe_type(Entity*ent, ScopeBase*scope) const;
// The fit_type virtual method is used by the ExpConcat class
// to probe the type of operands. The atype argument is the
@ -70,13 +69,13 @@ class Expression : public LineInfo {
// returns its type as interpreted in this context. Really,
// this is mostly about helping aggregate expressions within
// concatenations to figure out their type.
virtual const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
virtual const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
// This virtual method elaborates an expression. The ltype is
// the type of the lvalue expression, if known, and can be
// used to calculate the type for the expression being
// elaborated.
virtual int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
virtual int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
// Return the type that this expression would be if it were an
// l-value. This should only be called after elaborate_lval is
@ -91,7 +90,7 @@ class Expression : public LineInfo {
// The emit virtual method is called by architecture emit to
// output the generated code for the expression. The derived
// class fills in the details of what exactly happened.
virtual int emit(ostream&out, Entity*ent, Architecture*arc) =0;
virtual int emit(ostream&out, Entity*ent, ScopeBase*scope) =0;
// The emit_package virtual message is similar, but is called
// in a package context and to emit SV packages.
@ -102,7 +101,7 @@ class Expression : public LineInfo {
// argument if the evaluation works, or return false if it
// cannot be done.
virtual bool evaluate(ScopeBase*scope, int64_t&val) const;
virtual bool evaluate(Entity*ent, Architecture*arc, int64_t&val) const;
virtual bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
// The symbolic compare returns true if the two expressions
@ -150,13 +149,13 @@ class ExpUnary : public Expression {
ExpUnary(Expression*op1);
virtual ~ExpUnary() =0;
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
protected:
inline void write_to_stream_operand1(std::ostream&fd)
{ operand1_->write_to_stream(fd); }
int emit_operand1(ostream&out, Entity*ent, Architecture*arc);
int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope);
void dump_operand1(ostream&out, int indent = 0) const;
private:
@ -176,13 +175,13 @@ class ExpBinary : public Expression {
const Expression* peek_operand1(void) const { return operand1_; }
const Expression* peek_operand2(void) const { return operand2_; }
const VType*probe_type(Entity*ent, Architecture*arc) const;
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
protected:
int elaborate_exprs(Entity*, Architecture*, const VType*);
int emit_operand1(ostream&out, Entity*ent, Architecture*arc);
int emit_operand2(ostream&out, Entity*ent, Architecture*arc);
int elaborate_exprs(Entity*, ScopeBase*, const VType*);
int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope);
int emit_operand2(ostream&out, Entity*ent, ScopeBase*scope);
bool eval_operand1(ScopeBase*scope, int64_t&val) const;
bool eval_operand2(ScopeBase*scope, int64_t&val) const;
@ -274,18 +273,18 @@ class ExpAggregate : public Expression {
~ExpAggregate();
const VType*probe_type(Entity*ent, Architecture*arc) const;
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
int elaborate_expr_array_(Entity*ent, Architecture*arc, const VTypeArray*ltype);
int elaborate_expr_record_(Entity*ent, Architecture*arc, const VTypeRecord*ltype);
int emit_array_(ostream&out, Entity*ent, Architecture*arc, const VTypeArray*ltype);
int emit_record_(ostream&out, Entity*ent, Architecture*arc, const VTypeRecord*ltype);
int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype);
int elaborate_expr_record_(Entity*ent, ScopeBase*scope, const VTypeRecord*ltype);
int emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*ltype);
int emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*ltype);
private:
// This is the elements as directly parsed.
@ -305,9 +304,9 @@ class ExpArithmetic : public ExpBinary {
ExpArithmetic(ExpArithmetic::fun_t op, Expression*op1, Expression*op2);
~ExpArithmetic();
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
virtual bool evaluate(ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const;
@ -327,13 +326,13 @@ class ExpAttribute : public Expression {
inline perm_string peek_attribute() const { return name_; }
inline const ExpName* peek_base() const { return base_; }
const VType*probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
// Some attributes can be evaluated at compile time
bool evaluate(ScopeBase*scope, int64_t&val) const;
bool evaluate(Entity*ent, Architecture*arc, int64_t&val) const;
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const;
private:
@ -347,10 +346,10 @@ class ExpBitstring : public Expression {
explicit ExpBitstring(const char*);
~ExpBitstring();
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -364,17 +363,17 @@ class ExpCharacter : public Expression {
ExpCharacter(char val);
~ExpCharacter();
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const;
char value() const { return value_; }
private:
int emit_primitive_bit_(ostream&out, Entity*ent, Architecture*arc,
int emit_primitive_bit_(ostream&out, Entity*ent, ScopeBase*scope,
const VTypePrimitive*etype);
private:
@ -387,17 +386,17 @@ class ExpConcat : public Expression {
ExpConcat(Expression*op1, Expression*op2);
~ExpConcat();
const VType*probe_type(Entity*ent, Architecture*arc) const;
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
virtual bool evaluate(ScopeBase*scope, int64_t&val) const;
bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const;
private:
int elaborate_expr_array_(Entity*ent, Architecture*arc, const VTypeArray*ltype);
int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype);
private:
Expression*operand1_;
@ -417,9 +416,9 @@ class ExpConditional : public Expression {
else_t(Expression*cond, std::list<Expression*>*tru);
~else_t();
int elaborate_expr(Entity*ent, Architecture*arc, const VType*lt);
int emit_when_else(ostream&out, Entity*ent, Architecture*arc);
int emit_else(ostream&out, Entity*ent, Architecture*arc);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*lt);
int emit_when_else(ostream&out, Entity*ent, ScopeBase*scope);
int emit_else(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -432,10 +431,10 @@ class ExpConditional : public Expression {
std::list<else_t*>*fal);
~ExpConditional();
const VType*probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -460,7 +459,7 @@ class ExpEdge : public ExpUnary {
inline fun_t edge_fun() const { return fun_; }
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -480,9 +479,9 @@ class ExpFunc : public Expression {
const VType*func_ret_type() const;
public: // Base methods
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -497,10 +496,10 @@ class ExpInteger : public Expression {
ExpInteger(int64_t val);
~ExpInteger();
const VType*probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
int emit_package(std::ostream&out);
bool is_primary(void) const;
bool evaluate(ScopeBase*scope, int64_t&val) const;
@ -517,10 +516,10 @@ class ExpReal : public Expression {
ExpReal(double val);
~ExpReal();
const VType*probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
int emit_package(std::ostream&out);
bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const;
@ -541,9 +540,9 @@ class ExpLogical : public ExpBinary {
inline fun_t logic_fun() const { return fun_; }
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -566,16 +565,16 @@ class ExpName : public Expression {
~ExpName();
public: // Base methods
int elaborate_lval(Entity*ent, Architecture*arc, bool);
int elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*);
const VType* probe_type(Entity*ent, Architecture*arc) const;
const VType* fit_type(Entity*ent, Architecture*arc, const VTypeArray*host) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate_lval(Entity*ent, ScopeBase*scope, bool);
int elaborate_rval(Entity*ent, ScopeBase*scope, const InterfacePort*);
const VType* probe_type(Entity*ent, ScopeBase*scope) const;
const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
bool is_primary(void) const;
bool evaluate(ScopeBase*scope, int64_t&val) const;
bool evaluate(Entity*ent, Architecture*arc, int64_t&val) const;
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
bool symbolic_compare(const Expression*that) const;
void dump(ostream&out, int indent = 0) const;
const char* name() const;
@ -584,13 +583,13 @@ class ExpName : public Expression {
void set_range(Expression*msb, Expression*lsb);
private:
const VType* elaborate_adjust_type_with_range_(Entity*ent, Architecture*arc, const VType*type);
const VType* elaborate_adjust_type_with_range_(Entity*ent, ScopeBase*scope, const VType*type);
int elaborate_lval_(Entity*ent, Architecture*arc, bool, ExpName*suffix);
const VType* probe_prefix_type_(Entity*ent, Architecture*arc) const;
const VType* probe_prefixed_type_(Entity*ent, Architecture*arc) const;
int elaborate_lval_(Entity*ent, ScopeBase*scope, bool, ExpName*suffix);
const VType* probe_prefix_type_(Entity*ent, ScopeBase*scope) const;
const VType* probe_prefixed_type_(Entity*ent, ScopeBase*scope) const;
int emit_as_prefix_(ostream&out, Entity*ent, Architecture*arc);
int emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope);
private:
std::auto_ptr<ExpName> prefix_;
@ -605,8 +604,8 @@ class ExpNameALL : public ExpName {
ExpNameALL() : ExpName(perm_string()) { }
public:
int elaborate_lval(Entity*ent, Architecture*arc, bool);
const VType* probe_type(Entity*ent, Architecture*arc) const;
int elaborate_lval(Entity*ent, ScopeBase*scope, bool);
const VType* probe_type(Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent =0) const;
};
@ -621,10 +620,10 @@ class ExpRelation : public ExpBinary {
ExpRelation(ExpRelation::fun_t ty, Expression*op1, Expression*op2);
~ExpRelation();
const VType* probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType* probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -637,16 +636,16 @@ class ExpString : public Expression {
explicit ExpString(const char*);
~ExpString();
const VType*fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const;
const std::vector<char>& get_value() const { return value_; }
private:
int emit_as_array_(ostream&out, Entity*ent, Architecture*arc, const VTypeArray*arr);
int emit_as_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*arr);
private:
std::vector<char> value_;
@ -659,7 +658,7 @@ class ExpUAbs : public ExpUnary {
~ExpUAbs();
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
};
@ -669,9 +668,9 @@ class ExpUNot : public ExpUnary {
ExpUNot(Expression*op1);
~ExpUNot();
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
};
@ -684,11 +683,11 @@ class ExpCast : public Expression {
ExpCast(Expression*base, const VType*type);
~ExpCast();
inline int elaborate_expr(Entity*ent, Architecture*arc, const VType*) {
return base_->elaborate_expr(ent, arc, type_);
inline int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*) {
return base_->elaborate_expr(ent, scope, type_);
}
void write_to_stream(std::ostream&fd);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:
@ -708,7 +707,7 @@ class ExpNew : public Expression {
// There is no 'new' in VHDL - do not emit anything
void write_to_stream(std::ostream&) {};
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent = 0) const;
private:

View File

@ -33,20 +33,20 @@
using namespace std;
int Expression::elaborate_lval(Entity*, Architecture*, bool)
int Expression::elaborate_lval(Entity*, ScopeBase*, bool)
{
cerr << get_fileline() << ": error: Expression is not a valid l-value." << endl;
return 1;
}
const VType* Expression::probe_type(Entity*, Architecture*) const
const VType* Expression::probe_type(Entity*, ScopeBase*) const
{
return 0;
}
const VType* Expression::fit_type(Entity*ent, Architecture*arc, const VTypeArray*) const
const VType* Expression::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*) const
{
const VType*res = probe_type(ent,arc);
const VType*res = probe_type(ent,scope);
if (res == 0) {
cerr << get_fileline() << ": internal error: "
<< "fit_type for " << typeid(*this).name()
@ -56,7 +56,7 @@ const VType* Expression::fit_type(Entity*ent, Architecture*arc, const VTypeArray
return res;
}
const VType*ExpName::elaborate_adjust_type_with_range_(Entity*, Architecture*arc, const VType*type)
const VType*ExpName::elaborate_adjust_type_with_range_(Entity*, ScopeBase*scope, const VType*type)
{
// Unfold typedefs
while (const VTypeDef*tdef = dynamic_cast<const VTypeDef*>(type)) {
@ -75,9 +75,9 @@ const VType*ExpName::elaborate_adjust_type_with_range_(Entity*, Architecture*arc
int64_t use_msb, use_lsb;
bool flag;
flag = index_->evaluate(arc, use_msb);
flag = index_->evaluate(scope, use_msb);
ivl_assert(*this, flag);
flag = lsb_->evaluate(arc, use_lsb);
flag = lsb_->evaluate(scope, use_lsb);
ivl_assert(*this, flag);
Expression*exp_msb = new ExpInteger(use_msb);
@ -91,7 +91,7 @@ const VType*ExpName::elaborate_adjust_type_with_range_(Entity*, Architecture*arc
return type;
}
int ExpName::elaborate_lval_(Entity*ent, Architecture*arc, bool is_sequ, ExpName*suffix)
int ExpName::elaborate_lval_(Entity*ent, ScopeBase*scope, bool is_sequ, ExpName*suffix)
{
int errors = 0;
@ -134,13 +134,13 @@ int ExpName::elaborate_lval_(Entity*ent, Architecture*arc, bool is_sequ, ExpName
<< ent->get_name() << "." << endl;
return errors + 1;
} else if (Signal*sig = arc->find_signal(name_)) {
} else if (Signal*sig = scope->find_signal(name_)) {
// Tell the target signal that this may be a sequential l-value.
if (is_sequ) sig->count_ref_sequ();
found_type = sig->peek_type();
} else if (Variable*var = arc->find_variable(name_)) {
} else if (Variable*var = scope->find_variable(name_)) {
// Tell the target signal that this may be a sequential l-value.
if (is_sequ) var->count_ref_sequ();
@ -201,7 +201,7 @@ int ExpName::elaborate_lval_(Entity*ent, Architecture*arc, bool is_sequ, ExpName
return errors;
}
suffix_type = suffix->elaborate_adjust_type_with_range_(ent, arc, suffix_type);
suffix_type = suffix->elaborate_adjust_type_with_range_(ent, scope, suffix_type);
ivl_assert(*this, suffix_type);
suffix->set_type(suffix_type);
@ -209,12 +209,12 @@ int ExpName::elaborate_lval_(Entity*ent, Architecture*arc, bool is_sequ, ExpName
return errors;
}
int ExpName::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
int ExpName::elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ)
{
int errors = 0;
if (prefix_.get()) {
return prefix_->elaborate_lval_(ent, arc, is_sequ, this);
return prefix_->elaborate_lval_(ent, scope, is_sequ, this);
}
const VType*found_type = 0;
@ -238,13 +238,13 @@ int ExpName::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
<< ent->get_name() << "." << endl;
return 1;
} else if (Signal*sig = arc->find_signal(name_)) {
} else if (Signal*sig = scope->find_signal(name_)) {
// Tell the target signal that this may be a sequential l-value.
if (is_sequ) sig->count_ref_sequ();
found_type = sig->peek_type();
} else if (Variable*var = arc->find_variable(name_)) {
} else if (Variable*var = scope->find_variable(name_)) {
// Tell the target signal that this may be a sequential l-value.
if (is_sequ) var->count_ref_sequ();
@ -257,13 +257,13 @@ int ExpName::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
return errors + 1;
}
found_type = elaborate_adjust_type_with_range_(ent, arc, found_type);
found_type = elaborate_adjust_type_with_range_(ent, scope, found_type);
set_type(found_type);
return errors;
}
int ExpName::elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*lval)
int ExpName::elaborate_rval(Entity*ent, ScopeBase*scope, const InterfacePort*lval)
{
int errors = 0;
@ -295,7 +295,7 @@ int ExpName::elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*lv
default:
break;
}
} else if (arc->find_signal(name_)) {
} else if (scope->find_signal(name_)) {
/* OK */
} else if (ent->find_generic(name_)) {
@ -310,21 +310,21 @@ int ExpName::elaborate_rval(Entity*ent, Architecture*arc, const InterfacePort*lv
return errors;
}
int ExpNameALL::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
int ExpNameALL::elaborate_lval(Entity*ent, ScopeBase*scope, bool is_sequ)
{
return Expression::elaborate_lval(ent, arc, is_sequ);
return Expression::elaborate_lval(ent, scope, is_sequ);
}
int Expression::elaborate_expr(Entity*, Architecture*, const VType*)
int Expression::elaborate_expr(Entity*, ScopeBase*, const VType*)
{
cerr << get_fileline() << ": internal error: I don't know how to elaborate expression type=" << typeid(*this).name() << endl;
return 1;
}
const VType* ExpBinary::probe_type(Entity*ent, Architecture*arc) const
const VType* ExpBinary::probe_type(Entity*ent, ScopeBase*scope) const
{
const VType*t1 = operand1_->probe_type(ent, arc);
const VType*t2 = operand2_->probe_type(ent, arc);
const VType*t1 = operand1_->probe_type(ent, scope);
const VType*t2 = operand2_->probe_type(ent, scope);
if (t1 == 0)
return t2;
@ -351,12 +351,12 @@ const VType*ExpBinary::resolve_operand_types_(const VType*, const VType*) const
return 0;
}
int ExpBinary::elaborate_exprs(Entity*ent, Architecture*arc, const VType*ltype)
int ExpBinary::elaborate_exprs(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
errors += operand1_->elaborate_expr(ent, arc, ltype);
errors += operand2_->elaborate_expr(ent, arc, ltype);
errors += operand1_->elaborate_expr(ent, scope, ltype);
errors += operand2_->elaborate_expr(ent, scope, ltype);
return errors;
}
@ -365,17 +365,17 @@ int ExpBinary::elaborate_exprs(Entity*ent, Architecture*arc, const VType*ltype)
* return the fit_type for the operand. The assumption is that the
* operator doesn't change the type.
*/
const VType*ExpUnary::fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const
const VType*ExpUnary::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const
{
return operand1_->fit_type(ent, arc, atype);
return operand1_->fit_type(ent, scope, atype);
}
const VType*ExpAggregate::probe_type(Entity*ent, Architecture*arc) const
const VType*ExpAggregate::probe_type(Entity*ent, ScopeBase*scope) const
{
return Expression::probe_type(ent, arc);
return Expression::probe_type(ent, scope);
}
const VType*ExpAggregate::fit_type(Entity*, Architecture*, const VTypeArray*host) const
const VType*ExpAggregate::fit_type(Entity*, ScopeBase*, const VTypeArray*host) const
{
ivl_assert(*this, elements_.size() == 1);
size_t choice_count = elements_[0]->count_choices();
@ -401,7 +401,7 @@ const VType*ExpAggregate::fit_type(Entity*, Architecture*, const VTypeArray*host
return res;
}
int ExpAggregate::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpAggregate::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
if (ltype == 0) {
cerr << get_fileline() << ": error: Elaboration of aggregate types needs well known type context?" << endl;
@ -415,10 +415,10 @@ int ExpAggregate::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype
}
if (const VTypeArray*larray = dynamic_cast<const VTypeArray*>(ltype)) {
return elaborate_expr_array_(ent, arc, larray);
return elaborate_expr_array_(ent, scope, larray);
}
else if(const VTypeRecord*lrecord = dynamic_cast<const VTypeRecord*>(ltype)) {
return elaborate_expr_record_(ent, arc, lrecord);
return elaborate_expr_record_(ent, scope, lrecord);
}
cerr << get_fileline() << ": internal error: I don't know how to elaborate aggregate expressions. type=" << typeid(*ltype).name() << endl;
@ -430,7 +430,7 @@ int ExpAggregate::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype
* expressions (the elements_ member) using the element type as the
* ltype for the subexpression.
*/
int ExpAggregate::elaborate_expr_array_(Entity*ent, Architecture*arc, const VTypeArray*ltype)
int ExpAggregate::elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype)
{
const VType*element_type = ltype->element_type();
int errors = 0;
@ -476,7 +476,7 @@ int ExpAggregate::elaborate_expr_array_(Entity*ent, Architecture*arc, const VTyp
if (aggregate_[idx].alias_flag)
continue;
errors += aggregate_[idx].expr->elaborate_expr(ent, arc, element_type);
errors += aggregate_[idx].expr->elaborate_expr(ent, scope, element_type);
}
// done with the obsolete elements_ vector.
@ -485,7 +485,7 @@ int ExpAggregate::elaborate_expr_array_(Entity*ent, Architecture*arc, const VTyp
return errors;
}
int ExpAggregate::elaborate_expr_record_(Entity*ent, Architecture*arc, const VTypeRecord*ltype)
int ExpAggregate::elaborate_expr_record_(Entity*ent, ScopeBase*scope, const VTypeRecord*ltype)
{
int errors = 0;
@ -518,7 +518,7 @@ int ExpAggregate::elaborate_expr_record_(Entity*ent, Architecture*arc, const VTy
ivl_assert(*this, idx >= 0);
aggregate_[idx] = tmp;
errors += aggregate_[idx].expr->elaborate_expr(ent, arc, el->peek_type());
errors += aggregate_[idx].expr->elaborate_expr(ent, scope, el->peek_type());
}
// done with the obsolete elements_ vector.
@ -537,16 +537,16 @@ void ExpAggregate::element_t::map_choices(ExpAggregate::choice_element*dst)
}
}
int ExpArithmetic::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpArithmetic::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
errors += elaborate_exprs(ent, arc, ltype);
errors += elaborate_exprs(ent, scope, ltype);
return errors;
}
@ -565,9 +565,9 @@ const VType* ExpArithmetic::resolve_operand_types_(const VType*t1, const VType*t
return 0;
}
const VType* ExpAttribute::probe_type(Entity*ent, Architecture*arc) const
const VType* ExpAttribute::probe_type(Entity*ent, ScopeBase*scope) const
{
base_->probe_type(ent, arc);
base_->probe_type(ent, scope);
if (name_ == "length" || name_ == "left" || name_ == "right") {
return &primitive_INTEGER;
@ -576,42 +576,42 @@ const VType* ExpAttribute::probe_type(Entity*ent, Architecture*arc) const
return 0;
}
int ExpAttribute::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
int ExpAttribute::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*)
{
int errors = 0;
const VType*sub_type = base_->probe_type(ent, arc);
errors += base_->elaborate_expr(ent, arc, sub_type);
const VType*sub_type = base_->probe_type(ent, scope);
errors += base_->elaborate_expr(ent, scope, sub_type);
return errors;
}
const VType*ExpBitstring::fit_type(Entity*, Architecture*, const VTypeArray*atype) const
const VType*ExpBitstring::fit_type(Entity*, ScopeBase*, const VTypeArray*atype) const
{
// Really should check that this string can work with the
// array element type?
return atype->element_type();
}
int ExpBitstring::elaborate_expr(Entity*, Architecture*, const VType*)
int ExpBitstring::elaborate_expr(Entity*, ScopeBase*, const VType*)
{
int errors = 0;
return errors;
}
const VType*ExpCharacter::fit_type(Entity*, Architecture*, const VTypeArray*atype) const
const VType*ExpCharacter::fit_type(Entity*, ScopeBase*, const VTypeArray*atype) const
{
// Really should check that this character can work with the
// array element type?
return atype->element_type();
}
int ExpCharacter::elaborate_expr(Entity*, Architecture*, const VType*ltype)
int ExpCharacter::elaborate_expr(Entity*, ScopeBase*, const VType*ltype)
{
ivl_assert(*this, ltype != 0);
set_type(ltype);
return 0;
}
const VType*ExpConcat::fit_type(Entity*ent, Architecture*arc, const VTypeArray*atype) const
const VType*ExpConcat::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const
{
Expression*operands[2] = {operand1_, operand2_};
const VType*types[2] = {NULL, NULL};
@ -619,7 +619,7 @@ const VType*ExpConcat::fit_type(Entity*ent, Architecture*arc, const VTypeArray*a
// determine the type and size of concatenated expressions
for(int i = 0; i < 2; ++i) {
types[i] = operands[i]->fit_type(ent, arc, atype);
types[i] = operands[i]->fit_type(ent, scope, atype);
if(const VTypeArray*arr = dynamic_cast<const VTypeArray*>(types[i])) {
types[i] = arr->element_type();
@ -647,62 +647,62 @@ const VType*ExpConcat::fit_type(Entity*ent, Architecture*arc, const VTypeArray*a
/*
* I don't know how to probe the type of a concatenation, quite yet.
*/
const VType*ExpConcat::probe_type(Entity*, Architecture*) const
const VType*ExpConcat::probe_type(Entity*, ScopeBase*) const
{
ivl_assert(*this, 0);
return 0;
}
int ExpConcat::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpConcat::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
if (const VTypeArray*atype = dynamic_cast<const VTypeArray*>(ltype)) {
errors += elaborate_expr_array_(ent, arc, atype);
errors += elaborate_expr_array_(ent, scope, atype);
} else {
errors += operand1_->elaborate_expr(ent, arc, ltype);
errors += operand2_->elaborate_expr(ent, arc, ltype);
errors += operand1_->elaborate_expr(ent, scope, ltype);
errors += operand2_->elaborate_expr(ent, scope, ltype);
}
return errors;
}
int ExpConcat::elaborate_expr_array_(Entity*ent, Architecture*arc, const VTypeArray*atype)
int ExpConcat::elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*atype)
{
int errors = 0;
// For now, only support single-dimension arrays here.
ivl_assert(*this, atype->dimensions() == 1);
const VType*type1 = operand1_->fit_type(ent, arc, atype);
const VType*type1 = operand1_->fit_type(ent, scope, atype);
ivl_assert(*this, type1);
const VType*type2 = operand2_->fit_type(ent, arc, atype);
const VType*type2 = operand2_->fit_type(ent, scope, atype);
ivl_assert(*this, type2);
errors += operand1_->elaborate_expr(ent, arc, type1);
errors += operand2_->elaborate_expr(ent, arc, type2);
errors += operand1_->elaborate_expr(ent, scope, type1);
errors += operand2_->elaborate_expr(ent, scope, type2);
return errors;
}
const VType* ExpConditional::probe_type(Entity*, Architecture*) const
const VType* ExpConditional::probe_type(Entity*, ScopeBase*) const
{
return 0;
}
int ExpConditional::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpConditional::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0)
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
ivl_assert(*this, ltype);
@ -710,42 +710,42 @@ int ExpConditional::elaborate_expr(Entity*ent, Architecture*arc, const VType*lty
/* Note that the type for the condition expression need not
have anything to do with the type of this expression. */
errors += cond_->elaborate_expr(ent, arc, 0);
errors += cond_->elaborate_expr(ent, scope, 0);
for (list<Expression*>::const_iterator cur = true_clause_.begin()
; cur != true_clause_.end() ; ++cur) {
errors += (*cur)->elaborate_expr(ent, arc, ltype);
errors += (*cur)->elaborate_expr(ent, scope, ltype);
}
for (list<else_t*>::const_iterator cur = else_clause_.begin()
; cur != else_clause_.end() ; ++cur) {
errors += (*cur)->elaborate_expr(ent, arc, ltype);
errors += (*cur)->elaborate_expr(ent, scope, ltype);
}
return errors;
}
int ExpConditional::else_t::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpConditional::else_t::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (cond_)
errors += cond_->elaborate_expr(ent, arc, 0);
errors += cond_->elaborate_expr(ent, scope, 0);
for (list<Expression*>::const_iterator cur = true_clause_.begin()
; cur != true_clause_.end() ; ++cur) {
errors += (*cur)->elaborate_expr(ent, arc, ltype);
errors += (*cur)->elaborate_expr(ent, scope, ltype);
}
return errors;
}
int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*)
{
int errors = 0;
ivl_assert(*this, arc);
Subprogram*prog = arc->find_subprogram(name_);
ivl_assert(*this, scope);
Subprogram*prog = scope->find_subprogram(name_);
if(!prog)
prog = library_find_subprogram(name_);
@ -755,13 +755,13 @@ int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
// Elaborate arguments
for (size_t idx = 0 ; idx < argv_.size() ; idx += 1) {
const VType*tmp = argv_[idx]->probe_type(ent, arc);
const VType*tmp = argv_[idx]->probe_type(ent, scope);
const VType*param_type = prog ? prog->peek_param_type(idx) : NULL;
if(!tmp && param_type)
tmp = param_type;
errors += argv_[idx]->elaborate_expr(ent, arc, tmp);
errors += argv_[idx]->elaborate_expr(ent, scope, tmp);
// Type casting for unbounded arrays
if(param_type && param_type->is_unbounded() /*&& !param_type->type_match(tmp)*/) {
@ -772,17 +772,17 @@ int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
return errors;
}
const VType* ExpInteger::probe_type(Entity*, Architecture*) const
const VType* ExpInteger::probe_type(Entity*, ScopeBase*) const
{
return &primitive_INTEGER;
}
int ExpInteger::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpInteger::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
@ -790,17 +790,17 @@ int ExpInteger::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
return errors;
}
const VType* ExpReal::probe_type(Entity*, Architecture*) const
const VType* ExpReal::probe_type(Entity*, ScopeBase*) const
{
return &primitive_REAL;
}
int ExpReal::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpReal::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
@ -808,27 +808,27 @@ int ExpReal::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
return errors;
}
int ExpLogical::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpLogical::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
errors += elaborate_exprs(ent, arc, ltype);
errors += elaborate_exprs(ent, scope, ltype);
return errors;
}
const VType* ExpName::probe_prefix_type_(Entity*ent, Architecture*arc) const
const VType* ExpName::probe_prefix_type_(Entity*ent, ScopeBase*scope) const
{
if (prefix_.get()) {
cerr << get_fileline() << ": sorry: I do not know how to support nested prefix parts." << endl;
return 0;
}
const VType*type = probe_type(ent, arc);
const VType*type = probe_type(ent, scope);
return type;
}
@ -837,10 +837,10 @@ const VType* ExpName::probe_prefix_type_(Entity*ent, Architecture*arc) const
* that have prefix parts. In this case we try to get the type of the
* prefix and interpret the name in that context.
*/
const VType* ExpName::probe_prefixed_type_(Entity*ent, Architecture*arc) const
const VType* ExpName::probe_prefixed_type_(Entity*ent, ScopeBase*scope) const
{
// First, get the type of the prefix.
const VType*prefix_type = prefix_->probe_prefix_type_(ent, arc);
const VType*prefix_type = prefix_->probe_prefix_type_(ent, scope);
if (prefix_type == 0) {
return 0;
}
@ -868,34 +868,40 @@ const VType* ExpName::probe_prefixed_type_(Entity*ent, Architecture*arc) const
return 0;
}
const VType* ExpName::probe_type(Entity*ent, Architecture*arc) const
const VType* ExpName::probe_type(Entity*ent, ScopeBase*scope) const
{
if (prefix_.get())
return probe_prefixed_type_(ent, arc);
return probe_prefixed_type_(ent, scope);
if (const InterfacePort*cur = ent->find_port(name_)) {
ivl_assert(*this, cur->type);
return cur->type;
if(ent) {
if (const InterfacePort*cur = ent->find_port(name_)) {
ivl_assert(*this, cur->type);
return cur->type;
}
if (const InterfacePort*cur = ent->find_generic(name_)) {
ivl_assert(*this, cur->type);
return cur->type;
}
}
if (const InterfacePort*cur = ent->find_generic(name_)) {
ivl_assert(*this, cur->type);
return cur->type;
}
if(scope) {
if (Signal*sig = scope->find_signal(name_))
return sig->peek_type();
if (Signal*sig = arc->find_signal(name_))
return sig->peek_type();
if (Variable*var = scope->find_variable(name_))
return var->peek_type();
if (Variable*var = arc->find_variable(name_))
return var->peek_type();
const VType*ctype = 0;
Expression*cval = 0;
if (scope->find_constant(name_, ctype, cval))
return ctype;
const VType*ctype = 0;
Expression*cval = 0;
if (arc->find_constant(name_, ctype, cval))
return ctype;
if (const VType*gtype = arc->probe_genvar_type(name_)) {
return gtype;
const VType*gtype = 0;
Architecture*arc = dynamic_cast<Architecture*>(scope);
if (arc && (gtype = arc->probe_genvar_type(name_))) {
return gtype;
}
}
cerr << get_fileline() << ": error: Signal/variable " << name_
@ -903,12 +909,12 @@ const VType* ExpName::probe_type(Entity*ent, Architecture*arc) const
return 0;
}
const VType* ExpName::fit_type(Entity*ent, Architecture*arc, const VTypeArray*)const
const VType* ExpName::fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*)const
{
return probe_type(ent, arc);
return probe_type(ent, scope);
}
int ExpName::elaborate_expr(Entity*, Architecture*, const VType*ltype)
int ExpName::elaborate_expr(Entity*, ScopeBase*, const VType*ltype)
{
if (ltype) {
ivl_assert(*this, ltype != 0);
@ -918,22 +924,22 @@ int ExpName::elaborate_expr(Entity*, Architecture*, const VType*ltype)
return 0;
}
const VType* ExpNameALL::probe_type(Entity*, Architecture*) const
const VType* ExpNameALL::probe_type(Entity*, ScopeBase*) const
{
return 0;
}
const VType* ExpRelation::probe_type(Entity*, Architecture*) const
const VType* ExpRelation::probe_type(Entity*, ScopeBase*) const
{
return &primitive_BOOLEAN;
}
int ExpRelation::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int ExpRelation::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (ltype == 0) {
ltype = probe_type(ent, arc);
ltype = probe_type(ent, scope);
}
ivl_assert(*this, ltype != 0);
@ -941,8 +947,8 @@ int ExpRelation::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
// The type of the operands must match, but need not match the
// type for the ExpRelation itself. So get the operand type
// separately.
const VType*otype = ExpBinary::probe_type(ent, arc);
errors += elaborate_exprs(ent, arc, otype);
const VType*otype = ExpBinary::probe_type(ent, scope);
errors += elaborate_exprs(ent, scope, otype);
return errors;
}
@ -952,7 +958,7 @@ int ExpRelation::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
* string is an array with the same element type of the concatenation,
* but with elements for each character of the string.
*/
const VType*ExpString::fit_type(Entity*, Architecture*, const VTypeArray*atype) const
const VType*ExpString::fit_type(Entity*, ScopeBase*, const VTypeArray*atype) const
{
vector<VTypeArray::range_t> range (atype->dimensions());
@ -968,14 +974,14 @@ const VType*ExpString::fit_type(Entity*, Architecture*, const VTypeArray*atype)
return type;
}
int ExpString::elaborate_expr(Entity*, Architecture*, const VType*ltype)
int ExpString::elaborate_expr(Entity*, ScopeBase*, const VType*ltype)
{
ivl_assert(*this, ltype != 0);
set_type(ltype);
return 0;
}
int ExpUNot::elaborate_expr(Entity*, Architecture*, const VType*ltype)
int ExpUNot::elaborate_expr(Entity*, ScopeBase*, const VType*ltype)
{
ivl_assert(*this, ltype != 0);
set_type(ltype);

View File

@ -33,7 +33,7 @@
using namespace std;
int Expression::emit(ostream&out, Entity*, Architecture*)
int Expression::emit(ostream&out, Entity*, ScopeBase*)
{
out << " /* " << get_fileline() << ": internal error: "
<< "I don't know how to emit this expression! "
@ -54,34 +54,34 @@ bool Expression::is_primary(void) const
return false;
}
int ExpBinary::emit_operand1(ostream&out, Entity*ent, Architecture*arc)
int ExpBinary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
bool oper_primary = operand1_->is_primary();
if (! oper_primary) out << "(";
errors += operand1_->emit(out, ent, arc);
errors += operand1_->emit(out, ent, scope);
if (! oper_primary) out << ")";
return errors;
}
int ExpBinary::emit_operand2(ostream&out, Entity*ent, Architecture*arc)
int ExpBinary::emit_operand2(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
bool oper_primary = operand2_->is_primary();
if (! oper_primary) out << "(";
errors += operand2_->emit(out, ent, arc);
errors += operand2_->emit(out, ent, scope);
if (! oper_primary) out << ")";
return errors;
}
int ExpUnary::emit_operand1(ostream&out, Entity*ent, Architecture*arc)
int ExpUnary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += operand1_->emit(out, ent, arc);
errors += operand1_->emit(out, ent, scope);
return errors;
}
int ExpAggregate::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpAggregate::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
if (peek_type() == 0) {
out << "/* " << get_fileline() << ": internal error: "
@ -95,9 +95,9 @@ int ExpAggregate::emit(ostream&out, Entity*ent, Architecture*arc)
}
if (const VTypeArray*atype = dynamic_cast<const VTypeArray*> (use_type))
return emit_array_(out, ent, arc, atype);
return emit_array_(out, ent, scope, atype);
else if (const VTypeRecord*arecord = dynamic_cast<const VTypeRecord*> (use_type))
return emit_record_(out, ent, arc, arecord);
return emit_record_(out, ent, scope, arecord);
out << "/* " << get_fileline() << ": internal error: "
<< "I don't know how to elab/emit aggregate in " << typeid(use_type).name()
@ -105,7 +105,7 @@ int ExpAggregate::emit(ostream&out, Entity*ent, Architecture*arc)
return 1;
}
int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const VTypeArray*atype)
int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*atype)
{
int errors = 0;
@ -119,14 +119,14 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
int64_t use_msb;
int64_t use_lsb;
bool rc_msb, rc_lsb;
rc_msb = rang.msb()->evaluate(ent, arc, use_msb);
rc_lsb = rang.lsb()->evaluate(ent, arc, use_lsb);
rc_msb = rang.msb()->evaluate(ent, scope, use_msb);
rc_lsb = rang.lsb()->evaluate(ent, scope, use_lsb);
if (rc_msb && rc_lsb) {
int asize = (use_msb >= use_lsb) ? (use_msb - use_lsb) + 1 :
(use_lsb - use_msb) + 1;
out << "{" << asize << "{";
errors += aggregate_[0].expr->emit(out, ent, arc);
errors += aggregate_[0].expr->emit(out, ent, scope);
out << "}}";
} else {
out << "{(";
@ -134,7 +134,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
out << use_msb;
} else {
out << "(";
errors += rang.msb()->emit(out, ent, arc);
errors += rang.msb()->emit(out, ent, scope);
out << ")";
}
if (rc_lsb && use_lsb==0) {
@ -142,11 +142,11 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
out << "-" << use_lsb;
} else {
out << "-(";
errors += rang.lsb()->emit(out, ent, arc);
errors += rang.lsb()->emit(out, ent, scope);
out << ")";
}
out << "+1){";
errors += aggregate_[0].expr->emit(out, ent, arc);
errors += aggregate_[0].expr->emit(out, ent, scope);
out << "}}";
}
return errors;
@ -158,9 +158,9 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
// Fully calculate the range numbers.
int64_t use_msb, use_lsb;
bool rc;
rc = rang.msb()->evaluate(ent, arc, use_msb);
rc = rang.msb()->evaluate(ent, scope, use_msb);
ivl_assert(*this, rc);
rc = rang.lsb()->evaluate(ent, arc, use_lsb);
rc = rang.lsb()->evaluate(ent, scope, use_lsb);
ivl_assert(*this, rc);
if(use_msb < use_lsb)
swap(use_msb, use_lsb);
@ -198,14 +198,14 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
if (prange_t*range = aggregate_[idx].choice->range_expressions()) {
int64_t begin_val, end_val;
if (! range->msb()->evaluate(ent, arc, begin_val)) {
if (! range->msb()->evaluate(ent, scope, begin_val)) {
cerr << range->msb()->get_fileline() << ": error: "
<< "Unable to evaluate aggregate choice expression." << endl;
errors += 1;
continue;
}
if (! range->lsb()->evaluate(ent, arc, end_val)) {
if (! range->lsb()->evaluate(ent, scope, end_val)) {
cerr << range->msb()->get_fileline() << ": error: "
<< "Unable to evaluate aggregate choice expression." << endl;
errors += 1;
@ -235,7 +235,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
// elements so disable further positional
// processing.
positional_section = false;
if (! tmp->evaluate(ent, arc, tmp_val)) {
if (! tmp->evaluate(ent, scope, tmp_val)) {
cerr << tmp->get_fileline() << ": error: "
<< "Unable to evaluate aggregate choice expression." << endl;
errors += 1;
@ -266,7 +266,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
<< "Missing element " << idx << "." << endl;
errors += 1;
} else {
errors += cur->expr->emit(out, ent, arc);
errors += cur->expr->emit(out, ent, scope);
}
}
out << "}";
@ -274,7 +274,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, Architecture*arc, const V
return errors;
}
int ExpAggregate::emit_record_(ostream&out, Entity*ent, Architecture*arc, const VTypeRecord*)
int ExpAggregate::emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*)
{
int errors = 0;
@ -292,9 +292,9 @@ int ExpAggregate::emit_record_(ostream&out, Entity*ent, Architecture*arc, const
if(idx != 0)
out << ",";
//errors += name->emit(out, ent, arc);
//errors += name->emit(out, ent, scope);
//out << ": ";
errors += val->emit(out, ent, arc);
errors += val->emit(out, ent, scope);
}
out << "}";
@ -302,13 +302,13 @@ int ExpAggregate::emit_record_(ostream&out, Entity*ent, Architecture*arc, const
return errors;
}
int ExpAttribute::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
if (name_ == "event") {
out << "$ivlh_attribute_event(";
errors += base_->emit(out, ent, arc);
errors += base_->emit(out, ent, scope);
out << ")";
return errors;
}
@ -319,27 +319,27 @@ int ExpAttribute::emit(ostream&out, Entity*ent, Architecture*arc)
expression doesn't even need to be evaluated.) */
if (name_=="length") {
out << "$bits(";
errors += base_->emit(out, ent, arc);
errors += base_->emit(out, ent, scope);
out << ")";
return errors;
} else if (name_=="left" || name_=="right") {
out << "$" << name_ << "(";
errors += base_->emit(out, ent, arc);
errors += base_->emit(out, ent, scope);
out << ")";
return errors;
}
out << "$ivl_attribute(";
errors += base_->emit(out, ent, arc);
errors += base_->emit(out, ent, scope);
out << ", \"" << name_ << "\")";
return errors;
}
int ExpArithmetic::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpArithmetic::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
switch (fun_) {
case PLUS:
@ -369,12 +369,12 @@ int ExpArithmetic::emit(ostream&out, Entity*ent, Architecture*arc)
break;
}
errors += emit_operand2(out, ent, arc);
errors += emit_operand2(out, ent, scope);
return errors;
}
int ExpBitstring::emit(ostream&out, Entity*, Architecture*)
int ExpBitstring::emit(ostream&out, Entity*, ScopeBase*)
{
int errors = 0;
@ -385,7 +385,7 @@ int ExpBitstring::emit(ostream&out, Entity*, Architecture*)
return errors;
}
int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, Architecture*,
int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, ScopeBase*,
const VTypePrimitive*etype)
{
switch (etype->type()) {
@ -407,17 +407,17 @@ int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, Architecture*,
return 1;
}
int ExpCharacter::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpCharacter::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
const VType*etype = peek_type();
if (const VTypePrimitive*use_type = dynamic_cast<const VTypePrimitive*>(etype)) {
return emit_primitive_bit_(out, ent, arc, use_type);
return emit_primitive_bit_(out, ent, scope, use_type);
}
if (const VTypeArray*array = dynamic_cast<const VTypeArray*>(etype)) {
if (const VTypePrimitive*use_type = dynamic_cast<const VTypePrimitive*>(array->element_type())) {
return emit_primitive_bit_(out, ent, arc, use_type);
return emit_primitive_bit_(out, ent, scope, use_type);
}
}
@ -439,22 +439,22 @@ bool ExpConcat::is_primary(void) const
return true;
}
int ExpConcat::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpConcat::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "{";
errors += operand1_->emit(out, ent, arc);
errors += operand1_->emit(out, ent, scope);
out << ", ";
errors += operand2_->emit(out, ent, arc);
errors += operand2_->emit(out, ent, scope);
out << "}";
return errors;
}
int ExpConditional::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "(";
errors += cond_->emit(out, ent, arc);
errors += cond_->emit(out, ent, scope);
out << ")? (";
if (true_clause_.size() > 1) {
@ -463,7 +463,7 @@ int ExpConditional::emit(ostream&out, Entity*ent, Architecture*arc)
}
Expression*tmp = true_clause_.front();
errors += tmp->emit(out, ent, arc);
errors += tmp->emit(out, ent, scope);
out << ") : (";
@ -475,11 +475,11 @@ int ExpConditional::emit(ostream&out, Entity*ent, Architecture*arc)
for (list<else_t*>::iterator cur = else_clause_.begin()
; cur != last ; ++cur) {
errors += (*cur) ->emit_when_else(out, ent, arc);
errors += (*cur) ->emit_when_else(out, ent, scope);
}
}
errors += else_clause_.back()->emit_else(out, ent, arc);
errors += else_clause_.back()->emit_else(out, ent, scope);
out << ")";
// The emit_when_else() functions do not close the last
@ -492,13 +492,13 @@ int ExpConditional::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int ExpConditional::else_t::emit_when_else(ostream&out, Entity*ent, Architecture*arc)
int ExpConditional::else_t::emit_when_else(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
assert(cond_ != 0);
out << "(";
errors += cond_->emit(out, ent, arc);
errors += cond_->emit(out, ent, scope);
out << ")? (";
if (true_clause_.size() > 1) {
@ -507,14 +507,14 @@ int ExpConditional::else_t::emit_when_else(ostream&out, Entity*ent, Architecture
}
Expression*tmp = true_clause_.front();
errors += tmp->emit(out, ent, arc);
errors += tmp->emit(out, ent, scope);
out << ") : (";
return errors;
}
int ExpConditional::else_t::emit_else(ostream&out, Entity*ent, Architecture*arc)
int ExpConditional::else_t::emit_else(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
// Trailing else must have no condition.
@ -526,12 +526,12 @@ int ExpConditional::else_t::emit_else(ostream&out, Entity*ent, Architecture*arc)
}
Expression*tmp = true_clause_.front();
errors += tmp->emit(out, ent, arc);
errors += tmp->emit(out, ent, scope);
return errors;
}
int ExpEdge::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpEdge::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
switch (fun_) {
@ -544,11 +544,11 @@ int ExpEdge::emit(ostream&out, Entity*ent, Architecture*arc)
case ANYEDGE:
break;
}
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
return errors;
}
int ExpFunc::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpFunc::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
@ -558,46 +558,46 @@ int ExpFunc::emit(ostream&out, Entity*ent, Architecture*arc)
// std numeric library, but we interpret it as the same
// as the $unsigned function.
out << "$unsigned(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ")";
} else if (name_ == "integer" && argv_.size() == 1) {
// Simply skip the function name, SystemVerilog takes care of
// rounding real numbers
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
} else if (name_ == "std_logic_vector" && argv_.size() == 1) {
// Special case: The std_logic_vector function casts its
// argument to std_logic_vector. Internally, we don't
// have to do anything for that to work.
out << "(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ")";
} else if (name_ == "to_unsigned" && argv_.size() == 2) {
out << "$ivlh_to_unsigned(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ", ";
errors += argv_[1]->emit(out, ent, arc);
errors += argv_[1]->emit(out, ent, scope);
out << ")";
} else if (name_ == "conv_std_logic_vector" && argv_.size() == 2) {
int64_t use_size;
bool rc = argv_[1]->evaluate(ent, arc, use_size);
bool rc = argv_[1]->evaluate(ent, scope, use_size);
ivl_assert(*this, rc);
out << use_size << "'(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ")";
} else if (name_ == "rising_edge" && argv_.size()==1) {
out << "$ivlh_rising_edge(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ")";
} else if (name_ == "falling_edge" && argv_.size()==1) {
out << "$ivlh_falling_edge(";
errors += argv_[0]->emit(out, ent, arc);
errors += argv_[0]->emit(out, ent, scope);
out << ")";
} else {
@ -615,7 +615,7 @@ int ExpFunc::emit(ostream&out, Entity*ent, Architecture*arc)
out << "\\" << name_ << " (";
for (size_t idx = 0; idx < argv_.size() ; idx += 1) {
if (idx > 0) out << ", ";
errors += argv_[idx]->emit(out, ent, arc);
errors += argv_[idx]->emit(out, ent, scope);
}
out << ")";
}
@ -623,7 +623,7 @@ int ExpFunc::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int ExpInteger::emit(ostream&out, Entity*, Architecture*)
int ExpInteger::emit(ostream&out, Entity*, ScopeBase*)
{
out << value_;
return 0;
@ -640,7 +640,7 @@ bool ExpInteger::is_primary(void) const
return true;
}
int ExpReal::emit(ostream&out, Entity*, Architecture*)
int ExpReal::emit(ostream&out, Entity*, ScopeBase*)
{
out << value_;
return 0;
@ -657,11 +657,11 @@ bool ExpReal::is_primary(void) const
return true;
}
int ExpLogical::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpLogical::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
switch (fun_) {
case AND:
@ -684,22 +684,22 @@ int ExpLogical::emit(ostream&out, Entity*ent, Architecture*arc)
break;
}
errors += emit_operand2(out, ent, arc);
errors += emit_operand2(out, ent, scope);
return errors;
}
int ExpName::emit_as_prefix_(ostream&out, Entity*ent, Architecture*arc)
int ExpName::emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
if (prefix_.get()) {
errors += prefix_->emit_as_prefix_(out, ent, arc);
errors += prefix_->emit_as_prefix_(out, ent, scope);
}
out << "\\" << name_ << " ";
if (index_) {
out << "[";
errors += index_->emit(out, ent, arc);
errors += index_->emit(out, ent, scope);
out << "]";
ivl_assert(*this, lsb_ == 0);
}
@ -707,27 +707,28 @@ int ExpName::emit_as_prefix_(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int ExpName::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpName::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
if (prefix_.get()) {
errors += prefix_->emit_as_prefix_(out, ent, arc);
errors += prefix_->emit_as_prefix_(out, ent, scope);
}
const GenerateStatement*gs = 0;
Architecture*arc = dynamic_cast<Architecture*>(scope);
if (arc && (gs = arc->probe_genvar_emit(name_)))
out << "\\" << gs->get_name() << ":" << name_ << " ";
out << "\\" << gs->get_name() << ":" << name_ << " ";
else
out << "\\" << name_ << " ";
if (index_) {
out << "[";
errors += index_->emit(out, ent, arc);
errors += index_->emit(out, ent, scope);
if (lsb_) {
out << ":";
errors += lsb_->emit(out, ent, arc);
errors += lsb_->emit(out, ent, scope);
}
out << "]";
}
@ -740,10 +741,10 @@ bool ExpName::is_primary(void) const
return true;
}
int ExpRelation::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpRelation::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
switch (fun_) {
case EQ:
@ -766,7 +767,7 @@ int ExpRelation::emit(ostream&out, Entity*ent, Architecture*arc)
break;
}
errors += emit_operand2(out, ent, arc);
errors += emit_operand2(out, ent, scope);
return errors;
}
@ -775,13 +776,13 @@ bool ExpString::is_primary(void) const
return true;
}
int ExpString::emit(ostream& out, Entity*ent, Architecture*arc)
int ExpString::emit(ostream& out, Entity*ent, ScopeBase*scope)
{
const VType*type = peek_type();
assert(type != 0);
if (const VTypeArray*arr = dynamic_cast<const VTypeArray*>(type)) {
return emit_as_array_(out, ent, arc, arr);
return emit_as_array_(out, ent, scope, arr);
}
out << "\"";
@ -792,7 +793,7 @@ int ExpString::emit(ostream& out, Entity*ent, Architecture*arc)
return 0;
}
int ExpString::emit_as_array_(ostream& out, Entity*, Architecture*, const VTypeArray*arr)
int ExpString::emit_as_array_(ostream& out, Entity*, ScopeBase*, const VTypeArray*arr)
{
int errors = 0;
assert(arr->dimensions() == 1);
@ -843,39 +844,39 @@ int ExpString::emit_as_array_(ostream& out, Entity*, Architecture*, const VTypeA
return errors;
}
int ExpUAbs::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpUAbs::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "abs(";
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
out << ")";
return errors;
}
int ExpUNot::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpUNot::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "~(";
errors += emit_operand1(out, ent, arc);
errors += emit_operand1(out, ent, scope);
out << ")";
return errors;
}
int ExpCast::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpCast::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += type_->emit_def(out, empty_perm_string);
out << "'(";
errors += base_->emit(out, ent, arc);
errors += base_->emit(out, ent, scope);
out << ")";
return errors;
}
int ExpNew::emit(ostream&out, Entity*ent, Architecture*arc)
int ExpNew::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "new[";
errors += size_->emit(out, ent, arc);
errors += size_->emit(out, ent, scope);
out << "]";
return errors;
}

View File

@ -26,9 +26,9 @@ bool Expression::evaluate(ScopeBase*, int64_t&) const
return false;
}
bool Expression::evaluate(Entity*, Architecture*arc, int64_t&val) const
bool Expression::evaluate(Entity*, ScopeBase*scope, int64_t&val) const
{
return evaluate(arc, val);
return evaluate(scope, val);
}
@ -110,16 +110,16 @@ bool ExpAttribute::evaluate(ScopeBase*, int64_t&val) const
return false;
}
bool ExpAttribute::evaluate(Entity*ent, Architecture*arc, int64_t&val) const
bool ExpAttribute::evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const
{
if (!ent || !arc) { // it's impossible to evaluate, probably it is inside a subprogram
if (!ent || !scope) { // it's impossible to evaluate, probably it is inside a subprogram
return false;
}
if (name_ == "left" || name_ == "right") {
const VType*base_type = base_->peek_type();
if (base_type == 0)
base_type = base_->probe_type(ent, arc);
base_type = base_->probe_type(ent, scope);
ivl_assert(*this, base_type);
@ -133,14 +133,14 @@ bool ExpAttribute::evaluate(Entity*ent, Architecture*arc, int64_t&val) const
ivl_assert(*this, arr->dimensions() == 1);
if(name_ == "left")
arr->dimension(0).msb()->evaluate(ent, arc, val);
arr->dimension(0).msb()->evaluate(ent, scope, val);
else // "right"
arr->dimension(0).lsb()->evaluate(ent, arc, val);
arr->dimension(0).lsb()->evaluate(ent, scope, val);
return true;
}
return evaluate(arc, val);
return evaluate(scope, val);
}
/*
@ -169,7 +169,7 @@ bool ExpName::evaluate(ScopeBase*scope, int64_t&val) const
return exp->evaluate(scope, val);
}
bool ExpName::evaluate(Entity*ent, Architecture*arc, int64_t&val) const
bool ExpName::evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const
{
if (prefix_.get()) {
cerr << get_fileline() << ": sorry: I don't know how to evaluate ExpName prefix parts." << endl;
@ -182,8 +182,8 @@ bool ExpName::evaluate(Entity*ent, Architecture*arc, int64_t&val) const
// Evaluate the default expression and use that.
if (gen->expr)
return gen->expr->evaluate(ent, arc, val);
return gen->expr->evaluate(ent, scope, val);
}
return evaluate(arc, val);
return evaluate(scope, val);
}

View File

@ -25,7 +25,7 @@
# include <list>
# include <functional>
class Architecture;
class ScopeBase;
class Entity;
class Expression;
class SequentialStmt;
@ -42,8 +42,8 @@ class SequentialStmt : public LineInfo {
virtual ~SequentialStmt() =0;
public:
virtual int elaborate(Entity*ent, Architecture*arc);
virtual int emit(ostream&out, Entity*entity, Architecture*arc);
virtual int elaborate(Entity*ent, ScopeBase*scope);
virtual int emit(ostream&out, Entity*entity, ScopeBase*scope);
virtual void dump(ostream&out, int indent) const;
// Recursively visits a tree of sequential statements.
@ -65,8 +65,8 @@ class LoopStatement : public SequentialStmt {
void visit(SeqStmtVisitor& func);
protected:
int elaborate_substatements(Entity*ent, Architecture*arc);
int emit_substatements(std::ostream&out, Entity*ent, Architecture*arc);
int elaborate_substatements(Entity*ent, ScopeBase*scope);
int emit_substatements(std::ostream&out, Entity*ent, ScopeBase*scope);
private:
perm_string name_;
@ -81,9 +81,9 @@ class IfSequential : public SequentialStmt {
Elsif(Expression*cond, std::list<SequentialStmt*>*tr);
~Elsif();
int elaborate(Entity*entity, Architecture*arc);
int condition_emit(ostream&out, Entity*entity, Architecture*arc);
int statement_emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*entity, ScopeBase*scope);
int condition_emit(ostream&out, Entity*entity, ScopeBase*scope);
int statement_emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
void visit(SeqStmtVisitor& func);
@ -103,8 +103,8 @@ class IfSequential : public SequentialStmt {
~IfSequential();
public:
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
void visit(SeqStmtVisitor& func);
@ -130,7 +130,7 @@ class ReturnStmt : public SequentialStmt {
~ReturnStmt();
public:
int emit(ostream&out, Entity*entity, Architecture*arc);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
const Expression*peek_expr() const { return val_; };
@ -146,8 +146,8 @@ class SignalSeqAssignment : public SequentialStmt {
~SignalSeqAssignment();
public:
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
private:
@ -162,9 +162,9 @@ class CaseSeqStmt : public SequentialStmt {
CaseStmtAlternative(Expression* exp, std::list<SequentialStmt*>* stmts);
~CaseStmtAlternative();
void dump(std::ostream& out, int indent) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void visit(SeqStmtVisitor& func);
private:
@ -181,8 +181,8 @@ class CaseSeqStmt : public SequentialStmt {
public:
void dump(ostream&out, int indent) const;
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void visit(SeqStmtVisitor& func);
private:
@ -196,8 +196,8 @@ class ProcedureCall : public SequentialStmt {
ProcedureCall(perm_string name, std::list<named_expr_t*>* param_list);
~ProcedureCall();
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
private:
@ -211,8 +211,8 @@ class VariableSeqAssignment : public SequentialStmt {
~VariableSeqAssignment();
public:
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
private:
@ -226,8 +226,8 @@ class WhileLoopStatement : public LoopStatement {
ExpLogical*, list<SequentialStmt*>*);
~WhileLoopStatement();
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
private:
@ -240,14 +240,14 @@ class ForLoopStatement : public LoopStatement {
perm_string index, prange_t*, list<SequentialStmt*>*);
~ForLoopStatement();
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
void dump(ostream&out, int indent) const;
private:
// Emits for-loop which direction is determined at run-time.
// It is used for 'range & 'reverse_range attributes.
int emit_runtime_(ostream&out, Entity*ent, Architecture*arc);
int emit_runtime_(ostream&out, Entity*ent, ScopeBase*scope);
perm_string it_;
prange_t* range_;
@ -258,8 +258,8 @@ class BasicLoopStatement : public LoopStatement {
BasicLoopStatement(perm_string lname, list<SequentialStmt*>*);
~BasicLoopStatement();
int elaborate(Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*entity, Architecture*arc);
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void dump(ostream&out, int indent) const;
};

View File

@ -20,35 +20,35 @@
# include "sequential.h"
# include "expression.h"
int SequentialStmt::elaborate(Entity*, Architecture*)
int SequentialStmt::elaborate(Entity*, ScopeBase*)
{
return 0;
}
int LoopStatement::elaborate_substatements(Entity*ent, Architecture*arc)
int LoopStatement::elaborate_substatements(Entity*ent, ScopeBase*scope)
{
int errors = 0;
for (list<SequentialStmt*>::iterator cur = stmts_.begin()
; cur != stmts_.end() ; ++cur) {
errors += (*cur)->elaborate(ent, arc);
errors += (*cur)->elaborate(ent, scope);
}
return errors;
}
int CaseSeqStmt::elaborate(Entity*ent, Architecture*arc)
int CaseSeqStmt::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
const VType*ctype = cond_->probe_type(ent, arc);
errors += cond_->elaborate_expr(ent, arc, ctype);
const VType*ctype = cond_->probe_type(ent, scope);
errors += cond_->elaborate_expr(ent, scope, ctype);
for (list<CaseStmtAlternative*>::iterator cur = alt_.begin()
; cur != alt_.end() ; ++cur) {
CaseStmtAlternative*curp = *cur;
errors += curp->elaborate_expr(ent, arc, ctype);
errors += curp->elaborate(ent, arc);
errors += curp->elaborate_expr(ent, scope, ctype);
errors += curp->elaborate(ent, scope);
}
return errors;
@ -59,78 +59,78 @@ int CaseSeqStmt::elaborate(Entity*ent, Architecture*arc)
* ltype is the probed type for the main case condition. The
* expression needs to elaborate itself in that context.
*/
int CaseSeqStmt::CaseStmtAlternative::elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype)
int CaseSeqStmt::CaseStmtAlternative::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype)
{
int errors = 0;
if (exp_)
errors += exp_->elaborate_expr(ent, arc, ltype);
errors += exp_->elaborate_expr(ent, scope, ltype);
return errors;
}
int CaseSeqStmt::CaseStmtAlternative::elaborate(Entity*ent, Architecture*arc)
int CaseSeqStmt::CaseStmtAlternative::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
for (list<SequentialStmt*>::iterator cur = stmts_.begin()
; cur != stmts_.end() ; ++cur) {
SequentialStmt*curp = *cur;
errors += curp->elaborate(ent, arc);
errors += curp->elaborate(ent, scope);
}
return errors;
}
int ForLoopStatement::elaborate(Entity*ent, Architecture*arc)
int ForLoopStatement::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += elaborate_substatements(ent, arc);
errors += elaborate_substatements(ent, scope);
return errors;
}
int IfSequential::elaborate(Entity*ent, Architecture*arc)
int IfSequential::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += cond_->elaborate_expr(ent, arc, 0);
errors += cond_->elaborate_expr(ent, scope, 0);
for (list<SequentialStmt*>::iterator cur = if_.begin()
; cur != if_.end() ; ++cur) {
errors += (*cur)->elaborate(ent, arc);
errors += (*cur)->elaborate(ent, scope);
}
for (list<IfSequential::Elsif*>::iterator cur = elsif_.begin()
; cur != elsif_.end() ; ++cur) {
errors += (*cur)->elaborate(ent, arc);
errors += (*cur)->elaborate(ent, scope);
}
for (list<SequentialStmt*>::iterator cur = else_.begin()
; cur != else_.end() ; ++cur) {
errors += (*cur)->elaborate(ent, arc);
errors += (*cur)->elaborate(ent, scope);
}
return errors;
}
int IfSequential::Elsif::elaborate(Entity*ent, Architecture*arc)
int IfSequential::Elsif::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += cond_->elaborate_expr(ent, arc, 0);
errors += cond_->elaborate_expr(ent, scope, 0);
for (list<SequentialStmt*>::iterator cur = if_.begin()
; cur != if_.end() ; ++cur) {
errors += (*cur)->elaborate(ent, arc);
errors += (*cur)->elaborate(ent, scope);
}
return errors;
}
int SignalSeqAssignment::elaborate(Entity*ent, Architecture*arc)
int SignalSeqAssignment::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
// Elaborate the l-value expression.
errors += lval_->elaborate_lval(ent, arc, true);
errors += lval_->elaborate_lval(ent, scope, true);
// The elaborate_lval should have resolved the type of the
// l-value expression. We'll use that type to elaborate the
@ -145,23 +145,23 @@ int SignalSeqAssignment::elaborate(Entity*ent, Architecture*arc)
for (list<Expression*>::iterator cur = waveform_.begin()
; cur != waveform_.end() ; ++cur) {
errors += (*cur)->elaborate_expr(ent, arc, lval_type);
errors += (*cur)->elaborate_expr(ent, scope, lval_type);
}
return errors;
}
int ProcedureCall::elaborate(Entity*, Architecture*)
int ProcedureCall::elaborate(Entity*, ScopeBase*)
{
return 0;
}
int VariableSeqAssignment::elaborate(Entity*ent, Architecture*arc)
int VariableSeqAssignment::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;
// Elaborate the l-value expression.
errors += lval_->elaborate_lval(ent, arc, true);
errors += lval_->elaborate_lval(ent, scope, true);
// The elaborate_lval should have resolved the type of the
// l-value expression. We'll use that type to elaborate the
@ -173,7 +173,7 @@ int VariableSeqAssignment::elaborate(Entity*ent, Architecture*arc)
}
// Elaborate the r-value expression.
errors += rval_->elaborate_expr(ent, arc, lval_type);
errors += rval_->elaborate_expr(ent, scope, lval_type);
// Handle functions that return unbounded arrays
if(ExpFunc*call = dynamic_cast<ExpFunc*>(rval_)) {
@ -185,13 +185,13 @@ int VariableSeqAssignment::elaborate(Entity*ent, Architecture*arc)
return errors;
}
int WhileLoopStatement::elaborate(Entity*, Architecture*)
int WhileLoopStatement::elaborate(Entity*, ScopeBase*)
{
//TODO:check whether there is any wait statement in the statements (there should be)
return 0;
}
int BasicLoopStatement::elaborate(Entity*, Architecture*)
int BasicLoopStatement::elaborate(Entity*, ScopeBase*)
{
return 0;
}

View File

@ -27,7 +27,7 @@
# include <typeinfo>
# include <ivl_assert.h>
int SequentialStmt::emit(ostream&out, Entity*, Architecture*)
int SequentialStmt::emit(ostream&out, Entity*, ScopeBase*)
{
out << " // " << get_fileline() << ": internal error: "
<< "I don't know how to emit this sequential statement! "
@ -35,23 +35,23 @@ int SequentialStmt::emit(ostream&out, Entity*, Architecture*)
return 1;
}
int IfSequential::emit(ostream&out, Entity*ent, Architecture*arc)
int IfSequential::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "if (";
errors += cond_->emit(out, ent, arc);
errors += cond_->emit(out, ent, scope);
out << ") begin" << endl;
for (list<SequentialStmt*>::iterator cur = if_.begin()
; cur != if_.end() ; ++cur)
errors += (*cur)->emit(out, ent, arc);
errors += (*cur)->emit(out, ent, scope);
for (list<IfSequential::Elsif*>::iterator cur = elsif_.begin()
; cur != elsif_.end() ; ++cur) {
out << "end else if (";
errors += (*cur)->condition_emit(out, ent, arc);
errors += (*cur)->condition_emit(out, ent, scope);
out << ") begin" << endl;
errors += (*cur)->statement_emit(out, ent, arc);
errors += (*cur)->statement_emit(out, ent, scope);
}
if (! else_.empty()) {
@ -59,7 +59,7 @@ int IfSequential::emit(ostream&out, Entity*ent, Architecture*arc)
for (list<SequentialStmt*>::iterator cur = else_.begin()
; cur != else_.end() ; ++cur)
errors += (*cur)->emit(out, ent, arc);
errors += (*cur)->emit(out, ent, scope);
}
@ -67,36 +67,36 @@ int IfSequential::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int IfSequential::Elsif::condition_emit(ostream&out, Entity*ent, Architecture*arc)
int IfSequential::Elsif::condition_emit(ostream&out, Entity*ent, ScopeBase*scope)
{
return cond_->emit(out, ent, arc);
return cond_->emit(out, ent, scope);
}
int IfSequential::Elsif::statement_emit(ostream&out, Entity*ent, Architecture*arc)
int IfSequential::Elsif::statement_emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
for (list<SequentialStmt*>::iterator cur = if_.begin()
; cur != if_.end() ; ++cur)
errors += (*cur)->emit(out, ent, arc);
errors += (*cur)->emit(out, ent, scope);
return errors;
}
int ReturnStmt::emit(ostream&out, Entity*ent, Architecture*arc)
int ReturnStmt::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "return ";
errors += val_->emit(out, ent, arc);
errors += val_->emit(out, ent, scope);
out << ";" << endl;
return errors;
}
int SignalSeqAssignment::emit(ostream&out, Entity*ent, Architecture*arc)
int SignalSeqAssignment::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += lval_->emit(out, ent, arc);
errors += lval_->emit(out, ent, scope);
if (waveform_.size() != 1) {
out << "/* Confusing waveform? */;" << endl;
@ -105,27 +105,27 @@ int SignalSeqAssignment::emit(ostream&out, Entity*ent, Architecture*arc)
} else {
Expression*tmp = waveform_.front();
out << " <= ";
errors += tmp->emit(out, ent, arc);
errors += tmp->emit(out, ent, scope);
out << ";" << endl;
}
return errors;
}
int VariableSeqAssignment::emit(ostream&out, Entity*ent, Architecture*arc)
int VariableSeqAssignment::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
errors += lval_->emit(out, ent, arc);
errors += lval_->emit(out, ent, scope);
out << " = ";
errors += rval_->emit(out, ent, arc);
errors += rval_->emit(out, ent, scope);
out << ";" << endl;
return errors;
}
int ProcedureCall::emit(ostream&out, Entity*, Architecture*)
int ProcedureCall::emit(ostream&out, Entity*, ScopeBase*)
{
out << " // " << get_fileline() << ": internal error: "
<< "I don't know how to emit this sequential statement! "
@ -133,29 +133,29 @@ int ProcedureCall::emit(ostream&out, Entity*, Architecture*)
return 1;
}
int LoopStatement::emit_substatements(ostream&out, Entity*ent, Architecture*arc)
int LoopStatement::emit_substatements(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
for (list<SequentialStmt*>::iterator cur = stmts_.begin()
; cur != stmts_.end() ; ++cur) {
SequentialStmt*tmp = *cur;
errors += tmp->emit(out, ent, arc);
errors += tmp->emit(out, ent, scope);
}
return errors;
}
int CaseSeqStmt::emit(ostream&out, Entity*ent, Architecture*arc)
int CaseSeqStmt::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "case (";
errors += cond_->emit(out, ent, arc);
errors += cond_->emit(out, ent, scope);
out << ")" << endl;
for (list<CaseStmtAlternative*>::iterator cur = alt_.begin()
; cur != alt_.end() ; ++cur) {
CaseStmtAlternative*curp = *cur;
errors += curp ->emit(out, ent, arc);
errors += curp ->emit(out, ent, scope);
}
out << "endcase" << endl;
@ -163,12 +163,12 @@ int CaseSeqStmt::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int CaseSeqStmt::CaseStmtAlternative::emit(ostream&out, Entity*ent, Architecture*arc)
int CaseSeqStmt::CaseStmtAlternative::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
if (exp_) {
errors += exp_->emit(out, ent, arc);
errors += exp_->emit(out, ent, scope);
out << ":" << endl;
} else {
out << "default:" << endl;
@ -182,14 +182,14 @@ int CaseSeqStmt::CaseStmtAlternative::emit(ostream&out, Entity*ent, Architecture
break;
case 1:
curp = stmts_.front();
errors += curp->emit(out, ent, arc);
errors += curp->emit(out, ent, scope);
break;
default:
out << "begin" << endl;
for (list<SequentialStmt*>::iterator cur = stmts_.begin()
; cur != stmts_.end() ; ++cur) {
curp = *cur;
errors += curp->emit(out, ent, arc);
errors += curp->emit(out, ent, scope);
}
out << "end" << endl;
break;
@ -198,16 +198,16 @@ int CaseSeqStmt::CaseStmtAlternative::emit(ostream&out, Entity*ent, Architecture
return errors;
}
int ForLoopStatement::emit(ostream&out, Entity*ent, Architecture*arc)
int ForLoopStatement::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
ivl_assert(*this, range_);
int64_t start_val;
bool start_rc = range_->msb()->evaluate(ent, arc, start_val);
bool start_rc = range_->msb()->evaluate(ent, scope, start_val);
int64_t finish_val;
bool finish_rc = range_->lsb()->evaluate(ent, arc, finish_val);
bool finish_rc = range_->lsb()->evaluate(ent, scope, finish_val);
perm_string scope_name = loop_name();
if (scope_name.nil()) {
@ -222,7 +222,7 @@ int ForLoopStatement::emit(ostream&out, Entity*ent, Architecture*arc)
if(!start_rc || !finish_rc) {
// Could not evaluate one of the loop boundaries, it has to be
// determined during the run-time
errors += emit_runtime_(out, ent, arc);
errors += emit_runtime_(out, ent, scope);
} else {
bool dir = range_->is_downto();
@ -271,7 +271,7 @@ int ForLoopStatement::emit(ostream&out, Entity*ent, Architecture*arc)
out << " begin" << endl;
errors += emit_substatements(out, ent, arc);
errors += emit_substatements(out, ent, scope);
out << "end" << endl;
out << "end /* " << scope_name << " */" << endl;
@ -279,32 +279,32 @@ int ForLoopStatement::emit(ostream&out, Entity*ent, Architecture*arc)
return errors;
}
int ForLoopStatement::emit_runtime_(ostream&out, Entity*ent, Architecture*arc)
int ForLoopStatement::emit_runtime_(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
out << "for (\\" << it_ << " = ";
errors += range_->expr_left()->emit(out, ent, arc);
errors += range_->expr_left()->emit(out, ent, scope);
// Twisted way of determining the loop direction at runtime
out << " ;\n(";
errors += range_->expr_left()->emit(out, ent, arc);
errors += range_->expr_left()->emit(out, ent, scope);
out << " < ";
errors += range_->expr_right()->emit(out, ent, arc);
errors += range_->expr_right()->emit(out, ent, scope);
out << " ? \\" << it_ << " <= ";
errors += range_->expr_right()->emit(out, ent, arc);
errors += range_->expr_right()->emit(out, ent, scope);
out << " : \\" << it_ << " >= ";
errors += range_->expr_right()->emit(out, ent, arc);
errors += range_->expr_right()->emit(out, ent, scope);
out << ");\n\\" << it_ << " = \\" << it_ << " + (";
errors += range_->expr_left()->emit(out, ent, arc);
errors += range_->expr_left()->emit(out, ent, scope);
out << " < ";
errors += range_->expr_right()->emit(out, ent, arc);
errors += range_->expr_right()->emit(out, ent, scope);
out << " ? 1 : -1))";
return errors;
}
int WhileLoopStatement::emit(ostream&out, Entity*, Architecture*)
int WhileLoopStatement::emit(ostream&out, Entity*, ScopeBase*)
{
out << " // " << get_fileline() << ": internal error: "
<< "I don't know how to emit this sequential statement! "
@ -312,7 +312,7 @@ int WhileLoopStatement::emit(ostream&out, Entity*, Architecture*)
return 1;
}
int BasicLoopStatement::emit(ostream&out, Entity*, Architecture*)
int BasicLoopStatement::emit(ostream&out, Entity*, ScopeBase*)
{
out << " // " << get_fileline() << ": internal error: "
<< "I don't know how to emit this sequential statement! "

View File

@ -54,7 +54,7 @@ class Subprogram : public LineInfo, public ScopeBase {
const VType*peek_param_type(int idx) const;
const VType*peek_return_type() const { return return_type_; }
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
// Emit a definition as it would show up in a package.
int emit_package(std::ostream&fd) const;

View File

@ -70,7 +70,7 @@ int Subprogram::emit_package(ostream&fd) const
if (statements_) {
for (list<SequentialStmt*>::const_iterator cur = statements_->begin()
; cur != statements_->end() ; ++cur) {
errors += (*cur)->emit(fd, NULL, NULL);
errors += (*cur)->emit(fd, NULL, const_cast<Subprogram*>(this));
}
} else {
fd << " begin /* empty body */ end" << endl;

View File

@ -34,10 +34,10 @@ SigVarBase::~SigVarBase()
{
}
void SigVarBase::elaborate_init_expr(Entity*ent, Architecture*arc)
void SigVarBase::elaborate_init_expr(Entity*ent, ScopeBase*scope)
{
if(init_expr_) {
init_expr_->elaborate_expr(ent, arc, peek_type());
init_expr_->elaborate_expr(ent, scope, peek_type());
}
}
@ -46,7 +46,7 @@ void SigVarBase::type_elaborate_(VType::decl_t&decl)
decl.type = type_;
}
int Signal::emit(ostream&out, Entity*ent, Architecture*arc)
int Signal::emit(ostream&out, Entity*ent, ScopeBase*scope)
{
int errors = 0;
@ -59,13 +59,13 @@ int Signal::emit(ostream&out, Entity*ent, Architecture*arc)
Expression*init_expr = peek_init_expr();
if (init_expr) {
out << " = ";
init_expr->emit(out, ent, arc);
init_expr->emit(out, ent, scope);
}
out << ";" << endl;
return errors;
}
int Variable::emit(ostream&out, Entity*, Architecture*)
int Variable::emit(ostream&out, Entity*, ScopeBase*)
{
int errors = 0;

View File

@ -24,6 +24,7 @@
# include "vtype.h"
class Architecture;
class ScopeBase;
class Entity;
class Expression;
@ -42,7 +43,7 @@ class SigVarBase : public LineInfo {
void dump(ostream&out, int indent = 0) const;
// Elaborates initializer expressions if needed.
void elaborate_init_expr(Entity*ent, Architecture*arc);
void elaborate_init_expr(Entity*ent, ScopeBase*scope);
perm_string peek_name() const { return name_; }
@ -70,7 +71,7 @@ class Signal : public SigVarBase {
public:
Signal(perm_string name, const VType*type, Expression*init_expr);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
};
class Variable : public SigVarBase {
@ -78,7 +79,7 @@ class Variable : public SigVarBase {
public:
Variable(perm_string name, const VType*type);
int emit(ostream&out, Entity*ent, Architecture*arc);
int emit(ostream&out, Entity*ent, ScopeBase*scope);
};
inline void SigVarBase::count_ref_sequ()

View File

@ -30,6 +30,7 @@
# include "StringHeap.h"
class Architecture;
class ScopeBase;
class Entity;
class Expression;
class prange_t;
@ -52,7 +53,7 @@ class VType {
// This is rarely used, but some types may have expressions
// that need to be elaborated.
virtual int elaborate(Entity*end, Architecture*arc) const;
virtual int elaborate(Entity*end, ScopeBase*scope) const;
// This virtual method returns true if that is equivalent to
// this type. This method is used for example to compare
@ -205,7 +206,7 @@ class VTypeArray : public VType {
VTypeArray(const VType*etype, std::list<prange_t*>*r, bool signed_vector =false);
~VTypeArray();
int elaborate(Entity*ent, Architecture*arc) const;
int elaborate(Entity*ent, ScopeBase*scope) const;
void write_to_stream(std::ostream&fd) const;
void write_type_to_stream(std::ostream&fd) const;
void show(std::ostream&) const;

View File

@ -21,24 +21,24 @@
# include "vtype.h"
# include "expression.h"
int VType::elaborate(Entity*, Architecture*) const
int VType::elaborate(Entity*, ScopeBase*) const
{
return 0;
}
int VTypeArray::elaborate(Entity*ent, Architecture*arc) const
int VTypeArray::elaborate(Entity*ent, ScopeBase*scope) const
{
int errors = 0;
etype_->elaborate(ent, arc);
etype_->elaborate(ent, scope);
for (vector<range_t>::const_iterator cur = ranges_.begin()
; cur != ranges_.end() ; ++ cur) {
Expression*tmp = cur->msb();
if (tmp) errors += tmp->elaborate_expr(ent, arc, 0);
if (tmp) errors += tmp->elaborate_expr(ent, scope, 0);
tmp = cur->lsb();
if (tmp) errors += tmp->elaborate_expr(ent, arc, 0);
if (tmp) errors += tmp->elaborate_expr(ent, scope, 0);
}
return errors;