Skip to content

Commit 6c65a4a

Browse files
committed
VM: update
1 parent 0ab39c7 commit 6c65a4a

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

include/openminecraft/vm/pixeltower/om_pixeltower_interpreter.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class OMInterpreter
1919
OMInterpreter(OMPixelTower &tower);
2020
~OMInterpreter();
2121

22-
void execute(std::string clazz, std::string method, std::string sig);
2322
void execute(std::shared_ptr<OMClass> clazz, std::string method, std::string sig);
2423
void executeDynamic(std::string clazz, std::string method, std::string sig, std::shared_ptr<OMFrameMetadata> frame);
2524
void execute(std::shared_ptr<OMClass> clazz, std::shared_ptr<OMMethodInfo> mi);

src/vm/pixeltower/v0/om_pixeltower.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
#include "openminecraft/vm/pixeltower/om_pixeltower.hpp"
2-
#include "openminecraft/binary/om_bin_hash.hpp"
3-
#include "openminecraft/i18n/om_i18n_res.hpp"
42
#include "openminecraft/log/om_log_ansi.hpp"
53
#include "openminecraft/log/om_log_common.hpp"
64
#include "openminecraft/log/om_log_threadname.hpp"
@@ -46,16 +44,20 @@ void OMPixelTower::registerNativeFunc(std::string clazz, std::string func, std::
4644
}
4745
}
4846

49-
throw err::OMValidationError{err::Instructions, fmt::format("registering native function to a non-native function!"), fmt::format("{}.{}{}", clazz, func, desc)};
47+
throw err::OMValidationError{err::Instructions,
48+
fmt::format("registering native function to a non-native function!"),
49+
fmt::format("{}.{}{}", clazz, func, desc)};
5050
}
5151
std::any OMPixelTower::callNativeFunc(std::string clazz, std::string func, std::string desc, std::any args)
5252
{
5353
auto key = fmt::format("{}.{}{}", clazz, func, desc);
54-
if (nativeFuncs.count(key)) {
54+
if (nativeFuncs.count(key))
55+
{
5556
return nativeFuncs[key](args);
5657
}
5758

58-
throw err::OMValidationError{err::Instructions, fmt::format("native function not found"), fmt::format("{}.{}{}", clazz, func, desc)};
59+
throw err::OMValidationError{err::Instructions, fmt::format("native function not found"),
60+
fmt::format("{}.{}{}", clazz, func, desc)};
5961
}
6062
void OMPixelTower::loadClass(std::shared_ptr<classfile::OMClassFile> file)
6163
{
@@ -93,7 +95,7 @@ std::shared_ptr<OMClass> OMPixelTower::fetchClass(std::string name)
9395
}
9496
void OMPixelTower::execute(std::string clazz, std::string name, std::string desc)
9597
{
96-
std::any_cast<std::shared_ptr<runtime::OMInterpreter>>(interpreter)->execute(clazz, name, desc);
98+
std::any_cast<std::shared_ptr<runtime::OMInterpreter>>(interpreter)->execute(fetchClass(clazz), name, desc);
9799
}
98100
void OMPixelTower::debugStackStatus()
99101
{

src/vm/pixeltower/v0/om_pixeltower_interpreter.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ OMInterpreter::OMInterpreter(OMPixelTower &tower) : tower(tower), logger("pixelt
5050
OMInterpreter::~OMInterpreter()
5151
{
5252
}
53-
void OMInterpreter::execute(std::string clazz, std::string method, std::string sig)
54-
{
55-
return execute(tower.fetchClass(clazz), method, sig);
56-
}
5753
void OMInterpreter::execute(std::shared_ptr<OMClass> clazz, std::string method, std::string sig)
5854
{
5955
for (auto &m : clazz->methods)
@@ -106,7 +102,7 @@ void OMInterpreter::executeDynamic(std::string clazz, std::string method, std::s
106102
tempst.pop();
107103
}
108104

109-
return execute((*((OMClass **)obj))->name, method, sig);
105+
return execute(tower.fetchClass((*((OMClass **)obj))->name), method, sig);
110106
}
111107
else
112108
{

0 commit comments

Comments
 (0)