本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.BoundNode类的典型用法代码示例。如果您正苦于以下问题:C# BoundNode类的具体用法?C# BoundNode怎么用?C# BoundNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoundNode类属于Microsoft.CodeAnalysis.CSharp命名空间,在下文中一共展示了BoundNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegionAnalysisContext
/// <summary>
/// Construct context
/// </summary>
public RegionAnalysisContext(CSharpCompilation compilation, Symbol member, BoundNode boundNode, BoundNode firstInRegion, BoundNode lastInRegion)
{
this.Compilation = compilation;
this.Member = member;
this.BoundNode = boundNode;
this.FirstInRegion = firstInRegion;
this.LastInRegion = lastInRegion;
this.Failed =
boundNode == null ||
firstInRegion == null ||
lastInRegion == null ||
firstInRegion.Syntax.SpanStart > lastInRegion.Syntax.Span.End;
if (!this.Failed && ReferenceEquals(firstInRegion, lastInRegion))
{
switch (firstInRegion.Kind)
{
case BoundKind.NamespaceExpression:
case BoundKind.TypeExpression:
// Some bound nodes are still considered to be invalid for flow analysis
this.Failed = true;
break;
}
}
}
示例2: Analyze
public static MultiDictionary<Symbol, CSharpSyntaxNode> Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node)
{
var emptyStructs = new CaptureWalkerEmptyStructTypeCache();
var initiallyAssignedVariables = UnassignedVariablesWalker.Analyze(compilation, method, node, emptyStructs);
var walker = new IteratorAndAsyncCaptureWalker(compilation, method, node, emptyStructs, initiallyAssignedVariables);
bool badRegion = false;
walker.Analyze(ref badRegion);
Debug.Assert(!badRegion);
var result = walker.variablesCaptured;
if (!method.IsStatic && method.ContainingType.TypeKind == TypeKind.Struct)
{
// It is possible that the enclosing method only *writes* to the enclosing struct, but in that
// case it should be considered captured anyway so that we have a proxy for it to write to.
result.Add(method.ThisParameter, node.Syntax);
}
foreach (var variable in result.Keys.ToArray()) // take a snapshot, as we are modifying the underlying multidictionary
{
var local = variable as LocalSymbol;
if ((object)local != null && local.RefKind != RefKind.None)
{
walker.AddSpillsForRef(walker.refLocalInitializers[local], result[local]);
}
}
walker.Free();
return result;
}
示例3: Visit
public override BoundNode Visit(BoundNode node)
{
IOperation operation = node as IOperation;
if (operation != null)
{
this.nodes.Add(operation);
// Following operations are not bound node, therefore have to be added explicitly:
// 1. IArgument
// 2. IMemberInitializer
// 3. ICase
switch (operation.Kind)
{
case OperationKind.InvocationExpression:
nodes.AddRange(((IInvocationExpression)operation).ArgumentsInSourceOrder);
break;
case OperationKind.ObjectCreationExpression:
var objCreationExp = (IObjectCreationExpression)operation;
nodes.AddRange(objCreationExp.ConstructorArguments);
nodes.AddRange(objCreationExp.MemberInitializers);
break;
case OperationKind.SwitchStatement:
nodes.AddRange(((ISwitchStatement)operation).Cases);
break;
}
}
return base.Visit(node);
}
示例4: NoteUnsafe
private void NoteUnsafe(BoundNode node)
{
if (_inExpressionLambda && !_reportedUnsafe)
{
Error(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node);
_reportedUnsafe = true;
}
}
示例5: IssueDiagnostics
public static void IssueDiagnostics(CSharpCompilation compilation, BoundNode node, DiagnosticBag diagnostics, MethodSymbol containingSymbol)
{
Debug.Assert(node != null);
Debug.Assert((object)containingSymbol != null);
var diagnosticPass = new DiagnosticsPass(compilation, diagnostics, containingSymbol);
diagnosticPass.Visit(node);
}
示例6: IteratorAndAsyncCaptureWalker
private IteratorAndAsyncCaptureWalker(CSharpCompilation compilation, MethodSymbol method, BoundNode node, CaptureWalkerEmptyStructTypeCache emptyStructCache, HashSet<Symbol> initiallyAssignedVariables)
: base(compilation,
method,
node,
emptyStructCache,
trackUnassignments: true,
initiallyAssignedVariables: initiallyAssignedVariables)
{
}
示例7: AbstractRegionControlFlowPass
internal AbstractRegionControlFlowPass(
CSharpCompilation compilation,
Symbol member,
BoundNode node,
BoundNode firstInRegion,
BoundNode lastInRegion)
: base(compilation, member, node, firstInRegion, lastInRegion)
{
}
示例8: Visit
public override BoundNode Visit(BoundNode node)
{
IOperation operation = node as IOperation;
if (operation != null)
{
this.nodes.Add(operation);
}
return base.Visit(node);
}
示例9: AbstractRegionDataFlowPass
internal AbstractRegionDataFlowPass(
CSharpCompilation compilation,
Symbol member,
BoundNode node,
BoundNode firstInRegion,
BoundNode lastInRegion,
HashSet<Symbol> initiallyAssignedVariables = null,
HashSet<PrefixUnaryExpressionSyntax> unassignedVariableAddressOfSyntaxes = null,
bool trackUnassignments = false)
: base(compilation, member, node, firstInRegion, lastInRegion, initiallyAssignedVariables, unassignedVariableAddressOfSyntaxes, trackUnassignments)
{
}
示例10: Find
public static HashSet<LabelSymbol> Find(BoundNode node, Dictionary<BoundNode, HashSet<LabelSymbol>> unmatchedLabelsCache)
{
UnmatchedGotoFinder finder = new UnmatchedGotoFinder(unmatchedLabelsCache);
finder.Visit(node);
HashSet<LabelSymbol> gotos = finder._gotos;
HashSet<LabelSymbol> targets = finder._targets;
if (gotos != null && targets != null)
{
gotos.RemoveAll(targets);
}
return gotos;
}
示例11: NoteBranch
protected override void NoteBranch(
PendingBranch pending,
BoundNode gotoStmt,
BoundStatement targetStmt)
{
targetStmt.AssertIsLabeledStatement();
if (!gotoStmt.WasCompilerGenerated && !targetStmt.WasCompilerGenerated && !RegionContains(gotoStmt.Syntax.Span) && RegionContains(targetStmt.Syntax.Span))
{
pending.State = ResetState(pending.State);
}
base.NoteBranch(pending, gotoStmt, targetStmt);
}
示例12: Analyze
// Returns deterministically ordered list of variables that ought to be hoisted.
public static OrderedSet<Symbol> Analyze(CSharpCompilation compilation, MethodSymbol method, BoundNode node, DiagnosticBag diagnostics)
{
var initiallyAssignedVariables = UnassignedVariablesWalker.Analyze(compilation, method, node, convertInsufficientExecutionStackExceptionToCancelledByStackGuardException: true);
var walker = new IteratorAndAsyncCaptureWalker(compilation, method, node, new NeverEmptyStructTypeCache(), initiallyAssignedVariables);
walker._convertInsufficientExecutionStackExceptionToCancelledByStackGuardException = true;
bool badRegion = false;
walker.Analyze(ref badRegion);
Debug.Assert(!badRegion);
if (!method.IsStatic && method.ContainingType.TypeKind == TypeKind.Struct)
{
// It is possible that the enclosing method only *writes* to the enclosing struct, but in that
// case it should be considered captured anyway so that we have a proxy for it to write to.
walker.CaptureVariable(method.ThisParameter, node.Syntax);
}
var variablesToHoist = walker._variablesToHoist;
var lazyDisallowedCaptures = walker._lazyDisallowedCaptures;
var allVariables = walker.variableBySlot;
walker.Free();
if (lazyDisallowedCaptures != null)
{
foreach (var kvp in lazyDisallowedCaptures)
{
var variable = kvp.Key;
var type = (variable.Kind == SymbolKind.Local) ? ((LocalSymbol)variable).Type : ((ParameterSymbol)variable).Type;
foreach (CSharpSyntaxNode syntax in kvp.Value)
{
// CS4013: Instance of type '{0}' cannot be used inside an anonymous function, query expression, iterator block or async method
diagnostics.Add(ErrorCode.ERR_SpecialByRefInLambda, syntax.Location, type);
}
}
}
if (compilation.Options.OptimizationLevel != OptimizationLevel.Release)
{
Debug.Assert(variablesToHoist.Count == 0);
// In debug build we hoist all locals and parameters:
variablesToHoist.AddRange(from v in allVariables
where v.Symbol != null && HoistInDebugBuild(v.Symbol)
select v.Symbol);
}
return variablesToHoist;
}
示例13: Analyze
internal static HashSet<Symbol> Analyze(CSharpCompilation compilation, Symbol member, BoundNode node, EmptyStructTypeCache emptyStructCache = null)
{
var walker = new UnassignedVariablesWalker(compilation, member, node, emptyStructCache);
try
{
bool badRegion = false;
var result = walker.Analyze(ref badRegion);
return badRegion ? new HashSet<Symbol>() : result;
}
finally
{
walker.Free();
}
}
示例14: Analyze
internal static IEnumerable<Symbol> Analyze(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion)
{
var walker = new VariablesDeclaredWalker(compilation, member, node, firstInRegion, lastInRegion);
try
{
bool badRegion = false;
walker.Analyze(ref badRegion);
return badRegion ? SpecializedCollections.EmptyEnumerable<Symbol>() : walker._variablesDeclared;
}
finally
{
walker.Free();
}
}
示例15: Analyze
internal static IEnumerable<Symbol> Analyze(CSharpCompilation compilation, Symbol member, BoundNode node, BoundNode firstInRegion, BoundNode lastInRegion)
{
var walker = new AlwaysAssignedWalker(compilation, member, node, firstInRegion, lastInRegion);
bool badRegion = false;
try
{
var result = walker.Analyze(ref badRegion);
return badRegion ? SpecializedCollections.EmptyEnumerable<Symbol>() : result;
}
finally
{
walker.Free();
}
}