4 self.instance_fields = 3
5 ivar_as_index :__ivars__ => 0, :block => 1, :check_args => 2
7 def block; @block ; end
13 def check_args=(other)
18 Binding.setup @block.home
22 # An optimized version, used for the &block syntax
25 def self.__from_block__(env)
26 if env.__kind_of__(BlockEnvironment)
34 raise ArgumentError, "Unable to convert #{env.inspect} to a Proc"
39 def self.from_environment(env, check_args=false)
42 elsif env.kind_of?(BlockEnvironment)
45 obj.check_args = check_args
47 elsif env.respond_to? :to_proc
50 raise ArgumentError.new("Unable to turn a #{env.inspect} into a Proc")
58 # This behavior is stupid.
59 be = MethodContext.current.sender.block
61 return from_environment(be)
63 raise ArgumentError, "tried to create a Proc object without a block"
69 "#<#{self.class}:0x#{self.object_id.to_s(16)} @ #{self.block.file}:#{self.block.line}>"
72 alias_method :to_s, :inspect
75 return false unless other.kind_of? self.class
91 alias_method :[], :call
94 ivar_as_index :block => 1
98 unless a < 0 or a == 1 or args.size == a
99 raise ArgumentError, "wrong number of arguments (#{args.size} for #{arity})"
104 rescue IllegalLongReturn, LongReturnException => e
109 alias_method :[], :call