Skip to content

Commit e5a8861

Browse files
committed
style: improve code style according to @mikecovlee
Signed-off-by: imkiva <[email protected]>
1 parent 9e3dfd3 commit e5a8861

40 files changed

+111
-124
lines changed

include/kivm/bytecode/bytecodeInterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include <kivm/runtime/javaThread.h>
1010

1111
namespace kivm {
12-
class ByteCodeInterpreter {
12+
class ByteCodeInterpreter final {
1313
public:
1414
/**
1515
* Run a thread method

include/kivm/bytecode/codeBlob.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include <kivm/kivm.h>
77

88
namespace kivm {
9-
class CodeBlob {
9+
class CodeBlob final {
1010
friend class Method;
1111

1212
private:

include/kivm/bytecode/execution.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#define T_LONG 11
2121

2222
namespace kivm {
23-
class Resolver {
23+
class Resolver final {
2424
public:
2525
static oop javaOop(jobject obj);
2626

@@ -43,7 +43,7 @@ namespace kivm {
4343
* Each country has an execution officer,
4444
* and virtual machines are no exception.
4545
*/
46-
class Execution {
46+
class Execution final {
4747
public:
4848
static oop invokeInterface(JavaThread *thread, RuntimeConstantPool *rt,
4949
Stack &stack, int constantIndex, int count);

include/kivm/bytecode/javaCall.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <list>
88

99
namespace kivm {
10-
class JavaCall {
10+
class JavaCall final {
1111
private:
1212
JavaThread *_thread;
1313
Method *_method;

include/kivm/bytecode/threadedInterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ namespace kivm {
2020

2121
class InstanceKlass;
2222

23-
class ThreadedInterpreter {
23+
class ThreadedInterpreter final {
2424
public:
2525
/**
2626
* Run a thread method

include/kivm/classfile/classFile.h

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,24 @@ namespace kivm {
112112
void init(ClassFileStream &stream, cp_info **constant_pool);
113113
};
114114

115-
struct ClassFile {
115+
struct ClassFile final {
116116
/**
117117
* The magic item supplies the magic number identifying the class file format.
118118
* It has the value 0xCAFEBABE.
119119
*/
120-
u4 magic;
121-
u2 minor_version;
122-
u2 major_version;
120+
u4 magic{};
121+
u2 minor_version{};
122+
u2 major_version{};
123123

124-
u2 constant_pool_count;
124+
u2 constant_pool_count{};
125125

126126
/**
127127
* The constant_pool table is indexed
128128
* from {@code 1} to {@code constant_pool_count - 1}.
129129
*/
130-
cp_info **constant_pool;
130+
cp_info **constant_pool = nullptr;
131131

132-
u2 access_flags;
132+
u2 access_flags{};
133133

134134
/**
135135
* The value of the {@code this_class} item must be
@@ -138,7 +138,7 @@ namespace kivm {
138138
* a {@code CONSTANT_Class_info} structure (§4.4.1)
139139
* representing the class or interface defined by this class file.
140140
*/
141-
u2 this_class;
141+
u2 this_class{};
142142

143143
/**
144144
* For a class, the value of the {@code super_class} item either must
@@ -147,18 +147,18 @@ namespace kivm {
147147
* a {@code CONSTANT_Class_info} structure representing
148148
* the direct superclass of the class defined by this class file.
149149
*/
150-
u2 super_class;
150+
u2 super_class{};
151151

152-
u2 interfaces_count;
153-
u2 *interfaces;
152+
u2 interfaces_count{};
153+
u2 *interfaces = nullptr;
154154

155-
u2 fields_count;
156-
field_info *fields;
155+
u2 fields_count{};
156+
field_info *fields = nullptr;
157157

158-
u2 methods_count;
159-
method_info *methods;
158+
u2 methods_count{};
159+
method_info *methods = nullptr;
160160

161-
u2 attributes_count;
162-
attribute_info **attributes;
161+
u2 attributes_count{};
162+
attribute_info **attributes = nullptr;
163163
};
164164
}

include/kivm/classfile/classFileParser.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
#include <kivm/classfile/classFileStream.h>
99

1010
namespace kivm {
11-
class ClassFileParser {
11+
class ClassFileParser final {
1212
public:
1313
static ClassFile *alloc();
1414

1515
static void dealloc(ClassFile *class_file);
1616

1717
private:
18-
ClassFile *_classFile;
18+
ClassFile *_classFile = nullptr;
1919
ClassFileStream _classFileStream;
20-
u1 *_content;
20+
u1 *_content = nullptr;
2121
size_t _size;
2222

2323
ClassFile *parse();

include/kivm/classfile/classFileStream.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ namespace kivm {
2323
* The entire input stream is present in a buffer allocated by the caller.
2424
* The caller is responsible for deallocating the buffer.
2525
*/
26-
class ClassFileStream {
26+
class ClassFileStream final {
2727
private:
28-
u1 *_bufferStart; // Buffer bottom
29-
u1 *_bufferEnd; // Buffer top (one past last element)
30-
u1 *_current; // Current buffer position
28+
u1 *_bufferStart = nullptr; // Buffer bottom
29+
u1 *_bufferEnd = nullptr; // Buffer top (one past last element)
30+
u1 *_current = nullptr; // Current buffer position
3131
String _source; // Source of stream (directory name, ZIP/JAR archive name)
32-
bool _needVerify; // True if verification is on for the class file
32+
bool _needVerify{}; // True if verification is on for the class file
3333

3434
void guaranteeMore(int size) {
3535
auto remaining = (size_t) (_bufferEnd - _current);
@@ -40,7 +40,7 @@ namespace kivm {
4040
}
4141

4242
public:
43-
ClassFileStream();
43+
ClassFileStream() = default;
4444

4545
void init(u1 *buffer, size_t length);
4646

include/kivm/classpath/classPathManager.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ namespace kivm {
1313
JAR
1414
};
1515

16-
struct ClassSearchResult {
16+
struct ClassSearchResult final {
1717
String _file;
18-
int _fd;
18+
int _fd{};
1919
ClassSource _source;
20-
u1 *_buffer;
21-
size_t _bufferSize;
20+
u1 *_buffer = nullptr;
21+
size_t _bufferSize{};
2222

2323
ClassSearchResult(const String &file, int fd, ClassSource source, u1 *buffer, size_t bufferSize);
2424

2525
void closeResource() const;
2626
};
2727

28-
struct ClassPathEntry {
28+
struct ClassPathEntry final {
2929
ClassSource _source;
3030
String _path;
3131
void *_cookie;
3232
};
3333

34-
class ClassPathManager {
34+
class ClassPathManager final {
3535
private:
3636
std::list<ClassPathEntry> _runtimeClassPath;
3737

include/kivm/classpath/system.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace kivm {
1111
class Klass;
1212

13-
class SystemDictionary {
13+
class SystemDictionary final {
1414
private:
1515
HashMap<String, Klass *> _classes;
1616
Lock _lock;

0 commit comments

Comments
 (0)