本文整理汇总了C#中ArrayBuilder类的典型用法代码示例。如果您正苦于以下问题:C# ArrayBuilder类的具体用法?C# ArrayBuilder怎么用?C# ArrayBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ArrayBuilder类属于命名空间,在下文中一共展示了ArrayBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildDispatchMap
DispatchMapEntry[] BuildDispatchMap(NodeFactory factory)
{
ArrayBuilder<DispatchMapEntry> dispatchMapEntries = new ArrayBuilder<DispatchMapEntry>();
for (int i = 0; i < _type.RuntimeInterfaces.Length; i++)
{
var interfaceType = _type.RuntimeInterfaces[i];
Debug.Assert(interfaceType.IsInterface);
List<MethodDesc> virtualSlots;
factory.VirtualSlots.TryGetValue(interfaceType, out virtualSlots);
if (virtualSlots != null)
{
for (int j = 0; j < virtualSlots.Count; j++)
{
MethodDesc declMethod = virtualSlots[j];
var implMethod = VirtualFunctionResolution.ResolveInterfaceMethodToVirtualMethodOnType(declMethod, _type.GetClosestMetadataType());
// Interface methods first implemented by a base type in the hierarchy will return null for the implMethod (runtime interface
// dispatch will walk the inheritance chain).
if (implMethod != null)
{
var entry = new DispatchMapEntry();
entry.InterfaceIndex = checked((short)i);
entry.InterfaceMethodSlot = checked((short)j);
entry.ImplementationMethodSlot = checked((short)VirtualMethodSlotHelper.GetVirtualMethodSlot(factory, implMethod));
dispatchMapEntries.Add(entry);
}
}
}
}
return dispatchMapEntries.ToArray();
}
示例2: BindDeconstructionAssignment
/// <summary>
/// There are two kinds of deconstruction-assignments which this binding handles: tuple and non-tuple.
///
/// Returns a BoundDeconstructionAssignmentOperator with a list of deconstruction steps and assignment steps.
/// Deconstruct steps for tuples have no invocation to Deconstruct, but steps for non-tuples do.
/// The caller is responsible for releasing all the ArrayBuilders in checkedVariables.
/// </summary>
private BoundDeconstructionAssignmentOperator BindDeconstructionAssignment(
CSharpSyntaxNode node,
ExpressionSyntax right,
ArrayBuilder<DeconstructionVariable> checkedVariables,
DiagnosticBag diagnostics,
bool isDeclaration,
BoundDeconstructValuePlaceholder rhsPlaceholder = null)
{
// receiver for first Deconstruct step
var boundRHS = rhsPlaceholder ?? BindValue(right, diagnostics, BindValueKind.RValue);
boundRHS = FixTupleLiteral(checkedVariables, boundRHS, node, diagnostics);
if ((object)boundRHS.Type == null)
{
// we could still not infer a type for the RHS
FailRemainingInferences(checkedVariables, diagnostics);
return new BoundDeconstructionAssignmentOperator(
node, isDeclaration, FlattenDeconstructVariables(checkedVariables), boundRHS,
ImmutableArray<BoundDeconstructionDeconstructStep>.Empty,
ImmutableArray<BoundDeconstructionAssignmentStep>.Empty,
ImmutableArray<BoundDeconstructionAssignmentStep>.Empty,
ImmutableArray<BoundDeconstructionConstructionStep>.Empty,
GetSpecialType(SpecialType.System_Void, diagnostics, node),
hasErrors: true);
}
var deconstructionSteps = ArrayBuilder<BoundDeconstructionDeconstructStep>.GetInstance(1);
var conversionSteps = ArrayBuilder<BoundDeconstructionAssignmentStep>.GetInstance(1);
var assignmentSteps = ArrayBuilder<BoundDeconstructionAssignmentStep>.GetInstance(1);
var constructionStepsOpt = isDeclaration ? null : ArrayBuilder<BoundDeconstructionConstructionStep>.GetInstance(1);
bool hasErrors = !DeconstructIntoSteps(
new BoundDeconstructValuePlaceholder(boundRHS.Syntax, boundRHS.Type),
node,
diagnostics,
checkedVariables,
deconstructionSteps,
conversionSteps,
assignmentSteps,
constructionStepsOpt);
TypeSymbol returnType = isDeclaration ?
GetSpecialType(SpecialType.System_Void, diagnostics, node) :
hasErrors ?
CreateErrorType() :
constructionStepsOpt.Last().OutputPlaceholder.Type;
var deconstructions = deconstructionSteps.ToImmutableAndFree();
var conversions = conversionSteps.ToImmutableAndFree();
var assignments = assignmentSteps.ToImmutableAndFree();
var constructions = isDeclaration ? default(ImmutableArray<BoundDeconstructionConstructionStep>) : constructionStepsOpt.ToImmutableAndFree();
FailRemainingInferences(checkedVariables, diagnostics);
return new BoundDeconstructionAssignmentOperator(
node, isDeclaration, FlattenDeconstructVariables(checkedVariables), boundRHS,
deconstructions, conversions, assignments, constructions, returnType, hasErrors: hasErrors);
}
示例3: CollectLocalsFromDeconstruction
internal void CollectLocalsFromDeconstruction(
ExpressionSyntax declaration,
LocalDeclarationKind kind,
ArrayBuilder<LocalSymbol> locals,
SyntaxNode deconstructionStatement,
Binder enclosingBinderOpt = null)
{
switch (declaration.Kind())
{
case SyntaxKind.TupleExpression:
{
var tuple = (TupleExpressionSyntax)declaration;
foreach (var arg in tuple.Arguments)
{
CollectLocalsFromDeconstruction(arg.Expression, kind, locals, deconstructionStatement, enclosingBinderOpt);
}
break;
}
case SyntaxKind.DeclarationExpression:
{
var declarationExpression = (DeclarationExpressionSyntax)declaration;
CollectLocalsFromDeconstruction(
declarationExpression.Designation, declarationExpression.Type,
kind, locals, deconstructionStatement, enclosingBinderOpt);
break;
}
case SyntaxKind.IdentifierName:
break;
default:
throw ExceptionUtilities.UnexpectedValue(declaration.Kind());
}
}
示例4: CollectLocalsFromDeconstruction
internal void CollectLocalsFromDeconstruction(
ExpressionSyntax declaration,
LocalDeclarationKind kind,
ArrayBuilder<LocalSymbol> locals,
SyntaxNode deconstructionStatement,
Binder enclosingBinderOpt = null)
{
switch (declaration.Kind())
{
case SyntaxKind.TupleExpression:
{
var tuple = (TupleExpressionSyntax)declaration;
foreach (var arg in tuple.Arguments)
{
CollectLocalsFromDeconstruction(arg.Expression, kind, locals, deconstructionStatement, enclosingBinderOpt);
}
break;
}
case SyntaxKind.DeclarationExpression:
{
var declarationExpression = (DeclarationExpressionSyntax)declaration;
CollectLocalsFromDeconstruction(
declarationExpression.Designation, declarationExpression.Type,
kind, locals, deconstructionStatement, enclosingBinderOpt);
break;
}
case SyntaxKind.IdentifierName:
break;
default:
// In broken code, we can have an arbitrary expression here. Collect its expression variables.
ExpressionVariableFinder.FindExpressionVariables(this, locals, declaration);
break;
}
}
示例5: AddSynthesizedAttributes
internal override void AddSynthesizedAttributes(ModuleCompilationState compilationState, ref ArrayBuilder<SynthesizedAttributeData> attributes)
{
base.AddSynthesizedAttributes(compilationState, ref attributes);
CSharpCompilation compilation = this.DeclaringCompilation;
// do not emit CompilerGenerated attributes for fields inside compiler generated types:
if (!_containingType.IsImplicitlyDeclared)
{
AddSynthesizedAttribute(ref attributes, compilation.TrySynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
}
if (!this.SuppressDynamicAttribute &&
this.Type.ContainsDynamic() &&
compilation.HasDynamicEmitAttributes() &&
compilation.CanEmitBoolean())
{
AddSynthesizedAttribute(ref attributes, compilation.SynthesizeDynamicAttribute(this.Type, this.CustomModifiers.Length));
}
if (Type.ContainsTuple() &&
compilation.HasTupleNamesAttributes &&
compilation.CanEmitSpecialType(SpecialType.System_String))
{
AddSynthesizedAttribute(ref attributes,
compilation.SynthesizeTupleNamesAttributeOpt(Type));
}
}
示例6: GetAllScopes
private static void GetAllScopes(
ISymUnmanagedScope root,
ArrayBuilder<ISymUnmanagedScope> allScopes,
ArrayBuilder<ISymUnmanagedScope> containingScopes,
int offset,
bool isScopeEndInclusive)
{
var stack = ArrayBuilder<ISymUnmanagedScope>.GetInstance();
stack.Push(root);
while (stack.Any())
{
var scope = stack.Pop();
allScopes.Add(scope);
if (offset >= 0 && scope.IsInScope(offset, isScopeEndInclusive))
{
containingScopes.Add(scope);
}
foreach (var nested in scope.GetScopes())
{
stack.Push(nested);
}
}
stack.Free();
}
示例7: LargeTextWriter
public LargeTextWriter(Encoding encoding, SourceHashAlgorithm checksumAlgorithm, int length)
{
_encoding = encoding;
_checksumAlgorithm = checksumAlgorithm;
_chunks = ArrayBuilder<char[]>.GetInstance(1 + length / LargeText.ChunkSize);
_bufferSize = Math.Min(LargeText.ChunkSize, length);
}
示例8: AddSynthesizedAttributes
internal override void AddSynthesizedAttributes(ref ArrayBuilder<SynthesizedAttributeData> attributes)
{
base.AddSynthesizedAttributes(ref attributes);
var compilation = this.DeclaringCompilation;
AddSynthesizedAttribute(ref attributes, compilation.SynthesizeAttribute(WellKnownMember.System_Diagnostics_DebuggerHiddenAttribute__ctor));
}
示例9: SpillBuilder
internal SpillBuilder()
{
locals = ArrayBuilder<LocalSymbol>.GetInstance();
temps = ArrayBuilder<BoundSpillTemp>.GetInstance();
statements = ArrayBuilder<BoundStatement>.GetInstance();
fields = ArrayBuilder<FieldSymbol>.GetInstance();
}
示例10: AddSynthesizedAttributes
internal override void AddSynthesizedAttributes(ref ArrayBuilder<SynthesizedAttributeData> attributes)
{
base.AddSynthesizedAttributes(ref attributes);
var compilation = this.DeclaringCompilation;
AddSynthesizedAttribute(ref attributes, compilation.SynthesizeAttribute(WellKnownMember.System_Runtime_CompilerServices_CompilerGeneratedAttribute__ctor));
}
示例11: Context
internal Context(ArrayBuilder<SyntaxTree> builder, Compilation compilation, string path, bool writeToDisk)
{
_builder = builder;
_compilation = compilation;
_path = path;
_writeToDisk = writeToDisk;
}
示例12: VisitPointerType
protected internal override object VisitPointerType(PointerTypeSymbol symbol, ArrayBuilder<SymbolDescriptionPart> builder)
{
VisitType(symbol.PointedAtType, builder);
AddPunctuation(SyntaxKind.AsteriskToken, builder);
return null;
}
示例13: VisitArrayType
protected internal override object VisitArrayType(ArrayTypeSymbol symbol, ArrayBuilder<SymbolDescriptionPart> builder)
{
//See spec section 12.1 for the order of rank specificiers
//e.g. int[][,][,,] is stored as
// ArrayType
// Rank = 1
// ElementType = ArrayType
// Rank = 2
// ElementType = ArrayType
// Rank = 3
// ElementType = int
TypeSymbol underlyingNonArrayType = symbol.ElementType;
while (underlyingNonArrayType.TypeKind == TypeKind.ArrayType)
{
underlyingNonArrayType = ((ArrayTypeSymbol)underlyingNonArrayType).ElementType;
}
VisitType(underlyingNonArrayType, builder);
ArrayTypeSymbol arrayType = symbol;
while (arrayType != null)
{
AddArrayRank(arrayType, builder);
arrayType = arrayType.ElementType as ArrayTypeSymbol;
}
return null;
}
示例14: GetRows
internal override void GetRows(
ResultProvider resultProvider,
ArrayBuilder<EvalResult> rows,
DkmInspectionContext inspectionContext,
EvalResultDataItem parent,
DkmClrValue value,
int startIndex,
int count,
bool visitAll,
ref int index)
{
var fields = GetFields();
int startIndex2;
int count2;
GetIntersection(startIndex, count, index, fields.Count, out startIndex2, out count2);
int offset = startIndex2 - index;
for (int i = 0; i < count2; i++)
{
var row = GetMemberRow(resultProvider, inspectionContext, value, fields[i + offset], parent);
rows.Add(row);
}
index += fields.Count;
}
示例15: AddCollectionInitializers
// Rewrite collection initializer add method calls:
// 2) new List<int> { 1 };
// ~
private void AddCollectionInitializers(ref ArrayBuilder<BoundExpression> dynamicSiteInitializers, ArrayBuilder<BoundExpression> result, BoundExpression rewrittenReceiver, ImmutableArray<BoundExpression> initializers)
{
Debug.Assert(rewrittenReceiver != null || _inExpressionLambda);
foreach (var initializer in initializers)
{
// In general bound initializers may contain bad expressions or element initializers.
// We don't lower them if they contain errors, so it's safe to assume an element initializer.
BoundExpression rewrittenInitializer;
if (initializer.Kind == BoundKind.CollectionElementInitializer)
{
rewrittenInitializer = MakeCollectionInitializer(rewrittenReceiver, (BoundCollectionElementInitializer)initializer);
}
else
{
Debug.Assert(!_inExpressionLambda);
Debug.Assert(initializer.Kind == BoundKind.DynamicCollectionElementInitializer);
rewrittenInitializer = MakeDynamicCollectionInitializer(rewrittenReceiver, (BoundDynamicCollectionElementInitializer)initializer);
}
// the call to Add may be omitted
if (rewrittenInitializer != null)
{
result.Add(rewrittenInitializer);
}
}
}