mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
restore ac5 fix
This commit is contained in:
parent
ac33581343
commit
e5cdf022dd
@ -390,7 +390,7 @@ Method methodArg_getPtr(Arg* method_arg) {
|
||||
void* info = arg_getContent(method_arg);
|
||||
void* ptr = NULL;
|
||||
__platform_memcpy(&ptr, info, size_ptr);
|
||||
return (Method)ptr;
|
||||
return ptr;
|
||||
}
|
||||
|
||||
Method obj_getNativeMethod(PikaObj* self, char* method_name) {
|
||||
@ -445,22 +445,19 @@ static int32_t __class_defineMethodWithType(PikaObj* self,
|
||||
|
||||
PikaObj* methodHost = obj_getObj(self, methodPath, 1);
|
||||
char* methodName;
|
||||
|
||||
MethodInfo method_info = {
|
||||
.dec = cleanDeclearation,
|
||||
.name = methodName,
|
||||
.ptr = (void*)methodPtr,
|
||||
.type = method_type,
|
||||
.bytecode_frame = bytecode_frame,
|
||||
};
|
||||
|
||||
if (NULL == methodHost) {
|
||||
/* no found method object */
|
||||
res = 1;
|
||||
goto exit;
|
||||
}
|
||||
methodName = strPointToLastToken(methodPath, '.');
|
||||
|
||||
MethodInfo method_info = {
|
||||
.dec = cleanDeclearation,
|
||||
.name = methodName,
|
||||
.ptr = (void*)methodPtr,
|
||||
.type = method_type,
|
||||
.bytecode_frame = bytecode_frame,
|
||||
};
|
||||
obj_saveMethodInfo(methodHost, &method_info);
|
||||
res = 0;
|
||||
goto exit;
|
||||
|
@ -1517,12 +1517,8 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
||||
.is_new_line = 0,
|
||||
.line_pointer = pikaAsm,
|
||||
};
|
||||
uint16_t const_pool_offset;
|
||||
char* data;
|
||||
char line_buff[PIKA_CONFIG_PATH_BUFF_SIZE] = {0};
|
||||
uint16_t exist_offset;
|
||||
InstructUnit ins_unit = {0};
|
||||
|
||||
char line_buff[PIKA_CONFIG_PATH_BUFF_SIZE] = {0};
|
||||
for (int i = 0; i < strCountSign(pikaAsm, '\n'); i++) {
|
||||
char* line = strGetLine(line_buff, asmer.line_pointer);
|
||||
|
||||
@ -1536,10 +1532,10 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
||||
/* process each ins */
|
||||
|
||||
/* get constPool offset */
|
||||
const_pool_offset = 0;
|
||||
uint16_t const_pool_offset = 0;
|
||||
|
||||
data = line + 6;
|
||||
exist_offset =
|
||||
char* data = line + 6;
|
||||
uint16_t exist_offset =
|
||||
constPool_getOffsetByData(&(self->const_pool), data);
|
||||
|
||||
/* get const offset */
|
||||
@ -1557,6 +1553,7 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
||||
}
|
||||
|
||||
/* load Asm to byte code unit */
|
||||
InstructUnit ins_unit = {0};
|
||||
instructUnit_setBlockDeepth(&ins_unit, asmer.block_deepth_now);
|
||||
instructUnit_setInvokeDeepth(&ins_unit, line[0] - '0');
|
||||
instructUnit_setConstPoolIndex(&ins_unit, const_pool_offset);
|
||||
|
17
src/PikaVM.c
17
src/PikaVM.c
@ -198,10 +198,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self, VMState* vs, char* data) {
|
||||
char* method_dec;
|
||||
char* type_list;
|
||||
char* sys_out;
|
||||
Arg* call_arg = NULL;
|
||||
uint8_t call_arg_index = 0;
|
||||
ByteCodeFrame* method_bytecodeFrame;
|
||||
|
||||
/* return arg directly */
|
||||
if (strEqu(data, "")) {
|
||||
return_arg = arg_copy(queue_popArg(vs->qSuper));
|
||||
@ -250,6 +247,8 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self, VMState* vs, char* data) {
|
||||
}
|
||||
|
||||
sub_locals = New_PikaObj();
|
||||
Arg* call_arg = NULL;
|
||||
uint8_t call_arg_index = 0;
|
||||
/* load pars */
|
||||
while (1) {
|
||||
/* load 'self' as the first arg when call object method */
|
||||
@ -893,7 +892,7 @@ char* constPool_getNow(ConstPool* self) {
|
||||
/* is the end */
|
||||
return NULL;
|
||||
}
|
||||
return (char*)((uintptr_t)constPool_getStart(self) + (uintptr_t)(self->content_offset_now));
|
||||
return constPool_getStart(self) + (uintptr_t)(self->content_offset_now);
|
||||
}
|
||||
|
||||
uint16_t constPool_getLastOffset(ConstPool* self) {
|
||||
@ -966,11 +965,11 @@ void byteCodeFrame_init(ByteCodeFrame* self) {
|
||||
void byteCodeFrame_loadBytes(ByteCodeFrame* self, uint8_t* bytes) {
|
||||
uint16_t* ins_size_p = (uint16_t*)bytes;
|
||||
void* ins_start_p = (uint16_t*)(bytes + 2);
|
||||
uint16_t* const_size_p = (uint16_t *)((uintptr_t)ins_start_p + (uintptr_t)*ins_size_p);
|
||||
uint16_t* const_size_p = ins_start_p + *ins_size_p;
|
||||
self->instruct_array.size = *ins_size_p;
|
||||
self->instruct_array.content_start = ins_start_p;
|
||||
self->const_pool.size = *const_size_p;
|
||||
self->const_pool.content_start = (uint16_t *)((uintptr_t)const_size_p + 2);
|
||||
self->const_pool.content_start = (void*)const_size_p + 2;
|
||||
}
|
||||
|
||||
void byteCodeFrame_deinit(ByteCodeFrame* self) {
|
||||
@ -1023,7 +1022,7 @@ static InstructUnit* instructArray_getNow(InstructArray* self) {
|
||||
/* is the end */
|
||||
return NULL;
|
||||
}
|
||||
return (InstructUnit*)((uintptr_t)instructArray_getStart(self) +
|
||||
return (InstructUnit*)(instructArray_getStart(self) +
|
||||
(uintptr_t)(self->content_offset_now));
|
||||
}
|
||||
|
||||
@ -1172,11 +1171,11 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
|
||||
}
|
||||
|
||||
char* constPool_getByOffset(ConstPool* self, uint16_t offset) {
|
||||
return (char*)((uintptr_t)constPool_getStart(self) + (uintptr_t)offset);
|
||||
return (char*)(constPool_getStart(self) + (uintptr_t)offset);
|
||||
}
|
||||
|
||||
InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset) {
|
||||
return (InstructUnit*)((uintptr_t)instructArray_getStart(self) + (uintptr_t)offset);
|
||||
return (InstructUnit*)(instructArray_getStart(self) + (uintptr_t)offset);
|
||||
}
|
||||
|
||||
void constPool_printAsArray(ConstPool* self) {
|
||||
|
@ -179,4 +179,4 @@ char* strsGetLine(Args* buffs_p, char* code) {
|
||||
|
||||
void strsDeinit(Args* buffs_p) {
|
||||
link_deinit_stack(buffs_p);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user