fix ac5 gnu extention

This commit is contained in:
lyon 2022-03-23 15:20:40 +08:00
parent 5292217175
commit ac33581343
4 changed files with 29 additions and 22 deletions

View File

@ -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 ptr;
return (Method)ptr;
}
Method obj_getNativeMethod(PikaObj* self, char* method_name) {
@ -445,19 +445,22 @@ static int32_t __class_defineMethodWithType(PikaObj* self,
PikaObj* methodHost = obj_getObj(self, methodPath, 1);
char* methodName;
if (NULL == methodHost) {
/* no found method object */
res = 1;
goto exit;
}
methodName = strPointToLastToken(methodPath, '.');
MethodInfo method_info = {
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, '.');
obj_saveMethodInfo(methodHost, &method_info);
res = 0;
goto exit;

View File

@ -1517,8 +1517,12 @@ 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};
for (int i = 0; i < strCountSign(pikaAsm, '\n'); i++) {
char* line = strGetLine(line_buff, asmer.line_pointer);
@ -1532,10 +1536,10 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
/* process each ins */
/* get constPool offset */
uint16_t const_pool_offset = 0;
const_pool_offset = 0;
char* data = line + 6;
uint16_t exist_offset =
data = line + 6;
exist_offset =
constPool_getOffsetByData(&(self->const_pool), data);
/* get const offset */
@ -1553,7 +1557,6 @@ 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);

View File

@ -198,7 +198,10 @@ 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));
@ -247,8 +250,6 @@ 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 */
@ -892,7 +893,7 @@ char* constPool_getNow(ConstPool* self) {
/* is the end */
return NULL;
}
return constPool_getStart(self) + (uintptr_t)(self->content_offset_now);
return (char*)((uintptr_t)constPool_getStart(self) + (uintptr_t)(self->content_offset_now));
}
uint16_t constPool_getLastOffset(ConstPool* self) {
@ -965,11 +966,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 = ins_start_p + *ins_size_p;
uint16_t* const_size_p = (uint16_t *)((uintptr_t)ins_start_p + (uintptr_t)*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 = (void*)const_size_p + 2;
self->const_pool.content_start = (uint16_t *)((uintptr_t)const_size_p + 2);
}
void byteCodeFrame_deinit(ByteCodeFrame* self) {
@ -1022,7 +1023,7 @@ static InstructUnit* instructArray_getNow(InstructArray* self) {
/* is the end */
return NULL;
}
return (InstructUnit*)(instructArray_getStart(self) +
return (InstructUnit*)((uintptr_t)instructArray_getStart(self) +
(uintptr_t)(self->content_offset_now));
}
@ -1171,11 +1172,11 @@ VMParameters* pikaVM_runByteCodeFrame(PikaObj* self,
}
char* constPool_getByOffset(ConstPool* self, uint16_t offset) {
return (char*)(constPool_getStart(self) + (uintptr_t)offset);
return (char*)((uintptr_t)constPool_getStart(self) + (uintptr_t)offset);
}
InstructUnit* instructArray_getByOffset(InstructArray* self, int32_t offset) {
return (InstructUnit*)(instructArray_getStart(self) + (uintptr_t)offset);
return (InstructUnit*)((uintptr_t)instructArray_getStart(self) + (uintptr_t)offset);
}
void constPool_printAsArray(ConstPool* self) {

View File

@ -179,4 +179,4 @@ char* strsGetLine(Args* buffs_p, char* code) {
void strsDeinit(Args* buffs_p) {
link_deinit_stack(buffs_p);
}
}