Exemplo n.º 1
0
        // Load the local variable information.
        private void LoadVariables()
        {
            SymInfoEnumerator e;
            int      nameIndex, index;
            int      start, end;
            SymScope childScope;

            e = new SymInfoEnumerator(reader, token);
            while (e.MoveNext())
            {
                if (e.Type == SymReader.DataType_LocalVariables)
                {
                    // Local variables within the root scope.
                    while ((nameIndex = e.GetNextInt()) != -1)
                    {
                        index = e.GetNextInt();
                        rootScope.AddLocal
                            (reader.ReadString(nameIndex), index);
                    }
                }
                else if (e.Type == SymReader.DataType_LocalVariablesOffsets)
                {
                    // Local variables within a child scope.
                    start      = e.GetNextInt();
                    end        = e.GetNextInt();
                    childScope = rootScope.FindScope(end, start);
                    while ((nameIndex = e.GetNextInt()) != -1)
                    {
                        index = e.GetNextInt();
                        childScope.AddLocal
                            (reader.ReadString(nameIndex), index);
                    }
                }
            }
        }
Exemplo n.º 2
0
        internal SymReader(String filename, byte[] data)
        {
            // Store the parameters for later.
            this.filename = filename;
            this.data     = data;

            // We need the UTF8 encoding object to decode strings.
            utf8 = Encoding.UTF8;

            // Read and validate the header.
            if (data.Length < 24)
            {
                throw new ArgumentException();
            }
            if (data[0] != (byte)'I' ||
                data[1] != (byte)'L' ||
                data[2] != (byte)'D' ||
                data[3] != (byte)'B' ||
                data[4] != (byte)0x01 ||
                data[5] != (byte)0x00 ||
                data[6] != (byte)0x00 ||
                data[7] != (byte)0x00)
            {
                throw new ArgumentException();
            }
            indexOffset     = Utils.ReadInt32(data, 8);
            numIndexEntries = Utils.ReadInt32(data, 12);
            stringOffset    = Utils.ReadInt32(data, 16);
            stringLength    = Utils.ReadInt32(data, 20);
            if (indexOffset < 24 || indexOffset >= data.Length)
            {
                throw new ArgumentException();
            }
            if (numIndexEntries < 0 ||
                ((data.Length - indexOffset) / 8) < numIndexEntries)
            {
                throw new ArgumentException();
            }
            if (stringOffset < 24 || stringOffset >= data.Length)
            {
                throw new ArgumentException();
            }
            if (stringLength <= 0 ||
                stringLength > (data.Length - stringOffset) ||
                data[stringOffset + stringLength - 1] != 0)
            {
                throw new ArgumentException();
            }

            // Get the link directory, if specified.
            SymInfoEnumerator e = new SymInfoEnumerator(this, "LDIR");

            if (e.MoveNext())
            {
                linkDirectory = ReadString(e.GetNextInt());
            }
        }
Exemplo n.º 3
0
        public virtual ISymbolDocument[] GetDocuments()
        {
            // Bail out early if we already loaded the document list.
            if (documents != null)
            {
                return(documents);
            }

            // Read the document information list from the symbol data.
            ArrayList         list = new ArrayList();
            SymInfoEnumerator e    = new SymInfoEnumerator(this);
            String            filename;
            ISymbolDocument   doc;

            while (e.MoveNext())
            {
                if (e.Type == DataType_LineColumn ||
                    e.Type == DataType_LineOffsets ||
                    e.Type == DataType_LineColumnOffsets)
                {
                    filename = ReadString(e.GetNextInt());
                    doc      = GetDocument(filename);
                    if (doc != null && !list.Contains(doc))
                    {
                        list.Add(doc);
                    }
                }
            }

            // Return the final document list.
            documents = new ISymbolDocument [list.Count];
            int index = 0;

            foreach (ISymbolDocument d in list)
            {
                documents[index++] = d;
            }
            return(documents);
        }
Exemplo n.º 4
0
	// Load the sequence point information.
	private void LoadSequencePoints()
			{
				SymInfoEnumerator e;
				String filename;
				ISymbolDocument document;
				int line, column, offset;

				// Bail out if we have already loaded the sequence points.
				if(sequencePoints != null)
				{
					return;
				}

				// Create the sequence point list.
				sequencePoints = new ArrayList();

				// Load the sequence point information.
				e = new SymInfoEnumerator(reader, token);
				while(e.MoveNext())
				{
					if(e.Type == SymReader.DataType_LineColumn)
					{
						// Block contains line and column values only.
						filename = reader.ReadString(e.GetNextInt());
						document = reader.GetDocument(filename);
						while((line = e.GetNextInt()) != -1)
						{
							column = e.GetNextInt();
							sequencePoints.Add
								(new SequencePoint(0, document, line, column));
						}
					}
					else if(e.Type == SymReader.DataType_LineOffsets)
					{
						// Block contains line and offset values only.
						filename = reader.ReadString(e.GetNextInt());
						document = reader.GetDocument(filename);
						while((line = e.GetNextInt()) != -1)
						{
							offset = e.GetNextInt();
							sequencePoints.Add
								(new SequencePoint(offset, document, line, 0));
						}
					}
					else if(e.Type == SymReader.DataType_LineColumnOffsets)
					{
						// Block contains line, column, and offset values.
						filename = reader.ReadString(e.GetNextInt());
						document = reader.GetDocument(filename);
						while((line = e.GetNextInt()) != -1)
						{
							column = e.GetNextInt();
							offset = e.GetNextInt();
							sequencePoints.Add
								(new SequencePoint
									(offset, document, line, column));
						}
					}
				}

				// Sort the sequence points on ascending offset.
				sequencePoints.Sort(new SequencePointComparer());
			}
Exemplo n.º 5
0
	// Load the local variable information.
	private void LoadVariables()
			{
				SymInfoEnumerator e;
				int nameIndex, index;
				int start, end;
				SymScope childScope;
				e = new SymInfoEnumerator(reader, token);
				while(e.MoveNext())
				{
					if(e.Type == SymReader.DataType_LocalVariables)
					{
						// Local variables within the root scope.
						while((nameIndex = e.GetNextInt()) != -1)
						{
							index = e.GetNextInt();
							rootScope.AddLocal
								(reader.ReadString(nameIndex), index);
						}
					}
					else if(e.Type == SymReader.DataType_LocalVariablesOffsets)
					{
						// Local variables within a child scope.
						start = e.GetNextInt();
						end = e.GetNextInt();
						childScope = rootScope.FindScope(end, start);
						while((nameIndex = e.GetNextInt()) != -1)
						{
							index = e.GetNextInt();
							childScope.AddLocal
								(reader.ReadString(nameIndex), index);
						}
					}
				}
			}
Exemplo n.º 6
0
        // Load the sequence point information.
        private void LoadSequencePoints()
        {
            SymInfoEnumerator e;
            String            filename;
            ISymbolDocument   document;
            int line, column, offset;

            // Bail out if we have already loaded the sequence points.
            if (sequencePoints != null)
            {
                return;
            }

            // Create the sequence point list.
            sequencePoints = new ArrayList();

            // Load the sequence point information.
            e = new SymInfoEnumerator(reader, token);
            while (e.MoveNext())
            {
                if (e.Type == SymReader.DataType_LineColumn)
                {
                    // Block contains line and column values only.
                    filename = reader.ReadString(e.GetNextInt());
                    document = reader.GetDocument(filename);
                    while ((line = e.GetNextInt()) != -1)
                    {
                        column = e.GetNextInt();
                        sequencePoints.Add
                            (new SequencePoint(0, document, line, column));
                    }
                }
                else if (e.Type == SymReader.DataType_LineOffsets)
                {
                    // Block contains line and offset values only.
                    filename = reader.ReadString(e.GetNextInt());
                    document = reader.GetDocument(filename);
                    while ((line = e.GetNextInt()) != -1)
                    {
                        offset = e.GetNextInt();
                        sequencePoints.Add
                            (new SequencePoint(offset, document, line, 0));
                    }
                }
                else if (e.Type == SymReader.DataType_LineColumnOffsets)
                {
                    // Block contains line, column, and offset values.
                    filename = reader.ReadString(e.GetNextInt());
                    document = reader.GetDocument(filename);
                    while ((line = e.GetNextInt()) != -1)
                    {
                        column = e.GetNextInt();
                        offset = e.GetNextInt();
                        sequencePoints.Add
                            (new SequencePoint
                                (offset, document, line, column));
                    }
                }
            }

            // Sort the sequence points on ascending offset.
            sequencePoints.Sort(new SequencePointComparer());
        }
Exemplo n.º 7
0
        public virtual ISymbolMethod GetMethodFromDocumentPosition
            (ISymbolDocument document, int line, int column)
        {
            if (document == null || document.URL == null)
            {
                return(null);
            }
            SymInfoEnumerator e = new SymInfoEnumerator(this);
            String            filename;
            ISymbolDocument   doc;
            int tempLine, tempColumn, tempOffset;
            int closestBelow      = 0;
            int closestBelowToken = 0;

            while (e.MoveNext())
            {
                // We only check on line because column values
                // are likely to be inaccurate.
                if (e.Type == DataType_LineColumn)
                {
                    filename = ReadString(e.GetNextInt());
                    doc      = GetDocument(filename);
                    if (doc != null && doc.URL == document.URL)
                    {
                        while ((tempLine = e.GetNextInt()) != -1)
                        {
                            tempColumn = e.GetNextInt();
                            if (tempLine == line)
                            {
                                return(GetMethod(new SymbolToken(e.Token)));
                            }
                            else if (tempLine < line &&
                                     tempLine > closestBelow)
                            {
                                closestBelow      = tempLine;
                                closestBelowToken = e.Token;
                            }
                        }
                    }
                }
                else if (e.Type == DataType_LineOffsets)
                {
                    filename = ReadString(e.GetNextInt());
                    doc      = GetDocument(filename);
                    if (doc != null && doc.URL == document.URL)
                    {
                        while ((tempLine = e.GetNextInt()) != -1)
                        {
                            tempOffset = e.GetNextInt();
                            if (tempLine == line)
                            {
                                return(GetMethod(new SymbolToken(e.Token)));
                            }
                            else if (tempLine < line &&
                                     tempLine > closestBelow)
                            {
                                closestBelow      = tempLine;
                                closestBelowToken = e.Token;
                            }
                        }
                    }
                }
                else if (e.Type == DataType_LineColumnOffsets)
                {
                    filename = ReadString(e.GetNextInt());
                    doc      = GetDocument(filename);
                    if (doc != null && doc.URL == document.URL)
                    {
                        while ((tempLine = e.GetNextInt()) != -1)
                        {
                            tempColumn = e.GetNextInt();
                            tempOffset = e.GetNextInt();
                            if (tempLine == line)
                            {
                                return(GetMethod(new SymbolToken(e.Token)));
                            }
                            else if (tempLine < line &&
                                     tempLine > closestBelow)
                            {
                                closestBelow      = tempLine;
                                closestBelowToken = e.Token;
                            }
                        }
                    }
                }
            }
            if (closestBelowToken != 0)
            {
                // Return the closest match that we found in the
                // document that is below the specified line.
                return(GetMethod(new SymbolToken(closestBelowToken)));
            }
            return(null);
        }
Exemplo n.º 8
0
	internal SymReader(String filename, byte[] data)
			{
				// Store the parameters for later.
				this.filename = filename;
				this.data = data;

				// We need the UTF8 encoding object to decode strings.
				utf8 = Encoding.UTF8;

				// Read and validate the header.
				if(data.Length < 24)
				{
					throw new ArgumentException();
				}
				if(data[0] != (byte)'I' ||
				   data[1] != (byte)'L' ||
				   data[2] != (byte)'D' ||
				   data[3] != (byte)'B' ||
				   data[4] != (byte)0x01 ||
				   data[5] != (byte)0x00 ||
				   data[6] != (byte)0x00 ||
				   data[7] != (byte)0x00)
				{
					throw new ArgumentException();
				}
				indexOffset = Utils.ReadInt32(data, 8);
				numIndexEntries = Utils.ReadInt32(data, 12);
				stringOffset = Utils.ReadInt32(data, 16);
				stringLength = Utils.ReadInt32(data, 20);
				if(indexOffset < 24 || indexOffset >= data.Length)
				{
					throw new ArgumentException();
				}
				if(numIndexEntries < 0 ||
				   ((data.Length - indexOffset) / 8) < numIndexEntries)
				{
					throw new ArgumentException();
				}
				if(stringOffset < 24 || stringOffset >= data.Length)
				{
					throw new ArgumentException();
				}
				if(stringLength <= 0 ||
				   stringLength > (data.Length - stringOffset) ||
				   data[stringOffset + stringLength - 1] != 0)
				{
					throw new ArgumentException();
				}

				// Get the link directory, if specified.
				SymInfoEnumerator e = new SymInfoEnumerator(this, "LDIR");
				if(e.MoveNext())
				{
					linkDirectory = ReadString(e.GetNextInt());
				}
			}
Exemplo n.º 9
0
	public virtual ISymbolMethod GetMethodFromDocumentPosition
				(ISymbolDocument document, int line, int column)
			{
				if(document == null || document.URL == null)
				{
					return null;
				}
				SymInfoEnumerator e = new SymInfoEnumerator(this);
				String filename;
				ISymbolDocument doc;
				int tempLine, tempColumn, tempOffset;
				int closestBelow = 0;
				int closestBelowToken = 0;
				while(e.MoveNext())
				{
					// We only check on line because column values
					// are likely to be inaccurate.
					if(e.Type == DataType_LineColumn)
					{
						filename = ReadString(e.GetNextInt());
						doc = GetDocument(filename);
						if(doc != null && doc.URL == document.URL)
						{
							while((tempLine = e.GetNextInt()) != -1)
							{
								tempColumn = e.GetNextInt();
								if(tempLine == line)
								{
									return GetMethod(new SymbolToken(e.Token));
								}
								else if(tempLine < line &&
								        tempLine > closestBelow)
								{
									closestBelow = tempLine;
									closestBelowToken = e.Token;
								}
							}
						}
					}
					else if(e.Type == DataType_LineOffsets)
					{
						filename = ReadString(e.GetNextInt());
						doc = GetDocument(filename);
						if(doc != null && doc.URL == document.URL)
						{
							while((tempLine = e.GetNextInt()) != -1)
							{
								tempOffset = e.GetNextInt();
								if(tempLine == line)
								{
									return GetMethod(new SymbolToken(e.Token));
								}
								else if(tempLine < line &&
								        tempLine > closestBelow)
								{
									closestBelow = tempLine;
									closestBelowToken = e.Token;
								}
							}
						}
					}
					else if(e.Type == DataType_LineColumnOffsets)
					{
						filename = ReadString(e.GetNextInt());
						doc = GetDocument(filename);
						if(doc != null && doc.URL == document.URL)
						{
							while((tempLine = e.GetNextInt()) != -1)
							{
								tempColumn = e.GetNextInt();
								tempOffset = e.GetNextInt();
								if(tempLine == line)
								{
									return GetMethod(new SymbolToken(e.Token));
								}
								else if(tempLine < line &&
								        tempLine > closestBelow)
								{
									closestBelow = tempLine;
									closestBelowToken = e.Token;
								}
							}
						}
					}
				}
				if(closestBelowToken != 0)
				{
					// Return the closest match that we found in the
					// document that is below the specified line.
					return GetMethod(new SymbolToken(closestBelowToken));
				}
				return null;
			}
Exemplo n.º 10
0
	public virtual ISymbolDocument[] GetDocuments()
			{
				// Bail out early if we already loaded the document list.
				if(documents != null)
				{
					return documents;
				}

				// Read the document information list from the symbol data.
				ArrayList list = new ArrayList();
				SymInfoEnumerator e = new SymInfoEnumerator(this);
				String filename;
				ISymbolDocument doc;
				while(e.MoveNext())
				{
					if(e.Type == DataType_LineColumn ||
					   e.Type == DataType_LineOffsets ||
					   e.Type == DataType_LineColumnOffsets)
					{
						filename = ReadString(e.GetNextInt());
						doc = GetDocument(filename);
						if(doc != null && !list.Contains(doc))
						{
							list.Add(doc);
						}
					}
				}

				// Return the final document list.
				documents = new ISymbolDocument [list.Count];
				int index = 0;
				foreach(ISymbolDocument d in list)
				{
					documents[index++] = d;
				}
				return documents;
			}