Class: HDLRuby::Low::Operation

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_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

Extends the Operation class with fixing of types and constants.

Direct Known Subclasses

Binary, Select, Unary

Constant Summary

Constants included from Low2Symbol

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

Instance Attribute Summary collapse

Attributes inherited from Expression

#type

Attributes included from Hparent

#parent

Instance Method Summary collapse

Methods inherited from Expression

#boolean?, #break_types!, #clone, #each_node, #each_node_deep, #each_ref_deep, #extract_selects_to!, #immutable?, #leftvalue?, #map_nodes!, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #signal2subs!, #statement, #to_c_expr, #to_high, #use_name?

Methods included from Low2Symbol

#to_sym

Methods included from Hparent

#hierarchy, #no_parent!, #scope

Constructor Details

#initialize(type, operator) ⇒ Operation

Creates a new operation with +type+ applying +operator+. def initialize(operator)



5087
5088
5089
5090
5091
# File 'lib/HDLRuby/hruby_low.rb', line 5087

def initialize(type,operator)
    super(type)
    # Check and set the operator.
    @operator = operator.to_sym
end

Instance Attribute Details

#operatorObject (readonly)

The operator of the operation.



5083
5084
5085
# File 'lib/HDLRuby/hruby_low.rb', line 5083

def operator
  @operator
end

Instance Method Details

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


5094
5095
5096
5097
5098
5099
5100
5101
# File 'lib/HDLRuby/hruby_low.rb', line 5094

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.



258
259
260
# File 'lib/HDLRuby/hruby_low_fix_types.rb', line 258

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

#hashObject

Hash function.



5104
5105
5106
# File 'lib/HDLRuby/hruby_low.rb', line 5104

def hash
    return [super,@operator].hash
end

#set_operator!(operator) ⇒ Object

Sets the operator.



1457
1458
1459
1460
# File 'lib/HDLRuby/hruby_low_mutable.rb', line 1457

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)

Raises:



2355
2356
2357
2358
# File 'lib/HDLRuby/hruby_low2c.rb', line 2355

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.

Raises:



578
579
580
581
# File 'lib/HDLRuby/hruby_low2hdr.rb', line 578

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.

Raises:



1249
1250
1251
1252
# File 'lib/HDLRuby/hruby_low2vhd.rb', line 1249

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