!31 fix run context problem when call the callback function

* remove __pikaMain from StdTask
* support run arg from other context(file name space)
* format
* use def_context in callback
* supporting def_context, not ok
This commit is contained in:
李昂 2022-06-21 03:29:29 +00:00
parent 45207b3738
commit e31135ba90
12 changed files with 414 additions and 393 deletions

View File

@ -1,9 +1,10 @@
#api #api
from PikaObj import * from PikaObj import *
import PikaStdData import PikaStdData
import PikaStdLib
class Task(TinyObj): class Task(PikaStdLib.SysObj):
calls = PikaStdData.List() calls = PikaStdData.List()
def __init__(self): def __init__(self):

View File

@ -1,10 +1,8 @@
#include "BaseObj.h" #include "BaseObj.h"
#include "PikaVM.h" #include "PikaVM.h"
extern PikaObj* __pikaMain;
void PikaStdTask_Task___init__(PikaObj* self) { void PikaStdTask_Task___init__(PikaObj* self) {
obj_setInt(self, "is_period", 0); obj_setInt(self, "is_period", 0);
obj_setRef(__pikaMain, "__calls", obj_getObj(self, "calls"));
} }
void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) { void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) {
@ -90,116 +88,115 @@ void PikaStdTask_Task_call_period_ms(PikaObj* self,
} }
void PikaStdTask_Task_run_once(PikaObj* self) { void PikaStdTask_Task_run_once(PikaObj* self) {
/* transfer the tick to pikaMain */
obj_setInt(__pikaMain, "__tick", obj_getInt(self, "tick"));
/* clang-format off */ /* clang-format off */
PIKA_PYTHON( PIKA_PYTHON(
len = __calls.len() len = calls.len()
mode = 'none' mode = 'none'
info_index = 0 info_index = 0
for i in range(0, len): for i in range(0, len):
if len == 0: if len == 0:
break break
if info_index == 0: if info_index == 0:
mode = __calls[i] mode = calls[i]
info_index = 1 info_index = 1
elif info_index == 1: elif info_index == 1:
if mode == 'always': if mode == 'always':
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'when': elif mode == 'when':
when = __calls[i] when = calls[i]
info_index = 2 info_index = 2
elif mode == 'period_ms': elif mode == 'period_ms':
period_ms = __calls[i] period_ms = calls[i]
info_index = 2 info_index = 2
elif info_index == 2: elif info_index == 2:
if mode == 'when': if mode == 'when':
if when(): if when():
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'period_ms': elif mode == 'period_ms':
todo = __calls[i] todo = calls[i]
info_index = 3 info_index = 3
elif info_index == 3: elif info_index == 3:
if mode == 'period_ms': if mode == 'period_ms':
if __tick > __calls[i]: if tick > calls[i]:
todo() todo()
__calls[i] = __tick + period_ms calls[i] = tick + period_ms
info_index = 0 info_index = 0
) )
/* clang-format on */ /* clang-format on */
const uint8_t bytes[] = { const uint8_t bytes[] = {
0x60, 0x02, /* instruct array size */ 0x60, 0x02, /* instruct array size */
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00, 0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x83, 0x0f, 0x00,
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00, 0x00, 0x04, 0x14, 0x00, 0x00, 0x85, 0x19, 0x00, 0x00, 0x04, 0x1b, 0x00,
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00, 0x20, 0x85, 0x19, 0x00, 0x20, 0x01, 0x0b, 0x00, 0x10, 0x02, 0x26, 0x00,
0x00, 0x02, 0x2e, 0x00, 0x00, 0x04, 0x33, 0x00, 0x00, 0x82, 0x37, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x04, 0x31, 0x00, 0x00, 0x82, 0x35, 0x00,
0x00, 0x04, 0x44, 0x00, 0x00, 0x0d, 0x44, 0x00, 0x00, 0x07, 0x46, 0x00, 0x00, 0x04, 0x42, 0x00, 0x00, 0x0d, 0x42, 0x00, 0x00, 0x07, 0x44, 0x00,
0x11, 0x81, 0x0d, 0x00, 0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x11, 0x81, 0x0b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00,
0x01, 0x07, 0x4b, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1d, 0x00, 0x01, 0x07, 0x49, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1b, 0x00,
0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x4d, 0x00, 0x12, 0x01, 0x44, 0x00, 0x22, 0x01, 0x44, 0x00, 0x12, 0x81, 0x4b, 0x00, 0x12, 0x01, 0x42, 0x00, 0x22, 0x01, 0x42, 0x00,
0x22, 0x05, 0x4b, 0x00, 0x12, 0x08, 0x55, 0x00, 0x12, 0x05, 0x4b, 0x00, 0x22, 0x05, 0x49, 0x00, 0x12, 0x08, 0x51, 0x00, 0x12, 0x05, 0x49, 0x00,
0x02, 0x02, 0x57, 0x00, 0x02, 0x04, 0x16, 0x00, 0x02, 0x85, 0x4b, 0x00, 0x02, 0x02, 0x53, 0x00, 0x02, 0x04, 0x14, 0x00, 0x02, 0x85, 0x49, 0x00,
0x02, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x02, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x4b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x49, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x61, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x5d, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00,
0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00,
0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00,
0x03, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x6d, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x69, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x6d, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x69, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x72, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x6e, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x46, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00, 0x11, 0x05, 0x44, 0x00,
0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x12, 0x81, 0x16, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00, 0x12, 0x81, 0x14, 0x00,
0x12, 0x03, 0x6d, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x69, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x03, 0x82, 0x6d, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x14, 0x81, 0x4d, 0x00, 0x03, 0x82, 0x69, 0x00, 0x03, 0x07, 0x49, 0x00, 0x14, 0x81, 0x4b, 0x00,
0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x44, 0x00, 0x24, 0x05, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x42, 0x00, 0x24, 0x05, 0x49, 0x00,
0x14, 0x08, 0x55, 0x00, 0x14, 0x05, 0x4b, 0x00, 0x04, 0x02, 0x57, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x05, 0x49, 0x00, 0x04, 0x02, 0x53, 0x00,
0x04, 0x04, 0x68, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x04, 0x04, 0x64, 0x00, 0x04, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00,
0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00,
0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00,
0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x03, 0x85, 0x7c, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00, 0x03, 0x85, 0x78, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x7c, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x78, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x7e, 0x00, 0x23, 0x01, 0x4d, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x7a, 0x00, 0x23, 0x01, 0x4b, 0x00,
0x23, 0x01, 0x44, 0x00, 0x33, 0x01, 0x44, 0x00, 0x33, 0x05, 0x4b, 0x00, 0x23, 0x01, 0x42, 0x00, 0x33, 0x01, 0x42, 0x00, 0x33, 0x05, 0x49, 0x00,
0x23, 0x08, 0x55, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x02, 0x57, 0x00, 0x23, 0x08, 0x51, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x02, 0x53, 0x00,
0x03, 0x08, 0x85, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x08, 0x7f, 0x00, 0x03, 0x07, 0x49, 0x00, 0x04, 0x82, 0x64, 0x00,
0x14, 0x81, 0x4d, 0x00, 0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x7e, 0x00, 0x14, 0x81, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x7a, 0x00,
0x24, 0x01, 0x72, 0x00, 0x14, 0x08, 0x55, 0x00, 0x14, 0x03, 0x4d, 0x00, 0x24, 0x01, 0x6e, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x03, 0x4b, 0x00,
0x04, 0x02, 0x87, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x04, 0x02, 0x81, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x00, 0x86, 0x8f, 0x00, 0x00, 0x8c, 0x33, 0x00, /* instruct array */ 0x00, 0x86, 0x89, 0x00, 0x00, 0x8c, 0x31, 0x00, /* instruct array */
0x92, 0x00, /* const pool size */ 0x8c, 0x00, /* const pool size */
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x6c,
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64, 0x65,
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65,
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x65, 0x72,
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e,
0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d,
0x3d, 0x3d, 0x00, 0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x31, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x2b, 0x00, 0x5f,
0x00, 0x2b, 0x00, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77,
0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65,
0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00,
0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x33, 0x00, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73,
0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
0x31, 0x00, /* const pool */
}; };
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes); pikaVM_runByteCode(self, (uint8_t*)bytes);
} }
void __Task_update_tick(PikaObj* self) { void __Task_update_tick(PikaObj* self) {

View File

@ -11,7 +11,7 @@
"program": "${workspaceFolder}/build/test/pikascript_test", "program": "${workspaceFolder}/build/test/pikascript_test",
// "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain", // "program": "${workspaceFolder}/build/boot/demo06-pikamain/pikascript_demo06-pikamain",
"args": [ "args": [
// "--gtest_filter=event.gpio" // "--gtest_filter=compiler*"
], ],
"stopAtEntry": false, "stopAtEntry": false,
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",

View File

@ -1,9 +1,10 @@
#api #api
from PikaObj import * from PikaObj import *
import PikaStdData import PikaStdData
import PikaStdLib
class Task(TinyObj): class Task(PikaStdLib.SysObj):
calls = PikaStdData.List() calls = PikaStdData.List()
def __init__(self): def __init__(self):

View File

@ -1,10 +1,8 @@
#include "BaseObj.h" #include "BaseObj.h"
#include "PikaVM.h" #include "PikaVM.h"
extern PikaObj* __pikaMain;
void PikaStdTask_Task___init__(PikaObj* self) { void PikaStdTask_Task___init__(PikaObj* self) {
obj_setInt(self, "is_period", 0); obj_setInt(self, "is_period", 0);
obj_setRef(__pikaMain, "__calls", obj_getObj(self, "calls"));
} }
void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) { void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) {
@ -90,116 +88,115 @@ void PikaStdTask_Task_call_period_ms(PikaObj* self,
} }
void PikaStdTask_Task_run_once(PikaObj* self) { void PikaStdTask_Task_run_once(PikaObj* self) {
/* transfer the tick to pikaMain */
obj_setInt(__pikaMain, "__tick", obj_getInt(self, "tick"));
/* clang-format off */ /* clang-format off */
PIKA_PYTHON( PIKA_PYTHON(
len = __calls.len() len = calls.len()
mode = 'none' mode = 'none'
info_index = 0 info_index = 0
for i in range(0, len): for i in range(0, len):
if len == 0: if len == 0:
break break
if info_index == 0: if info_index == 0:
mode = __calls[i] mode = calls[i]
info_index = 1 info_index = 1
elif info_index == 1: elif info_index == 1:
if mode == 'always': if mode == 'always':
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'when': elif mode == 'when':
when = __calls[i] when = calls[i]
info_index = 2 info_index = 2
elif mode == 'period_ms': elif mode == 'period_ms':
period_ms = __calls[i] period_ms = calls[i]
info_index = 2 info_index = 2
elif info_index == 2: elif info_index == 2:
if mode == 'when': if mode == 'when':
if when(): if when():
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'period_ms': elif mode == 'period_ms':
todo = __calls[i] todo = calls[i]
info_index = 3 info_index = 3
elif info_index == 3: elif info_index == 3:
if mode == 'period_ms': if mode == 'period_ms':
if __tick > __calls[i]: if tick > calls[i]:
todo() todo()
__calls[i] = __tick + period_ms calls[i] = tick + period_ms
info_index = 0 info_index = 0
) )
/* clang-format on */ /* clang-format on */
const uint8_t bytes[] = { const uint8_t bytes[] = {
0x60, 0x02, /* instruct array size */ 0x60, 0x02, /* instruct array size */
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00, 0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x83, 0x0f, 0x00,
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00, 0x00, 0x04, 0x14, 0x00, 0x00, 0x85, 0x19, 0x00, 0x00, 0x04, 0x1b, 0x00,
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00, 0x20, 0x85, 0x19, 0x00, 0x20, 0x01, 0x0b, 0x00, 0x10, 0x02, 0x26, 0x00,
0x00, 0x02, 0x2e, 0x00, 0x00, 0x04, 0x33, 0x00, 0x00, 0x82, 0x37, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x04, 0x31, 0x00, 0x00, 0x82, 0x35, 0x00,
0x00, 0x04, 0x44, 0x00, 0x00, 0x0d, 0x44, 0x00, 0x00, 0x07, 0x46, 0x00, 0x00, 0x04, 0x42, 0x00, 0x00, 0x0d, 0x42, 0x00, 0x00, 0x07, 0x44, 0x00,
0x11, 0x81, 0x0d, 0x00, 0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x11, 0x81, 0x0b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00,
0x01, 0x07, 0x4b, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1d, 0x00, 0x01, 0x07, 0x49, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1b, 0x00,
0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x4d, 0x00, 0x12, 0x01, 0x44, 0x00, 0x22, 0x01, 0x44, 0x00, 0x12, 0x81, 0x4b, 0x00, 0x12, 0x01, 0x42, 0x00, 0x22, 0x01, 0x42, 0x00,
0x22, 0x05, 0x4b, 0x00, 0x12, 0x08, 0x55, 0x00, 0x12, 0x05, 0x4b, 0x00, 0x22, 0x05, 0x49, 0x00, 0x12, 0x08, 0x51, 0x00, 0x12, 0x05, 0x49, 0x00,
0x02, 0x02, 0x57, 0x00, 0x02, 0x04, 0x16, 0x00, 0x02, 0x85, 0x4b, 0x00, 0x02, 0x02, 0x53, 0x00, 0x02, 0x04, 0x14, 0x00, 0x02, 0x85, 0x49, 0x00,
0x02, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x02, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x4b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x49, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x61, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x5d, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00,
0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00,
0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00,
0x03, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x6d, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x69, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x6d, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x69, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x72, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x6e, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x46, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00, 0x11, 0x05, 0x44, 0x00,
0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x12, 0x81, 0x16, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00, 0x12, 0x81, 0x14, 0x00,
0x12, 0x03, 0x6d, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x69, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x03, 0x82, 0x6d, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x14, 0x81, 0x4d, 0x00, 0x03, 0x82, 0x69, 0x00, 0x03, 0x07, 0x49, 0x00, 0x14, 0x81, 0x4b, 0x00,
0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x44, 0x00, 0x24, 0x05, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x42, 0x00, 0x24, 0x05, 0x49, 0x00,
0x14, 0x08, 0x55, 0x00, 0x14, 0x05, 0x4b, 0x00, 0x04, 0x02, 0x57, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x05, 0x49, 0x00, 0x04, 0x02, 0x53, 0x00,
0x04, 0x04, 0x68, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x04, 0x04, 0x64, 0x00, 0x04, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00,
0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00,
0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00,
0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x03, 0x85, 0x7c, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00, 0x03, 0x85, 0x78, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x7c, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x78, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x7e, 0x00, 0x23, 0x01, 0x4d, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x7a, 0x00, 0x23, 0x01, 0x4b, 0x00,
0x23, 0x01, 0x44, 0x00, 0x33, 0x01, 0x44, 0x00, 0x33, 0x05, 0x4b, 0x00, 0x23, 0x01, 0x42, 0x00, 0x33, 0x01, 0x42, 0x00, 0x33, 0x05, 0x49, 0x00,
0x23, 0x08, 0x55, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x02, 0x57, 0x00, 0x23, 0x08, 0x51, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x02, 0x53, 0x00,
0x03, 0x08, 0x85, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x08, 0x7f, 0x00, 0x03, 0x07, 0x49, 0x00, 0x04, 0x82, 0x64, 0x00,
0x14, 0x81, 0x4d, 0x00, 0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x7e, 0x00, 0x14, 0x81, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x7a, 0x00,
0x24, 0x01, 0x72, 0x00, 0x14, 0x08, 0x55, 0x00, 0x14, 0x03, 0x4d, 0x00, 0x24, 0x01, 0x6e, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x03, 0x4b, 0x00,
0x04, 0x02, 0x87, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x04, 0x02, 0x81, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x00, 0x86, 0x8f, 0x00, 0x00, 0x8c, 0x33, 0x00, /* instruct array */ 0x00, 0x86, 0x89, 0x00, 0x00, 0x8c, 0x31, 0x00, /* instruct array */
0x92, 0x00, /* const pool size */ 0x8c, 0x00, /* const pool size */
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x6c,
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64, 0x65,
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65,
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x65, 0x72,
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e,
0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d,
0x3d, 0x3d, 0x00, 0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x31, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x2b, 0x00, 0x5f,
0x00, 0x2b, 0x00, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77,
0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65,
0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00,
0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x33, 0x00, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73,
0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
0x31, 0x00, /* const pool */
}; };
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes); pikaVM_runByteCode(self, (uint8_t*)bytes);
} }
void __Task_update_tick(PikaObj* self) { void __Task_update_tick(PikaObj* self) {

View File

@ -2,82 +2,83 @@
TEST(compiler, file) { TEST(compiler, file) {
char* lines = char* lines =
"len = __calls.len()\n" "len = calls.len()\n"
"mode = 'none'\n" "mode = 'none'\n"
"info_index = 0\n" "info_index = 0\n"
"for i in range(0, len):\n" "for i in range(0, len):\n"
" if len == 0:\n" " if len == 0:\n"
" break\n" " break\n"
" if info_index == 0:\n" " if info_index == 0:\n"
" mode = __calls[i]\n" " mode = calls[i]\n"
" info_index = 1\n" " info_index = 1\n"
" elif info_index == 1:\n" " elif info_index == 1:\n"
" if mode == 'always':\n" " if mode == 'always':\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" todo()\n" " todo()\n"
" info_index = 0\n" " info_index = 0\n"
" elif mode == 'when':\n" " elif mode == 'when':\n"
" when = __calls[i]\n" " when = calls[i]\n"
" info_index = 2\n" " info_index = 2\n"
" elif mode == 'period_ms':\n" " elif mode == 'period_ms':\n"
" period_ms = __calls[i]\n" " period_ms = calls[i]\n"
" info_index = 2\n" " info_index = 2\n"
" elif info_index == 2:\n" " elif info_index == 2:\n"
" if mode == 'when':\n" " if mode == 'when':\n"
" if when():\n" " if when():\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" todo()\n" " todo()\n"
" info_index = 0\n" " info_index = 0\n"
" elif mode == 'period_ms':\n" " elif mode == 'period_ms':\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" info_index = 3\n" " info_index = 3\n"
" elif info_index == 3:\n" " elif info_index == 3:\n"
" if mode == 'period_ms':\n" " if mode == 'period_ms':\n"
" if __tick > __calls[i]:\n" " if tick > calls[i]:\n"
" todo()\n" " todo()\n"
" __calls[i] = __tick + period_ms\n" " calls[i] = tick + period_ms\n"
" info_index = 0\n" " info_index = 0\n"
"\n"; "\n";
pikaCompile("task.bin", lines); pikaCompile("task.bin", lines);
Parser_compilePyToBytecodeArray(lines);
EXPECT_EQ(pikaMemNow(), 0); EXPECT_EQ(pikaMemNow(), 0);
} }
TEST(compiler, task) { TEST(compiler, task) {
char* lines = char* lines =
"len = __calls.len()\n" "len = calls.len()\n"
"mode = 'none'\n" "mode = 'none'\n"
"info_index = 0\n" "info_index = 0\n"
"for i in range(0, len):\n" "for i in range(0, len):\n"
" if len == 0:\n" " if len == 0:\n"
" break\n" " break\n"
" if info_index == 0:\n" " if info_index == 0:\n"
" mode = __calls[i]\n" " mode = calls[i]\n"
" info_index = 1\n" " info_index = 1\n"
" elif info_index == 1:\n" " elif info_index == 1:\n"
" if mode == 'always':\n" " if mode == 'always':\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" todo()\n" " todo()\n"
" info_index = 0\n" " info_index = 0\n"
" elif mode == 'when':\n" " elif mode == 'when':\n"
" when = __calls[i]\n" " when = calls[i]\n"
" info_index = 2\n" " info_index = 2\n"
" elif mode == 'period_ms':\n" " elif mode == 'period_ms':\n"
" period_ms = __calls[i]\n" " period_ms = calls[i]\n"
" info_index = 2\n" " info_index = 2\n"
" elif info_index == 2:\n" " elif info_index == 2:\n"
" if mode == 'when':\n" " if mode == 'when':\n"
" if when():\n" " if when():\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" todo()\n" " todo()\n"
" info_index = 0\n" " info_index = 0\n"
" elif mode == 'period_ms':\n" " elif mode == 'period_ms':\n"
" todo = __calls[i]\n" " todo = calls[i]\n"
" info_index = 3\n" " info_index = 3\n"
" elif info_index == 3:\n" " elif info_index == 3:\n"
" if mode == 'period_ms':\n" " if mode == 'period_ms':\n"
" if __tick > __calls[i]:\n" " if tick > calls[i]:\n"
" todo()\n" " todo()\n"
" __calls[i] = __tick + period_ms\n" " calls[i] = tick + period_ms\n"
" info_index = 0\n" " info_index = 0\n"
"\n"; "\n";
@ -564,7 +565,7 @@ TEST(compiler, event_cb) {
} }
TEST(compiler, event_cb_lvgl) { TEST(compiler, event_cb_lvgl) {
char* lines = "_event_cb(_event_evt)"; char* lines = "eventCallBack(eventSignal)";
Parser_compilePyToBytecodeArray(lines); Parser_compilePyToBytecodeArray(lines);
EXPECT_EQ(pikaMemNow(), 0); EXPECT_EQ(pikaMemNow(), 0);
} }

View File

@ -1,6 +1,5 @@
#include "test_common.h" #include "test_common.h"
extern PikaEventListener* g_pika_device_event_listener; extern PikaEventListener* g_pika_device_event_listener;
TEST(event, gpio) { TEST(event, gpio) {
/* init */ /* init */

View File

@ -521,7 +521,15 @@ ByteCodeFrame* methodArg_getBytecodeFrame(Arg* method_arg) {
char* methodArg_getDec(Arg* method_arg) { char* methodArg_getDec(Arg* method_arg) {
uint32_t size_ptr = sizeof(void*); uint32_t size_ptr = sizeof(void*);
void* info = arg_getContent(method_arg); void* info = arg_getContent(method_arg);
return (char*)((uintptr_t)info + 2 * size_ptr); return (char*)((uintptr_t)info + 3 * size_ptr);
}
PikaObj* methodArg_getDefContext(Arg* method_arg) {
uint32_t size_ptr = sizeof(void*);
void* info = arg_getContent(method_arg) + 2 * size_ptr;
PikaObj* context = NULL;
__platform_memcpy(&context, info, size_ptr);
return context;
} }
static void obj_saveMethodInfo(PikaObj* self, MethodInfo* method_info) { static void obj_saveMethodInfo(PikaObj* self, MethodInfo* method_info) {
@ -532,11 +540,17 @@ static void obj_saveMethodInfo(PikaObj* self, MethodInfo* method_info) {
uint32_t size_pars = strGetSize(pars); uint32_t size_pars = strGetSize(pars);
uintptr_t method_info_bytecode_frame = uintptr_t method_info_bytecode_frame =
(uintptr_t)method_info->bytecode_frame; (uintptr_t)method_info->bytecode_frame;
uintptr_t method_info_def_context = (uintptr_t)method_info->def_context;
/* the first arg_value */
arg = arg =
arg_setPtr(arg, method_info->name, method_info->type, method_info->ptr); arg_setPtr(arg, method_info->name, method_info->type, method_info->ptr);
/* the seconed */
arg = arg_append(arg, &(method_info_bytecode_frame), arg = arg_append(arg, &(method_info_bytecode_frame),
sizeof(method_info_bytecode_frame)); sizeof(method_info_bytecode_frame));
arg = arg_append(arg, &(method_info_def_context),
sizeof(method_info_def_context));
arg = arg_append(arg, method_info->pars, size_pars + 1); arg = arg_append(arg, method_info->pars, size_pars + 1);
args_setArg(self->list, arg); args_setArg(self->list, arg);
strsDeinit(&buffs); strsDeinit(&buffs);
} }
@ -545,6 +559,7 @@ static int32_t __class_defineMethodWithType(PikaObj* self,
char* declearation, char* declearation,
Method method_ptr, Method method_ptr,
ArgType method_type, ArgType method_type,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame) { ByteCodeFrame* bytecode_frame) {
int32_t size = strGetSize(declearation); int32_t size = strGetSize(declearation);
int32_t res = 0; int32_t res = 0;
@ -567,6 +582,7 @@ static int32_t __class_defineMethodWithType(PikaObj* self,
method_info.name = method_name; method_info.name = method_name;
method_info.ptr = (void*)method_ptr; method_info.ptr = (void*)method_ptr;
method_info.type = method_type; method_info.type = method_type;
method_info.def_context = def_context;
method_info.bytecode_frame = bytecode_frame; method_info.bytecode_frame = bytecode_frame;
obj_saveMethodInfo(method_host, &method_info); obj_saveMethodInfo(method_host, &method_info);
res = 0; res = 0;
@ -582,7 +598,7 @@ int32_t class_defineConstructor(PikaObj* self,
Method methodPtr) { Method methodPtr) {
return __class_defineMethodWithType(self, declearation, methodPtr, return __class_defineMethodWithType(self, declearation, methodPtr,
ARG_TYPE_METHOD_NATIVE_CONSTRUCTOR, ARG_TYPE_METHOD_NATIVE_CONSTRUCTOR,
NULL); NULL, NULL);
} }
/* define a native method as default */ /* define a native method as default */
@ -590,35 +606,40 @@ int32_t class_defineMethod(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr) { Method methodPtr) {
return __class_defineMethodWithType(self, declearation, methodPtr, return __class_defineMethodWithType(self, declearation, methodPtr,
ARG_TYPE_METHOD_NATIVE, NULL); ARG_TYPE_METHOD_NATIVE, NULL, NULL);
} }
/* define object method, object method is which startwith (self) */ /* define object method, object method is which startwith (self) */
int32_t class_defineRunTimeConstructor(PikaObj* self, int32_t class_defineRunTimeConstructor(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame) { ByteCodeFrame* bytecode_frame) {
return __class_defineMethodWithType(self, declearation, methodPtr, return __class_defineMethodWithType(self, declearation, methodPtr,
ARG_TYPE_METHOD_CONSTRUCTOR, ARG_TYPE_METHOD_CONSTRUCTOR,
bytecode_frame); def_context, bytecode_frame);
} }
/* define object method, object method is which startwith (self) */ /* define object method, object method is which startwith (self) */
int32_t class_defineObjectMethod(PikaObj* self, int32_t class_defineObjectMethod(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame) { ByteCodeFrame* bytecode_frame) {
return __class_defineMethodWithType(self, declearation, methodPtr, return __class_defineMethodWithType(self, declearation, methodPtr,
ARG_TYPE_METHOD_OBJECT, bytecode_frame); ARG_TYPE_METHOD_OBJECT, def_context,
bytecode_frame);
} }
/* define a static method as default */ /* define a static method as default */
int32_t class_defineStaticMethod(PikaObj* self, int32_t class_defineStaticMethod(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame) { ByteCodeFrame* bytecode_frame) {
return __class_defineMethodWithType(self, declearation, methodPtr, return __class_defineMethodWithType(self, declearation, methodPtr,
ARG_TYPE_METHOD_STATIC, bytecode_frame); ARG_TYPE_METHOD_STATIC, def_context,
bytecode_frame);
} }
VMParameters* obj_runDirect(PikaObj* self, char* cmd) { VMParameters* obj_runDirect(PikaObj* self, char* cmd) {
@ -992,7 +1013,8 @@ PikaObj* obj_importModuleWithByteCode(PikaObj* self,
PikaObj* obj_importModuleWithByteCodeFrame(PikaObj* self, PikaObj* obj_importModuleWithByteCodeFrame(PikaObj* self,
char* name, char* name,
ByteCodeFrame* byteCode_frame) { ByteCodeFrame* byteCode_frame) {
obj_newDirectObj(self, name, New_TinyObj); PikaObj* New_PikaStdLib_SysObj(Args * args);
obj_newDirectObj(self, name, New_PikaStdLib_SysObj);
pikaVM_runByteCodeFrame(obj_getObj(self, name), byteCode_frame); pikaVM_runByteCodeFrame(obj_getObj(self, name), byteCode_frame);
return self; return self;
} }
@ -1092,8 +1114,6 @@ static PikaObj* pks_eventLisener_getEventHandleObj(PikaEventListener* self,
return eventHandleObj; return eventHandleObj;
} }
extern PikaObj* __pikaMain;
void pks_eventLisener_init(PikaEventListener** p_self) { void pks_eventLisener_init(PikaEventListener** p_self) {
*p_self = newNormalObj(New_TinyObj); *p_self = newNormalObj(New_TinyObj);
} }
@ -1114,23 +1134,19 @@ void pks_eventLisener_sendSignal(PikaEventListener* self,
"Error: can not find event handler by id: [0x%02x]\r\n", eventId); "Error: can not find event handler by id: [0x%02x]\r\n", eventId);
return; return;
} }
obj_setArg(__pikaMain, "_eventCallBack", obj_setInt(eventHandleObj, "eventSignal", eventSignal);
obj_getArg(eventHandleObj, "eventCallBack"));
obj_setInt(__pikaMain, "_eventSignal", eventSignal);
/* clang-format off */ /* clang-format off */
PIKA_PYTHON( PIKA_PYTHON(
_eventCallBack(_eventSignal) eventCallBack(eventSignal)
) )
/* clang-format on */ /* clang-format on */
const uint8_t bytes[] = { const uint8_t bytes[] = {
0x08, 0x00, /* instruct array size */ 0x08, 0x00, /* instruct array size */
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0e, 0x00, /* instruct array */ 0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x0d, 0x00, /* instruct array */
0x1d, 0x00, /* const pool size */ 0x1b, 0x00, /* const pool size */
0x00, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x67, 0x00, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x69, 0x67,
0x6e, 0x61, 0x6c, 0x00, 0x5f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x6e, 0x61, 0x6c, 0x00, 0x65, 0x76, 0x65, 0x6e, 0x74,
0x43, 0x61, 0x6c, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x00, /* const pool */ 0x43, 0x61, 0x6c, 0x6c, 0x42, 0x61, 0x63, 0x6b, 0x00, /* const pool */
}; };
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes); pikaVM_runByteCode(eventHandleObj, (uint8_t*)bytes);
obj_removeArg(__pikaMain, "_eventCallBack");
obj_removeArg(__pikaMain, "_eventSignal");
} }

View File

@ -81,6 +81,7 @@ struct MethodInfo {
char* dec; char* dec;
char* ptr; char* ptr;
char* pars; char* pars;
PikaObj* def_context;
ArgType type; ArgType type;
ByteCodeFrame* bytecode_frame; ByteCodeFrame* bytecode_frame;
}; };
@ -128,16 +129,20 @@ PikaObj* obj_getHostObj(PikaObj* self, char* objPath);
int32_t obj_freeObj(PikaObj* self, char* subObjectName); int32_t obj_freeObj(PikaObj* self, char* subObjectName);
/* method */ /* method */
int32_t class_defineMethod(PikaObj* self, char* declearation, Method methodPtr); int32_t class_defineMethod(PikaObj* self,
char* declearation,
Method methodPtr);
int32_t class_defineObjectMethod(PikaObj* self, int32_t class_defineObjectMethod(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame); ByteCodeFrame* bytecode_frame);
int32_t class_defineStaticMethod(PikaObj* self, int32_t class_defineStaticMethod(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame); ByteCodeFrame* bytecode_frame);
int32_t class_defineConstructor(PikaObj* self, int32_t class_defineConstructor(PikaObj* self,
@ -147,6 +152,7 @@ int32_t class_defineConstructor(PikaObj* self,
int32_t class_defineRunTimeConstructor(PikaObj* self, int32_t class_defineRunTimeConstructor(PikaObj* self,
char* declearation, char* declearation,
Method methodPtr, Method methodPtr,
PikaObj* def_context,
ByteCodeFrame* bytecode_frame); ByteCodeFrame* bytecode_frame);
int32_t obj_removeArg(PikaObj* self, char* argPath); int32_t obj_removeArg(PikaObj* self, char* argPath);
@ -264,4 +270,5 @@ void pks_eventLicener_registEvent(PikaEventListener* self,
void pks_eventLisener_init(PikaEventListener** p_self); void pks_eventLisener_init(PikaEventListener** p_self);
void pks_eventLisener_deinit(PikaEventListener** p_self); void pks_eventLisener_deinit(PikaEventListener** p_self);
PikaObj* methodArg_getDefContext(Arg* method_arg);
#endif #endif

View File

@ -207,6 +207,10 @@ static Arg* VMState_runMethodArg(VMState* vs,
} }
ByteCodeFrame* method_bytecodeFrame = ByteCodeFrame* method_bytecodeFrame =
methodArg_getBytecodeFrame(method_arg); methodArg_getBytecodeFrame(method_arg);
PikaObj* method_context = methodArg_getDefContext(method_arg);
if (NULL != method_context) {
method_host_obj = method_context;
}
obj_setErrorCode(method_host_obj, 0); obj_setErrorCode(method_host_obj, 0);
/* run method */ /* run method */
@ -229,8 +233,8 @@ static Arg* VMState_runMethodArg(VMState* vs,
&(method_bytecodeFrame->instruct_array), 0); &(method_bytecodeFrame->instruct_array), 0);
uint16_t pc = (uintptr_t)method_ptr - insturctArray_start; uint16_t pc = (uintptr_t)method_ptr - insturctArray_start;
method_args_obj = __pikaVM_runByteCodeFrameWithState( method_args_obj = __pikaVM_runByteCodeFrameWithState(
method_host_obj, method_args_obj, vs->globals, method_bytecodeFrame, method_host_obj, method_args_obj, method_host_obj,
pc); method_bytecodeFrame, pc);
/* get method return */ /* get method return */
return_arg = return_arg =
@ -925,15 +929,15 @@ static Arg* __VM_instruction_handler_DEF(PikaObj* self,
if (instructUnit_getBlockDeepth(ins_unit_now) == thisBlockDeepth + 1) { if (instructUnit_getBlockDeepth(ins_unit_now) == thisBlockDeepth + 1) {
if (is_in_class) { if (is_in_class) {
class_defineObjectMethod(hostObj, data, (Method)ins_unit_now, class_defineObjectMethod(hostObj, data, (Method)ins_unit_now,
vs->bytecode_frame); self, vs->bytecode_frame);
} else { } else {
if (is_class) { if (is_class) {
class_defineRunTimeConstructor(hostObj, data, class_defineRunTimeConstructor(hostObj, data,
(Method)ins_unit_now, (Method)ins_unit_now, self,
vs->bytecode_frame); vs->bytecode_frame);
} else { } else {
class_defineStaticMethod(hostObj, data, class_defineStaticMethod(hostObj, data,
(Method)ins_unit_now, (Method)ins_unit_now, self,
vs->bytecode_frame); vs->bytecode_frame);
} }
} }

View File

@ -1,9 +1,10 @@
#api #api
from PikaObj import * from PikaObj import *
import PikaStdData import PikaStdData
import PikaStdLib
class Task(TinyObj): class Task(PikaStdLib.SysObj):
calls = PikaStdData.List() calls = PikaStdData.List()
def __init__(self): def __init__(self):

View File

@ -1,10 +1,8 @@
#include "BaseObj.h" #include "BaseObj.h"
#include "PikaVM.h" #include "PikaVM.h"
extern PikaObj* __pikaMain;
void PikaStdTask_Task___init__(PikaObj* self) { void PikaStdTask_Task___init__(PikaObj* self) {
obj_setInt(self, "is_period", 0); obj_setInt(self, "is_period", 0);
obj_setRef(__pikaMain, "__calls", obj_getObj(self, "calls"));
} }
void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) { void PikaStdTask_Task_call_always(PikaObj* self, Arg* fun_todo) {
@ -90,116 +88,115 @@ void PikaStdTask_Task_call_period_ms(PikaObj* self,
} }
void PikaStdTask_Task_run_once(PikaObj* self) { void PikaStdTask_Task_run_once(PikaObj* self) {
/* transfer the tick to pikaMain */
obj_setInt(__pikaMain, "__tick", obj_getInt(self, "tick"));
/* clang-format off */ /* clang-format off */
PIKA_PYTHON( PIKA_PYTHON(
len = __calls.len() len = calls.len()
mode = 'none' mode = 'none'
info_index = 0 info_index = 0
for i in range(0, len): for i in range(0, len):
if len == 0: if len == 0:
break break
if info_index == 0: if info_index == 0:
mode = __calls[i] mode = calls[i]
info_index = 1 info_index = 1
elif info_index == 1: elif info_index == 1:
if mode == 'always': if mode == 'always':
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'when': elif mode == 'when':
when = __calls[i] when = calls[i]
info_index = 2 info_index = 2
elif mode == 'period_ms': elif mode == 'period_ms':
period_ms = __calls[i] period_ms = calls[i]
info_index = 2 info_index = 2
elif info_index == 2: elif info_index == 2:
if mode == 'when': if mode == 'when':
if when(): if when():
todo = __calls[i] todo = calls[i]
todo() todo()
info_index = 0 info_index = 0
elif mode == 'period_ms': elif mode == 'period_ms':
todo = __calls[i] todo = calls[i]
info_index = 3 info_index = 3
elif info_index == 3: elif info_index == 3:
if mode == 'period_ms': if mode == 'period_ms':
if __tick > __calls[i]: if tick > calls[i]:
todo() todo()
__calls[i] = __tick + period_ms calls[i] = tick + period_ms
info_index = 0 info_index = 0
) )
/* clang-format on */ /* clang-format on */
const uint8_t bytes[] = { const uint8_t bytes[] = {
0x60, 0x02, /* instruct array size */ 0x60, 0x02, /* instruct array size */
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00, 0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0b, 0x00, 0x00, 0x83, 0x0f, 0x00,
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00, 0x00, 0x04, 0x14, 0x00, 0x00, 0x85, 0x19, 0x00, 0x00, 0x04, 0x1b, 0x00,
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00, 0x20, 0x85, 0x19, 0x00, 0x20, 0x01, 0x0b, 0x00, 0x10, 0x02, 0x26, 0x00,
0x00, 0x02, 0x2e, 0x00, 0x00, 0x04, 0x33, 0x00, 0x00, 0x82, 0x37, 0x00, 0x00, 0x02, 0x2c, 0x00, 0x00, 0x04, 0x31, 0x00, 0x00, 0x82, 0x35, 0x00,
0x00, 0x04, 0x44, 0x00, 0x00, 0x0d, 0x44, 0x00, 0x00, 0x07, 0x46, 0x00, 0x00, 0x04, 0x42, 0x00, 0x00, 0x0d, 0x42, 0x00, 0x00, 0x07, 0x44, 0x00,
0x11, 0x81, 0x0d, 0x00, 0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x11, 0x81, 0x0b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00,
0x01, 0x07, 0x4b, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1d, 0x00, 0x01, 0x07, 0x49, 0x00, 0x02, 0x8e, 0x00, 0x00, 0x11, 0x81, 0x1b, 0x00,
0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x19, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x4d, 0x00, 0x12, 0x01, 0x44, 0x00, 0x22, 0x01, 0x44, 0x00, 0x12, 0x81, 0x4b, 0x00, 0x12, 0x01, 0x42, 0x00, 0x22, 0x01, 0x42, 0x00,
0x22, 0x05, 0x4b, 0x00, 0x12, 0x08, 0x55, 0x00, 0x12, 0x05, 0x4b, 0x00, 0x22, 0x05, 0x49, 0x00, 0x12, 0x08, 0x51, 0x00, 0x12, 0x05, 0x49, 0x00,
0x02, 0x02, 0x57, 0x00, 0x02, 0x04, 0x16, 0x00, 0x02, 0x85, 0x4b, 0x00, 0x02, 0x02, 0x53, 0x00, 0x02, 0x04, 0x14, 0x00, 0x02, 0x85, 0x49, 0x00,
0x02, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x02, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x4b, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x49, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x61, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x5d, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00,
0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00,
0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00,
0x03, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x6d, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x69, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x6d, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x69, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00,
0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x4d, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x4b, 0x00,
0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00, 0x23, 0x05, 0x49, 0x00,
0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x03, 0x02, 0x57, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00, 0x03, 0x02, 0x53, 0x00,
0x03, 0x04, 0x72, 0x00, 0x03, 0x85, 0x46, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x03, 0x04, 0x6e, 0x00, 0x03, 0x85, 0x44, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x46, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00, 0x11, 0x05, 0x44, 0x00,
0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x12, 0x81, 0x16, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00, 0x12, 0x81, 0x14, 0x00,
0x12, 0x03, 0x6d, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x69, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x03, 0x82, 0x6d, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x14, 0x81, 0x4d, 0x00, 0x03, 0x82, 0x69, 0x00, 0x03, 0x07, 0x49, 0x00, 0x14, 0x81, 0x4b, 0x00,
0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x44, 0x00, 0x24, 0x05, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x42, 0x00, 0x24, 0x05, 0x49, 0x00,
0x14, 0x08, 0x55, 0x00, 0x14, 0x05, 0x4b, 0x00, 0x04, 0x02, 0x57, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x05, 0x49, 0x00, 0x04, 0x02, 0x53, 0x00,
0x04, 0x04, 0x68, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x04, 0x04, 0x64, 0x00, 0x04, 0x82, 0x64, 0x00, 0x03, 0x85, 0x19, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x4b, 0x00, 0x12, 0x01, 0x16, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x02, 0x8b, 0x49, 0x00, 0x12, 0x01, 0x14, 0x00,
0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x02, 0x07, 0x4b, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00, 0x02, 0x07, 0x49, 0x00,
0x13, 0x81, 0x4d, 0x00, 0x13, 0x01, 0x44, 0x00, 0x23, 0x01, 0x44, 0x00, 0x13, 0x81, 0x4b, 0x00, 0x13, 0x01, 0x42, 0x00, 0x23, 0x01, 0x42, 0x00,
0x23, 0x05, 0x4b, 0x00, 0x13, 0x08, 0x55, 0x00, 0x13, 0x05, 0x4b, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x08, 0x51, 0x00, 0x13, 0x05, 0x49, 0x00,
0x03, 0x02, 0x57, 0x00, 0x03, 0x04, 0x68, 0x00, 0x03, 0x85, 0x7c, 0x00, 0x03, 0x02, 0x53, 0x00, 0x03, 0x04, 0x64, 0x00, 0x03, 0x85, 0x78, 0x00,
0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x4b, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x03, 0x04, 0x1b, 0x00, 0x01, 0x8b, 0x49, 0x00, 0x11, 0x01, 0x1b, 0x00,
0x11, 0x05, 0x7c, 0x00, 0x01, 0x08, 0x48, 0x00, 0x01, 0x07, 0x4b, 0x00, 0x11, 0x05, 0x78, 0x00, 0x01, 0x08, 0x46, 0x00, 0x01, 0x07, 0x49, 0x00,
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x72, 0x00, 0x02, 0x08, 0x48, 0x00, 0x12, 0x81, 0x14, 0x00, 0x12, 0x03, 0x6e, 0x00, 0x02, 0x08, 0x46, 0x00,
0x02, 0x07, 0x4b, 0x00, 0x13, 0x81, 0x7e, 0x00, 0x23, 0x01, 0x4d, 0x00, 0x02, 0x07, 0x49, 0x00, 0x13, 0x81, 0x7a, 0x00, 0x23, 0x01, 0x4b, 0x00,
0x23, 0x01, 0x44, 0x00, 0x33, 0x01, 0x44, 0x00, 0x33, 0x05, 0x4b, 0x00, 0x23, 0x01, 0x42, 0x00, 0x33, 0x01, 0x42, 0x00, 0x33, 0x05, 0x49, 0x00,
0x23, 0x08, 0x55, 0x00, 0x23, 0x05, 0x4b, 0x00, 0x13, 0x02, 0x57, 0x00, 0x23, 0x08, 0x51, 0x00, 0x23, 0x05, 0x49, 0x00, 0x13, 0x02, 0x53, 0x00,
0x03, 0x08, 0x85, 0x00, 0x03, 0x07, 0x4b, 0x00, 0x04, 0x82, 0x68, 0x00, 0x03, 0x08, 0x7f, 0x00, 0x03, 0x07, 0x49, 0x00, 0x04, 0x82, 0x64, 0x00,
0x14, 0x81, 0x4d, 0x00, 0x14, 0x01, 0x44, 0x00, 0x24, 0x01, 0x7e, 0x00, 0x14, 0x81, 0x4b, 0x00, 0x14, 0x01, 0x42, 0x00, 0x24, 0x01, 0x7a, 0x00,
0x24, 0x01, 0x72, 0x00, 0x14, 0x08, 0x55, 0x00, 0x14, 0x03, 0x4d, 0x00, 0x24, 0x01, 0x6e, 0x00, 0x14, 0x08, 0x51, 0x00, 0x14, 0x03, 0x4b, 0x00,
0x04, 0x02, 0x87, 0x00, 0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x04, 0x02, 0x81, 0x00, 0x03, 0x85, 0x19, 0x00, 0x03, 0x04, 0x1b, 0x00,
0x00, 0x86, 0x8f, 0x00, 0x00, 0x8c, 0x33, 0x00, /* instruct array */ 0x00, 0x86, 0x89, 0x00, 0x00, 0x8c, 0x31, 0x00, /* instruct array */
0x92, 0x00, /* const pool size */ 0x8c, 0x00, /* const pool size */
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00, 0x6c,
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64, 0x65,
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64, 0x65,
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x65, 0x72,
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e,
0x5f, 0x6e, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x65, 0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d,
0x3d, 0x3d, 0x00, 0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x31, 0x00, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x2b, 0x00, 0x5f,
0x00, 0x2b, 0x00, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x5f, 0x73, 0x6c, 0x69, 0x63, 0x65, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77,
0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x61, 0x79, 0x73, 0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65,
0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x6e, 0x00, 0x70, 0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00,
0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f, 0x5f, 0x74, 0x69, 0x63, 0x6b, 0x33, 0x00, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73,
0x00, 0x3e, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
0x31, 0x00, /* const pool */
}; };
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes); pikaVM_runByteCode(self, (uint8_t*)bytes);
} }
void __Task_update_tick(PikaObj* self) { void __Task_update_tick(PikaObj* self) {