Browse Source

Add DecompilerSettings reference to StatementBuilder and ExpressionBuilder

pull/863/head
Siegfried Pammer 8 years ago
parent
commit
8fed5b11f7
  1. 2
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 6
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
  3. 6
      ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

2
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -657,7 +657,7 @@ namespace ICSharpCode.Decompiler.CSharp
} }
AddDefinesForConditionalAttributes(function); AddDefinesForConditionalAttributes(function);
var statementBuilder = new StatementBuilder(specializingTypeSystem, decompilationContext, method, function, CancellationToken); var statementBuilder = new StatementBuilder(specializingTypeSystem, decompilationContext, method, function, settings, CancellationToken);
var body = statementBuilder.ConvertAsBlock(function.Body); var body = statementBuilder.ConvertAsBlock(function.Body);
entityDecl.AddChild(body, Roles.Body); entityDecl.AddChild(body, Roles.Body);

6
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -65,13 +65,15 @@ namespace ICSharpCode.Decompiler.CSharp
internal readonly ICompilation compilation; internal readonly ICompilation compilation;
internal readonly CSharpResolver resolver; internal readonly CSharpResolver resolver;
readonly TypeSystemAstBuilder astBuilder; readonly TypeSystemAstBuilder astBuilder;
readonly DecompilerSettings settings;
readonly CancellationToken cancellationToken; readonly CancellationToken cancellationToken;
public ExpressionBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, CancellationToken cancellationToken) public ExpressionBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, DecompilerSettings settings, CancellationToken cancellationToken)
{ {
Debug.Assert(decompilationContext != null); Debug.Assert(decompilationContext != null);
this.typeSystem = typeSystem; this.typeSystem = typeSystem;
this.decompilationContext = decompilationContext; this.decompilationContext = decompilationContext;
this.settings = settings;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
this.compilation = decompilationContext.Compilation; this.compilation = decompilationContext.Compilation;
this.resolver = new CSharpResolver(new CSharpTypeResolveContext(compilation.MainAssembly, null, decompilationContext.CurrentTypeDefinition, decompilationContext.CurrentMember)); this.resolver = new CSharpResolver(new CSharpTypeResolveContext(compilation.MainAssembly, null, decompilationContext.CurrentTypeDefinition, decompilationContext.CurrentMember));
@ -959,7 +961,7 @@ namespace ICSharpCode.Decompiler.CSharp
AnonymousMethodExpression ame = new AnonymousMethodExpression(); AnonymousMethodExpression ame = new AnonymousMethodExpression();
ame.Parameters.AddRange(MakeParameters(method, function)); ame.Parameters.AddRange(MakeParameters(method, function));
ame.HasParameterList = true; ame.HasParameterList = true;
StatementBuilder builder = new StatementBuilder(typeSystem.GetSpecializingTypeSystem(new SimpleTypeResolveContext(method)), this.decompilationContext, method, function, cancellationToken); StatementBuilder builder = new StatementBuilder(typeSystem.GetSpecializingTypeSystem(new SimpleTypeResolveContext(method)), this.decompilationContext, method, function, settings, cancellationToken);
var body = builder.ConvertAsBlock(function.Body); var body = builder.ConvertAsBlock(function.Body);
bool isLambda = false; bool isLambda = false;
bool isMultiLineLambda = false; bool isMultiLineLambda = false;

6
ICSharpCode.Decompiler/CSharp/StatementBuilder.cs

@ -34,14 +34,16 @@ namespace ICSharpCode.Decompiler.CSharp
internal readonly ExpressionBuilder exprBuilder; internal readonly ExpressionBuilder exprBuilder;
readonly ILFunction currentFunction; readonly ILFunction currentFunction;
readonly IMethod currentMethod; readonly IMethod currentMethod;
readonly DecompilerSettings settings;
readonly CancellationToken cancellationToken; readonly CancellationToken cancellationToken;
public StatementBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, IMethod currentMethod, ILFunction currentFunction, CancellationToken cancellationToken) public StatementBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, IMethod currentMethod, ILFunction currentFunction, DecompilerSettings settings, CancellationToken cancellationToken)
{ {
Debug.Assert(typeSystem != null && decompilationContext != null && currentMethod != null); Debug.Assert(typeSystem != null && decompilationContext != null && currentMethod != null);
this.exprBuilder = new ExpressionBuilder(typeSystem, decompilationContext, cancellationToken); this.exprBuilder = new ExpressionBuilder(typeSystem, decompilationContext, settings, cancellationToken);
this.currentFunction = currentFunction; this.currentFunction = currentFunction;
this.currentMethod = currentMethod; this.currentMethod = currentMethod;
this.settings = settings;
this.cancellationToken = cancellationToken; this.cancellationToken = cancellationToken;
} }

Loading…
Cancel
Save