From f002d9f73d029fdfccb4658899a274bea8d110de Mon Sep 17 00:00:00 2001 From: lyon Date: Sat, 30 Apr 2022 23:13:05 +0800 Subject: [PATCH] static Link ok --- port/linux/test/compile-test.cpp | 8 ++++---- src/pikaCompiler.c | 10 +++++----- src/pikaCompiler.h | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/port/linux/test/compile-test.cpp b/port/linux/test/compile-test.cpp index d4d1e9c90..607086960 100644 --- a/port/linux/test/compile-test.cpp +++ b/port/linux/test/compile-test.cpp @@ -334,7 +334,7 @@ TEST(lib, init) { TEST(lib, lib_link_bytecode) { LibObj* lib = New_LibObj(); - LibObj_linkByteCode(lib, "module1", (uint8_t*)0x3344); + LibObj_dynamicLink(lib, "module1", (uint8_t*)0x3344); EXPECT_STREQ(obj_getStr(lib, "index.module1.name"), "module1"); EXPECT_EQ((uintptr_t)obj_getPtr(lib, "index.module1.bytecode"), 0x3344); /* deinit */ @@ -344,7 +344,7 @@ TEST(lib, lib_link_bytecode) { TEST(lib, lib_push_file) { LibObj* lib = New_LibObj(); - LibObj_pushByteCodeFile(lib, "test/python/main.py.o"); + LibObj_staticLinkFile(lib, "test/python/main.py.o"); /* deinit */ LibObj_deinit(lib); EXPECT_EQ(pikaMemNow(), 0); @@ -352,8 +352,8 @@ TEST(lib, lib_push_file) { TEST(lib, lib_push_files) { LibObj* lib = New_LibObj(); - LibObj_pushByteCodeFile(lib, "test/python/main.py.o"); - LibObj_pushByteCodeFile(lib, "test/python/main_snake_LCD.py.o"); + LibObj_staticLinkFile(lib, "test/python/main.py.o"); + LibObj_staticLinkFile(lib, "test/python/main_snake_LCD.py.o"); LibObj_listModules(lib); /* asset */ EXPECT_STREQ(log_buff[0], "main\r\n"); diff --git a/src/pikaCompiler.c b/src/pikaCompiler.c index d002dee5f..4c17fe350 100644 --- a/src/pikaCompiler.c +++ b/src/pikaCompiler.c @@ -124,7 +124,7 @@ void LibObj_deinit(LibObj* self) { } /* add bytecode to lib, not copy the bytecode */ -void LibObj_linkByteCode(LibObj* self, char* module_name, uint8_t* bytecode) { +void LibObj_dynamicLink(LibObj* self, char* module_name, uint8_t* bytecode) { PikaObj* index_obj = obj_getObj(self, "index"); if (!obj_isArgExist(index_obj, module_name)) { obj_newObj(index_obj, module_name, "", New_TinyObj); @@ -135,7 +135,7 @@ void LibObj_linkByteCode(LibObj* self, char* module_name, uint8_t* bytecode) { } /* add bytecode to lib, and copy the bytecode to the buff in the lib */ -int LibObj_pushByteCode(LibObj* self, +int LibObj_staticLink(LibObj* self, char* module_name, uint8_t* bytecode, size_t size) { @@ -147,11 +147,11 @@ int LibObj_pushByteCode(LibObj* self, /* copy bytecode to buff */ obj_setBytes(module_obj, "buff", bytecode, size); /* link to buff */ - LibObj_linkByteCode(self, module_name, obj_getBytes(module_obj, "buff")); + LibObj_dynamicLink(self, module_name, obj_getBytes(module_obj, "buff")); return 0; } -int LibObj_pushByteCodeFile(LibObj* self, char* input_file_name) { +int LibObj_staticLinkFile(LibObj* self, char* input_file_name) { char* file_buff = __platform_malloc(PIKA_READ_FILE_BUFF_SIZE); Args buffs = {0}; FILE* input_f = __platform_fopen(input_file_name, "r"); @@ -164,7 +164,7 @@ int LibObj_pushByteCodeFile(LibObj* self, char* input_file_name) { module_name[strlen(module_name) - (sizeof(".py.o") - 1)] = 0; /* push bytecode */ - LibObj_pushByteCode(self, module_name, (uint8_t*)file_buff, size); + LibObj_staticLink(self, module_name, (uint8_t*)file_buff, size); /* deinit */ __platform_free(file_buff); diff --git a/src/pikaCompiler.h b/src/pikaCompiler.h index 8a078357c..54c552c48 100644 --- a/src/pikaCompiler.h +++ b/src/pikaCompiler.h @@ -11,11 +11,11 @@ int pikaCompile(char* output_file_name, char* py_lines); typedef PikaObj LibObj; LibObj* New_LibObj(void); void LibObj_deinit(LibObj* self); -void LibObj_linkByteCode(LibObj* self, char* module_name, uint8_t* bytecode); -int LibObj_pushByteCode(LibObj* self, +void LibObj_dynamicLink(LibObj* self, char* module_name, uint8_t* bytecode); +int LibObj_staticLink(LibObj* self, char* module_name, uint8_t* bytecode, size_t size); -int LibObj_pushByteCodeFile(LibObj* self, char* input_file_name); +int LibObj_staticLinkFile(LibObj* self, char* input_file_name); void LibObj_listModules(LibObj* self); #endif \ No newline at end of file