internal static DynamicMetaObject/*!*/ ConvertComArgument(DynamicMetaObject/*!*/ arg) {
Expression expr = arg.Expression;
BindingRestrictions restrictions;
if (arg.Value != null) {
Type type = arg.Value.GetType();
if (type == typeof(BigInteger)) {
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(BigInteger)), typeof(double));
} else if (type == typeof(MutableString)) {
// TODO: encoding?
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(MutableString)), typeof(string));
} else if (type == typeof(RubySymbol)) {
// TODO: encoding?
expr = Ast.Convert(AstUtils.Convert(arg.Expression, typeof(RubySymbol)), typeof(string));
}
restrictions = BindingRestrictions.GetTypeRestriction(arg.Expression, type);
} else {
restrictions = BindingRestrictions.GetExpressionRestriction(Ast.Equal(arg.Expression, AstUtils.Constant(null)));
}
return arg.Clone(expr, restrictions);
}
}