Skip to content

Commit

Permalink
[feature] basic interpreting
Browse files Browse the repository at this point in the history
  • Loading branch information
lvntky committed Jun 22, 2024
1 parent 97a0776 commit 2d4d448
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/execute_engine/cvm_execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ void CVM::execute(const Classfile& cf, const std::string& methodName) {

const uint8_t* bytecode = getByteCode(cf, methodInfo);
validateByteCode(bytecode);

spdlog::info("Size of bytecode: {}", sizeof(bytecode));

interprete(bytecode, cf);
}

std::string CVM::getUtf8FromConstantPool(const Classfile& cf, uint16_t index) {
Expand Down Expand Up @@ -71,3 +75,18 @@ const uint8_t* CVM::getByteCode(const Classfile& cf,
}
return nullptr;
}

void CVM::interprete(const uint8_t* byteCode, const Classfile& cf) {
size_t pc = 0;
std::stack<int> operandStack;
size_t codeLength = sizeof(byteCode);

while (pc < 100) {
uint8_t opcode = byteCode[pc++];
switch (opcode) {
default:
spdlog::error("Unknown Opcode: {:#04x} at PC: {}", opcode, pc);
break;
}
}
}

0 comments on commit 2d4d448

Please sign in to comment.