diff --git a/port/linux/.vscode/launch.json b/port/linux/.vscode/launch.json index 56ddd162d..fcd1f2db0 100644 --- a/port/linux/.vscode/launch.json +++ b/port/linux/.vscode/launch.json @@ -23,7 +23,7 @@ // "--gtest_filter=except.try_import_except" // "--gtest_filter=vm.test_cmodule_import_as" // "--gtest_filter=vm.subsrc_import" - // "--gtest_filter=event.event_thread" + "--gtest_filter=event.event_thread3" // "--gtest_filter=module.while_loop" ], "stopAtEntry": false, diff --git a/port/linux/package/pikascript/main.py b/port/linux/package/pikascript/main.py index 4b4f9d555..dff24d92a 100644 --- a/port/linux/package/pikascript/main.py +++ b/port/linux/package/pikascript/main.py @@ -1,6 +1,7 @@ import PikaStdLib import PikaDebug import this +from subsrc import mod1 print('hello pikapython!') mem = PikaStdLib.MemChecker() diff --git a/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c b/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c index 2692f7334..d30231be9 100644 --- a/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c +++ b/port/linux/package/pikascript/pikascript-lib/PikaStdDevice/pika_hal_SOFT_SPI.c @@ -63,7 +63,7 @@ int pika_hal_platform_SOFT_SPI_ioctl_enable(pika_dev* dev) { } pika_debug("SCK[0x%p] config", cfg->SCK); pika_hal_ioctl(cfg->SCK, PIKA_HAL_IOCTL_CONFIG, &cfg_SCK); - if (NULL != cfg->MOSI){ + if (NULL != cfg->MOSI) { pika_debug("MOSI[0x%p] config", cfg->MOSI); pika_hal_ioctl(cfg->MOSI, PIKA_HAL_IOCTL_CONFIG, &cfg_MOSI); } @@ -78,7 +78,7 @@ int pika_hal_platform_SOFT_SPI_ioctl_enable(pika_dev* dev) { } pika_debug("SCK[0x%p] enable", cfg->SCK); pika_hal_ioctl(cfg->SCK, PIKA_HAL_IOCTL_ENABLE); - if (NULL != cfg->MOSI){ + if (NULL != cfg->MOSI) { pika_debug("MOSI[0x%p] enable", cfg->MOSI); pika_hal_ioctl(cfg->MOSI, PIKA_HAL_IOCTL_ENABLE); } @@ -91,7 +91,7 @@ int pika_hal_platform_SOFT_SPI_ioctl_enable(pika_dev* dev) { _GPIO_write(cfg->CS, 1); } _GPIO_write(cfg->SCK, 1); - if (NULL != cfg->MOSI){ + if (NULL != cfg->MOSI) { _GPIO_write(cfg->MOSI, 1); } return 0; diff --git a/src/PikaObj.c b/src/PikaObj.c index 31756bafe..eb5fa145a 100644 --- a/src/PikaObj.c +++ b/src/PikaObj.c @@ -3016,14 +3016,14 @@ PIKA_RES _do_pika_eventListener_send(PikaEventListener* self, if (pika_GIL_isInit()) { /* python thread is running */ /* wait python thread get first lock */ - while (1){ - if (_VM_is_first_lock()){ + while (1) { + if (_VM_is_first_lock()) { break; } - if (pika_GIL_getBareLock() == 0){ + if (g_PikaVMState.vm_cnt == 0) { break; } - if (g_PikaVMState.vm_cnt == 0){ + if (pika_GIL_getBareLock() == 0) { break; } pika_platform_thread_yield(); diff --git a/src/PikaObj.h b/src/PikaObj.h index 2ae76d45f..04e0900c7 100644 --- a/src/PikaObj.h +++ b/src/PikaObj.h @@ -777,7 +777,7 @@ const MethodProp floatMethod = { #define pika_class(_method) _method##NativeProp void _obj_updateProxyFlag(PikaObj* self); -#define obj_setClass(_self, _method) \ +#define obj_setClass(_self, _method) \ obj_setPtr((_self), "@p_", (void*)&pika_class(_method)); \ _obj_updateProxyFlag((_self)) @@ -842,7 +842,6 @@ int pika_GIL_EXIT(void); int pika_GIL_ENTER(void); int pika_GIL_getBareLock(void); - int32_t pika_debug_find_break_point_pc(char* pyFile, uint32_t pyLine); typedef PikaObj PikaList; diff --git a/src/PikaVM.c b/src/PikaVM.c index 6c3002fa2..755aac1bd 100644 --- a/src/PikaVM.c +++ b/src/PikaVM.c @@ -92,18 +92,15 @@ int pika_GIL_ENTER(void) { return ret; } -int pika_GIL_getBareLock(void){ +int pika_GIL_getBareLock(void) { return g_pikaGIL.mutex.bare_lock; } int pika_GIL_EXIT(void) { - if (!g_pikaGIL.mutex.is_init) { + if (!g_pikaGIL.mutex.is_first_lock || !g_pikaGIL.mutex.is_init) { g_pikaGIL.mutex.bare_lock = 0; return 0; } - if (!g_pikaGIL.mutex.is_first_lock) { - return 0; - } return pika_thread_recursive_mutex_unlock(&g_pikaGIL); } @@ -2658,6 +2655,15 @@ static void _OPT_ADD(OperatorInfo* op) { return; } #endif + // Check if either argument is a string and the other is not a string + if ((op->t1 == ARG_TYPE_STRING && op->t2 != ARG_TYPE_STRING) || + (op->t2 == ARG_TYPE_STRING && op->t1 != ARG_TYPE_STRING)) { + PikaVMFrame_setErrorCode(op->vm, PIKA_RES_ERR_OPERATION_FAILED); + PikaVMFrame_setSysOut( + op->vm, "TypeError: unsupported operand + between str and non-str"); + op->res = NULL; + return; + } if ((op->t1 == ARG_TYPE_STRING) && (op->t2 == ARG_TYPE_STRING)) { char* num1_s = NULL; char* num2_s = NULL; diff --git a/src/PikaVersion.h b/src/PikaVersion.h index 8720d3acd..99bb5f211 100644 --- a/src/PikaVersion.h +++ b/src/PikaVersion.h @@ -2,4 +2,4 @@ #define PIKA_VERSION_MINOR 13 #define PIKA_VERSION_MICRO 3 -#define PIKA_EDIT_TIME "2024/05/06 00:34:23" +#define PIKA_EDIT_TIME "2024/05/15 10:48:43" diff --git a/tools/pikaCompiler/rust-msc-latest-win10.exe b/tools/pikaCompiler/rust-msc-latest-win10.exe index 24064a9bd..0cb3a4918 100644 Binary files a/tools/pikaCompiler/rust-msc-latest-win10.exe and b/tools/pikaCompiler/rust-msc-latest-win10.exe differ diff --git a/tools/pikaCompiler/src/compiler.rs b/tools/pikaCompiler/src/compiler.rs index 82d1e688e..465b6ae48 100644 --- a/tools/pikaCompiler/src/compiler.rs +++ b/tools/pikaCompiler/src/compiler.rs @@ -238,6 +238,23 @@ impl Compiler { Err(std::io::Error::from(std::io::ErrorKind::NotFound)) } + // Check if a given path is a folder. + fn check_is_folder(&self, folder_name: &str) -> bool { + let folder_path = format!("{}{}", self.source_path, folder_name); + Compiler::is_folder(folder_path).is_ok() + } + + // Function to check if the given path is a folder. + fn is_folder(path: String) -> io::Result<()> { + let new_path = transform_path(&path); + let path = Path::new(&new_path); + if path.exists() && path.is_dir() { + Ok(()) + } else { + Err(io::Error::from(io::ErrorKind::NotFound)) + } + } + pub fn analyse_py_package_main(self: Compiler, file_name: String) -> Compiler { return self.__do_analyse_file(file_name, PackageType::PyPackageTop); } @@ -272,6 +289,12 @@ impl Compiler { } pub fn import_module_ex(self, file_name: String, from_scan: bool) -> Compiler { + // Check for folder + if self.check_is_folder(&file_name) { + println!(" skip folder: {}{}...", self.source_path, file_name); + return self; + } + // Check for py.o file. if self.try_open_file(&file_name, "py.o") { println!(" found {}{}.py.o...", self.source_path, file_name);