Class: HDLRuby::Low::Operation
- Inherits:
-
Expression
- Object
- Expression
- HDLRuby::Low::Operation
- Defined in:
- lib/HDLRuby/hruby_low.rb,
lib/HDLRuby/hruby_viz.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_skeleton.rb,
lib/HDLRuby/hruby_low_fix_types.rb
Overview
Describes an operation.
NOTE: this is an abstract class which is not to be used directly.
Constant Summary
Constants included from Low2Symbol
Low2Symbol::Low2SymbolPrefix, Low2Symbol::Low2SymbolTable, Low2Symbol::Symbol2LowTable
Instance Attribute Summary collapse
-
#operator ⇒ Object
readonly
The operator of the operation.
Attributes inherited from Expression
Attributes included from Hparent
Instance Method Summary collapse
-
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
-
#explicit_types(type = nil) ⇒ Object
Explicit the types conversions in the operation where +type+ is the expected type of the condition if any.
-
#hash ⇒ Object
Hash function.
-
#initialize(type, operator) ⇒ Operation
constructor
Creates a new operation with +type+ applying +operator+.
-
#set_operator!(operator) ⇒ Object
Sets the operator.
-
#to_c(res, level = 0) ⇒ 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.
-
#to_viz_node(parent) ⇒ Object
Converts the operation to a Viz flow node under +parent+.
Methods inherited from Expression
#boolean?, #break_types!, #clone, #each_node, #each_node_deep, #each_ref_deep, #extract_selects_to!, #fix_scope_refnames!, #immutable?, #leftvalue?, #map_nodes!, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #signal2subs!, #statement, #to_c_expr, #to_high, #to_viz_names, #use_name?
Methods included from Low2Symbol
Methods included from Hparent
#absolute_ref, #hierarchy, #no_parent!, #scope
Constructor Details
#initialize(type, operator) ⇒ Operation
Creates a new operation with +type+ applying +operator+. def initialize(operator)
5258 5259 5260 5261 5262 |
# File 'lib/HDLRuby/hruby_low.rb', line 5258 def initialize(type,operator) super(type) # Check and set the operator. @operator = operator.to_sym end |
Instance Attribute Details
#operator ⇒ Object (readonly)
The operator of the operation.
5254 5255 5256 |
# File 'lib/HDLRuby/hruby_low.rb', line 5254 def operator @operator end |
Instance Method Details
#eql?(obj) ⇒ Boolean
Comparison for hash: structural comparison.
5265 5266 5267 5268 5269 5270 5271 5272 |
# File 'lib/HDLRuby/hruby_low.rb', line 5265 def eql?(obj) # General comparison. return false unless super(obj) # Specific comparison. return false unless obj.is_a?(Operation) return false unless @operator.eql?(obj.operator) return true end |
#explicit_types(type = nil) ⇒ Object
Explicit the types conversions in the operation where +type+ is the expected type of the condition if any.
279 280 281 |
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 279 def explicit_types(type = nil) raise "Should implement explicit_types for class #{self.class}." end |
#hash ⇒ Object
Hash function.
5275 5276 5277 |
# File 'lib/HDLRuby/hruby_low.rb', line 5275 def hash return [super,@operator].hash end |
#set_operator!(operator) ⇒ Object
Sets the operator.
1408 1409 1410 1411 |
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1408 def set_operator!(operator) # Check and set the operator. @operator = operator.to_sym end |
#to_c(res, level = 0) ⇒ Object
Generates the C text of the equivalent HDLRuby code. +level+ is the hierachical level of the object. def to_c(level = 0)
2367 2368 2369 2370 |
# File 'lib/HDLRuby/hruby_low2c.rb', line 2367 def to_c(res,level = 0) # 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.
594 595 596 597 |
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 594 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.
1274 1275 1276 1277 |
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1274 def to_vhdl(level = 0) # Should never be here. raise AnyError, "Internal error: to_vhdl should be implemented in class :#{self.class}" end |
#to_viz_node(parent) ⇒ Object
Converts the operation to a Viz flow node under +parent+.
4920 4921 4922 4923 4924 4925 |
# File 'lib/HDLRuby/hruby_viz.rb', line 4920 def to_viz_node(parent) node = HDLRuby::Viz::Node.new(self.operator,parent) # And generate the children. self.each_node {|child| child.to_viz_node(node) } return node end |