byteCodePrint is ok

This commit is contained in:
lyon1998 2022-03-13 13:04:07 +08:00
parent eb35a8c536
commit d83265d345
3 changed files with 8 additions and 3 deletions

View File

@ -2132,8 +2132,7 @@ TEST(asmer, asmer_to_instructUnit) {
ByteCodeFrame bytecode_frame;
byteCodeFrame_init(&bytecode_frame);
byteCodeFrame_appendFromAsm(&bytecode_frame, asm_line);
constPool_print(&(bytecode_frame.const_pool));
instructArray_print(&(bytecode_frame.instruct_array));
byteCodeFrame_print(&bytecode_frame);
size_t byteCode_size = byteCodeFrame_getSize(&bytecode_frame);
EXPECT_EQ(byteCode_size, 33);
EXPECT_STREQ(constPool_getNext(&(bytecode_frame.const_pool)), (char*)"2");

View File

@ -997,6 +997,11 @@ exit:
return;
}
size_t byteCodeFrame_getSize(ByteCodeFrame* bf){
size_t byteCodeFrame_getSize(ByteCodeFrame* bf) {
return bf->const_pool.size + bf->instruct_array.size;
}
void byteCodeFrame_print(ByteCodeFrame* self) {
constPool_print(&(self->const_pool));
instructArray_print(&(self->instruct_array));
}

View File

@ -138,5 +138,6 @@ void instructArray_append(InstructArray* ins_array, InstructUnit* ins_unit);
void instructUnit_init(InstructUnit* ins_unit);
void instructUnit_print(InstructUnit* self);
void instructArray_print(InstructArray* self);
void byteCodeFrame_print(ByteCodeFrame* self);
#endif