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

C# BoundStatement类代码示例

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

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



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

示例1: Optimize

        public static BoundStatement Optimize(
            BoundStatement src, bool debugFriendly,
            out HashSet<LocalSymbol> stackLocals)
        {
            //TODO: run other optimizing passes here.
            //      stack scheduler must be the last one.

            var locals = PooledDictionary<LocalSymbol, LocalDefUseInfo>.GetInstance();
            var evalStack = ArrayBuilder<ValueTuple<BoundExpression, ExprContext>>.GetInstance();
            src = (BoundStatement)StackOptimizerPass1.Analyze(src, locals, evalStack, debugFriendly);
            evalStack.Free();

            FilterValidStackLocals(locals);

            BoundStatement result;
            if (locals.Count == 0)
            {
                stackLocals = null;
                result = src;
            }
            else
            {
                stackLocals = new HashSet<LocalSymbol>(locals.Keys);
                result = StackOptimizerPass2.Rewrite(src, locals);
            }

            foreach (var info in locals.Values)
            {
                info.LocalDefs.Free();
            }

            locals.Free();

            return result;
        }
开发者ID:rosslyn-cuongle,项目名称:roslyn,代码行数:35,代码来源:Optimizer.cs


示例2: BoundIfStatement

 public BoundIfStatement(BoundExpression condition, BoundStatement consequence, BoundStatement alternativeOpt)
     : base(BoundNodeKind.IfStatement)
 {
     Condition = condition;
     Consequence = consequence;
     AlternativeOpt = alternativeOpt;
 }
开发者ID:Samana,项目名称:HlslTools,代码行数:7,代码来源:BoundIfStatement.cs


示例3: Rewrite

 public static BoundStatement Rewrite(BoundStatement node, MethodSymbol containingSymbol, NamedTypeSymbol containingType, SynthesizedSubmissionFields previousSubmissionFields, Compilation compilation)
 {
     Debug.Assert(node != null);
     var rewriter = new CallRewriter(containingSymbol, containingType, previousSubmissionFields, compilation);
     var result = (BoundStatement)rewriter.Visit(node);
     return result;
 }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:7,代码来源:CallRewriter.cs


示例4: CodeGenerator

        public CodeGenerator(
            MethodSymbol method,
            BoundStatement boundBody,
            ILBuilder builder,
            PEModuleBuilder moduleBuilder,
            DiagnosticBag diagnostics,
            OptimizationLevel optimizations,
            bool emittingPdb)
        {
            Debug.Assert((object)method != null);
            Debug.Assert(boundBody != null);
            Debug.Assert(builder != null);
            Debug.Assert(moduleBuilder != null);
            Debug.Assert(diagnostics != null);

            _method = method;
            _boundBody = boundBody;
            _builder = builder;
            _module = moduleBuilder;
            _diagnostics = diagnostics;

            if (!method.GenerateDebugInfo)
            {
                // Always optimize synthesized methods that don't contain user code.
                // 
                // Specifically, always optimize synthesized explicit interface implementation methods
                // (aka bridge methods) with by-ref returns because peverify produces errors if we
                // return a ref local (which the return local will be in such cases).
                _ilEmitStyle = ILEmitStyle.Release;
            }
            else
            {
                if (optimizations == OptimizationLevel.Debug)
                {
                    _ilEmitStyle = ILEmitStyle.Debug;
                }
                else
                {
                    _ilEmitStyle = IsDebugPlus() ? 
                        ILEmitStyle.DebugFriendlyRelease : 
                        ILEmitStyle.Release;
                }
            }

            // Emit sequence points unless
            // - the PDBs are not being generated
            // - debug information for the method is not generated since the method does not contain
            //   user code that can be stepped through, or changed during EnC.
            // 
            // This setting only affects generating PDB sequence points, it shall not affect generated IL in any way.
            _emitPdbSequencePoints = emittingPdb && method.GenerateDebugInfo;

            _boundBody = Optimizer.Optimize(
                boundBody, 
                debugFriendly: _ilEmitStyle != ILEmitStyle.Release, 
                stackLocals: out _stackLocals);

            _methodBodySyntaxOpt = (method as SourceMethodSymbol)?.BodySyntax;
        }
开发者ID:nemec,项目名称:roslyn,代码行数:59,代码来源:CodeGenerator.cs


示例5: Rewrite

 public static BoundStatement Rewrite(BoundStatement node, MethodSymbol containingMethod, Compilation compilation, bool generateDebugInfo, out bool sawLambdas)
 {
     Debug.Assert(node != null);
     var rewriter = new ControlFlowRewriter(containingMethod, compilation, generateDebugInfo);
     var result = (BoundStatement)rewriter.Visit(node);
     sawLambdas = rewriter.sawLambdas;
     return result;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:8,代码来源:ControlFlowRewriter.cs


示例6: Rewrite

        public static BoundStatement Rewrite(BoundStatement node, MethodSymbol containingSymbol, Compilation compilation)
        {
            Debug.Assert(node != null);
            Debug.Assert(compilation != null);

            var rewriter = new IsAndAsRewriter(containingSymbol, compilation);
            var result = (BoundStatement)rewriter.Visit(node);
            return result;
        }
开发者ID:modulexcite,项目名称:pattern-matching-csharp,代码行数:9,代码来源:IsAndAsRewriter.cs


示例7: BoundForStatement

 public BoundForStatement(BoundMultipleVariableDeclarations declaration, BoundExpression initializer, BoundExpression condition, BoundExpression incrementor, BoundStatement body)
     : base(BoundNodeKind.ForStatement)
 {
     Declarations = declaration;
     Initializer = initializer;
     Condition = condition;
     Incrementor = incrementor;
     Body = body;
 }
开发者ID:Samana,项目名称:HlslTools,代码行数:9,代码来源:BoundForStatement.cs


示例8: RegionAnalysisWalker

        protected RegionPlace regionPlace; // tells whether we are analyzing the region before, during, or after the region

        protected RegionAnalysisWalker(Compilation compilation, SyntaxTree tree, MethodSymbol method, BoundStatement block, TextSpan region, ThisSymbolCache thisSymbolCache, HashSet<Symbol> unassignedVariables = null, bool trackUnassignmentsInLoops = false)
            : base(compilation, tree, method, block, thisSymbolCache, unassignedVariables, trackUnassignmentsInLoops)
        {
            this.region = region;

            // assign slots to the parameters
            foreach (var parameter in method.Parameters)
            {
                MakeSlot(parameter);
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:13,代码来源:RegionAnalysisWalker.cs


示例9: StatementBinding

 internal StatementBinding(
     BoundStatement boundStatement,
     ImmutableMap<SyntaxNode, BlockBaseBinderContext> blockMap,
     IList<LocalSymbol> locals,
     Dictionary<SyntaxNode, BoundNode> nodeMap,
     DiagnosticBag diagnostics)
 {
     this.boundStatement = boundStatement;
     this.blockMap = blockMap;
     this.locals = locals;
     this.nodeMap = nodeMap;
     this.diagnostics = diagnostics;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:13,代码来源:StatementBinding.cs


示例10: CodeGenerator

        private CodeGenerator(MethodSymbol method,
            BoundStatement block,
            ILBuilder builder,
            PEModuleBuilder module,
            DiagnosticBag diagnostics,
            bool optimize,
            bool emitSequencePoints)
        {
            this.method = method;
            this.block = block;
            this.builder = builder;
            this.module = module;
            this.diagnostics = diagnostics;

            this.noOptimizations = !optimize;
            this.debugInformationKind = module.Compilation.Options.DebugInformationKind;

            if (!this.debugInformationKind.IsValid())
            {
                this.debugInformationKind = DebugInformationKind.None;
            }

            // Special case: always optimize synthesized explicit interface implementation methods
            // (aka bridge methods) with by-ref returns because peverify produces errors if we
            // return a ref local (which the return local will be in such cases).
            if (this.noOptimizations && method.ReturnType is ByRefReturnErrorTypeSymbol)
            {
                Debug.Assert(method is SynthesizedExplicitImplementationMethod);
                this.noOptimizations = false;
            }

            this.emitSequencePoints = emitSequencePoints;

            if (!this.noOptimizations)
            {
                this.block = Optimizer.Optimize(block, out stackLocals);
            }

            Debug.Assert((object)method != null);
            Debug.Assert(block != null);
            Debug.Assert(builder != null);
            Debug.Assert(module != null);

            var asSourceMethod = method as SourceMethodSymbol;
            if ((object)asSourceMethod != null)
            {
                methodBlockSyntax = asSourceMethod.BlockSyntax;
            }
        }
开发者ID:riversky,项目名称:roslyn,代码行数:49,代码来源:CodeGenerator.cs


示例11: RewriteIfStatement

        private static BoundStatement RewriteIfStatement(
            SyntaxNode syntax,  
            BoundExpression rewrittenCondition, 
            BoundStatement rewrittenConsequence, 
            BoundStatement rewrittenAlternativeOpt, 
            bool hasErrors)
        {
            var afterif = new GeneratedLabelSymbol("afterif");

            // if (condition) 
            //   consequence;  
            //
            // becomes
            //
            // GotoIfFalse condition afterif;
            // consequence;
            // afterif:

            if (rewrittenAlternativeOpt == null)
            {
                return BoundStatementList.Synthesized(syntax, 
                    new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, afterif),
                    rewrittenConsequence,
                    new BoundLabelStatement(syntax, afterif));
            }

            // if (condition)
            //     consequence;
            // else 
            //     alternative
            //
            // becomes
            //
            // GotoIfFalse condition alt;
            // consequence
            // goto afterif;
            // alt:
            // alternative;
            // afterif:

            var alt = new GeneratedLabelSymbol("alternative");
            return BoundStatementList.Synthesized(syntax, hasErrors,
                new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, alt),
                rewrittenConsequence,
                new BoundGotoStatement(syntax, afterif),
                new BoundLabelStatement(syntax, alt),
                rewrittenAlternativeOpt,
                new BoundLabelStatement(syntax, afterif));
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:49,代码来源:ControlFlowRewriter.cs


示例12: GenerateMethodBody

            internal override void GenerateMethodBody(TypeCompilationState compilationState, DiagnosticBag diagnostics)
            {
                //  Method body:
                //
                //  {
                //      Object..ctor();
                //      this.backingField_1 = arg1;
                //      ...
                //      this.backingField_N = argN;
                //  }
                SyntheticBoundNodeFactory F = this.CreateBoundNodeFactory(compilationState, diagnostics);

                int paramCount = this.ParameterCount;

                // List of statements
                BoundStatement[] statements = new BoundStatement[paramCount + 2];
                int statementIndex = 0;

                //  explicit base constructor call
                BoundExpression call = MethodCompiler.GenerateObjectConstructorInitializer(this, diagnostics);
                if (call == null)
                {
                    // This may happen if Object..ctor is not found or is unaccessible
                    return;
                }
                statements[statementIndex++] = F.ExpressionStatement(call);

                if (paramCount > 0)
                {
                    AnonymousTypeTemplateSymbol anonymousType = (AnonymousTypeTemplateSymbol)this.ContainingType;
                    Debug.Assert(anonymousType.Properties.Length == paramCount);

                    // Assign fields
                    for (int index = 0; index < this.ParameterCount; index++)
                    {
                        // Generate 'field' = 'parameter' statement
                        statements[statementIndex++] =
                            F.Assignment(F.Field(F.This(), anonymousType.Properties[index].BackingField), F.Parameter(_parameters[index]));
                    }
                }

                // Final return statement
                statements[statementIndex++] = F.Return();

                // Create a bound block 
                F.CloseMethod(F.Block(statements));
            }
开发者ID:GloryChou,项目名称:roslyn,代码行数:47,代码来源:AnonymousTypeMethodBodySynthesizer.cs


示例13: CodeGenerator

        private CodeGenerator(
            MethodSymbol method,
            BoundStatement block,
            ILBuilder builder,
            PEModuleBuilder moduleBuilder,
            DiagnosticBag diagnostics,
            OptimizationLevel optimizations,
            bool emittingPdbs)
        {
            this.method = method;
            this.block = block;
            this.builder = builder;
            this.module = moduleBuilder;
            this.diagnostics = diagnostics;

            // Always optimize synthesized methods that don't contain user code.
            // 
            // Specifically, always optimize synthesized explicit interface implementation methods
            // (aka bridge methods) with by-ref returns because peverify produces errors if we
            // return a ref local (which the return local will be in such cases).

            this.optimizations = method.GenerateDebugInfo ? optimizations : OptimizationLevel.Release;

            // Emit sequence points unless
            // - the PDBs are not being generated
            // - debug information for the method is not generated since the method does not contain
            //   user code that can be stepped thru, or changed during EnC.
            // 
            // This setting only affects generating PDB sequence points, it shall not affect generated IL in any way.
            this.emitPdbSequencePoints = emittingPdbs && method.GenerateDebugInfo;

            if (this.optimizations == OptimizationLevel.Release)
            {
                this.block = Optimizer.Optimize(block, out stackLocals);
            }

            Debug.Assert((object)method != null);
            Debug.Assert(block != null);
            Debug.Assert(builder != null);
            Debug.Assert(moduleBuilder != null);

            var asSourceMethod = method as SourceMethodSymbol;
            if ((object)asSourceMethod != null)
            {
                methodBlockSyntax = asSourceMethod.BlockSyntax;
            }
        }
开发者ID:jerriclynsjohn,项目名称:roslyn,代码行数:47,代码来源:CodeGenerator.cs


示例14: Rewrite

        internal static BoundStatement Rewrite(CSharpCompilation compilation, EENamedTypeSymbol container, HashSet<LocalSymbol> declaredLocals, BoundStatement node, ImmutableArray<LocalSymbol> declaredLocalsArray)
        {
            var builder = ArrayBuilder<BoundStatement>.GetInstance();

            foreach (var local in declaredLocalsArray)
            {
                CreateLocal(compilation, declaredLocals, builder, local, node.Syntax);
            }

            // Rewrite top-level declarations only.
            switch (node.Kind)
            {
                case BoundKind.LocalDeclaration:
                    Debug.Assert(declaredLocals.Contains(((BoundLocalDeclaration)node).LocalSymbol));
                    RewriteLocalDeclaration(builder, (BoundLocalDeclaration)node);
                    break;

                case BoundKind.MultipleLocalDeclarations:
                    foreach (var declaration in ((BoundMultipleLocalDeclarations)node).LocalDeclarations)
                    {
                        Debug.Assert(declaredLocals.Contains(declaration.LocalSymbol));
                        RewriteLocalDeclaration(builder, declaration);
                    }

                    break;

                default:
                    if (builder.Count == 0)
                    {
                        builder.Free();
                        return node;
                    }

                    builder.Add(node);
                    break; 
            }

            return BoundBlock.SynthesizedNoLocals(node.Syntax, builder.ToImmutableAndFree());
        }
开发者ID:tvsonar,项目名称:roslyn,代码行数:39,代码来源:LocalDeclarationRewriter.cs


示例15: Rewrite

 public static BoundStatement Rewrite(BoundStatement src, Dictionary<LocalSymbol, LocalDefUseInfo> info)
 {
     var scheduler = new StackOptimizerPass2(info);
     return (BoundStatement)scheduler.Visit(src);
 }
开发者ID:rosslyn-cuongle,项目名称:roslyn,代码行数:5,代码来源:Optimizer.cs


示例16: EmitStatementAndCountInstructions

 private int EmitStatementAndCountInstructions(BoundStatement statement)
 {
     int n = _builder.InstructionsEmitted;
     this.EmitStatement(statement);
     return _builder.InstructionsEmitted - n;
 }
开发者ID:jkotas,项目名称:roslyn,代码行数:6,代码来源:EmitStatement.cs


示例17: EmitStatement

        private void EmitStatement(BoundStatement statement)
        {
            switch (statement.Kind)
            {
                case BoundKind.Block:
                    EmitBlock((BoundBlock)statement);
                    break;

                case BoundKind.SequencePoint:
                    this.EmitSequencePointStatement((BoundSequencePoint)statement);
                    break;

                case BoundKind.SequencePointWithSpan:
                    this.EmitSequencePointStatement((BoundSequencePointWithSpan)statement);
                    break;

                case BoundKind.ExpressionStatement:
                    EmitExpression(((BoundExpressionStatement)statement).Expression, false);
                    break;

                case BoundKind.StatementList:
                    EmitStatementList((BoundStatementList)statement);
                    break;

                case BoundKind.ReturnStatement:
                    EmitReturnStatement((BoundReturnStatement)statement);
                    break;

                case BoundKind.GotoStatement:
                    EmitGotoStatement((BoundGotoStatement)statement);
                    break;

                case BoundKind.LabelStatement:
                    EmitLabelStatement((BoundLabelStatement)statement);
                    break;

                case BoundKind.ConditionalGoto:
                    EmitConditionalGoto((BoundConditionalGoto)statement);
                    break;

                case BoundKind.ThrowStatement:
                    EmitThrowStatement((BoundThrowStatement)statement);
                    break;

                case BoundKind.TryStatement:
                    EmitTryStatement((BoundTryStatement)statement);
                    break;

                case BoundKind.SwitchStatement:
                    EmitSwitchStatement((BoundSwitchStatement)statement);
                    break;

                case BoundKind.StateMachineScope:
                    EmitStateMachineScope((BoundStateMachineScope)statement);
                    break;

                case BoundKind.NoOpStatement:
                    EmitNoOpStatement((BoundNoOpStatement)statement);
                    break;

                default:
                    // Code gen should not be invoked if there are errors.
                    throw ExceptionUtilities.UnexpectedValue(statement.Kind);
            }

#if DEBUG
            if (_stackLocals == null || _stackLocals.Count == 0)
            {
                _builder.AssertStackEmpty();
            }
#endif
        }
开发者ID:jkotas,项目名称:roslyn,代码行数:72,代码来源:EmitStatement.cs


示例18: FlowAnalysisWalker

        protected FlowAnalysisWalker(
            Compilation compilation,
            SyntaxTree tree,
            MethodSymbol method,
            BoundStatement block,
            ThisSymbolCache thisSymbolCache = null,
            HashSet<Symbol> initiallyAssignedVariables = null,
            bool trackUnassignmentsInLoops = false)
        {
            this.compilation = compilation;
            this.tree = tree;
            this.method = method;
            this.block = block;
            this.thisSymbolCache = thisSymbolCache ?? new ThisSymbolCache();
            this.initiallyAssignedVariables = initiallyAssignedVariables;
            this.loopHeadState = trackUnassignmentsInLoops ? new Dictionary<BoundLoopStatement, FlowAnalysisLocalState>() : null;

            // TODO: mark "this" as not assigned in a struct constructor (unless it has no fields)
            // TODO: accommodate instance variables of a local variable of struct type.
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:20,代码来源:FlowAnalysisWalker.cs


示例19: Analyze

 /// <summary>
 /// Perform flow analysis, reporting all necessary diagnostics.  Returns true if the end of
 /// the body might be reachable..
 /// </summary>
 /// <param name="compilation"></param>
 /// <param name="tree"></param>
 /// <param name="method"></param>
 /// <param name="block"></param>
 /// <param name="diagnostics"></param>
 /// <returns></returns>
 public static bool Analyze(Compilation compilation, SyntaxTree tree, MethodSymbol method, BoundStatement block, DiagnosticBag diagnostics)
 {
     var walker = new FlowAnalysisWalker(compilation, tree, method, block);
     var result = walker.Analyze(diagnostics);
     walker.Free();
     return result;
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:17,代码来源:FlowAnalysisWalker.cs


示例20: Run

        public static void Run(MethodSymbol method, BoundStatement block, ILBuilder builder, PEModuleBuilder module, DiagnosticBag diagnostics, bool optimize, bool emitSequencePoints)
        {
            CodeGenerator generator = new CodeGenerator(method, block, builder, module, diagnostics, optimize, emitSequencePoints);
            generator.Generate();
            Debug.Assert(generator.asyncCatchHandlerOffset < 0);
            Debug.Assert(generator.asyncYieldPoints == null);
            Debug.Assert(generator.asyncResumePoints == null);

            if (!diagnostics.HasAnyErrors())
            {
                builder.Realize();
            }
        }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:13,代码来源:CodeGenerator.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BoundingBox类代码示例发布时间:2022-05-24
下一篇:
C# BoundSequence类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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