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, #explicit_types, #hash, #map_nodes!, #path_each, #resolve, #to_c, #to_hdr, #to_vhdl

Methods inherited from Low::Expression

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

Methods included from Low::Low2Symbol

#to_sym

Methods included from Low::Hparent

#hierarchy, #scope

Constructor Details

#initialize(base, object) ⇒ RefObject

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



3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
# File 'lib/HDLRuby/hruby_high.rb', line 3187

def initialize(base,object)
    # puts "New RefObjet with base=#{base}, object=#{object.name}"
    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.



3236
3237
3238
# File 'lib/HDLRuby/hruby_high.rb', line 3236

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

Instance Attribute Details

#baseObject (readonly)

The base of the reference



3181
3182
3183
# File 'lib/HDLRuby/hruby_high.rb', line 3181

def base
  @base
end

#objectObject (readonly)

The refered object.



3184
3185
3186
# File 'lib/HDLRuby/hruby_high.rb', line 3184

def object
  @object
end

Instance Method Details

#constant?Boolean

Tell if the expression is constant.

Returns:

  • (Boolean)


3206
3207
3208
# File 'lib/HDLRuby/hruby_high.rb', line 3206

def constant?
    return self.base.constant?
end

#eql?(obj) ⇒ Boolean

Comparison for hash: structural comparison.

Returns:

  • (Boolean)


3216
3217
3218
3219
3220
3221
# File 'lib/HDLRuby/hruby_high.rb', line 3216

def eql?(obj)
    return false unless obj.is_a?(RefObject)
    return false unless @base.eql?(obj.base)
    return false unless @object.eql?(obj.object)
    return true
end

#to_lowObject

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



3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
# File 'lib/HDLRuby/hruby_high.rb', line 3224

def to_low
    # puts "to_low with base=#{@base} @object=#{@object}"
    # puts "@object.name=#{@object.name}"
    refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
                                     @base.to_ref.to_low,@object.name)
    # # For debugging: set the source high object 
    # refNameL.properties[:low2high] = self.hdr_id
    # self.properties[:high2low] = refNameL
    return refNameL
end

#to_refObject

Converts to a new reference.



3211
3212
3213
# File 'lib/HDLRuby/hruby_high.rb', line 3211

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