public AnonymousExpression Compatible(ResolveContext ec, AnonymousExpression ae) { // TODO: Implement clone BlockContext aec = new BlockContext (ec.MemberContext, Block, ReturnType); aec.CurrentAnonymousMethod = ae; IDisposable aec_dispose = null; ResolveContext.Options flags = 0; if (ec.HasSet (ResolveContext.Options.InferReturnType)) { flags |= ResolveContext.Options.InferReturnType; aec.ReturnTypeInference = new TypeInferenceContext (); } if (ec.IsInProbingMode) flags |= ResolveContext.Options.ProbingMode; if (ec.HasSet (ResolveContext.Options.FieldInitializerScope)) flags |= ResolveContext.Options.FieldInitializerScope; if (ec.IsUnsafe) flags |= ResolveContext.Options.UnsafeScope; if (ec.HasSet (ResolveContext.Options.CheckedScope)) flags |= ResolveContext.Options.CheckedScope; if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion)) flags |= ResolveContext.Options.ExpressionTreeConversion; // HACK: Flag with 0 cannot be set if (flags != 0) aec_dispose = aec.Set (flags); bool res = Block.Resolve (ec.CurrentBranching, aec, Block.Parameters, null); if (aec.HasReturnLabel) return_label = aec.ReturnLabel; if (ec.HasSet (ResolveContext.Options.InferReturnType)) { aec.ReturnTypeInference.FixAllTypes (ec); ReturnType = aec.ReturnTypeInference.InferredTypeArguments [0]; } if (aec_dispose != null) { aec_dispose.Dispose (); } return res ? this : null; }
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec, block, ReturnType); aec.CurrentAnonymousMethod = ae; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } var bc = ec as BlockContext; if (bc != null) aec.FlowOffset = bc.FlowOffset; var errors = ec.Report.Errors; bool res = Block.Resolve (ec.CurrentBranching, aec, null); if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; // // If e is synchronous the inferred return type is T // If e is asynchronous the inferred return type is Task<T> // if (block.IsAsync && ReturnType != null) { ReturnType = ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType }); } } if (res && errors != ec.Report.Errors) return null; return res ? this : null; }
public AnonymousMethodMethod (TypeDefinition parent, AnonymousExpression am, AnonymousMethodStorey storey, TypeExpr return_type, Modifiers mod, MemberName name, ParametersCompiled parameters) : base (parent, return_type, mod | Modifiers.COMPILER_GENERATED, name, parameters, null) { this.AnonymousMethod = am; this.Storey = storey; Parent.PartialContainer.Members.Add (this); Block = new ToplevelBlock (am.block, parameters); }
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec, block, ReturnType); aec.CurrentAnonymousMethod = ae; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } var bc = ec as BlockContext; if (bc != null) { aec.AssignmentInfoOffset = bc.AssignmentInfoOffset; aec.EnclosingLoop = bc.EnclosingLoop; aec.EnclosingLoopOrSwitch = bc.EnclosingLoopOrSwitch; aec.Switch = bc.Switch; } var errors = ec.Report.Errors; bool res = Block.Resolve (aec); if (res && errors == ec.Report.Errors) { MarkReachable (new Reachability ()); if (!CheckReachableExit (ec.Report)) { return null; } if (bc != null) bc.AssignmentInfoOffset = aec.AssignmentInfoOffset; } if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; // // If e is synchronous the inferred return type is T // If e is asynchronous and the body of F is either an expression classified as nothing // or a statement block where no return statements have expressions, the inferred return type is Task // If e is async and has an inferred result type T, the inferred return type is Task<T> // if (block.IsAsync && ReturnType != null) { ReturnType = ReturnType.Kind == MemberKind.Void ? ec.Module.PredefinedTypes.Task.TypeSpec : ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType }); } } if (res && errors != ec.Report.Errors) return null; return res ? this : null; }
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec, block, ReturnType); aec.CurrentAnonymousMethod = ae; ResolveContext.Options flags = 0; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } if (ec.IsInProbingMode) flags |= ResolveContext.Options.ProbingMode; if (ec.HasSet (ResolveContext.Options.FieldInitializerScope)) flags |= ResolveContext.Options.FieldInitializerScope; if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion)) flags |= ResolveContext.Options.ExpressionTreeConversion; aec.Set (flags); var errors = ec.Report.Errors; bool res = Block.Resolve (ec.CurrentBranching, aec, null); if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; // // If e is synchronous the inferred return type is T // If e is asynchronous the inferred return type is Task<T> // if (block.IsAsync && ReturnType != null) { ReturnType = ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType }); } } if (res && errors != ec.Report.Errors) return null; return res ? this : null; }
public AnonymousMethodMethod (DeclSpace parent, AnonymousExpression am, AnonymousMethodStorey storey, GenericMethod generic, TypeExpr return_type, Modifiers mod, string real_name, MemberName name, ParametersCompiled parameters) : base (parent, generic, return_type, mod | Modifiers.COMPILER_GENERATED, name, parameters, null) { this.AnonymousMethod = am; this.Storey = storey; this.RealName = real_name; Parent.PartialContainer.AddMethod (this); Block = new ToplevelBlock (am.block, parameters); }
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec.MemberContext, Block, ReturnType); aec.CurrentAnonymousMethod = ae; ResolveContext.FlagsHandle? aec_dispose = null; ResolveContext.Options flags = 0; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } if (ec.IsInProbingMode) flags |= ResolveContext.Options.ProbingMode; if (ec.HasSet (ResolveContext.Options.FieldInitializerScope)) flags |= ResolveContext.Options.FieldInitializerScope; if (ec.IsUnsafe) flags |= ResolveContext.Options.UnsafeScope; if (ec.HasSet (ResolveContext.Options.CheckedScope)) flags |= ResolveContext.Options.CheckedScope; if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion)) flags |= ResolveContext.Options.ExpressionTreeConversion; // HACK: Flag with 0 cannot be set if (flags != 0) aec_dispose = aec.Set (flags); var errors = ec.Report.Errors; bool res = Block.Resolve (ec.CurrentBranching, aec, Block.Parameters, null); if (aec.HasReturnLabel) return_label = aec.ReturnLabel; if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; } if (aec_dispose != null) { aec_dispose.Value.Dispose (); } if (res && errors != ec.Report.Errors) return null; return res ? this : null; }
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec, block, ReturnType); aec.CurrentAnonymousMethod = ae; ResolveContext.Options flags = 0; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } if (ec.IsInProbingMode) flags |= ResolveContext.Options.ProbingMode; if (ec.HasSet (ResolveContext.Options.FieldInitializerScope)) flags |= ResolveContext.Options.FieldInitializerScope; if (ec.HasSet (ResolveContext.Options.ExpressionTreeConversion)) flags |= ResolveContext.Options.ExpressionTreeConversion; aec.Set (flags); var errors = ec.Report.Errors; bool res = Block.Resolve (ec.CurrentBranching, aec, null); if (aec.HasReturnLabel) return_label = aec.ReturnLabel; if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; } if (res && errors != ec.Report.Errors) return null; return res ? this : null; }
public override HoistedVariable GetHoistedVariable(AnonymousExpression ae) { return li.HoistedVariant; }
public override HoistedVariable GetHoistedVariable (AnonymousExpression ae) { if (ae == null) return null; AnonymousMethodStorey storey = ae.Storey; while (storey != null) { AnonymousMethodStorey temp = storey.Parent as AnonymousMethodStorey; if (temp == null) return storey.HoistedThis; storey = temp; } return null; }
public override HoistedVariable GetHoistedVariable (AnonymousExpression ae) { return pi.Parameter.HoistedVariableReference; }
public override HoistedVariable GetHoistedVariable (AnonymousExpression ae) { return local_info.HoistedVariableReference; }
public abstract HoistedVariable GetHoistedVariable (AnonymousExpression ae);
public AnonymousExpression Compatible (ResolveContext ec, AnonymousExpression ae) { if (block.Resolved) return this; // TODO: Implement clone BlockContext aec = new BlockContext (ec, block, ReturnType); aec.CurrentAnonymousMethod = ae; var am = this as AnonymousMethodBody; if (ec.HasSet (ResolveContext.Options.InferReturnType) && am != null) { am.ReturnTypeInference = new TypeInferenceContext (); } var bc = ec as BlockContext; if (bc != null) { aec.AssignmentInfoOffset = bc.AssignmentInfoOffset; aec.EnclosingLoop = bc.EnclosingLoop; aec.EnclosingLoopOrSwitch = bc.EnclosingLoopOrSwitch; aec.Switch = bc.Switch; } var errors = ec.Report.Errors; bool res = Block.Resolve (aec); if (res && errors == ec.Report.Errors) { MarkReachable (new Reachability ()); if (!CheckReachableExit (ec.Report)) { return null; } if (bc != null) bc.AssignmentInfoOffset = aec.AssignmentInfoOffset; } if (am != null && am.ReturnTypeInference != null) { am.ReturnTypeInference.FixAllTypes (ec); ReturnType = am.ReturnTypeInference.InferredTypeArguments [0]; am.ReturnTypeInference = null; // // If e is synchronous the inferred return type is T // If e is asynchronous and the body of F is either an expression classified as nothing // or a statement block where no return statements have expressions, the inferred return type is Task // If e is async and has an inferred result type T, the inferred return type is Task<T> // if (block.IsAsync && ReturnType != null) { ReturnType = ReturnType.Kind == MemberKind.Void ? ec.Module.PredefinedTypes.Task.TypeSpec : ec.Module.PredefinedTypes.TaskGeneric.TypeSpec.MakeGenericType (ec, new [] { ReturnType }); } } if (res && errors != ec.Report.Errors) return null; if (block.IsAsync && block.Original.ParametersBlock.HasCapturedThis && ec.CurrentAnonymousMethod != null && ec.CurrentAnonymousMethod.block.IsAsync) { // // We'll do ldftn to load the fabricated m_X method but // because we are inside struct the method can be hoisted // anywhere in the parent scope // ec.CurrentBlock.ParametersBlock.HasReferenceToStoreyForInstanceLambdas = true; } return res ? this : null; }