|
|
@ -47,6 +47,8 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
internal IType currentResultType; |
|
|
|
internal IType currentResultType; |
|
|
|
internal bool currentIsIterator; |
|
|
|
internal bool currentIsIterator; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal bool EmitAsRefReadOnly; |
|
|
|
|
|
|
|
|
|
|
|
public StatementBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, |
|
|
|
public StatementBuilder(IDecompilerTypeSystem typeSystem, ITypeResolveContext decompilationContext, |
|
|
|
ILFunction currentFunction, DecompilerSettings settings, DecompileRun decompileRun, |
|
|
|
ILFunction currentFunction, DecompilerSettings settings, DecompileRun decompileRun, |
|
|
|
CancellationToken cancellationToken) |
|
|
|
CancellationToken cancellationToken) |
|
|
@ -1367,6 +1369,32 @@ namespace ICSharpCode.Decompiler.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
var blockStatement = ConvertBlockContainer(new BlockStatement(), container, container.Blocks, isLoop); |
|
|
|
var blockStatement = ConvertBlockContainer(new BlockStatement(), container, container.Blocks, isLoop); |
|
|
|
DeclareLocalFunctions(currentFunction, container, blockStatement); |
|
|
|
DeclareLocalFunctions(currentFunction, container, blockStatement); |
|
|
|
|
|
|
|
if (currentFunction.Body == container) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (EmitAsRefReadOnly) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var methodDecl = new MethodDeclaration(); |
|
|
|
|
|
|
|
if (settings.StaticLocalFunctions) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
methodDecl.Modifiers = Modifiers.Static; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methodDecl.ReturnType = new ComposedType() { HasReadOnlySpecifier = true, HasRefSpecifier = true, BaseType = new SimpleType("T") }; |
|
|
|
|
|
|
|
methodDecl.Name = "ILSpyHelper_AsRefReadOnly"; |
|
|
|
|
|
|
|
methodDecl.TypeParameters.Add(new TypeParameterDeclaration("T")); |
|
|
|
|
|
|
|
methodDecl.Parameters.Add(new ParameterDeclaration { ParameterModifier = ReferenceKind.In, Type = new SimpleType("T"), Name = "temp" }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
methodDecl.Body = new BlockStatement(); |
|
|
|
|
|
|
|
methodDecl.Body.AddChild(new Comment( |
|
|
|
|
|
|
|
"ILSpy generated this function to help ensure overload resolution can pick the overload using 'in'"), |
|
|
|
|
|
|
|
Roles.Comment); |
|
|
|
|
|
|
|
methodDecl.Body.Add(new ReturnStatement(new DirectionExpression(FieldDirection.Ref, new IdentifierExpression("temp")))); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
blockStatement.Statements.Add( |
|
|
|
|
|
|
|
new LocalFunctionDeclarationStatement(methodDecl) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return blockStatement; |
|
|
|
return blockStatement; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|