public virtual INotation GenerateNotations(ISymbolSource source) { return(source.GetTypes() .Where(Filter) .Where(FilterGenerated) .Select(CreateImplement) .Combine()); }
public void Setup() { mr = new MockRepository(); this.sc = new ServiceContainer(); this.node = mr.StrictMock <ITreeNode>(); this.host = mr.StrictMock <ITreeNodeDesignerHost>(); this.uiSvc = mr.StrictMock <IDecompilerShellUiService>(); this.cmdidLoadSymbols = new CommandID(CmdSets.GuidReko, CmdIds.LoadSymbols); this.slSvc = mr.StrictMock <ISymbolLoadingService>(); this.symSrc = mr.StrictMock <ISymbolSource>(); // Add services to the Service container (which in the real program is the Reko "main window") this.sc.AddService <ISymbolLoadingService>(slSvc); this.sc.AddService <IDecompilerShellUiService>(uiSvc); }
public T Generate(ISymbolSource source) { var sb = new StringBuilder(); CreateNotationGenerators() .Select(i => i.GenerateNotations(source)) .Combine().Record(sb); var code = sb.ToString(); var options = CreateOptions(); var compileTrees = CSharpSyntaxTree.ParseText(code, options.ParseOptions); var references = AppDomain.CurrentDomain.GetAssemblies() .Where(i => !i.IsDynamic && !string.IsNullOrWhiteSpace(i.Location)) .Distinct() .Select(i => MetadataReference.CreateFromFile(i.Location)); var compilation = CSharpCompilation.Create(RandomUtils.NewName(), new SyntaxTree[] { compileTrees }, references, options.CompilationOptions); return(Complie(compilation)); }
public static List<LocalVariable> GetLocalVariables(ISymbolSource symbolSource, IMethod method) { var module = method.ParentAssembly.GetModule(); List<LocalVariable> localVariables = new List<LocalVariable>(); foreach (ILLocalVariable ilvar in symbolSource.GetLocalVariables(method)) { int index = ilvar.Index; // NB: Display class does not have the compiler-generated flag if (ilvar.IsCompilerGenerated || ilvar.Name.StartsWith("CS$")) { // Get display class from local variable AddCapturedLocalVariables( localVariables, method, ilvar.ILRanges, context => GetLocalVariableValue(context, index), ilvar.Type ); } else { LocalVariable locVar = new LocalVariable( method, ilvar.Index, ilvar.Type, ilvar.Name, ilvar.ILRanges, context => GetLocalVariableValue(context, index) ); localVariables.Add(locVar); } } if (method.DeclaringType.IsDisplayClass()) { // Get display class from 'this' AddCapturedLocalVariables( localVariables, method, new [] { new ILRange(0, int.MaxValue) }, context => context.GetThisValue(false), method.DeclaringType ); // Get display classes from fields foreach(IField fieldInfo in method.DeclaringType.GetFields(f => f.Name.StartsWith("CS$"), GetMemberOptions.None)) { IField fieldInfoCopy = fieldInfo; AddCapturedLocalVariables( localVariables, method, new [] { new ILRange(0, int.MaxValue) }, // TODO: Use eval thread context => context.GetThisValue(false).GetFieldValue(context.Thread, fieldInfoCopy), fieldInfo.Type ); } } else { // Add this if (!method.IsStatic) { LocalVariable thisVar = new LocalVariable( method, -1, method.DeclaringType, "this", new [] { new ILRange(0, int.MaxValue) }, context => context.GetThisValue(false) ); thisVar.IsThis = true; localVariables.Add(thisVar); } } return localVariables; }
public static List <LocalVariable> GetLocalVariables(ISymbolSource symbolSource, IMethod method) { var module = method.ParentAssembly.GetModule(); List <LocalVariable> localVariables = new List <LocalVariable>(); foreach (ILLocalVariable ilvar in symbolSource.GetLocalVariables(method)) { int index = ilvar.Index; // NB: Display class does not have the compiler-generated flag if (ilvar.IsCompilerGenerated || ilvar.Name.StartsWith("CS$")) { // Get display class from local variable AddCapturedLocalVariables( localVariables, method, ilvar.ILRanges, context => GetLocalVariableValue(context, index), ilvar.Type ); } else { LocalVariable locVar = new LocalVariable( method, ilvar.Index, ilvar.Type, ilvar.Name, ilvar.ILRanges, context => GetLocalVariableValue(context, index) ); localVariables.Add(locVar); } } if (method.DeclaringType.IsDisplayClass()) { // Get display class from 'this' AddCapturedLocalVariables( localVariables, method, new [] { new ILRange(0, int.MaxValue) }, context => context.GetThisValue(false), method.DeclaringType ); // Get display classes from fields foreach (IField fieldInfo in method.DeclaringType.GetFields(f => f.Name.StartsWith("CS$"), GetMemberOptions.None)) { IField fieldInfoCopy = fieldInfo; AddCapturedLocalVariables( localVariables, method, new [] { new ILRange(0, int.MaxValue) }, // TODO: Use eval thread context => context.GetThisValue(false).GetFieldValue(context.Thread, fieldInfoCopy), fieldInfo.Type ); } } else { // Add this if (!method.IsStatic) { LocalVariable thisVar = new LocalVariable( method, -1, method.DeclaringType, "this", new [] { new ILRange(0, int.MaxValue) }, context => context.GetThisValue(false) ); thisVar.IsThis = true; localVariables.Add(thisVar); } } return(localVariables); }
public INotation GenerateNotations(ISymbolSource source) { infos.AddRange(source.GetTypes()); return(ConstNotations.Nothing); }