Skip to content

Commit 87111d0

Browse files
committed
linux 适配
1 parent 4efc487 commit 87111d0

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

CMakeLists.txt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.28.1)
1+
cmake_minimum_required(VERSION 3.13)
22

33
project(jvm)
44

@@ -7,6 +7,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

88
if (MSVC)
99
add_compile_options(/utf-8)
10+
if (VCPKG_TARGET_TRIPLET STREQUAL "x64-windows-static")
11+
set(CMAKE_CXX_FLAGS_DEBUG /MTd)
12+
set(CMAKE_CXX_FLAGS_MINSIZEREL /MT)
13+
set(CMAKE_CXX_FLAGS_RELEASE /MT)
14+
set(CMAKE_CXX_FLAGS_RELWITHDEBUGINFO /MT)
15+
endif ()
1016
endif ()
1117

1218
include_directories(src)

src/jvm/Class.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace jvm {
6161
tag = float_info;
6262
}
6363

64-
float_t bytes{};
64+
float bytes{};
6565
};
6666

6767
struct ConstantInfo_Long final : ConstantInfo {
@@ -77,7 +77,7 @@ namespace jvm {
7777
tag = double_info;
7878
}
7979

80-
double_t bytes{};
80+
double bytes{};
8181
};
8282

8383
struct ConstantInfo_Class final : ConstantInfo {

src/jvm/Runtime.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#include <sese/util/Endian.h>
66
#include <sese/util/Exception.h>
77

8+
#include <cmath>
9+
810
void jvm::Runtime::regClass(const std::shared_ptr<Class> &class_) {
911
classes[class_->getThisName()] = class_;
1012
if (main.class_ == nullptr) {

src/jvm/Runtime.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ namespace jvm {
3030

3131
void run(Info &prev, Info &current);
3232

33-
static struct MethodRefResult {
33+
34+
struct MethodRefResult {
3435
std::string class_name;
3536
std::string method_id;
36-
} getMethodRefResult(const std::shared_ptr<Class> &class_, uint16_t index);
37+
};
38+
static MethodRefResult getMethodRefResult(const std::shared_ptr<Class> &class_, uint16_t index);
3739

3840

3941
std::unordered_map<std::string, std::shared_ptr<Class> > classes;

src/jvm/Type.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
#include <sese/text/StringBuilder.h>
55

66
#include <cassert>
7+
#include <algorithm>
78

89
void jvm::TypeInfo::parse(std::string raw_name) {
910
assert(!raw_name.empty());
1011
// 计算 raw_name 中 [ 的个数
11-
is_array = std::count(raw_name.begin(), raw_name.end(), '[');
12+
is_array = static_cast<uint8_t>(std::count(raw_name.begin(), raw_name.end(), '['));
1213
if (is_array) {
1314
raw_name = raw_name.substr(is_array, raw_name.length() - is_array);
1415
}

src/jvm/Type.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#pragma once
22

33
#include <string>
4+
#include <cstdint>
5+
46

57
namespace jvm {
68
enum Type : char {

0 commit comments

Comments
 (0)