本文整理汇总了C#中TemporaryVariableReference.Resolve方法的典型用法代码示例。如果您正苦于以下问题:C# TemporaryVariableReference.Resolve方法的具体用法?C# TemporaryVariableReference.Resolve怎么用?C# TemporaryVariableReference.Resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TemporaryVariableReference
的用法示例。
在下文中一共展示了TemporaryVariableReference.Resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateExpressionTreeVariable
public ExpressionStatement CreateExpressionTreeVariable (BlockContext ec)
{
if ((modFlags & Modifier.RefOutMask) != 0)
ec.Report.Error (1951, Location, "An expression tree parameter cannot use `ref' or `out' modifier");
expr_tree_variable = TemporaryVariableReference.Create (ResolveParameterExpressionType (ec, Location).Type, ec.CurrentBlock.ParametersBlock, Location);
expr_tree_variable = (TemporaryVariableReference) expr_tree_variable.Resolve (ec);
Arguments arguments = new Arguments (2);
arguments.Add (new Argument (new TypeOf (parameter_type, Location)));
arguments.Add (new Argument (new StringConstant (ec.BuiltinTypes, Name, Location)));
return new SimpleAssign (ExpressionTreeVariableReference (),
Expression.CreateExpressionFactoryCall (ec, "Parameter", null, arguments, Location));
}
示例2: Resolve
public override bool Resolve (BlockContext ec)
{
bool is_dynamic = expr.Type == InternalType.Dynamic;
if (is_dynamic) {
expr = Convert.ImplicitConversionRequired (ec, expr, TypeManager.ienumerable_type, loc);
} else if (TypeManager.IsNullableType (expr.Type)) {
expr = new Nullable.UnwrapCall (expr).Resolve (ec);
}
var get_enumerator_mg = ResolveGetEnumerator (ec);
if (get_enumerator_mg == null) {
return false;
}
var get_enumerator = get_enumerator_mg.BestCandidate;
enumerator_variable = TemporaryVariableReference.Create (get_enumerator.ReturnType, variable.Block, loc);
enumerator_variable.Resolve (ec);
// Prepare bool MoveNext ()
var move_next_mg = ResolveMoveNext (ec, get_enumerator);
if (move_next_mg == null) {
return false;
}
move_next_mg.InstanceExpression = enumerator_variable;
// Prepare ~T~ Current { get; }
var current_prop = ResolveCurrent (ec, get_enumerator);
if (current_prop == null) {
return false;
}
var current_pe = new PropertyExpr (current_prop, loc) { InstanceExpression = enumerator_variable }.Resolve (ec);
if (current_pe == null)
return false;
VarExpr ve = var_type as VarExpr;
if (ve != null) {
if (is_dynamic) {
// Source type is dynamic, set element type to dynamic too
var_type = new TypeExpression (InternalType.Dynamic, var_type.Location);
} else {
// Infer implicitly typed local variable from foreach enumerable type
var_type = new TypeExpression (current_pe.Type, var_type.Location);
}
} else if (is_dynamic) {
// Explicit cast of dynamic collection elements has to be done at runtime
current_pe = EmptyCast.Create (current_pe, InternalType.Dynamic);
}
var_type = var_type.ResolveAsTypeTerminal (ec, false);
if (var_type == null)
return false;
variable.Type = var_type.Type;
var init = new Invocation (get_enumerator_mg, null);
statement = new While (new BooleanExpression (new Invocation (move_next_mg, null)),
new Body (var_type.Type, variable, current_pe, statement, loc), loc);
var enum_type = enumerator_variable.Type;
//
// Add Dispose method call when enumerator can be IDisposable
//
if (!enum_type.ImplementsInterface (TypeManager.idisposable_type, false)) {
if (!enum_type.IsSealed && !TypeManager.IsValueType (enum_type)) {
//
// Runtime Dispose check
//
var vd = new RuntimeDispose (enumerator_variable.LocalInfo, loc);
vd.Initializer = init;
statement = new Using (vd, statement, loc);
} else {
//
// No Dispose call needed
//
this.init = new SimpleAssign (enumerator_variable, init);
this.init.Resolve (ec);
}
} else {
//
// Static Dispose check
//
var vd = new Using.VariableDeclaration (enumerator_variable.LocalInfo, loc);
vd.Initializer = init;
statement = new Using (vd, statement, loc);
}
return statement.Resolve (ec);
}
示例3: Resolve
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
if (expr == null)
return false;
if (!TypeManager.IsReferenceType (expr.Type)){
ec.Report.Error (185, loc,
"`{0}' is not a reference type as required by the lock statement",
expr.Type.GetSignatureForError ());
}
if (expr.Type.IsGenericParameter) {
expr = Convert.ImplicitTypeParameterConversion (expr, TypeManager.object_type);
}
VariableReference lv = expr as VariableReference;
bool locked;
if (lv != null) {
locked = lv.IsLockedByStatement;
lv.IsLockedByStatement = true;
} else {
lv = null;
locked = false;
}
ec.StartFlowBranching (this);
Statement.Resolve (ec);
ec.EndFlowBranching ();
if (lv != null) {
lv.IsLockedByStatement = locked;
}
base.Resolve (ec);
//
// Have to keep original lock value around to unlock same location
// in the case the original has changed or is null
//
expr_copy = TemporaryVariableReference.Create (TypeManager.object_type, ec.CurrentBlock.Parent, loc);
expr_copy.Resolve (ec);
//
// Ensure Monitor methods are available
//
if (ResolvePredefinedMethods (ec) > 1) {
lock_taken = TemporaryVariableReference.Create (TypeManager.bool_type, ec.CurrentBlock.Parent, loc);
lock_taken.Resolve (ec);
}
return true;
}