35 lines
826 B
C
Raw Normal View History

2021-09-10 17:49:56 +08:00
#include "PikaIf.h"
2021-09-08 21:25:52 +08:00
#include <stdarg.h>
#include "PikaBlock.h"
#include "TinyObj.h"
2021-09-10 17:49:56 +08:00
#include "dataStrs.h"
2021-09-08 21:25:52 +08:00
2021-09-10 17:49:56 +08:00
void if_setAssert(PikaObj* self, char* line) {
Args* buffs = New_strBuff();
char* assert = strsRemovePrefix(buffs, line, "if ");
assert = strsGetFirstToken(buffs, assert, ':');
block_setAssert(self, assert);
block_setMode(self, "if");
args_deinit(buffs);
2021-09-08 21:25:52 +08:00
}
2021-09-10 17:49:56 +08:00
void if_pushLine(PikaObj* self, char* line) {
Args* buffs = New_strBuff();
char* bodyLine = strsRemovePrefix(buffs, line, " ");
block_pushLine(self, bodyLine);
goto exit;
2021-09-08 21:25:52 +08:00
exit:
2021-09-10 17:49:56 +08:00
args_deinit(buffs);
return;
2021-09-08 21:25:52 +08:00
}
2021-09-10 17:49:56 +08:00
void if_run(PikaObj* self) {
if (block_checkAssert(self)) {
PikaObj* host = obj_getContext(self);
while (0 != block_getLineSize(self)) {
char* line = block_popLine(self);
obj_run(host, line);
2021-09-08 21:25:52 +08:00
}
2021-09-10 17:49:56 +08:00
}
2021-09-08 21:25:52 +08:00
}