update PikaStdLib

This commit is contained in:
lyon 2022-01-04 19:11:47 +08:00
parent 76f9b3ee25
commit 1f1a9c1f63
2 changed files with 13 additions and 8 deletions

View File

@ -2,12 +2,11 @@
Arg* PikaStdLib_RangeObj___iter__(PikaObj* self) {
return arg_setPtr(NULL, "", TYPE_OBJECT, self);
;
}
Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
int a1 = obj_getInt(self, "a1");
int a2 = obj_getInt(self, "a2");
int a3 = obj_getInt(self, "a3");
int a1 = args_getInt(self->list, "a1");
int a2 = args_getInt(self->list, "a2");
int a3 = args_getInt(self->list, "a3");
int start = 0;
int end = 0;
int foot = 1;
@ -17,7 +16,7 @@ Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
end = a2;
}
/* start */
int iter_i = obj_getInt(self, "iter_i");
int iter_i = args_getInt(self->list, "iter_i");
/* iter_i is not inited */
if (-999999999 == iter_i) {
iter_i = start;
@ -26,6 +25,6 @@ Arg* PikaStdLib_RangeObj___next__(PikaObj* self) {
if (iter_i >= end) {
return arg_setNull(NULL);
}
obj_setInt(self, "iter_i", iter_i + foot);
args_setInt(self->list, "iter_i", iter_i + foot);
return arg_setInt(NULL, "", iter_i);
}

View File

@ -84,7 +84,10 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
/* object */
if (TYPE_POINTER == arg_getType(arg)) {
PikaObj* arg_obj = arg_getPtr(arg);
obj_run(arg_obj, "__res = __iter__()");
pikaVM_runAsm(arg_obj,
"B0\n"
"0 RUN __iter__\n"
"0 OUT __res\n");
return arg_copy(args_getArg(arg_obj->list, "__res"));
}
return arg_setNull(NULL);
@ -92,7 +95,10 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
Arg* PikaStdLib_SysObj_next(PikaObj* self, Arg* arg) {
PikaObj* arg_obj = arg_getPtr(arg);
obj_run(arg_obj, "__res = __next__()");
pikaVM_runAsm(arg_obj,
"B0\n"
"0 RUN __next__\n"
"0 OUT __res\n");
return arg_copy(args_getArg(arg_obj->list, "__res"));
}