mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-29 17:22:56 +08:00
fix fullthrough on vm
This commit is contained in:
parent
214f3b87fa
commit
480134b68e
32
src/PikaVM.c
32
src/PikaVM.c
@ -501,9 +501,9 @@ Arg* _vm_slice(VMState* vm,
|
|||||||
size_t size_origin = arg_getBytesSize(sliced_arg);
|
size_t size_origin = arg_getBytesSize(sliced_arg);
|
||||||
Arg* sliced_arg_new = arg_newBytes(NULL, size_origin + 1);
|
Arg* sliced_arg_new = arg_newBytes(NULL, size_origin + 1);
|
||||||
pika_platform_memcpy(arg_getBytes(sliced_arg_new), bytes_origin,
|
pika_platform_memcpy(arg_getBytes(sliced_arg_new), bytes_origin,
|
||||||
size_origin);
|
size_origin);
|
||||||
pika_platform_memcpy(arg_getBytes(sliced_arg_new) + size_origin,
|
pika_platform_memcpy(arg_getBytes(sliced_arg_new) + size_origin,
|
||||||
arg_getBytes(item_arg), 1);
|
arg_getBytes(item_arg), 1);
|
||||||
arg_deinit(sliced_arg);
|
arg_deinit(sliced_arg);
|
||||||
sliced_arg = sliced_arg_new;
|
sliced_arg = sliced_arg_new;
|
||||||
arg_deinit(item_arg);
|
arg_deinit(item_arg);
|
||||||
@ -677,18 +677,22 @@ static Arg* VM_instruction_handler_REF(PikaObj* self,
|
|||||||
if (strEqu(arg_path, (char*)"True")) {
|
if (strEqu(arg_path, (char*)"True")) {
|
||||||
return arg_setInt(arg_ret_reg, "", 1);
|
return arg_setInt(arg_ret_reg, "", 1);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'F':
|
case 'F':
|
||||||
if (strEqu(arg_path, (char*)"False")) {
|
if (strEqu(arg_path, (char*)"False")) {
|
||||||
return arg_setInt(arg_ret_reg, "", 0);
|
return arg_setInt(arg_ret_reg, "", 0);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'N':
|
case 'N':
|
||||||
if (strEqu(arg_path, (char*)"None")) {
|
if (strEqu(arg_path, (char*)"None")) {
|
||||||
return arg_setNull(arg_ret_reg);
|
return arg_setNull(arg_ret_reg);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case 'R':
|
case 'R':
|
||||||
if (strEqu(arg_path, (char*)"RuntimeError")) {
|
if (strEqu(arg_path, (char*)"RuntimeError")) {
|
||||||
return arg_setInt(arg_ret_reg, "", PIKA_RES_ERR_RUNTIME_ERROR);
|
return arg_setInt(arg_ret_reg, "", PIKA_RES_ERR_RUNTIME_ERROR);
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arg* res = NULL;
|
Arg* res = NULL;
|
||||||
@ -754,7 +758,8 @@ static Arg* VM_instruction_handler_REF(PikaObj* self,
|
|||||||
exit:
|
exit:
|
||||||
if (NULL == res) {
|
if (NULL == res) {
|
||||||
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
||||||
pika_platform_printf("NameError: name '%s' is not defined\r\n", arg_path);
|
pika_platform_printf("NameError: name '%s' is not defined\r\n",
|
||||||
|
arg_path);
|
||||||
} else {
|
} else {
|
||||||
res = arg_copy_noalloc(res, arg_ret_reg);
|
res = arg_copy_noalloc(res, arg_ret_reg);
|
||||||
}
|
}
|
||||||
@ -1607,7 +1612,8 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
if (NULL == method || ARG_TYPE_NONE == arg_getType(method)) {
|
if (NULL == method || ARG_TYPE_NONE == arg_getType(method)) {
|
||||||
/* error, method no found */
|
/* error, method no found */
|
||||||
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
||||||
pika_platform_printf("NameError: name '%s' is not defined\r\n", run_path);
|
pika_platform_printf("NameError: name '%s' is not defined\r\n",
|
||||||
|
run_path);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1616,7 +1622,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
|
|||||||
/* error, method no found */
|
/* error, method no found */
|
||||||
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
|
||||||
pika_platform_printf("TypeError: '%s' object is not callable\r\n",
|
pika_platform_printf("TypeError: '%s' object is not callable\r\n",
|
||||||
run_path);
|
run_path);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3283,8 +3289,8 @@ void instructUnit_print(InstructUnit* self) {
|
|||||||
pika_platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
pika_platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
||||||
}
|
}
|
||||||
pika_platform_printf("%d %s #%d\r\n", instructUnit_getInvokeDeepth(self),
|
pika_platform_printf("%d %s #%d\r\n", instructUnit_getInvokeDeepth(self),
|
||||||
instructUnit_getInstructStr(self),
|
instructUnit_getInstructStr(self),
|
||||||
self->const_pool_index);
|
self->const_pool_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void instructUnit_printWithConst(InstructUnit* self,
|
static void instructUnit_printWithConst(InstructUnit* self,
|
||||||
@ -3292,9 +3298,10 @@ static void instructUnit_printWithConst(InstructUnit* self,
|
|||||||
// if (instructUnit_getIsNewLine(self)) {
|
// if (instructUnit_getIsNewLine(self)) {
|
||||||
// pika_platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
// pika_platform_printf("B%d\r\n", instructUnit_getBlockDeepth(self));
|
||||||
// }
|
// }
|
||||||
pika_platform_printf("%s %s \t\t(#%d)\r\n", instructUnit_getInstructStr(self),
|
pika_platform_printf(
|
||||||
constPool_getByOffset(const_pool, self->const_pool_index),
|
"%s %s \t\t(#%d)\r\n", instructUnit_getInstructStr(self),
|
||||||
self->const_pool_index);
|
constPool_getByOffset(const_pool, self->const_pool_index),
|
||||||
|
self->const_pool_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void instructArray_printWithConst(InstructArray* self, ConstPool* const_pool) {
|
void instructArray_printWithConst(InstructArray* self, ConstPool* const_pool) {
|
||||||
@ -3347,7 +3354,8 @@ void instructArray_printAsArray(InstructArray* self) {
|
|||||||
}
|
}
|
||||||
for (int i = 0; i < (int)instructUnit_getSize(); i++) {
|
for (int i = 0; i < (int)instructUnit_getSize(); i++) {
|
||||||
g_i++;
|
g_i++;
|
||||||
pika_platform_printf("0x%02x, ", *((uint8_t*)ins_unit + (uintptr_t)i));
|
pika_platform_printf("0x%02x, ",
|
||||||
|
*((uint8_t*)ins_unit + (uintptr_t)i));
|
||||||
if (g_i % line_num == 0) {
|
if (g_i % line_num == 0) {
|
||||||
pika_platform_printf("\n");
|
pika_platform_printf("\n");
|
||||||
}
|
}
|
||||||
@ -3369,7 +3377,7 @@ void byteCodeFrame_print(ByteCodeFrame* self) {
|
|||||||
instructArray_printWithConst(&(self->instruct_array), &(self->const_pool));
|
instructArray_printWithConst(&(self->instruct_array), &(self->const_pool));
|
||||||
pika_platform_printf("---------------\r\n");
|
pika_platform_printf("---------------\r\n");
|
||||||
pika_platform_printf("byte code size: %d\r\n",
|
pika_platform_printf("byte code size: %d\r\n",
|
||||||
self->const_pool.size + self->instruct_array.size);
|
self->const_pool.size + self->instruct_array.size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VMState_solveUnusedStack(VMState* vm) {
|
void VMState_solveUnusedStack(VMState* vm) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user