• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# CSharp.SyntheticBoundNodeFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.SyntheticBoundNodeFactory的典型用法代码示例。如果您正苦于以下问题:C# SyntheticBoundNodeFactory类的具体用法?C# SyntheticBoundNodeFactory怎么用?C# SyntheticBoundNodeFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SyntheticBoundNodeFactory类属于Microsoft.CodeAnalysis.CSharp命名空间,在下文中一共展示了SyntheticBoundNodeFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Rewrite

        internal static BoundBlock Rewrite(SourceMethodSymbol sourceMethodSymbol, MethodContractSyntax contract, BoundBlock body, TypeCompilationState compilationState, DiagnosticBag diagsForCurrentMethod)
        {
            var binder = compilationState.Compilation.GetBinderFactory(sourceMethodSymbol.SyntaxTree)
                                     .GetBinder(body.Syntax);
            SyntheticBoundNodeFactory factory = new SyntheticBoundNodeFactory(sourceMethodSymbol, sourceMethodSymbol.SyntaxNode, compilationState, diagsForCurrentMethod);
            var contractType = compilationState.Compilation.GetTypeByReflectionType(typeof(System.Diagnostics.Contracts.Contract), diagsForCurrentMethod);

            var contractStatements = ArrayBuilder<BoundStatement>.GetInstance(contract.Requires.Count);
            foreach (var requires in contract.Requires)
            {
                var condition = binder.BindExpression(requires.Condition, diagsForCurrentMethod);
                
                var methodCall = factory.StaticCall(contractType, "Requires", condition);
                var statement = factory.ExpressionStatement(methodCall);

                contractStatements.Add(statement);
            }
            foreach (var requires in contract.Ensures)
            {
                var condition = binder.BindExpression(requires.Condition, diagsForCurrentMethod);
                var methodCall = factory.StaticCall(contractType, "Ensures", condition);
                var statement = factory.ExpressionStatement(methodCall);

                contractStatements.Add(statement);
            }

            return body.Update(body.Locals, body.Statements.InsertRange(0, contractStatements.ToImmutableAndFree()));
        }
开发者ID:Daniel-Svensson,项目名称:roslyn,代码行数:28,代码来源:MethodContractRewriter.cs


示例2: SpillFieldAllocator

 internal SpillFieldAllocator(SyntheticBoundNodeFactory F, TypeCompilationState CompilationState)
 {
     allocatedFields = new KeyedStack<TypeSymbol, FieldSymbol>();
     realizedSpills = new Dictionary<BoundSpillTemp, FieldSymbol>();
     this.F = F;
     this.CompilationState = CompilationState;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:AwaitLoweringRewriterPass2_SpillFieldAllocator.cs


示例3: TryCreate

        public static DynamicAnalysisInjector TryCreate(MethodSymbol method, BoundStatement methodBody, SyntheticBoundNodeFactory methodBodyFactory, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, Instrumenter previous)
        {
            // Do not instrument implicitly-declared methods, except for constructors.
            // Instrument implicit constructors in order to instrument member initializers.
            if (method.IsImplicitlyDeclared && !method.IsImplicitConstructor)
            {
                return null;
            }

            // Do not instrument methods marked with or in scope of ExcludeFromCodeCoverageAttribute.
            if (IsExcludedFromCodeCoverage(method))
            {
                return null;
            }

            MethodSymbol createPayload = GetCreatePayload(methodBodyFactory.Compilation, methodBody.Syntax, diagnostics);

            // Do not instrument any methods if CreatePayload is not present.
            if ((object)createPayload == null)
            {
                return null;
            }

            // Do not instrument CreatePayload if it is part of the current compilation (which occurs only during testing).
            // CreatePayload will fail at run time with an infinite recursion if it is instrumented.
            if (method.Equals(createPayload))
            {
                return null;
            }

            return new DynamicAnalysisInjector(method, methodBody, methodBodyFactory, createPayload, diagnostics, debugDocumentProvider, previous);
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:32,代码来源:DynamicAnalysisInjector.cs


示例4: LoweredDynamicOperation

 public LoweredDynamicOperation(SyntheticBoundNodeFactory factory, BoundExpression siteInitialization, BoundExpression siteInvocation, TypeSymbol resultType)
 {
     this.Factory = factory;
     this.resultType = resultType;
     this.SiteInitialization = siteInitialization;
     this.SiteInvocation = siteInvocation;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:7,代码来源:LoweredDynamicOperation.cs


示例5: StateMachineRewriter

        protected StateMachineRewriter(
            BoundStatement body,
            MethodSymbol method,
            SynthesizedContainer stateMachineType,
            VariableSlotAllocator slotAllocatorOpt,
            TypeCompilationState compilationState,
            DiagnosticBag diagnostics)
        {
            Debug.Assert(body != null);
            Debug.Assert(method != null);
            Debug.Assert(stateMachineType != null);
            Debug.Assert(compilationState != null);
            Debug.Assert(diagnostics != null);

            this.body = body;
            this.method = method;
            this.stateMachineType = stateMachineType;
            this.slotAllocatorOpt = slotAllocatorOpt;
            this.synthesizedLocalOrdinals = new SynthesizedLocalOrdinalsDispenser();
            this.diagnostics = diagnostics;

            this.F = new SyntheticBoundNodeFactory(method, body.Syntax, compilationState, diagnostics);
            Debug.Assert(F.CurrentType == method.ContainingType);
            Debug.Assert(F.Syntax == body.Syntax);
        }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:25,代码来源:StateMachineRewriter.cs


示例6: MethodToStateMachineRewriter

        public MethodToStateMachineRewriter(
            SyntheticBoundNodeFactory F,
            MethodSymbol originalMethod,
            FieldSymbol state,
            IReadOnlySet<Symbol> variablesCaptured,
            IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
            DiagnosticBag diagnostics,
            bool useFinalizerBookkeeping)
            : base(F.CompilationState, diagnostics)
        {
            Debug.Assert(F != null);
            Debug.Assert(originalMethod != null);
            Debug.Assert(state != null);
            Debug.Assert(nonReusableLocalProxies != null);
            Debug.Assert(diagnostics != null);
            Debug.Assert(variablesCaptured != null);

            this.F = F;
            this.stateField = state;
            this.cachedState = F.SynthesizedLocal(F.SpecialType(SpecialType.System_Int32), kind: SynthesizedLocalKind.StateMachineCachedState);
            this.useFinalizerBookkeeping = useFinalizerBookkeeping;
            this.hasFinalizerState = useFinalizerBookkeeping;
            this.originalMethod = originalMethod;
            this.variablesCaptured = variablesCaptured;

            foreach (var proxy in nonReusableLocalProxies)
            {
                this.proxies.Add(proxy.Key, proxy.Value);
            }
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:30,代码来源:MethodToStateMachineRewriter.cs


示例7: AsyncMethodToClassRewriter

            internal AsyncMethodToClassRewriter(
                MethodSymbol method,
                AsyncMethodBuilderMemberCollection asyncMethodBuilderMemberCollection,
                SyntheticBoundNodeFactory F,
                FieldSymbol state,
                FieldSymbol builder,
                HashSet<Symbol> variablesCaptured,
                Dictionary<Symbol, CapturedSymbolReplacement> initialProxies,
                DiagnosticBag diagnostics,
                bool generateDebugInfo)
                : base(F, method, state, variablesCaptured, initialProxies, diagnostics,
                      useFinalizerBookkeeping: false,
                      generateDebugInfo: generateDebugInfo)
            {
                this.method = method;
                this.asyncMethodBuilderMemberCollection = asyncMethodBuilderMemberCollection;
                this.asyncMethodBuilderField = builder;
                this.exprReturnLabel = F.GenerateLabel("exprReturn");
                this.exitLabel = F.GenerateLabel("exitLabel");

                this.exprRetValue = method.IsGenericTaskReturningAsync(F.Compilation)
                    ? F.SynthesizedLocal(asyncMethodBuilderMemberCollection.ResultType, GeneratedNames.AsyncExprRetValueFieldName())
                    : null;

                this.dynamicFactory = new LoweredDynamicOperationFactory(F);
            }
开发者ID:riversky,项目名称:roslyn,代码行数:26,代码来源:AsyncMethodToClassRewriter.cs


示例8: AsyncMethodToStateMachineRewriter

        internal AsyncMethodToStateMachineRewriter(
            MethodSymbol method,
            int methodOrdinal,
            AsyncMethodBuilderMemberCollection asyncMethodBuilderMemberCollection,
            SyntheticBoundNodeFactory F,
            FieldSymbol state,
            FieldSymbol builder,
            IReadOnlySet<Symbol> hoistedVariables,
            IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
            SynthesizedLocalOrdinalsDispenser synthesizedLocalOrdinals,
            VariableSlotAllocator slotAllocatorOpt,
            int nextFreeHoistedLocalSlot,
            DiagnosticBag diagnostics)
            : base(F, method, state, hoistedVariables, nonReusableLocalProxies, synthesizedLocalOrdinals, slotAllocatorOpt, nextFreeHoistedLocalSlot, diagnostics, useFinalizerBookkeeping: false)
        {
            _method = method;
            _asyncMethodBuilderMemberCollection = asyncMethodBuilderMemberCollection;
            _asyncMethodBuilderField = builder;
            _exprReturnLabel = F.GenerateLabel("exprReturn");
            _exitLabel = F.GenerateLabel("exitLabel");

            _exprRetValue = method.IsGenericTaskReturningAsync(F.Compilation)
                ? F.SynthesizedLocal(asyncMethodBuilderMemberCollection.ResultType, syntax: F.Syntax, kind: SynthesizedLocalKind.AsyncMethodReturnValue)
                : null;

            _dynamicFactory = new LoweredDynamicOperationFactory(F, methodOrdinal);
            _awaiterFields = new Dictionary<TypeSymbol, FieldSymbol>(TypeSymbol.EqualsIgnoringDynamicComparer);
            _nextAwaiterId = slotAllocatorOpt?.PreviousAwaiterSlotCount ?? 0;
        }
开发者ID:rafaellincoln,项目名称:roslyn,代码行数:29,代码来源:AsyncMethodToStateMachineRewriter.cs


示例9: LoweredDynamicOperation

 public LoweredDynamicOperation(SyntheticBoundNodeFactory factory, BoundExpression siteInitialization, BoundExpression siteInvocation, TypeSymbol resultType, ImmutableArray<LocalSymbol> temps)
 {
     _factory = factory;
     _resultType = resultType;
     _temps = temps;
     this.SiteInitialization = siteInitialization;
     this.SiteInvocation = siteInvocation;
 }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:8,代码来源:LoweredDynamicOperation.cs


示例10: AddSequence

 internal void AddSequence(SyntheticBoundNodeFactory F, BoundSequence sequence)
 {
     locals.AddRange(sequence.Locals);
     foreach (var sideEffect in sequence.SideEffects)
     {
         statements.Add(F.ExpressionStatement(sideEffect));
     }
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:8,代码来源:SpillBuilder.cs


示例11: ExpressionLambdaRewriter

 private ExpressionLambdaRewriter(TypeCompilationState compilationState, CSharpSyntaxNode node, DiagnosticBag diagnostics)
 {
     Bound = new SyntheticBoundNodeFactory((NamedTypeSymbol)null, node, compilationState, diagnostics);
     Int32Type = Bound.SpecialType(SpecialType.System_Int32);
     ObjectType = Bound.SpecialType(SpecialType.System_Object);
     NullableType = Bound.SpecialType(SpecialType.System_Nullable_T);
     IEnumerableType = Bound.SpecialType(SpecialType.System_Collections_Generic_IEnumerable_T);
 }
开发者ID:riversky,项目名称:roslyn,代码行数:8,代码来源:ExpressionLambdaRewriter.cs


示例12: BuildSequenceAndFree

        internal BoundExpression BuildSequenceAndFree(SyntheticBoundNodeFactory F, BoundExpression expression)
        {
            var result = (locals.Count > 0 || statements.Count > 0 || temps.Count > 0)
                ? F.SpillSequence(locals.ToReadOnly(), temps.ToReadOnly(), fields.ToReadOnly(), statements.ToReadOnly(), expression)
                : expression;

            Free();

            return result;
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:10,代码来源:SpillBuilder.cs


示例13: IteratorMethodToStateMachineRewriter

        private int nextFinalizeState = StateMachineStates.FinishedStateMachine - 1;  // -3

        internal IteratorMethodToStateMachineRewriter(
            SyntheticBoundNodeFactory F,
            MethodSymbol originalMethod,
            FieldSymbol state,
            FieldSymbol current,
            IReadOnlySet<Symbol> variablesCaptured,
            IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> initialProxies,
            DiagnosticBag diagnostics)
            : base(F, originalMethod, state, variablesCaptured, initialProxies, diagnostics, useFinalizerBookkeeping: false)
        {
            this.current = current;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:14,代码来源:IteratorMethodToStateMachineRewriter.cs


示例14: AsyncExceptionHandlerRewriter

 private AsyncExceptionHandlerRewriter(
     MethodSymbol containingMethod,
     NamedTypeSymbol containingType,
     SyntheticBoundNodeFactory factory,
     DiagnosticBag diagnostics,
     AwaitInFinallyAnalysis analysis)
 {
     _F = factory;
     _F.CurrentMethod = containingMethod;
     Debug.Assert(factory.CurrentType == (containingType ?? containingMethod.ContainingType));
     _diagnostics = diagnostics;
     _analysis = analysis;
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:13,代码来源:AsyncExceptionHandlerRewriter.cs


示例15: IteratorMethodToClassRewriter

        private int nextFinalizeState = StateMachineStates.FinishedStateMachine - 1;  // -3

        internal IteratorMethodToClassRewriter(
            SyntheticBoundNodeFactory F,
            MethodSymbol originalMethod,
            FieldSymbol state,
            FieldSymbol current,
            HashSet<Symbol> variablesCaptured,
            Dictionary<Symbol, CapturedSymbolReplacement> initialProxies,
            DiagnosticBag diagnostics,
            bool generateDebugInfo)
            : base(F, originalMethod, state, variablesCaptured, initialProxies, diagnostics,
                  useFinalizerBookkeeping: false,
                  generateDebugInfo: generateDebugInfo)
        {
            this.current = current;
        }
开发者ID:nagyist,项目名称:roslyn,代码行数:17,代码来源:IteratorMethodToClassRewriter.cs


示例16: IteratorMethodToStateMachineRewriter

        private int _nextFinalizeState = StateMachineStates.FinishedStateMachine - 1;  // -3

        internal IteratorMethodToStateMachineRewriter(
            SyntheticBoundNodeFactory F,
            MethodSymbol originalMethod,
            FieldSymbol state,
            FieldSymbol current,
            IReadOnlySet<Symbol> hoistedVariables,
            IReadOnlyDictionary<Symbol, CapturedSymbolReplacement> nonReusableLocalProxies,
            SynthesizedLocalOrdinalsDispenser synthesizedLocalOrdinals,
            VariableSlotAllocator slotAllocatorOpt,
            int nextFreeHoistedLocalSlot,
            DiagnosticBag diagnostics)
            : base(F, originalMethod, state, hoistedVariables, nonReusableLocalProxies, synthesizedLocalOrdinals, slotAllocatorOpt, nextFreeHoistedLocalSlot, diagnostics, useFinalizerBookkeeping: false)
        {
            _current = current;
        }
开发者ID:daking2014,项目名称:roslyn,代码行数:17,代码来源:IteratorMethodToStateMachineRewriter.cs


示例17: AsyncExceptionHandlerRewriter

 private AsyncExceptionHandlerRewriter(
     MethodSymbol containingMethod,
     NamedTypeSymbol containingType,
     SyntheticBoundNodeFactory factory,
     CSharpCompilation compilation,
     DiagnosticBag diagnostics,
     AwaitInFinallyAnalysis analysis)
 {
     this.generateDebugInfo = containingMethod.GenerateDebugInfo;
     this.compilation = compilation;
     this.F = factory;
     this.F.CurrentMethod = containingMethod;
     Debug.Assert(factory.CurrentClass == (containingType ?? containingMethod.ContainingType));
     this.diagnostics = diagnostics;
     this.analysis = analysis;
 }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:16,代码来源:AsyncExceptionHandlerRewriter.cs


示例18: StateMachineRewriter

 protected StateMachineRewriter(
     BoundStatement body,
     MethodSymbol method,
     SynthesizedContainer stateMachineClass,
     TypeCompilationState compilationState,
     DiagnosticBag diagnostics)
 {
     this.body = body;
     this.method = method;
     this.stateMachineClass = stateMachineClass;
     this.compilationState = compilationState;
     this.diagnostics = diagnostics;
     this.F = new SyntheticBoundNodeFactory(method, body.Syntax, compilationState, diagnostics);
     Debug.Assert(F.CurrentClass == method.ContainingType);
     Debug.Assert(F.Syntax == body.Syntax);
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:16,代码来源:StateMachineRewriter.cs


示例19: TryCreate

        public static DynamicAnalysisInjector TryCreate(MethodSymbol method, BoundStatement methodBody, SyntheticBoundNodeFactory methodBodyFactory, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, Instrumenter previous)
        {
            // Do not instrument implicitly-declared methods.
            if (!method.IsImplicitlyDeclared)
            {
                MethodSymbol createPayload = GetCreatePayload(methodBodyFactory.Compilation, methodBody.Syntax, diagnostics);

                // Do not instrument any methods if CreatePayload is not present.
                // Do not instrument CreatePayload if it is part of the current compilation (which occurs only during testing).
                // CreatePayload will fail at run time with an infinite recursion if it Is instrumented.
                if ((object)createPayload != null && !method.Equals(createPayload))
                {
                    return new DynamicAnalysisInjector(method, methodBody, methodBodyFactory, createPayload, diagnostics, debugDocumentProvider, previous);
                }
            }

            return null;
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:18,代码来源:DynamicAnalysisInjector.cs


示例20: DynamicAnalysisInjector

        private DynamicAnalysisInjector(MethodSymbol method, BoundStatement methodBody, SyntheticBoundNodeFactory methodBodyFactory, MethodSymbol createPayload, DiagnosticBag diagnostics, DebugDocumentProvider debugDocumentProvider, Instrumenter previous)
            : base(previous)
        {
            _createPayload = createPayload;
            _method = method;
            _methodBody = methodBody;
            _spansBuilder = ArrayBuilder<SourceSpan>.GetInstance();
            TypeSymbol payloadElementType = methodBodyFactory.SpecialType(SpecialType.System_Boolean);
            _payloadType = ArrayTypeSymbol.CreateCSharpArray(methodBodyFactory.Compilation.Assembly, payloadElementType);
            _methodPayload = methodBodyFactory.SynthesizedLocal(_payloadType, kind: SynthesizedLocalKind.InstrumentationPayload, syntax: methodBody.Syntax);
            _diagnostics = diagnostics;
            _debugDocumentProvider = debugDocumentProvider;
            _methodHasExplicitBlock = MethodHasExplicitBlock(method);
            _methodBodyFactory = methodBodyFactory;

            // The first point indicates entry into the method and has the span of the method definition.
            _methodEntryInstrumentation = AddAnalysisPoint(MethodDeclarationIfAvailable(methodBody.Syntax), methodBodyFactory);
        }
开发者ID:Rickinio,项目名称:roslyn,代码行数:18,代码来源:DynamicAnalysisInjector.cs



注:本文中的Microsoft.CodeAnalysis.CSharp.SyntheticBoundNodeFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CSharp.TypeCompilationState类代码示例发布时间:2022-05-26
下一篇:
C# CSharp.SyntaxTreeSemanticModel类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap