module HDLRuby::High::Hmissing

Module providing handling of unknown methods for hardware constructs.

Constants

High

High-level libraries for describing digital hardware.

Public Instance Methods

method_missing(m, *args, &ruby_block) click to toggle source

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

# File lib/HDLRuby/hruby_high.rb, line 138
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?
    # 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