tfpt review /shelveset:Super17;REDMOND\tomat
DLR changes:
-
Removes InvokeMethodAttributes.
-
Makes ActionExpression factory public - it's needed by a
custom Ruby action (ProtocolConverterAction).
Ruby changes:
-
Adds InvokeSuperMemberAction custom action
-
Refactors handling of member invocation in RubyBinder.
-
Improves implementation of super call. This is how 'super'
seems to work:
-
Let s be the inner-most scope in the lexical scope hierarchy
of the ‘super’ call site that is either
a. a method scope, or
b. a block definition scope of a block whose caller is a method
created by ‘define_method’
-
If s is a method definition scope (1a) then this method's frame
f is available: either it is
a. the frame that invokes the ‘super’ call, or
b. captured by a closure of the block that contains the ‘super’
call
-
If s is a block (1b) then its caller's frame f is available. Use the arguments, self object and method name of the
frame f for the ‘super’ invocation.
Implementation: the method defined by define_method passes its frame
into the block it calls (in BlockParam object). Super call site
traverses lexical hierarchy and finds scope s and frame f. All
information necessary to perform the super call are on f. For super to
work within eval some additional work needs to be done beyond this
shelveset - arguments needs to be distinguishable from other local
variables at run-time. Super in eval will then do dynamic local variable
lookup on the argument names that it finds in the frame f. This change
doesn’t implement any optimizations though they are possible in some
cases.
-
Adds ProtocolConverterAction custom action.
o It’s an abstract class for specific protocol conversions (to_proc,
to_s, …)
o This shelveset adds only ConvertToProcAction <:
ProtocolConverterAction so far, we can replace Protocols by these
actions in future.
o The protocol used for conversions is:
-
result = obj.to_xxxif obj.respond_to? :to_xxx
if result.subclass_of Xxx then return result
end
errror
o The action implements an optimization that avoids 2 dynamic
dispatches in case respond_to? is not overridden:
-
check class version of object obj in rule test
-
obj.class overrides respond_to? => no optimization (emit 2
dynamic dispatches to respond_to? and to_xxx)
-
otherwise: lookup to_xxx, not found => emit error, found =>
emit static call to to_xxx
-
check result of to_xxx
-
Implements to_proc conversion for & operator using
ConvertToProcAction (fixes bug #19714: & operator should call to_proc)
-
Adds #method-definition closure local variable of type
RubyMethodInfo:
o Each method definition stores itself into this variable, which is
used inside the method definition. This effectively enables any
library/ops code to access the current method definition.
o RubyMethodInfo now holds on the method’s declaring local scope.
o Adds DefinitionName to RubyMethodInfo - this is the name of the
method definition. The method itself could be used under different names
(if aliased). Some language operations care only about definition name
(like super call).
-
Adds UndefineMethod attribute - it is used on library classes
to undefined methods defined in base classes.
-
Fixes GetInstanceMethods to skip undefined method.
-
Implements Kernel#block_given?, Module#module_function
methods. Fixes Kernel#private/public/protected methods.
-
Replaces VariableExpression and ParameterExpression by
Expression where possible.
-
Simplifies code emitted per method definition.
-
Fixes bug #19907: class_eval not singleton.
-
Fixes bug #19672: Logical operator in method arguments won't
parse.
-
Fixes bug #19803: rescue next syntax bug.
-
Fixes bug #19892: Proc cannot be used as Boolean.
-
Fixes bug #19706: alias method resolution bug.
-
Adds more unit tests and refactors unit test driver a little
bit.
Tomas