Class: ClassHDL::BlockIF

Inherits:
Object
  • Object
show all
Defined in:
lib/tdl/class_hdl/hdl_block_ifelse.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_moduleObject (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

#condObject

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_chainsObject

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

#slaverObject

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