mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +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);
|
||||||
|
}
|
||||||
|
@ -1525,6 +1525,10 @@ ByteCodeFrame* byteCodeFrame_appendFromAsm(ByteCodeFrame* self, char* pikaAsm) {
|
|||||||
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, "")) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user