Class: HDLRuby::Low::Ref

Inherits:
Expression show all
Defined in:
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low_resolve.rb,
lib/HDLRuby/hruby_low_fix_types.rb,
lib/HDLRuby/hruby_low_skeleton.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2c.rb

Overview

Describes a reference expression.

NOTE: this is an abstract class which is not to be used directly.

Direct Known Subclasses

High::RefObject, RefConcat, RefIndex, RefName, RefRange, RefThis

Constant Summary

Constants included from Low2Symbol

Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable

Instance Attribute Summary

Attributes inherited from Expression

#type

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Expression

#boolean?, #break_types!, #clone, #each_ref_deep, #extract_selects_to!, #fix_scope_refnames!, #immutable?, #initialize, #leftvalue?, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #signal2subs!, #statement, #to_c_expr, #to_high, #to_viz_names, #use_name?, #width

Methods included from Hparent

#absolute_ref, #hierarchy, #no_parent!, #scope

Methods included from Low2Symbol

#to_sym

Constructor Details

This class inherits a constructor from HDLRuby::Low::Expression

Instance Method Details

#each_node(&ruby_block) ⇒ Object Also known as: each_expression

Iterates over the reference children if any.



5777
5778
5779
5780
5781
# File 'lib/HDLRuby/hruby_low.rb', line 5777

def each_node(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node) unless ruby_block
    # A ruby block? Apply it on the children: default none.
end

#each_node_deep(&ruby_block) ⇒ Object

Iterates over the nodes deeply if any.



5786
5787
5788
5789
5790
5791
5792
# File 'lib/HDLRuby/hruby_low.rb', line 5786

def each_node_deep(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:each_node_deep) unless ruby_block
    # A ruby block? First apply it to current.
    ruby_block.call(self)
    # And that's all.
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


5749
5750
5751
5752
5753
5754
5755
# File 'lib/HDLRuby/hruby_low.rb', line 5749

def eql?(obj)
    # General comparison.
    return false unless super(obj)
    # Specific comparison.
    return false unless obj.is_a?(Ref)
    return true
end

#explicit_types(type = nil) ⇒ Object

Explicit the types conversions in the reference where type is the expected type of the condition if any.



387
388
389
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 387

def explicit_types(type = nil)
    raise "Should implement explicit_types for class #{self.class}."
end

#hashObject

Hash function.



5758
5759
5760
# File 'lib/HDLRuby/hruby_low.rb', line 5758

def hash
    super
end

#map_nodes!(&ruby_block) ⇒ Object Also known as: map_expressions!

Maps on the children.



1667
1668
1669
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1667

def map_nodes!(&ruby_block)
    # Nothing to do.
end

#path_each(&ruby_block) ⇒ Object

Iterates over the names of the path indicated by the reference.

NOTE: this is not a method for iterating over all the names included in the reference. For instance, this method will return nil without iterating if a RefConcat or is met.

Returns an enumerator if no ruby block is given.



5769
5770
5771
5772
5773
5774
# File 'lib/HDLRuby/hruby_low.rb', line 5769

def path_each(&ruby_block)
    # No ruby block? Return an enumerator.
    return to_enum(:path_each) unless ruby_block
    # A ruby block? Apply it on... nothing by default.
    return nil
end

#resolveObject

Resolves the name of the reference (if any) and return the corresponding object. NOTE: return nil if could not resolve.



131
132
133
134
# File 'lib/HDLRuby/hruby_low_resolve.rb', line 131

def resolve
    # By default cannot resolve.
    return nil
end

#to_c(res, level = 0, left = false) ⇒ Object

Generates the C text of the equivalent HDLRuby code. level is the hierachical level of the object and left tells if it is a left value or not. def to_c(level = 0, left = false)

Raises:



2824
2825
2826
2827
# File 'lib/HDLRuby/hruby_low2c.rb', line 2824

def to_c(res,level = 0, left = false)
    # Should never be here.
    raise AnyError, "Internal error: to_c should be implemented in class :#{self.class}"
end

#to_hdr(level = 0) ⇒ Object

Generates the text of the equivalent hdr text. level is the hierachical level of the object.

Raises:



674
675
676
677
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 674

def to_hdr(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
end

#to_vhdl(level = 0) ⇒ Object

Generates the text of the equivalent HDLRuby::High code. level is the hierachical level of the object.

Raises:



1454
1455
1456
1457
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1454

def to_vhdl(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}"
end