mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
not use define in some operathion of bytecode
This commit is contained in:
parent
1df5292130
commit
4210cf37c0
42
src/PikaVM.c
42
src/PikaVM.c
@ -823,10 +823,14 @@ exit:
|
|||||||
return globals;
|
return globals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* constPool_getStart(ConstPool* self) {
|
||||||
|
return (char*)arg_getContent(self->arg_buff);
|
||||||
|
}
|
||||||
|
|
||||||
void constPool_init(ConstPool* self) {
|
void constPool_init(ConstPool* self) {
|
||||||
self->arg_buff = arg_setStr(NULL, "", "");
|
self->arg_buff = arg_setStr(NULL, "", "");
|
||||||
self->content_offset_now = 0;
|
self->content_offset_now = 0;
|
||||||
self->size = strGetSize((char*)arg_getContent(self->arg_buff)) + 1;
|
self->size = strGetSize(constPool_getStart(self)) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void constPool_deinit(ConstPool* self) {
|
void constPool_deinit(ConstPool* self) {
|
||||||
@ -844,8 +848,7 @@ char* constPool_getNow(ConstPool* self) {
|
|||||||
/* is the end */
|
/* is the end */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (char*)(arg_getContent(self->arg_buff) +
|
return constPool_getStart(self) + (uintptr_t)(self->content_offset_now);
|
||||||
(uintptr_t)(self->content_offset_now));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t constPool_getLastOffset(ConstPool* self) {
|
uint16_t constPool_getLastOffset(ConstPool* self) {
|
||||||
@ -939,29 +942,24 @@ void instructUnit_init(InstructUnit* ins_unit) {
|
|||||||
ins_unit->isNewLine_instruct = 0;
|
ins_unit->isNewLine_instruct = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructUnit* instructArray_getNow(InstructArray* self) {
|
static InstructUnit* instructArray_getStart(InstructArray* self) {
|
||||||
|
return (InstructUnit*)(arg_getContent(self->arg_buff));
|
||||||
|
}
|
||||||
|
|
||||||
|
static InstructUnit* instructArray_getNow(InstructArray* self) {
|
||||||
if (self->content_offset_now >= self->size) {
|
if (self->content_offset_now >= self->size) {
|
||||||
/* is the end */
|
/* is the end */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (InstructUnit*)(arg_getContent(self->arg_buff) +
|
return instructArray_getStart(self) + (uintptr_t)(self->content_offset_now);
|
||||||
(uintptr_t)(self->content_offset_now));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructUnit* instructArray_getNext(InstructArray* self) {
|
static InstructUnit* instructArray_getNext(InstructArray* self) {
|
||||||
self->content_offset_now += instructUnit_getSize();
|
self->content_offset_now += instructUnit_getSize();
|
||||||
return instructArray_getNow(self);
|
return instructArray_getNow(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructUnit* instructArray_getLast(InstructArray* self) {
|
static char* instructUnit_getInstructStr(InstructUnit* self) {
|
||||||
if (0 == self->content_offset_now) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
self->content_offset_now -= instructUnit_getSize();
|
|
||||||
return instructArray_getNow(self);
|
|
||||||
}
|
|
||||||
|
|
||||||
char* instructUnit_getInstructStr(InstructUnit* self) {
|
|
||||||
#define __INS_GET_INS_STR
|
#define __INS_GET_INS_STR
|
||||||
#include "__instruction_table.cfg"
|
#include "__instruction_table.cfg"
|
||||||
return "NON";
|
return "NON";
|
||||||
@ -976,7 +974,8 @@ void instructUnit_print(InstructUnit* self) {
|
|||||||
self->const_pool_index);
|
self->const_pool_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void instructUnit_printWithConst(InstructUnit* self, ConstPool* const_pool) {
|
static void instructUnit_printWithConst(InstructUnit* self,
|
||||||
|
ConstPool* const_pool) {
|
||||||
if (instructUnit_getIsNewLine(self)) {
|
if (instructUnit_getIsNewLine(self)) {
|
||||||
__platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
__platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
||||||
}
|
}
|
||||||
@ -1074,3 +1073,12 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
|||||||
ByteCodeFrame* byteCode_frame) {
|
ByteCodeFrame* byteCode_frame) {
|
||||||
return pikaVM_runByteCodeWithState(self, self, self, byteCode_frame, 0);
|
return pikaVM_runByteCodeWithState(self, self, self, byteCode_frame, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* constPool_getByOffset(ConstPool* self, uint16_t offset) {
|
||||||
|
return (char*)((void*)constPool_getStart(self) + (uintptr_t)offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset) {
|
||||||
|
return (InstructUnit*)((void*)instructArray_getStart(self) +
|
||||||
|
(uintptr_t)offset);
|
||||||
|
}
|
||||||
|
24
src/PikaVM.h
24
src/PikaVM.h
@ -59,8 +59,6 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
|||||||
|
|
||||||
#define instructUnit_getBlockDeepth(self) (((self)->deepth) & 0x0F)
|
#define instructUnit_getBlockDeepth(self) (((self)->deepth) & 0x0F)
|
||||||
#define instructUnit_getInvokeDeepth(self) (((self)->deepth) >> 4)
|
#define instructUnit_getInvokeDeepth(self) (((self)->deepth) >> 4)
|
||||||
// #define instructUnit_getDataSize(self) (strGetSize((char*)(self)->data))
|
|
||||||
// #define instructUnit_getData(self) (char*)((self)->data)
|
|
||||||
#define instructUnit_getInstruct(self) \
|
#define instructUnit_getInstruct(self) \
|
||||||
((enum Instruct)((self)->isNewLine_instruct & 0x7F))
|
((enum Instruct)((self)->isNewLine_instruct & 0x7F))
|
||||||
#define instructUnit_getConstPoolIndex(self) ((self)->const_pool_index)
|
#define instructUnit_getConstPoolIndex(self) ((self)->const_pool_index)
|
||||||
@ -81,13 +79,6 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
|||||||
((self)->deepth) |= ((0x0F & (val)) << 4); \
|
((self)->deepth) |= ((0x0F & (val)) << 4); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
|
||||||
#define instructUnit_setData(self, val) \
|
|
||||||
do { \
|
|
||||||
__platform_memcpy((self)->data, val, strGetSize(val) + 1); \
|
|
||||||
} while (0)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define instructUnit_setInstruct(self, val) \
|
#define instructUnit_setInstruct(self, val) \
|
||||||
do { \
|
do { \
|
||||||
((self)->isNewLine_instruct) |= (0x7F & (val)); \
|
((self)->isNewLine_instruct) |= (0x7F & (val)); \
|
||||||
@ -101,14 +92,6 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
|||||||
InstructUnit* New_instructUnit(uint8_t data_size);
|
InstructUnit* New_instructUnit(uint8_t data_size);
|
||||||
void instructUnit_deinit(InstructUnit* self);
|
void instructUnit_deinit(InstructUnit* self);
|
||||||
|
|
||||||
/*
|
|
||||||
#define __get_alined_size(size) (((((size)-1) / 4) + 1) * 4)
|
|
||||||
#define instructUnit_getTotleSize_withDataSize(data_size) \
|
|
||||||
(__get_alined_size(instructUnit_getSize() + data_size + 1))
|
|
||||||
#define instructUnit_getTotleSize(self) \
|
|
||||||
(instructUnit_getTotleSize_withDataSize(instructUnit_getDataSize(self)))
|
|
||||||
*/
|
|
||||||
|
|
||||||
enum Instruct pikaVM_getInstructFromAsm(char* line);
|
enum Instruct pikaVM_getInstructFromAsm(char* line);
|
||||||
|
|
||||||
void constPool_init(ConstPool* self);
|
void constPool_init(ConstPool* self);
|
||||||
@ -117,12 +100,10 @@ void constPool_append(ConstPool* self, char* content);
|
|||||||
char* constPool_getNow(ConstPool* self);
|
char* constPool_getNow(ConstPool* self);
|
||||||
char* constPool_getNext(ConstPool* self);
|
char* constPool_getNext(ConstPool* self);
|
||||||
char* constPool_getByIndex(ConstPool* self, uint16_t index);
|
char* constPool_getByIndex(ConstPool* self, uint16_t index);
|
||||||
|
char* constPool_getByOffset(ConstPool* self, uint16_t offset);
|
||||||
uint16_t constPool_getLastOffset(ConstPool* self);
|
uint16_t constPool_getLastOffset(ConstPool* self);
|
||||||
void constPool_print(ConstPool* self);
|
void constPool_print(ConstPool* self);
|
||||||
|
|
||||||
#define constPool_getByOffset(ConstPoll_p_self, uint16_t_offset) \
|
|
||||||
((char*)(arg_getContent((ConstPoll_p_self)->arg_buff) + \
|
|
||||||
(uintptr_t)(uint16_t_offset)))
|
|
||||||
|
|
||||||
void byteCodeFrame_init(ByteCodeFrame* bf);
|
void byteCodeFrame_init(ByteCodeFrame* bf);
|
||||||
void byteCodeFrame_deinit(ByteCodeFrame* bf);
|
void byteCodeFrame_deinit(ByteCodeFrame* bf);
|
||||||
@ -137,9 +118,6 @@ void instructArray_print(InstructArray* self);
|
|||||||
void byteCodeFrame_print(ByteCodeFrame* self);
|
void byteCodeFrame_print(ByteCodeFrame* self);
|
||||||
InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset);
|
InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset);
|
||||||
|
|
||||||
#define instructArray_getByOffset(InstructArray_p_self, int32_t_offset) \
|
|
||||||
((InstructUnit*)(arg_getContent((InstructArray_p_self)->arg_buff) + \
|
|
||||||
(uintptr_t)(int32_t_offset)));
|
|
||||||
|
|
||||||
#define instructUnit_getSize(InstructUnit_p_self) ((size_t)sizeof(InstructUnit))
|
#define instructUnit_getSize(InstructUnit_p_self) ((size_t)sizeof(InstructUnit))
|
||||||
#define instructArray_getSize(InsturctArry_p_self) \
|
#define instructArray_getSize(InsturctArry_p_self) \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user