Class: HDLRuby::High::RefObject

Inherits:
Low::Ref show all
Includes:
HRef
Defined in:
lib/HDLRuby/hruby_high.rb

Overview

Describes a high-level object reference: no low-level equivalent!

Constant Summary

Constants included from Low::Low2Symbol

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

Instance Attribute Summary collapse

Attributes inherited from Low::Expression

#type

Attributes included from Low::Hparent

#parent

Instance Method Summary collapse

Methods included from HRef

#each, included, #to_event

Methods inherited from Low::Ref

#each_node, #each_node_deep, #eql?, #explicit_types, #hash, #map_nodes!, #path_each, #to_c, #to_high, #to_vhdl

Methods inherited from Low::Expression

#boolean?, #break_types!, #clone, #each_node, #each_node_deep, #each_ref_deep, #eql?, #explicit_types, #extract_selects_to!, #hash, #leftvalue?, #map_nodes!, #replace_expressions!, #replace_names!, #rightvalue?, #set_type!, #statement, #to_c, #to_high, #to_vhdl

Methods included from Low::Low2Symbol

#to_sym

Constructor Details

#initialize(base, object) ⇒ RefObject

Creates a new reference from a +base+ reference and named +object+.



2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
# File 'lib/HDLRuby/hruby_high.rb', line 2554

def initialize(base,object)
    if object.respond_to?(:type) then
        # Typed object, so typed reference.
        super(object.type)
    else
        # Untyped object, so untyped reference.
        super(void)
    end
    # Check and set the base (it must be convertible to a reference).
    unless base.respond_to?(:to_ref)
        raise AnyError, "Invalid base for a RefObject: #{base}"
    end
    @base = base
    # Set the object
    @object = object
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &ruby_block) ⇒ Object

Missing methods are looked for into the refered object.



2589
2590
2591
# File 'lib/HDLRuby/hruby_high.rb', line 2589

def method_missing(m, *args, &ruby_block)
    @object.send(m,*args,&ruby_block)
end

Instance Attribute Details

#baseObject (readonly)

The base of the reference



2548
2549
2550
# File 'lib/HDLRuby/hruby_high.rb', line 2548

def base
  @base
end

#objectObject (readonly)

The refered object.



2551
2552
2553
# File 'lib/HDLRuby/hruby_high.rb', line 2551

def object
  @object
end

Instance Method Details

#constant?Boolean

Tell if the expression is constant.

Returns:

  • (Boolean)


2572
2573
2574
# File 'lib/HDLRuby/hruby_high.rb', line 2572

def constant?
    return self.base.constant?
end

#to_lowObject

Converts the name reference to a HDLRuby::Low::RefName.



2582
2583
2584
2585
2586
# File 'lib/HDLRuby/hruby_high.rb', line 2582

def to_low
    # return HDLRuby::Low::RefName.new(@base.to_ref.to_low,@object.name)
    return HDLRuby::Low::RefName.new(self.type.to_low,
                                     @base.to_ref.to_low,@object.name)
end

#to_refObject

Converts to a new reference.



2577
2578
2579
# File 'lib/HDLRuby/hruby_high.rb', line 2577

def to_ref
    return RefObject.new(@base,@object)
end