mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
update PikaStdTask to bytecode based
This commit is contained in:
parent
494f61a562
commit
ff1c71322b
@ -45,7 +45,7 @@ void PikaStdLib_SysObj_type(PikaObj* self, Arg* arg) {
|
||||
obj_setSysOut(self, "mate_object");
|
||||
return;
|
||||
}
|
||||
if (ARG_TYPE_STATIC_METHOD == type) {
|
||||
if (ARG_TYPE_NATIVE_METHOD == type) {
|
||||
obj_setSysOut(self, "method");
|
||||
return;
|
||||
}
|
||||
@ -79,22 +79,22 @@ int PikaStdLib_SysObj_int(PikaObj* self, Arg* arg) {
|
||||
|
||||
char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
|
||||
ArgType type = arg_getType(arg);
|
||||
Args* buffs = New_strBuff();
|
||||
Args buffs = {0};
|
||||
char* res = NULL;
|
||||
do {
|
||||
if (ARG_TYPE_INT == type) {
|
||||
int val = arg_getInt(arg);
|
||||
res = strsFormat(buffs, 11, "%d", val);
|
||||
res = strsFormat(&buffs, 11, "%d", val);
|
||||
break;
|
||||
}
|
||||
if (ARG_TYPE_FLOAT == type) {
|
||||
float val = arg_getFloat(arg);
|
||||
res = strsFormat(buffs, 11, "%f", val);
|
||||
res = strsFormat(&buffs, 11, "%f", val);
|
||||
break;
|
||||
}
|
||||
} while (0);
|
||||
obj_setStr(self, "__strtmp", res);
|
||||
args_deinit(buffs);
|
||||
strsDeinit(&buffs);
|
||||
return obj_getStr(self, "__strtmp");
|
||||
}
|
||||
|
||||
|
@ -80,176 +80,70 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
|
||||
" info_index = 0\n"
|
||||
"\n");
|
||||
*/
|
||||
pikaVM_runAsm(__pikaMain,
|
||||
"B0\n"
|
||||
"0 RUN __calls.len\n"
|
||||
"0 OUT len\n"
|
||||
"B0\n"
|
||||
"0 STR none\n"
|
||||
"0 OUT mode\n"
|
||||
"B0\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B0\n"
|
||||
"2 NUM 0\n"
|
||||
"2 REF len\n"
|
||||
"1 RUN range\n"
|
||||
"0 RUN iter\n"
|
||||
"0 OUT _l0\n"
|
||||
"0 REF _r1\n"
|
||||
"0 REF _r2\n"
|
||||
"0 REF _r3\n"
|
||||
"0 OUT _l0.a1\n"
|
||||
"0 OUT _l0.a2\n"
|
||||
"0 OUT _l0.a3\n"
|
||||
"B0\n"
|
||||
"0 RUN _l0.__next__\n"
|
||||
"0 OUT i\n"
|
||||
"0 EST i\n"
|
||||
"0 JEZ 2\n"
|
||||
"B1\n"
|
||||
"1 REF len\n"
|
||||
"1 NUM 0\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"0 BRK\n"
|
||||
"B1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 0\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT mode\n"
|
||||
"B2\n"
|
||||
"0 NUM 1\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 1\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR always\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B3\n"
|
||||
"0 RUN todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR when\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT when\n"
|
||||
"B3\n"
|
||||
"0 NUM 2\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT period_ms\n"
|
||||
"B3\n"
|
||||
"0 NUM 2\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 2\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR when\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"0 RUN when\n"
|
||||
"0 JEZ 1\n"
|
||||
"B4\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B4\n"
|
||||
"0 RUN todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 3\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 3\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __tick\n"
|
||||
"2 REF __calls\n"
|
||||
"2 REF i\n"
|
||||
"1 RUN __get__\n"
|
||||
"0 OPT >\n"
|
||||
"0 JEZ 1\n"
|
||||
"B4\n"
|
||||
"0 RUN todo\n"
|
||||
"B4\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"2 REF __tick\n"
|
||||
"2 REF period_ms\n"
|
||||
"1 OPT +\n"
|
||||
"1 STR __calls\n"
|
||||
"0 RUN __set__\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B0\n"
|
||||
"0 JMP -1\n"
|
||||
"B0\n"
|
||||
"0 DEL _l0\n"
|
||||
"B0\n");
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x02, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00,
|
||||
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00,
|
||||
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00,
|
||||
0x00, 0x02, 0x2e, 0x00, 0x00, 0x04, 0x33, 0x00, 0x00, 0x01, 0x37, 0x00,
|
||||
0x00, 0x01, 0x3b, 0x00, 0x00, 0x01, 0x3f, 0x00, 0x00, 0x04, 0x43, 0x00,
|
||||
0x00, 0x04, 0x4a, 0x00, 0x00, 0x04, 0x51, 0x00, 0x00, 0x82, 0x58, 0x00,
|
||||
0x00, 0x04, 0x65, 0x00, 0x00, 0x0d, 0x65, 0x00, 0x00, 0x07, 0x67, 0x00,
|
||||
0x11, 0x81, 0x0d, 0x00, 0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x69, 0x00,
|
||||
0x01, 0x07, 0x6c, 0x00, 0x02, 0x8e, 0x6c, 0x00, 0x11, 0x81, 0x1d, 0x00,
|
||||
0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00,
|
||||
0x12, 0x81, 0x6e, 0x00, 0x12, 0x01, 0x65, 0x00, 0x02, 0x02, 0x76, 0x00,
|
||||
0x02, 0x04, 0x16, 0x00, 0x02, 0x85, 0x6c, 0x00, 0x02, 0x04, 0x1d, 0x00,
|
||||
0x01, 0x8b, 0x6c, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x6c, 0x00,
|
||||
0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00, 0x12, 0x81, 0x16, 0x00,
|
||||
0x12, 0x03, 0x7e, 0x00, 0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00,
|
||||
0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00,
|
||||
0x03, 0x04, 0x85, 0x00, 0x03, 0x82, 0x85, 0x00, 0x03, 0x85, 0x1b, 0x00,
|
||||
0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x6c, 0x00, 0x12, 0x01, 0x16, 0x00,
|
||||
0x12, 0x03, 0x8a, 0x00, 0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00,
|
||||
0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00,
|
||||
0x03, 0x04, 0x8a, 0x00, 0x03, 0x85, 0x67, 0x00, 0x03, 0x04, 0x1d, 0x00,
|
||||
0x02, 0x8b, 0x6c, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00,
|
||||
0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x6e, 0x00,
|
||||
0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00, 0x03, 0x04, 0x8f, 0x00,
|
||||
0x03, 0x85, 0x67, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x6c, 0x00,
|
||||
0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x67, 0x00, 0x01, 0x08, 0x69, 0x00,
|
||||
0x01, 0x07, 0x6c, 0x00, 0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x8a, 0x00,
|
||||
0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00, 0x03, 0x82, 0x8a, 0x00,
|
||||
0x03, 0x07, 0x6c, 0x00, 0x14, 0x81, 0x6e, 0x00, 0x14, 0x01, 0x65, 0x00,
|
||||
0x04, 0x02, 0x76, 0x00, 0x04, 0x04, 0x85, 0x00, 0x04, 0x82, 0x85, 0x00,
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x6c, 0x00,
|
||||
0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00, 0x02, 0x08, 0x69, 0x00,
|
||||
0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00,
|
||||
0x03, 0x02, 0x76, 0x00, 0x03, 0x04, 0x85, 0x00, 0x03, 0x85, 0x99, 0x00,
|
||||
0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x6c, 0x00, 0x11, 0x01, 0x1d, 0x00,
|
||||
0x11, 0x05, 0x99, 0x00, 0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00,
|
||||
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00, 0x02, 0x08, 0x69, 0x00,
|
||||
0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x9b, 0x00, 0x23, 0x01, 0x6e, 0x00,
|
||||
0x23, 0x01, 0x65, 0x00, 0x13, 0x02, 0x76, 0x00, 0x03, 0x08, 0xa2, 0x00,
|
||||
0x03, 0x07, 0x6c, 0x00, 0x04, 0x82, 0x85, 0x00, 0x14, 0x81, 0x6e, 0x00,
|
||||
0x14, 0x01, 0x65, 0x00, 0x24, 0x01, 0x9b, 0x00, 0x24, 0x01, 0x8f, 0x00,
|
||||
0x14, 0x08, 0xa4, 0x00, 0x14, 0x03, 0x6e, 0x00, 0x04, 0x02, 0xa6, 0x00,
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x00, 0x86, 0xae, 0x00,
|
||||
0x00, 0x8c, 0x33, 0x00, /* instruct array */
|
||||
0xb1, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
|
||||
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74,
|
||||
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x72, 0x31, 0x00, 0x5f,
|
||||
0x72, 0x32, 0x00, 0x5f, 0x72, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61,
|
||||
0x31, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61, 0x32, 0x00, 0x5f, 0x6c, 0x30,
|
||||
0x2e, 0x61, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d, 0x00,
|
||||
0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x5f, 0x5f,
|
||||
0x67, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73,
|
||||
0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70,
|
||||
0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f,
|
||||
0x5f, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x2b, 0x00, 0x5f, 0x5f,
|
||||
0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes);
|
||||
}
|
||||
|
||||
void __Task_update_tick(PikaObj* self) {
|
||||
|
@ -80,176 +80,70 @@ void PikaStdTask_Task_run_once(PikaObj* self) {
|
||||
" info_index = 0\n"
|
||||
"\n");
|
||||
*/
|
||||
pikaVM_runAsm(__pikaMain,
|
||||
"B0\n"
|
||||
"0 RUN __calls.len\n"
|
||||
"0 OUT len\n"
|
||||
"B0\n"
|
||||
"0 STR none\n"
|
||||
"0 OUT mode\n"
|
||||
"B0\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B0\n"
|
||||
"2 NUM 0\n"
|
||||
"2 REF len\n"
|
||||
"1 RUN range\n"
|
||||
"0 RUN iter\n"
|
||||
"0 OUT _l0\n"
|
||||
"0 REF _r1\n"
|
||||
"0 REF _r2\n"
|
||||
"0 REF _r3\n"
|
||||
"0 OUT _l0.a1\n"
|
||||
"0 OUT _l0.a2\n"
|
||||
"0 OUT _l0.a3\n"
|
||||
"B0\n"
|
||||
"0 RUN _l0.__next__\n"
|
||||
"0 OUT i\n"
|
||||
"0 EST i\n"
|
||||
"0 JEZ 2\n"
|
||||
"B1\n"
|
||||
"1 REF len\n"
|
||||
"1 NUM 0\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"0 BRK\n"
|
||||
"B1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 0\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT mode\n"
|
||||
"B2\n"
|
||||
"0 NUM 1\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 1\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR always\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B3\n"
|
||||
"0 RUN todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR when\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT when\n"
|
||||
"B3\n"
|
||||
"0 NUM 2\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT period_ms\n"
|
||||
"B3\n"
|
||||
"0 NUM 2\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 2\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR when\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"0 RUN when\n"
|
||||
"0 JEZ 1\n"
|
||||
"B4\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B4\n"
|
||||
"0 RUN todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B2\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"0 RUN __get__\n"
|
||||
"0 OUT todo\n"
|
||||
"B3\n"
|
||||
"0 NUM 3\n"
|
||||
"0 OUT info_index\n"
|
||||
"B1\n"
|
||||
"0 NEL 1\n"
|
||||
"1 REF info_index\n"
|
||||
"1 NUM 3\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B2\n"
|
||||
"1 REF mode\n"
|
||||
"1 STR period_ms\n"
|
||||
"0 OPT ==\n"
|
||||
"0 JEZ 1\n"
|
||||
"B3\n"
|
||||
"1 REF __tick\n"
|
||||
"2 REF __calls\n"
|
||||
"2 REF i\n"
|
||||
"1 RUN __get__\n"
|
||||
"0 OPT >\n"
|
||||
"0 JEZ 1\n"
|
||||
"B4\n"
|
||||
"0 RUN todo\n"
|
||||
"B4\n"
|
||||
"1 REF __calls\n"
|
||||
"1 REF i\n"
|
||||
"2 REF __tick\n"
|
||||
"2 REF period_ms\n"
|
||||
"1 OPT +\n"
|
||||
"1 STR __calls\n"
|
||||
"0 RUN __set__\n"
|
||||
"B3\n"
|
||||
"0 NUM 0\n"
|
||||
"0 OUT info_index\n"
|
||||
"B0\n"
|
||||
"0 JMP -1\n"
|
||||
"B0\n"
|
||||
"0 DEL _l0\n"
|
||||
"B0\n");
|
||||
const uint8_t bytes[] = {
|
||||
0x08, 0x02, /* instruct array size */
|
||||
0x00, 0x82, 0x01, 0x00, 0x00, 0x04, 0x0d, 0x00, 0x00, 0x83, 0x11, 0x00,
|
||||
0x00, 0x04, 0x16, 0x00, 0x00, 0x85, 0x1b, 0x00, 0x00, 0x04, 0x1d, 0x00,
|
||||
0x20, 0x85, 0x1b, 0x00, 0x20, 0x01, 0x0d, 0x00, 0x10, 0x02, 0x28, 0x00,
|
||||
0x00, 0x02, 0x2e, 0x00, 0x00, 0x04, 0x33, 0x00, 0x00, 0x01, 0x37, 0x00,
|
||||
0x00, 0x01, 0x3b, 0x00, 0x00, 0x01, 0x3f, 0x00, 0x00, 0x04, 0x43, 0x00,
|
||||
0x00, 0x04, 0x4a, 0x00, 0x00, 0x04, 0x51, 0x00, 0x00, 0x82, 0x58, 0x00,
|
||||
0x00, 0x04, 0x65, 0x00, 0x00, 0x0d, 0x65, 0x00, 0x00, 0x07, 0x67, 0x00,
|
||||
0x11, 0x81, 0x0d, 0x00, 0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x69, 0x00,
|
||||
0x01, 0x07, 0x6c, 0x00, 0x02, 0x8e, 0x6c, 0x00, 0x11, 0x81, 0x1d, 0x00,
|
||||
0x11, 0x05, 0x1b, 0x00, 0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00,
|
||||
0x12, 0x81, 0x6e, 0x00, 0x12, 0x01, 0x65, 0x00, 0x02, 0x02, 0x76, 0x00,
|
||||
0x02, 0x04, 0x16, 0x00, 0x02, 0x85, 0x6c, 0x00, 0x02, 0x04, 0x1d, 0x00,
|
||||
0x01, 0x8b, 0x6c, 0x00, 0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x6c, 0x00,
|
||||
0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00, 0x12, 0x81, 0x16, 0x00,
|
||||
0x12, 0x03, 0x7e, 0x00, 0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00,
|
||||
0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00,
|
||||
0x03, 0x04, 0x85, 0x00, 0x03, 0x82, 0x85, 0x00, 0x03, 0x85, 0x1b, 0x00,
|
||||
0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x6c, 0x00, 0x12, 0x01, 0x16, 0x00,
|
||||
0x12, 0x03, 0x8a, 0x00, 0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00,
|
||||
0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00,
|
||||
0x03, 0x04, 0x8a, 0x00, 0x03, 0x85, 0x67, 0x00, 0x03, 0x04, 0x1d, 0x00,
|
||||
0x02, 0x8b, 0x6c, 0x00, 0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00,
|
||||
0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x6e, 0x00,
|
||||
0x13, 0x01, 0x65, 0x00, 0x03, 0x02, 0x76, 0x00, 0x03, 0x04, 0x8f, 0x00,
|
||||
0x03, 0x85, 0x67, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x6c, 0x00,
|
||||
0x11, 0x01, 0x1d, 0x00, 0x11, 0x05, 0x67, 0x00, 0x01, 0x08, 0x69, 0x00,
|
||||
0x01, 0x07, 0x6c, 0x00, 0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x8a, 0x00,
|
||||
0x02, 0x08, 0x69, 0x00, 0x02, 0x07, 0x6c, 0x00, 0x03, 0x82, 0x8a, 0x00,
|
||||
0x03, 0x07, 0x6c, 0x00, 0x14, 0x81, 0x6e, 0x00, 0x14, 0x01, 0x65, 0x00,
|
||||
0x04, 0x02, 0x76, 0x00, 0x04, 0x04, 0x85, 0x00, 0x04, 0x82, 0x85, 0x00,
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x02, 0x8b, 0x6c, 0x00,
|
||||
0x12, 0x01, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00, 0x02, 0x08, 0x69, 0x00,
|
||||
0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x6e, 0x00, 0x13, 0x01, 0x65, 0x00,
|
||||
0x03, 0x02, 0x76, 0x00, 0x03, 0x04, 0x85, 0x00, 0x03, 0x85, 0x99, 0x00,
|
||||
0x03, 0x04, 0x1d, 0x00, 0x01, 0x8b, 0x6c, 0x00, 0x11, 0x01, 0x1d, 0x00,
|
||||
0x11, 0x05, 0x99, 0x00, 0x01, 0x08, 0x69, 0x00, 0x01, 0x07, 0x6c, 0x00,
|
||||
0x12, 0x81, 0x16, 0x00, 0x12, 0x03, 0x8f, 0x00, 0x02, 0x08, 0x69, 0x00,
|
||||
0x02, 0x07, 0x6c, 0x00, 0x13, 0x81, 0x9b, 0x00, 0x23, 0x01, 0x6e, 0x00,
|
||||
0x23, 0x01, 0x65, 0x00, 0x13, 0x02, 0x76, 0x00, 0x03, 0x08, 0xa2, 0x00,
|
||||
0x03, 0x07, 0x6c, 0x00, 0x04, 0x82, 0x85, 0x00, 0x14, 0x81, 0x6e, 0x00,
|
||||
0x14, 0x01, 0x65, 0x00, 0x24, 0x01, 0x9b, 0x00, 0x24, 0x01, 0x8f, 0x00,
|
||||
0x14, 0x08, 0xa4, 0x00, 0x14, 0x03, 0x6e, 0x00, 0x04, 0x02, 0xa6, 0x00,
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x00, 0x86, 0xae, 0x00,
|
||||
0x00, 0x8c, 0x33, 0x00, /* instruct array */
|
||||
0xb1, 0x00, /* const pool size */
|
||||
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
|
||||
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74,
|
||||
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x72, 0x31, 0x00, 0x5f,
|
||||
0x72, 0x32, 0x00, 0x5f, 0x72, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61,
|
||||
0x31, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61, 0x32, 0x00, 0x5f, 0x6c, 0x30,
|
||||
0x2e, 0x61, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d, 0x00,
|
||||
0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x5f, 0x5f,
|
||||
0x67, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73,
|
||||
0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70,
|
||||
0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f,
|
||||
0x5f, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x2b, 0x00, 0x5f, 0x5f,
|
||||
0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
|
||||
};
|
||||
pikaVM_runByteCode(__pikaMain, (uint8_t*)bytes);
|
||||
}
|
||||
|
||||
void __Task_update_tick(PikaObj* self) {
|
||||
|
@ -863,21 +863,21 @@ TEST(VM, load_static_bytes) {
|
||||
0x03, 0x85, 0x1b, 0x00, 0x03, 0x04, 0x1d, 0x00, 0x00, 0x86, 0xae, 0x00,
|
||||
0x00, 0x8c, 0x33, 0x00, /* instruct array */
|
||||
0xb1, 0x00, /* const pool size */
|
||||
0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e, 0x00,
|
||||
0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f, 0x64,
|
||||
0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e, 0x64,
|
||||
0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74, 0x65,
|
||||
0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x72, 0x31, 0x00, 0x5f, 0x72,
|
||||
0x32, 0x00, 0x5f, 0x72, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61, 0x31,
|
||||
0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61, 0x32, 0x00, 0x5f, 0x6c, 0x30, 0x2e,
|
||||
0x61, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78,
|
||||
0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d, 0x00, 0x31,
|
||||
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x5f, 0x5f, 0x67,
|
||||
0x65, 0x74, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x00,
|
||||
0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70, 0x65,
|
||||
0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f, 0x5f,
|
||||
0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x2b, 0x00, 0x5f, 0x5f, 0x73,
|
||||
0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
|
||||
0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x2e, 0x6c, 0x65, 0x6e,
|
||||
0x00, 0x6c, 0x65, 0x6e, 0x00, 0x6e, 0x6f, 0x6e, 0x65, 0x00, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x00, 0x30, 0x00, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x69, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x00, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x00, 0x69, 0x74,
|
||||
0x65, 0x72, 0x00, 0x5f, 0x6c, 0x30, 0x00, 0x5f, 0x72, 0x31, 0x00, 0x5f,
|
||||
0x72, 0x32, 0x00, 0x5f, 0x72, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61,
|
||||
0x31, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x61, 0x32, 0x00, 0x5f, 0x6c, 0x30,
|
||||
0x2e, 0x61, 0x33, 0x00, 0x5f, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65,
|
||||
0x78, 0x74, 0x5f, 0x5f, 0x00, 0x69, 0x00, 0x32, 0x00, 0x3d, 0x3d, 0x00,
|
||||
0x31, 0x00, 0x5f, 0x5f, 0x63, 0x61, 0x6c, 0x6c, 0x73, 0x00, 0x5f, 0x5f,
|
||||
0x67, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x61, 0x6c, 0x77, 0x61, 0x79, 0x73,
|
||||
0x00, 0x74, 0x6f, 0x64, 0x6f, 0x00, 0x77, 0x68, 0x65, 0x6e, 0x00, 0x70,
|
||||
0x65, 0x72, 0x69, 0x6f, 0x64, 0x5f, 0x6d, 0x73, 0x00, 0x33, 0x00, 0x5f,
|
||||
0x5f, 0x74, 0x69, 0x63, 0x6b, 0x00, 0x3e, 0x00, 0x2b, 0x00, 0x5f, 0x5f,
|
||||
0x73, 0x65, 0x74, 0x5f, 0x5f, 0x00, 0x2d, 0x31, 0x00, /* const pool */
|
||||
};
|
||||
ByteCodeFrame bytecode_frame = {.const_pool =
|
||||
{
|
||||
@ -894,6 +894,7 @@ TEST(VM, load_static_bytes) {
|
||||
}};
|
||||
|
||||
byteCodeFrame_loadBytes(&bytecode_frame, (uint8_t*)bytes);
|
||||
byteCodeFrame_print(&bytecode_frame);
|
||||
|
||||
EXPECT_EQ(instructArray_getSize(&(bytecode_frame.instruct_array)), 520);
|
||||
EXPECT_EQ(bytecode_frame.const_pool.size, 177);
|
||||
|
Loading…
x
Reference in New Issue
Block a user