本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.EXPR.Map方法的典型用法代码示例。如果您正苦于以下问题:C# EXPR.Map方法的具体用法?C# EXPR.Map怎么用?C# EXPR.Map使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.CSharp.RuntimeBinder.Semantics.EXPR
的用法示例。
在下文中一共展示了EXPR.Map方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindArrayIndexCore
internal EXPR BindArrayIndexCore(BindingFlag bindFlags, EXPR pOp1, EXPR pOp2)
{
EXPR pExpr;
bool bIsError = false;
if (!pOp1.isOK() || !pOp2.isOK())
{
bIsError = true;
}
CType pIntType = GetReqPDT(PredefinedType.PT_INT);
// Array indexing must occur on an array type.
if (!pOp1.type.IsArrayType())
{
Debug.Assert(!pOp1.type.IsPointerType());
pExpr = bindIndexer(pOp1, pOp2, bindFlags);
if (bIsError)
{
pExpr.SetError();
}
return pExpr;
}
ArrayType pArrayType = pOp1.type.AsArrayType();
checkUnsafe(pArrayType.GetElementType()); // added to the binder so we don't bind to pointer ops
// Check the rank of the array against the number of indices provided, and
// convert the indexes to ints
CType pDestType = chooseArrayIndexType(pOp2);
if (null == pDestType)
{
// using int as the type will allow us to give a better error...
pDestType = pIntType;
}
int rank = pArrayType.rank;
int cIndices = 0;
EXPR transformedIndices = pOp2.Map(GetExprFactory(),
(EXPR x) =>
{
cIndices++;
EXPR pTemp = mustConvert(x, pDestType);
if (pDestType == pIntType)
return pTemp;
#if CSEE
EXPRFLAG flag = 0;
#else
EXPRFLAG flag = EXPRFLAG.EXF_INDEXEXPR;
#endif
EXPRCLASS exprType = GetExprFactory().MakeClass(pDestType);
return GetExprFactory().CreateCast(flag, exprType, pTemp);
});
if (cIndices != rank)
{
ErrorContext.Error(ErrorCode.ERR_BadIndexCount, rank);
pExpr = GetExprFactory().CreateArrayIndex(pOp1, transformedIndices);
pExpr.SetError();
return pExpr;
}
// Allocate a new expression, the type is the element type of the array.
// Array index operations are always lvalues.
pExpr = GetExprFactory().CreateArrayIndex(pOp1, transformedIndices);
pExpr.flags |= EXPRFLAG.EXF_LVALUE | EXPRFLAG.EXF_ASSGOP;
if (bIsError)
{
pExpr.SetError();
}
return pExpr;
}