fix warnning on ac5

This commit is contained in:
lyon 2022-12-29 19:49:41 +08:00
parent 9e81800b35
commit 87c1fed401
7 changed files with 38 additions and 37 deletions

View File

@ -92,7 +92,10 @@ static void __handler_instructArray_output_file(InstructArray* self,
PIKA_RES pikaCompile(char* output_file_name, char* py_lines) {
PIKA_RES res = PIKA_RES_OK;
ByteCodeFrame bytecode_frame = {0};
uint32_t const_pool_size = 0;
uint32_t instruct_array_size = 0;
uint32_t bytecode_size = 0;
char void_ = 0;
FILE* bytecode_f = pika_platform_fopen(output_file_name, "wb+");
if (NULL == bytecode_f) {
pika_platform_printf("Error: open file %s failed.\r\n", output_file_name);
@ -112,9 +115,9 @@ PIKA_RES pikaCompile(char* output_file_name, char* py_lines) {
pika_platform_printf(" Error: Syntax error.\r\n");
goto exit;
}
uint32_t const_pool_size = bytecode_frame.const_pool.size;
uint32_t instruct_array_size = bytecode_frame.instruct_array.size;
uint32_t bytecode_size = const_pool_size + instruct_array_size +
const_pool_size = bytecode_frame.const_pool.size;
instruct_array_size = bytecode_frame.instruct_array.size;
bytecode_size = const_pool_size + instruct_array_size +
sizeof(const_pool_size) +
sizeof(instruct_array_size);
byteCodeFrame_deinit(&bytecode_frame);
@ -138,7 +141,7 @@ PIKA_RES pikaCompile(char* output_file_name, char* py_lines) {
/* step 3, write const pool to file */
pika_platform_fwrite(&const_pool_size, 1, sizeof(const_pool_size), bytecode_f);
char void_ = 0;
void_ = 0;
/* add \0 at the start */
pika_platform_fwrite(&void_, 1, 1, bytecode_f);
byteCodeFrame_init(&bytecode_frame);
@ -408,12 +411,12 @@ static PIKA_RES _loadModuleDataWithIndex(uint8_t* library_bytes,
// pika_platform_printf("loading module: %s\r\n", module_name);
*name_p = module_name;
*addr_p = bytecode_addr;
uint32_t module_size =
size_t module_size =
*(uint32_t*)(module_name + LIB_INFO_BLOCK_SIZE - sizeof(uint32_t));
*size = module_size;
bytecode_addr += module_size;
}
return 0;
return PIKA_RES_OK;
}
PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
@ -422,7 +425,7 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
size_t* size_p) {
int module_num = _getModuleNum(library_bytes);
if (module_num < 0) {
return module_num;
return (PIKA_RES)module_num;
}
for (int i = 0; i < module_num; i++) {
char* name = NULL;
@ -433,7 +436,7 @@ PIKA_RES _loadModuleDataWithName(uint8_t* library_bytes,
if (strEqu(module_name, name)) {
*addr_p = addr;
*size_p = size;
return 0;
return PIKA_RES_OK;
}
}
return PIKA_RES_ERR_ARG_NO_FOUND;
@ -797,7 +800,7 @@ int32_t __foreach_handler_linkCompiledModules(Arg* argEach, Args* context) {
PIKA_RES pikaMaker_linkCompiledModulesFullPath(PikaMaker* self,
char* lib_path) {
PIKA_RES compile_err = obj_getInt(self, "err");
PIKA_RES compile_err = (PIKA_RES)obj_getInt(self, "err");
if (PIKA_RES_OK != compile_err) {
pika_platform_printf(" Error: compile failed, link aborted.\r\n");
return compile_err;
@ -833,5 +836,5 @@ PIKA_RES pikaMaker_linkCompiledModules(PikaMaker* self, char* lib_name) {
PIKA_RES pikaMaker_linkRaw(PikaMaker* self, char* file_path) {
LibObj* lib = obj_getPtr(self, "lib");
LibObj_staticLinkFile(lib, file_path);
return 0;
return PIKA_RES_OK;
}

View File

@ -671,7 +671,7 @@ PikaObj* obj_getHostObjWithIsTemp(PikaObj* self,
Method methodArg_getPtr(Arg* method_arg) {
MethodProp* method_store = (MethodProp*)arg_getContent(method_arg);
return method_store->ptr;
return (Method)method_store->ptr;
}
char* methodArg_getTypeList(Arg* method_arg, char* buffs, size_t size) {
@ -1660,13 +1660,13 @@ void _do_pks_eventListener_send(PikaEventListener* self,
void pks_eventListener_send(PikaEventListener* self,
uint32_t eventId,
Arg* eventData) {
return _do_pks_eventListener_send(self, eventId, eventData, PIKA_TRUE);
_do_pks_eventListener_send(self, eventId, eventData, PIKA_TRUE);
}
void pks_eventListener_sendSignal(PikaEventListener* self,
uint32_t eventId,
int eventSignal) {
return pks_eventListener_send(self, eventId, arg_newInt(eventSignal));
pks_eventListener_send(self, eventId, arg_newInt(eventSignal));
}
Arg* pks_eventListener_sendSignalAwaitResult(PikaEventListener* self,

View File

@ -1522,6 +1522,10 @@ char* Suger_not_in(Args* out_buffs, char* line) {
return line;
#endif
char* ret = line;
char* stmt1 = "";
char* stmt2 = "";
PIKA_BOOL got_not_in = PIKA_FALSE;
PIKA_BOOL skip = PIKA_FALSE;
Args buffs = {0};
if (!Cursor_isContain(line, TOKEN_operator, " not ")) {
ret = line;
@ -1531,24 +1535,21 @@ char* Suger_not_in(Args* out_buffs, char* line) {
ret = line;
goto __exit;
}
char* stmt1 = "";
char* stmt2 = "";
PIKA_BOOL got_not_in = 0;
PIKA_BOOL skip = 0;
/* stmt1 not in stmt2 => not stmt1 in stmt2 */
Cursor_forEachToken(cs, line) {
Cursor_iterStart(&cs);
if (!got_not_in) {
if (strEqu(cs.token1.pyload, " not ") &&
strEqu(cs.token2.pyload, " in ")) {
got_not_in = 1;
got_not_in = PIKA_TRUE;
Cursor_iterEnd(&cs);
continue;
}
stmt1 = strsAppend(&buffs, stmt1, cs.token1.pyload);
} else {
if (!skip) {
skip = 1;
skip = PIKA_TRUE;
Cursor_iterEnd(&cs);
continue;
}
@ -2254,6 +2255,8 @@ static char* Suger_from_import_as(Args* buffs_p, char* line) {
char* module = NULL;
char* alias = NULL;
char* stmt = line + 5;
char* class_after = "";
if (!strIsStartWith(line, "from ")) {
line_out = line;
goto exit;
@ -2277,7 +2280,6 @@ static char* Suger_from_import_as(Args* buffs_p, char* line) {
goto exit;
}
char* class_after = "";
while (1) {
char* class_item = Cursor_popToken(&buffs, &class, ",");
if (class_item[0] == '\0') {
@ -2339,6 +2341,7 @@ static char* Suger_import(Args* outbuffs, char* line) {
static char* Parser_linePreProcess(Args* outbuffs, char* line) {
line = Parser_removeAnnotation(line);
Arg* line_buff = NULL;
int line_num = 0;
/* check syntex error */
if (Lexer_isError(line)) {
line = NULL;
@ -2350,7 +2353,7 @@ static char* Parser_linePreProcess(Args* outbuffs, char* line) {
line = Suger_import(outbuffs, line);
/* process multi assign */
int line_num = strCountSign(line, '\n') + 1;
line_num = strCountSign(line, '\n') + 1;
line_buff = arg_newStr("");
for (int i = 0; i < line_num; i++) {
if (i > 0) {

View File

@ -486,7 +486,7 @@ PIKA_WEAK char pika_platform_timer_is_expired(pika_platform_timer_t* timer) {
return platform_uptime_ms() > timer->time ? 1 : 0;
#else
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
return -1;
return 1;
#endif
}
@ -516,7 +516,7 @@ PIKA_WEAK unsigned long pika_platform_timer_now(void) {
return (unsigned long)platform_uptime_ms();
#else
WEAK_FUNCTION_NEED_OVERRIDE_ERROR();
return -1;
return 1;
#endif
}

View File

@ -54,11 +54,11 @@ int _VMEvent_getVMCnt(void) {
#if PIKA_EVENT_ENABLE
static PIKA_BOOL _cq_isEmpty(volatile EventCQ* cq) {
return cq->head == cq->tail;
return (PIKA_BOOL)(cq->head == cq->tail);
}
static PIKA_BOOL _cq_isFull(volatile EventCQ* cq) {
return (cq->tail + 1) % PIKA_EVENT_LIST_SIZE == cq->head;
return (PIKA_BOOL)((cq->tail + 1) % PIKA_EVENT_LIST_SIZE == cq->head);
}
#endif
@ -174,7 +174,7 @@ static VMParameters* __pikaVM_runByteCodeFrameWithState(
/* head declare end */
static void VMState_setErrorCode(VMState* vm, uint8_t error_code) {
static void VMState_setErrorCode(VMState* vm, int8_t error_code) {
vm->error_code = error_code;
}
@ -953,7 +953,7 @@ static void _type_list_parse(FunctionArgsInfo* f) {
}
/* kw */
if (x == 2) {
f->is_keys = 1;
f->is_keys = PIKA_TRUE;
f->n_positional = res - 1;
return;
}
@ -3003,7 +3003,7 @@ VMParameters* _do_pikaVM_runByteCode(PikaObj* self,
/* get bytecode_ptr from stack */
bytecode_frame_p = &bytecode_frame_stack;
/* no def/class ins, no need cache bytecode */
is_const_bytecode = 1;
is_const_bytecode = PIKA_TRUE;
}
/* load or generate byte code frame */
@ -3210,11 +3210,6 @@ void _do_byteCodeFrame_loadByteCode(ByteCodeFrame* self,
}
}
static void byteCodeFrame_loadByteCodeInconst(ByteCodeFrame* self,
uint8_t* bytes) {
_do_byteCodeFrame_loadByteCode(self, bytes, PIKA_FALSE);
}
void byteCodeFrame_loadByteCode(ByteCodeFrame* self, uint8_t* bytes) {
_do_byteCodeFrame_loadByteCode(self, bytes, PIKA_TRUE);
}

View File

@ -72,7 +72,7 @@ struct VMState {
int32_t pc;
ByteCodeFrame* bytecode_frame;
uint8_t loop_deepth;
uint8_t error_code;
int8_t error_code;
uint8_t line_error_code;
uint8_t try_error_code;
uint32_t ins_cnt;

View File

@ -149,10 +149,10 @@ static int32_t _stack_pushArg(Stack* stack, Arg* arg, PIKA_BOOL is_alloc) {
if (is_big_arg) {
/* push a pointer to this arg */
stack_pushSize(stack, -1);
stack_pushPyload(stack, (uint8_t*)&arg, sizeof(Arg*), 1);
stack_pushPyload(stack, (uint8_t*)&arg, sizeof(Arg*), PIKA_TRUE);
} else {
stack_pushSize(stack, size);
stack_pushPyload(stack, (uint8_t*)arg, size, arg_isSerialized(arg));
stack_pushPyload(stack, (uint8_t*)arg, size, (PIKA_BOOL)arg_isSerialized(arg));
}
if (is_big_arg) {