本文整理汇总了C#中Mono.CSharp.Statement.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# Statement.Resolve方法的具体用法?C# Statement.Resolve怎么用?C# Statement.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.Statement
的用法示例。
在下文中一共展示了Statement.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveInitializer
protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer)
{
if (li.Type == InternalType.Dynamic) {
initializer = initializer.Resolve (bc);
if (initializer == null)
return null;
// Once there is dynamic used defer conversion to runtime even if we know it will never succeed
Arguments args = new Arguments (1);
args.Add (new Argument (initializer));
initializer = new DynamicConversion (TypeManager.idisposable_type, 0, args, initializer.Location).Resolve (bc);
if (initializer == null)
return null;
var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
dispose_call = CreateDisposeCall (bc, var);
dispose_call.Resolve (bc);
return base.ResolveInitializer (bc, li, new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc));
}
if (li == Variable) {
CheckIDiposableConversion (bc, li, initializer);
dispose_call = CreateDisposeCall (bc, li);
dispose_call.Resolve (bc);
}
return base.ResolveInitializer (bc, li, initializer);
}
示例2: ResolveInitializer
protected override Expression ResolveInitializer (BlockContext bc, LocalVariable li, Expression initializer)
{
Assign assign;
if (li.Type == InternalType.Dynamic) {
initializer = initializer.Resolve (bc);
if (initializer == null)
return null;
initializer = Convert.ImplicitConversionRequired (bc, initializer, TypeManager.idisposable_type, loc);
if (initializer == null)
return null;
var var = LocalVariable.CreateCompilerGenerated (TypeManager.idisposable_type, bc.CurrentBlock, loc);
assign = new SimpleAssign (var.CreateReferenceExpression (bc, loc), initializer, loc);
assign.ResolveStatement (bc);
dispose_call = CreateDisposeCall (bc, var);
dispose_call.Resolve (bc);
return assign;
}
if (li == Variable) {
CheckIDiposableConversion (bc, li, initializer);
dispose_call = CreateDisposeCall (bc, li);
dispose_call.Resolve (bc);
}
return base.ResolveInitializer (bc, li, initializer);
}
示例3: Resolve
public override bool Resolve (EmitContext ec)
{
enumerator_type = TypeManager.ienumerator_type;
if (!ProbeCollectionType (ec, expr.Type)) {
Error_Enumerator ();
return false;
}
bool is_disposable = !enumerator_type.IsSealed ||
TypeManager.ImplementsInterface (enumerator_type, TypeManager.idisposable_type);
VarExpr ve = var_type as VarExpr;
if (ve != null) {
// Infer implicitly typed local variable from foreach enumerable type
var_type = new TypeExpression (get_current.PropertyInfo.PropertyType, var_type.Location);
}
var_type = var_type.ResolveAsTypeTerminal (ec, false);
if (var_type == null)
return false;
enumerator = new TemporaryVariable (enumerator_type, loc);
enumerator.Resolve (ec);
init = new Invocation (get_enumerator, null);
init = init.Resolve (ec);
if (init == null)
return false;
Expression move_next_expr;
{
MemberInfo[] mi = new MemberInfo[] { move_next };
MethodGroupExpr mg = new MethodGroupExpr (mi, var_type.Type, loc);
mg.InstanceExpression = enumerator;
move_next_expr = new Invocation (mg, null);
}
get_current.InstanceExpression = enumerator;
Statement block = new CollectionForeachStatement (
var_type.Type, variable, get_current, statement, loc);
loop = new While (move_next_expr, block, loc);
wrapper = is_disposable ?
(Statement) new DisposableWrapper (this) :
(Statement) new NonDisposableWrapper (this);
return wrapper.Resolve (ec);
}