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
-
#belong_to_module ⇒ Object
readonly
Returns the value of attribute belong_to_module.
-
#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(belong_to_module) ⇒ BlockIF
constructor
A new instance of BlockIF.
- #instance(as_type = :cond) ⇒ Object
Constructor Details
#initialize(belong_to_module) ⇒ BlockIF
Returns a new instance of BlockIF.
6 7 8 9 10 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 6 def initialize(belong_to_module) @opertor_chains = [] @cond = nil @belong_to_module = belong_to_module end |
Instance Attribute Details
#belong_to_module ⇒ Object (readonly)
Returns the value of attribute belong_to_module.
5 6 7 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 5 def belong_to_module @belong_to_module end |
#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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tdl/class_hdl/hdl_block_ifelse.rb', line 12 def instance(as_type= :cond) if cond.is_a? ClassHDL::OpertorChain head_str = "if(#{cond.instance(:cond, belong_to_module)})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, belong_to_module)) 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 |