Browse Source

Use ConcurrentDictionary

pull/191/merge
Eusebiu Marcu 15 years ago
parent
commit
31c1527d1a
  1. 2
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 6
      ICSharpCode.Decompiler/Ast/CSharpCodeMapping.cs
  3. 12
      ICSharpCode.Decompiler/CodeMappings.cs
  4. 5
      ICSharpCode.Decompiler/Disassembler/ILCodeMapping.cs
  5. 4
      ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs
  6. 130
      ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj
  7. 8
      ILSpy.sln

2
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -125,7 +125,7 @@ namespace Decompiler @@ -125,7 +125,7 @@ namespace Decompiler
{
// create IL code mappings - used for debugger
if (!CSharpCodeMapping.SourceCodeMappings.ContainsKey(typeDef.FullName)) {
CSharpCodeMapping.SourceCodeMappings.Add(typeDef.FullName, new List<MethodMapping>());
CSharpCodeMapping.SourceCodeMappings.TryAdd(typeDef.FullName, new List<MethodMapping>());
} else {
CSharpCodeMapping.SourceCodeMappings[typeDef.FullName].Clear();
}

6
ICSharpCode.Decompiler/Ast/CSharpCodeMapping.cs

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using ICSharpCode.Decompiler;
namespace Decompiler
@ -12,12 +14,12 @@ namespace Decompiler @@ -12,12 +14,12 @@ namespace Decompiler
/// </summary>
public static class CSharpCodeMapping
{
static Dictionary<string, List<MethodMapping>> codeMappings = new Dictionary<string, List<MethodMapping>>();
static ConcurrentDictionary<string, List<MethodMapping>> codeMappings = new ConcurrentDictionary<string, List<MethodMapping>>();
/// <summary>
/// Stores the source codes mappings: CSharp &lt;-&gt; editor lines
/// </summary>
public static Dictionary<string, List<MethodMapping>> SourceCodeMappings {
public static ConcurrentDictionary<string, List<MethodMapping>> SourceCodeMappings {
get { return codeMappings; }
set { codeMappings = value; }
}

12
ICSharpCode.Decompiler/CodeMappings.cs

@ -2,7 +2,9 @@ @@ -2,7 +2,9 @@
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Decompiler;
using ICSharpCode.Decompiler.Disassembler;
using Mono.Cecil;
@ -39,9 +41,9 @@ namespace ICSharpCode.Decompiler @@ -39,9 +41,9 @@ namespace ICSharpCode.Decompiler
public static class CodeMappings
{
public static Dictionary<string, List<MethodMapping>> GetStorage(DecompiledLanguages language)
public static ConcurrentDictionary<string, List<MethodMapping>> GetStorage(DecompiledLanguages language)
{
Dictionary<string, List<MethodMapping>> storage = null;
ConcurrentDictionary<string, List<MethodMapping>> storage = null;
switch (language) {
case DecompiledLanguages.IL:
@ -64,7 +66,7 @@ namespace ICSharpCode.Decompiler @@ -64,7 +66,7 @@ namespace ICSharpCode.Decompiler
/// <param name="sourceCodeMappings">Source code mapping storage.</param>
public static MethodMapping CreateCodeMapping(
this MethodDefinition method,
Dictionary<string, List<MethodMapping>> sourceCodeMappings)
ConcurrentDictionary<string, List<MethodMapping>> sourceCodeMappings)
{
// create IL code mappings - used in debugger
MethodMapping currentMethodMapping = null;
@ -92,7 +94,7 @@ namespace ICSharpCode.Decompiler @@ -92,7 +94,7 @@ namespace ICSharpCode.Decompiler
/// <param name="metadataToken">Metadata token.</param>
/// <returns></returns>
public static SourceCodeMapping GetInstructionByTypeAndLine(
this Dictionary<string, List<MethodMapping>> codeMappings,
this ConcurrentDictionary<string, List<MethodMapping>> codeMappings,
string typeName,
int lineNumber,
out uint metadataToken)
@ -129,7 +131,7 @@ namespace ICSharpCode.Decompiler @@ -129,7 +131,7 @@ namespace ICSharpCode.Decompiler
/// <param name="typeName">Type name.</param>
/// <param name="line">Line number.</param>
public static void GetSourceCodeFromMetadataTokenAndOffset(
this Dictionary<string, List<MethodMapping>> codeMappings,
this ConcurrentDictionary<string, List<MethodMapping>> codeMappings,
uint token,
int ilOffset,
out string typeName,

5
ICSharpCode.Decompiler/Disassembler/ILCodeMapping.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Disassembler
@ -11,12 +12,12 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -11,12 +12,12 @@ namespace ICSharpCode.Decompiler.Disassembler
/// </summary>
public static class ILCodeMapping
{
static Dictionary<string, List<MethodMapping>> codeMappings = new Dictionary<string, List<MethodMapping>>();
static ConcurrentDictionary<string, List<MethodMapping>> codeMappings = new ConcurrentDictionary<string, List<MethodMapping>>();
/// <summary>
/// Stores the source codes mappings: IL &lt;-&gt; editor lines
/// </summary>
public static Dictionary<string, List<MethodMapping>> SourceCodeMappings {
public static ConcurrentDictionary<string, List<MethodMapping>> SourceCodeMappings {
get { return codeMappings; }
set { codeMappings = value; }
}

4
ICSharpCode.Decompiler/Disassembler/ReflectionDisassembler.cs

@ -314,7 +314,9 @@ namespace ICSharpCode.Decompiler.Disassembler @@ -314,7 +314,9 @@ namespace ICSharpCode.Decompiler.Disassembler
{
// create IL code mappings - used for debugger
if (!ILCodeMapping.SourceCodeMappings.ContainsKey(type.FullName)) {
ILCodeMapping.SourceCodeMappings.Add(type.FullName, new List<MethodMapping>());
ILCodeMapping.SourceCodeMappings.TryAdd(type.FullName, new List<MethodMapping>());
} else {
ILCodeMapping.SourceCodeMappings.Clear();
}
// start writing IL

130
ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj

@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@
<<<<<<< HEAD
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
@ -52,8 +51,8 @@ @@ -52,8 +51,8 @@
<ItemGroup>
<Compile Include="Ast\AstBuilder.cs" />
<Compile Include="Ast\AstMethodBodyBuilder.cs" />
<Compile Include="Ast\CSharpCodeMapping.cs" />
<Compile Include="Ast\CommentStatement.cs" />
<Compile Include="Ast\CSharpCodeMapping.cs" />
<Compile Include="Ast\DecompilerContext.cs" />
<Compile Include="Ast\NameVariables.cs" />
<Compile Include="Ast\NRefactoryExtensions.cs" />
@ -72,132 +71,8 @@ @@ -72,132 +71,8 @@
<Compile Include="CecilExtensions.cs" />
<Compile Include="CodeMappings.cs" />
<Compile Include="DecompilerException.cs" />
<Compile Include="Disassembler\ILCodeMapping.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
<Compile Include="Disassembler\ILStructure.cs" />
<Compile Include="Disassembler\MethodBodyDisassembler.cs" />
<Compile Include="Disassembler\ReflectionDisassembler.cs" />
<Compile Include="FlowAnalysis\ControlFlowEdge.cs" />
<Compile Include="FlowAnalysis\ControlFlowGraph.cs" />
<Compile Include="FlowAnalysis\ControlFlowGraphBuilder.cs" />
<Compile Include="FlowAnalysis\ControlFlowNode.cs" />
<Compile Include="FlowAnalysis\ControlStructureDetector.cs" />
<Compile Include="FlowAnalysis\OpCodeInfo.cs" />
<Compile Include="FlowAnalysis\SimplifyByRefCalls.cs" />
<Compile Include="FlowAnalysis\SsaBlock.cs" />
<Compile Include="FlowAnalysis\SsaForm.cs" />
<Compile Include="FlowAnalysis\SsaFormBuilder.cs" />
<Compile Include="FlowAnalysis\SsaInstruction.cs" />
<Compile Include="FlowAnalysis\SsaOptimization.cs" />
<Compile Include="FlowAnalysis\SsaVariable.cs" />
<Compile Include="FlowAnalysis\TransformToSsa.cs" />
<Compile Include="GraphVizGraph.cs" />
<Compile Include="ILAst\ILAstBuilder.cs" />
<Compile Include="ILAst\ILAstOptimizer.cs" />
<Compile Include="ILAst\ILAstTypes.cs" />
<Compile Include="ILAst\ILCodes.cs" />
<Compile Include="ILAst\TypeAnalysis.cs" />
<Compile Include="ITextOutput.cs" />
<Compile Include="Options.cs" />
<Compile Include="PlainTextOutput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<None Include="Properties\AssemblyInfo.template.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mono.Cecil\Mono.Cecil.csproj">
<Project>{D68133BD-1E63-496E-9EDE-4FBDBF77B486}</Project>
<Name>Mono.Cecil</Name>
</ProjectReference>
<ProjectReference Include="..\NRefactory\ICSharpCode.NRefactory\ICSharpCode.NRefactory.csproj">
<Project>{3B2A5653-EC97-4001-BB9B-D90F1AF2C371}</Project>
<Name>ICSharpCode.NRefactory</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Ast" />
<Folder Include="Ast\Transforms" />
<Folder Include="Disassembler" />
<Folder Include="ILAst" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<Target Name="BeforeBuild">
<MSBuild Projects="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\UpdateAssemblyInfo.csproj" Targets="Build" Properties="Configuration=Debug" />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe --branchname $(BranchName)" Timeout="60000" Condition=" '$(BranchName)' != '' " />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe" Timeout="60000" Condition=" '$(BranchName)' == '' " />
</Target>
=======
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
<PropertyGroup>
<ProjectGuid>{984CC812-9470-4A13-AFF9-CC44068D666C}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.Decompiler</RootNamespace>
<AssemblyName>ICSharpCode.Decompiler</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Ast\AstBuilder.cs" />
<Compile Include="Ast\AstMethodBodyBuilder.cs" />
<Compile Include="Ast\CommentStatement.cs" />
<Compile Include="Ast\DecompilerContext.cs" />
<Compile Include="Ast\NameVariables.cs" />
<Compile Include="Ast\NRefactoryExtensions.cs" />
<Compile Include="Ast\TextOutputFormatter.cs" />
<Compile Include="Ast\Transforms\ContextTrackingVisitor.cs" />
<Compile Include="Ast\Transforms\ConvertConstructorCallIntoInitializer.cs" />
<Compile Include="Ast\Transforms\DelegateConstruction.cs" />
<Compile Include="Ast\Transforms\ReplaceMethodCallsWithOperators.cs" />
<Compile Include="Ast\Transforms\PushNegation.cs" />
<Compile Include="Ast\Transforms\RemoveDeadLabels.cs" />
<Compile Include="Ast\Transforms\RemoveEmptyElseBody.cs" />
<Compile Include="Ast\Transforms\RemoveGotos.cs" />
<Compile Include="Ast\Transforms\RestoreLoop.cs" />
<Compile Include="Ast\Transforms\TransformationPipeline.cs" />
<Compile Include="Ast\Transforms\UsingStatementTransform.cs" />
<Compile Include="CecilExtensions.cs" />
<Compile Include="DecompilerException.cs" />
<Compile Include="Disassembler\DisassemblerHelpers.cs" />
<Compile Include="Disassembler\ILCodeMapping.cs" />
<Compile Include="Disassembler\ILStructure.cs" />
<Compile Include="Disassembler\MethodBodyDisassembler.cs" />
<Compile Include="Disassembler\ReflectionDisassembler.cs" />
@ -250,5 +125,4 @@ @@ -250,5 +125,4 @@
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe --branchname $(BranchName)" Timeout="60000" Condition=" '$(BranchName)' != '' " />
<Exec WorkingDirectory="$(MSBuildProjectDirectory)\..\BuildTools\UpdateAssemblyInfo\bin\Debug" Command="UpdateAssemblyInfo.exe" Timeout="60000" Condition=" '$(BranchName)' == '' " />
</Target>
>>>>>>> 758f18c73f2667591014666e73ee139fe449c022
</Project>

8
ILSpy.sln

@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
# SharpDevelop 4.1.0.7302-alpha
# SharpDevelop 4.1.0.7279-alpha
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Debugger", "Debugger", "{1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy.Debugger", "Debugger\ILSpy.Debugger\ILSpy.Debugger.csproj", "{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Debugger.Core", "Debugger\Debugger.Core\Debugger.Core.csproj", "{1D18D788-F7EE-4585-A23B-34DC8EC63CB8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ILSpy", "ILSpy\ILSpy.csproj", "{1E85EFF9-E370-4683-83E4-8A3D063FF791}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.TreeView", "SharpTreeView\ICSharpCode.TreeView.csproj", "{DDE2A481-8271-4EAC-A330-8FA6A38D13D1}"
@ -106,7 +106,7 @@ Global @@ -106,7 +106,7 @@ Global
{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A}.Release|Any CPU.ActiveCfg = Release|x86
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
{1D18D788-F7EE-4585-A23B-34DC8EC63CB8} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
{6D3D0F0D-348D-456A-A6ED-E9BD5EFABB6A} = {1DEB3B4E-03AC-437C-821D-B09FBFCC3E5B}
EndGlobalSection
EndGlobal

Loading…
Cancel
Save