src/share/vm/adlc/filebuff.hpp

changeset 9816
acd345f4f9e5
parent 4161
d336b3173277
child 9852
70aa912cebe5
equal deleted inserted replaced
9815:127e100fb80e 9816:acd345f4f9e5
1 /* 1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
44 44
45 //------------------------------FileBuff-------------------------------------- 45 //------------------------------FileBuff--------------------------------------
46 // This class defines a nicely behaved buffer of text. Entire file of text 46 // This class defines a nicely behaved buffer of text. Entire file of text
47 // is read into buffer at creation, with sentinels at start and end. 47 // is read into buffer at creation, with sentinels at start and end.
48 class FileBuff { 48 class FileBuff {
49 friend class FileBuffRegion;
50 private: 49 private:
51 long _bufferSize; // Size of text holding buffer. 50 long _bufferSize; // Size of text holding buffer.
52 long _offset; // Expected filepointer offset. 51 long _offset; // Expected filepointer offset.
53 long _bufoff; // Start of buffer file offset 52 long _bufoff; // Start of buffer file offset
54 53
80 79
81 // This converts a pointer into the buffer to a file offset. It only works 80 // This converts a pointer into the buffer to a file offset. It only works
82 // when the pointer is valid (i.e. just obtained from getline()). 81 // when the pointer is valid (i.e. just obtained from getline()).
83 long getoff(const char* s) { return _bufoff + (long)(s - _buf); } 82 long getoff(const char* s) { return _bufoff + (long)(s - _buf); }
84 }; 83 };
85
86 //------------------------------FileBuffRegion---------------------------------
87 // A buffer region is really a region of some file, specified as a linked list
88 // of offsets and lengths. These regions can be merged; overlapping regions
89 // will coalesce.
90 class FileBuffRegion {
91 public: // Workaround dev-studio friend/private bug
92 FileBuffRegion *_next; // Linked list of regions sorted by offset.
93 private:
94 FileBuff *_bfr; // The Buffer of the file
95 int _offset, _length; // The file area
96 int _sol; // Start of line where the file area starts
97 int _line; // First line of region
98
99 public:
100 FileBuffRegion(FileBuff*, int sol, int line, int offset, int len);
101 ~FileBuffRegion();
102
103 FileBuffRegion *copy(); // Deep copy
104 FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input
105
106 void print(ostream&);
107 friend ostream& operator<< (ostream&, FileBuffRegion&);
108 };
109
110 #endif // SHARE_VM_ADLC_FILEBUFF_HPP 84 #endif // SHARE_VM_ADLC_FILEBUFF_HPP

mercurial