src/share/vm/adlc/filebuff.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 



  25 // FILEBUFF.HPP - Definitions for parser file buffering routines
  26 #include <iostream>
  27 
  28 using namespace std;
  29 
  30 // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
  31 typedef struct {
  32   const char *_name;
  33   FILE *_fp;
  34 } BufferedFile;
  35 
  36 class ArchDesc;
  37 
  38 //------------------------------FileBuff--------------------------------------
  39 // This class defines a nicely behaved buffer of text.  Entire file of text
  40 // is read into buffer at creation, with sentinels at start and end.
  41 class FileBuff {
  42   friend class FileBuffRegion;
  43  private:
  44   long  _bufferSize;            // Size of text holding buffer.


  82 // will coalesce.
  83 class FileBuffRegion {
  84  public:                        // Workaround dev-studio friend/private bug
  85   FileBuffRegion *_next;        // Linked list of regions sorted by offset.
  86  private:
  87   FileBuff       *_bfr;         // The Buffer of the file
  88   int _offset, _length;         // The file area
  89   int             _sol;         // Start of line where the file area starts
  90   int             _line;        // First line of region
  91 
  92  public:
  93   FileBuffRegion(FileBuff*, int sol, int line, int offset, int len);
  94   ~FileBuffRegion();
  95 
  96   FileBuffRegion *copy();                   // Deep copy
  97   FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input
  98 
  99   void print(ostream&);
 100   friend ostream& operator<< (ostream&, FileBuffRegion&);
 101 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_ADLC_FILEBUFF_HPP
  26 #define SHARE_VM_ADLC_FILEBUFF_HPP
  27 
  28 // FILEBUFF.HPP - Definitions for parser file buffering routines
  29 #include <iostream>
  30 
  31 using namespace std;
  32 
  33 // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
  34 typedef struct {
  35   const char *_name;
  36   FILE *_fp;
  37 } BufferedFile;
  38 
  39 class ArchDesc;
  40 
  41 //------------------------------FileBuff--------------------------------------
  42 // This class defines a nicely behaved buffer of text.  Entire file of text
  43 // is read into buffer at creation, with sentinels at start and end.
  44 class FileBuff {
  45   friend class FileBuffRegion;
  46  private:
  47   long  _bufferSize;            // Size of text holding buffer.


  85 // will coalesce.
  86 class FileBuffRegion {
  87  public:                        // Workaround dev-studio friend/private bug
  88   FileBuffRegion *_next;        // Linked list of regions sorted by offset.
  89  private:
  90   FileBuff       *_bfr;         // The Buffer of the file
  91   int _offset, _length;         // The file area
  92   int             _sol;         // Start of line where the file area starts
  93   int             _line;        // First line of region
  94 
  95  public:
  96   FileBuffRegion(FileBuff*, int sol, int line, int offset, int len);
  97   ~FileBuffRegion();
  98 
  99   FileBuffRegion *copy();                   // Deep copy
 100   FileBuffRegion *merge(FileBuffRegion*); // Merge 2 regions; delete input
 101 
 102   void print(ostream&);
 103   friend ostream& operator<< (ostream&, FileBuffRegion&);
 104 };
 105 
 106 #endif // SHARE_VM_ADLC_FILEBUFF_HPP