mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
write to file with user path
This commit is contained in:
parent
21a8f63d92
commit
6b4e857b76
@ -2273,7 +2273,7 @@ TEST(compiler, file) {
|
|||||||
" __calls[i] = __tick + period_ms\n"
|
" __calls[i] = __tick + period_ms\n"
|
||||||
" info_index = 0\n"
|
" info_index = 0\n"
|
||||||
"\n";
|
"\n";
|
||||||
Parser_multiLineToFile((char*)lines);
|
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2416,6 +2416,6 @@ TEST(compiler, snake_file) {
|
|||||||
" elif key_val == 3:\n"
|
" elif key_val == 3:\n"
|
||||||
" d = 3\n"
|
" d = 3\n"
|
||||||
" isUpdate = 1\n";
|
" isUpdate = 1\n";
|
||||||
Parser_multiLineToFile((char*)lines);
|
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
@ -1297,7 +1297,7 @@ TEST(pikaMain, class_demo_1_file) {
|
|||||||
" \n"
|
" \n"
|
||||||
"print(x.i)\n"
|
"print(x.i)\n"
|
||||||
"print(x.f())\n";
|
"print(x.f())\n";
|
||||||
Parser_multiLineToFile((char*)lines);
|
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
|
||||||
char bytecodebuff[4096] = {0};
|
char bytecodebuff[4096] = {0};
|
||||||
FILE* f = __platform_fopen("pika_bytecode.bin", "r");
|
FILE* f = __platform_fopen("pika_bytecode.bin", "r");
|
||||||
fread(bytecodebuff, 1, 4096, f);
|
fread(bytecodebuff, 1, 4096, f);
|
||||||
|
@ -1609,10 +1609,10 @@ static void __handler_instructArray_output_file(InstructArray* self,
|
|||||||
__platform_fwrite(ins_unit, 1, instructUnit_getSize(), self->output_f);
|
__platform_fwrite(ins_unit, 1, instructUnit_getSize(), self->output_f);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Parser_multiLineToFile(char* multi_line) {
|
int Parser_multiLineToFile(char* multi_line, char* file_name) {
|
||||||
ByteCodeFrame bytecode_frame = {0};
|
ByteCodeFrame bytecode_frame = {0};
|
||||||
|
|
||||||
FILE* bytecode_f = __platform_fopen("pika_bytecode.bin", "w+");
|
FILE* bytecode_f = __platform_fopen(file_name, "w+");
|
||||||
/* main process */
|
/* main process */
|
||||||
|
|
||||||
/* step 1, get size of const pool and instruct array */
|
/* step 1, get size of const pool and instruct array */
|
||||||
|
@ -45,6 +45,6 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* bf, char* pikaAsm);
|
|||||||
int bytecodeFrame_fromMultiLine(ByteCodeFrame* bytecode_frame,
|
int bytecodeFrame_fromMultiLine(ByteCodeFrame* bytecode_frame,
|
||||||
char* multi_line);
|
char* multi_line);
|
||||||
void Parser_compilePyToBytecodeArray(char* lines);
|
void Parser_compilePyToBytecodeArray(char* lines);
|
||||||
int Parser_multiLineToFile(char* multi_line);
|
int Parser_multiLineToFile(char* multi_line, char* file_name);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user