mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
clean stack when match new line
This commit is contained in:
parent
8116f4f48b
commit
60514571b6
@ -35,7 +35,8 @@
|
|||||||
#include "dataStrs.h"
|
#include "dataStrs.h"
|
||||||
|
|
||||||
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr) {
|
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr) {
|
||||||
Args buffs = {0}; Arg* argNew = New_arg(NULL);
|
Args buffs = {0};
|
||||||
|
Arg* argNew = New_arg(NULL);
|
||||||
/* m means mate-object */
|
/* m means mate-object */
|
||||||
argNew = arg_setPtr(argNew, objName, ARG_TYPE_MATE_OBJECT, (void*)objPtr);
|
argNew = arg_setPtr(argNew, objName, ARG_TYPE_MATE_OBJECT, (void*)objPtr);
|
||||||
strsDeinit(&buffs);
|
strsDeinit(&buffs);
|
||||||
@ -69,7 +70,7 @@ static void print_no_end(PikaObj* self, Args* args) {
|
|||||||
__platform_printf("%s", res);
|
__platform_printf("%s", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(PikaObj* self, Args* args) {
|
void baseobj_print(PikaObj* self, Args* args) {
|
||||||
obj_setErrorCode(self, 0);
|
obj_setErrorCode(self, 0);
|
||||||
char* res = args_print(args, "val");
|
char* res = args_print(args, "val");
|
||||||
if (NULL == res) {
|
if (NULL == res) {
|
||||||
@ -88,7 +89,7 @@ void print(PikaObj* self, Args* args) {
|
|||||||
|
|
||||||
PikaObj* New_BaseObj(Args* args) {
|
PikaObj* New_BaseObj(Args* args) {
|
||||||
PikaObj* self = New_TinyObj(args);
|
PikaObj* self = New_TinyObj(args);
|
||||||
class_defineMethod(self, "print(val:any)", print);
|
class_defineMethod(self, "print(val:any)", baseobj_print);
|
||||||
class_defineMethod(self, "printNoEnd(val:any)", print_no_end);
|
class_defineMethod(self, "printNoEnd(val:any)", print_no_end);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,6 @@ int32_t obj_newObj(PikaObj* self,
|
|||||||
char* className,
|
char* className,
|
||||||
NewFun newFunPtr);
|
NewFun newFunPtr);
|
||||||
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr);
|
Arg* arg_setMetaObj(char* objName, char* className, NewFun objPtr);
|
||||||
|
void baseobj_print(PikaObj* self, Args* args);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
13
src/PikaVM.c
13
src/PikaVM.c
@ -1138,6 +1138,19 @@ VMParameters* pikaVM_runByteCodeWithState(PikaObj* self,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
InstructUnit* this_ins_unit = VMState_getInstructNow(&vs);
|
InstructUnit* this_ins_unit = VMState_getInstructNow(&vs);
|
||||||
|
if (instructUnit_getIsNewLine(this_ins_unit)) {
|
||||||
|
for (int8_t i = 0; i < stack_getTop(vs.stack); i++) {
|
||||||
|
// Args print_args = {0};
|
||||||
|
// Arg* print_arg = stack_popArg(vs.stack);
|
||||||
|
// arg_setName(print_arg, "val");
|
||||||
|
// args_setArg(&print_args, print_arg);
|
||||||
|
// if (ARG_TYPE_NONE != arg_getType(print_arg)) {
|
||||||
|
// baseobj_print(self, &print_args);
|
||||||
|
// }
|
||||||
|
// args_deinit_stack(&print_args);
|
||||||
|
arg_deinit(stack_popArg(vs.stack));
|
||||||
|
}
|
||||||
|
}
|
||||||
vs.pc = pikaVM_runInstructUnit(self, &vs, this_ins_unit);
|
vs.pc = pikaVM_runInstructUnit(self, &vs, this_ins_unit);
|
||||||
if (0 != vs.error_code) {
|
if (0 != vs.error_code) {
|
||||||
InstructUnit* head_ins_unit = this_ins_unit;
|
InstructUnit* head_ins_unit = this_ins_unit;
|
||||||
|
@ -312,3 +312,4 @@ void arg_deinit(Arg* self) {
|
|||||||
}
|
}
|
||||||
arg_freeContent(self);
|
arg_freeContent(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user