Module: HDLRuby::High::Hmissing

Included in:
HScope_missing, Std::ChannelB, Std::ChannelI, Std::ReconfI, Std::TaskI, SystemT
Defined in:
lib/HDLRuby/hruby_high.rb

Overview

Module providing handling of unknown methods for hardware constructs.

Constant Summary collapse

High =
HDLRuby::High
NAMES =
{ }

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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

Missing methods may be immediate values, if not, they are looked up in the upper level of the namespace if any.



141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/HDLRuby/hruby_high.rb', line 141

def method_missing(m, *args, &ruby_block)
    # puts "method_missing in class=#{self.class} with m=#{m}"
    # Is the missing method an immediate value?
    value = m.to_value
    return value if value and args.empty?
    # Or is it a uniq name generator?
    if (m[-1] == '?') then
        # Yes
        m = m[0..-2]
        return NAMES[m] = HDLRuby.uniq_name(m)
    end
    # Is in a previous uniq name?
    if (m[-1] == '!') then
        pm = m[0..-2]
        if NAMES.key?(pm) then
            # Yes, returns the current corresponding uniq name.
            return self.send(NAMES[pm],*args,&ruby_block)
        end
    end
    # No, is there an upper namespace, i.e. is the current object
    # present in the space?
    if High.space_index(self) then
        # Yes, self is in it, can try the methods in the space.
        High.space_call(m,*args,&ruby_block)
    elsif self.respond_to?(:namespace) and
          High.space_index(self.namespace) then
        # Yes, the private namespace is in it, can try the methods in
        # the space.
        begin
            High.space_call(m,*args,&ruby_block)
        end
    elsif self.respond_to?(:public_namespace) and
          High.space_index(self.public_namespace) then
        # Yes, the private namespace is in it, can try the methods in
        # the space.
        High.space_call(m,*args,&ruby_block)
    else
        # No, this is a true error.
        raise NotDefinedError, "undefined HDLRuby construct, local variable or method `#{m}'."
    end
end