Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2009-08-07 14:51:18 +0400
committerMarek Safar <marek.safar@gmail.com>2009-08-07 14:51:18 +0400
commit727841576eba9c252beef79c2c149bb4e44f1379 (patch)
tree0e100bf78d3b0697008bce9eff3414ea302370de
parent25cb5c4338f5727bec5390ccd4ca95148ff0299b (diff)
2009-08-07 Marek Safar <marek.safar@gmail.com>
* dynamic.cs, expression.cs: More dynamic conversions. svn path=/trunk/mcs/; revision=139561
-rw-r--r--mcs/mcs/ChangeLog4
-rw-r--r--mcs/mcs/dynamic.cs5
-rw-r--r--mcs/mcs/expression.cs38
3 files changed, 28 insertions, 19 deletions
diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog
index 27b09d8b1d7..3e04f642436 100644
--- a/mcs/mcs/ChangeLog
+++ b/mcs/mcs/ChangeLog
@@ -1,3 +1,7 @@
+2009-08-07 Marek Safar <marek.safar@gmail.com>
+
+ * dynamic.cs, expression.cs: More dynamic conversions.
+
2009-08-06 Miguel de Icaza <miguel@novell.com>
* generic.cs: This loop was incorrect, it was increment ii, but
diff --git a/mcs/mcs/dynamic.cs b/mcs/mcs/dynamic.cs
index 7b9c28c09d5..dd7855a64fc 100644
--- a/mcs/mcs/dynamic.cs
+++ b/mcs/mcs/dynamic.cs
@@ -280,13 +280,12 @@ namespace Mono.CSharp
class DynamicConversion : DynamicExpressionStatement, IDynamicBinder
{
- Type target_type;
bool is_explicit;
public DynamicConversion (Type targetType, bool isExplicit, Arguments args, Location loc)
: base (null, args, loc)
{
- this.target_type = targetType;
+ type = targetType;
is_explicit = isExplicit;
base.binder = this;
}
@@ -296,7 +295,7 @@ namespace Mono.CSharp
Arguments binder_args = new Arguments (2);
MemberAccess binder = GetBinderNamespace (loc);
- binder_args.Add (new Argument (new TypeOf (new TypeExpression (target_type, loc), loc)));
+ binder_args.Add (new Argument (new TypeOf (new TypeExpression (type, loc), loc)));
binder_args.Add (new Argument (new MemberAccess (new MemberAccess (binder, "CSharpConversionKind", loc),
is_explicit ? "ExplicitConversion" : "ImplicitConversion", loc)));
binder_args.Add (new Argument (new BoolLiteral (ec.CheckState, loc)));
diff --git a/mcs/mcs/expression.cs b/mcs/mcs/expression.cs
index 35464013e2e..6748eb42b5d 100644
--- a/mcs/mcs/expression.cs
+++ b/mcs/mcs/expression.cs
@@ -1555,8 +1555,12 @@ namespace Mono.CSharp {
if (type.IsPointer && !ec.InUnsafe) {
UnsafeError (loc);
- return null;
+ } else if (TypeManager.IsDynamicType (expr.Type)) {
+ Arguments arg = new Arguments (1);
+ arg.Add (new Argument (expr));
+ return new DynamicConversion (type, true, arg, loc).Resolve (ec);
}
+
expr = Convert.ExplicitConversion (ec, expr, type, loc);
return expr;
}
@@ -2074,6 +2078,10 @@ namespace Mono.CSharp {
return "LessThan";
case Operator.LessThanOrEqual:
return "LessThanOrEqual";
+ case Operator.LogicalAnd:
+ return "And";
+ case Operator.LogicalOr:
+ return "Or";
case Operator.Modulus:
return is_compound ? "ModuloAssign" : "Modulo";
case Operator.Multiply:
@@ -2629,24 +2637,22 @@ namespace Mono.CSharp {
ec, oper, lc, rc, loc);
if (e != null || Report.Errors != prev_e)
return e;
- } else {
- if ((oper == Operator.BitwiseAnd || oper == Operator.LogicalAnd) &&
+ } else if ((oper == Operator.BitwiseAnd || oper == Operator.LogicalAnd) && !TypeManager.IsDynamicType (left.Type) &&
((lc != null && lc.IsDefaultValue) || (rc != null && rc.IsDefaultValue))) {
- if ((ResolveOperator (ec)) == null) {
- Error_OperatorCannotBeApplied (left, right);
- return null;
- }
+ if ((ResolveOperator (ec)) == null) {
+ Error_OperatorCannotBeApplied (left, right);
+ return null;
+ }
- //
- // The result is a constant with side-effect
- //
- Constant side_effect = rc == null ?
- new SideEffectConstant (lc, right, loc) :
- new SideEffectConstant (rc, left, loc);
+ //
+ // The result is a constant with side-effect
+ //
+ Constant side_effect = rc == null ?
+ new SideEffectConstant (lc, right, loc) :
+ new SideEffectConstant (rc, left, loc);
- return ReducedExpression.Create (side_effect, this);
- }
+ return ReducedExpression.Create (side_effect, this);
}
// Comparison warnings
@@ -6861,7 +6867,7 @@ namespace Mono.CSharp {
Report.Error (673, loc, "System.Void cannot be used from C#. Use typeof (void) to get the void type object");
} else if (typearg.IsPointer && !ec.InUnsafe){
UnsafeError (loc);
- } else if (TypeManager.IsDynamicType (typearg)) {
+ } else if (texpr is DynamicTypeExpr) {
Report.Error (1962, QueriedType.Location,
"The typeof operator cannot be used on the dynamic type");
}