本文整理汇总了C#中Mono.CSharp.LocalVariableReference.ResolveLValue方法的典型用法代码示例。如果您正苦于以下问题:C# LocalVariableReference.ResolveLValue方法的具体用法?C# LocalVariableReference.ResolveLValue怎么用?C# LocalVariableReference.ResolveLValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mono.CSharp.LocalVariableReference
的用法示例。
在下文中一共展示了LocalVariableReference.ResolveLValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoSimpleNameResolve
/// <remarks>
/// 7.5.2: Simple Names.
///
/// Local Variables and Parameters are handled at
/// parse time, so they never occur as SimpleNames.
///
/// The `intermediate' flag is used by MemberAccess only
/// and it is used to inform us that it is ok for us to
/// avoid the static check, because MemberAccess might end
/// up resolving the Name as a Type name and the access as
/// a static type access.
///
/// ie: Type Type; .... { Type.GetType (""); }
///
/// Type is both an instance variable and a Type; Type.GetType
/// is the static method not an instance method of type.
/// </remarks>
Expression DoSimpleNameResolve(ResolveContext ec, Expression right_side, bool intermediate)
{
Expression e = null;
//
// Stage 1: Performed by the parser (binding to locals or parameters).
//
Block current_block = ec.CurrentBlock;
if (current_block != null){
LocalInfo vi = current_block.GetLocalInfo (Name);
if (vi != null){
e = new LocalVariableReference (ec.CurrentBlock, Name, loc);
if (right_side != null) {
e = e.ResolveLValue (ec, right_side);
} else {
if (intermediate) {
using (ec.With (ResolveContext.Options.DoFlowAnalysis, false)) {
e = e.Resolve (ec, ResolveFlags.VariableOrValue);
}
} else {
e = e.Resolve (ec, ResolveFlags.VariableOrValue);
}
}
if (HasTypeArguments && e != null)
e.Error_TypeArgumentsCannotBeUsed (ec.Report, loc, null, 0);
return e;
}
e = current_block.Toplevel.GetParameterReference (Name, loc);
if (e != null) {
if (right_side != null)
e = e.ResolveLValue (ec, right_side);
else
e = e.Resolve (ec);
if (HasTypeArguments && e != null)
e.Error_TypeArgumentsCannotBeUsed (ec.Report, loc, null, 0);
return e;
}
}
//
// Stage 2: Lookup members
//
int arity = HasTypeArguments ? Arity : -1;
// TypeSpec almost_matched_type = null;
// IList<MemberSpec> almost_matched = null;
for (TypeSpec lookup_ds = ec.CurrentType; lookup_ds != null; lookup_ds = lookup_ds.DeclaringType) {
e = MemberLookup (ec.Compiler, ec.CurrentType, lookup_ds, Name, arity, BindingRestriction.NoOverrides, loc);
if (e != null) {
PropertyExpr pe = e as PropertyExpr;
if (pe != null) {
// since TypeManager.MemberLookup doesn't know if we're doing a lvalue access or not,
// it doesn't know which accessor to check permissions against
if (pe.PropertyInfo.Kind == MemberKind.Property && pe.IsAccessibleFrom (ec.CurrentType, right_side != null))
break;
} else if (e is EventExpr) {
if (((EventExpr) e).IsAccessibleFrom (ec.CurrentType))
break;
} else if (HasTypeArguments && e is TypeExpression) {
e = new GenericTypeExpr (e.Type, targs, loc).ResolveAsTypeStep (ec, false);
break;
} else {
break;
}
e = null;
}
/*
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = lookup_ds;
almost_matched = new List<MemberSpec>(almost_matched_members);
}
*/
}
if (e == null) {
/*
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = ec.CurrentType;
//.........这里部分代码省略.........
示例2: DoSimpleNameResolve
/// <remarks>
/// 7.5.2: Simple Names.
///
/// Local Variables and Parameters are handled at
/// parse time, so they never occur as SimpleNames.
///
/// The `intermediate' flag is used by MemberAccess only
/// and it is used to inform us that it is ok for us to
/// avoid the static check, because MemberAccess might end
/// up resolving the Name as a Type name and the access as
/// a static type access.
///
/// ie: Type Type; .... { Type.GetType (""); }
///
/// Type is both an instance variable and a Type; Type.GetType
/// is the static method not an instance method of type.
/// </remarks>
Expression DoSimpleNameResolve (EmitContext ec, Expression right_side, bool intermediate)
{
Expression e = null;
//
// Stage 1: Performed by the parser (binding to locals or parameters).
//
Block current_block = ec.CurrentBlock;
if (current_block != null){
LocalInfo vi = current_block.GetLocalInfo (Name);
if (vi != null){
LocalVariableReference var = new LocalVariableReference (ec.CurrentBlock, Name, loc);
if (right_side != null) {
return var.ResolveLValue (ec, right_side, loc);
} else {
ResolveFlags rf = ResolveFlags.VariableOrValue;
if (intermediate)
rf |= ResolveFlags.DisableFlowAnalysis;
return var.Resolve (ec, rf);
}
}
Expression expr = current_block.Toplevel.GetParameterReference (Name, loc);
if (expr != null) {
if (right_side != null)
return expr.ResolveLValue (ec, right_side, loc);
return expr.Resolve (ec);
}
}
//
// Stage 2: Lookup members
//
Type almost_matched_type = null;
ArrayList almost_matched = null;
for (DeclSpace lookup_ds = ec.DeclContainer; lookup_ds != null; lookup_ds = lookup_ds.Parent) {
// either RootDeclSpace or GenericMethod
if (lookup_ds.TypeBuilder == null)
continue;
e = MemberLookup (ec.ContainerType, lookup_ds.TypeBuilder, Name, loc);
if (e != null) {
PropertyExpr pe = e as PropertyExpr;
if (pe != null) {
AParametersCollection param = TypeManager.GetParameterData (pe.PropertyInfo);
// since TypeManager.MemberLookup doesn't know if we're doing a lvalue access or not,
// it doesn't know which accessor to check permissions against
if (param.IsEmpty && pe.IsAccessibleFrom (ec.ContainerType, right_side != null))
break;
} else if (e is EventExpr) {
if (((EventExpr) e).IsAccessibleFrom (ec.ContainerType))
break;
} else if (targs != null && e is TypeExpression) {
e = new GenericTypeExpr (e.Type, targs, loc).ResolveAsTypeStep (ec, false);
break;
} else {
break;
}
e = null;
}
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = lookup_ds.TypeBuilder;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
}
if (e == null) {
if (almost_matched == null && almost_matched_members.Count > 0) {
almost_matched_type = ec.ContainerType;
almost_matched = (ArrayList) almost_matched_members.Clone ();
}
e = ResolveAsTypeStep (ec, true);
}
if (e == null) {
if (current_block != null) {
IKnownVariable ikv = current_block.Explicit.GetKnownVariable (Name);
if (ikv != null) {
LocalInfo li = ikv as LocalInfo;
//.........这里部分代码省略.........