Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/adlc/filebuff.hpp
32285 views
1
/*
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.
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
35
class BufferedFile {
36
public:
37
const char *_name;
38
FILE *_fp;
39
inline BufferedFile() { _name = NULL; _fp = NULL; };
40
inline ~BufferedFile() {};
41
};
42
43
class ArchDesc;
44
45
//------------------------------FileBuff--------------------------------------
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.
48
class FileBuff {
49
private:
50
long _bufferSize; // Size of text holding buffer.
51
long _offset; // Expected filepointer offset.
52
long _bufoff; // Start of buffer file offset
53
54
char *_buf; // The buffer itself.
55
char *_bigbuf; // The buffer plus sentinels; actual heap area
56
char *_bufmax; // A pointer to the buffer end sentinel
57
char *_bufeol; // A pointer to the last complete line end
58
59
int _err; // Error flag for file seek/read operations
60
long _filepos; // Current offset from start of file
61
int _linenum;
62
63
ArchDesc& _AD; // Reference to Architecture Description
64
65
// Error reporting function
66
void file_error(int flag, int linenum, const char *fmt, ...);
67
68
public:
69
const BufferedFile *_fp; // File to be buffered
70
71
FileBuff(BufferedFile *fp, ArchDesc& archDesc); // Constructor
72
~FileBuff(); // Destructor
73
74
// This returns a pointer to the start of the current line in the buffer,
75
// and increments bufeol and filepos to point at the end of that line.
76
char *get_line(void);
77
int linenum() const { return _linenum; }
78
void set_linenum(int line) { _linenum = line; }
79
80
// This converts a pointer into the buffer to a file offset. It only works
81
// when the pointer is valid (i.e. just obtained from getline()).
82
long getoff(const char* s) { return _bufoff + (long)(s - _buf); }
83
};
84
#endif // SHARE_VM_ADLC_FILEBUFF_HPP
85
86