mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
load bytecode ok
This commit is contained in:
parent
2a3b272ccd
commit
94a47b1fbc
@ -514,3 +514,11 @@ TEST(make, compile) {
|
||||
obj_deinit(maker);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(make, depend) {
|
||||
PikaMaker* maker = New_PikaMaker();
|
||||
pikaMaker_setPWD(maker, "package/pikascript/");
|
||||
pikaMaker_getDependencies(maker, "main");
|
||||
obj_deinit(maker);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -385,8 +385,26 @@ void pikaMaker_compileModule(PikaMaker* self, char* module_name) {
|
||||
obj_setStr(self, module_name, "compiled");
|
||||
}
|
||||
|
||||
void pikaMaker_getDependencies(PikaMaker* self, char* module_name) {
|
||||
__Maker_compileModuleWithInfo(self, module_name);
|
||||
/* update compile info */
|
||||
obj_setStr(self, module_name, "compiled");
|
||||
int pikaMaker_getDependencies(PikaMaker* self, char* module_name) {
|
||||
int res = 0;
|
||||
ByteCodeFrame bf = {0};
|
||||
Args buffs = {0};
|
||||
byteCodeFrame_init(&bf);
|
||||
char* file_path = strsAppend(&buffs, obj_getStr(self, "pwd"), module_name);
|
||||
file_path = strsAppend(&buffs, file_path, ".py.o");
|
||||
Arg* file_arg = arg_loadFile(NULL, file_path);
|
||||
if (NULL == file_arg) {
|
||||
res = 1;
|
||||
goto exit;
|
||||
}
|
||||
byteCodeFrame_loadByteCode(&bf, arg_getBytes(file_arg));
|
||||
byteCodeFrame_print(&bf);
|
||||
|
||||
exit:
|
||||
if (NULL != file_arg) {
|
||||
arg_deinit(file_arg);
|
||||
}
|
||||
strsDeinit(&buffs);
|
||||
byteCodeFrame_deinit(&bf);
|
||||
return res;
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ int Lib_loadLibraryFileToArray(char* origin_file_name, char* pikascript_root);
|
||||
PikaMaker* New_PikaMaker(void);
|
||||
void pikaMaker_setPWD(PikaMaker* self, char* pwd);
|
||||
void pikaMaker_compileModule(PikaMaker* self, char* module_name);
|
||||
int pikaMaker_getDependencies(PikaMaker* self, char* module_name);
|
||||
|
||||
|
||||
#define LIB_VERSION_NUMBER 1
|
||||
|
@ -29,8 +29,8 @@
|
||||
#define __PIKA_VM__H
|
||||
#include "PikaObj.h"
|
||||
#include "dataQueue.h"
|
||||
#include "dataStack.h"
|
||||
#include "dataQueueObj.h"
|
||||
#include "dataStack.h"
|
||||
|
||||
enum Instruct {
|
||||
#define __INS_ENUM
|
||||
@ -126,6 +126,7 @@ void constPool_printAsArray(ConstPool* self);
|
||||
void instructArray_printAsArray(InstructArray* self);
|
||||
void byteCodeFrame_loadByteCode(ByteCodeFrame* self, uint8_t* bytes);
|
||||
void byteCodeFrame_printAsArray(ByteCodeFrame* self);
|
||||
void byteCodeFrame_init(ByteCodeFrame* self);
|
||||
VMParameters* pikaVM_runByteCode(PikaObj* self, uint8_t* bytecode);
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user