Skip to content

Commit

Permalink
[bugfix] multiple definiton error for logging fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lvntky committed Jun 22, 2024
1 parent 00d5a79 commit 3ae2547
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 10 deletions.
4 changes: 4 additions & 0 deletions cmake/SourcesAndHeaders.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set(sources
src/log.cpp
src/classfile/classfile.cpp
src/stack/frame.cpp
src/execute_engine/cvm_execute.cpp

)

Expand All @@ -11,6 +13,7 @@ set(exe_sources

set(headers
include/cvm/fmt_commons.hpp
include/cvm/log.hpp
include/cvm/banner.hpp
include/cvm/classfile/classfile.hpp
include/cvm/classfile/cp_info.hpp
Expand All @@ -19,6 +22,7 @@ set(headers
include/cvm/classfile/field_info.hpp
include/cvm/stack/frame.hpp
include/cvm/stack/cvm_stack.hpp
include/cvm/execute_engine/cvm_execute.hpp
)


Expand Down
23 changes: 23 additions & 0 deletions include/cvm/execute_engine/cvm_execute.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef __CVM_EXECUTE_HPP__
#define __CVM_EXECUTE_HPP__

#include <iostream>
#include <stack>
#include <vector>

#include "../classfile/classfile.hpp"
#include "../log.hpp"

class CVM
{
public:
CVM() = default;
void execute(const Classfile& cf, const std::string& methodName);

private:
std::string getUtf8FromConstantPool(const Classfile& cf, uint16_t index);
const method_info* findMehodByName(const Classfile& cf, const std::string& methodName);
const uint8_t* getByteCode(const method_info* methodInfo);
};

#endif //__CVM_EXECUTE_HPP__
13 changes: 5 additions & 8 deletions include/cvm/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
#define __LOG_HPP__

#include <spdlog/spdlog.h>

#include <memory>

#define LOG_OK "OK"
#define LOG_NOK "NOK"
#define LOG_OK "OK"
#define LOG_NOK "NOK"
#define DEBUG_ENABLED 0

void setLevel() {
if(DEBUG_ENABLED) {
spdlog::set_level(spdlog::level::debug);
void setLevel();

}
}
#endif //__LOG_HPP__
#endif //__LOG_HPP__
1 change: 1 addition & 0 deletions src/execute_engine/cvm_execute.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "../../include/cvm/execute_engine/cvm_execute.hpp"
9 changes: 9 additions & 0 deletions src/log.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "../include/cvm/log.hpp"

void setLevel()
{
if (DEBUG_ENABLED)
{
spdlog::set_level(spdlog::level::debug);
}
}
2 changes: 0 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ int main(int argc, char** argv)

classFile.close();

Frame frame(10, 10);
fmt::print("frame: {}", frame.getOperandStackSize());
return 0;
}

0 comments on commit 3ae2547

Please sign in to comment.