Ejemplo n.º 1
0
 /// <summary>
 /// Consumes all symbols from provider copying them to the destination.
 /// </summary>
 /// <param name="destination">Destination.</param>
 /// <param name="source">Source.</param>
 private static void CopyRest(ICollection <Symbol> destination, ISymbolProvider source)
 {
     while (!source.Empty)
     {
         destination.Add(source.Consume());
     }
 }
Ejemplo n.º 2
0
        public frmGoToAll(bool allowOutOfScope, bool showFilesAndConstants)
        {
            InitializeComponent();

            Icon                   = Properties.Resources.Find;
            _symbolProvider        = DebugWorkspaceManager.GetSymbolProvider();
            _allowOutOfScope       = allowOutOfScope;
            _showFilesAndConstants = showFilesAndConstants;

            tlpResults.SuspendLayout();
            for (int i = 0; i < MaxResultCount; i++)
            {
                ctrlSearchResult searchResult = new ctrlSearchResult();
                searchResult.Dock         = DockStyle.Top;
                searchResult.BackColor    = i % 2 == 0 ? SystemColors.ControlLight : SystemColors.ControlLightLight;
                searchResult.Visible      = false;
                searchResult.Click       += SearchResult_Click;
                searchResult.DoubleClick += SearchResult_DoubleClick;
                tlpResults.Controls.Add(searchResult, 0, i);
                tlpResults.RowStyles.Add(new RowStyle(SizeType.AutoSize));

                _results.Add(searchResult);
            }
            tlpResults.ResumeLayout();

            UpdateResults();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Resolves value of the function call in compile time if possible.
        /// </summary>
        public static Optional <object> TryResolve(BoundGlobalFunctionCall x, ISymbolProvider model)
        {
            if (x.Name.IsDirect && x.ArgumentsInSourceOrder.All(arg => arg.Value.ConstantValue.HasValue))
            {
                // direct func name with all arguments resolved:

                // take the function name ignoring current namespace resolution, simple names only:
                var name = x.NameOpt.HasValue ? x.NameOpt.Value : x.Name.NameValue;
                if (name.IsSimpleName)
                {
                    var args = x.ArgumentsInSourceOrder;
                    switch (name.Name.Value)
                    {
                    case "function_exists":
                        if (args.Length == 1)
                        {
                            // TRUE <=> function name is defined unconditionally in a reference library (PE assembly)
                            var str = args[0].Value.ConstantValue.Value as string;
                            if (str != null)
                            {
                                var tmp = model.ResolveFunction(NameUtils.MakeQualifiedName(str, true));
                                if (tmp is PEMethodSymbol || (tmp is AmbiguousMethodSymbol && ((AmbiguousMethodSymbol)tmp).Ambiguities.All(f => f is PEMethodSymbol)))
                                {
                                    return(new Optional <object>(true));
                                }
                            }
                        }
                        break;
                    }
                }
            }

            //
            return(default(Optional <object>));
        }
Ejemplo n.º 4
0
            /// <summary>
            /// Consumes a symbol from oldSymbols, and puts it into destination and/or tails of oldSymbols. Handles overlapping with newSymbols.
            /// The head of a symbol is the part from start of the *old* symbol till the start of the *new* one.
            /// The tail of the symbol is the part from the end of the *new* symbol till the end of the *old*.
            /// This function copies over the head to the destination and adds a tail to the tail set (of course
            /// when it makes sense).
            /// </summary>
            /// <param name="newSymbols">Provider of new symbols.</param>
            /// <param name="destination">Destination container.</param>
            /// <param name="oldSymbols">OldSymbolsProvider, symbols provider.</param>
            /// <param name="createdSymbols">Container with the symbols that got created during merging.</param>
            /// <param name="deletedSymbols">Container with the symbols that got got replaced/deleted during merging.</param>
            private void AddSymbolWithHashing(OldSymbolProvider oldSymbols, ISymbolProvider newSymbols, ICollection <Symbol> destination, ICollection <Symbol> createdSymbols, ICollection <Symbol> deletedSymbols)
            {
                var consumedSymbolType = oldSymbols.CurrentType;
                var symbolToAdd        = oldSymbols.Consume();

                //If there is no symbol to potentially overlap just copy the orignal one
                if (newSymbols.Empty)
                {
                    destination.Add(symbolToAdd);
                    return;
                }

                if (consumedSymbolType == OldSymbolProvider.SymbolType.Original)
                {
                    deletedSymbols.Add(symbolToAdd);
                }

                //If the symbol to add starts before the new one, add its head to the destination.
                if (symbolToAdd.Start < newSymbols.Current.Start)
                {
                    Symbol symbolHead;
                    symbolToAdd.TryGetRightTrimmed(newSymbols.Current.Start, out symbolHead);
                    //If there are symbols on the tail list, check if the trimming would produce the same interval.
                    //If so, we skip the current addition. We do so, because in such case we want to preserve the top (most inner-one) former symbol.
                    //We need, however, to process the possible remainder, a new tail might be generated.
                    Symbol trimmedTail;
                    if (!oldSymbols.HasNextTail ||
                        !oldSymbols.NextTail.TryGetRightTrimmed(newSymbols.Current.Start, out trimmedTail) ||
                        comparer.Compare(symbolHead, trimmedTail) != 0)
                    {
                        destination.Add(symbolHead);
                        createdSymbols.Add(symbolHead);
                    }
                }

                if (newSymbols.Current.Length == 0 && symbolToAdd.Start == newSymbols.Current.Start)
                {
                    destination.Add(symbolToAdd);
                    return;
                }

                //if there is something behind it add it to the new symbols list
                if (symbolToAdd.End > newSymbols.Current.End)
                {
                    Symbol symbolTail;
                    symbolToAdd.TryGetLeftTrimmed(newSymbols.Current.End, out symbolTail);
                    oldSymbols.AddTail(symbolTail);
                    #if DEBUG
                    DebugAssert.AssertFalse(
                        newSymbols.Current.Overlaps(symbolTail),
                        "New symbol overlaps with created tail! Old and new symbols should not overlap."
                        );
                    #endif
                    return;
                }

                //There is one another case. Where the overlapping candidate completely overshadows the symbol.
                //Don't do anything, the overshadowed symbol got deleted anyways and no new symbol gets created.
            }
Ejemplo n.º 5
0
        public LocalSymbolProvider(ISymbolProvider /*!*/ model, FlowContext /*!*/ ctx)
        {
            Debug.Assert(model != null);
            Debug.Assert(ctx != null);

            _model = model;
            _ctx   = ctx;
        }
Ejemplo n.º 6
0
 public FieldView(Field <IAnimal> field, IConsoleOutput consoleOutput, IConsoleWindow consoleWindow, ISymbolProvider animalSymbolProvider, IStringDrawer stringDrawer, StringBuilder fieldAsStringBuilder) : this(field)
 {
     _consoleOutput        = consoleOutput;
     _consoleWindow        = consoleWindow;
     _animalSymbolProvider = animalSymbolProvider;
     _fieldAsStringBuilder = fieldAsStringBuilder;
     _stringDrawer         = stringDrawer;
 }
Ejemplo n.º 7
0
    // Use this for initialization
    void Start()
    {
        symbolProvider = GetComponent <ISymbolProvider>();

        currentLevel = (int)PlayerPrefs.GetFloat("game.currentlevel", 1);

        StartLevel(currentLevel);
    }
Ejemplo n.º 8
0
        private string Execute(string command, params string[] parameters)
        {
            IDebuggerEngine debugger       = Context.Debugger;
            ISymbolProvider symbolProvider = Context.SymbolProvider;
            string          output         = DbgEngDll.ExecuteAndCapture(command, parameters);

            Context.InitializeDebugger(debugger, symbolProvider);
            return(output);
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PerModuleSymbolProvider" /> class.
 /// </summary>
 /// <param name="fallbackSymbolProvider">The fall-back symbol provider.</param>
 public PerModuleSymbolProvider(ISymbolProvider fallbackSymbolProvider = null)
 {
     FallbackSymbolProvider = fallbackSymbolProvider ?? Context.SymbolProvider;
     if (FallbackSymbolProvider == null)
     {
         FallbackSymbolProvider = Context.Debugger?.GetDefaultSymbolProvider();
     }
     modules = GlobalCache.Caches.CreateDictionaryCache <Module, ISymbolProviderModule>(LoadModule);
     runtimeCodeTypeAndOffsetCache = GlobalCache.Caches.CreateDictionaryCache <Tuple <Process, ulong>, Tuple <CodeType, int> >(GetRuntimeCodeTypeAndOffset);
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes the Context with the specified debugger engine interface.
 /// It will also <see cref="IDebuggerEngine.EndSession"/> for previous debugger engine.
 /// </summary>
 /// <param name="debuggerEngine">The debugger engine interface.</param>
 /// <param name="symbolProvider">The symbol provider interface.</param>
 public static void InitializeDebugger(IDebuggerEngine debuggerEngine, ISymbolProvider symbolProvider)
 {
     if (Debugger != debuggerEngine)
     {
         Debugger?.EndSession();
     }
     ClearCache();
     Debugger       = debuggerEngine;
     SymbolProvider = symbolProvider;
 }
Ejemplo n.º 11
0
            /// <summary>
            /// Consumes whole cake from provider
            /// </summary>
            /// <param name="destination">Destination.</param>
            /// <param name="source">Source.</param>
            private static void CopyCake(ICollection <Symbol> destination, ISymbolProvider source)
            {
                Symbol cakeBase = source.Current;

                destination.Add(source.Consume()); // copy base
                //"move cake" - while current old symbol is contained in base copy it
                while (!source.Empty && cakeBase.Contains(source.Current))
                {
                    destination.Add(source.Consume());
                }
            }
Ejemplo n.º 12
0
        public static void ImportDbgFile(string dbgPath, bool silent = false)
        {
            _symbolProvider = null;

            _symbolProvider = new DbgImporter();
            (_symbolProvider as DbgImporter).Import(dbgPath, silent);
            SymbolProviderChanged?.Invoke(_symbolProvider);
            LabelManager.RefreshLabels();

            SymbolProviderChanged?.Invoke(_symbolProvider);
        }
Ejemplo n.º 13
0
        public SymbolCodeDataProvider(CpuType type, ISymbolProvider symbolProvider, SourceFileInfo file)
        {
            //_prgRom = DebugApi.GetMemoryState(SnesMemoryType.PrgRom);
            _cpuType        = type;
            _symbolProvider = symbolProvider;
            _file           = file;
            _lineCount      = file.Data.Length;

            string filename = file.Name.ToLower();

            _isC = filename.EndsWith(".h") || filename.EndsWith(".c");
        }
Ejemplo n.º 14
0
 public virtual void RefreshCode(ISymbolProvider symbolProvider, SourceFileInfo file)
 {
     _symbolProvider = symbolProvider;
     if (file == null)
     {
         this._provider = new CodeDataProvider(CpuType.Cpu);
     }
     else
     {
         this._provider = new SymbolCodeDataProvider(CpuType.Cpu, symbolProvider, file);
     }
 }
Ejemplo n.º 15
0
        public static bool TryResolveFile(ISymbolProvider model, SourceRoutineSymbol routine, BoundExpression expr, out IPhpScriptTypeSymbol script)
        {
            script = null;

            if (expr.ConstantValue.TryConvertToString(out var path))
            {
                // include (path)
                script = model.ResolveFile(path);
            }
            else if (expr is BoundPseudoConst pc1 && pc1.ConstType == BoundPseudoConst.Types.File) // __FILE__
            {
                script = routine.ContainingFile;
            }
Ejemplo n.º 16
0
        public static string GetDetailedSummary(this IOutputResult result, ISymbolProvider symbolProvider = null, bool includeExceptions = true)
        {
            symbolProvider = symbolProvider ?? new DefaultSymbolProvider();
            var builder = new StringBuilder();

            AppendOperations(result.GetOperationResults(), builder, symbolProvider);
            AppendOutput(result.OutputEntries, builder, symbolProvider);
            if (includeExceptions)
            {
                AppendExceptions(result.GetExceptions(), builder);
            }

            return(builder.ToString());
        }
Ejemplo n.º 17
0
        private void DebugWorkspaceManager_SymbolProviderChanged(ISymbolProvider symbolProvider)
        {
            _symbolProvider = symbolProvider;

            if (_symbolProvider == null && _inSourceView)
            {
                ToggleView();
            }

            if (_manager?.Provider != null)
            {
                UpdateSourceFileDropdown();
                UpdateCode();
            }
        }
Ejemplo n.º 18
0
        public void Initialize(IDisassemblyManager manager, BaseStyleProvider styleProvider)
        {
            _manager        = manager;
            _styleProvider  = styleProvider;
            _symbolProvider = DebugWorkspaceManager.GetSymbolProvider();

            ctrlCode.StyleProvider       = _styleProvider;
            ctrlCode.ShowContentNotes    = false;
            ctrlCode.ShowMemoryValues    = true;
            ctrlCode.ExtendedMarginWidth = manager.ByteCodeSize * 4;
            ctrlCode.AddressSize         = manager.AddressSize;

            UpdateSourceFileDropdown();
            _manager.RefreshCode(_inSourceView ? _symbolProvider : null, _inSourceView ? cboSourceFile.SelectedItem as SourceFileInfo : null);
        }
Ejemplo n.º 19
0
        internal NativeHeap(NativeRuntime runtime, NativeModule[] modules)
            : base(runtime)
        {
            NativeRuntime = runtime;
            _modules = modules;

            _symProvider = runtime.DataTarget.SymbolProvider;
            if (_symProvider == null)
                throw new InvalidOperationException("You must set DataTarget.SymbolProvider to enumerate the heap on a .Net Native runtime.");

            _mrtModule = FindMrtModule();

            CreateFreeType();
            InitSegments(runtime);

        }
Ejemplo n.º 20
0
        internal NativeHeap(NativeRuntime runtime, NativeModule[] modules)
            : base(runtime)
        {
            NativeRuntime = runtime;
            _modules      = modules;

            _symProvider = runtime.DataTarget.SymbolProvider;
            if (_symProvider == null)
            {
                throw new InvalidOperationException("You must set DataTarget.SymbolProvider to enumerate the heap on a .Net Native runtime.");
            }

            _mrtModule = FindMrtModule();

            CreateFreeType();
            InitSegments(runtime);
        }
Ejemplo n.º 21
0
    // Use this for initialization
    void Start()
    {
        symbolProvider = GetComponentsInParent <ISymbolProvider>()[0];

        checkpointSymbols = GetComponentInParent <Gameplay>();

        RemoveAllSymbols();

        if (symbolProvider != null)
        {
            StartCoroutine(AddSymbols());
        }
        else
        {
            Debug.LogWarning("symbol provider not set");
        }
    }
Ejemplo n.º 22
0
        private static void Build(Blog b, ISymbolProvider[] providers)
        {
            FileSystem = new VirtualFileSystem();

               Console.WriteLine("Loading posts...");
               List<Post> posts = new List<Post>(b.GetPosts());
               Console.WriteLine($"Loaded {posts.Count} posts!");

               Console.WriteLine("Loading templates...");
               List<Template> templates = new List<Template>();

               Console.WriteLine("Building posts...");

               Console.WriteLine("Loading pages...");
               List<CodeFile> pages = new List<CodeFile>();

               Console.WriteLine("Building pages...");

               Console.WriteLine("Saving...");
               FileSystem.Save(b.OutputFolder);

               Console.WriteLine("Moving resources...");
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DiaSymbolProvider"/> class.
 /// </summary>
 /// <param name="fallbackSymbolProvider">The fall-back symbol provider.</param>
 public DiaSymbolProvider(ISymbolProvider fallbackSymbolProvider = null)
     : base(fallbackSymbolProvider)
 {
 }
Ejemplo n.º 24
0
 public override void RefreshCode(ISymbolProvider symbolProvider, SourceFileInfo file)
 {
     this._provider = new CodeDataProvider(CpuType.Gameboy);
 }
Ejemplo n.º 25
0
        private static void AppendOutput(IEnumerable <OutputEntry> entries, StringBuilder builder, ISymbolProvider symbolProvider)
        {
            var entriesList = entries.ToList();

            if (entriesList.Count != 0)
            {
                builder.AppendLine().AppendLine("Output:");
                entriesList.ForEach(x => builder.Append($"{symbolProvider.GetSymbol(x.Type)} {x.Message}\r\n"));
            }
        }
Ejemplo n.º 26
0
    // Use this for initialization
    void Start()
    {
        symbolProvider = GetComponent<ISymbolProvider>();

        currentLevel = (int)PlayerPrefs.GetFloat("game.currentlevel", 1);

        StartLevel(currentLevel);
    }
Ejemplo n.º 27
0
 public GlobalSymbolProvider(PhpCompilation compilation)
 {
     Contract.ThrowIfNull(compilation);
     _compilation = compilation;
     _next        = new SourceSymbolProvider(compilation.SourceSymbolCollection);
 }
Ejemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        symbolProvider = GetComponentsInParent<ISymbolProvider>()[0];

        checkpointSymbols = GetComponentInParent<Gameplay>();

        RemoveAllSymbols();

        if (symbolProvider != null)
        {
            StartCoroutine(AddSymbols());
        }
        else
        {
            Debug.LogWarning("symbol provider not set");
        }
    }
Ejemplo n.º 29
0
 public SymbolSelectorViewModel(ISymbolProvider symbolProvider, ISymbolThemeService symbolThemeService)
 {
     _symbolThemeService = symbolThemeService;
     Symbols             = symbolProvider.SymbolThemes;
 }
Ejemplo n.º 30
0
 public RunListener(ISymbolProvider symbolProvider = null)
 {
     _symbolProvider = symbolProvider ?? new DefaultSymbolProvider();
 }
Ejemplo n.º 31
0
 public DataTargetBuilder WithSymbolProvider(ISymbolProvider symbolProvider)
 {
     Mock.Setup(target => target.SymbolProvider).Returns(symbolProvider);
     return(this);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EngineSymbolProviderModule" /> class.
 /// </summary>
 /// <param name="module">The engine module.</param>
 /// <param name="xmlModule">The XML module description.</param>
 /// <param name="symbolProvider">The engine symbol provider.</param>
 public EngineSymbolProviderModule(CsDebugScript.Module module, XmlModule xmlModule, ISymbolProvider symbolProvider)
 {
     if (string.IsNullOrEmpty(xmlModule.Name))
     {
         xmlModule.Name = module.Name;
     }
     Name                 = xmlModule.Name;
     Namespace            = xmlModule.Namespace;
     EngineModule         = module;
     EngineModuleProvider = symbolProvider.GetSymbolProviderModule(module);
     symbolsById          = new DictionaryCache <uint, Symbol>(CreateSymbol);
     symbolsByName        = new DictionaryCache <string, Symbol>(FindSymbol);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Initializes the Context with the specified debugger engine interface.
 /// </summary>
 /// <param name="debuggerEngine">The debugger engine interface.</param>
 /// <param name="symbolProvider">The symbol provider interface.</param>
 public static void InitializeDebugger(IDebuggerEngine debuggerEngine, ISymbolProvider symbolProvider)
 {
     ClearCache();
     Debugger       = debuggerEngine;
     SymbolProvider = symbolProvider;
 }
Ejemplo n.º 34
0
 public GlobalSymbolProvider(PhpCompilation compilation)
 {
     _compilation = compilation ?? throw new ArgumentNullException(nameof(compilation));
     _next        = new SourceSymbolProvider(compilation.SourceSymbolCollection);
 }