Class: ClassHDL::BlockFOR

Inherits:
BlockELSE show all
Defined in:
lib/tdl/class_hdl/hdl_foreach.rb

Instance Attribute Summary collapse

Attributes inherited from BlockIF

#cond, #opertor_chains, #slaver

Instance Method Summary collapse

Methods inherited from BlockIF

#initialize

Constructor Details

This class inherits a constructor from ClassHDL::BlockIF

Instance Attribute Details

#flagObject

Returns the value of attribute flag.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def flag
  @flag
end

#startObject

Returns the value of attribute start.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def start
  @start
end

#stepObject

Returns the value of attribute step.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def step
  @step
end

#stopObject

Returns the value of attribute stop.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def stop
  @stop
end

#varObject

Returns the value of attribute var.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def var
  @var
end

#var_typeObject

Returns the value of attribute var_type.



26
27
28
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 26

def var_type
  @var_type
end

Instance Method Details

#instance(as_type = :cond) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/tdl/class_hdl/hdl_foreach.rb', line 27

def instance(as_type= :cond)
    
    unless var
        head_str = "for(#{var_type} #{flag}=#{start};#{flag}<#{stop};#{flag}=#{flag}+#{step})begin"
    else
        head_str = "for(#{var}=#{start};#{flag}<#{stop};#{flag}=#{flag}+#{step})begin"
    end

    sub_str = []
    opertor_chains.each do |oc|
        unless oc.is_a? BlockIF
            unless oc.slaver
                sub_str.push "    #{oc.instance(as_type)};"
            end
        else 
            sub_str.push( oc.instance(as_type).gsub(/^./){ |m| "    #{m}"} )
        end
    end

    return "#{head_str}\n#{sub_str.join("\n")}\nend"

end