X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mcs%2Fmcs%2Fassign.cs;h=a07c8c0ef397d1e2d597680f035cf078aa732489;hb=01df432af43ed3dd9a225b13e0ebcce9a8a34a5a;hp=9481aef96edae4b6d66b28b161a9eeb43e0b5b44;hpb=3fb128ac0de7cca459098c2dc3359d81f5e48353;p=mono.git diff --git a/mcs/mcs/assign.cs b/mcs/mcs/assign.cs index 9481aef96ed..a07c8c0ef39 100644 --- a/mcs/mcs/assign.cs +++ b/mcs/mcs/assign.cs @@ -334,7 +334,7 @@ namespace Mono.CSharp { if (source == null) { ok = false; - source = EmptyExpression.Null; + source = ErrorExpression.Instance; } target = target.ResolveLValue (ec, source); @@ -363,7 +363,6 @@ namespace Mono.CSharp { return this; } -#if NET_4_0 || MOBILE_DYNAMIC public override System.Linq.Expressions.Expression MakeExpression (BuilderContext ctx) { var tassign = target as IDynamicAssign; @@ -391,7 +390,7 @@ namespace Mono.CSharp { return System.Linq.Expressions.Expression.Assign (target_object, source_object); } -#endif + protected virtual Expression ResolveConversions (ResolveContext ec) { source = Convert.ImplicitConversionRequired (ec, source, target.Type, source.Location); @@ -421,7 +420,13 @@ namespace Mono.CSharp { { source.FlowAnalysis (fc); - if (target is ArrayAccess || target is IndexerExpr || target is PropertyExpr) + if (target is ArrayAccess || target is IndexerExpr) { + target.FlowAnalysis (fc); + return; + } + + var pe = target as PropertyExpr; + if (pe != null && !pe.IsAutoPropertyAccess) target.FlowAnalysis (fc); } @@ -491,13 +496,23 @@ namespace Mono.CSharp { fe.SetFieldAssigned (fc); return; } + + var pe = target as PropertyExpr; + if (pe != null) { + pe.SetBackingFieldAssigned (fc); + return; + } + + var td = target as TupleDeconstruct; + if (td != null) { + td.SetGeneratedFieldAssigned (fc); + return; + } } - public override void MarkReachable (Reachability rc) + public override Reachability MarkReachable (Reachability rc) { - var es = source as ExpressionStatement; - if (es != null) - es.MarkReachable (rc); + return source.MarkReachable (rc); } } @@ -564,6 +579,9 @@ namespace Mono.CSharp { { flags |= Options.FieldInitializerScope | Options.ConstructorScope; this.ctor_block = constructorContext.CurrentBlock.Explicit; + + if (ctor_block.IsCompilerGenerated) + CurrentBlock = ctor_block; } public override ExplicitBlock ConstructorBlock { @@ -589,6 +607,12 @@ namespace Mono.CSharp { public int AssignmentOffset { get; private set; } + public FieldBase Field { + get { + return mc; + } + } + public override Location StartLocation { get { return loc; @@ -601,8 +625,8 @@ namespace Mono.CSharp { if (source == null) return null; - var bc = (BlockContext) rc; if (resolved == null) { + var bc = (BlockContext) rc; var ctx = new FieldInitializerContext (mc, bc); resolved = base.DoResolve (ctx) as ExpressionStatement; AssignmentOffset = ctx.AssignmentInfoOffset - bc.AssignmentInfoOffset; @@ -636,6 +660,7 @@ namespace Mono.CSharp { public override void FlowAnalysis (FlowAnalysisContext fc) { source.FlowAnalysis (fc); + ((FieldExpr) target).SetFieldAssigned (fc); } public bool IsDefaultInitializer { @@ -656,6 +681,33 @@ namespace Mono.CSharp { } } + class PrimaryConstructorAssign : SimpleAssign + { + readonly Field field; + readonly Parameter parameter; + + public PrimaryConstructorAssign (Field field, Parameter parameter) + : base (null, null, parameter.Location) + { + this.field = field; + this.parameter = parameter; + } + + protected override Expression DoResolve (ResolveContext rc) + { + target = new FieldExpr (field, loc); + source = rc.CurrentBlock.ParametersBlock.GetParameterInfo (parameter).CreateReferenceExpression (rc, loc); + return base.DoResolve (rc); + } + + public override void EmitStatement (EmitContext ec) + { + using (ec.With (BuilderContext.Options.OmitDebugInfo, true)) { + base.EmitStatement (ec); + } + } + } + // // This class is used for compound assignments. // @@ -672,9 +724,11 @@ namespace Mono.CSharp { this.loc = child.Location; } + public bool RequiresEmitWithAwait { get; set; } + public override bool ContainsEmitWithAwait () { - return child.ContainsEmitWithAwait (); + return RequiresEmitWithAwait || child.ContainsEmitWithAwait (); } public override Expression CreateExpressionTree (ResolveContext ec)