mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
use more warning and debug maybe use uninited
This commit is contained in:
parent
71e87600f9
commit
20b228e3aa
@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.0.0)
|
||||
add_compile_options(-Wall)
|
||||
add_compile_options(-Wall -Wextra -Wno-unused-parameter -Werror)
|
||||
|
||||
project(pikascript VERSION 0.1.0)
|
||||
|
||||
|
0
port/linux/api-make-linux.sh
Normal file → Executable file
0
port/linux/api-make-linux.sh
Normal file → Executable file
0
port/linux/api-make-win10.sh
Normal file → Executable file
0
port/linux/api-make-win10.sh
Normal file → Executable file
0
port/linux/api-make.sh
Normal file → Executable file
0
port/linux/api-make.sh
Normal file → Executable file
0
port/linux/gtest.sh
Normal file → Executable file
0
port/linux/gtest.sh
Normal file → Executable file
0
port/linux/init.sh
Normal file → Executable file
0
port/linux/init.sh
Normal file → Executable file
0
port/linux/make.sh
Normal file → Executable file
0
port/linux/make.sh
Normal file → Executable file
0
port/linux/package/pikascript/rust-msc-latest-linux
Normal file → Executable file
0
port/linux/package/pikascript/rust-msc-latest-linux
Normal file → Executable file
0
port/linux/pkg-push.sh
Normal file → Executable file
0
port/linux/pkg-push.sh
Normal file → Executable file
0
port/linux/pull-core.sh
Normal file → Executable file
0
port/linux/pull-core.sh
Normal file → Executable file
0
port/linux/push-core.sh
Normal file → Executable file
0
port/linux/push-core.sh
Normal file → Executable file
0
port/linux/test-banchmark.sh
Normal file → Executable file
0
port/linux/test-banchmark.sh
Normal file → Executable file
0
port/linux/update-compiler.sh
Normal file → Executable file
0
port/linux/update-compiler.sh
Normal file → Executable file
@ -221,7 +221,7 @@ exit:
|
||||
uint8_t Parser_checkIsDirect(char* str) {
|
||||
/* include '0' */
|
||||
uint32_t size = strGetSize(str) + 1;
|
||||
for (int i = 1; i + 1 < size; i++) {
|
||||
for (uint32_t i = 1; i + 1 < size; i++) {
|
||||
if ((str[i - 1] != '%') && (str[i - 1] != '!') && (str[i - 1] != '<') &&
|
||||
(str[i - 1] != '>') && (str[i - 1] != '=') && (str[i - 1] != '+') &&
|
||||
(str[i - 1] != '-') && (str[i - 1] != '*') && (str[i - 1] != '/') &&
|
||||
@ -239,7 +239,7 @@ char* Lexer_printTokens(Args* outBuffs, char* tokens) {
|
||||
|
||||
/* process */
|
||||
uint16_t tokenSize = strCountSign(tokens, 0x1F) + 1;
|
||||
for (int i = 0; i < tokenSize; i++) {
|
||||
for (uint16_t i = 0; i < tokenSize; i++) {
|
||||
char* token = strsPopToken(buffs, tokens, 0x1F);
|
||||
if (token[0] == TOKEN_operator) {
|
||||
printOut = strsAppend(buffs, printOut, "{opt}");
|
||||
@ -283,8 +283,8 @@ Arg* Lexer_setToken(Arg* tokens_arg,
|
||||
|
||||
Arg* Lexer_setSymbel(Arg* tokens_arg,
|
||||
char* stmt,
|
||||
uint32_t i,
|
||||
int* symbol_start_index) {
|
||||
int32_t i,
|
||||
int32_t* symbol_start_index) {
|
||||
Args* buffs = New_strBuff();
|
||||
char* symbol_buff = NULL;
|
||||
/* nothing to add symbel */
|
||||
@ -316,18 +316,18 @@ char* Lexer_getTokens(Args* outBuffs, char* stmt) {
|
||||
/* init */
|
||||
Arg* tokens_arg = New_arg(NULL);
|
||||
tokens_arg = arg_setStr(tokens_arg, "", "");
|
||||
uint32_t size = strGetSize(stmt);
|
||||
int32_t size = strGetSize(stmt);
|
||||
uint8_t bracket_deepth = 0;
|
||||
uint8_t c0 = 0;
|
||||
uint8_t c1 = 0;
|
||||
uint8_t c2 = 0;
|
||||
uint8_t c3 = 0;
|
||||
int symbol_start_index = -1;
|
||||
int32_t symbol_start_index = -1;
|
||||
int is_in_string = 0;
|
||||
char* tokens;
|
||||
|
||||
/* process */
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
/* update char */
|
||||
c0 = stmt[i];
|
||||
if (i + 1 < size) {
|
||||
@ -564,7 +564,7 @@ char* Lexer_getOperator(Args* outBuffs, char* stmt) {
|
||||
"**", "~", "*", "/", "%", "//", "+", "-", ">>", "<<",
|
||||
"&", "^", "|", "<", "<=", ">", ">=", "!=", "==", "%=",
|
||||
"/=", "//=", "-=", "+=", "*=", "**=", " not ", " and ", " or "};
|
||||
for (int i = 0; i < sizeof(operators) / 6; i++) {
|
||||
for (uint32_t i = 0; i < sizeof(operators) / 6; i++) {
|
||||
if (Lexer_isContain(tokens, (char*)operators[i])) {
|
||||
operator= strsCopy(buffs, (char*)operators[i]);
|
||||
}
|
||||
@ -658,7 +658,7 @@ exit:
|
||||
|
||||
static int32_t Parser_getPyLineBlockDeepth(char* line) {
|
||||
uint32_t size = strGetSize(line);
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
if (line[i] != ' ') {
|
||||
uint32_t spaceNum = i;
|
||||
if (0 == spaceNum % 4) {
|
||||
@ -673,7 +673,7 @@ static int32_t Parser_getPyLineBlockDeepth(char* line) {
|
||||
|
||||
char* Parser_removeAnnotation(char* line) {
|
||||
uint8_t is_annotation_exit = 0;
|
||||
for (int i = 0; i < strGetSize(line); i++) {
|
||||
for (uint32_t i = 0; i < strGetSize(line); i++) {
|
||||
if ('#' == line[i]) {
|
||||
/* end the line */
|
||||
line[i] = 0;
|
||||
@ -686,7 +686,7 @@ char* Parser_removeAnnotation(char* line) {
|
||||
return line;
|
||||
}
|
||||
/* check empty line */
|
||||
for (int i = 0; i < strGetSize(line); i++) {
|
||||
for (uint32_t i = 0; i < strGetSize(line); i++) {
|
||||
if (' ' != line[i]) {
|
||||
return line;
|
||||
}
|
||||
|
37
src/PikaVM.c
37
src/PikaVM.c
@ -109,7 +109,6 @@ Arg* pikaVM_runInstruct(PikaObj* self,
|
||||
Queue* invokeQuene0,
|
||||
Queue* invokeQuene1,
|
||||
int32_t* jmp,
|
||||
int32_t* jmp_block,
|
||||
char* programConter,
|
||||
char* asmStart) {
|
||||
if (instruct == NUM) {
|
||||
@ -204,10 +203,10 @@ Arg* pikaVM_runInstruct(PikaObj* self,
|
||||
Arg* arg2 = arg_copy(queue_popArg(invokeQuene1));
|
||||
ArgType type_arg1 = arg_getType(arg1);
|
||||
ArgType type_arg2 = arg_getType(arg2);
|
||||
int num1_i;
|
||||
int num2_i;
|
||||
float num1_f;
|
||||
float num2_f;
|
||||
int num1_i = 0;
|
||||
int num2_i = 0;
|
||||
float num1_f = 0.0;
|
||||
float num2_f = 0.0;
|
||||
/* get int and float num */
|
||||
if (type_arg1 == TYPE_INT) {
|
||||
num1_i = arg_getInt(arg1);
|
||||
@ -492,11 +491,9 @@ int getThisBlockDeepth(char* start, char* code, int* offset) {
|
||||
return thisBlockDeepth;
|
||||
}
|
||||
|
||||
int32_t VM_getAddrOffsetFromJmp(char* start,
|
||||
char* code,
|
||||
int32_t jmp,
|
||||
int32_t offset,
|
||||
int thisBlockDeepth) {
|
||||
int32_t getAddrOffsetFromJmp(char* start, char* code, int32_t jmp) {
|
||||
int offset = 0;
|
||||
int thisBlockDeepth = getThisBlockDeepth(start, code, &offset);
|
||||
char* codeNow = code + offset;
|
||||
int8_t blockNum = 0;
|
||||
if (jmp > 0) {
|
||||
@ -534,14 +531,6 @@ int32_t VM_getAddrOffsetFromJmp(char* start,
|
||||
return offset;
|
||||
}
|
||||
|
||||
int32_t VM_getAddrOffsetFromJmpByThisBlockDeepth(char* start,
|
||||
char* code,
|
||||
int32_t jmp) {
|
||||
int offset = 0;
|
||||
int thisBlockDeepth = getThisBlockDeepth(start, code, &offset);
|
||||
return VM_getAddrOffsetFromJmp(start, code, jmp, offset, thisBlockDeepth);
|
||||
}
|
||||
|
||||
int32_t pikaVM_runAsmLine(PikaObj* self,
|
||||
Parameters* locals,
|
||||
Parameters* globals,
|
||||
@ -552,7 +541,6 @@ int32_t pikaVM_runAsmLine(PikaObj* self,
|
||||
char* line = strs_getLine(buffs, programCounter);
|
||||
int32_t nextAddr = lineAddr + strGetSize(line) + 1;
|
||||
int32_t jmp = 0;
|
||||
int32_t jmp_block = -1;
|
||||
enum Instruct instruct;
|
||||
char invokeDeepth0[2] = {0}, invokeDeepth1[2] = {0};
|
||||
char* data;
|
||||
@ -581,9 +569,9 @@ int32_t pikaVM_runAsmLine(PikaObj* self,
|
||||
invokeQuene1 = New_queue();
|
||||
args_setPtr(locals->list, invokeDeepth1, invokeQuene1);
|
||||
}
|
||||
resArg = pikaVM_runInstruct(self, locals, globals, instruct, data,
|
||||
invokeQuene0, invokeQuene1, &jmp, &jmp_block,
|
||||
programCounter, pikaAsm);
|
||||
resArg =
|
||||
pikaVM_runInstruct(self, locals, globals, instruct, data, invokeQuene0,
|
||||
invokeQuene1, &jmp, programCounter, pikaAsm);
|
||||
if (NULL != resArg) {
|
||||
queue_pushArg(invokeQuene0, resArg);
|
||||
}
|
||||
@ -594,10 +582,7 @@ nextLine:
|
||||
return -99999;
|
||||
}
|
||||
if (jmp != 0) {
|
||||
if (-1 == jmp_block) {
|
||||
return lineAddr + VM_getAddrOffsetFromJmpByThisBlockDeepth(
|
||||
pikaAsm, programCounter, jmp);
|
||||
}
|
||||
return lineAddr + getAddrOffsetFromJmp(pikaAsm, programCounter, jmp);
|
||||
}
|
||||
return nextAddr;
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ char* strCut(char* strOut, char* strIn, char startSign, char endSign) {
|
||||
|
||||
char* strDeleteChar(char* strOut, char* strIn, char ch) {
|
||||
int32_t iOut = 0;
|
||||
for (int32_t i = 0; i < strGetSize(strIn); i++) {
|
||||
for (uint32_t i = 0; i < strGetSize(strIn); i++) {
|
||||
if (ch == strIn[i]) {
|
||||
continue;
|
||||
}
|
||||
@ -107,7 +107,7 @@ char* strAppendWithSize(char* strOut, char* pData, int32_t Size) {
|
||||
|
||||
int32_t strCountSign(char* strIn, char sign) {
|
||||
int32_t count = 0;
|
||||
for (int32_t i = 0; i < strGetSize(strIn); i++) {
|
||||
for (uint32_t i = 0; i < strGetSize(strIn); i++) {
|
||||
if (sign == strIn[i]) {
|
||||
count++;
|
||||
}
|
||||
@ -210,12 +210,12 @@ char* strGetFirstToken(char* strOut, char* strIn, char sign) {
|
||||
|
||||
int32_t strGetToken(char* string, char** argv, char sign) {
|
||||
int32_t argc = 0;
|
||||
int32_t i = 0;
|
||||
uint32_t i = 0;
|
||||
// arg_i point32_t to the arg operated now
|
||||
int32_t arg_i = 0;
|
||||
// if not found ' ', then put chars from CMD to argv_tem
|
||||
int32_t char_i = 0;
|
||||
for (i = 0; (i < strGetSize(string)); i++) {
|
||||
for (i = 0; i < strGetSize(string); i++) {
|
||||
if (string[i] != sign) {
|
||||
argv[arg_i][char_i] = string[i];
|
||||
char_i++;
|
||||
@ -246,7 +246,7 @@ int32_t strIsStartWith(char* str, char* strStart) {
|
||||
}
|
||||
uint32_t size = strGetSize(strStart);
|
||||
uint32_t CMDName_get = 1;
|
||||
for (int32_t i = 0; i < size; i++) {
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
if (str[i] != strStart[i]) {
|
||||
CMDName_get = 0;
|
||||
}
|
||||
@ -266,21 +266,21 @@ char* strRemovePrefix(char* inputStr, char* prefix, char* outputStr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int32_t i = strGetSize(prefix); i < strGetSize(inputStr); i++) {
|
||||
for (uint32_t i = strGetSize(prefix); i < strGetSize(inputStr); i++) {
|
||||
outputStr[i - strGetSize(prefix)] = inputStr[i];
|
||||
}
|
||||
return outputStr;
|
||||
}
|
||||
|
||||
char* strClear(char* str) {
|
||||
for (int32_t i = 0; i < sizeof(str); i++) {
|
||||
for (uint32_t i = 0; i < sizeof(str); i++) {
|
||||
str[i] = 0;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
int32_t strIsContain(char* str, char ch) {
|
||||
for (int32_t i = 0; i < strGetSize(str); i++) {
|
||||
for (uint32_t i = 0; i < strGetSize(str); i++) {
|
||||
if (str[i] == ch) {
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user