mirror of https://github.com/icsharpcode/ILSpy.git
Browse Source
Conflicts: ICSharpCode.Decompiler/ICSharpCode.Decompiler.csproj ILSpy.SharpDevelop.LGPL/ILSpy.SharpDevelop.LGPL.csprojpull/205/head
208 changed files with 10314 additions and 955 deletions
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
using System; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.Decompiler.Ast |
||||
{ |
||||
public class TypeInformation |
||||
{ |
||||
public readonly TypeReference InferredType; |
||||
|
||||
public TypeInformation(TypeReference inferredType) |
||||
{ |
||||
this.InferredType = inferredType; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<UserControl |
||||
x:Class="ICSharpCode.ILSpy.Controls.ResourceStringTable" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<UserControl.CommandBindings> |
||||
<CommandBinding Command="ApplicationCommands.Copy" |
||||
Executed="ExecuteCopy" |
||||
CanExecute="CanExecuteCopy"/> |
||||
</UserControl.CommandBindings> |
||||
<ListView |
||||
Name="resourceListView" |
||||
SelectionMode="Extended"> |
||||
<ListView.View> |
||||
<GridView |
||||
AllowsColumnReorder="False"> |
||||
<GridView.Columns> |
||||
<GridViewColumn |
||||
Header="Resource id" |
||||
DisplayMemberBinding="{Binding Key}" /> |
||||
<GridViewColumn |
||||
Header="Resource value" |
||||
DisplayMemberBinding="{Binding Value}" /> |
||||
</GridView.Columns> |
||||
</GridView> |
||||
</ListView.View> |
||||
</ListView> |
||||
</UserControl> |
||||
@ -0,0 +1,51 @@
@@ -0,0 +1,51 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Ronny Klier |
||||
* Date: 31.05.2011 |
||||
* Time: 00:13 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Text; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Documents; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
|
||||
namespace ICSharpCode.ILSpy.Controls |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for ResourceStringTable.xaml
|
||||
/// </summary>
|
||||
public partial class ResourceStringTable : UserControl |
||||
{ |
||||
public ResourceStringTable(IEnumerable strings) |
||||
{ |
||||
InitializeComponent(); |
||||
// set size to fit decompiler window
|
||||
// TODO: there should be a more transparent way to do this
|
||||
MaxWidth = MainWindow.Instance.mainPane.ActualWidth-20; |
||||
MaxHeight = MainWindow.Instance.mainPane.ActualHeight-100; |
||||
resourceListView.ItemsSource = strings; |
||||
} |
||||
|
||||
void ExecuteCopy(object sender, ExecutedRoutedEventArgs args) |
||||
{ |
||||
StringBuilder sb = new StringBuilder(); |
||||
foreach (var item in resourceListView.SelectedItems) |
||||
{ |
||||
sb.AppendLine(item.ToString()); |
||||
} |
||||
Clipboard.SetText(sb.ToString()); |
||||
} |
||||
|
||||
void CanExecuteCopy(object sender, CanExecuteRoutedEventArgs args) |
||||
{ |
||||
args.CanExecute = true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.TreeView; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for entity nodes.
|
||||
/// </summary>
|
||||
public abstract class AnalyzerEntityTreeNode : AnalyzerTreeNode, IMemberTreeNode |
||||
{ |
||||
public abstract MemberReference Member { get; } |
||||
|
||||
public override void ActivateItem(System.Windows.RoutedEventArgs e) |
||||
{ |
||||
e.Handled = true; |
||||
MainWindow.Instance.JumpToReference(this.Member); |
||||
} |
||||
|
||||
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies) |
||||
{ |
||||
foreach (LoadedAssembly asm in removedAssemblies) { |
||||
if (this.Member.Module.Assembly == asm.AssemblyDefinition) |
||||
return false; // remove this node
|
||||
} |
||||
this.Children.RemoveAll( |
||||
delegate(SharpTreeNode n) { |
||||
AnalyzerTreeNode an = n as AnalyzerTreeNode; |
||||
return an == null || !an.HandleAssemblyListChanged(removedAssemblies, addedAssemblies); |
||||
}); |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Threading; |
||||
|
||||
namespace ICSharpCode.ILSpy.TreeNodes.Analyzer |
||||
{ |
||||
/// <summary>
|
||||
/// Base class for analyzer nodes that perform a search.
|
||||
/// </summary>
|
||||
public abstract class AnalyzerSearchTreeNode : AnalyzerTreeNode |
||||
{ |
||||
private readonly ThreadingSupport threading = new ThreadingSupport(); |
||||
|
||||
protected AnalyzerSearchTreeNode() |
||||
{ |
||||
this.LazyLoading = true; |
||||
} |
||||
|
||||
public override object Icon |
||||
{ |
||||
get { return Images.Search; } |
||||
} |
||||
|
||||
protected override void LoadChildren() |
||||
{ |
||||
threading.LoadChildren(this, FetchChildren); |
||||
} |
||||
|
||||
protected abstract IEnumerable<AnalyzerTreeNode> FetchChildren(CancellationToken ct); |
||||
|
||||
protected override void OnIsVisibleChanged() |
||||
{ |
||||
base.OnIsVisibleChanged(); |
||||
if (!this.IsVisible && threading.IsRunning) { |
||||
this.LazyLoading = true; |
||||
threading.Cancel(); |
||||
this.Children.Clear(); |
||||
} |
||||
} |
||||
|
||||
public override bool HandleAssemblyListChanged(ICollection<LoadedAssembly> removedAssemblies, ICollection<LoadedAssembly> addedAssemblies) |
||||
{ |
||||
this.LazyLoading = true; |
||||
threading.Cancel(); |
||||
this.Children.Clear(); |
||||
return true; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,152 @@
@@ -0,0 +1,152 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Ast; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.VB.Visitors; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.VB |
||||
{ |
||||
public class ILSpyEnvironmentProvider : IEnvironmentProvider |
||||
{ |
||||
public string RootNamespace { |
||||
get { |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
ITypeResolveContext context; |
||||
|
||||
CecilLoader loader = new CecilLoader(false); |
||||
|
||||
public ILSpyEnvironmentProvider(ITypeResolveContext context) |
||||
{ |
||||
this.context = context; |
||||
} |
||||
|
||||
public ITypeResolveContext ResolveContext { |
||||
get { |
||||
return context; |
||||
} |
||||
} |
||||
|
||||
public string GetTypeNameForAttribute(ICSharpCode.NRefactory.CSharp.Attribute attribute) |
||||
{ |
||||
return attribute.Type.Annotations |
||||
.OfType<Mono.Cecil.MemberReference>() |
||||
.First() |
||||
.FullName; |
||||
} |
||||
|
||||
public IType ResolveType(NRefactory.VB.Ast.AstType type, NRefactory.VB.Ast.TypeDeclaration entity = null) |
||||
{ |
||||
var annotation = type.Annotation<TypeReference>(); |
||||
if (annotation == null ) |
||||
return null; |
||||
|
||||
IEntity current = null; |
||||
if (entity != null) { |
||||
var typeInfo = entity.Annotation<TypeReference>(); |
||||
current = loader.ReadTypeReference(typeInfo).Resolve(context).GetDefinition(); |
||||
} |
||||
|
||||
return loader.ReadTypeReference(annotation, entity: current).Resolve(context); |
||||
} |
||||
|
||||
public ClassType GetClassTypeForAstType(ICSharpCode.NRefactory.CSharp.AstType type) |
||||
{ |
||||
var definition = type.Annotations.OfType<TypeReference>().First().ResolveOrThrow(); |
||||
|
||||
if (definition.IsClass) |
||||
return ClassType.Class; |
||||
if (definition.IsInterface) |
||||
return ClassType.Interface; |
||||
if (definition.IsEnum) |
||||
return ClassType.Enum; |
||||
if (definition.IsFunctionPointer) |
||||
return ClassType.Delegate; |
||||
if (definition.IsValueType) |
||||
return ClassType.Struct; |
||||
|
||||
return ClassType.Module; |
||||
} |
||||
|
||||
public TypeCode ResolveExpression(ICSharpCode.NRefactory.CSharp.Expression expression) |
||||
{ |
||||
var annotation = expression.Annotations.OfType<TypeInformation>().FirstOrDefault(); |
||||
|
||||
if (annotation == null) |
||||
return TypeCode.Object; |
||||
|
||||
var definition = annotation.InferredType.Resolve(); |
||||
|
||||
if (definition == null) |
||||
return TypeCode.Object; |
||||
|
||||
switch (definition.FullName) { |
||||
case "System.String": |
||||
return TypeCode.String; |
||||
default: |
||||
|
||||
break; |
||||
} |
||||
|
||||
return TypeCode.Object; |
||||
} |
||||
|
||||
public Nullable<bool> IsReferenceType(ICSharpCode.NRefactory.CSharp.Expression expression) |
||||
{ |
||||
if (expression is ICSharpCode.NRefactory.CSharp.NullReferenceExpression) |
||||
return true; |
||||
|
||||
var annotation = expression.Annotations.OfType<TypeInformation>().FirstOrDefault(); |
||||
|
||||
if (annotation == null) |
||||
return null; |
||||
|
||||
var definition = annotation.InferredType.Resolve(); |
||||
|
||||
if (definition == null) |
||||
return null; |
||||
|
||||
return !definition.IsValueType; |
||||
} |
||||
|
||||
public IEnumerable<NRefactory.VB.Ast.InterfaceMemberSpecifier> CreateMemberSpecifiersForInterfaces(IEnumerable<NRefactory.VB.Ast.AstType> interfaces) |
||||
{ |
||||
foreach (var type in interfaces) { |
||||
var def = type.Annotation<TypeReference>().Resolve(); |
||||
if (def == null) continue; |
||||
foreach (var method in def.Methods.Where(m => !m.Name.StartsWith("get_") && !m.Name.StartsWith("set_"))) { |
||||
yield return new NRefactory.VB.Ast.InterfaceMemberSpecifier((NRefactory.VB.Ast.AstType)type.Clone(), method.Name); |
||||
} |
||||
|
||||
foreach (var property in def.Properties) { |
||||
yield return new NRefactory.VB.Ast.InterfaceMemberSpecifier((NRefactory.VB.Ast.AstType)type.Clone(), property.Name); |
||||
} |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
||||
@ -0,0 +1,523 @@
@@ -0,0 +1,523 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.ComponentModel.Composition; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Resources; |
||||
using System.Text; |
||||
using System.Threading.Tasks; |
||||
using System.Xml; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.Ast; |
||||
using ICSharpCode.Decompiler.Ast.Transforms; |
||||
using ICSharpCode.ILSpy.XmlDoc; |
||||
using ICSharpCode.NRefactory.TypeSystem; |
||||
using ICSharpCode.NRefactory.TypeSystem.Implementation; |
||||
using ICSharpCode.NRefactory.VB; |
||||
using ICSharpCode.NRefactory.VB.Visitors; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.VB |
||||
{ |
||||
/// <summary>
|
||||
/// Decompiler logic for VB.
|
||||
/// </summary>
|
||||
[Export(typeof(Language))] |
||||
public class VBLanguage : Language |
||||
{ |
||||
Predicate<IAstTransform> transformAbortCondition = null; |
||||
bool showAllMembers = false; |
||||
|
||||
public VBLanguage() |
||||
{ |
||||
} |
||||
|
||||
public override string Name { |
||||
get { return "VB"; } |
||||
} |
||||
|
||||
public override string FileExtension { |
||||
get { return ".vb"; } |
||||
} |
||||
|
||||
public override string ProjectFileExtension { |
||||
get { return ".vbproj"; } |
||||
} |
||||
|
||||
public override void WriteCommentLine(ITextOutput output, string comment) |
||||
{ |
||||
output.WriteLine("' " + comment); |
||||
} |
||||
|
||||
public override void DecompileAssembly(LoadedAssembly assembly, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
if (options.FullDecompilation && options.SaveAsProjectDirectory != null) { |
||||
HashSet<string> directories = new HashSet<string>(StringComparer.OrdinalIgnoreCase); |
||||
var files = WriteCodeFilesInProject(assembly.AssemblyDefinition, options, directories).ToList(); |
||||
files.AddRange(WriteResourceFilesInProject(assembly, options, directories)); |
||||
WriteProjectFile(new TextOutputWriter(output), files, assembly.AssemblyDefinition.MainModule); |
||||
} else { |
||||
base.DecompileAssembly(assembly, output, options); |
||||
output.WriteLine(); |
||||
ModuleDefinition mainModule = assembly.AssemblyDefinition.MainModule; |
||||
if (mainModule.EntryPoint != null) { |
||||
output.Write("' Entry point: "); |
||||
output.WriteReference(mainModule.EntryPoint.DeclaringType.FullName + "." + mainModule.EntryPoint.Name, mainModule.EntryPoint); |
||||
output.WriteLine(); |
||||
} |
||||
switch (mainModule.Architecture) { |
||||
case TargetArchitecture.I386: |
||||
if ((mainModule.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
||||
WriteCommentLine(output, "Architecture: x86"); |
||||
else |
||||
WriteCommentLine(output, "Architecture: AnyCPU"); |
||||
break; |
||||
case TargetArchitecture.AMD64: |
||||
WriteCommentLine(output, "Architecture: x64"); |
||||
break; |
||||
case TargetArchitecture.IA64: |
||||
WriteCommentLine(output, "Architecture: Itanium-64"); |
||||
break; |
||||
} |
||||
if ((mainModule.Attributes & ModuleAttributes.ILOnly) == 0) { |
||||
WriteCommentLine(output, "This assembly contains unmanaged code."); |
||||
} |
||||
switch (mainModule.Runtime) { |
||||
case TargetRuntime.Net_1_0: |
||||
WriteCommentLine(output, "Runtime: .NET 1.0"); |
||||
break; |
||||
case TargetRuntime.Net_1_1: |
||||
WriteCommentLine(output, "Runtime: .NET 1.1"); |
||||
break; |
||||
case TargetRuntime.Net_2_0: |
||||
WriteCommentLine(output, "Runtime: .NET 2.0"); |
||||
break; |
||||
case TargetRuntime.Net_4_0: |
||||
WriteCommentLine(output, "Runtime: .NET 4.0"); |
||||
break; |
||||
} |
||||
output.WriteLine(); |
||||
|
||||
// don't automatically load additional assemblies when an assembly node is selected in the tree view
|
||||
using (options.FullDecompilation ? null : LoadedAssembly.DisableAssemblyLoad()) { |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.AssemblyDefinition.MainModule); |
||||
codeDomBuilder.AddAssembly(assembly.AssemblyDefinition, onlyAssemblyLevel: !options.FullDecompilation); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, assembly.AssemblyDefinition.MainModule); |
||||
} |
||||
} |
||||
OnDecompilationFinished(null); |
||||
} |
||||
|
||||
static readonly string[] projectImports = new[] { |
||||
"System.Diagnostics", |
||||
"Microsoft.VisualBasic", |
||||
"System", |
||||
"System.Collections", |
||||
"System.Collections.Generic" |
||||
}; |
||||
|
||||
#region WriteProjectFile
|
||||
void WriteProjectFile(TextWriter writer, IEnumerable<Tuple<string, string>> files, ModuleDefinition module) |
||||
{ |
||||
const string ns = "http://schemas.microsoft.com/developer/msbuild/2003"; |
||||
string platformName; |
||||
switch (module.Architecture) { |
||||
case TargetArchitecture.I386: |
||||
if ((module.Attributes & ModuleAttributes.Required32Bit) == ModuleAttributes.Required32Bit) |
||||
platformName = "x86"; |
||||
else |
||||
platformName = "AnyCPU"; |
||||
break; |
||||
case TargetArchitecture.AMD64: |
||||
platformName = "x64"; |
||||
break; |
||||
case TargetArchitecture.IA64: |
||||
platformName = "Itanium"; |
||||
break; |
||||
default: |
||||
throw new NotSupportedException("Invalid value for TargetArchitecture"); |
||||
} |
||||
using (XmlTextWriter w = new XmlTextWriter(writer)) { |
||||
w.Formatting = Formatting.Indented; |
||||
w.WriteStartDocument(); |
||||
w.WriteStartElement("Project", ns); |
||||
w.WriteAttributeString("ToolsVersion", "4.0"); |
||||
w.WriteAttributeString("DefaultTargets", "Build"); |
||||
|
||||
w.WriteStartElement("PropertyGroup"); |
||||
w.WriteElementString("ProjectGuid", Guid.NewGuid().ToString().ToUpperInvariant()); |
||||
|
||||
w.WriteStartElement("Configuration"); |
||||
w.WriteAttributeString("Condition", " '$(Configuration)' == '' "); |
||||
w.WriteValue("Debug"); |
||||
w.WriteEndElement(); // </Configuration>
|
||||
|
||||
w.WriteStartElement("Platform"); |
||||
w.WriteAttributeString("Condition", " '$(Platform)' == '' "); |
||||
w.WriteValue(platformName); |
||||
w.WriteEndElement(); // </Platform>
|
||||
|
||||
switch (module.Kind) { |
||||
case ModuleKind.Windows: |
||||
w.WriteElementString("OutputType", "WinExe"); |
||||
break; |
||||
case ModuleKind.Console: |
||||
w.WriteElementString("OutputType", "Exe"); |
||||
break; |
||||
default: |
||||
w.WriteElementString("OutputType", "Library"); |
||||
break; |
||||
} |
||||
|
||||
w.WriteElementString("AssemblyName", module.Assembly.Name.Name); |
||||
switch (module.Runtime) { |
||||
case TargetRuntime.Net_1_0: |
||||
w.WriteElementString("TargetFrameworkVersion", "v1.0"); |
||||
break; |
||||
case TargetRuntime.Net_1_1: |
||||
w.WriteElementString("TargetFrameworkVersion", "v1.1"); |
||||
break; |
||||
case TargetRuntime.Net_2_0: |
||||
w.WriteElementString("TargetFrameworkVersion", "v2.0"); |
||||
// TODO: Detect when .NET 3.0/3.5 is required
|
||||
break; |
||||
default: |
||||
w.WriteElementString("TargetFrameworkVersion", "v4.0"); |
||||
// TODO: Detect TargetFrameworkProfile
|
||||
break; |
||||
} |
||||
w.WriteElementString("WarningLevel", "4"); |
||||
|
||||
w.WriteEndElement(); // </PropertyGroup>
|
||||
|
||||
w.WriteStartElement("PropertyGroup"); // platform-specific
|
||||
w.WriteAttributeString("Condition", " '$(Platform)' == '" + platformName + "' "); |
||||
w.WriteElementString("PlatformTarget", platformName); |
||||
w.WriteEndElement(); // </PropertyGroup> (platform-specific)
|
||||
|
||||
w.WriteStartElement("PropertyGroup"); // Debug
|
||||
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Debug' "); |
||||
w.WriteElementString("OutputPath", "bin\\Debug\\"); |
||||
w.WriteElementString("DebugSymbols", "true"); |
||||
w.WriteElementString("DebugType", "full"); |
||||
w.WriteElementString("Optimize", "false"); |
||||
w.WriteEndElement(); // </PropertyGroup> (Debug)
|
||||
|
||||
w.WriteStartElement("PropertyGroup"); // Release
|
||||
w.WriteAttributeString("Condition", " '$(Configuration)' == 'Release' "); |
||||
w.WriteElementString("OutputPath", "bin\\Release\\"); |
||||
w.WriteElementString("DebugSymbols", "true"); |
||||
w.WriteElementString("DebugType", "pdbonly"); |
||||
w.WriteElementString("Optimize", "true"); |
||||
w.WriteEndElement(); // </PropertyGroup> (Release)
|
||||
|
||||
|
||||
w.WriteStartElement("ItemGroup"); // References
|
||||
foreach (AssemblyNameReference r in module.AssemblyReferences) { |
||||
if (r.Name != "mscorlib") { |
||||
w.WriteStartElement("Reference"); |
||||
w.WriteAttributeString("Include", r.Name); |
||||
// TODO: RequiredTargetFramework
|
||||
w.WriteEndElement(); |
||||
} |
||||
} |
||||
w.WriteEndElement(); // </ItemGroup> (References)
|
||||
|
||||
foreach (IGrouping<string, string> gr in (from f in files group f.Item2 by f.Item1 into g orderby g.Key select g)) { |
||||
w.WriteStartElement("ItemGroup"); |
||||
foreach (string file in gr.OrderBy(f => f, StringComparer.OrdinalIgnoreCase)) { |
||||
w.WriteStartElement(gr.Key); |
||||
w.WriteAttributeString("Include", file); |
||||
w.WriteEndElement(); |
||||
} |
||||
w.WriteEndElement(); |
||||
} |
||||
|
||||
w.WriteStartElement("ItemGroup"); // Imports
|
||||
foreach (var import in projectImports.OrderBy(x => x)) { |
||||
w.WriteStartElement("Import"); |
||||
w.WriteAttributeString("Include", import); |
||||
w.WriteEndElement(); |
||||
} |
||||
w.WriteEndElement(); // </ItemGroup> (Imports)
|
||||
|
||||
w.WriteStartElement("Import"); |
||||
w.WriteAttributeString("Project", "$(MSBuildToolsPath)\\Microsoft.VisualBasic.targets"); |
||||
w.WriteEndElement(); |
||||
|
||||
w.WriteEndDocument(); |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
#region WriteCodeFilesInProject
|
||||
bool IncludeTypeWhenDecompilingProject(TypeDefinition type, DecompilationOptions options) |
||||
{ |
||||
if (type.Name == "<Module>" || AstBuilder.MemberIsHidden(type, options.DecompilerSettings)) |
||||
return false; |
||||
if (type.Namespace == "XamlGeneratedNamespace" && type.Name == "GeneratedInternalTypeHelper") |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
IEnumerable<Tuple<string, string>> WriteCodeFilesInProject(AssemblyDefinition assembly, DecompilationOptions options, HashSet<string> directories) |
||||
{ |
||||
var files = assembly.MainModule.Types.Where(t => IncludeTypeWhenDecompilingProject(t, options)).GroupBy( |
||||
delegate(TypeDefinition type) { |
||||
string file = TextView.DecompilerTextView.CleanUpName(type.Name) + this.FileExtension; |
||||
if (string.IsNullOrEmpty(type.Namespace)) { |
||||
return file; |
||||
} else { |
||||
string dir = TextView.DecompilerTextView.CleanUpName(type.Namespace); |
||||
if (directories.Add(dir)) |
||||
Directory.CreateDirectory(Path.Combine(options.SaveAsProjectDirectory, dir)); |
||||
return Path.Combine(dir, file); |
||||
} |
||||
}, StringComparer.OrdinalIgnoreCase).ToList(); |
||||
AstMethodBodyBuilder.ClearUnhandledOpcodes(); |
||||
Parallel.ForEach( |
||||
files, |
||||
new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount }, |
||||
delegate(IGrouping<string, TypeDefinition> file) { |
||||
using (StreamWriter w = new StreamWriter(Path.Combine(options.SaveAsProjectDirectory, file.Key))) { |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentModule: assembly.MainModule); |
||||
foreach (TypeDefinition type in file) { |
||||
codeDomBuilder.AddType(type); |
||||
} |
||||
RunTransformsAndGenerateCode(codeDomBuilder, new PlainTextOutput(w), options, assembly.MainModule); |
||||
} |
||||
}); |
||||
AstMethodBodyBuilder.PrintNumberOfUnhandledOpcodes(); |
||||
return files.Select(f => Tuple.Create("Compile", f.Key)); |
||||
} |
||||
#endregion
|
||||
|
||||
#region WriteResourceFilesInProject
|
||||
IEnumerable<Tuple<string, string>> WriteResourceFilesInProject(LoadedAssembly assembly, DecompilationOptions options, HashSet<string> directories) |
||||
{ |
||||
AppDomain bamlDecompilerAppDomain = null; |
||||
try { |
||||
foreach (EmbeddedResource r in assembly.AssemblyDefinition.MainModule.Resources.OfType<EmbeddedResource>()) { |
||||
string fileName; |
||||
Stream s = r.GetResourceStream(); |
||||
s.Position = 0; |
||||
if (r.Name.EndsWith(".g.resources", StringComparison.OrdinalIgnoreCase)) { |
||||
IEnumerable<DictionaryEntry> rs = null; |
||||
try { |
||||
rs = new ResourceSet(s).Cast<DictionaryEntry>(); |
||||
} |
||||
catch (ArgumentException) { |
||||
} |
||||
if (rs != null && rs.All(e => e.Value is Stream)) { |
||||
foreach (var pair in rs) { |
||||
fileName = Path.Combine(((string)pair.Key).Split('/').Select(p => TextView.DecompilerTextView.CleanUpName(p)).ToArray()); |
||||
string dirName = Path.GetDirectoryName(fileName); |
||||
if (!string.IsNullOrEmpty(dirName) && directories.Add(dirName)) { |
||||
Directory.CreateDirectory(Path.Combine(options.SaveAsProjectDirectory, dirName)); |
||||
} |
||||
Stream entryStream = (Stream)pair.Value; |
||||
entryStream.Position = 0; |
||||
if (fileName.EndsWith(".baml", StringComparison.OrdinalIgnoreCase)) { |
||||
MemoryStream ms = new MemoryStream(); |
||||
entryStream.CopyTo(ms); |
||||
// TODO implement extension point
|
||||
// var decompiler = Baml.BamlResourceEntryNode.CreateBamlDecompilerInAppDomain(ref bamlDecompilerAppDomain, assembly.FileName);
|
||||
// string xaml = null;
|
||||
// try {
|
||||
// xaml = decompiler.DecompileBaml(ms, assembly.FileName, new ConnectMethodDecompiler(assembly), new AssemblyResolver(assembly));
|
||||
// }
|
||||
// catch (XamlXmlWriterException) { } // ignore XAML writer exceptions
|
||||
// if (xaml != null) {
|
||||
// File.WriteAllText(Path.Combine(options.SaveAsProjectDirectory, Path.ChangeExtension(fileName, ".xaml")), xaml);
|
||||
// yield return Tuple.Create("Page", Path.ChangeExtension(fileName, ".xaml"));
|
||||
// continue;
|
||||
// }
|
||||
} |
||||
using (FileStream fs = new FileStream(Path.Combine(options.SaveAsProjectDirectory, fileName), FileMode.Create, FileAccess.Write)) { |
||||
entryStream.CopyTo(fs); |
||||
} |
||||
yield return Tuple.Create("Resource", fileName); |
||||
} |
||||
continue; |
||||
} |
||||
} |
||||
fileName = GetFileNameForResource(r.Name, directories); |
||||
using (FileStream fs = new FileStream(Path.Combine(options.SaveAsProjectDirectory, fileName), FileMode.Create, FileAccess.Write)) { |
||||
s.CopyTo(fs); |
||||
} |
||||
yield return Tuple.Create("EmbeddedResource", fileName); |
||||
} |
||||
} |
||||
finally { |
||||
if (bamlDecompilerAppDomain != null) |
||||
AppDomain.Unload(bamlDecompilerAppDomain); |
||||
} |
||||
} |
||||
|
||||
string GetFileNameForResource(string fullName, HashSet<string> directories) |
||||
{ |
||||
string[] splitName = fullName.Split('.'); |
||||
string fileName = TextView.DecompilerTextView.CleanUpName(fullName); |
||||
for (int i = splitName.Length - 1; i > 0; i--) { |
||||
string ns = string.Join(".", splitName, 0, i); |
||||
if (directories.Contains(ns)) { |
||||
string name = string.Join(".", splitName, i, splitName.Length - i); |
||||
fileName = Path.Combine(ns, TextView.DecompilerTextView.CleanUpName(name)); |
||||
break; |
||||
} |
||||
} |
||||
return fileName; |
||||
} |
||||
#endregion
|
||||
|
||||
public override void DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
WriteCommentLine(output, TypeToString(method.DeclaringType, includeNamespace: true)); |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: method.DeclaringType, isSingleMember: true); |
||||
codeDomBuilder.AddMethod(method); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, method.Module); |
||||
} |
||||
|
||||
public override void DecompileProperty(PropertyDefinition property, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
WriteCommentLine(output, TypeToString(property.DeclaringType, includeNamespace: true)); |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: property.DeclaringType, isSingleMember: true); |
||||
codeDomBuilder.AddProperty(property); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, property.Module); |
||||
} |
||||
|
||||
public override void DecompileField(FieldDefinition field, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
WriteCommentLine(output, TypeToString(field.DeclaringType, includeNamespace: true)); |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: field.DeclaringType, isSingleMember: true); |
||||
codeDomBuilder.AddField(field); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, field.Module); |
||||
} |
||||
|
||||
public override void DecompileEvent(EventDefinition ev, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
WriteCommentLine(output, TypeToString(ev.DeclaringType, includeNamespace: true)); |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: ev.DeclaringType, isSingleMember: true); |
||||
codeDomBuilder.AddEvent(ev); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, ev.Module); |
||||
} |
||||
|
||||
public override void DecompileType(TypeDefinition type, ITextOutput output, DecompilationOptions options) |
||||
{ |
||||
AstBuilder codeDomBuilder = CreateAstBuilder(options, currentType: type); |
||||
codeDomBuilder.AddType(type); |
||||
RunTransformsAndGenerateCode(codeDomBuilder, output, options, type.Module); |
||||
} |
||||
|
||||
public override bool ShowMember(MemberReference member) |
||||
{ |
||||
return showAllMembers || !AstBuilder.MemberIsHidden(member, new DecompilationOptions().DecompilerSettings); |
||||
} |
||||
|
||||
void RunTransformsAndGenerateCode(AstBuilder astBuilder, ITextOutput output, DecompilationOptions options, ModuleDefinition module) |
||||
{ |
||||
astBuilder.RunTransformations(transformAbortCondition); |
||||
if (options.DecompilerSettings.ShowXmlDocumentation) |
||||
AddXmlDocTransform.Run(astBuilder.CompilationUnit); |
||||
var unit = astBuilder.CompilationUnit.AcceptVisitor(new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider(CreateResolveContext(module))), null); |
||||
var outputFormatter = new VBTextOutputFormatter(output); |
||||
var formattingPolicy = new VBFormattingOptions(); |
||||
unit.AcceptVisitor(new OutputVisitor(outputFormatter, formattingPolicy), null); |
||||
} |
||||
|
||||
AstBuilder CreateAstBuilder(DecompilationOptions options, ModuleDefinition currentModule = null, TypeDefinition currentType = null, bool isSingleMember = false) |
||||
{ |
||||
if (currentModule == null) |
||||
currentModule = currentType.Module; |
||||
DecompilerSettings settings = options.DecompilerSettings; |
||||
settings = settings.Clone(); |
||||
if (isSingleMember) |
||||
settings.UsingDeclarations = false; |
||||
settings.IntroduceIncrementAndDecrement = false; |
||||
settings.QueryExpressions = false; |
||||
settings.AlwaysGenerateExceptionVariableForCatchBlocks = true; |
||||
return new AstBuilder( |
||||
new DecompilerContext(currentModule) { |
||||
CancellationToken = options.CancellationToken, |
||||
CurrentType = currentType, |
||||
Settings = settings |
||||
}); |
||||
} |
||||
|
||||
public override string FormatTypeName(TypeDefinition type) |
||||
{ |
||||
if (type == null) |
||||
throw new ArgumentNullException("type"); |
||||
|
||||
return TypeToString(ConvertTypeOptions.DoNotUsePrimitiveTypeNames | ConvertTypeOptions.IncludeTypeParameterDefinitions, type); |
||||
} |
||||
|
||||
public override string TypeToString(TypeReference type, bool includeNamespace, ICustomAttributeProvider typeAttributes = null) |
||||
{ |
||||
ConvertTypeOptions options = ConvertTypeOptions.IncludeTypeParameterDefinitions; |
||||
if (includeNamespace) |
||||
options |= ConvertTypeOptions.IncludeNamespace; |
||||
|
||||
return TypeToString(options, type, typeAttributes); |
||||
} |
||||
|
||||
ITypeResolveContext CreateResolveContext(ModuleDefinition module) |
||||
{ |
||||
IProjectContent projectContent = new CecilTypeResolveContext(module); |
||||
|
||||
List<ITypeResolveContext> resolveContexts = new List<ITypeResolveContext>(); |
||||
resolveContexts.Add(projectContent); |
||||
foreach (AssemblyNameReference r in module.AssemblyReferences) { |
||||
AssemblyDefinition d = module.AssemblyResolver.Resolve(r); |
||||
if (d != null) { |
||||
resolveContexts.Add(new CecilTypeResolveContext(d.MainModule)); |
||||
} |
||||
} |
||||
|
||||
return new CompositeTypeResolveContext(resolveContexts); |
||||
} |
||||
|
||||
string TypeToString(ConvertTypeOptions options, TypeReference type, ICustomAttributeProvider typeAttributes = null) |
||||
{ |
||||
|
||||
var astType = AstBuilder |
||||
.ConvertType(type, typeAttributes, options) |
||||
.AcceptVisitor(new CSharpToVBConverterVisitor(new ILSpyEnvironmentProvider(CreateResolveContext(type.Resolve().Module))), null); |
||||
StringWriter w = new StringWriter(); |
||||
// TODO
|
||||
// if (type.IsByReference) {
|
||||
// ParameterDefinition pd = typeAttributes as ParameterDefinition;
|
||||
// if (pd != null && (!pd.IsIn && pd.IsOut))
|
||||
// w.Write("out ");
|
||||
// else
|
||||
// w.Write("ref ");
|
||||
//
|
||||
// if (astType is ComposedType && ((ComposedType)astType).PointerRank > 0)
|
||||
// ((ComposedType)astType).PointerRank--;
|
||||
// }
|
||||
|
||||
astType.AcceptVisitor(new OutputVisitor(w, new VBFormattingOptions()), null); |
||||
return w.ToString(); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,153 @@
@@ -0,0 +1,153 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Decompiler; |
||||
using ICSharpCode.Decompiler.ILAst; |
||||
using ICSharpCode.NRefactory.VB; |
||||
using Mono.Cecil; |
||||
|
||||
namespace ICSharpCode.ILSpy.VB |
||||
{ |
||||
/// <summary>
|
||||
/// Description of VBTextOutputFormatter.
|
||||
/// </summary>
|
||||
public class VBTextOutputFormatter : IOutputFormatter |
||||
{ |
||||
readonly ITextOutput output; |
||||
readonly Stack<AstNode> nodeStack = new Stack<AstNode>(); |
||||
|
||||
public VBTextOutputFormatter(ITextOutput output) |
||||
{ |
||||
if (output == null) |
||||
throw new ArgumentNullException("output"); |
||||
this.output = output; |
||||
} |
||||
|
||||
public void StartNode(AstNode node) |
||||
{ |
||||
// var ranges = node.Annotation<List<ILRange>>();
|
||||
// if (ranges != null && ranges.Count > 0)
|
||||
// {
|
||||
// // find the ancestor that has method mapping as annotation
|
||||
// if (node.Ancestors != null && node.Ancestors.Count() > 0)
|
||||
// {
|
||||
// var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
|
||||
// if (n != null) {
|
||||
// MemberMapping mapping = n.Annotation<MemberMapping>();
|
||||
//
|
||||
// // add all ranges
|
||||
// foreach (var range in ranges) {
|
||||
// mapping.MemberCodeMappings.Add(new SourceCodeMapping {
|
||||
// ILInstructionOffset = range,
|
||||
// SourceCodeLine = output.CurrentLine,
|
||||
// MemberMapping = mapping
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
nodeStack.Push(node); |
||||
} |
||||
|
||||
public void EndNode(AstNode node) |
||||
{ |
||||
if (nodeStack.Pop() != node) |
||||
throw new InvalidOperationException(); |
||||
} |
||||
|
||||
public void WriteIdentifier(string identifier) |
||||
{ |
||||
MemberReference memberRef = GetCurrentMemberReference(); |
||||
|
||||
if (memberRef != null) |
||||
output.WriteReference(identifier, memberRef); |
||||
else |
||||
output.Write(identifier); |
||||
} |
||||
|
||||
MemberReference GetCurrentMemberReference() |
||||
{ |
||||
AstNode node = nodeStack.Peek(); |
||||
MemberReference memberRef = node.Annotation<MemberReference>(); |
||||
// TODO : implement this!
|
||||
// if (memberRef == null && node.Role == AstNode.Roles.TargetExpression && (node.Parent is InvocationExpression || node.Parent is ObjectCreateExpression)) {
|
||||
// memberRef = node.Parent.Annotation<MemberReference>();
|
||||
// }
|
||||
return memberRef; |
||||
} |
||||
|
||||
public void WriteKeyword(string keyword) |
||||
{ |
||||
output.Write(keyword); |
||||
} |
||||
|
||||
public void WriteToken(string token) |
||||
{ |
||||
// Attach member reference to token only if there's no identifier in the current node.
|
||||
MemberReference memberRef = GetCurrentMemberReference(); |
||||
if (memberRef != null && nodeStack.Peek().GetChildByRole(AstNode.Roles.Identifier).IsNull) |
||||
output.WriteReference(token, memberRef); |
||||
else |
||||
output.Write(token); |
||||
} |
||||
|
||||
public void Space() |
||||
{ |
||||
output.Write(' '); |
||||
} |
||||
|
||||
public void Indent() |
||||
{ |
||||
output.Indent(); |
||||
} |
||||
|
||||
public void Unindent() |
||||
{ |
||||
output.Unindent(); |
||||
} |
||||
|
||||
public void NewLine() |
||||
{ |
||||
output.WriteLine(); |
||||
} |
||||
|
||||
public void WriteComment(bool isDocumentation, string content) |
||||
{ |
||||
if (isDocumentation) |
||||
output.Write("'''"); |
||||
else |
||||
output.Write("'"); |
||||
output.WriteLine(content); |
||||
} |
||||
|
||||
public void MarkFoldStart() |
||||
{ |
||||
output.MarkFoldStart(); |
||||
} |
||||
|
||||
public void MarkFoldEnd() |
||||
{ |
||||
output.MarkFoldEnd(); |
||||
} |
||||
} |
||||
} |
||||
Binary file not shown.
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Diagnostics; |
||||
using System.Linq; |
||||
using System.Threading; |
||||
using ICSharpCode.NRefactory.PatternMatching; |
||||
using ICSharpCode.NRefactory.VB.Ast; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB |
||||
{ |
||||
public class Comment : AstNode |
||||
{ |
||||
public bool IsDocumentationComment { get; set; } |
||||
|
||||
public bool StartsLine { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
public string Content { |
||||
get; |
||||
set; |
||||
} |
||||
|
||||
AstLocation startLocation; |
||||
public override AstLocation StartLocation { |
||||
get { |
||||
return startLocation; |
||||
} |
||||
} |
||||
|
||||
AstLocation endLocation; |
||||
public override AstLocation EndLocation { |
||||
get { |
||||
return endLocation; |
||||
} |
||||
} |
||||
|
||||
public Comment (string content, bool isDocumentation = false) |
||||
{ |
||||
this.IsDocumentationComment = isDocumentation; |
||||
this.Content = content; |
||||
} |
||||
|
||||
public Comment (bool isDocumentation, AstLocation startLocation, AstLocation endLocation) |
||||
{ |
||||
this.IsDocumentationComment = isDocumentation; |
||||
this.startLocation = startLocation; |
||||
this.endLocation = endLocation; |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitComment(this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
Comment o = other as Comment; |
||||
return o != null && this.IsDocumentationComment == o.IsDocumentationComment && MatchString(this.Content, o.Content); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,41 @@
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class AnonymousObjectCreationExpression : Expression |
||||
{ |
||||
public AstNodeCollection<Expression> Initializer { |
||||
get { return GetChildrenByRole(Roles.Expression); } |
||||
} |
||||
|
||||
public AnonymousObjectCreationExpression () |
||||
{ |
||||
} |
||||
|
||||
public AnonymousObjectCreationExpression (IEnumerable<Expression> initializer) |
||||
{ |
||||
foreach (var ini in initializer) { |
||||
AddChild (ini, Roles.Expression); |
||||
} |
||||
} |
||||
|
||||
public AnonymousObjectCreationExpression (params Expression[] initializer) : this ((IEnumerable<Expression>)initializer) |
||||
{ |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitAnonymousObjectCreationExpression(this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
var o = other as AnonymousObjectCreationExpression; |
||||
return o != null && this.Initializer.DoMatch(o.Initializer, match); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// New Type[Dimensions]
|
||||
/// </summary>
|
||||
public class ArrayCreateExpression : Expression |
||||
{ |
||||
public readonly static Role<ArraySpecifier> AdditionalArraySpecifierRole = new Role<ArraySpecifier>("AdditionalArraySpecifier"); |
||||
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null); |
||||
|
||||
public AstType Type { |
||||
get { return GetChildByRole (Roles.Type); } |
||||
set { SetChildByRole (Roles.Type, value); } |
||||
} |
||||
|
||||
public AstNodeCollection<Expression> Arguments { |
||||
get { return GetChildrenByRole (Roles.Argument); } |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets additional array ranks (those without size info).
|
||||
/// Empty for "New Integer(5,1)"; will contain a single element for "New Integer(5)()".
|
||||
/// </summary>
|
||||
public AstNodeCollection<ArraySpecifier> AdditionalArraySpecifiers { |
||||
get { return GetChildrenByRole(AdditionalArraySpecifierRole); } |
||||
} |
||||
|
||||
public ArrayInitializerExpression Initializer { |
||||
get { return GetChildByRole (InitializerRole); } |
||||
set { SetChildByRole (InitializerRole, value); } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitArrayCreateExpression (this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
ArrayCreateExpression o = other as ArrayCreateExpression; |
||||
return o != null && this.Type.DoMatch(o.Type, match) && this.Arguments.DoMatch(o.Arguments, match) && this.AdditionalArraySpecifiers.DoMatch(o.AdditionalArraySpecifiers, match) && this.Initializer.DoMatch(o.Initializer, match); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// { Elements }
|
||||
/// </summary>
|
||||
public class ArrayInitializerExpression : Expression |
||||
{ |
||||
#region Null
|
||||
public new static readonly ArrayInitializerExpression Null = new NullArrayInitializerExpression (); |
||||
|
||||
sealed class NullArrayInitializerExpression : ArrayInitializerExpression |
||||
{ |
||||
public override bool IsNull { |
||||
get { |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return default (S); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
return other == null || other.IsNull; |
||||
} |
||||
} |
||||
#endregion
|
||||
|
||||
public readonly static Role<ArrayInitializerExpression> InitializerRole = new Role<ArrayInitializerExpression>("Initializer", ArrayInitializerExpression.Null); |
||||
|
||||
public AstNodeCollection<Expression> Elements { |
||||
get { return GetChildrenByRole(Roles.Expression); } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitArrayInitializerExpression (this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
ArrayInitializerExpression o = other as ArrayInitializerExpression; |
||||
return o != null && this.Elements.DoMatch(o.Elements, match); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class AssignmentExpression : Expression |
||||
{ |
||||
public readonly static Role<Expression> LeftExpressionRole = BinaryOperatorExpression.LeftExpressionRole; |
||||
public readonly static Role<VBTokenNode> OperatorRole = BinaryOperatorExpression.OperatorRole; |
||||
public readonly static Role<Expression> RightExpressionRole = BinaryOperatorExpression.RightExpressionRole; |
||||
|
||||
public AssignmentExpression(Expression left, AssignmentOperatorType type, Expression right) |
||||
{ |
||||
AddChild(left, LeftExpressionRole); |
||||
AddChild(right, RightExpressionRole); |
||||
Operator = type; |
||||
} |
||||
|
||||
public Expression Left { |
||||
get { return GetChildByRole(LeftExpressionRole); } |
||||
set { SetChildByRole(LeftExpressionRole, value); } |
||||
} |
||||
|
||||
public AssignmentOperatorType Operator { get; set; } |
||||
|
||||
public Expression Right { |
||||
get { return GetChildByRole(RightExpressionRole); } |
||||
set { SetChildByRole(RightExpressionRole, value); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitAssignmentExpression(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,110 @@
@@ -0,0 +1,110 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class BinaryOperatorExpression : Expression |
||||
{ |
||||
public readonly static Role<Expression> LeftExpressionRole = new Role<Expression>("Left"); |
||||
public readonly static Role<VBTokenNode> OperatorRole = new Role<VBTokenNode>("Operator"); |
||||
public readonly static Role<Expression> RightExpressionRole = new Role<Expression>("Right"); |
||||
|
||||
public BinaryOperatorExpression(Expression left, BinaryOperatorType type, Expression right) |
||||
{ |
||||
AddChild(left, LeftExpressionRole); |
||||
AddChild(right, RightExpressionRole); |
||||
Operator = type; |
||||
} |
||||
|
||||
public Expression Left { |
||||
get { return GetChildByRole(LeftExpressionRole); } |
||||
set { SetChildByRole(LeftExpressionRole, value); } |
||||
} |
||||
|
||||
public BinaryOperatorType Operator { get; set; } |
||||
|
||||
public Expression Right { |
||||
get { return GetChildByRole(RightExpressionRole); } |
||||
set { SetChildByRole(RightExpressionRole, value); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitBinaryOperatorExpression(this, data); |
||||
} |
||||
} |
||||
|
||||
public enum BinaryOperatorType |
||||
{ |
||||
None, |
||||
|
||||
/// <summary>'&' in C#, 'And' in VB.</summary>
|
||||
BitwiseAnd, |
||||
/// <summary>'|' in C#, 'Or' in VB.</summary>
|
||||
BitwiseOr, |
||||
/// <summary>'&&' in C#, 'AndAlso' in VB.</summary>
|
||||
LogicalAnd, |
||||
/// <summary>'||' in C#, 'OrElse' in VB.</summary>
|
||||
LogicalOr, |
||||
/// <summary>'^' in C#, 'Xor' in VB.</summary>
|
||||
ExclusiveOr, |
||||
|
||||
/// <summary>></summary>
|
||||
GreaterThan, |
||||
/// <summary>>=</summary>
|
||||
GreaterThanOrEqual, |
||||
/// <summary>'==' in C#, '=' in VB.</summary>
|
||||
Equality, |
||||
/// <summary>'!=' in C#, '<>' in VB.</summary>
|
||||
InEquality, |
||||
/// <summary><</summary>
|
||||
LessThan, |
||||
/// <summary><=</summary>
|
||||
LessThanOrEqual, |
||||
|
||||
/// <summary>+</summary>
|
||||
Add, |
||||
/// <summary>-</summary>
|
||||
Subtract, |
||||
/// <summary>*</summary>
|
||||
Multiply, |
||||
/// <summary>/</summary>
|
||||
Divide, |
||||
/// <summary>'%' in C#, 'Mod' in VB.</summary>
|
||||
Modulus, |
||||
/// <summary>VB-only: \</summary>
|
||||
DivideInteger, |
||||
/// <summary>VB-only: ^</summary>
|
||||
Power, |
||||
/// <summary>VB-only: &</summary>
|
||||
Concat, |
||||
|
||||
/// <summary>C#: <<</summary>
|
||||
ShiftLeft, |
||||
/// <summary>C#: >></summary>
|
||||
ShiftRight, |
||||
/// <summary>VB-only: Is</summary>
|
||||
ReferenceEquality, |
||||
/// <summary>VB-only: IsNot</summary>
|
||||
ReferenceInequality, |
||||
|
||||
/// <summary>VB-only: Like</summary>
|
||||
Like, |
||||
/// <summary>
|
||||
/// C#: ??
|
||||
/// VB: IF(x, y)
|
||||
/// </summary>
|
||||
NullCoalescing, |
||||
|
||||
/// <summary>VB-only: !</summary>
|
||||
DictionaryAccess |
||||
} |
||||
} |
||||
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// CastType(Expression, AstType)
|
||||
/// </summary>
|
||||
public class CastExpression : Expression |
||||
{ |
||||
public CastType CastType { get; set; } |
||||
|
||||
public VBTokenNode CastTypeToken { |
||||
get { return GetChildByRole (Roles.Keyword); } |
||||
} |
||||
|
||||
public AstType Type { |
||||
get { return GetChildByRole (Roles.Type); } |
||||
set { SetChildByRole (Roles.Type, value); } |
||||
} |
||||
|
||||
public Expression Expression { |
||||
get { return GetChildByRole (Roles.Expression); } |
||||
set { SetChildByRole (Roles.Expression, value); } |
||||
} |
||||
|
||||
public CastExpression () |
||||
{ |
||||
} |
||||
|
||||
public CastExpression (CastType castType, AstType castToType, Expression expression) |
||||
{ |
||||
CastType = castType; |
||||
AddChild (castToType, Roles.Type); |
||||
AddChild (expression, Roles.Expression); |
||||
} |
||||
|
||||
public CastExpression (CastType castType, Expression expression) |
||||
{ |
||||
CastType = castType; |
||||
AddChild (expression, Roles.Expression); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitCastExpression (this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
CastExpression o = other as CastExpression; |
||||
return o != null && this.CastType == o.CastType && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); |
||||
} |
||||
} |
||||
|
||||
public enum CastType |
||||
{ |
||||
DirectCast, |
||||
TryCast, |
||||
CType, |
||||
CBool, |
||||
CByte, |
||||
CChar, |
||||
CDate, |
||||
CDec, |
||||
CDbl, |
||||
CInt, |
||||
CLng, |
||||
CObj, |
||||
CSByte, |
||||
CShort, |
||||
CSng, |
||||
CStr, |
||||
CUInt, |
||||
CULng, |
||||
CUShort |
||||
} |
||||
} |
||||
@ -0,0 +1,42 @@
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// Identifier As Type In Expression
|
||||
/// </summary>
|
||||
public class CollectionRangeVariableDeclaration : AstNode |
||||
{ |
||||
public static readonly Role<CollectionRangeVariableDeclaration> CollectionRangeVariableDeclarationRole = new Role<CollectionRangeVariableDeclaration>("CollectionRangeVariableDeclaration"); |
||||
|
||||
public VariableIdentifier Identifier { |
||||
get { return GetChildByRole(VariableIdentifier.VariableIdentifierRole); } |
||||
set { SetChildByRole(VariableIdentifier.VariableIdentifierRole, value); } |
||||
} |
||||
|
||||
public AstType Type { |
||||
get { return GetChildByRole(Roles.Type); } |
||||
set { SetChildByRole(Roles.Type, value); } |
||||
} |
||||
|
||||
public Expression Expression { |
||||
get { return GetChildByRole (Roles.Expression); } |
||||
set { SetChildByRole (Roles.Expression, value); } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitCollectionRangeVariableDeclaration(this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
CollectionRangeVariableDeclaration o = other as CollectionRangeVariableDeclaration; |
||||
return o != null && this.Identifier.DoMatch(o.Identifier, match) && this.Type.DoMatch(o.Type, match) && this.Expression.DoMatch(o.Expression, match); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class ConditionalExpression : Expression |
||||
{ |
||||
public readonly static Role<Expression> ConditionExpressionRole = new Role<Expression>("ConditionExpressionRole", Expression.Null); |
||||
public readonly static Role<Expression> TrueExpressionRole = new Role<Expression>("TrueExpressionRole", Expression.Null); |
||||
public readonly static Role<Expression> FalseExpressionRole = new Role<Expression>("FalseExpressionRole", Expression.Null); |
||||
|
||||
public VBTokenNode IfToken { |
||||
get { return GetChildByRole (Roles.Keyword); } |
||||
} |
||||
|
||||
public Expression ConditionExpression { |
||||
get { return GetChildByRole (ConditionExpressionRole); } |
||||
set { SetChildByRole (ConditionExpressionRole, value); } |
||||
} |
||||
|
||||
public Expression TrueExpression { |
||||
get { return GetChildByRole (TrueExpressionRole); } |
||||
set { SetChildByRole (TrueExpressionRole, value); } |
||||
} |
||||
|
||||
public Expression FalseExpression { |
||||
get { return GetChildByRole (FalseExpressionRole); } |
||||
set { SetChildByRole (FalseExpressionRole, value); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitConditionalExpression(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,59 @@
@@ -0,0 +1,59 @@
|
||||
// Copyright (c) 2011 AlphaSierraPapa for the SharpDevelop Team
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||
// software and associated documentation files (the "Software"), to deal in the Software
|
||||
// without restriction, including without limitation the rights to use, copy, modify, merge,
|
||||
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
|
||||
// to whom the Software is furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all copies or
|
||||
// substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
||||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class EmptyExpression : Expression |
||||
{ |
||||
AstLocation location; |
||||
|
||||
public override AstLocation StartLocation { |
||||
get { |
||||
return location; |
||||
} |
||||
} |
||||
|
||||
public override AstLocation EndLocation { |
||||
get { |
||||
return location; |
||||
} |
||||
} |
||||
|
||||
public EmptyExpression() |
||||
{ |
||||
} |
||||
|
||||
public EmptyExpression(AstLocation location) |
||||
{ |
||||
this.location = location; |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitEmptyExpression(this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
var o = other as EmptyExpression; |
||||
return o != null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// [ Key ] .Identifier = Expression
|
||||
/// </summary>
|
||||
public class FieldInitializerExpression : Expression |
||||
{ |
||||
public bool IsKey { get; set; } |
||||
|
||||
public VBTokenNode KeyToken { |
||||
get { return GetChildByRole (Roles.Keyword); } |
||||
} |
||||
|
||||
public VBTokenNode DotToken { |
||||
get { return GetChildByRole (Roles.Dot); } |
||||
} |
||||
|
||||
public Identifier Identifier { |
||||
get { return GetChildByRole(Roles.Identifier); } |
||||
set { SetChildByRole(Roles.Identifier, value); } |
||||
} |
||||
|
||||
public VBTokenNode AssignToken { |
||||
get { return GetChildByRole (Roles.Assign); } |
||||
} |
||||
|
||||
public Expression Expression { |
||||
get { return GetChildByRole (Roles.Expression); } |
||||
set { SetChildByRole (Roles.Expression, value); } |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitFieldInitializerExpression(this, data); |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) |
||||
{ |
||||
FieldInitializerExpression o = other as FieldInitializerExpression; |
||||
return o != null && this.IsKey == o.IsKey && this.Identifier.DoMatch(o.Identifier, match) && this.Expression.DoMatch(o.Expression, match); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class GetTypeExpression : Expression |
||||
{ |
||||
public GetTypeExpression() |
||||
{ |
||||
} |
||||
|
||||
public AstType Type { |
||||
get { return GetChildByRole(Roles.Type); } |
||||
set { SetChildByRole(Roles.Type, value); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
var expr = other as GetTypeExpression; |
||||
return expr != null && |
||||
Type.DoMatch(expr.Type, match); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitGetTypeExpression(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class GetXmlNamespaceExpression : Expression |
||||
{ |
||||
public GetXmlNamespaceExpression(XmlIdentifier namespaceName) |
||||
{ |
||||
SetChildByRole(Roles.XmlIdentifier, namespaceName); |
||||
} |
||||
|
||||
public XmlIdentifier NamespaceName { |
||||
get { return GetChildByRole(Roles.XmlIdentifier); } |
||||
set { SetChildByRole(Roles.XmlIdentifier, value); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
var expr = other as GetXmlNamespaceExpression; |
||||
return expr != null && |
||||
NamespaceName.DoMatch(expr.NamespaceName, match); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitGetXmlNamespaceExpression(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
public class IdentifierExpression : Expression |
||||
{ |
||||
public IdentifierExpression() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public IdentifierExpression(Identifier identifier) |
||||
{ |
||||
this.Identifier = identifier; |
||||
} |
||||
|
||||
public Identifier Identifier { |
||||
get { return GetChildByRole(Roles.Identifier); } |
||||
set { SetChildByRole(Roles.Identifier, value); } |
||||
} |
||||
|
||||
public AstNodeCollection<AstType> TypeArguments { |
||||
get { return GetChildrenByRole(Roles.TypeArgument); } |
||||
} |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitIdentifierExpression(this, data); |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,61 @@
@@ -0,0 +1,61 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.NRefactory.VB.Ast |
||||
{ |
||||
/// <summary>
|
||||
/// Description of InstanceExpression.
|
||||
/// </summary>
|
||||
public class InstanceExpression : Expression |
||||
{ |
||||
AstLocation location; |
||||
|
||||
public InstanceExpression(InstanceExpressionType type, AstLocation location) |
||||
{ |
||||
this.Type = type; |
||||
this.location = location; |
||||
} |
||||
|
||||
public override AstLocation StartLocation { |
||||
get { return location; } |
||||
} |
||||
|
||||
public override AstLocation EndLocation { |
||||
get { |
||||
switch (Type) { |
||||
case InstanceExpressionType.Me: |
||||
return new AstLocation(location.Line, location.Column + "Me".Length); |
||||
case InstanceExpressionType.MyBase: |
||||
return new AstLocation(location.Line, location.Column + "MyBase".Length); |
||||
case InstanceExpressionType.MyClass: |
||||
return new AstLocation(location.Line, location.Column + "MyClass".Length); |
||||
default: |
||||
throw new Exception("Invalid value for InstanceExpressionType"); |
||||
} |
||||
} |
||||
} |
||||
|
||||
public InstanceExpressionType Type { get; set; } |
||||
|
||||
protected internal override bool DoMatch(AstNode other, ICSharpCode.NRefactory.PatternMatching.Match match) |
||||
{ |
||||
var expr = other as InstanceExpression; |
||||
return expr != null && |
||||
Type == expr.Type; |
||||
} |
||||
|
||||
public override S AcceptVisitor<T, S>(IAstVisitor<T, S> visitor, T data) |
||||
{ |
||||
return visitor.VisitInstanceExpression(this, data); |
||||
} |
||||
} |
||||
|
||||
public enum InstanceExpressionType |
||||
{ |
||||
Me, |
||||
MyBase, |
||||
MyClass |
||||
} |
||||
} |
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue