Code Review: Conversions12

tfpt review “/shelveset:Conversions12;REDMOND\tomat”

DLR:

RestrictionInfo is renamed to RestrictedArguments and passed to
ArgBuilder.ToExpression and ArgBuilder.ToDelegate instead of
List. This way the methods have full information on the
meta-arguments as well as their restrictions that were used to resolve
the overload.

OverloadResolver.ConvertExpression now takes DynamicMetaObject and its
restricted Type. Conversions can directly cast the value to the
restricted type (if visible) instead of testing the type again.

ConversionResult - hold on the argument value as well as its limit type.
We need to report class name in an error message that can only be
retrieved from the actual object not the CLR type.

Adds InstanceBuilder class, removes NullArgBuilder. NullArgBuilder is
handled as a special case in InstanceBuilder. InstanceBuilder first
finds a callable method if the current method info is not and then
converts the instance argument to the declaring type of the method
(could be an interface). It uses limit type of the instance meta
argument to determine the callable method. The limit type could be an
internal type that inherits an implementation of the method from its
super type and exposes it via a public interface. In that case the
declaring type of the method info given to the overload resolver is the
base type yet that type might not implement the interface that exposes
the method in the derived type. Hence we need to use the real type of
the argument to find out the callable interface method in
GetCallableMethod.

Fixes a bug in MetaObjectExtensions.Restrict - the method created
meta-objects with a value given meta-objects w/o one.

Ruby:

Removes legacy implementation of conversions (copied long time ago from
Python) and replaces it by a new one. We use 3 narrowing levels for
conversions performed in overload resolution. Implicit static
conversions are considered in level 1, explicit static conversions on
level 2 and dynamic conversions on level 3.

Adds GenericConversionAction that implements dynamic non-protocol
conversion to an arbitrary type.

ClsTypeEmitter: replaces conversions with conversion dynamic site. Adds
dynamic site construction expressions to a list as they are emitted to
IL and at the end, when the type is being finished, combines them all
into a single block expression and emits that into a static method. This
static method is then called from cctor. The approach can also be used
for the other sites initialized in cctor (not included in this
shelveset).

Tomas

Fixed. I renamed OverloadResolver.ConvertExpression to Convert and
ConvertObject that returns Func<object[], object> to
GetConversionDelegate.

Tomas

From: Dino Viehland
Sent: Tuesday, May 19, 2009 1:19 PM
To: Tomas M.; IronRuby External Code R.; Rowan Code
Reviewers
Cc: [email protected]
Subject: RE: Code Review: Conversions12

Why does ActionBinder.ConvertExpression lose its comment?

OutArgBuilder’s /ReturnReferenceArgBuilder - new namespace is added in
an ugly way (and again in
ReferenceArgBuilder/ReturnBuilder/MethodCandidate/RestrictionInfo but
it’s not as ugly - just not sorted).

OverloadResolver.ConvertExpression should be renamed to
ConvertMetaObject.

Otherwise looks good!

From: Tomas M.
Sent: Tuesday, May 19, 2009 12:40 PM
To: IronRuby External Code R.; Rowan Code R.
Cc: [email protected]
Subject: Code Review: Conversions12

tfpt review “/shelveset:Conversions12;REDMOND\tomat”

DLR:

RestrictionInfo is renamed to RestrictedArguments and passed to
ArgBuilder.ToExpression and ArgBuilder.ToDelegate instead of
List. This way the methods have full information on the
meta-arguments as well as their restrictions that were used to resolve
the overload.

OverloadResolver.ConvertExpression now takes DynamicMetaObject and its
restricted Type. Conversions can directly cast the value to the
restricted type (if visible) instead of testing the type again.

ConversionResult - hold on the argument value as well as its limit type.
We need to report class name in an error message that can only be
retrieved from the actual object not the CLR type.

Adds InstanceBuilder class, removes NullArgBuilder. NullArgBuilder is
handled as a special case in InstanceBuilder. InstanceBuilder first
finds a callable method if the current method info is not and then
converts the instance argument to the declaring type of the method
(could be an interface). It uses limit type of the instance meta
argument to determine the callable method. The limit type could be an
internal type that inherits an implementation of the method from its
super type and exposes it via a public interface. In that case the
declaring type of the method info given to the overload resolver is the
base type yet that type might not implement the interface that exposes
the method in the derived type. Hence we need to use the real type of
the argument to find out the callable interface method in
GetCallableMethod.

Fixes a bug in MetaObjectExtensions.Restrict - the method created
meta-objects with a value given meta-objects w/o one.

Ruby:

Removes legacy implementation of conversions (copied long time ago from
Python) and replaces it by a new one. We use 3 narrowing levels for
conversions performed in overload resolution. Implicit static
conversions are considered in level 1, explicit static conversions on
level 2 and dynamic conversions on level 3.

Adds GenericConversionAction that implements dynamic non-protocol
conversion to an arbitrary type.

ClsTypeEmitter: replaces conversions with conversion dynamic site. Adds
dynamic site construction expressions to a list as they are emitted to
IL and at the end, when the type is being finished, combines them all
into a single block expression and emits that into a static method. This
static method is then called from cctor. The approach can also be used
for the other sites initialized in cctor (not included in this
shelveset).

Tomas