本文整理汇总了C#中Mono.CSharp.AnonymousExpression类的典型用法代码示例。如果您正苦于以下问题:C# AnonymousExpression类的具体用法?C# AnonymousExpression怎么用?C# AnonymousExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnonymousExpression类属于Mono.CSharp命名空间,在下文中一共展示了AnonymousExpression类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Compatible
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;
}
示例2: Compatible
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;
}
示例3: AnonymousMethodMethod
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);
}
示例4: Compatible
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;
}
示例5: Compatible
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;
}
示例6: AnonymousMethodMethod
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);
}
示例7: Compatible
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;
}
示例8: Compatible
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;
}
示例9: GetHoistedVariable
public override HoistedVariable GetHoistedVariable(AnonymousExpression ae)
{
return li.HoistedVariant;
}
示例10: GetHoistedVariable
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;
}
示例11: Compatible
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;
}