write to file with user path

This commit is contained in:
lyon1998 2022-03-18 16:09:31 +08:00
parent 21a8f63d92
commit 6b4e857b76
4 changed files with 6 additions and 6 deletions

View File

@ -2273,7 +2273,7 @@ TEST(compiler, file) {
" __calls[i] = __tick + period_ms\n"
" info_index = 0\n"
"\n";
Parser_multiLineToFile((char*)lines);
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
EXPECT_EQ(pikaMemNow(), 0);
}
@ -2416,6 +2416,6 @@ TEST(compiler, snake_file) {
" elif key_val == 3:\n"
" d = 3\n"
" isUpdate = 1\n";
Parser_multiLineToFile((char*)lines);
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
EXPECT_EQ(pikaMemNow(), 0);
}

View File

@ -1297,7 +1297,7 @@ TEST(pikaMain, class_demo_1_file) {
" \n"
"print(x.i)\n"
"print(x.f())\n";
Parser_multiLineToFile((char*)lines);
Parser_multiLineToFile((char*)lines, (char*)"pika_bytecode.bin");
char bytecodebuff[4096] = {0};
FILE* f = __platform_fopen("pika_bytecode.bin", "r");
fread(bytecodebuff, 1, 4096, f);

View File

@ -1609,10 +1609,10 @@ static void __handler_instructArray_output_file(InstructArray* self,
__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};
FILE* bytecode_f = __platform_fopen("pika_bytecode.bin", "w+");
FILE* bytecode_f = __platform_fopen(file_name, "w+");
/* main process */
/* step 1, get size of const pool and instruct array */

View File

@ -45,6 +45,6 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* bf, char* pikaAsm);
int bytecodeFrame_fromMultiLine(ByteCodeFrame* bytecode_frame,
char* multi_line);
void Parser_compilePyToBytecodeArray(char* lines);
int Parser_multiLineToFile(char* multi_line);
int Parser_multiLineToFile(char* multi_line, char* file_name);
#endif