當前位置: 首頁>>代碼示例>>C#>>正文


C# CSharp.BoundNode類代碼示例

本文整理匯總了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;
                }
            }
        }
開發者ID:EkardNT,項目名稱:Roslyn,代碼行數:29,代碼來源:RegionAnalysisContext.cs

示例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;
        }
開發者ID:EkardNT,項目名稱:Roslyn,代碼行數:33,代碼來源:IteratorAndAsyncCaptureWalker.cs

示例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);
 }
開發者ID:hughgao,項目名稱:roslyn,代碼行數:27,代碼來源:Expression.cs

示例4: NoteUnsafe

 private void NoteUnsafe(BoundNode node)
 {
     if (_inExpressionLambda && !_reportedUnsafe)
     {
         Error(ErrorCode.ERR_ExpressionTreeContainsPointerOp, node);
         _reportedUnsafe = true;
     }
 }
開發者ID:abock,項目名稱:roslyn,代碼行數:8,代碼來源:DiagnosticsPass_ExpressionTrees.cs

示例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);
        }
開發者ID:jerriclynsjohn,項目名稱:roslyn,代碼行數:8,代碼來源:DiagnosticsPass_ExpressionTrees.cs

示例6: IteratorAndAsyncCaptureWalker

 private IteratorAndAsyncCaptureWalker(CSharpCompilation compilation, MethodSymbol method, BoundNode node, CaptureWalkerEmptyStructTypeCache emptyStructCache, HashSet<Symbol> initiallyAssignedVariables)
     : base(compilation, 
           method, 
           node, 
           emptyStructCache, 
           trackUnassignments: true, 
           initiallyAssignedVariables: initiallyAssignedVariables)
 {
 }
開發者ID:modulexcite,項目名稱:pattern-matching-csharp,代碼行數:9,代碼來源:IteratorAndAsyncCaptureWalker.cs

示例7: AbstractRegionControlFlowPass

 internal AbstractRegionControlFlowPass(
     CSharpCompilation compilation,
     Symbol member,
     BoundNode node,
     BoundNode firstInRegion,
     BoundNode lastInRegion)
     : base(compilation, member, node, firstInRegion, lastInRegion)
 {
 }
開發者ID:CAPCHIK,項目名稱:roslyn,代碼行數:9,代碼來源:AbstractRegionControlFlowPass.cs

示例8: Visit

            public override BoundNode Visit(BoundNode node)
            {
                IOperation operation = node as IOperation;
                if (operation != null)
                {
                    this.nodes.Add(operation);
                }

                return base.Visit(node);
            }
開發者ID:physhi,項目名稱:roslyn,代碼行數:10,代碼來源:Expression.cs

示例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)
 {
 }
開發者ID:CAPCHIK,項目名稱:roslyn,代碼行數:12,代碼來源:AbstractRegionDataFlowPass.cs

示例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;
 }
開發者ID:GloryChou,項目名稱:roslyn,代碼行數:12,代碼來源:UnmatchedGotoFinder.cs

示例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);
        }
開發者ID:XieShuquan,項目名稱:roslyn,代碼行數:13,代碼來源:DataFlowsInWalker.cs

示例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;
        }
開發者ID:Rickinio,項目名稱:roslyn,代碼行數:52,代碼來源:IteratorAndAsyncCaptureWalker.cs

示例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();
     }
 }
開發者ID:modulexcite,項目名稱:pattern-matching-csharp,代碼行數:14,代碼來源:UnassignedVariablesWalker.cs

示例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();
     }
 }
開發者ID:Rookieek,項目名稱:roslyn,代碼行數:14,代碼來源:VariablesDeclaredWalker.cs

示例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();
     }
 }
開發者ID:CAPCHIK,項目名稱:roslyn,代碼行數:14,代碼來源:AlwaysAssignedWalker.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.BoundNode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。