Module: HDLRuby::Low::Hparent

Included in:
Behavior, Chunk, Code, Delay, Event, Expression, Program, Scope, SignalI, Statement, SystemI, SystemT, Type, When
Defined in:
lib/HDLRuby/hruby_low.rb

Overview

Gives parent definition and access properties to an hardware object.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parentObject

The parent.



45
46
47
# File 'lib/HDLRuby/hruby_low.rb', line 45

def parent
  @parent
end

Instance Method Details

#absolute_refObject

Get an absolute reference to the object.



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/HDLRuby/hruby_low.rb', line 84

def absolute_ref
    # Get the full hierarchy up to the object.
    path = self.hierarchy
    # Create the reference.
    # return path.reduce(RefThis.new) do |ref,node|
    return path.reverse_each.reduce(RefThis.new) do |ref,node|
        # puts "node=#{node}"
        # puts "name=#{node.name}" if node.respond_to?(:name)
        if node.respond_to?(:name) then
            typ = node.respond_to?(:type) ? node.type : void
            RefName.new(typ,ref,node.name)
        else
            ref
        end
    end
end

#hierarchyObject

Get the full parents hierachy.



73
74
75
76
77
78
79
80
81
# File 'lib/HDLRuby/hruby_low.rb', line 73

def hierarchy
    res = []
    cur = self
    while(cur) do
        res << cur
        cur = cur.parent
    end
    return res
end

#no_parent!Object

Clears the parent.



61
62
63
# File 'lib/HDLRuby/hruby_low.rb', line 61

def no_parent!
    @parent = nil
end

#scopeObject

Get the parent scope.



66
67
68
69
70
# File 'lib/HDLRuby/hruby_low.rb', line 66

def scope
    cur = self.parent
    cur = cur.parent until cur.is_a?(Scope)
    return cur
end