Class: HDLRuby::Low::Ref
- Inherits:
-
Expression
- Object
- Base::Expression
- Expression
- HDLRuby::Low::Ref
- Defined in:
- lib/HDLRuby/hruby_db.rb,
lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_low2c.rb,
lib/HDLRuby/hruby_low2hdr.rb,
lib/HDLRuby/hruby_low2vhd.rb,
lib/HDLRuby/hruby_low2high.rb,
lib/HDLRuby/hruby_low_mutable.rb,
lib/HDLRuby/hruby_low_resolve.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.
Constant Summary
Constants included from Low2Symbol
Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable
Instance Attribute Summary
Attributes inherited from Expression
Attributes included from Hparent
Instance Method Summary collapse
-
#each_node(&ruby_block) ⇒ Object
(also: #each_expression)
Iterates over the reference children if any.
-
#each_node_deep(&ruby_block) ⇒ Object
Iterates over the nodes deeply if any.
-
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
-
#explicit_types(type = nil) ⇒ Object
Explicit the types conversions in the reference where +type+ is the expected type of the condition if any.
-
#hash ⇒ Object
Hash function.
-
#map_nodes!(&ruby_block) ⇒ Object
Maps on the children.
-
#path_each(&ruby_block) ⇒ Object
Iterates over the names of the path indicated by the reference.
-
#resolve ⇒ Object
Resolves the name of the reference (if any) and return the corresponding object.
-
#to_c(res, level = 0, left = false) ⇒ Object
Generates the C text of the equivalent HDLRuby code.
-
#to_hdr(level = 0) ⇒ Object
Generates the text of the equivalent hdr text.
-
#to_vhdl(level = 0) ⇒ Object
Generates the text of the equivalent HDLRuby::High code.
Methods inherited from Expression
#boolean?, #break_types!, #clone, #each_ref_deep, #extract_selects_to!, #immutable?, #initialize, #leftvalue?, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #statement, #to_c_expr, #to_high, #use_name?
Methods included from Low2Symbol
Methods included from Hparent
#hierarchy, #no_parent!, #scope
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.
5460 5461 5462 5463 5464 |
# File 'lib/HDLRuby/hruby_low.rb', line 5460 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.
5469 5470 5471 5472 5473 5474 5475 |
# File 'lib/HDLRuby/hruby_low.rb', line 5469 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.
5432 5433 5434 5435 5436 5437 5438 |
# File 'lib/HDLRuby/hruby_low.rb', line 5432 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.
361 362 363 |
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 361 def explicit_types(type = nil) raise "Should implement explicit_types for class #{self.class}." end |
#hash ⇒ Object
Hash function.
5441 5442 5443 |
# File 'lib/HDLRuby/hruby_low.rb', line 5441 def hash super end |
#map_nodes!(&ruby_block) ⇒ Object
Maps on the children.
1707 1708 1709 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1707 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.
5452 5453 5454 5455 5456 5457 |
# File 'lib/HDLRuby/hruby_low.rb', line 5452 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 |
#resolve ⇒ Object
Resolves the name of the reference (if any) and return the corresponding object. NOTE: return nil if could not resolve.
119 120 121 122 |
# File 'lib/HDLRuby/hruby_low_resolve.rb', line 119 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)
2778 2779 2780 2781 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 2778 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.
653 654 655 656 |
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 653 def to_hdr(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.
1424 1425 1426 1427 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1424 def to_vhdl(level = 0) # Should never be here. raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}" end |