vhdlpp: emit() methods are const.

This commit is contained in:
Maciej Suminski 2016-01-20 16:41:26 +01:00
parent 730fdaf0f0
commit eeb5728e20
3 changed files with 85 additions and 85 deletions

View File

@ -659,7 +659,7 @@ void ExpName::visit(ExprVisitor& func)
func(this); func(this);
} }
int ExpName::index_t::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpName::index_t::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;

View File

@ -97,11 +97,11 @@ class Expression : public LineInfo {
// The emit virtual method is called by architecture emit to // The emit virtual method is called by architecture emit to
// output the generated code for the expression. The derived // output the generated code for the expression. The derived
// class fills in the details of what exactly happened. // class fills in the details of what exactly happened.
virtual int emit(ostream&out, Entity*ent, ScopeBase*scope) =0; virtual int emit(ostream&out, Entity*ent, ScopeBase*scope) const =0;
// The emit_package virtual message is similar, but is called // The emit_package virtual message is similar, but is called
// in a package context and to emit SV packages. // in a package context and to emit SV packages.
virtual int emit_package(std::ostream&out); virtual int emit_package(std::ostream&out) const;
// The evaluate virtual method tries to evaluate expressions // The evaluate virtual method tries to evaluate expressions
// to constant literal values. Return true and set the val // to constant literal values. Return true and set the val
@ -176,7 +176,7 @@ class ExpUnary : public Expression {
inline void write_to_stream_operand1(std::ostream&fd) const inline void write_to_stream_operand1(std::ostream&fd) const
{ operand1_->write_to_stream(fd); } { operand1_->write_to_stream(fd); }
int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope); int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump_operand1(ostream&out, int indent = 0) const; void dump_operand1(ostream&out, int indent = 0) const;
private: private:
@ -202,8 +202,8 @@ class ExpBinary : public Expression {
protected: protected:
int elaborate_exprs(Entity*, ScopeBase*, const VType*); int elaborate_exprs(Entity*, ScopeBase*, const VType*);
int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope); int emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) const;
int emit_operand2(ostream&out, Entity*ent, ScopeBase*scope); int emit_operand2(ostream&out, Entity*ent, ScopeBase*scope) const;
bool eval_operand1(Entity*ent, ScopeBase*scope, int64_t&val) const; bool eval_operand1(Entity*ent, ScopeBase*scope, int64_t&val) const;
bool eval_operand2(Entity*ent, ScopeBase*scope, int64_t&val) const; bool eval_operand2(Entity*ent, ScopeBase*scope, int64_t&val) const;
@ -308,15 +308,15 @@ class ExpAggregate : public Expression {
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
private: private:
int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype); int elaborate_expr_array_(Entity*ent, ScopeBase*scope, const VTypeArray*ltype);
int elaborate_expr_record_(Entity*ent, ScopeBase*scope, const VTypeRecord*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_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*ltype) const;
int emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*ltype); int emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*ltype) const;
private: private:
// This is the elements as directly parsed. // This is the elements as directly parsed.
@ -342,7 +342,7 @@ class ExpArithmetic : public ExpBinary {
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
virtual bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; virtual bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
@ -386,7 +386,7 @@ class ExpObjAttribute : public ExpAttribute {
inline const ExpName* peek_base() const { return base_; } inline const ExpName* peek_base() const { return base_; }
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
@ -408,7 +408,7 @@ class ExpTypeAttribute : public ExpAttribute {
inline const VType* peek_base() const { return base_; } inline const VType* peek_base() const { return base_; }
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
@ -434,7 +434,7 @@ class ExpBitstring : public Expression {
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
private: private:
@ -454,7 +454,7 @@ class ExpCharacter : public Expression {
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
bool is_primary(void) const; bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
@ -462,7 +462,7 @@ class ExpCharacter : public Expression {
private: private:
int emit_primitive_bit_(ostream&out, Entity*ent, ScopeBase*scope, int emit_primitive_bit_(ostream&out, Entity*ent, ScopeBase*scope,
const VTypePrimitive*etype); const VTypePrimitive*etype) const;
private: private:
char value_; char value_;
@ -482,7 +482,7 @@ class ExpConcat : public Expression {
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
bool is_primary(void) const; bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
@ -513,8 +513,8 @@ class ExpConditional : public Expression {
inline void set_condition(Expression*cond) { cond_ = cond; } inline void set_condition(Expression*cond) { cond_ = cond; }
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*lt); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*lt);
int emit_option(ostream&out, Entity*ent, ScopeBase*scope); int emit_option(ostream&out, Entity*ent, ScopeBase*scope) const;
int emit_default(ostream&out, Entity*ent, ScopeBase*scope); int emit_default(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
std::list<Expression*>& extract_true_clause() { return true_clause_; } std::list<Expression*>& extract_true_clause() { return true_clause_; }
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
@ -534,7 +534,7 @@ class ExpConditional : public Expression {
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
@ -574,7 +574,7 @@ class ExpEdge : public ExpUnary {
inline fun_t edge_fun() const { return fun_; } inline fun_t edge_fun() const { return fun_; }
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
private: private:
@ -600,7 +600,7 @@ class ExpFunc : public Expression {
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); // NOTE: does not handle expressions in subprogram void visit(ExprVisitor& func); // NOTE: does not handle expressions in subprogram
@ -622,8 +622,8 @@ class ExpInteger : public Expression {
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
int emit_package(std::ostream&out); int emit_package(std::ostream&out) const;
bool is_primary(void) const { return true; } bool is_primary(void) const { return true; }
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
@ -645,8 +645,8 @@ class ExpReal : public Expression {
const VType*probe_type(Entity*ent, ScopeBase*scope) const; const VType*probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
int emit_package(std::ostream&out); int emit_package(std::ostream&out) const;
bool is_primary(void) const; bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
virtual ostream& dump_inline(ostream&out) const; virtual ostream& dump_inline(ostream&out) const;
@ -672,7 +672,7 @@ class ExpLogical : public ExpBinary {
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
private: private:
@ -705,7 +705,7 @@ class ExpName : public Expression {
const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const; const VType* fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*host) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
bool is_primary(void) const; bool is_primary(void) const;
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
bool symbolic_compare(const Expression*that) const; bool symbolic_compare(const Expression*that) const;
@ -726,7 +726,7 @@ class ExpName : public Expression {
delete offset_; delete offset_;
} }
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
private: private:
Expression*idx_; Expression*idx_;
@ -740,14 +740,14 @@ class ExpName : public Expression {
const VType* probe_prefix_type_(Entity*ent, ScopeBase*scope) const; const VType* probe_prefix_type_(Entity*ent, ScopeBase*scope) const;
const VType* probe_prefixed_type_(Entity*ent, ScopeBase*scope) const; const VType* probe_prefixed_type_(Entity*ent, ScopeBase*scope) const;
int emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope); int emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope) const;
// There are some workarounds required for constant arrays/records, as // There are some workarounds required for constant arrays/records, as
// they are currently emitted as flat localparams (without any type // they are currently emitted as flat localparams (without any type
// information). The following workarounds adjust the access indices // information). The following workarounds adjust the access indices
// to select appropriate parts of the localparam. // to select appropriate parts of the localparam.
bool try_workarounds_(ostream&out, Entity*ent, ScopeBase*scope, bool try_workarounds_(ostream&out, Entity*ent, ScopeBase*scope,
list<index_t*>&indices, int&data_size); list<index_t*>&indices, int&data_size) const;
bool check_const_array_workaround_(const VTypeArray*arr, ScopeBase*scope, bool check_const_array_workaround_(const VTypeArray*arr, ScopeBase*scope,
list<index_t*>&indices, int&data_size) const; list<index_t*>&indices, int&data_size) const;
@ -756,7 +756,7 @@ class ExpName : public Expression {
list<index_t*>&indices, int&data_size) const; list<index_t*>&indices, int&data_size) const;
int emit_workaround_(ostream&out, Entity*ent, ScopeBase*scope, int emit_workaround_(ostream&out, Entity*ent, ScopeBase*scope,
const list<index_t*>&indices, int field_size); const list<index_t*>&indices, int field_size) const;
private: private:
std::auto_ptr<ExpName> prefix_; std::auto_ptr<ExpName> prefix_;
@ -793,7 +793,7 @@ class ExpRelation : public ExpBinary {
const VType* probe_type(Entity*ent, ScopeBase*scope) const; const VType* probe_type(Entity*ent, ScopeBase*scope) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
private: private:
@ -813,7 +813,7 @@ class ExpShift : public ExpBinary {
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
@ -833,7 +833,7 @@ class ExpString : public Expression {
const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const; const VType*fit_type(Entity*ent, ScopeBase*scope, const VTypeArray*atype) const;
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
bool is_primary(void) const; bool is_primary(void) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
const std::string& get_value() const { return value_; } const std::string& get_value() const { return value_; }
@ -843,7 +843,7 @@ class ExpString : public Expression {
static std::string escape_quot(const std::string& str); static std::string escape_quot(const std::string& str);
private: private:
int emit_as_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*arr); int emit_as_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*arr) const;
private: private:
std::string value_; std::string value_;
@ -858,7 +858,7 @@ class ExpUAbs : public ExpUnary {
Expression*clone() const { return new ExpUAbs(peek_operand()->clone()); } Expression*clone() const { return new ExpUAbs(peek_operand()->clone()); }
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
}; };
@ -871,7 +871,7 @@ class ExpUNot : public ExpUnary {
Expression*clone() const { return new ExpUNot(peek_operand()->clone()); } Expression*clone() const { return new ExpUNot(peek_operand()->clone()); }
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
}; };
@ -890,7 +890,7 @@ class ExpCast : public Expression {
return base_->elaborate_expr(ent, scope, type_); return base_->elaborate_expr(ent, scope, type_);
} }
void write_to_stream(std::ostream&fd) const; void write_to_stream(std::ostream&fd) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
@ -913,7 +913,7 @@ class ExpNew : public Expression {
// There is no 'new' in VHDL - do not emit anything // There is no 'new' in VHDL - do not emit anything
void write_to_stream(std::ostream&) const {}; void write_to_stream(std::ostream&) const {};
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
void visit(ExprVisitor& func); void visit(ExprVisitor& func);
@ -931,7 +931,7 @@ class ExpTime : public Expression {
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&) const; void write_to_stream(std::ostream&) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
//bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const; //bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
@ -966,7 +966,7 @@ class ExpRange : public Expression {
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype);
void write_to_stream(std::ostream&) const; void write_to_stream(std::ostream&) const;
int emit(ostream&out, Entity*ent, ScopeBase*scope); int emit(ostream&out, Entity*ent, ScopeBase*scope) const;
void dump(ostream&out, int indent = 0) const; void dump(ostream&out, int indent = 0) const;
private: private:
// Regular range related fields // Regular range related fields

View File

@ -62,7 +62,7 @@ inline static int emit_logic(char val, ostream& out, const VTypePrimitive::type_
return 0; return 0;
} }
int Expression::emit(ostream&out, Entity*, ScopeBase*) int Expression::emit(ostream&out, Entity*, ScopeBase*) const
{ {
out << " /* " << get_fileline() << ": internal error: " out << " /* " << get_fileline() << ": internal error: "
<< "I don't know how to emit this expression! " << "I don't know how to emit this expression! "
@ -70,7 +70,7 @@ int Expression::emit(ostream&out, Entity*, ScopeBase*)
return 1; return 1;
} }
int Expression::emit_package(ostream&out) int Expression::emit_package(ostream&out) const
{ {
out << " /* " << get_fileline() << ": internal error: " out << " /* " << get_fileline() << ": internal error: "
<< "I don't know how to emit_package this expression! " << "I don't know how to emit_package this expression! "
@ -83,7 +83,7 @@ bool Expression::is_primary(void) const
return false; return false;
} }
int ExpBinary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) int ExpBinary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
bool oper_primary = operand1_->is_primary(); bool oper_primary = operand1_->is_primary();
@ -93,7 +93,7 @@ int ExpBinary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpBinary::emit_operand2(ostream&out, Entity*ent, ScopeBase*scope) int ExpBinary::emit_operand2(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
bool oper_primary = operand2_->is_primary(); bool oper_primary = operand2_->is_primary();
@ -103,14 +103,14 @@ int ExpBinary::emit_operand2(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpUnary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) int ExpUnary::emit_operand1(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
errors += operand1_->emit(out, ent, scope); errors += operand1_->emit(out, ent, scope);
return errors; return errors;
} }
int ExpAggregate::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpAggregate::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
if (peek_type() == 0) { if (peek_type() == 0) {
out << "/* " << get_fileline() << ": internal error: " out << "/* " << get_fileline() << ": internal error: "
@ -134,7 +134,7 @@ int ExpAggregate::emit(ostream&out, Entity*ent, ScopeBase*scope)
return 1; return 1;
} }
int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*atype) int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeArray*atype) const
{ {
int errors = 0; int errors = 0;
@ -194,8 +194,8 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VT
if(use_msb < use_lsb) if(use_msb < use_lsb)
swap(use_msb, use_lsb); swap(use_msb, use_lsb);
map<int64_t,choice_element*> element_map; map<int64_t,const choice_element*> element_map;
choice_element*element_other = 0; const choice_element*element_other = 0;
bool positional_section = true; bool positional_section = true;
int64_t positional_idx = use_msb; int64_t positional_idx = use_msb;
@ -283,7 +283,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VT
out << "{"; out << "{";
for (int64_t idx = use_msb ; idx >= use_lsb ; idx -= 1) { for (int64_t idx = use_msb ; idx >= use_lsb ; idx -= 1) {
choice_element*cur = element_map[idx]; const choice_element*cur = element_map[idx];
if (cur == 0) if (cur == 0)
cur = element_other; cur = element_other;
@ -303,7 +303,7 @@ int ExpAggregate::emit_array_(ostream&out, Entity*ent, ScopeBase*scope, const VT
return errors; return errors;
} }
int ExpAggregate::emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*) int ExpAggregate::emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const VTypeRecord*) const
{ {
int errors = 0; int errors = 0;
@ -331,7 +331,7 @@ int ExpAggregate::emit_record_(ostream&out, Entity*ent, ScopeBase*scope, const V
return errors; return errors;
} }
int ExpObjAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpObjAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -372,7 +372,7 @@ int ExpObjAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpTypeAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpTypeAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -409,7 +409,7 @@ int ExpTypeAttribute::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpArithmetic::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpArithmetic::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -463,7 +463,7 @@ int ExpArithmetic::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpBitstring::emit(ostream&out, Entity*, ScopeBase*) int ExpBitstring::emit(ostream&out, Entity*, ScopeBase*) const
{ {
int errors = 0; int errors = 0;
@ -475,7 +475,7 @@ int ExpBitstring::emit(ostream&out, Entity*, ScopeBase*)
} }
int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, ScopeBase*, int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, ScopeBase*,
const VTypePrimitive*etype) const VTypePrimitive*etype) const
{ {
out << "1'b"; out << "1'b";
int res = emit_logic(value_, out, etype->type()); int res = emit_logic(value_, out, etype->type());
@ -488,7 +488,7 @@ int ExpCharacter::emit_primitive_bit_(ostream&out, Entity*, ScopeBase*,
return res; return res;
} }
int ExpCharacter::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpCharacter::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
const VType*etype = peek_type(); const VType*etype = peek_type();
const VTypeArray*array; const VTypeArray*array;
@ -519,7 +519,7 @@ bool ExpConcat::is_primary(void) const
return true; return true;
} }
int ExpConcat::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpConcat::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
out << "{"; out << "{";
@ -530,7 +530,7 @@ int ExpConcat::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
out << "("; out << "(";
@ -538,10 +538,10 @@ int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope)
// Draw out any when-else expressions. These are all the else_ // Draw out any when-else expressions. These are all the else_
// clauses besides the last. // clauses besides the last.
if (options_.size() > 1) { if (options_.size() > 1) {
list<case_t*>::iterator last = options_.end(); list<case_t*>::const_iterator last = options_.end();
--last; --last;
for (list<case_t*>::iterator cur = options_.begin() for (list<case_t*>::const_iterator cur = options_.begin()
; cur != last ; ++cur) { ; cur != last ; ++cur) {
errors += (*cur)->emit_option(out, ent, scope); errors += (*cur)->emit_option(out, ent, scope);
} }
@ -560,7 +560,7 @@ int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpConditional::case_t::emit_option(ostream&out, Entity*ent, ScopeBase*scope) int ExpConditional::case_t::emit_option(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
assert(cond_ != 0); assert(cond_ != 0);
@ -582,7 +582,7 @@ int ExpConditional::case_t::emit_option(ostream&out, Entity*ent, ScopeBase*scope
return errors; return errors;
} }
int ExpConditional::case_t::emit_default(ostream&out, Entity*ent, ScopeBase*scope) int ExpConditional::case_t::emit_default(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
// Trailing else must have no condition. // Trailing else must have no condition.
@ -599,7 +599,7 @@ int ExpConditional::case_t::emit_default(ostream&out, Entity*ent, ScopeBase*scop
return errors; return errors;
} }
int ExpEdge::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpEdge::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
switch (fun_) { switch (fun_) {
@ -616,7 +616,7 @@ int ExpEdge::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpFunc::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpFunc::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -642,25 +642,25 @@ int ExpFunc::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpInteger::emit(ostream&out, Entity*, ScopeBase*) int ExpInteger::emit(ostream&out, Entity*, ScopeBase*) const
{ {
out << "32'd" << value_; out << "32'd" << value_;
return 0; return 0;
} }
int ExpInteger::emit_package(ostream&out) int ExpInteger::emit_package(ostream&out) const
{ {
out << value_; out << value_;
return 0; return 0;
} }
int ExpReal::emit(ostream&out, Entity*, ScopeBase*) int ExpReal::emit(ostream&out, Entity*, ScopeBase*) const
{ {
out << value_; out << value_;
return 0; return 0;
} }
int ExpReal::emit_package(ostream&out) int ExpReal::emit_package(ostream&out) const
{ {
out << value_; out << value_;
return 0; return 0;
@ -671,7 +671,7 @@ bool ExpReal::is_primary(void) const
return true; return true;
} }
int ExpLogical::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpLogical::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -703,7 +703,7 @@ int ExpLogical::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpName::emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope) int ExpName::emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
if (prefix_.get()) { if (prefix_.get()) {
@ -721,7 +721,7 @@ int ExpName::emit_as_prefix_(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpName::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpName::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
int field_size = 0; int field_size = 0;
@ -763,7 +763,7 @@ int ExpName::emit(ostream&out, Entity*ent, ScopeBase*scope)
} }
bool ExpName::try_workarounds_(ostream&out, Entity*ent, ScopeBase*scope, bool ExpName::try_workarounds_(ostream&out, Entity*ent, ScopeBase*scope,
list<index_t*>& indices, int& data_size) list<index_t*>& indices, int& data_size) const
{ {
Expression*exp = NULL; Expression*exp = NULL;
bool wrkand_required = false; bool wrkand_required = false;
@ -860,7 +860,7 @@ bool ExpName::check_const_record_workaround_(const VTypeRecord*rec,
} }
int ExpName::emit_workaround_(ostream&out, Entity*ent, ScopeBase*scope, int ExpName::emit_workaround_(ostream&out, Entity*ent, ScopeBase*scope,
const list<index_t*>& indices, int field_size) const list<index_t*>& indices, int field_size) const
{ {
int errors = 0; int errors = 0;
@ -882,7 +882,7 @@ bool ExpName::is_primary(void) const
return true; return true;
} }
int ExpRelation::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpRelation::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
errors += emit_operand1(out, ent, scope); errors += emit_operand1(out, ent, scope);
@ -912,7 +912,7 @@ int ExpRelation::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpShift::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpShift::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -947,7 +947,7 @@ bool ExpString::is_primary(void) const
return true; return true;
} }
int ExpString::emit(ostream& out, Entity*ent, ScopeBase*scope) int ExpString::emit(ostream& out, Entity*ent, ScopeBase*scope) const
{ {
const VTypeArray*arr; const VTypeArray*arr;
const VType*type = peek_type(); const VType*type = peek_type();
@ -962,7 +962,7 @@ int ExpString::emit(ostream& out, Entity*ent, ScopeBase*scope)
return 0; return 0;
} }
int ExpString::emit_as_array_(ostream& out, Entity*, ScopeBase*, const VTypeArray*arr) int ExpString::emit_as_array_(ostream& out, Entity*, ScopeBase*, const VTypeArray*arr) const
{ {
int errors = 0; int errors = 0;
assert(arr->dimensions() == 1); assert(arr->dimensions() == 1);
@ -1010,7 +1010,7 @@ std::string ExpString::escape_quot(const std::string& str)
return result; return result;
} }
int ExpUAbs::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpUAbs::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
out << "abs("; out << "abs(";
@ -1019,7 +1019,7 @@ int ExpUAbs::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpUNot::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpUNot::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
@ -1035,7 +1035,7 @@ int ExpUNot::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpCast::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpCast::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
errors += type_->emit_def(out, empty_perm_string); errors += type_->emit_def(out, empty_perm_string);
@ -1045,7 +1045,7 @@ int ExpCast::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpNew::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpNew::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;
out << "new["; out << "new[";
@ -1054,7 +1054,7 @@ int ExpNew::emit(ostream&out, Entity*ent, ScopeBase*scope)
return errors; return errors;
} }
int ExpTime::emit(ostream&out, Entity*, ScopeBase*) int ExpTime::emit(ostream&out, Entity*, ScopeBase*) const
{ {
out << amount_; out << amount_;
@ -1070,7 +1070,7 @@ int ExpTime::emit(ostream&out, Entity*, ScopeBase*)
return 0; return 0;
} }
int ExpRange::emit(ostream&out, Entity*ent, ScopeBase*scope) int ExpRange::emit(ostream&out, Entity*ent, ScopeBase*scope) const
{ {
int errors = 0; int errors = 0;