Class: HDLRuby::Low::Ref

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

Overview

Extends the Ref class with fixing of types and constants.

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!, #initialize, #leftvalue?, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #statement

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.



4344
4345
4346
4347
4348
# File 'lib/HDLRuby/hruby_low.rb', line 4344

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.



4353
4354
4355
4356
4357
4358
4359
# File 'lib/HDLRuby/hruby_low.rb', line 4353

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)


4316
4317
4318
4319
4320
4321
4322
# File 'lib/HDLRuby/hruby_low.rb', line 4316

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.



324
325
326
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 324

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

#hashObject

Hash function.



4325
4326
4327
# File 'lib/HDLRuby/hruby_low.rb', line 4325

def hash
    super
end

#map_nodes!(&ruby_block) ⇒ Object

Maps on the children.



1536
1537
1538
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1536

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.



4336
4337
4338
4339
4340
4341
# File 'lib/HDLRuby/hruby_low.rb', line 4336

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

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

Generates the C text of the equivalent HDLRuby::High code. +level+ is the hierachical level of the object and +left+ tells if it is a left value or not.

Raises:



1804
1805
1806
1807
# File 'lib/HDLRuby/hruby_low2c.rb', line 1804

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

#to_high(level = 0) ⇒ Object

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

Raises:



653
654
655
656
# File 'lib/HDLRuby/hruby_low2high.rb', line 653

def to_high(level = 0)
    # Should never be here.
    raise AnyError, "Internal error: to_high 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:



1324
1325
1326
1327
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1324

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