mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
fix '\r' err in pikaRunAsm
This commit is contained in:
parent
7e36cd3bbd
commit
ed489e2070
@ -2432,3 +2432,31 @@ TEST(asmer, asm_to_bytecodeArray) {
|
|||||||
byteCodeFrame_deinit(&bytecode_frame);
|
byteCodeFrame_deinit(&bytecode_frame);
|
||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(asmer, asm_to_bytecode_0x0d) {
|
||||||
|
char* pikaAsm =(char*)
|
||||||
|
"B0\n"
|
||||||
|
"0 RUN __init__\n";
|
||||||
|
char* pikaAsm1 =(char*)
|
||||||
|
"B0\r\n"
|
||||||
|
"0 RUN __init__\r\n";
|
||||||
|
|
||||||
|
ByteCodeFrame bytecode_frame;
|
||||||
|
byteCodeFrame_init(&bytecode_frame);
|
||||||
|
byteCodeFrame_appendFromAsm(&bytecode_frame, pikaAsm);
|
||||||
|
byteCodeFrame_printAsArray(&bytecode_frame);
|
||||||
|
|
||||||
|
ByteCodeFrame bytecode_frame1;
|
||||||
|
byteCodeFrame_init(&bytecode_frame1);
|
||||||
|
byteCodeFrame_appendFromAsm(&bytecode_frame1, pikaAsm1);
|
||||||
|
byteCodeFrame_printAsArray(&bytecode_frame1);
|
||||||
|
|
||||||
|
EXPECT_EQ(bytecode_frame1.const_pool.size, bytecode_frame.const_pool.size);
|
||||||
|
EXPECT_EQ(bytecode_frame1.instruct_array.size,
|
||||||
|
bytecode_frame.instruct_array.size);
|
||||||
|
|
||||||
|
/* deinit */
|
||||||
|
byteCodeFrame_deinit(&bytecode_frame1);
|
||||||
|
byteCodeFrame_deinit(&bytecode_frame);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
|
@ -1517,14 +1517,18 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
|||||||
.is_new_line = 0,
|
.is_new_line = 0,
|
||||||
.line_pointer = pikaAsm,
|
.line_pointer = pikaAsm,
|
||||||
};
|
};
|
||||||
uint16_t const_pool_offset;
|
uint16_t const_pool_offset;
|
||||||
char* data;
|
char* data;
|
||||||
uint16_t exist_offset;
|
uint16_t exist_offset;
|
||||||
|
|
||||||
char line_buff[PIKA_CONFIG_PATH_BUFF_SIZE] = {0};
|
char line_buff[PIKA_CONFIG_PATH_BUFF_SIZE] = {0};
|
||||||
for (int i = 0; i < strCountSign(pikaAsm, '\n'); i++) {
|
for (int i = 0; i < strCountSign(pikaAsm, '\n'); i++) {
|
||||||
char* line = strGetLine(line_buff, asmer.line_pointer);
|
char* line = strGetLine(line_buff, asmer.line_pointer);
|
||||||
InstructUnit ins_unit = {0};
|
InstructUnit ins_unit = {0};
|
||||||
|
/* remove '\r' */
|
||||||
|
if (line[strGetSize(line) - 1] == '\r') {
|
||||||
|
line[strGetSize(line) - 1] = 0;
|
||||||
|
}
|
||||||
/* process block deepth flag*/
|
/* process block deepth flag*/
|
||||||
if ('B' == line[0]) {
|
if ('B' == line[0]) {
|
||||||
asmer.block_deepth_now = line[1] - '0';
|
asmer.block_deepth_now = line[1] - '0';
|
||||||
@ -1538,8 +1542,7 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
|||||||
const_pool_offset = 0;
|
const_pool_offset = 0;
|
||||||
|
|
||||||
data = line + 6;
|
data = line + 6;
|
||||||
exist_offset =
|
exist_offset = constPool_getOffsetByData(&(self->const_pool), data);
|
||||||
constPool_getOffsetByData(&(self->const_pool), data);
|
|
||||||
|
|
||||||
/* get const offset */
|
/* get const offset */
|
||||||
if (strEqu(data, "")) {
|
if (strEqu(data, "")) {
|
||||||
@ -1611,7 +1614,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
need implament :
|
need implament :
|
||||||
__platform_fopen()
|
__platform_fopen()
|
||||||
__platform_fwrite()
|
__platform_fwrite()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user