本文整理汇总了C#中ConsList类的典型用法代码示例。如果您正苦于以下问题:C# ConsList类的具体用法?C# ConsList怎么用?C# ConsList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConsList类属于命名空间,在下文中一共展示了ConsList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveBounds
/// <summary>
/// Determine the effective base type, effective interface set, and set of type
/// parameters (excluding cycles) from the type parameter constraints. Conflicts
/// within the constraints and constraint types are returned as diagnostics.
/// 'inherited' should be true if the type parameters are from an overridden
/// generic method. In those cases, additional constraint checks are applied.
/// </summary>
public static TypeParameterBounds ResolveBounds(
this TypeParameterSymbol typeParameter,
AssemblySymbol corLibrary,
ConsList<TypeParameterSymbol> inProgress,
ImmutableArray<TypeSymbol> constraintTypes,
bool inherited,
CSharpCompilation currentCompilation,
DiagnosticBag diagnostics)
{
var diagnosticsBuilder = ArrayBuilder<TypeParameterDiagnosticInfo>.GetInstance();
ArrayBuilder<TypeParameterDiagnosticInfo> useSiteDiagnosticsBuilder = null;
var bounds = typeParameter.ResolveBounds(corLibrary, inProgress, constraintTypes, inherited, currentCompilation, diagnosticsBuilder, ref useSiteDiagnosticsBuilder);
if (useSiteDiagnosticsBuilder != null)
{
diagnosticsBuilder.AddRange(useSiteDiagnosticsBuilder);
}
foreach (var pair in diagnosticsBuilder)
{
diagnostics.Add(new CSDiagnostic(pair.DiagnosticInfo, pair.TypeParameter.Locations[0]));
}
diagnosticsBuilder.Free();
return bounds;
}
示例2: BindFieldInitializers
internal static ImmutableArray<BoundInitializer> BindFieldInitializers(
SourceMemberContainerTypeSymbol containingType,
MethodSymbol scriptCtor,
ImmutableArray<FieldInitializers> initializers,
DiagnosticBag diagnostics,
bool generateDebugInfo,
out ConsList<Imports> firstDebugImports)
{
if (initializers.IsEmpty)
{
firstDebugImports = null;
return ImmutableArray<BoundInitializer>.Empty;
}
CSharpCompilation compilation = containingType.DeclaringCompilation;
ArrayBuilder<BoundInitializer> boundInitializers = ArrayBuilder<BoundInitializer>.GetInstance();
if ((object)scriptCtor == null)
{
BindRegularCSharpFieldInitializers(compilation, initializers, boundInitializers, diagnostics, generateDebugInfo, out firstDebugImports);
}
else
{
BindScriptFieldInitializers(compilation, scriptCtor, initializers, boundInitializers, diagnostics, generateDebugInfo, out firstDebugImports);
}
return boundInitializers.ToImmutableAndFree();
}
示例3: LookupSymbolsInSingleBinder
protected override void LookupSymbolsInSingleBinder(
LookupResult result, string name, int arity, ConsList<Symbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if ((options & (LookupOptions.NamespaceAliasesOnly | LookupOptions.MustBeInvocableIfMember)) != 0)
{
return;
}
Debug.Assert(result.IsClear);
var count = parameterMap.GetCountForKey(name);
if (count == 1)
{
ParameterSymbol p;
parameterMap.TryGetSingleValue(name, out p);
result.MergeEqual(originalBinder.CheckViability(p, arity, options, null, diagnose, ref useSiteDiagnostics));
}
else if (count > 1)
{
var parameters = parameterMap[name];
foreach (var sym in parameters)
{
result.MergeEqual(originalBinder.CheckViability(sym, arity, options, null, diagnose, ref useSiteDiagnostics));
}
}
}
示例4: LookupSymbolsInSingleBinder
internal sealed override void LookupSymbolsInSingleBinder(
LookupResult result,
string name,
int arity,
ConsList<Symbol> basesBeingResolved,
LookupOptions options,
Binder originalBinder,
bool diagnose,
ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
if ((options & (LookupOptions.NamespaceAliasesOnly | LookupOptions.NamespacesOrTypesOnly | LookupOptions.LabelsOnly)) != 0)
{
return;
}
var local = this.LookupPlaceholder(name);
if ((object)local == null)
{
base.LookupSymbolsInSingleBinder(result, name, arity, basesBeingResolved, options, originalBinder, diagnose, ref useSiteDiagnostics);
}
else
{
result.MergeEqual(this.CheckViability(local, arity, options, null, diagnose, ref useSiteDiagnostics, basesBeingResolved));
}
}
示例5: GetImports
private Imports GetImports(ConsList<Symbol> basesBeingResolved)
{
if (_imports == null)
{
Interlocked.CompareExchange(ref _imports, Imports.FromSyntax(_declarationSyntax, this, basesBeingResolved, _inUsing), null);
}
return _imports;
}
示例6: GetFieldType
internal override TypeSymbol GetFieldType(ConsList<FieldSymbol> fieldsBeingBound)
{
if ((object)_lazyType == null)
{
Interlocked.CompareExchange(ref _lazyType, _containingType.TypeSubstitution.SubstituteType(_originalDefinition.GetFieldType(fieldsBeingBound)).Type, null);
}
return _lazyType;
}
示例7: BindRegularCSharpFieldInitializers
/// <summary>
/// In regular C#, all field initializers are assignments to fields and the assigned expressions
/// may not reference instance members.
/// </summary>
private static void BindRegularCSharpFieldInitializers(
CSharpCompilation compilation,
ImmutableArray<ImmutableArray<FieldInitializer>> initializers,
ArrayBuilder<BoundInitializer> boundInitializers,
DiagnosticBag diagnostics,
bool generateDebugInfo,
out ConsList<Imports> firstDebugImports)
{
firstDebugImports = null;
foreach (ImmutableArray<FieldInitializer> siblingInitializers in initializers)
{
// All sibling initializers share the same parent node and tree so we can reuse the binder
// factory across siblings. Unfortunately, we cannot reuse the binder itself, because
// individual fields might have their own binders (e.g. because of being declared unsafe).
BinderFactory binderFactory = null;
foreach (FieldInitializer initializer in siblingInitializers)
{
FieldSymbol fieldSymbol = initializer.Field;
Debug.Assert((object)fieldSymbol != null);
// A constant field of type decimal needs a field initializer, so
// check if it is a metadata constant, not just a constant to exclude
// decimals. Other constants do not need field initializers.
if (!fieldSymbol.IsMetadataConstant)
{
//Can't assert that this is a regular C# compilation, because we could be in a nested type of a script class.
SyntaxReference syntaxRef = initializer.Syntax;
var initializerNode = (CSharpSyntaxNode)syntaxRef.GetSyntax();
if (binderFactory == null)
{
binderFactory = compilation.GetBinderFactory(syntaxRef.SyntaxTree);
}
Binder parentBinder = binderFactory.GetBinder(initializerNode);
Debug.Assert(parentBinder.ContainingMemberOrLambda == fieldSymbol.ContainingType || //should be the binder for the type
fieldSymbol.ContainingType.IsImplicitClass); //however, we also allow fields in namespaces to help support script scenarios
if (generateDebugInfo && firstDebugImports == null)
{
firstDebugImports = parentBinder.ImportsList;
}
BoundInitializer boundInitializer = BindFieldInitializer(
new LocalScopeBinder(parentBinder).WithAdditionalFlagsAndContainingMemberOrLambda(parentBinder.Flags | BinderFlags.FieldInitializer, fieldSymbol),
fieldSymbol,
(EqualsValueClauseSyntax)initializerNode,
diagnostics);
boundInitializers.Add(boundInitializer);
}
}
}
}
示例8: BuildStringBuilder
/// <summary>
/// Builds a string builder from a cons list
/// </summary>
/// <param name="s">ConsList of prefix's</param>
/// <returns>A stringbuilder with spaces seperating prefixes</returns>
private string BuildStringBuilder(ConsList<string> s)
{
StringBuilder st = new StringBuilder();
while (s != null)
{
st.Append(s.Head + " ");
s = s.Tail;
}
return st.ToString();
}
示例9: IsSymbolAccessible
/// <summary>
/// Checks if 'symbol' is accessible from within type 'within', with
/// an qualifier of type "throughTypeOpt". Sets "failedThroughTypeCheck" to true
/// if it failed the "through type" check.
/// </summary>
public static bool IsSymbolAccessible(
Symbol symbol,
NamedTypeSymbol within,
TypeSymbol throughTypeOpt,
out bool failedThroughTypeCheck,
ref HashSet<DiagnosticInfo> useSiteDiagnostics,
ConsList<Symbol> basesBeingResolved = null)
{
return IsSymbolAccessibleCore(symbol, within, throughTypeOpt, out failedThroughTypeCheck, within.DeclaringCompilation, ref useSiteDiagnostics, basesBeingResolved);
}
示例10: GetNamespaceScopes
/// <remarks>
/// CONSIDER: in the case of field initializers, it is possible that different parts of a method could have different
/// namespace scopes (i.e. if they come from different parts of a partial type). Currently, we're following Dev10's
/// approach of using the context of the (possibly synthesized) constructor into which the field initializers are
/// inserted. It might be possible to give field initializers their own scopes, assuming the EE supports it.
/// </remarks>
public ImmutableArray<Cci.NamespaceScope> GetNamespaceScopes(ConsList<Imports> debugImports)
{
if (debugImports == null)
{
return ImmutableArray<Cci.NamespaceScope>.Empty;
}
else
{
return cache.GetOrAdd(debugImports, buildNamespaceScopes);
}
}
示例11: SubstituteFields
private static ConsList<FieldSymbol> SubstituteFields(ConsList<FieldSymbol> fields, TypeMap typeMap)
{
if (!fields.Any())
{
return ConsList<FieldSymbol>.Empty;
}
var head = SubstituteField(fields.Head, typeMap);
var tail = SubstituteFields(fields.Tail, typeMap);
return tail.Prepend(head);
}
示例12: GetImports
internal override Imports GetImports(ConsList<Symbol> basesBeingResolved)
{
Debug.Assert(_lazyImports != null || _computeImports != null, "Have neither imports nor a way to compute them.");
if (_lazyImports == null)
{
Interlocked.CompareExchange(ref _lazyImports, _computeImports(basesBeingResolved), null);
}
return _lazyImports;
}
示例13: CheckStruct
private bool CheckStruct(ConsList<NamedTypeSymbol> typesWithMembersOfThisType, NamedTypeSymbol nts)
{
// Break recursive cycles. If we find a member that contains us, it is considered empty
if (!typesWithMembersOfThisType.ContainsReference(nts))
{
// Remember that we're in the process of doing this type while checking members.
typesWithMembersOfThisType = new ConsList<NamedTypeSymbol>(nts, typesWithMembersOfThisType);
return CheckStructInstanceFields(typesWithMembersOfThisType, nts);
}
return true;
}
示例14: DisplayClassVariable
internal DisplayClassVariable(string name, DisplayClassVariableKind kind, DisplayClassInstance displayClassInstance, ConsList<FieldSymbol> displayClassFields)
{
Debug.Assert(displayClassFields.Any());
this.Name = name;
this.Kind = kind;
this.DisplayClassInstance = displayClassInstance;
this.DisplayClassFields = displayClassFields;
// Verify all type parameters are substituted.
Debug.Assert(this.ContainingSymbol.IsContainingSymbolOfAllTypeParameters(this.Type));
}
示例15: LookupSymbolsInSingleBinder
internal override void LookupSymbolsInSingleBinder(LookupResult result, string name, int arity, ConsList<Symbol> basesBeingResolved, LookupOptions options, Binder originalBinder, bool diagnose, ref HashSet<DiagnosticInfo> useSiteDiagnostics)
{
_sourceBinder.LookupSymbolsInSingleBinder(result, name, arity, basesBeingResolved, options, this, diagnose, ref useSiteDiagnostics);
var symbols = result.Symbols;
for (int i = 0; i < symbols.Count; i++)
{
// Type parameters requiring mapping to the target type and
// should be found by WithMethodTypeParametersBinder instead.
var parameter = (ParameterSymbol)symbols[i];
Debug.Assert(parameter.ContainingSymbol == _sourceBinder.ContainingMemberOrLambda);
symbols[i] = _targetParameters[parameter.Ordinal + _parameterOffset];
}
}