Class: ClassHDL::BlockIF
- Inherits:
-
Object
- Object
- ClassHDL::BlockIF
- Defined in:
- lib/tdl/class_hdl/hdl_block_ifelse.rb
Direct Known Subclasses
BlocAssertIF, BlockCASE, BlockCASEDEFAULT, BlockCASEWHEN, BlockCASEX, BlockELSE, BlockELSIF
Instance Attribute Summary collapse
-
#cond ⇒ Object
Returns the value of attribute cond.
-
#opertor_chains ⇒ Object
Returns the value of attribute opertor_chains.
-
#slaver ⇒ Object
Returns the value of attribute slaver.
Instance Method Summary collapse
-
#initialize ⇒ BlockIF
constructor
A new instance of BlockIF.
- #instance(as_type = :cond) ⇒ Object
Constructor Details
#initialize ⇒ BlockIF
Returns a new instance of BlockIF.
5 6 7 8 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 5 def initialize @opertor_chains = [] @cond = nil end |
Instance Attribute Details
#cond ⇒ Object
Returns the value of attribute cond.
4 5 6 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4 def cond @cond end |
#opertor_chains ⇒ Object
Returns the value of attribute opertor_chains.
4 5 6 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4 def opertor_chains @opertor_chains end |
#slaver ⇒ Object
Returns the value of attribute slaver.
4 5 6 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 4 def slaver @slaver end |
Instance Method Details
#instance(as_type = :cond) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 10 def instance(as_type= :cond) if cond.is_a? ClassHDL::OpertorChain head_str = "if(#{cond.instance(:cond)})begin" else head_str = "if(#{cond.to_s})begin" end sub_str = [] opertor_chains.each do |oc| unless oc.is_a? BlockIF unless oc.slaver rel_str = ClassHDL.compact_op_ch(oc.instance(as_type)) sub_str.push " #{rel_str};" end else sub_str.push( oc.instance(as_type).gsub(/^./){ |m| " #{m}"} ) end end return "#{head_str}\n#{sub_str.join("\n")}\nend" end |