X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fnullable.cs;h=3c95d7689bd55fc94f68a5e5d619386e83e842b9;hb=5ad1099341581dee94f77b32db728918e90fa64f;hp=1732a9b9c5c46edda117e4104b1d1637ad617bda;hpb=e946a6cdebde729e1c03ec374184254ab38da184;p=mono.git diff --git a/mcs/mcs/nullable.cs b/mcs/mcs/nullable.cs index 1732a9b9c5c..3c95d7689bd 100644 --- a/mcs/mcs/nullable.cs +++ b/mcs/mcs/nullable.cs @@ -201,6 +201,11 @@ namespace Mono.CSharp.Nullable return uw != null && expr.Equals (uw.expr); } + public override void FlowAnalysis (FlowAnalysisContext fc) + { + expr.FlowAnalysis (fc); + } + public Expression Original { get { return expr; @@ -480,6 +485,11 @@ namespace Mono.CSharp.Nullable ec.MarkLabel (end_label); } + public override void FlowAnalysis (FlowAnalysisContext fc) + { + expr.FlowAnalysis (fc); + } + public void AddressOf (EmitContext ec, AddressOp mode) { unwrap.AddressOf (ec, mode); @@ -649,10 +659,10 @@ namespace Mono.CSharp.Nullable { if (rc.IsRuntimeBinder) { if (UnwrapLeft == null && !Left.Type.IsNullableType) - Left = Wrap.Create (Left, rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType (rc.Module, new[] { Left.Type })); + Left = LiftOperand (rc, Left); if (UnwrapRight == null && !Right.Type.IsNullableType) - Right = Wrap.Create (Right, rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType (rc.Module, new[] { Right.Type })); + Right = LiftOperand (rc, Right); } else { if (UnwrapLeft == null && Left != null && Left.Type.IsNullableType) { Left = Unwrap.CreateUnwrapped (Left); @@ -671,6 +681,21 @@ namespace Mono.CSharp.Nullable return this; } + Expression LiftOperand (ResolveContext rc, Expression expr) + { + TypeSpec type; + if (expr.IsNull) { + type = Left.IsNull ? Right.Type : Left.Type; + } else { + type = expr.Type; + } + + if (!type.IsNullableType) + type = rc.Module.PredefinedTypes.Nullable.TypeSpec.MakeGenericType (rc.Module, new[] { type }); + + return Wrap.Create (expr, type); + } + public override void Emit (EmitContext ec) { if (IsBitwiseBoolean && UserOperator == null) { @@ -1008,6 +1033,11 @@ namespace Mono.CSharp.Nullable ec.MarkLabel (end_label); } + public override void FlowAnalysis (FlowAnalysisContext fc) + { + Binary.FlowAnalysis (fc); + } + public override SLE.Expression MakeExpression (BuilderContext ctx) { return Binary.MakeExpression (ctx, Left, Right); @@ -1221,6 +1251,14 @@ namespace Mono.CSharp.Nullable ec.MarkLabel (end_label); } + public override void FlowAnalysis (FlowAnalysisContext fc) + { + left.FlowAnalysis (fc); + var left_da = fc.BranchDefiniteAssignment (); + right.FlowAnalysis (fc); + fc.DefiniteAssignment = left_da; + } + protected override void CloneTo (CloneContext clonectx, Expression t) { NullCoalescingOperator target = (NullCoalescingOperator) t;