Skip to content

Commit

Permalink
fix subdir for pre-compiler, fix num + str opt
Browse files Browse the repository at this point in the history
  • Loading branch information
pikasTech committed May 15, 2024
1 parent 65249be commit ee6889d
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion port/linux/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions port/linux/package/pikascript/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PikaStdLib
import PikaDebug
import this
from subsrc import mod1

print('hello pikapython!')
mem = PikaStdLib.MemChecker()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/PikaObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions src/PikaObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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;
Expand Down
16 changes: 11 additions & 5 deletions src/PikaVM.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/PikaVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 modified tools/pikaCompiler/rust-msc-latest-win10.exe
Binary file not shown.
23 changes: 23 additions & 0 deletions tools/pikaCompiler/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ee6889d

Please sign in to comment.