mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix subdir for pre-compiler, fix num + str opt
This commit is contained in:
parent
65249bef38
commit
ee6889d64a
2
port/linux/.vscode/launch.json
vendored
2
port/linux/.vscode/launch.json
vendored
@ -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,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import PikaStdLib
|
||||
import PikaDebug
|
||||
import this
|
||||
from subsrc import mod1
|
||||
|
||||
print('hello pikapython!')
|
||||
mem = PikaStdLib.MemChecker()
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
16
src/PikaVM.c
16
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;
|
||||
|
@ -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"
|
||||
|
Binary file not shown.
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user