本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.EXPR类的典型用法代码示例。如果您正苦于以下问题:C# EXPR类的具体用法?C# EXPR怎么用?C# EXPR使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EXPR类属于Microsoft.CSharp.RuntimeBinder.Semantics命名空间,在下文中一共展示了EXPR类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StripNullableConstructor
public static EXPR StripNullableConstructor(EXPR pExpr)
{
while (IsNullableConstructor(pExpr))
{
Debug.Assert(pExpr.isCALL());
pExpr = pExpr.asCALL().GetOptionalArguments();
Debug.Assert(pExpr != null && !pExpr.isLIST());
}
return pExpr;
}
示例2: Dispatch
protected override EXPR Dispatch(EXPR expr)
{
Debug.Assert(expr != null);
EXPR result = base.Dispatch(expr);
if (result == expr)
{
throw Error.InternalCompilerError();
}
return result;
}
示例3: ImplicitConversion
public ImplicitConversion(ExpressionBinder binder, EXPR exprSrc, CType typeSrc, EXPRTYPEORNAMESPACE typeDest, bool needsExprDest, CONVERTTYPE flags)
{
_binder = binder;
_exprSrc = exprSrc;
_typeSrc = typeSrc;
_typeDest = typeDest.TypeOrNamespace.AsType();
_exprTypeDest = typeDest;
_needsExprDest = needsExprDest;
_flags = flags;
_exprDest = null;
}
示例4: CreateFunctionPointer
public EXPRFUNCPTR CreateFunctionPointer(EXPRFLAG nFlags, CType pType, EXPR pObject, MethWithInst MWI)
{
Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_BASECALL)));
EXPRFUNCPTR rval = new EXPRFUNCPTR();
rval.kind = ExpressionKind.EK_FUNCPTR;
rval.type = pType;
rval.flags = nFlags;
rval.OptionalObject = pObject;
rval.mwi = new MethWithInst(MWI);
Debug.Assert(rval != null);
return (rval);
}
示例5: ExplicitConversion
// ----------------------------------------------------------------------------
// BindExplicitConversion
// ----------------------------------------------------------------------------
public ExplicitConversion(ExpressionBinder binder, EXPR exprSrc, CType typeSrc, EXPRTYPEORNAMESPACE typeDest, CType pDestinationTypeForLambdaErrorReporting, bool needsExprDest, CONVERTTYPE flags)
{
_binder = binder;
_exprSrc = exprSrc;
_typeSrc = typeSrc;
_typeDest = typeDest.TypeOrNamespace.AsType();
_pDestinationTypeForLambdaErrorReporting = pDestinationTypeForLambdaErrorReporting;
_exprTypeDest = typeDest;
_needsExprDest = needsExprDest;
_flags = flags;
_exprDest = null;
}
示例6: CreateField
public EXPRFIELD CreateField(EXPRFLAG nFlags, CType pType, EXPR pOptionalObject, uint nOffset, FieldWithType FWT, EXPR pOptionalLHS)
{
Debug.Assert(0 == (nFlags & ~(EXPRFLAG.EXF_MEMBERSET | EXPRFLAG.EXF_MASK_ANY)));
EXPRFIELD rval = new EXPRFIELD();
rval.kind = ExpressionKind.EK_FIELD;
rval.type = pType;
rval.flags = nFlags;
rval.SetOptionalObject(pOptionalObject);
if (FWT != null)
{
rval.fwt = FWT;
}
Debug.Assert(rval != null);
return (rval);
}
示例7: BinOpArgInfo
public BinOpArgInfo(EXPR op1, EXPR op2)
{
Debug.Assert(op1 != null);
Debug.Assert(op2 != null);
arg1 = op1;
arg2 = op2;
type1 = arg1.type;
type2 = arg2.type;
typeRaw1 = type1.StripNubs();
typeRaw2 = type2.StripNubs();
pt1 = type1.isPredefined() ? type1.getPredefType() : PredefinedType.PT_COUNT;
pt2 = type2.isPredefined() ? type2.getPredefType() : PredefinedType.PT_COUNT;
ptRaw1 = typeRaw1.isPredefined() ? typeRaw1.getPredefType() : PredefinedType.PT_COUNT;
ptRaw2 = typeRaw2.isPredefined() ? typeRaw2.getPredefType() : PredefinedType.PT_COUNT;
}
示例8: Visit
public EXPR Visit(EXPR pExpr)
{
if (pExpr == null)
{
return null;
}
EXPR pResult;
if (IsCachedExpr(pExpr, out pResult))
{
return pResult;
}
if (pExpr.isSTMT())
{
return CacheExprMapping(pExpr, DispatchStatementList(pExpr.asSTMT()));
}
return CacheExprMapping(pExpr, Dispatch(pExpr));
}
示例9: BindValue
// Value
public EXPR BindValue(EXPR exprSrc)
{
Debug.Assert(exprSrc != null && exprSrc.type.IsNullableType());
// For new T?(x), the answer is x.
if (CNullable.IsNullableConstructor(exprSrc))
{
Debug.Assert(exprSrc.asCALL().GetOptionalArguments() != null && !exprSrc.asCALL().GetOptionalArguments().isLIST());
return exprSrc.asCALL().GetOptionalArguments();
}
CType typeBase = exprSrc.type.AsNullableType().GetUnderlyingType();
AggregateType ats = exprSrc.type.AsNullableType().GetAts(GetErrorContext());
if (ats == null)
{
EXPRPROP rval = GetExprFactory().CreateProperty(typeBase, exprSrc);
rval.SetError();
return rval;
}
PropertySymbol prop = GetSymbolLoader().getBSymmgr().propNubValue;
if (prop == null)
{
prop = GetSymbolLoader().getPredefinedMembers().GetProperty(PREDEFPROP.PP_G_OPTIONAL_VALUE);
GetSymbolLoader().getBSymmgr().propNubValue = prop;
}
PropWithType pwt = new PropWithType(prop, ats);
MethWithType mwt = new MethWithType(prop != null ? prop.methGet : null, ats);
MethPropWithInst mpwi = new MethPropWithInst(prop, ats);
EXPRMEMGRP pMemGroup = GetExprFactory().CreateMemGroup(exprSrc, mpwi);
EXPRPROP exprRes = GetExprFactory().CreateProperty(typeBase, null, null, pMemGroup, pwt, mwt, null);
if (prop == null)
{
exprRes.SetError();
}
return exprRes;
}
示例10: IsNullableConstructor
public static bool IsNullableConstructor(EXPR expr)
{
Debug.Assert(expr != null);
if (!expr.isCALL())
{
return false;
}
EXPRCALL pCall = expr.asCALL();
if (pCall.GetMemberGroup().GetOptionalObject() != null)
{
return false;
}
MethodSymbol meth = pCall.mwi.Meth();
if (meth == null)
{
return false;
}
return meth.IsNullableConstructor();
}
示例11: CreateCall
public EXPRCALL CreateCall(EXPRFLAG nFlags, CType pType, EXPR pOptionalArguments, EXPRMEMGRP pMemberGroup, MethWithInst MWI)
{
Debug.Assert(0 == (nFlags &
~(
EXPRFLAG.EXF_NEWOBJCALL | EXPRFLAG.EXF_CONSTRAINED | EXPRFLAG.EXF_BASECALL |
EXPRFLAG.EXF_NEWSTRUCTASSG |
EXPRFLAG.EXF_IMPLICITSTRUCTASSG | EXPRFLAG.EXF_MASK_ANY
)
));
EXPRCALL rval = new EXPRCALL();
rval.kind = ExpressionKind.EK_CALL;
rval.type = pType;
rval.flags = nFlags;
rval.SetOptionalArguments(pOptionalArguments);
rval.SetMemberGroup(pMemberGroup);
rval.nubLiftKind = NullableCallLiftKind.NotLifted;
rval.castOfNonLiftedResultToLiftedType = null;
rval.mwi = MWI;
Debug.Assert(rval != null);
return (rval);
}
示例12: Rewrite
/////////////////////////////////////////////////////////////////////////////////
public static Expression Rewrite(TypeManager typeManager, EXPR pExpr, IEnumerable<Expression> listOfParameters)
{
ExpressionTreeCallRewriter rewriter = new ExpressionTreeCallRewriter(typeManager, listOfParameters);
// We should have a EXPRBINOP thats an EK_SEQUENCE. The RHS of our sequence
// should be a call to PM_EXPRESSION_LAMBDA. The LHS of our sequence is the
// set of declarations for the parameters that we'll need.
// Assert all of these first, and then unwrap them.
Debug.Assert(pExpr != null);
Debug.Assert(pExpr.isBIN());
Debug.Assert(pExpr.kind == ExpressionKind.EK_SEQUENCE);
Debug.Assert(pExpr.asBIN().GetOptionalRightChild() != null);
Debug.Assert(pExpr.asBIN().GetOptionalRightChild().isCALL());
Debug.Assert(pExpr.asBIN().GetOptionalRightChild().asCALL().PredefinedMethod == PREDEFMETH.PM_EXPRESSION_LAMBDA);
Debug.Assert(pExpr.asBIN().GetOptionalLeftChild() != null);
// Visit the left to generate the parameter construction.
rewriter.Visit(pExpr.asBIN().GetOptionalLeftChild());
EXPRCALL call = pExpr.asBIN().GetOptionalRightChild().asCALL();
ExpressionEXPR e = rewriter.Visit(call) as ExpressionEXPR;
return e.Expression;
}
示例13: IsDelegateConstructorCall
protected bool IsDelegateConstructorCall(EXPR pExpr)
{
Debug.Assert(pExpr != null);
if (!pExpr.isCALL())
{
return false;
}
EXPRCALL pCall = pExpr.asCALL();
return pCall.mwi.Meth() != null &&
pCall.mwi.Meth().IsConstructor() &&
pCall.type.isDelegateType() &&
pCall.GetOptionalArguments() != null &&
pCall.GetOptionalArguments().isLIST() &&
pCall.GetOptionalArguments().asLIST().GetOptionalNextListNode().kind == ExpressionKind.EK_FUNCPTR;
}
示例14: IsNullableValueAccess
protected bool IsNullableValueAccess(EXPR pExpr, EXPR pObject)
{
Debug.Assert(pExpr != null);
return pExpr.isPROP() && (pExpr.asPROP().GetMemberGroup().GetOptionalObject() == pObject) && pObject.type.IsNullableType();
}
示例15: FixLiftedUserDefinedBinaryOperators
protected void FixLiftedUserDefinedBinaryOperators(EXPRBINOP expr, ref EXPR pp1, ref EXPR pp2)
{
// If we have lifted T1 op T2 to T1? op T2?, and we have an expression T1 op T2? or T1? op T2 then
// we need to ensure that the unlifted actual arguments are promoted to their nullable CType.
Debug.Assert(expr != null);
Debug.Assert(pp1 != null);
Debug.Assert(pp1 != null);
Debug.Assert(pp2 != null);
Debug.Assert(pp2 != null);
MethodSymbol method = expr.GetUserDefinedCallMethod().Meth();
EXPR orig1 = expr.GetOptionalLeftChild();
EXPR orig2 = expr.GetOptionalRightChild();
Debug.Assert(orig1 != null && orig2 != null);
EXPR new1 = pp1;
EXPR new2 = pp2;
CType fptype1 = method.Params.Item(0);
CType fptype2 = method.Params.Item(1);
CType aatype1 = orig1.type;
CType aatype2 = orig2.type;
// Is the operator even a candidate for lifting?
if (fptype1.IsNullableType() || fptype2.IsNullableType() ||
!fptype1.IsAggregateType() || !fptype2.IsAggregateType() ||
!fptype1.AsAggregateType().getAggregate().IsValueType() ||
!fptype2.AsAggregateType().getAggregate().IsValueType())
{
return;
}
CType nubfptype1 = GetSymbolLoader().GetTypeManager().GetNullable(fptype1);
CType nubfptype2 = GetSymbolLoader().GetTypeManager().GetNullable(fptype2);
// If we have null op X, or T1 op T2?, or T1 op null, lift first arg to T1?
if (aatype1.IsNullType() || aatype1 == fptype1 && (aatype2 == nubfptype2 || aatype2.IsNullType()))
{
new1 = GenerateCall(PREDEFMETH.PM_EXPRESSION_CONVERT, new1, CreateTypeOf(nubfptype1));
}
// If we have X op null, or T1? op T2, or null op T2, lift second arg to T2?
if (aatype2.IsNullType() || aatype2 == fptype2 && (aatype1 == nubfptype1 || aatype1.IsNullType()))
{
new2 = GenerateCall(PREDEFMETH.PM_EXPRESSION_CONVERT, new2, CreateTypeOf(nubfptype2));
}
pp1 = new1;
pp2 = new2;
}