本文整理汇总了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;
}
示例2: BoundIfStatement
public BoundIfStatement(BoundExpression condition, BoundStatement consequence, BoundStatement alternativeOpt)
: base(BoundNodeKind.IfStatement)
{
Condition = condition;
Consequence = consequence;
AlternativeOpt = alternativeOpt;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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));
}
示例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));
}
示例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;
}
}
示例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());
}
示例15: Rewrite
public static BoundStatement Rewrite(BoundStatement src, Dictionary<LocalSymbol, LocalDefUseInfo> info)
{
var scheduler = new StackOptimizerPass2(info);
return (BoundStatement)scheduler.Visit(src);
}