本文整理汇总了C#中Microsoft.CSharp.RuntimeBinder.Semantics.CType类的典型用法代码示例。如果您正苦于以下问题:C# CType类的具体用法?C# CType怎么用?C# CType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CType类属于Microsoft.CSharp.RuntimeBinder.Semantics命名空间,在下文中一共展示了CType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CheckAccess2
public virtual ACCESSERROR CheckAccess2(Symbol symCheck, AggregateType atsCheck, Symbol symWhere, CType typeThru)
{
Debug.Assert(symCheck != null);
Debug.Assert(atsCheck == null || symCheck.parent == atsCheck.getAggregate());
Debug.Assert(typeThru == null ||
typeThru.IsAggregateType() ||
typeThru.IsTypeParameterType() ||
typeThru.IsArrayType() ||
typeThru.IsNullableType() ||
typeThru.IsErrorType());
#if DEBUG
switch (symCheck.getKind())
{
default:
break;
case SYMKIND.SK_MethodSymbol:
case SYMKIND.SK_PropertySymbol:
case SYMKIND.SK_FieldSymbol:
case SYMKIND.SK_EventSymbol:
Debug.Assert(atsCheck != null);
break;
}
#endif // DEBUG
ACCESSERROR error = CheckAccessCore(symCheck, atsCheck, symWhere, typeThru);
if (ACCESSERROR.ACCESSERROR_NOERROR != error)
{
return error;
}
// Check the accessibility of the return CType.
CType CType = symCheck.getType();
if (CType == null)
{
return ACCESSERROR.ACCESSERROR_NOERROR;
}
// For members of AGGSYMs, atsCheck should always be specified!
Debug.Assert(atsCheck != null);
if (atsCheck.getAggregate().IsSource())
{
// We already check the "at least as accessible as" rules.
// Does this always work for generics?
// Could we get a bad CType argument in typeThru?
// Maybe call CheckTypeAccess on typeThru?
return ACCESSERROR.ACCESSERROR_NOERROR;
}
// Substitute on the CType.
if (atsCheck.GetTypeArgsAll().size > 0)
{
CType = SymbolLoader.GetTypeManager().SubstType(CType, atsCheck);
}
return CheckTypeAccess(CType, symWhere) ? ACCESSERROR.ACCESSERROR_NOERROR : ACCESSERROR.ACCESSERROR_NOACCESS;
}
示例2: CheckForStaticClass
// Generate an error if CType is static.
public bool CheckForStaticClass(Symbol symCtx, CType CType, ErrorCode err)
{
if (!CType.isStaticClass())
return false;
ReportStaticClassError(symCtx, CType, err);
return true;
}
示例3: CMethodIterator
public CMethodIterator(CSemanticChecker checker, SymbolLoader symLoader, Name name, TypeArray containingTypes, CType @object, CType qualifyingType, Declaration context, bool allowBogusAndInaccessible, bool allowExtensionMethods, int arity, EXPRFLAG flags, symbmask_t mask)
{
Debug.Assert(name != null);
Debug.Assert(symLoader != null);
Debug.Assert(checker != null);
Debug.Assert(containingTypes != null);
_pSemanticChecker = checker;
_pSymbolLoader = symLoader;
_pCurrentType = null;
_pCurrentSym = null;
_pName = name;
_pContainingTypes = containingTypes;
_pQualifyingType = qualifyingType;
_pContext = context;
_bAllowBogusAndInaccessible = allowBogusAndInaccessible;
_bAllowExtensionMethods = allowExtensionMethods;
_nArity = arity;
_flags = flags;
_mask = mask;
_nCurrentTypeCount = 0;
_bIsCheckingInstanceMethods = true;
_bAtEnd = false;
_bCurrentSymIsBogus = false;
_bCurrentSymIsInaccessible = false;
_bcanIncludeExtensionsInResults = _bAllowExtensionMethods;
_bEndIterationAtCurrentExtensionList = false;
}
示例4: CopyItems
public void CopyItems(int i, int c, CType[] dest)
{
for (int j = 0; j < c; ++j)
{
dest[j] = _items[i + j];
}
}
示例5: GetMethodIterator
public CMethodIterator GetMethodIterator(
CSemanticChecker pChecker, SymbolLoader pSymLoader, CType pObject, CType pQualifyingType, Declaration pContext, bool allowBogusAndInaccessible, bool allowExtensionMethods, int arity, EXPRFLAG flags, symbmask_t mask)
{
Debug.Assert(pSymLoader != null);
CMethodIterator iterator = new CMethodIterator(pChecker, pSymLoader, _pName, ContainingTypes, pObject, pQualifyingType, pContext, allowBogusAndInaccessible, allowExtensionMethods, arity, flags, mask);
return iterator;
}
示例6: TypeArray
public TypeArray(CType[] types)
{
_items = types;
if (_items == null)
{
_items = Array.Empty<CType>();
}
}
示例7: SubstContext
public SubstContext(CType[] prgtypeCls, int ctypeCls, CType[] prgtypeMeth, int ctypeMeth, SubstTypeFlags grfst)
{
this.prgtypeCls = prgtypeCls;
this.ctypeCls = ctypeCls;
this.prgtypeMeth = prgtypeMeth;
this.ctypeMeth = ctypeMeth;
this.grfst = grfst;
}
示例8: 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;
}
示例9: 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);
}
示例10: 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;
}
示例11: TypeContainsAnonymousTypes
public static bool TypeContainsAnonymousTypes(CType type)
{
CType ctype = (CType)type;
LRecurse: // Label used for "tail" recursion.
switch (ctype.GetTypeKind())
{
default:
Debug.Assert(false, "Bad Symbol kind in TypeContainsAnonymousTypes");
return false;
case TypeKind.TK_NullType:
case TypeKind.TK_VoidType:
case TypeKind.TK_NullableType:
case TypeKind.TK_TypeParameterType:
case TypeKind.TK_UnboundLambdaType:
case TypeKind.TK_MethodGroupType:
return false;
case TypeKind.TK_ArrayType:
case TypeKind.TK_ParameterModifierType:
case TypeKind.TK_PointerType:
ctype = (CType)ctype.GetBaseOrParameterOrElementType();
goto LRecurse;
case TypeKind.TK_AggregateType:
if (ctype.AsAggregateType().getAggregate().IsAnonymousType())
{
return true;
}
TypeArray typeArgsAll = ctype.AsAggregateType().GetTypeArgsAll();
for (int i = 0; i < typeArgsAll.size; i++)
{
CType typeArg = typeArgsAll.Item(i);
if (TypeContainsAnonymousTypes(typeArg))
{
return true;
}
}
return false;
case TypeKind.TK_ErrorType:
if (ctype.AsErrorType().HasTypeParent())
{
ctype = ctype.AsErrorType().GetTypeParent();
goto LRecurse;
}
return false;
}
}
示例12: BinOpFullSig
public BinOpFullSig(CType type1, CType type2, PfnBindBinOp pfn, OpSigFlags grfos,
LiftFlags grflt, BinOpFuncKind fnkind)
{
this.pt1 = PredefinedType.PT_UNDEFINEDINDEX;
this.pt2 = PredefinedType.PT_UNDEFINEDINDEX;
this.mask = BinOpMask.None;
this.cbosSkip = 0;
this.pfn = pfn;
this.grfos = grfos;
_type1 = type1;
_type2 = type2;
_grflt = grflt;
this.fnkind = fnkind;
}
示例13: 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);
}
示例14: GetAts
public AggregateType GetAts(ErrorHandling errorContext)
{
AggregateSymbol aggNullable = typeManager.GetNullable();
if (aggNullable == null)
{
throw Error.InternalCompilerError();
}
if (ats == null)
{
CType typePar = GetUnderlyingType();
CType[] typeParArray = new CType[] { typePar };
TypeArray ta = symmgr.AllocParams(1, typeParArray);
ats = typeManager.GetAggregate(aggNullable, ta);
}
return ats;
}
示例15: 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);
}