mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
add PikaLib class to gen '*.a'
This commit is contained in:
parent
c9f56112c7
commit
882421ae5b
@ -901,7 +901,7 @@ TEST(VM, load_static_bytes) {
|
||||
.output_f = NULL,
|
||||
}};
|
||||
|
||||
byteCodeFrame_loadBytes(&bytecode_frame, (uint8_t*)bytes);
|
||||
byteCodeFrame_loadByteCode(&bytecode_frame, (uint8_t*)bytes);
|
||||
byteCodeFrame_print(&bytecode_frame);
|
||||
|
||||
EXPECT_EQ(instructArray_getSize(&(bytecode_frame.instruct_array)), 520);
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
extern "C" {
|
||||
#include "PikaMain.h"
|
||||
@ -331,3 +330,9 @@ TEST(compiler, file2) {
|
||||
pikaCompileFile((char*)"test/python/main_snake_LCD.py");
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
||||
TEST(lib, init) {
|
||||
PikaLib* lib = New_PikaLib();
|
||||
PikaLib_deinit(lib);
|
||||
EXPECT_EQ(pikaMemNow(), 0);
|
||||
}
|
||||
|
@ -1025,7 +1025,7 @@ static VMParameters* __pikaVM_runPyLines_or_byteCode(PikaObj* self,
|
||||
}
|
||||
} else {
|
||||
/* load bytecode */
|
||||
byteCodeFrame_loadBytes(bytecode_frame_p, bytecode);
|
||||
byteCodeFrame_loadByteCode(bytecode_frame_p, bytecode);
|
||||
}
|
||||
|
||||
/* run byteCode */
|
||||
@ -1157,7 +1157,7 @@ void byteCodeFrame_init(ByteCodeFrame* self) {
|
||||
instructArray_init(&(self->instruct_array));
|
||||
}
|
||||
|
||||
void byteCodeFrame_loadBytes(ByteCodeFrame* self, uint8_t* bytes) {
|
||||
void byteCodeFrame_loadByteCode(ByteCodeFrame* self, uint8_t* bytes) {
|
||||
uint16_t* ins_size_p = (uint16_t*)bytes;
|
||||
void* ins_start_p = (uint16_t*)(bytes + 2);
|
||||
uint16_t* const_size_p =
|
||||
|
@ -124,7 +124,7 @@ void constPool_update(ConstPool* self);
|
||||
void instructArray_update(InstructArray* self);
|
||||
void constPool_printAsArray(ConstPool* self);
|
||||
void instructArray_printAsArray(InstructArray* self);
|
||||
void byteCodeFrame_loadBytes(ByteCodeFrame* self, uint8_t* bytes);
|
||||
void byteCodeFrame_loadByteCode(ByteCodeFrame* self, uint8_t* bytes);
|
||||
void byteCodeFrame_printAsArray(ByteCodeFrame* self);
|
||||
VMParameters* pikaVM_runByteCode(PikaObj* self, uint8_t* bytecode);
|
||||
|
||||
|
@ -86,6 +86,13 @@ int pikaCompile(char* output_file_name, char* py_lines) {
|
||||
return 0;
|
||||
};
|
||||
|
||||
/*
|
||||
need implament :
|
||||
__platform_fopen()
|
||||
__platform_fread()
|
||||
__platform_fwrite()
|
||||
__platform_fclose()
|
||||
*/
|
||||
int pikaCompileFileWithOutputName(char* output_file_name,
|
||||
char* input_file_name) {
|
||||
char* file_buff = __platform_malloc(PIKA_READ_FILE_BUFF_SIZE);
|
||||
@ -105,3 +112,14 @@ int pikaCompileFile(char* input_file_name) {
|
||||
strsDeinit(&buffs);
|
||||
return 0;
|
||||
}
|
||||
|
||||
PikaLib* New_PikaLib(void) {
|
||||
return New_TinyObj(NULL);
|
||||
}
|
||||
|
||||
void PikaLib_deinit(PikaLib* self) {
|
||||
obj_deinit(self);
|
||||
}
|
||||
|
||||
void PikaLib_LinkByteCode(PikaLib* self, char* module_name, uint8_t* bytecode) {
|
||||
}
|
||||
|
@ -1,8 +1,17 @@
|
||||
#ifndef __PIKA_COMPILER__H
|
||||
#define __PIKA_COMPILER__H
|
||||
#include "PikaObj.h"
|
||||
|
||||
int pikaCompileFile(char* input_file_name);
|
||||
int pikaCompileFileWithOutputName(char* output_file_name, char* input_file_name);
|
||||
int pikaCompileFileWithOutputName(char* output_file_name,
|
||||
char* input_file_name);
|
||||
int pikaCompile(char* output_file_name, char* py_lines);
|
||||
|
||||
typedef PikaObj PikaLib;
|
||||
PikaLib* New_PikaLib(void);
|
||||
void PikaLib_deinit(PikaLib* self);
|
||||
void PikaLib_importByteCodeFrame(PikaLib* self,
|
||||
char* module_name,
|
||||
ByteCodeFrame* bf);
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user