本文整理汇总了C#中TypeSymbol类的典型用法代码示例。如果您正苦于以下问题:C# TypeSymbol类的具体用法?C# TypeSymbol怎么用?C# TypeSymbol使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeSymbol类属于命名空间,在下文中一共展示了TypeSymbol类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetInferredType
public BoundLocal SetInferredType(TypeSymbol type, bool success)
{
Debug.Assert(type != null);
var syntaxNode = (SingleVariableDesignationSyntax)this.Syntax;
Binder.DeclareLocalVariable((SourceLocalSymbol)this.LocalSymbol, syntaxNode.Identifier, type);
return new BoundLocal(syntaxNode, this.LocalSymbol, constantValueOpt: null, type: type, hasErrors: this.HasErrors || !success);
}
开发者ID:tvsonar,项目名称:roslyn,代码行数:7,代码来源:DeconstructionLocalPendingInference.cs
示例2: StructDependsClosure
private static void StructDependsClosure(TypeSymbol type, HashSet<Symbol> partialClosure, NamedTypeSymbol on)
{
if ((object)type == null)
{
return;
}
var nt = type as NamedTypeSymbol;
if ((object)nt != null && ReferenceEquals(nt.OriginalDefinition, on))
{
// found a possibly expanding cycle, for example
// struct X<T> { public T t; }
// struct W<T> { X<W<W<T>>> x; }
// while not explicitly forbidden by the spec, it should be.
partialClosure.Add(on);
return;
}
if ((object)nt != null && partialClosure.Add(nt))
{
foreach (var member in type.GetMembersUnordered())
{
var field = member as FieldSymbol;
if ((object)field == null || field.Type.TypeKind != TypeKind.Struct || field.IsStatic)
{
continue;
}
StructDependsClosure(field.Type, partialClosure, on);
}
}
}
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:31,代码来源:BaseTypeAnalysis.cs
示例3: ClassifyConversionFromExpression
public Conversion ClassifyConversionFromExpression(TypeSymbol source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
Debug.Assert((object)source != null);
Debug.Assert((object)destination != null);
return ClassifyConversionFromExpression(null, source, destination, ref useSiteDiagnostics);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:Conversions.cs
示例4: TempLocalSymbol
internal TempLocalSymbol(TypeSymbol type, RefKind refKind, MethodSymbol containingMethod) : base(containingMethod, type, null)
{
this.refKind = refKind;
#if TEMPNAMES
this.name = "_" + Interlocked.Increment(ref nextName);
#endif
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:TempLocalSymbol.cs
示例5: CreateMask
public static TypeRefMask CreateMask(TypeRefContext ctx, TypeSymbol t)
{
Contract.ThrowIfNull(t);
switch (t.SpecialType)
{
case SpecialType.System_Void: return 0;
case SpecialType.System_Int64: return ctx.GetLongTypeMask();
case SpecialType.System_String: return ctx.GetStringTypeMask();
case SpecialType.System_Double: return ctx.GetDoubleTypeMask();
case SpecialType.System_Boolean: return ctx.GetBooleanTypeMask();
case SpecialType.None:
var containing = t.ContainingAssembly;
if (containing != null && containing.IsPchpCorLibrary)
{
if (t.Name == "PhpValue") return TypeRefMask.AnyType;
if (t.Name == "PhpAlias") return TypeRefMask.AnyType.WithRefFlag;
if (t.Name == "PhpNumber") return ctx.GetNumberTypeMask();
if (t.Name == "PhpString") return ctx.GetWritableStringTypeMask();
if (t.Name == "PhpArray") return ctx.GetArrayTypeMask();
if (t.Name == "IPhpCallable") return ctx.GetCallableTypeMask();
}
break;
}
return CreateMask(ctx, CreateTypeRef(ctx, t));
}
开发者ID:iolevel,项目名称:peachpie,代码行数:28,代码来源:TypeRefFactory.cs
示例6: IsSameType
/// <summary>
/// Logical equality on anonymous types that ignores custom modifiers and/or the object/dynamic distinction.
/// Differs from IsSameType for arrays, pointers, and generic instantiations.
/// </summary>
internal static bool IsSameType(TypeSymbol type1, TypeSymbol type2, bool ignoreCustomModifiers, bool ignoreDynamic)
{
Debug.Assert(type1.IsAnonymousType);
Debug.Assert(type2.IsAnonymousType);
if (ignoreCustomModifiers || ignoreDynamic)
{
AnonymousTypeDescriptor left = ((AnonymousTypePublicSymbol)type1).TypeDescriptor;
AnonymousTypeDescriptor right = ((AnonymousTypePublicSymbol)type2).TypeDescriptor;
if (left.Key != right.Key)
{
return false;
}
int count = left.Fields.Length;
Debug.Assert(right.Fields.Length == count);
for (int i = 0; i < count; i++)
{
if (!left.Fields[i].Type.Equals(right.Fields[i].Type, ignoreCustomModifiers, ignoreDynamic))
{
return false;
}
}
return true;
}
else
{
return type1 == type2;
}
}
开发者ID:riversky,项目名称:roslyn,代码行数:35,代码来源:AnonymousTypeManager.cs
示例7: EELocalSymbol
public EELocalSymbol(
MethodSymbol method,
ImmutableArray<Location> locations,
string nameOpt,
int ordinal,
LocalDeclarationKind declarationKind,
TypeSymbol type,
RefKind refKind,
bool isPinned,
bool isCompilerGenerated,
bool canScheduleToStack)
{
Debug.Assert(method != null);
Debug.Assert(ordinal >= -1);
Debug.Assert(!locations.IsDefault);
Debug.Assert(type != null);
_method = method;
_locations = locations;
_nameOpt = nameOpt;
_ordinal = ordinal;
_declarationKind = declarationKind;
_type = type;
_refKind = refKind;
_isPinned = isPinned;
_isCompilerGenerated = isCompilerGenerated;
_canScheduleToStack = canScheduleToStack;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:28,代码来源:EELocalSymbol.cs
示例8: CopyTypeCustomModifiers
/// <param name="sourceType">Type that already has custom modifiers.</param>
/// <param name="destinationType">Same as <paramref name="sourceType"/>, but without custom modifiers. May differ in object/dynamic.</param>
/// <param name="refKind"><see cref="RefKind"/> of the parameter of which this is the type (or <see cref="RefKind.None"/> for a return type.</param>
/// <param name="containingAssembly">The assembly containing the signature referring to the destination type.</param>
/// <returns><paramref name="destinationType"/> with custom modifiers copied from <paramref name="sourceType"/>.</returns>
internal static TypeSymbol CopyTypeCustomModifiers(TypeSymbol sourceType, TypeSymbol destinationType, RefKind refKind, AssemblySymbol containingAssembly)
{
Debug.Assert(sourceType.Equals(destinationType, TypeCompareKind.AllIgnoreOptions));
// NOTE: overrides can differ by object/dynamic. If they do, we'll need to tweak newType before
// we can use it in place of this.Type. We do so by computing the dynamic transform flags that
// code gen uses and then passing them to the dynamic type decoder that metadata reading uses.
ImmutableArray<bool> flags = CSharpCompilation.DynamicTransformsEncoder.EncodeWithoutCustomModifierFlags(destinationType, refKind);
TypeSymbol typeWithDynamic = DynamicTypeDecoder.TransformTypeWithoutCustomModifierFlags(sourceType, containingAssembly, refKind, flags);
TypeSymbol resultType;
if (destinationType.ContainsTuple() && !sourceType.Equals(destinationType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreDynamic))
{
// We also preserve tuple names, if present and different
ImmutableArray<string> names = CSharpCompilation.TupleNamesEncoder.Encode(destinationType);
resultType = TupleTypeDecoder.DecodeTupleTypesIfApplicable(typeWithDynamic, containingAssembly, names);
}
else
{
resultType = typeWithDynamic;
}
Debug.Assert(resultType.Equals(sourceType, TypeCompareKind.IgnoreDynamicAndTupleNames)); // Same custom modifiers as source type.
Debug.Assert(resultType.Equals(destinationType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds)); // Same object/dynamic and tuple names as destination type.
return resultType;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:31,代码来源:CustomModifierUtils.cs
示例9: MakeLiteral
private BoundExpression MakeLiteral(CSharpSyntaxNode syntax, ConstantValue constantValue, TypeSymbol type, BoundLiteral oldNodeOpt = null)
{
Debug.Assert(constantValue != null);
if (constantValue.IsDecimal)
{
// Rewrite decimal literal
Debug.Assert((object)type != null);
Debug.Assert(type.SpecialType == SpecialType.System_Decimal);
return MakeDecimalLiteral(syntax, constantValue);
}
else if (constantValue.IsDateTime)
{
// C# does not support DateTime constants but VB does; we might have obtained a
// DateTime constant by calling a method with an optional parameter with a DateTime
// for its default value.
Debug.Assert((object)type != null);
Debug.Assert(type.SpecialType == SpecialType.System_DateTime);
return MakeDateTimeLiteral(syntax, constantValue);
}
else if (oldNodeOpt != null)
{
return oldNodeOpt.Update(constantValue, type);
}
else
{
return new BoundLiteral(syntax, constantValue, type, hasErrors: constantValue.IsBad);
}
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:LocalRewriter_Literal.cs
示例10: MetadataTypeAdapter
/// <summary>
/// </summary>
/// <param name="typeDef">
/// </param>
/// <param name="isByRef">
/// </param>
internal MetadataTypeAdapter(TypeSymbol typeDef, bool isByRef = false, bool isPinned = false)
{
Debug.Assert(typeDef != null);
this.typeDef = typeDef;
this.IsByRef = isByRef;
this.IsPinned = isPinned;
var def = typeDef as ByRefReturnErrorTypeSymbol;
if (def != null)
{
this.typeDef = def.ReferencedType;
this.IsByRef = true;
}
Debug.Assert(this.typeDef.TypeKind != TypeKind.Error);
this.lazyName = new Lazy<string>(this.CalculateName);
this.lazyFullName = new Lazy<string>(this.CalculateFullName);
this.lazyMetadataName = new Lazy<string>(this.CalculateMetadataName);
this.lazyMetadataFullName = new Lazy<string>(this.CalculateMetadataFullName);
this.lazyNamespace = new Lazy<string>(this.CalculateNamespace);
this.lazyBaseType = new Lazy<IType>(this.CalculateBaseType);
this.lazyAssemblyQualifiedName = new Lazy<string>(this.CalculateAssemblyQualifiedName);
this.lazyToString = new Lazy<string>(this.CalculateToString);
}
开发者ID:SperoSophia,项目名称:il2bc,代码行数:32,代码来源:MetadataTypeAdapter.cs
示例11: MakeFieldAccess
private BoundExpression MakeFieldAccess(
CSharpSyntaxNode syntax,
BoundExpression rewrittenReceiver,
FieldSymbol fieldSymbol,
ConstantValue constantValueOpt,
LookupResultKind resultKind,
TypeSymbol type,
BoundFieldAccess oldNodeOpt = null)
{
if (fieldSymbol.IsTupleField)
{
return MakeTupleFieldAccess(syntax, fieldSymbol, rewrittenReceiver, constantValueOpt, resultKind);
}
BoundExpression result = oldNodeOpt != null ?
oldNodeOpt.Update(rewrittenReceiver, fieldSymbol, constantValueOpt, resultKind, type) :
new BoundFieldAccess(syntax, rewrittenReceiver, fieldSymbol, constantValueOpt, resultKind, type);
if (fieldSymbol.IsFixed)
{
// a reference to a fixed buffer is translated into its address
result = new BoundConversion(syntax,
new BoundAddressOfOperator(syntax, result, syntax != null && SyntaxFacts.IsFixedStatementExpression(syntax), type, false),
new Conversion(ConversionKind.PointerToPointer), false, false, default(ConstantValue), type, false);
}
return result;
}
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:29,代码来源:LocalRewriter_Field.cs
示例12: GetImplicitTupleLiteralConversion
protected override Conversion GetImplicitTupleLiteralConversion(BoundTupleLiteral source, TypeSymbol destination, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
var arguments = source.Arguments;
// check if the type is actually compatible type for a tuple of given cardinality
if (!destination.IsTupleOrCompatibleWithTupleOfCardinality(arguments.Length))
{
return Conversion.NoConversion;
}
ImmutableArray<TypeSymbol> targetElementTypes = destination.GetElementTypesOfTupleOrCompatible();
Debug.Assert(arguments.Length == targetElementTypes.Length);
// check arguments against flattened list of target element types
var argumentConversions = ArrayBuilder<Conversion>.GetInstance(arguments.Length);
for (int i = 0; i < arguments.Length; i++)
{
var argument = arguments[i];
var result = ClassifyImplicitConversionFromExpression(argument, targetElementTypes[i], ref useSiteDiagnostics);
if (!result.Exists)
{
argumentConversions.Free();
return Conversion.NoConversion;
}
argumentConversions.Add(result);
}
return new Conversion(ConversionKind.ImplicitTupleLiteral, argumentConversions.ToImmutableAndFree());
}
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:30,代码来源:Conversions.cs
示例13: SynthesizedEntryPointSymbol
internal SynthesizedEntryPointSymbol(NamedTypeSymbol containingType, TypeSymbol returnType, DiagnosticBag diagnostics)
{
Debug.Assert((object)containingType != null);
this.containingType = containingType;
if (containingType.ContainingAssembly.IsInteractive)
{
var interactiveSessionType = this.DeclaringCompilation.GetWellKnownType(WellKnownType.Microsoft_CSharp_RuntimeHelpers_Session);
var useSiteDiagnostic = interactiveSessionType.GetUseSiteDiagnostic();
if (useSiteDiagnostic != null)
{
Symbol.ReportUseSiteDiagnostic(useSiteDiagnostic, diagnostics, NoLocation.Singleton);
}
this.parameters = ImmutableArray.Create<ParameterSymbol>(new SynthesizedParameterSymbol(this, interactiveSessionType, 0, RefKind.None, "session"));
this.name = "<Factory>";
}
else
{
this.parameters = ImmutableArray<ParameterSymbol>.Empty;
this.name = "<Main>";
}
this.returnType = returnType;
}
开发者ID:riversky,项目名称:roslyn,代码行数:25,代码来源:SynthesizedEntryPointSymbol.cs
示例14: SourceStrictComplexParameterSymbol
internal SourceStrictComplexParameterSymbol(
DiagnosticBag diagnostics,
Binder binder,
Symbol owner,
int ordinal,
TypeSymbol parameterType,
RefKind refKind,
string name,
ImmutableArray<Location> locations,
SyntaxReference syntaxRef,
ConstantValue defaultSyntaxValue,
bool isParams,
bool isExtensionMethodThis)
: base(
owner: owner,
ordinal: ordinal,
parameterType: parameterType,
refKind: refKind,
name: name,
locations: locations,
syntaxRef: syntaxRef,
defaultSyntaxValue: defaultSyntaxValue,
isParams: isParams,
isExtensionMethodThis: isExtensionMethodThis)
{
_tempBinder = binder;
var unused = GetAttributesBag(diagnostics);
_lazyDefaultSyntaxValue = MakeDefaultExpression(diagnostics, binder);
_tempBinder = null; // no need to keep it around anymore, just uses up a lot of memory
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:30,代码来源:SourceStrictComplexParameterSymbol.cs
示例15: SynthesizedImplementationMethod
public SynthesizedImplementationMethod(
MethodSymbol interfaceMethod,
NamedTypeSymbol implementingType,
string name = null,
bool debuggerHidden = false,
PropertySymbol associatedProperty = null,
MethodSymbol asyncKickoffMethod = null)
{
//it does not make sense to add methods to substituted types
Debug.Assert(implementingType.IsDefinition);
this.name = name ?? ExplicitInterfaceHelpers.GetMemberName(interfaceMethod.Name, interfaceMethod.ContainingType, aliasQualifierOpt: null);
this.interfaceMethod = interfaceMethod;
this.implementingType = implementingType;
this.debuggerHidden = debuggerHidden;
this.associatedProperty = associatedProperty;
this.explicitInterfaceImplementations = ImmutableArray.Create<MethodSymbol>(interfaceMethod);
this.asyncKickoffMethod = asyncKickoffMethod;
// alpha-rename to get the implementation's type parameters
var typeMap = interfaceMethod.ContainingType.TypeSubstitution ?? TypeMap.Empty;
typeMap.WithAlphaRename(interfaceMethod, this, out this.typeParameters);
var substitutedInterfaceMethod = interfaceMethod.ConstructIfGeneric(this.typeParameters.Cast<TypeParameterSymbol, TypeSymbol>());
this.returnType = substitutedInterfaceMethod.ReturnType;
this.parameters = SynthesizedParameterSymbol.DeriveParameters(substitutedInterfaceMethod, this);
}
开发者ID:riversky,项目名称:roslyn,代码行数:27,代码来源:SynthesizedMethodSymbol.cs
示例16: UnaryOperatorSignature
public UnaryOperatorSignature(UnaryOperatorKind kind, TypeSymbol operandType, TypeSymbol returnType, MethodSymbol method = null)
{
this.Kind = kind;
this.OperandType = operandType;
this.ReturnType = returnType;
this.Method = method;
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:7,代码来源:UnaryOperatorSignature.cs
示例17: Create
/// <summary>
/// Return the extension method in reduced form if the extension method
/// is applicable, and satisfies type parameter constraints, based on the
/// "this" argument type. Otherwise, returns null.
/// </summary>
public static MethodSymbol Create(MethodSymbol method, TypeSymbol receiverType, Compilation compilation)
{
Debug.Assert(method.IsExtensionMethod && method.MethodKind != MethodKind.ReducedExtension);
Debug.Assert(method.ParameterCount > 0);
Debug.Assert((object)receiverType != null);
HashSet<DiagnosticInfo> useSiteDiagnostics = null;
method = method.InferExtensionMethodTypeArguments(receiverType, compilation, ref useSiteDiagnostics);
if ((object)method == null)
{
return null;
}
var conversions = new TypeConversions(method.ContainingAssembly.CorLibrary);
var conversion = conversions.ConvertExtensionMethodThisArg(method.Parameters[0].Type, receiverType, ref useSiteDiagnostics);
if (!conversion.Exists)
{
return null;
}
if (useSiteDiagnostics != null)
{
foreach (var diag in useSiteDiagnostics)
{
if (diag.Severity == DiagnosticSeverity.Error)
{
return null;
}
}
}
return Create(method);
}
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:39,代码来源:ReducedExtensionMethodSymbol.cs
示例18: SetInferredType
public BoundDeconstructValuePlaceholder SetInferredType(TypeSymbol type, bool success)
{
Debug.Assert((object)Placeholder == null);
Placeholder = new BoundDeconstructValuePlaceholder(this.Syntax, type, hasErrors: this.HasErrors || !success);
return Placeholder;
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:7,代码来源:OutDeconstructVarPendingInference.cs
示例19: RewriteConditionalOperator
private static BoundExpression RewriteConditionalOperator(
CSharpSyntaxNode syntax,
BoundExpression rewrittenCondition,
BoundExpression rewrittenConsequence,
BoundExpression rewrittenAlternative,
ConstantValue constantValueOpt,
TypeSymbol rewrittenType)
{
// NOTE: This optimization assumes that a constant has no side effects. In the future we
// might wish to represent nodes that are known to the optimizer as having constant
// values as a sequence of side effects and a constant value; in that case the result
// of this should be a sequence containing the side effect and the consequence or alternative.
ConstantValue conditionConstantValue = rewrittenCondition.ConstantValue;
if (conditionConstantValue == ConstantValue.True)
{
return rewrittenConsequence;
}
else if (conditionConstantValue == ConstantValue.False)
{
return rewrittenAlternative;
}
else
{
return new BoundConditionalOperator(
syntax,
rewrittenCondition,
rewrittenConsequence,
rewrittenAlternative,
constantValueOpt,
rewrittenType);
}
}
开发者ID:EkardNT,项目名称:Roslyn,代码行数:33,代码来源:LocalRewriter_ConditionalOperator.cs
示例20: BoundLambda
public BoundLambda(CSharpSyntaxNode syntax, BoundBlock body, ImmutableArray<Diagnostic> diagnostics, Binder binder, TypeSymbol delegateType, bool inferReturnType)
: this(syntax, (LambdaSymbol)binder.ContainingMemberOrLambda, body, diagnostics, binder, delegateType)
{
if (inferReturnType)
{
this._inferredReturnType = InferReturnType(
this.Body,
this.Binder,
delegateType,
this.Symbol.IsAsync,
ref this._inferredReturnTypeUseSiteDiagnostics,
out this._refKind,
out this._inferredFromSingleType);
#if DEBUG
_hasInferredReturnType = true;
#endif
}
Debug.Assert(
syntax.IsAnonymousFunction() || // lambda expressions
syntax is ExpressionSyntax && LambdaUtilities.IsLambdaBody(syntax, allowReducedLambdas: true) || // query lambdas
LambdaUtilities.IsQueryPairLambda(syntax) // "pair" lambdas in queries
);
}
开发者ID:Rickinio,项目名称:roslyn,代码行数:25,代码来源:UnboundLambda.cs
注:本文中的TypeSymbol类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论