当前位置: 首页>>代码示例>>C#>>正文


C# BoundStatement类代码示例

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


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


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