PikaIf.c 924 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Author: lyon
  3. Tencent QQ: 645275593
  4. */
  5. #include "PikaIf.h"
  6. #include <stdarg.h>
  7. #include "PikaBlock.h"
  8. #include "TinyObj.h"
  9. #include "dataStrs.h"
  10. void if_setAssert(PikaObj* self, char* line) {
  11. Args* buffs = New_strBuff();
  12. char* assert = strsRemovePrefix(buffs, line, "if ");
  13. assert = strsGetFirstToken(buffs, assert, ':');
  14. block_setAssert(self, assert);
  15. block_setMode(self, "if");
  16. args_deinit(buffs);
  17. }
  18. void if_pushLine(PikaObj* self, char* line) {
  19. Args* buffs = New_strBuff();
  20. char* bodyLine = strsRemovePrefix(buffs, line, " ");
  21. block_pushLine(self, bodyLine);
  22. goto exit;
  23. exit:
  24. args_deinit(buffs);
  25. return;
  26. }
  27. void if_run(PikaObj* self) {
  28. if (block_checkAssert(self)) {
  29. PikaObj* host = obj_getContext(self);
  30. while (0 != block_getLineSize(self)) {
  31. char* line = block_popLine(self);
  32. obj_run(host, line);
  33. }
  34. }
  35. }