本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.EXPR.asFIELD方法的典型用法代码示例。如果您正苦于以下问题:C# EXPR.asFIELD方法的具体用法?C# EXPR.asFIELD怎么用?C# EXPR.asFIELD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.EXPR
的用法示例。
在下文中一共展示了EXPR.asFIELD方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: markFieldAssigned
////////////////////////////////////////////////////////////////////////////////
// Sets the isAssigned bit
protected void markFieldAssigned(EXPR expr)
{
if (expr.isFIELD() && 0 != (expr.flags & EXPRFLAG.EXF_LVALUE))
{
EXPRFIELD field;
do
{
field = expr.asFIELD();
field.fwt.Field().isAssigned = true;
expr = field.GetOptionalObject();
}
while (field.fwt.Field().getClass().IsStruct() && !field.fwt.Field().isStatic && expr != null && expr.isFIELD());
}
}
示例2: AdjustMemberObject
private EXPR AdjustMemberObject(SymWithType swt, EXPR pObject, out bool pfConstrained, out bool pIsMatchingStatic)
{
// Assert that the type is present and is an instantiation of the member's parent.
Debug.Assert(swt.GetType() != null && swt.GetType().getAggregate() == swt.Sym.parent.AsAggregateSymbol());
bool bIsMatchingStatic = IsMatchingStatic(swt, pObject);
pIsMatchingStatic = bIsMatchingStatic;
pfConstrained = false;
bool isStatic = swt.Sym.isStatic;
// If our static doesn't match, bail out of here.
if (!bIsMatchingStatic)
{
if (isStatic)
{
// If we have a mismatched static, a static method, and the binding flag
// that tells us we're binding simple names, then insert a type here instead.
if ((pObject.flags & EXPRFLAG.EXF_SIMPLENAME) != 0)
{
// We've made the static match now.
pIsMatchingStatic = true;
return null;
}
else
{
ErrorContext.ErrorRef(ErrorCode.ERR_ObjectProhibited, swt);
return null;
}
}
else
{
ErrorContext.ErrorRef(ErrorCode.ERR_ObjectRequired, swt);
return pObject;
}
}
// At this point, all errors for static invocations have been reported, and
// the object has been nulled out. So return out of here.
if (isStatic)
{
return null;
}
// If we're in a constructor, then bail.
if (swt.Sym.IsMethodSymbol() && swt.Meth().IsConstructor())
{
return pObject;
}
if (pObject == null)
{
if (InFieldInitializer() && !InStaticMethod() && ContainingAgg() == swt.Sym.parent)
{
ErrorContext.ErrorRef(ErrorCode.ERR_FieldInitRefNonstatic, swt); // give better error message for common mistake <BUGNUM>See VS7:119218</BUGNUM>
}
else if (InAnonymousMethod() && !InStaticMethod() && ContainingAgg() == swt.Sym.parent && ContainingAgg().IsStruct())
{
ErrorContext.Error(ErrorCode.ERR_ThisStructNotInAnonMeth);
}
else
{
return null;
}
// For fields or structs, make a this pointer for us to use.
EXPRTHISPOINTER thisExpr = GetExprFactory().CreateThis(Context.GetThisPointer(), true);
thisExpr.SetMismatchedStaticBit();
if (thisExpr.type == null)
{
thisExpr.setType(GetTypes().GetErrorSym());
}
return thisExpr;
}
CType typeObj = pObject.type;
CType typeTmp;
if (typeObj.IsNullableType() && (typeTmp = typeObj.AsNullableType().GetAts(GetErrorContext())) != null && typeTmp != swt.GetType())
{
typeObj = typeTmp;
}
if (typeObj.IsTypeParameterType() || typeObj.IsAggregateType())
{
AggregateSymbol aggCalled = null;
aggCalled = swt.Sym.parent.AsAggregateSymbol();
Debug.Assert(swt.GetType().getAggregate() == aggCalled);
// If we're invoking code on a struct-valued field, mark the struct as assigned (to
// avoid warning CS0649).
if (pObject.isFIELD() && !pObject.asFIELD().fwt.Field().isAssigned && !swt.Sym.IsFieldSymbol() &&
typeObj.isStructType() && !typeObj.isPredefined())
{
pObject.asFIELD().fwt.Field().isAssigned = true;
}
if (pfConstrained &&
(typeObj.IsTypeParameterType() ||
typeObj.isStructType() && swt.GetType().IsRefType() && swt.Sym.IsVirtual()))
//.........这里部分代码省略.........