From 418ebf1e4ef07f5e23d26c69dde599a6990345b5 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Wed, 15 Sep 2021 19:36:48 +0200 Subject: [PATCH] Berry update and global resolidify --- lib/libesp32/Berry/default/be_driverlib.c | 18 +- lib/libesp32/Berry/default/be_energylib.c | 8 - lib/libesp32/Berry/default/be_flash_lib.c | 11 - .../Berry/default/be_i2c_axp192_lib.c | 2 +- lib/libesp32/Berry/default/be_i2c_driverlib.c | 688 ++-- lib/libesp32/Berry/default/be_i2s_audio_lib.c | 2 - lib/libesp32/Berry/default/be_light_lib.c | 17 - lib/libesp32/Berry/default/be_lvgl_cb.c | 64 +- .../Berry/default/be_lvgl_clock_icon_lib.c | 4 +- .../Berry/default/be_lvgl_color_lib.c | 16 - lib/libesp32/Berry/default/be_lvgl_ctypes.c | 19 - lib/libesp32/Berry/default/be_lvgl_font_lib.c | 15 - .../Berry/default/be_lvgl_signal_arcs_lib.c | 8 +- .../Berry/default/be_lvgl_signal_bars_lib.c | 4 +- .../default/be_lvgl_wifi_arcs_icon_lib.c | 2 +- .../Berry/default/be_lvgl_wifi_arcs_lib.c | 4 +- .../default/be_lvgl_wifi_bars_icon_lib.c | 2 +- .../Berry/default/be_lvgl_wifi_bars_lib.c | 4 +- lib/libesp32/Berry/default/be_md5_lib.c | 15 - .../Berry/default/be_path_tasmota_lib.c | 10 - lib/libesp32/Berry/default/be_tasmotalib.c | 3152 +++++++---------- lib/libesp32/Berry/default/be_timer_class.c | 68 +- lib/libesp32/Berry/default/be_webserver_lib.c | 26 - lib/libesp32/Berry/default/be_wirelib.c | 150 +- lib/libesp32/Berry/default/embedded/Wire.be | 25 + .../Berry/default/embedded}/i2c_driver.be | 0 lib/libesp32/Berry/generate/be_const_strtab.h | 1 - .../Berry/generate/be_const_strtab_def.h | 5 +- .../Berry/generate/be_fixed_introspect.h | 5 +- .../Berry/generate/be_fixed_m_builtin.h | 86 +- lib/libesp32/Berry/src/be_baselib.c | 56 + lib/libesp32/Berry/src/be_introspectlib.c | 51 - lib/libesp32/Berry/src/be_libs.c | 2 + .../Berry/tools/coc/block_builder.cpp | 17 +- lib/libesp32/Berry/tools/coc/block_builder.h | 1 + lib/libesp32/Berry/tools/coc/coc_parser.cpp | 1 + lib/libesp32/Berry/tools/coc/object_block.h | 1 + .../Berry/tools/grammar/berry.bytecode | 2 +- lib/libesp32/Berry/tools/grammar/berry.ebnf | 2 +- tasmota/berry/modules/partition.bec | Bin 15648 -> 15584 bytes 40 files changed, 1883 insertions(+), 2681 deletions(-) create mode 100644 lib/libesp32/Berry/default/embedded/Wire.be rename {tasmota/berry/drivers => lib/libesp32/Berry/default/embedded}/i2c_driver.be (100%) diff --git a/lib/libesp32/Berry/default/be_driverlib.c b/lib/libesp32/Berry/default/be_driverlib.c index 72874c08b..dbef17a94 100644 --- a/lib/libesp32/Berry/default/be_driverlib.c +++ b/lib/libesp32/Berry/default/be_driverlib.c @@ -23,7 +23,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[ 1]) { /* code */ - 0x80000000, // 0000 RET 0 R0 + 0x80000000, // 0000 RET 0 }) ) ); @@ -44,12 +44,12 @@ be_local_closure(get_tasmota, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 1]) { /* constants */ - be_nested_string("tasmota", 424643812, 7), /* R256 - K0 */ + /* K0 */ be_nested_string("tasmota", 424643812, 7), }), (be_nested_const_str("get_tasmota", 334356779, 11)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[ 2]) { /* code */ - 0xB8060000, // 0000 GETNGBL R1 R256 + 0xB8060000, // 0000 GETNGBL R1 K0 0x80040200, // 0001 RET 1 R1 }) ) @@ -98,19 +98,19 @@ be_local_closure(add_cmd, /* name */ }), 1, /* has constants */ ( &(const bvalue[ 2]) { /* constants */ - be_nested_string("tasmota", 424643812, 7), /* R256 - K0 */ - be_nested_string("add_cmd", -933336417, 7), /* R257 - K1 */ + /* K0 */ be_nested_string("tasmota", 424643812, 7), + /* K1 */ be_nested_string("add_cmd", -933336417, 7), }), (be_nested_const_str("add_cmd", -933336417, 7)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[ 7]) { /* code */ - 0xB80E0000, // 0000 GETNGBL R3 R256 - 0x8C0C0701, // 0001 GETMET R3 R3 R257 + 0xB80E0000, // 0000 GETNGBL R3 K0 + 0x8C0C0701, // 0001 GETMET R3 R3 K1 0x5C140200, // 0002 MOVE R5 R1 0x84180000, // 0003 CLOSURE R6 P0 0x7C0C0600, // 0004 CALL R3 3 - 0xA0000000, // 0005 CLOSE 0 - 0x80000000, // 0006 RET 0 R0 + 0xA0000000, // 0005 CLOSE R0 + 0x80000000, // 0006 RET 0 }) ) ); diff --git a/lib/libesp32/Berry/default/be_energylib.c b/lib/libesp32/Berry/default/be_energylib.c index eb267f5db..1cbb0822e 100644 --- a/lib/libesp32/Berry/default/be_energylib.c +++ b/lib/libesp32/Berry/default/be_energylib.c @@ -11,19 +11,11 @@ extern int b_nrg_read(bvm *vm); -#if !BE_USE_PRECOMPILED_OBJECT -be_native_module_attr_table(energy) { - be_native_module_function("read", b_nrg_read), -}; - -be_define_native_module(energy, NULL); -#else /* @const_object_info_begin module energy (scope: global) { read, func(b_nrg_read) } @const_object_info_end */ #include "../generate/be_fixed_energy.h" -#endif #endif // USE_ENERGY_SENSOR \ No newline at end of file diff --git a/lib/libesp32/Berry/default/be_flash_lib.c b/lib/libesp32/Berry/default/be_flash_lib.c index b05b23637..539805d5d 100644 --- a/lib/libesp32/Berry/default/be_flash_lib.c +++ b/lib/libesp32/Berry/default/be_flash_lib.c @@ -11,16 +11,6 @@ extern int p_flash_read(bvm *vm); extern int p_flash_write(bvm *vm); extern int p_flash_erase(bvm *vm); -#if !BE_USE_PRECOMPILED_OBJECT -be_native_module_attr_table(flash) { - be_native_module_function("read", p_flash_read), - be_native_module_function("write", p_flash_write), - be_native_module_function("erase", p_flash_erase), - -}; - -be_define_native_module(flash, NULL); -#else /* @const_object_info_begin module flash (scope: global) { read, func(p_flash_read) @@ -29,4 +19,3 @@ module flash (scope: global) { } @const_object_info_end */ #include "../generate/be_fixed_flash.h" -#endif diff --git a/lib/libesp32/Berry/default/be_i2c_axp192_lib.c b/lib/libesp32/Berry/default/be_i2c_axp192_lib.c index b81c47775..5eba55476 100644 --- a/lib/libesp32/Berry/default/be_i2c_axp192_lib.c +++ b/lib/libesp32/Berry/default/be_i2c_axp192_lib.c @@ -476,7 +476,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[ 9]) { /* code */ - 0x60040014, // 0000 GETGBL R1 G20 + 0x60040003, // 0000 GETGBL R1 G3 0x5C080000, // 0001 MOVE R2 R0 0xB80E0000, // 0002 GETNGBL R3 K0 0x7C040400, // 0003 CALL R1 2 diff --git a/lib/libesp32/Berry/default/be_i2c_driverlib.c b/lib/libesp32/Berry/default/be_i2c_driverlib.c index 88d9ded34..2ac5627d9 100644 --- a/lib/libesp32/Berry/default/be_i2c_driverlib.c +++ b/lib/libesp32/Berry/default/be_i2c_driverlib.c @@ -11,333 +11,6 @@ extern bclass* be_class_Driver; // Parent class -/******************************************************************** -** Solidified function: init -********************************************************************/ -be_local_closure(init, /* name */ - be_nested_proto( - 10, /* nstack */ - 4, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[10]) { /* constants */ - be_nested_string("get_tasmota", 334356779, 11), - be_nested_string("i2c_enabled", 218388101, 11), - be_nested_string("addr", 1087856498, 4), - be_nested_string("wire", -212213352, 4), - be_nested_string("wire_scan", -1623691416, 9), - be_nested_string("function", -1630125495, 8), - be_nested_string("name", -1925595674, 4), - be_nested_string("I2C:", 813483371, 4), - be_nested_string("detected on bus", 1432002650, 15), - be_nested_string("bus", 1607822841, 3), - }), - (be_nested_const_str("init", 380752755, 4)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[44]) { /* code */ - 0x8C100100, // 0000 GETMET R4 R0 R256 - 0x7C100200, // 0001 CALL R4 1 - 0x4C140000, // 0002 LDNIL 5 - 0x20140605, // 0003 NE R5 R3 R5 - 0x78160004, // 0004 JMPF R5 #000A - 0x8C140901, // 0005 GETMET R5 R4 R257 - 0x5C1C0600, // 0006 MOVE R7 R3 - 0x7C140400, // 0007 CALL R5 2 - 0x74160000, // 0008 JMPT R5 #000A - 0x80000A00, // 0009 RET 0 R5 - 0x90020402, // 000A SETMBR R0 R258 R2 - 0x8C140904, // 000B GETMET R5 R4 R260 - 0x881C0102, // 000C GETMBR R7 R0 R258 - 0x7C140400, // 000D CALL R5 2 - 0x90020605, // 000E SETMBR R0 R259 R5 - 0x88140103, // 000F GETMBR R5 R0 R259 - 0x78160019, // 0010 JMPF R5 #002B - 0x60140015, // 0011 GETGBL R5 G21 - 0x5C180200, // 0012 MOVE R6 R1 - 0x7C140200, // 0013 CALL R5 1 - 0x1C140B05, // 0014 EQ R5 R5 R261 - 0x78160004, // 0015 JMPF R5 #001B - 0x5C140200, // 0016 MOVE R5 R1 - 0x5C180000, // 0017 MOVE R6 R0 - 0x7C140200, // 0018 CALL R5 1 - 0x90020C05, // 0019 SETMBR R0 R262 R5 - 0x70020000, // 001A JMP #001C - 0x90020C01, // 001B SETMBR R0 R262 R1 - 0x88140106, // 001C GETMBR R5 R0 R262 - 0x4C180000, // 001D LDNIL 6 - 0x1C140A06, // 001E EQ R5 R5 R6 - 0x78160001, // 001F JMPF R5 #0022 - 0x4C140000, // 0020 LDNIL 5 - 0x90020605, // 0021 SETMBR R0 R259 R5 - 0x88140103, // 0022 GETMBR R5 R0 R259 - 0x78160006, // 0023 JMPF R5 #002B - 0x6014000F, // 0024 GETGBL R5 G15 - 0x58180007, // 0025 LDCONST R6 K7 - 0x881C0106, // 0026 GETMBR R7 R0 R262 - 0x58200008, // 0027 LDCONST R8 K8 - 0x88240103, // 0028 GETMBR R9 R0 R259 - 0x88241309, // 0029 GETMBR R9 R9 R265 - 0x7C140800, // 002A CALL R5 4 - 0x80000000, // 002B RET 0 R0 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: write8 -********************************************************************/ -be_local_closure(write8, /* name */ - be_nested_proto( - 9, /* nstack */ - 3, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("write", -1104765092, 5), - be_nested_string("addr", 1087856498, 4), - be_const_int(1), - }), - (be_nested_const_str("write8", -1160975764, 6)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[ 8]) { /* code */ - 0x880C0100, // 0000 GETMBR R3 R0 R256 - 0x8C0C0701, // 0001 GETMET R3 R3 R257 - 0x88140102, // 0002 GETMBR R5 R0 R258 - 0x5C180200, // 0003 MOVE R6 R1 - 0x5C1C0400, // 0004 MOVE R7 R2 - 0x58200003, // 0005 LDCONST R8 K3 - 0x7C0C0A00, // 0006 CALL R3 5 - 0x80040600, // 0007 RET 1 R3 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: write_bit -********************************************************************/ -be_local_closure(write_bit, /* name */ - be_nested_proto( - 11, /* nstack */ - 4, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - be_const_int(0), - be_const_int(1), - be_nested_string("write8", -1160975764, 6), - be_nested_string("read8", -1492179129, 5), - }), - (be_nested_const_str("write_bit", -1633976860, 9)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[26]) { /* code */ - 0x14100500, // 0000 LT R4 R2 R256 - 0x74120002, // 0001 JMPT R4 #0005 - 0x54120006, // 0002 LDINT R4 7 - 0x24100404, // 0003 GT R4 R2 R4 - 0x78120000, // 0004 JMPF R4 #0006 - 0x80000800, // 0005 RET 0 R4 - 0x38120202, // 0006 SHL R4 R257 R2 - 0x780E0007, // 0007 JMPF R3 #0010 - 0x8C140102, // 0008 GETMET R5 R0 R258 - 0x5C1C0200, // 0009 MOVE R7 R1 - 0x8C200103, // 000A GETMET R8 R0 R259 - 0x5C280200, // 000B MOVE R10 R1 - 0x7C200400, // 000C CALL R8 2 - 0x30201004, // 000D OR R8 R8 R4 - 0x7C140600, // 000E CALL R5 3 - 0x70020008, // 000F JMP #0019 - 0x8C140102, // 0010 GETMET R5 R0 R258 - 0x5C1C0200, // 0011 MOVE R7 R1 - 0x8C200103, // 0012 GETMET R8 R0 R259 - 0x5C280200, // 0013 MOVE R10 R1 - 0x7C200400, // 0014 CALL R8 2 - 0x542600FE, // 0015 LDINT R9 255 - 0x04241204, // 0016 SUB R9 R9 R4 - 0x2C201009, // 0017 AND R8 R8 R9 - 0x7C140600, // 0018 CALL R5 3 - 0x80000000, // 0019 RET 0 R0 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: read8 -********************************************************************/ -be_local_closure(read8, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("read", -824204347, 4), - be_nested_string("addr", 1087856498, 4), - be_const_int(1), - }), - (be_nested_const_str("read8", -1492179129, 5)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[ 7]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x80040400, // 0006 RET 1 R2 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: read12 -********************************************************************/ -be_local_closure(read12, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 6]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("read_bytes", -718234123, 10), - be_nested_string("addr", 1087856498, 4), - be_const_int(2), - be_const_int(0), - be_const_int(1), - }), - (be_nested_const_str("read12", -3890326, 6)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[12]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x54120003, // 0007 LDINT R4 4 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0x000C0604, // 000A ADD R3 R3 R4 - 0x80040600, // 000B RET 1 R3 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: read13 -********************************************************************/ -be_local_closure(read13, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 6]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("read_bytes", -718234123, 10), - be_nested_string("addr", 1087856498, 4), - be_const_int(2), - be_const_int(0), - be_const_int(1), - }), - (be_nested_const_str("read13", 12887293, 6)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[12]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x54120004, // 0007 LDINT R4 5 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0x000C0604, // 000A ADD R3 R3 R4 - 0x80040600, // 000B RET 1 R3 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: read24 -********************************************************************/ -be_local_closure(read24, /* name */ - be_nested_proto( - 7, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 7]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("read_bytes", -718234123, 10), - be_nested_string("addr", 1087856498, 4), - be_const_int(3), - be_const_int(0), - be_const_int(1), - be_const_int(2), - }), - (be_nested_const_str("read24", 1808533811, 6)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[16]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x5412000F, // 0007 LDINT R4 16 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0x54160007, // 000A LDINT R5 8 - 0x38100805, // 000B SHL R4 R4 R5 - 0x000C0604, // 000C ADD R3 R3 R4 - 0x94100506, // 000D GETIDX R4 R2 R262 - 0x000C0604, // 000E ADD R3 R3 R4 - 0x80040600, // 000F RET 1 R3 - }) - ) -); -/*******************************************************************/ - /******************************************************************** ** Solidified function: read32 ********************************************************************/ @@ -352,35 +25,35 @@ be_local_closure(read32, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 7]) { /* constants */ - be_nested_string("wire", -212213352, 4), - be_nested_string("read_bytes", -718234123, 10), - be_nested_string("addr", 1087856498, 4), - be_const_int(0), - be_const_int(1), - be_const_int(2), - be_const_int(3), + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("read_bytes", -718234123, 10), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(0), + /* K4 */ be_const_int(1), + /* K5 */ be_const_int(2), + /* K6 */ be_const_int(3), }), (be_nested_const_str("read32", 1741276240, 6)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[20]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 0x5C140200, // 0003 MOVE R5 R1 0x541A0003, // 0004 LDINT R6 4 0x7C080800, // 0005 CALL R2 4 - 0x940C0503, // 0006 GETIDX R3 R2 R259 + 0x940C0503, // 0006 GETIDX R3 R2 K3 0x54120017, // 0007 LDINT R4 24 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100504, // 0009 GETIDX R4 R2 R260 + 0x94100504, // 0009 GETIDX R4 R2 K4 0x5416000F, // 000A LDINT R5 16 0x38100805, // 000B SHL R4 R4 R5 0x000C0604, // 000C ADD R3 R3 R4 - 0x94100505, // 000D GETIDX R4 R2 R261 + 0x94100505, // 000D GETIDX R4 R2 K5 0x54160007, // 000E LDINT R5 8 0x38100805, // 000F SHL R4 R4 R5 0x000C0604, // 0010 ADD R3 R3 R4 - 0x94100506, // 0011 GETIDX R4 R2 R262 + 0x94100506, // 0011 GETIDX R4 R2 K6 0x000C0604, // 0012 ADD R3 R3 R4 0x80040600, // 0013 RET 1 R3 }) @@ -389,6 +62,339 @@ be_local_closure(read32, /* name */ /*******************************************************************/ +/******************************************************************** +** Solidified function: write8 +********************************************************************/ +be_local_closure(write8, /* name */ + be_nested_proto( + 9, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("write", -1104765092, 5), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(1), + }), + (be_nested_const_str("write8", -1160975764, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[ 8]) { /* code */ + 0x880C0100, // 0000 GETMBR R3 R0 K0 + 0x8C0C0701, // 0001 GETMET R3 R3 K1 + 0x88140102, // 0002 GETMBR R5 R0 K2 + 0x5C180200, // 0003 MOVE R6 R1 + 0x5C1C0400, // 0004 MOVE R7 R2 + 0x58200003, // 0005 LDCONST R8 K3 + 0x7C0C0A00, // 0006 CALL R3 5 + 0x80040600, // 0007 RET 1 R3 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: read12 +********************************************************************/ +be_local_closure(read12, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("read_bytes", -718234123, 10), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(2), + /* K4 */ be_const_int(0), + /* K5 */ be_const_int(1), + }), + (be_nested_const_str("read12", -3890326, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[12]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 K4 + 0x54120003, // 0007 LDINT R4 4 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 K5 + 0x000C0604, // 000A ADD R3 R3 R4 + 0x80040600, // 000B RET 1 R3 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: write_bit +********************************************************************/ +be_local_closure(write_bit, /* name */ + be_nested_proto( + 11, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_const_int(1), + /* K2 */ be_nested_string("write8", -1160975764, 6), + /* K3 */ be_nested_string("read8", -1492179129, 5), + }), + (be_nested_const_str("write_bit", -1633976860, 9)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[26]) { /* code */ + 0x14100500, // 0000 LT R4 R2 K0 + 0x74120002, // 0001 JMPT R4 #0005 + 0x54120006, // 0002 LDINT R4 7 + 0x24100404, // 0003 GT R4 R2 R4 + 0x78120000, // 0004 JMPF R4 #0006 + 0x80000800, // 0005 RET 0 + 0x38120202, // 0006 SHL R4 K1 R2 + 0x780E0007, // 0007 JMPF R3 #0010 + 0x8C140102, // 0008 GETMET R5 R0 K2 + 0x5C1C0200, // 0009 MOVE R7 R1 + 0x8C200103, // 000A GETMET R8 R0 K3 + 0x5C280200, // 000B MOVE R10 R1 + 0x7C200400, // 000C CALL R8 2 + 0x30201004, // 000D OR R8 R8 R4 + 0x7C140600, // 000E CALL R5 3 + 0x70020008, // 000F JMP #0019 + 0x8C140102, // 0010 GETMET R5 R0 K2 + 0x5C1C0200, // 0011 MOVE R7 R1 + 0x8C200103, // 0012 GETMET R8 R0 K3 + 0x5C280200, // 0013 MOVE R10 R1 + 0x7C200400, // 0014 CALL R8 2 + 0x542600FE, // 0015 LDINT R9 255 + 0x04241204, // 0016 SUB R9 R9 R4 + 0x2C201009, // 0017 AND R8 R8 R9 + 0x7C140600, // 0018 CALL R5 3 + 0x80000000, // 0019 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: read24 +********************************************************************/ +be_local_closure(read24, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("read_bytes", -718234123, 10), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(3), + /* K4 */ be_const_int(0), + /* K5 */ be_const_int(1), + /* K6 */ be_const_int(2), + }), + (be_nested_const_str("read24", 1808533811, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[16]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 K4 + 0x5412000F, // 0007 LDINT R4 16 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 K5 + 0x54160007, // 000A LDINT R5 8 + 0x38100805, // 000B SHL R4 R4 R5 + 0x000C0604, // 000C ADD R3 R3 R4 + 0x94100506, // 000D GETIDX R4 R2 K6 + 0x000C0604, // 000E ADD R3 R3 R4 + 0x80040600, // 000F RET 1 R3 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: read8 +********************************************************************/ +be_local_closure(read8, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("read", -824204347, 4), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(1), + }), + (be_nested_const_str("read8", -1492179129, 5)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[ 7]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x80040400, // 0006 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: init +********************************************************************/ +be_local_closure(init, /* name */ + be_nested_proto( + 10, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[10]) { /* constants */ + /* K0 */ be_nested_string("get_tasmota", 334356779, 11), + /* K1 */ be_nested_string("i2c_enabled", 218388101, 11), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_nested_string("wire", -212213352, 4), + /* K4 */ be_nested_string("wire_scan", -1623691416, 9), + /* K5 */ be_nested_string("function", -1630125495, 8), + /* K6 */ be_nested_string("name", -1925595674, 4), + /* K7 */ be_nested_string("I2C:", 813483371, 4), + /* K8 */ be_nested_string("detected on bus", 1432002650, 15), + /* K9 */ be_nested_string("bus", 1607822841, 3), + }), + (be_nested_const_str("init", 380752755, 4)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[44]) { /* code */ + 0x8C100100, // 0000 GETMET R4 R0 K0 + 0x7C100200, // 0001 CALL R4 1 + 0x4C140000, // 0002 LDNIL R5 + 0x20140605, // 0003 NE R5 R3 R5 + 0x78160004, // 0004 JMPF R5 #000A + 0x8C140901, // 0005 GETMET R5 R4 K1 + 0x5C1C0600, // 0006 MOVE R7 R3 + 0x7C140400, // 0007 CALL R5 2 + 0x74160000, // 0008 JMPT R5 #000A + 0x80000A00, // 0009 RET 0 + 0x90020402, // 000A SETMBR R0 K2 R2 + 0x8C140904, // 000B GETMET R5 R4 K4 + 0x881C0102, // 000C GETMBR R7 R0 K2 + 0x7C140400, // 000D CALL R5 2 + 0x90020605, // 000E SETMBR R0 K3 R5 + 0x88140103, // 000F GETMBR R5 R0 K3 + 0x78160019, // 0010 JMPF R5 #002B + 0x60140004, // 0011 GETGBL R5 G4 + 0x5C180200, // 0012 MOVE R6 R1 + 0x7C140200, // 0013 CALL R5 1 + 0x1C140B05, // 0014 EQ R5 R5 K5 + 0x78160004, // 0015 JMPF R5 #001B + 0x5C140200, // 0016 MOVE R5 R1 + 0x5C180000, // 0017 MOVE R6 R0 + 0x7C140200, // 0018 CALL R5 1 + 0x90020C05, // 0019 SETMBR R0 K6 R5 + 0x70020000, // 001A JMP #001C + 0x90020C01, // 001B SETMBR R0 K6 R1 + 0x88140106, // 001C GETMBR R5 R0 K6 + 0x4C180000, // 001D LDNIL R6 + 0x1C140A06, // 001E EQ R5 R5 R6 + 0x78160001, // 001F JMPF R5 #0022 + 0x4C140000, // 0020 LDNIL R5 + 0x90020605, // 0021 SETMBR R0 K3 R5 + 0x88140103, // 0022 GETMBR R5 R0 K3 + 0x78160006, // 0023 JMPF R5 #002B + 0x60140001, // 0024 GETGBL R5 G1 + 0x58180007, // 0025 LDCONST R6 K7 + 0x881C0106, // 0026 GETMBR R7 R0 K6 + 0x58200008, // 0027 LDCONST R8 K8 + 0x88240103, // 0028 GETMBR R9 R0 K3 + 0x88241309, // 0029 GETMBR R9 R9 K9 + 0x7C140800, // 002A CALL R5 4 + 0x80000000, // 002B RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: read13 +********************************************************************/ +be_local_closure(read13, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + /* K0 */ be_nested_string("wire", -212213352, 4), + /* K1 */ be_nested_string("read_bytes", -718234123, 10), + /* K2 */ be_nested_string("addr", 1087856498, 4), + /* K3 */ be_const_int(2), + /* K4 */ be_const_int(0), + /* K5 */ be_const_int(1), + }), + (be_nested_const_str("read13", 12887293, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[12]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x88100102, // 0002 GETMBR R4 R0 K2 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 K4 + 0x54120004, // 0007 LDINT R4 5 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 K5 + 0x000C0604, // 000A ADD R3 R3 R4 + 0x80040600, // 000B RET 1 R3 + }) + ) +); +/*******************************************************************/ + #include "../generate/be_fixed_be_class_I2C_Driver.h" void be_load_driver_i2c_lib(bvm *vm) { diff --git a/lib/libesp32/Berry/default/be_i2s_audio_lib.c b/lib/libesp32/Berry/default/be_i2s_audio_lib.c index 888cb2d42..ef8720b23 100644 --- a/lib/libesp32/Berry/default/be_i2s_audio_lib.c +++ b/lib/libesp32/Berry/default/be_i2s_audio_lib.c @@ -32,7 +32,6 @@ extern int i2s_file_source_fs_deinit(bvm *vm); #endif // USE_UFILESYS -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_class_audio_output.h" #include "../generate/be_fixed_be_class_audio_output_i2s.h" #include "../generate/be_fixed_be_class_audio_generator.h" @@ -40,7 +39,6 @@ extern int i2s_file_source_fs_deinit(bvm *vm); #include "../generate/be_fixed_be_class_audio_generator_mp3.h" #include "../generate/be_fixed_be_class_audio_file_source.h" #include "../generate/be_fixed_be_class_audio_file_source_fs.h" -#endif void be_load_driver_audio_lib(bvm *vm) { be_pushntvclass(vm, &be_class_audio_output); diff --git a/lib/libesp32/Berry/default/be_light_lib.c b/lib/libesp32/Berry/default/be_light_lib.c index a536fd6df..6d020eca8 100644 --- a/lib/libesp32/Berry/default/be_light_lib.c +++ b/lib/libesp32/Berry/default/be_light_lib.c @@ -13,22 +13,6 @@ extern int l_gamma8(bvm *vm); extern int l_gamma10(bvm *vm); extern int l_rev_gamma10(bvm *vm); -#if !BE_USE_PRECOMPILED_OBJECT - -be_native_module_attr_table(light) { - - be_native_module_function("get", l_getlight), - be_native_module_function("set", l_setlight), - - be_native_module_function("gamma8", l_gamma8), - be_native_module_function("gamma10", l_gamma10), - be_native_module_function("reverse_gamma10", l_rev_gamma10), - -}; - -be_define_native_module(light, NULL); - -#else /* @const_object_info_begin module light (scope: global) { get, func(l_getlight) @@ -40,6 +24,5 @@ module light (scope: global) { } @const_object_info_end */ #include "../generate/be_fixed_light.h" -#endif #endif // USE_LIGHT \ No newline at end of file diff --git a/lib/libesp32/Berry/default/be_lvgl_cb.c b/lib/libesp32/Berry/default/be_lvgl_cb.c index 01c5e8d76..f226b2679 100644 --- a/lib/libesp32/Berry/default/be_lvgl_cb.c +++ b/lib/libesp32/Berry/default/be_lvgl_cb.c @@ -102,94 +102,32 @@ class be_lvgl_cb (scope: global, name: lv_cb) { // 'lv_gauge_format_cb' // -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_lv_group_focus_cb.h" #include "../generate/be_fixed_be_lv_event_cb.h" #include "../generate/be_fixed_be_lv_signal_cb.h" #include "../generate/be_fixed_be_lv_design_cb.h" #include "../generate/be_fixed_be_lv_gauge_format_cb.h" -#endif void be_load_lvgl_cb_all_lib(bvm *vm) { -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members_lv_group_focus_cb[] = { - { "()", lv_group_focus_cb_call }, - { NULL, NULL } - }; - be_regclass(vm, "lv_group_focus_cb", members); - be_getglobal(vm, "lv_group_focus_cb"); - be_getglobal(vm, "lv_cb"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else be_pushntvclass(vm, &be_lv_group_focus_cb); be_setglobal(vm, "lv_group_focus_cb"); be_pop(vm, 1); -#endif -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members_lv_event_cb[] = { - { "()", lv_event_cb_call }, - { NULL, NULL } - }; - be_regclass(vm, "lv_event_cb", members); - be_getglobal(vm, "lv_event_cb"); - be_getglobal(vm, "lv_cb"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else be_pushntvclass(vm, &be_lv_event_cb); be_setglobal(vm, "lv_event_cb"); be_pop(vm, 1); -#endif - -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members_lv_signal_cb[] = { - { "()", lv_signal_cb_call }, - { NULL, NULL } - }; - be_regclass(vm, "lv_signal_cb", members); - be_getglobal(vm, "lv_signal_cb"); - be_getglobal(vm, "lv_cb"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else + be_pushntvclass(vm, &be_lv_signal_cb); be_setglobal(vm, "lv_signal_cb"); be_pop(vm, 1); -#endif -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members_lv_design_cb[] = { - { "()", lv_design_cb_call }, - { NULL, NULL } - }; - be_regclass(vm, "lv_design_cb", members); - be_getglobal(vm, "lv_design_cb"); - be_getglobal(vm, "lv_cb"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else be_pushntvclass(vm, &be_lv_design_cb); be_setglobal(vm, "lv_design_cb"); be_pop(vm, 1); -#endif -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members_lv_gauge_format_cb[] = { - { "()", lv_gauge_format_cb_call }, - { NULL, NULL } - }; - be_regclass(vm, "lv_gauge_format_cb", members); - be_getglobal(vm, "lv_gauge_format_cb"); - be_getglobal(vm, "lv_cb"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else be_pushntvclass(vm, &be_lv_gauge_format_cb); be_setglobal(vm, "lv_gauge_format_cb"); be_pop(vm, 1); -#endif } /* @const_object_info_begin diff --git a/lib/libesp32/Berry/default/be_lvgl_clock_icon_lib.c b/lib/libesp32/Berry/default/be_lvgl_clock_icon_lib.c index 888456745..1969e6172 100644 --- a/lib/libesp32/Berry/default/be_lvgl_clock_icon_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_clock_icon_lib.c @@ -157,7 +157,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[76]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 @@ -260,7 +260,7 @@ be_local_closure(del, /* name */ (be_nested_const_str("del", -816214454, 3)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[10]) { /* code */ - 0x60040014, // 0000 GETGBL R1 G20 + 0x60040003, // 0000 GETGBL R1 G3 0x5C080000, // 0001 MOVE R2 R0 0x7C040200, // 0002 CALL R1 1 0x8C040300, // 0003 GETMET R1 R1 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_color_lib.c b/lib/libesp32/Berry/default/be_lvgl_color_lib.c index 27eabbbd1..ebc53821d 100644 --- a/lib/libesp32/Berry/default/be_lvgl_color_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_color_lib.c @@ -12,28 +12,12 @@ extern int lco_tostring(bvm *vm); // generic function extern int lco_toint(bvm *vm); // generic function -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_class_lv_color.h" -#endif void be_load_lvgl_color_lib(bvm *vm) { -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members[] = { - { ".p", NULL }, // keeping track of styles to avoid GC - { "init", lco_init }, - { "tostring", lco_tostring }, - { "toint", lco_toint }, - - // { NULL, (bntvfunc) BE_CLOSURE }, /* mark section for berry closures */ - - { NULL, NULL } - }; - be_regclass(vm, "lv_color", members); -#else be_pushntvclass(vm, &be_class_lv_color); be_setglobal(vm, "lv_color"); be_pop(vm, 1); -#endif } /* @const_object_info_begin diff --git a/lib/libesp32/Berry/default/be_lvgl_ctypes.c b/lib/libesp32/Berry/default/be_lvgl_ctypes.c index 1c5e52b46..1a4c3b046 100644 --- a/lib/libesp32/Berry/default/be_lvgl_ctypes.c +++ b/lib/libesp32/Berry/default/be_lvgl_ctypes.c @@ -311,31 +311,12 @@ int be_ctypes_setmember(bvm *vm) { BE_EXPORT_VARIABLE extern const bclass be_class_bytes; -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_class_lv_ctypes.h" -#endif void be_load_lvgl_ctypes_lib(bvm *vm) { -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members[] = { - { ".def", NULL }, // pointer to definition - { "init", be_ctypes_init }, - { "copy", be_ctypes_copy }, - { "member", be_ctypes_member }, - { "setmember", be_ctypes_setmember }, - { NULL, NULL } - }; - be_regclass(vm, "ctypes_bytes", members); - - be_getglobal(vm, "ctypes_bytes"); - be_getglobal(vm, "bytes"); - be_setsuper(vm, -2); - be_pop(vm, 2); -#else be_pushntvclass(vm, &be_class_lv_ctypes); be_setglobal(vm, "ctypes_bytes"); be_pop(vm, 1); -#endif } /* @const_object_info_begin diff --git a/lib/libesp32/Berry/default/be_lvgl_font_lib.c b/lib/libesp32/Berry/default/be_lvgl_font_lib.c index 0bf03c3f9..115f5c2c6 100644 --- a/lib/libesp32/Berry/default/be_lvgl_font_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_font_lib.c @@ -10,27 +10,12 @@ extern int lvx_init(bvm *vm); // generic function extern int lvx_tostring(bvm *vm); // generic function -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_class_lv_font.h" -#endif void be_load_lvgl_font_lib(bvm *vm) { -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members[] = { - { ".p", NULL }, // keeping track of styles to avoid GC - { "init", lvx_init }, - { "tostring", lvx_tostring }, - - // { NULL, (bntvfunc) BE_CLOSURE }, /* mark section for berry closures */ - - { NULL, NULL } - }; - be_regclass(vm, "lv_font", members); -#else be_pushntvclass(vm, &be_class_lv_font); be_setglobal(vm, "lv_font"); be_pop(vm, 1); -#endif } /* @const_object_info_begin diff --git a/lib/libesp32/Berry/default/be_lvgl_signal_arcs_lib.c b/lib/libesp32/Berry/default/be_lvgl_signal_arcs_lib.c index e33b5c205..0ff6d9951 100644 --- a/lib/libesp32/Berry/default/be_lvgl_signal_arcs_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_signal_arcs_lib.c @@ -157,14 +157,14 @@ be_local_closure(my_design_cb, /* name */ 0x04380A08, // 0046 SUB R14 R5 R8 0x0C3C0D03, // 0047 DIV R15 R6 K3 0x043C1E09, // 0048 SUB R15 R15 R9 - 0x60400007, // 0049 GETGBL R16 G7 + 0x60400009, // 0049 GETGBL R16 G9 0x54460059, // 004A LDINT R17 90 0x8C480719, // 004B GETMET R18 R3 K25 0x8C50071A, // 004C GETMET R20 R3 K26 - 0x60580011, // 004D GETGBL R22 G17 + 0x6058000A, // 004D GETGBL R22 G10 0x5C5C1E00, // 004E MOVE R23 R15 0x7C580200, // 004F CALL R22 1 - 0x605C0011, // 0050 GETGBL R23 G17 + 0x605C000A, // 0050 GETGBL R23 G10 0x5C601C00, // 0051 MOVE R24 R14 0x7C5C0200, // 0052 CALL R23 1 0x0C582C17, // 0053 DIV R22 R22 R23 @@ -327,7 +327,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[28]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c index 4c3e09bda..56f88987e 100644 --- a/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c @@ -149,7 +149,7 @@ be_local_closure(my_design_cb, /* name */ 0xB83E0800, // 003F GETNGBL R15 K4 0x883C1F16, // 0040 GETMBR R15 R15 K22 0x7C300600, // 0041 CALL R12 3 - 0x60340000, // 0042 GETGBL R13 G0 + 0x60340010, // 0042 GETGBL R13 G16 0x403A3102, // 0043 CONNECT R14 K24 K2 0x7C340200, // 0044 CALL R13 1 0xA802002C, // 0045 EXBLK 0 #0073 @@ -268,7 +268,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[28]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_icon_lib.c b/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_icon_lib.c index c46b09034..17538a88e 100644 --- a/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_icon_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_icon_lib.c @@ -41,7 +41,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[52]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_lib.c b/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_lib.c index 300b019d1..b820e2b1f 100644 --- a/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_wifi_arcs_lib.c @@ -84,7 +84,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[15]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 @@ -126,7 +126,7 @@ be_local_closure(del, /* name */ (be_nested_const_str("del", -816214454, 3)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[10]) { /* code */ - 0x60040014, // 0000 GETGBL R1 G20 + 0x60040003, // 0000 GETGBL R1 G3 0x5C080000, // 0001 MOVE R2 R0 0x7C040200, // 0002 CALL R1 1 0x8C040300, // 0003 GETMET R1 R1 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_wifi_bars_icon_lib.c b/lib/libesp32/Berry/default/be_lvgl_wifi_bars_icon_lib.c index a96a71e66..d65bb3ec5 100644 --- a/lib/libesp32/Berry/default/be_lvgl_wifi_bars_icon_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_wifi_bars_icon_lib.c @@ -40,7 +40,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[49]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 diff --git a/lib/libesp32/Berry/default/be_lvgl_wifi_bars_lib.c b/lib/libesp32/Berry/default/be_lvgl_wifi_bars_lib.c index 6e4540b2b..57e3e0cf2 100644 --- a/lib/libesp32/Berry/default/be_lvgl_wifi_bars_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_wifi_bars_lib.c @@ -84,7 +84,7 @@ be_local_closure(init, /* name */ (be_nested_const_str("init", 380752755, 4)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[15]) { /* code */ - 0x600C0014, // 0000 GETGBL R3 G20 + 0x600C0003, // 0000 GETGBL R3 G3 0x5C100000, // 0001 MOVE R4 R0 0x7C0C0200, // 0002 CALL R3 1 0x8C0C0700, // 0003 GETMET R3 R3 K0 @@ -126,7 +126,7 @@ be_local_closure(del, /* name */ (be_nested_const_str("del", -816214454, 3)), (be_nested_const_str("input", -103256197, 5)), ( &(const binstruction[10]) { /* code */ - 0x60040014, // 0000 GETGBL R1 G20 + 0x60040003, // 0000 GETGBL R1 G3 0x5C080000, // 0001 MOVE R2 R0 0x7C040200, // 0002 CALL R1 1 0x8C040300, // 0003 GETMET R1 R1 K0 diff --git a/lib/libesp32/Berry/default/be_md5_lib.c b/lib/libesp32/Berry/default/be_md5_lib.c index 3f55dd6a1..2c8dfd77b 100644 --- a/lib/libesp32/Berry/default/be_md5_lib.c +++ b/lib/libesp32/Berry/default/be_md5_lib.c @@ -11,27 +11,12 @@ extern int m_md5_init(bvm *vm); extern int m_md5_update(bvm *vm); extern int m_md5_finish(bvm *vm); -#if BE_USE_PRECOMPILED_OBJECT #include "../generate/be_fixed_be_class_md5.h" -#endif void be_load_md5_lib(bvm *vm) { -#if !BE_USE_PRECOMPILED_OBJECT - static const bnfuncinfo members[] = { - { ".p", NULL }, - - { "init", m_md5_init }, - { "update", m_md5_update }, - { "finish", m_md5_finish }, - - { NULL, NULL } - }; - be_regclass(vm, "MD5", members); -#else be_pushntvclass(vm, &be_class_md5); be_setglobal(vm, "MD5"); be_pop(vm, 1); -#endif } /* @const_object_info_begin diff --git a/lib/libesp32/Berry/default/be_path_tasmota_lib.c b/lib/libesp32/Berry/default/be_path_tasmota_lib.c index 22e0f7baa..810a8e712 100644 --- a/lib/libesp32/Berry/default/be_path_tasmota_lib.c +++ b/lib/libesp32/Berry/default/be_path_tasmota_lib.c @@ -27,19 +27,9 @@ static int m_path_exists(bvm *vm) be_return(vm); } -#if !BE_USE_PRECOMPILED_OBJECT -be_native_module_attr_table(path) { - be_native_module_function("exists", m_path_exists), -}; - -static be_define_native_module(path, NULL); - -#else /* @const_object_info_begin module path (scope: global, file: tasmota_path) { exists, func(m_path_exists) } @const_object_info_end */ #include "../generate/be_fixed_tasmota_path.h" - -#endif diff --git a/lib/libesp32/Berry/default/be_tasmotalib.c b/lib/libesp32/Berry/default/be_tasmotalib.c index 662a4b72d..ad6bfaa90 100644 --- a/lib/libesp32/Berry/default/be_tasmotalib.c +++ b/lib/libesp32/Berry/default/be_tasmotalib.c @@ -45,459 +45,152 @@ extern int l_i2cenabled(bvm *vm); /******************************************************************** - // add `chars_in_string(s:string,c:string) -> int`` - // looks for any char in c, and return the position of the first char - // or -1 if not found - // inv is optional and inverses the behavior, i.e. look for chars not in the list - "def chars_in_string(s,c,inv) " - "var inverted = inv ? true : false " - "for i:0..size(s)-1 " - "var found = false " - "for j:0..size(c)-1 " - "if s[i] == c[j] found = true end " - "end " - "if inverted != found return i end " - "end " - "return -1 " - "end " +** Solidified function: add_driver ********************************************************************/ -/******************************************************************** -** Solidified function: chars_in_string -********************************************************************/ - -be_define_local_const_str(chars_in_string_str_name, "chars_in_string", -1146182164, 15); -be_define_local_const_str(chars_in_string_str_source, "string", 398550328, 6); -be_define_local_const_str(chars_in_string_str_2, "stop_iteration", -121173395, 14); - -static const bvalue chars_in_string_ktab[3] = { - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, - { { .s=be_local_const_str(chars_in_string_str_2) }, BE_STRING}, -}; - -static const uint32_t chars_in_string_code[44] = { - 0x780E0001, // 0000 JMPF R3 #0003 - 0x50100200, // 0001 LDBOOL R4 1 0 - 0x70020000, // 0002 JMP #0004 - 0x50100000, // 0003 LDBOOL R4 0 0 - 0x60140000, // 0004 GETGBL R5 G0 - 0x60180012, // 0005 GETGBL R6 G18 - 0x5C1C0200, // 0006 MOVE R7 R1 - 0x7C180200, // 0007 CALL R6 1 - 0x4180D01, // 0008 SUB R6 R6 R257 - 0x401A0006, // 0009 CONNECT R6 R256 R6 - 0x7C140200, // 000A CALL R5 1 - 0xA802001A, // 000B EXBLK 0 #0027 - 0x5C180A00, // 000C MOVE R6 R5 - 0x7C180000, // 000D CALL R6 0 - 0x501C0000, // 000E LDBOOL R7 0 0 - 0x60200000, // 000F GETGBL R8 G0 - 0x60240012, // 0010 GETGBL R9 G18 - 0x5C280400, // 0011 MOVE R10 R2 - 0x7C240200, // 0012 CALL R9 1 - 0x4241301, // 0013 SUB R9 R9 R257 - 0x40260009, // 0014 CONNECT R9 R256 R9 - 0x7C200200, // 0015 CALL R8 1 - 0xA8020007, // 0016 EXBLK 0 #001F - 0x5C241000, // 0017 MOVE R9 R8 - 0x7C240000, // 0018 CALL R9 0 - 0x94280206, // 0019 GETIDX R10 R1 R6 - 0x942C0409, // 001A GETIDX R11 R2 R9 - 0x1C28140B, // 001B EQ R10 R10 R11 - 0x782A0000, // 001C JMPF R10 #001E - 0x501C0200, // 001D LDBOOL R7 1 0 - 0x7001FFF7, // 001E JMP #0017 - 0x58200002, // 001F LDCONST R8 K2 - 0xAC200200, // 0020 CATCH R8 1 0 - 0xB0080000, // 0021 RAISE 2 R0 R0 - 0x20200807, // 0022 NE R8 R4 R7 - 0x78220001, // 0023 JMPF R8 #0026 - 0xA8040001, // 0024 EXBLK 1 1 - 0x80040C00, // 0025 RET 1 R6 - 0x7001FFE4, // 0026 JMP #000C - 0x58140002, // 0027 LDCONST R5 K2 - 0xAC140200, // 0028 CATCH R5 1 0 - 0xB0080000, // 0029 RAISE 2 R0 R0 - 0x5415FFFE, // 002A LDINT R5 -1 - 0x80040A00, // 002B RET 1 R5 -}; - -static const bproto chars_in_string_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked 0x08 - 12, // nstack - 0, // nupvals - 4, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &chars_in_string_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &chars_in_string_code, // code - be_local_const_str(chars_in_string_str_name), // name - 44, // codesize - 3, // nconst - 0, // nproto - be_local_const_str(chars_in_string_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -const bclosure chars_in_string_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &chars_in_string_proto, // proto - { NULL } // upvals -}; - +be_local_closure(add_driver, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_string("_drivers", -1034638311, 8), + /* K1 */ be_nested_string("push", -2022703139, 4), + }), + (be_nested_const_str("add_driver", 1654458371, 10)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[12]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x780A0004, // 0001 JMPF R2 #0007 + 0x88080100, // 0002 GETMBR R2 R0 K0 + 0x8C080501, // 0003 GETMET R2 R2 K1 + 0x5C100200, // 0004 MOVE R4 R1 + 0x7C080400, // 0005 CALL R2 2 + 0x70020003, // 0006 JMP #000B + 0x60080012, // 0007 GETGBL R2 G18 + 0x7C080000, // 0008 CALL R2 0 + 0x400C0401, // 0009 CONNECT R3 R2 R1 + 0x90020002, // 000A SETMBR R0 K0 R2 + 0x80000000, // 000B RET 0 + }) + ) +); /*******************************************************************/ /******************************************************************** -// find a key in map, case insensitive, return actual key or nil if not found -def find_key_i(m,keyi) - import string - var keyu = string.toupper(keyi) - if classof(m) == map - for k:m.keys() - if string.toupper(k)==keyu || keyi=='?' - return k - end - end - end -end +** Solidified function: gen_cb ********************************************************************/ -/******************************************************************** -** Solidified function: find_key_i -********************************************************************/ - -be_define_local_const_str(find_key_i_str_name, "find_key_i", 850136726, 10); -be_define_local_const_str(find_key_i_str_source, "string", 398550328, 6); -be_define_local_const_str(find_key_i_str_0, "string", 398550328, 6); -be_define_local_const_str(find_key_i_str_1, "toupper", -602983720, 7); -be_define_local_const_str(find_key_i_str_2, "keys", -112588595, 4); -be_define_local_const_str(find_key_i_str_3, "?", 973910158, 1); -be_define_local_const_str(find_key_i_str_4, "stop_iteration", -121173395, 14); - -static const bvalue find_key_i_ktab[5] = { - { { .s=be_local_const_str(find_key_i_str_0) }, BE_STRING}, - { { .s=be_local_const_str(find_key_i_str_1) }, BE_STRING}, - { { .s=be_local_const_str(find_key_i_str_2) }, BE_STRING}, - { { .s=be_local_const_str(find_key_i_str_3) }, BE_STRING}, - { { .s=be_local_const_str(find_key_i_str_4) }, BE_STRING}, -}; - -static const uint32_t find_key_i_code[31] = { - 0xA40E0000, // 0000 IMPORT R3 R256 - 0x8C100701, // 0001 GETMET R4 R3 R257 - 0x5C180400, // 0002 MOVE R6 R2 - 0x7C100400, // 0003 CALL R4 2 - 0x60140004, // 0004 GETGBL R5 G4 - 0x5C180200, // 0005 MOVE R6 R1 - 0x7C140200, // 0006 CALL R5 1 - 0x6018000B, // 0007 GETGBL R6 G11 - 0x1C140A06, // 0008 EQ R5 R5 R6 - 0x78160013, // 0009 JMPF R5 #001E - 0x60140000, // 000A GETGBL R5 G0 - 0x8C180302, // 000B GETMET R6 R1 R258 - 0x7C180200, // 000C CALL R6 1 - 0x7C140200, // 000D CALL R5 1 - 0xA802000B, // 000E EXBLK 0 #001B - 0x5C180A00, // 000F MOVE R6 R5 - 0x7C180000, // 0010 CALL R6 0 - 0x8C1C0701, // 0011 GETMET R7 R3 R257 - 0x5C240C00, // 0012 MOVE R9 R6 - 0x7C1C0400, // 0013 CALL R7 2 - 0x1C1C0E04, // 0014 EQ R7 R7 R4 - 0x741E0001, // 0015 JMPT R7 #0018 - 0x1C1C0503, // 0016 EQ R7 R2 R259 - 0x781E0001, // 0017 JMPF R7 #001A - 0xA8040001, // 0018 EXBLK 1 1 - 0x80040C00, // 0019 RET 1 R6 - 0x7001FFF3, // 001A JMP #000F - 0x58140004, // 001B LDCONST R5 K4 - 0xAC140200, // 001C CATCH R5 1 0 - 0xB0080000, // 001D RAISE 2 R0 R0 - 0x80000000, // 001E RET 0 R0 -}; - -static const bproto find_key_i_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 10, // nstack - 0, // nupvals - 3, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &find_key_i_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &find_key_i_code, // code - be_local_const_str(find_key_i_str_name), // name - 31, // codesize - 5, // nconst - 0, // nproto - be_local_const_str(find_key_i_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -const bclosure find_key_i_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &find_key_i_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ - - - -/******************************************************************** - // # split the item when there is an operator, returns a list of (left,op,right) - // # ex: "Dimmer>50" -> ["Dimmer",tasmota_gt,"50"] - "def find_op(item) " - "import string " - "var op_chars = '=<>!' " - "var pos = self.chars_in_string(item, op_chars) " - "if pos >= 0 " - "var op_split = string.split(item,pos) " - "var op_left = op_split[0] " - "var op_rest = op_split[1] " - "pos = self.chars_in_string(op_rest, op_chars, true) " - "if pos >= 0 " - "var op_split2 = string.split(op_rest,pos) " - "var op_middle = op_split2[0] " - "var op_right = op_split2[1] " - "return [op_left,op_middle,op_right] " - "end " - "end " - "return [item, nil, nil] " - "end " -********************************************************************/ -/******************************************************************** -** Solidified function: find_op -********************************************************************/ - -be_define_local_const_str(find_op_str_name, "find_op", -528253920, 7); -be_define_local_const_str(find_op_str_source, "string", 398550328, 6); -be_define_local_const_str(find_op_str_0, "string", 398550328, 6); -be_define_local_const_str(find_op_str_1, "=<>!", -1630497019, 4); -be_define_local_const_str(find_op_str_2, "chars_in_string", -1146182164, 15); -be_define_local_const_str(find_op_str_4, "split", -2017972765, 5); - -static const bvalue find_op_ktab[6] = { - { { .s=be_local_const_str(find_op_str_0) }, BE_STRING}, - { { .s=be_local_const_str(find_op_str_1) }, BE_STRING}, - { { .s=be_local_const_str(find_op_str_2) }, BE_STRING}, - { { .i=0 }, BE_INT}, - { { .s=be_local_const_str(find_op_str_4) }, BE_STRING}, - { { .i=1 }, BE_INT}, -}; - -static const uint32_t find_op_code[42] = { - 0xA40A0000, // 0000 IMPORT R2 R256 - 0x580C0001, // 0001 LDCONST R3 K1 - 0x8C100102, // 0002 GETMET R4 R0 R258 - 0x5C180200, // 0003 MOVE R6 R1 - 0x5C1C0600, // 0004 MOVE R7 R3 - 0x7C100600, // 0005 CALL R4 3 - 0x28140903, // 0006 GE R5 R4 R259 - 0x78160019, // 0007 JMPF R5 #0022 - 0x8C140504, // 0008 GETMET R5 R2 R260 - 0x5C1C0200, // 0009 MOVE R7 R1 - 0x5C200800, // 000A MOVE R8 R4 - 0x7C140600, // 000B CALL R5 3 - 0x94180B03, // 000C GETIDX R6 R5 R259 - 0x941C0B05, // 000D GETIDX R7 R5 R261 - 0x8C200102, // 000E GETMET R8 R0 R258 - 0x5C280E00, // 000F MOVE R10 R7 - 0x5C2C0600, // 0010 MOVE R11 R3 - 0x50300200, // 0011 LDBOOL R12 1 0 - 0x7C200800, // 0012 CALL R8 4 - 0x5C101000, // 0013 MOVE R4 R8 - 0x28200903, // 0014 GE R8 R4 R259 - 0x7822000B, // 0015 JMPF R8 #0022 - 0x8C200504, // 0016 GETMET R8 R2 R260 - 0x5C280E00, // 0017 MOVE R10 R7 - 0x5C2C0800, // 0018 MOVE R11 R4 - 0x7C200600, // 0019 CALL R8 3 - 0x94241103, // 001A GETIDX R9 R8 R259 - 0x94281105, // 001B GETIDX R10 R8 R261 - 0x602C000A, // 001C GETGBL R11 G10 - 0x7C2C0000, // 001D CALL R11 0 - 0x40301606, // 001E CONNECT R12 R11 R6 - 0x40301609, // 001F CONNECT R12 R11 R9 - 0x4030160A, // 0020 CONNECT R12 R11 R10 - 0x80041600, // 0021 RET 1 R11 - 0x6014000A, // 0022 GETGBL R5 G10 - 0x7C140000, // 0023 CALL R5 0 - 0x40180A01, // 0024 CONNECT R6 R5 R1 - 0x4C180000, // 0025 LDNIL 6 - 0x40180A06, // 0026 CONNECT R6 R5 R6 - 0x4C180000, // 0027 LDNIL 6 - 0x40180A06, // 0028 CONNECT R6 R5 R6 - 0x80040A00, // 0029 RET 1 R5 -}; - -static const bproto find_op_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 13, // nstack - 0, // nupvals - 2, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &find_op_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &find_op_code, // code - be_local_const_str(find_op_str_name), // name - 42, // codesize - 6, // nconst - 0, // nproto - be_local_const_str(find_op_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -const bclosure find_op_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &find_op_proto, // proto - { NULL } // upvals -}; - +be_local_closure(gen_cb, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + /* K0 */ be_nested_string("_cb", -251666929, 3), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_string("find", -1108310694, 4), + /* K3 */ be_nested_string("_get_cb", 1448849122, 7), + /* K4 */ be_nested_string("stop_iteration", -121173395, 14), + /* K5 */ be_nested_string("internal_error", -1775809127, 14), + /* K6 */ be_nested_string("No callback available", 633786138, 21), + }), + (be_nested_const_str("gen_cb", -1049739745, 6)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[34]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x4C0C0000, // 0001 LDNIL R3 + 0x1C080403, // 0002 EQ R2 R2 R3 + 0x780A0002, // 0003 JMPF R2 #0007 + 0x60080013, // 0004 GETGBL R2 G19 + 0x7C080000, // 0005 CALL R2 0 + 0x90020002, // 0006 SETMBR R0 K0 R2 + 0x60080010, // 0007 GETGBL R2 G16 + 0x540E0012, // 0008 LDINT R3 19 + 0x400E0203, // 0009 CONNECT R3 K1 R3 + 0x7C080200, // 000A CALL R2 1 + 0xA8020010, // 000B EXBLK 0 #001D + 0x5C0C0400, // 000C MOVE R3 R2 + 0x7C0C0000, // 000D CALL R3 0 + 0x88100100, // 000E GETMBR R4 R0 K0 + 0x8C100902, // 000F GETMET R4 R4 K2 + 0x5C180600, // 0010 MOVE R6 R3 + 0x7C100400, // 0011 CALL R4 2 + 0x4C140000, // 0012 LDNIL R5 + 0x1C100805, // 0013 EQ R4 R4 R5 + 0x78120006, // 0014 JMPF R4 #001C + 0x88100100, // 0015 GETMBR R4 R0 K0 + 0x98100601, // 0016 SETIDX R4 R3 R1 + 0x8C100103, // 0017 GETMET R4 R0 K3 + 0x5C180600, // 0018 MOVE R6 R3 + 0x7C100400, // 0019 CALL R4 2 + 0xA8040001, // 001A EXBLK 1 1 + 0x80040800, // 001B RET 1 R4 + 0x7001FFEE, // 001C JMP #000C + 0x58080004, // 001D LDCONST R2 K4 + 0xAC080200, // 001E CATCH R2 1 0 + 0xB0080000, // 001F RAISE 2 R0 R0 + 0xB0060B06, // 0020 RAISE 1 K5 K6 + 0x80000000, // 0021 RET 0 + }) + ) +); /*******************************************************************/ /******************************************************************** - // Rules - "def add_rule(pat,f) " - "if !self._rules " - "self._rules={} " - "end " - "if type(f) == 'function' " - "self._rules[pat] = f " - "else " - "raise 'value_error', 'the second argument is not a function' " - "end " - "end " +** Solidified function: set_light ********************************************************************/ - -/******************************************************************** -** Solidified function: add_rule -********************************************************************/ - -be_define_local_const_str(add_rule_str_name, "add_rule", 596540743, 8); -be_define_local_const_str(add_rule_str_source, "string", 398550328, 6); -be_define_local_const_str(add_rule_str_0, "_rules", -28750191, 6); -be_define_local_const_str(add_rule_str_1, "function", -1630125495, 8); -be_define_local_const_str(add_rule_str_2, "value_error", 773297791, 11); -be_define_local_const_str(add_rule_str_3, "the second argument is not a function", -340392827, 37); - -static const bvalue add_rule_ktab[4] = { - { { .s=be_local_const_str(add_rule_str_0) }, BE_STRING}, - { { .s=be_local_const_str(add_rule_str_1) }, BE_STRING}, - { { .s=be_local_const_str(add_rule_str_2) }, BE_STRING}, - { { .s=be_local_const_str(add_rule_str_3) }, BE_STRING}, -}; - -static const uint32_t add_rule_code[15] = { - 0x880C0100, // 0000 GETMBR R3 R0 R256 - 0x740E0002, // 0001 JMPT R3 #0005 - 0x600C000B, // 0002 GETGBL R3 G11 - 0x7C0C0000, // 0003 CALL R3 0 - 0x90020003, // 0004 SETMBR R0 R256 R3 - 0x600C0015, // 0005 GETGBL R3 G21 - 0x5C100400, // 0006 MOVE R4 R2 - 0x7C0C0200, // 0007 CALL R3 1 - 0x1C0C0701, // 0008 EQ R3 R3 R257 - 0x780E0002, // 0009 JMPF R3 #000D - 0x880C0100, // 000A GETMBR R3 R0 R256 - 0x980C0202, // 000B SETIDX R3 R1 R2 - 0x70020000, // 000C JMP #000E - 0xB0060503, // 000D RAISE 1 R258 R259 - 0x80000000, // 000E RET 0 R0 -}; - -static const bproto add_rule_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 5, // nstack - 0, // nupvals - 3, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &add_rule_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &add_rule_code, // code - be_local_const_str(add_rule_str_name), // name - 15, // codesize - 4, // nconst - 0, // nproto - be_local_const_str(add_rule_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure add_rule_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &add_rule_proto, // proto - { NULL } // upvals -}; - +be_local_closure(set_light, /* name */ + be_nested_proto( + 8, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_string("tasmota.set_light() is deprecated, use light.set()", 2124937871, 50), + /* K1 */ be_nested_string("light", -493019601, 5), + /* K2 */ be_nested_string("set", -970520829, 3), + }), + (be_nested_const_str("set_light", -1118891144, 9)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[18]) { /* code */ + 0x600C0001, // 0000 GETGBL R3 G1 + 0x58100000, // 0001 LDCONST R4 K0 + 0x7C0C0200, // 0002 CALL R3 1 + 0xA40E0200, // 0003 IMPORT R3 K1 + 0x4C100000, // 0004 LDNIL R4 + 0x20100404, // 0005 NE R4 R2 R4 + 0x78120005, // 0006 JMPF R4 #000D + 0x8C100702, // 0007 GETMET R4 R3 K2 + 0x5C180200, // 0008 MOVE R6 R1 + 0x5C1C0400, // 0009 MOVE R7 R2 + 0x7C100600, // 000A CALL R4 3 + 0x80040800, // 000B RET 1 R4 + 0x70020003, // 000C JMP #0011 + 0x8C100702, // 000D GETMET R4 R3 K2 + 0x5C180200, // 000E MOVE R6 R1 + 0x7C100400, // 000F CALL R4 2 + 0x80040800, // 0010 RET 1 R4 + 0x80000000, // 0011 RET 0 + }) + ) +); /*******************************************************************/ -/******************************************************************** - "def remove_rule(pat) " - "if self._rules " - "self._rules.remove(pat) " - "end " - "end " -********************************************************************/ /******************************************************************** ** Solidified function: remove_rule @@ -512,20 +205,20 @@ be_local_closure(remove_rule, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 2]) { /* upvals */ - { { .s=be_nested_const_str("_rules", -28750191, 6) }, BE_STRING}, - { { .s=be_nested_const_str("remove", -611183107, 6) }, BE_STRING}, + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_string("_rules", -28750191, 6), + /* K1 */ be_nested_string("remove", -611183107, 6), }), (be_nested_const_str("remove_rule", -838755968, 11)), - (be_nested_const_str("string", 398550328, 6)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[ 7]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x780A0003, // 0001 JMPF R2 #0006 - 0x88080100, // 0002 GETMBR R2 R0 R256 - 0x8C080501, // 0003 GETMET R2 R2 R257 - 0x5C100200, // 0004 MOVE R4 R1 - 0x7C080400, // 0005 CALL R2 2 - 0x80000000, // 0006 RET 0 R0 + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x780A0003, // 0001 JMPF R2 #0006 + 0x88080100, // 0002 GETMBR R2 R0 K0 + 0x8C080501, // 0003 GETMET R2 R2 K1 + 0x5C100200, // 0004 MOVE R4 R1 + 0x7C080400, // 0005 CALL R2 2 + 0x80000000, // 0006 RET 0 }) ) ); @@ -533,400 +226,232 @@ be_local_closure(remove_rule, /* name */ /******************************************************************** - // Rules trigger if match. return true if match, false if not - "def try_rule(event, rule, f) " - "import string " - "var rl_list = self.find_op(rule) " - "var sub_event = event " - "var rl = string.split(rl_list[0],'#') " - "for it:rl " - "found=self.find_key_i(sub_event,it) " - "if found == nil return false end " - "sub_event = sub_event[found] " - "end " - "var op=rl_list[1]" - "var op2=rl_list[2]" - "if op " - "if op=='==' " - "if str(sub_event) != str(op2) return false end " - "elif op=='!==' " - "if str(sub_event) == str(op2) return false end " - "elif op=='=' " - "if real(sub_event) != real(op2) return false end " - "elif op=='!=' " - "if real(sub_event) == real(op2) return false end " - "elif op=='>' " - "if real(sub_event) <= real(op2) return false end " - "elif op=='>=' " - "if real(sub_event) < real(op2) return false end " - "elif op=='<' " - "if real(sub_event) >= real(op2) return false end " - "elif op=='<=' " - "if real(sub_event) > real(op2) return false end " - "end " - "end " - "f(sub_event, rl_list[0], event) " - "return true " - "end " +** Solidified function: add_cmd ********************************************************************/ -/******************************************************************** -** Solidified function: try_rule -********************************************************************/ - -be_define_local_const_str(try_rule_str_name, "try_rule", 1986449405, 8); -be_define_local_const_str(try_rule_str_source, "string", 398550328, 6); -be_define_local_const_str(try_rule_str_0, "string", 398550328, 6); -be_define_local_const_str(try_rule_str_1, "find_op", -528253920, 7); -be_define_local_const_str(try_rule_str_2, "split", -2017972765, 5); -be_define_local_const_str(try_rule_str_4, "#", 638357778, 1); -be_define_local_const_str(try_rule_str_5, "find_key_i", 850136726, 10); -be_define_local_const_str(try_rule_str_6, "stop_iteration", -121173395, 14); -be_define_local_const_str(try_rule_str_9, "==", -1863000881, 2); -be_define_local_const_str(try_rule_str_10, "!==", 559817114, 3); -be_define_local_const_str(try_rule_str_11, "=", 940354920, 1); -be_define_local_const_str(try_rule_str_12, "!=", -1866252285, 2); -be_define_local_const_str(try_rule_str_13, ">", 990687777, 1); -be_define_local_const_str(try_rule_str_14, ">=", 284975636, 2); -be_define_local_const_str(try_rule_str_15, "<", 957132539, 1); -be_define_local_const_str(try_rule_str_16, "<=", -1795743310, 2); - -static const bvalue try_rule_ktab[17] = { - { { .s=be_local_const_str(try_rule_str_0) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_1) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_2) }, BE_STRING}, - { { .i=0 }, BE_INT}, - { { .s=be_local_const_str(try_rule_str_4) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_5) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_6) }, BE_STRING}, - { { .i=1 }, BE_INT}, - { { .i=2 }, BE_INT}, - { { .s=be_local_const_str(try_rule_str_9) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_10) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_11) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_12) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_13) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_14) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_15) }, BE_STRING}, - { { .s=be_local_const_str(try_rule_str_16) }, BE_STRING}, -}; - -static const uint32_t try_rule_code[143] = { - 0xA4120000, // 0000 IMPORT R4 R256 - 0x8C140101, // 0001 GETMET R5 R0 R257 - 0x5C1C0400, // 0002 MOVE R7 R2 - 0x7C140400, // 0003 CALL R5 2 - 0x5C180200, // 0004 MOVE R6 R1 - 0x8C1C0902, // 0005 GETMET R7 R4 R258 - 0x94240B03, // 0006 GETIDX R9 R5 R259 - 0x58280004, // 0007 LDCONST R10 K4 - 0x7C1C0600, // 0008 CALL R7 3 - 0x60200000, // 0009 GETGBL R8 G0 - 0x5C240E00, // 000A MOVE R9 R7 - 0x7C200200, // 000B CALL R8 1 - 0xA802000D, // 000C EXBLK 0 #001B - 0x5C241000, // 000D MOVE R9 R8 - 0x7C240000, // 000E CALL R9 0 - 0x8C280105, // 000F GETMET R10 R0 R261 - 0x5C300C00, // 0010 MOVE R12 R6 - 0x5C341200, // 0011 MOVE R13 R9 - 0x7C280600, // 0012 CALL R10 3 - 0x4C2C0000, // 0013 LDNIL 11 - 0x1C2C140B, // 0014 EQ R11 R10 R11 - 0x782E0002, // 0015 JMPF R11 #0019 - 0x502C0000, // 0016 LDBOOL R11 0 0 - 0xA8040001, // 0017 EXBLK 1 1 - 0x80041600, // 0018 RET 1 R11 - 0x94180C0A, // 0019 GETIDX R6 R6 R10 - 0x7001FFF1, // 001A JMP #000D - 0x58200006, // 001B LDCONST R8 K6 - 0xAC200200, // 001C CATCH R8 1 0 - 0xB0080000, // 001D RAISE 2 R0 R0 - 0x94200B07, // 001E GETIDX R8 R5 R263 - 0x94240B08, // 001F GETIDX R9 R5 R264 - 0x78220066, // 0020 JMPF R8 #0088 - 0x1C281109, // 0021 EQ R10 R8 R265 - 0x782A000A, // 0022 JMPF R10 #002E - 0x60280013, // 0023 GETGBL R10 G19 - 0x5C2C0C00, // 0024 MOVE R11 R6 - 0x7C280200, // 0025 CALL R10 1 - 0x602C0013, // 0026 GETGBL R11 G19 - 0x5C301200, // 0027 MOVE R12 R9 - 0x7C2C0200, // 0028 CALL R11 1 - 0x2028140B, // 0029 NE R10 R10 R11 - 0x782A0001, // 002A JMPF R10 #002D - 0x50280000, // 002B LDBOOL R10 0 0 - 0x80041400, // 002C RET 1 R10 - 0x70020059, // 002D JMP #0088 - 0x1C28110A, // 002E EQ R10 R8 R266 - 0x782A000A, // 002F JMPF R10 #003B - 0x60280013, // 0030 GETGBL R10 G19 - 0x5C2C0C00, // 0031 MOVE R11 R6 - 0x7C280200, // 0032 CALL R10 1 - 0x602C0013, // 0033 GETGBL R11 G19 - 0x5C301200, // 0034 MOVE R12 R9 - 0x7C2C0200, // 0035 CALL R11 1 - 0x1C28140B, // 0036 EQ R10 R10 R11 - 0x782A0001, // 0037 JMPF R10 #003A - 0x50280000, // 0038 LDBOOL R10 0 0 - 0x80041400, // 0039 RET 1 R10 - 0x7002004C, // 003A JMP #0088 - 0x1C28110B, // 003B EQ R10 R8 R267 - 0x782A000A, // 003C JMPF R10 #0048 - 0x60280011, // 003D GETGBL R10 G17 - 0x5C2C0C00, // 003E MOVE R11 R6 - 0x7C280200, // 003F CALL R10 1 - 0x602C0011, // 0040 GETGBL R11 G17 - 0x5C301200, // 0041 MOVE R12 R9 - 0x7C2C0200, // 0042 CALL R11 1 - 0x2028140B, // 0043 NE R10 R10 R11 - 0x782A0001, // 0044 JMPF R10 #0047 - 0x50280000, // 0045 LDBOOL R10 0 0 - 0x80041400, // 0046 RET 1 R10 - 0x7002003F, // 0047 JMP #0088 - 0x1C28110C, // 0048 EQ R10 R8 R268 - 0x782A000A, // 0049 JMPF R10 #0055 - 0x60280011, // 004A GETGBL R10 G17 - 0x5C2C0C00, // 004B MOVE R11 R6 - 0x7C280200, // 004C CALL R10 1 - 0x602C0011, // 004D GETGBL R11 G17 - 0x5C301200, // 004E MOVE R12 R9 - 0x7C2C0200, // 004F CALL R11 1 - 0x1C28140B, // 0050 EQ R10 R10 R11 - 0x782A0001, // 0051 JMPF R10 #0054 - 0x50280000, // 0052 LDBOOL R10 0 0 - 0x80041400, // 0053 RET 1 R10 - 0x70020032, // 0054 JMP #0088 - 0x1C28110D, // 0055 EQ R10 R8 R269 - 0x782A000A, // 0056 JMPF R10 #0062 - 0x60280011, // 0057 GETGBL R10 G17 - 0x5C2C0C00, // 0058 MOVE R11 R6 - 0x7C280200, // 0059 CALL R10 1 - 0x602C0011, // 005A GETGBL R11 G17 - 0x5C301200, // 005B MOVE R12 R9 - 0x7C2C0200, // 005C CALL R11 1 - 0x1828140B, // 005D LE R10 R10 R11 - 0x782A0001, // 005E JMPF R10 #0061 - 0x50280000, // 005F LDBOOL R10 0 0 - 0x80041400, // 0060 RET 1 R10 - 0x70020025, // 0061 JMP #0088 - 0x1C28110E, // 0062 EQ R10 R8 R270 - 0x782A000A, // 0063 JMPF R10 #006F - 0x60280011, // 0064 GETGBL R10 G17 - 0x5C2C0C00, // 0065 MOVE R11 R6 - 0x7C280200, // 0066 CALL R10 1 - 0x602C0011, // 0067 GETGBL R11 G17 - 0x5C301200, // 0068 MOVE R12 R9 - 0x7C2C0200, // 0069 CALL R11 1 - 0x1428140B, // 006A LT R10 R10 R11 - 0x782A0001, // 006B JMPF R10 #006E - 0x50280000, // 006C LDBOOL R10 0 0 - 0x80041400, // 006D RET 1 R10 - 0x70020018, // 006E JMP #0088 - 0x1C28110F, // 006F EQ R10 R8 R271 - 0x782A000A, // 0070 JMPF R10 #007C - 0x60280011, // 0071 GETGBL R10 G17 - 0x5C2C0C00, // 0072 MOVE R11 R6 - 0x7C280200, // 0073 CALL R10 1 - 0x602C0011, // 0074 GETGBL R11 G17 - 0x5C301200, // 0075 MOVE R12 R9 - 0x7C2C0200, // 0076 CALL R11 1 - 0x2828140B, // 0077 GE R10 R10 R11 - 0x782A0001, // 0078 JMPF R10 #007B - 0x50280000, // 0079 LDBOOL R10 0 0 - 0x80041400, // 007A RET 1 R10 - 0x7002000B, // 007B JMP #0088 - 0x1C281110, // 007C EQ R10 R8 R272 - 0x782A0009, // 007D JMPF R10 #0088 - 0x60280011, // 007E GETGBL R10 G17 - 0x5C2C0C00, // 007F MOVE R11 R6 - 0x7C280200, // 0080 CALL R10 1 - 0x602C0011, // 0081 GETGBL R11 G17 - 0x5C301200, // 0082 MOVE R12 R9 - 0x7C2C0200, // 0083 CALL R11 1 - 0x2428140B, // 0084 GT R10 R10 R11 - 0x782A0001, // 0085 JMPF R10 #0088 - 0x50280000, // 0086 LDBOOL R10 0 0 - 0x80041400, // 0087 RET 1 R10 - 0x5C280600, // 0088 MOVE R10 R3 - 0x5C2C0C00, // 0089 MOVE R11 R6 - 0x94300B03, // 008A GETIDX R12 R5 R259 - 0x5C340200, // 008B MOVE R13 R1 - 0x7C280600, // 008C CALL R10 3 - 0x50280200, // 008D LDBOOL R10 1 0 - 0x80041400, // 008E RET 1 R10 -}; - -static const bproto try_rule_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 14, // nstack - 0, // nupvals - 4, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &try_rule_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &try_rule_code, // code - be_local_const_str(try_rule_str_name), // name - 143, // codesize - 17, // nconst - 0, // nproto - be_local_const_str(try_rule_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure try_rule_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &try_rule_proto, // proto - { NULL } // upvals -}; - +be_local_closure(add_cmd, /* name */ + be_nested_proto( + 5, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_string("_ccmd", -2131545883, 5), + /* K1 */ be_nested_string("function", -1630125495, 8), + /* K2 */ be_nested_string("value_error", 773297791, 11), + /* K3 */ be_nested_string("the second argument is not a function", -340392827, 37), + }), + (be_nested_const_str("add_cmd", -933336417, 7)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[15]) { /* code */ + 0x880C0100, // 0000 GETMBR R3 R0 K0 + 0x740E0002, // 0001 JMPT R3 #0005 + 0x600C0013, // 0002 GETGBL R3 G19 + 0x7C0C0000, // 0003 CALL R3 0 + 0x90020003, // 0004 SETMBR R0 K0 R3 + 0x600C0004, // 0005 GETGBL R3 G4 + 0x5C100400, // 0006 MOVE R4 R2 + 0x7C0C0200, // 0007 CALL R3 1 + 0x1C0C0701, // 0008 EQ R3 R3 K1 + 0x780E0002, // 0009 JMPF R3 #000D + 0x880C0100, // 000A GETMBR R3 R0 K0 + 0x980C0202, // 000B SETIDX R3 R1 R2 + 0x70020000, // 000C JMP #000E + 0xB0060503, // 000D RAISE 1 K2 K3 + 0x80000000, // 000E RET 0 + }) + ) +); /*******************************************************************/ /******************************************************************** - // Run rules, i.e. check each individual rule - // Returns true if at least one rule matched, false if none - "def exec_rules(ev_json) " - "if self._rules " - "import json " - "var ev = json.load(ev_json) " - "var ret = false " - "if ev == nil " - "print('BRY: ERROR, bad json: '+ev_json, 3) " - "else " - "for r: self._rules.keys() " - "ret = self.try_rule(ev,r,self._rules[r]) || ret " - "end " - "end " - "return ret " - "end " - "return false " - "end " - +** Solidified function: wire_scan ********************************************************************/ +be_local_closure(wire_scan, /* name */ + be_nested_proto( + 6, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_string("i2c_enabled", 218388101, 11), + /* K1 */ be_nested_string("wire1", -1082245877, 5), + /* K2 */ be_nested_string("detect", 8884370, 6), + /* K3 */ be_nested_string("wire2", -1065468258, 5), + }), + (be_nested_const_str("wire_scan", -1623691416, 9)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[25]) { /* code */ + 0x4C0C0000, // 0000 LDNIL R3 + 0x200C0403, // 0001 NE R3 R2 R3 + 0x780E0005, // 0002 JMPF R3 #0009 + 0x8C0C0100, // 0003 GETMET R3 R0 K0 + 0x5C140400, // 0004 MOVE R5 R2 + 0x7C0C0400, // 0005 CALL R3 2 + 0x740E0001, // 0006 JMPT R3 #0009 + 0x4C0C0000, // 0007 LDNIL R3 + 0x80040600, // 0008 RET 1 R3 + 0x880C0101, // 0009 GETMBR R3 R0 K1 + 0x8C0C0702, // 000A GETMET R3 R3 K2 + 0x5C140200, // 000B MOVE R5 R1 + 0x7C0C0400, // 000C CALL R3 2 + 0x780E0001, // 000D JMPF R3 #0010 + 0x880C0101, // 000E GETMBR R3 R0 K1 + 0x80040600, // 000F RET 1 R3 + 0x880C0103, // 0010 GETMBR R3 R0 K3 + 0x8C0C0702, // 0011 GETMET R3 R3 K2 + 0x5C140200, // 0012 MOVE R5 R1 + 0x7C0C0400, // 0013 CALL R3 2 + 0x780E0001, // 0014 JMPF R3 #0017 + 0x880C0103, // 0015 GETMBR R3 R0 K3 + 0x80040600, // 0016 RET 1 R3 + 0x4C0C0000, // 0017 LDNIL R3 + 0x80040600, // 0018 RET 1 R3 + }) + ) +); +/*******************************************************************/ + /******************************************************************** -** Solidified function: exec_rules +** Solidified function: find_key_i ********************************************************************/ - -be_define_local_const_str(exec_rules_str_name, "exec_rules", 1445221092, 10); -be_define_local_const_str(exec_rules_str_source, "string", 398550328, 6); -be_define_local_const_str(exec_rules_str_0, "_rules", -28750191, 6); -be_define_local_const_str(exec_rules_str_1, "json", 916562499, 4); -be_define_local_const_str(exec_rules_str_2, "load", -435725847, 4); -be_define_local_const_str(exec_rules_str_3, "BRY: ERROR, bad json: ", -1579831487, 22); -be_define_local_const_str(exec_rules_str_5, "keys", -112588595, 4); -be_define_local_const_str(exec_rules_str_6, "try_rule", 1986449405, 8); -be_define_local_const_str(exec_rules_str_7, "stop_iteration", -121173395, 14); - -static const bvalue exec_rules_ktab[8] = { - { { .s=be_local_const_str(exec_rules_str_0) }, BE_STRING}, - { { .s=be_local_const_str(exec_rules_str_1) }, BE_STRING}, - { { .s=be_local_const_str(exec_rules_str_2) }, BE_STRING}, - { { .s=be_local_const_str(exec_rules_str_3) }, BE_STRING}, - { { .i=3 }, BE_INT}, - { { .s=be_local_const_str(exec_rules_str_5) }, BE_STRING}, - { { .s=be_local_const_str(exec_rules_str_6) }, BE_STRING}, - { { .s=be_local_const_str(exec_rules_str_7) }, BE_STRING}, -}; - -static const uint32_t exec_rules_code[40] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x780A0023, // 0001 JMPF R2 #0026 - 0xA40A0200, // 0002 IMPORT R2 R257 - 0x8C0C0502, // 0003 GETMET R3 R2 R258 - 0x5C140200, // 0004 MOVE R5 R1 - 0x7C0C0400, // 0005 CALL R3 2 - 0x50100000, // 0006 LDBOOL R4 0 0 - 0x4C140000, // 0007 LDNIL 5 - 0x1C140605, // 0008 EQ R5 R3 R5 - 0x78160004, // 0009 JMPF R5 #000F - 0x6014000F, // 000A GETGBL R5 G15 - 0x1A0601, // 000B ADD R6 R259 R1 - 0x581C0004, // 000C LDCONST R7 K4 - 0x7C140400, // 000D CALL R5 2 - 0x70020015, // 000E JMP #0025 - 0x60140000, // 000F GETGBL R5 G0 - 0x88180100, // 0010 GETMBR R6 R0 R256 - 0x8C180D05, // 0011 GETMET R6 R6 R261 - 0x7C180200, // 0012 CALL R6 1 - 0x7C140200, // 0013 CALL R5 1 - 0xA802000C, // 0014 EXBLK 0 #0022 - 0x5C180A00, // 0015 MOVE R6 R5 - 0x7C180000, // 0016 CALL R6 0 - 0x8C1C0106, // 0017 GETMET R7 R0 R262 - 0x5C240600, // 0018 MOVE R9 R3 - 0x5C280C00, // 0019 MOVE R10 R6 - 0x882C0100, // 001A GETMBR R11 R0 R256 - 0x942C1606, // 001B GETIDX R11 R11 R6 - 0x7C1C0800, // 001C CALL R7 4 - 0x741E0001, // 001D JMPT R7 #0020 - 0x74120000, // 001E JMPT R4 #0020 - 0x50100001, // 001F LDBOOL R4 0 1 - 0x50100200, // 0020 LDBOOL R4 1 0 - 0x7001FFF2, // 0021 JMP #0015 - 0x58140007, // 0022 LDCONST R5 K7 - 0xAC140200, // 0023 CATCH R5 1 0 - 0xB0080000, // 0024 RAISE 2 R0 R0 - 0x80040800, // 0025 RET 1 R4 - 0x50080000, // 0026 LDBOOL R2 0 0 - 0x80040400, // 0027 RET 1 R2 -}; - -static const bproto exec_rules_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 12, // nstack - 0, // nupvals - 2, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &exec_rules_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &exec_rules_code, // code - be_local_const_str(exec_rules_str_name), // name - 40, // codesize - 8, // nconst - 0, // nproto - be_local_const_str(exec_rules_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -const bclosure exec_rules_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &exec_rules_proto, // proto - { NULL } // upvals -}; - +be_local_closure(find_key_i, /* name */ + be_nested_proto( + 10, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_string("string", 398550328, 6), + /* K1 */ be_nested_string("toupper", -602983720, 7), + /* K2 */ be_nested_string("keys", -112588595, 4), + /* K3 */ be_nested_string("?", 973910158, 1), + /* K4 */ be_nested_string("stop_iteration", -121173395, 14), + }), + (be_nested_const_str("find_key_i", 850136726, 10)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[31]) { /* code */ + 0xA40E0000, // 0000 IMPORT R3 K0 + 0x8C100701, // 0001 GETMET R4 R3 K1 + 0x5C180400, // 0002 MOVE R6 R2 + 0x7C100400, // 0003 CALL R4 2 + 0x60140006, // 0004 GETGBL R5 G6 + 0x5C180200, // 0005 MOVE R6 R1 + 0x7C140200, // 0006 CALL R5 1 + 0x60180013, // 0007 GETGBL R6 G19 + 0x1C140A06, // 0008 EQ R5 R5 R6 + 0x78160013, // 0009 JMPF R5 #001E + 0x60140010, // 000A GETGBL R5 G16 + 0x8C180302, // 000B GETMET R6 R1 K2 + 0x7C180200, // 000C CALL R6 1 + 0x7C140200, // 000D CALL R5 1 + 0xA802000B, // 000E EXBLK 0 #001B + 0x5C180A00, // 000F MOVE R6 R5 + 0x7C180000, // 0010 CALL R6 0 + 0x8C1C0701, // 0011 GETMET R7 R3 K1 + 0x5C240C00, // 0012 MOVE R9 R6 + 0x7C1C0400, // 0013 CALL R7 2 + 0x1C1C0E04, // 0014 EQ R7 R7 R4 + 0x741E0001, // 0015 JMPT R7 #0018 + 0x1C1C0503, // 0016 EQ R7 R2 K3 + 0x781E0001, // 0017 JMPF R7 #001A + 0xA8040001, // 0018 EXBLK 1 1 + 0x80040C00, // 0019 RET 1 R6 + 0x7001FFF3, // 001A JMP #000F + 0x58140004, // 001B LDCONST R5 K4 + 0xAC140200, // 001C CATCH R5 1 0 + 0xB0080000, // 001D RAISE 2 R0 R0 + 0x80000000, // 001E RET 0 + }) + ) +); /*******************************************************************/ + +/******************************************************************** +** Solidified function: chars_in_string +********************************************************************/ +be_local_closure(chars_in_string, /* name */ + be_nested_proto( + 12, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_const_int(0), + /* K1 */ be_const_int(1), + /* K2 */ be_nested_string("stop_iteration", -121173395, 14), + }), + (be_nested_const_str("chars_in_string", -1146182164, 15)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[44]) { /* code */ + 0x780E0001, // 0000 JMPF R3 #0003 + 0x50100200, // 0001 LDBOOL R4 1 0 + 0x70020000, // 0002 JMP #0004 + 0x50100000, // 0003 LDBOOL R4 0 0 + 0x60140010, // 0004 GETGBL R5 G16 + 0x6018000C, // 0005 GETGBL R6 G12 + 0x5C1C0200, // 0006 MOVE R7 R1 + 0x7C180200, // 0007 CALL R6 1 + 0x04180D01, // 0008 SUB R6 R6 K1 + 0x401A0006, // 0009 CONNECT R6 K0 R6 + 0x7C140200, // 000A CALL R5 1 + 0xA802001A, // 000B EXBLK 0 #0027 + 0x5C180A00, // 000C MOVE R6 R5 + 0x7C180000, // 000D CALL R6 0 + 0x501C0000, // 000E LDBOOL R7 0 0 + 0x60200010, // 000F GETGBL R8 G16 + 0x6024000C, // 0010 GETGBL R9 G12 + 0x5C280400, // 0011 MOVE R10 R2 + 0x7C240200, // 0012 CALL R9 1 + 0x04241301, // 0013 SUB R9 R9 K1 + 0x40260009, // 0014 CONNECT R9 K0 R9 + 0x7C200200, // 0015 CALL R8 1 + 0xA8020007, // 0016 EXBLK 0 #001F + 0x5C241000, // 0017 MOVE R9 R8 + 0x7C240000, // 0018 CALL R9 0 + 0x94280206, // 0019 GETIDX R10 R1 R6 + 0x942C0409, // 001A GETIDX R11 R2 R9 + 0x1C28140B, // 001B EQ R10 R10 R11 + 0x782A0000, // 001C JMPF R10 #001E + 0x501C0200, // 001D LDBOOL R7 1 0 + 0x7001FFF7, // 001E JMP #0017 + 0x58200002, // 001F LDCONST R8 K2 + 0xAC200200, // 0020 CATCH R8 1 0 + 0xB0080000, // 0021 RAISE 2 R0 R0 + 0x20200807, // 0022 NE R8 R4 R7 + 0x78220001, // 0023 JMPF R8 #0026 + 0xA8040001, // 0024 EXBLK 1 1 + 0x80040C00, // 0025 RET 1 R6 + 0x7001FFE4, // 0026 JMP #000C + 0x58140002, // 0027 LDCONST R5 K2 + 0xAC140200, // 0028 CATCH R5 1 0 + 0xB0080000, // 0029 RAISE 2 R0 R0 + 0x5415FFFE, // 002A LDINT R5 -1 + 0x80040A00, // 002B RET 1 R5 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: set_timer ********************************************************************/ @@ -941,35 +466,79 @@ be_local_closure(set_timer, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 4]) { /* constants */ - be_nested_string("_timers", -1694866380, 7), /* R256 - K0 */ - be_nested_string("push", -2022703139, 4), /* R257 - K1 */ - be_nested_string("Timer", -346839614, 5), /* R258 - K2 */ - be_nested_string("millis", 1214679063, 6), /* R259 - K3 */ + /* K0 */ be_nested_string("_timers", -1694866380, 7), + /* K1 */ be_nested_string("push", -2022703139, 4), + /* K2 */ be_nested_string("Timer", -346839614, 5), + /* K3 */ be_nested_string("millis", 1214679063, 6), }), (be_nested_const_str("set_timer", 2135414533, 9)), - (be_nested_const_str("input", -103256197, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[16]) { /* code */ - 0x88100100, // 0000 GETMBR R4 R0 R256 - 0x74120002, // 0001 JMPT R4 #0005 - 0x6010000A, // 0002 GETGBL R4 G10 - 0x7C100000, // 0003 CALL R4 0 - 0x90020004, // 0004 SETMBR R0 R256 R4 - 0x88100100, // 0005 GETMBR R4 R0 R256 - 0x8C100901, // 0006 GETMET R4 R4 R257 - 0xB81A0400, // 0007 GETNGBL R6 R258 - 0x8C1C0103, // 0008 GETMET R7 R0 R259 - 0x5C240200, // 0009 MOVE R9 R1 - 0x7C1C0400, // 000A CALL R7 2 - 0x5C200400, // 000B MOVE R8 R2 - 0x5C240600, // 000C MOVE R9 R3 - 0x7C180600, // 000D CALL R6 3 - 0x7C100400, // 000E CALL R4 2 - 0x80000000, // 000F RET 0 R0 + 0x88100100, // 0000 GETMBR R4 R0 K0 + 0x74120002, // 0001 JMPT R4 #0005 + 0x60100012, // 0002 GETGBL R4 G18 + 0x7C100000, // 0003 CALL R4 0 + 0x90020004, // 0004 SETMBR R0 K0 R4 + 0x88100100, // 0005 GETMBR R4 R0 K0 + 0x8C100901, // 0006 GETMET R4 R4 K1 + 0xB81A0400, // 0007 GETNGBL R6 K2 + 0x8C1C0103, // 0008 GETMET R7 R0 K3 + 0x5C240200, // 0009 MOVE R9 R1 + 0x7C1C0400, // 000A CALL R7 2 + 0x5C200400, // 000B MOVE R8 R2 + 0x5C240600, // 000C MOVE R9 R3 + 0x7C180600, // 000D CALL R6 3 + 0x7C100400, // 000E CALL R4 2 + 0x80000000, // 000F RET 0 }) ) ); /*******************************************************************/ + +/******************************************************************** +** Solidified function: add_rule +********************************************************************/ +be_local_closure(add_rule, /* name */ + be_nested_proto( + 5, /* nstack */ + 3, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_string("_rules", -28750191, 6), + /* K1 */ be_nested_string("function", -1630125495, 8), + /* K2 */ be_nested_string("value_error", 773297791, 11), + /* K3 */ be_nested_string("the second argument is not a function", -340392827, 37), + }), + (be_nested_const_str("add_rule", 596540743, 8)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[15]) { /* code */ + 0x880C0100, // 0000 GETMBR R3 R0 K0 + 0x740E0002, // 0001 JMPT R3 #0005 + 0x600C0013, // 0002 GETGBL R3 G19 + 0x7C0C0000, // 0003 CALL R3 0 + 0x90020003, // 0004 SETMBR R0 K0 R3 + 0x600C0004, // 0005 GETGBL R3 G4 + 0x5C100400, // 0006 MOVE R4 R2 + 0x7C0C0200, // 0007 CALL R3 1 + 0x1C0C0701, // 0008 EQ R3 R3 K1 + 0x780E0002, // 0009 JMPF R3 #000D + 0x880C0100, // 000A GETMBR R3 R0 K0 + 0x980C0202, // 000B SETIDX R3 R1 R2 + 0x70020000, // 000C JMP #000E + 0xB0060503, // 000D RAISE 1 K2 K3 + 0x80000000, // 000E RET 0 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: run_deferred ********************************************************************/ @@ -984,50 +553,327 @@ be_local_closure(run_deferred, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 8]) { /* constants */ - be_nested_string("_timers", -1694866380, 7), /* R256 - K0 */ - be_const_int(0), /* R257 - K1 */ - be_nested_string("size", 597743964, 4), /* R258 - K2 */ - be_nested_string("time_reached", 2075136773, 12), /* R259 - K3 */ - be_nested_string("due", -399437003, 3), /* R260 - K4 */ - be_nested_string("f", -485742695, 1), /* R261 - K5 */ - be_nested_string("remove", -611183107, 6), /* R262 - K6 */ - be_const_int(1), /* R263 - K7 */ + /* K0 */ be_nested_string("_timers", -1694866380, 7), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_string("size", 597743964, 4), + /* K3 */ be_nested_string("time_reached", 2075136773, 12), + /* K4 */ be_nested_string("due", -399437003, 3), + /* K5 */ be_nested_string("f", -485742695, 1), + /* K6 */ be_nested_string("remove", -611183107, 6), + /* K7 */ be_const_int(1), }), (be_nested_const_str("run_deferred", 371594696, 12)), - (be_nested_const_str("input", -103256197, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[27]) { /* code */ - 0x88040100, // 0000 GETMBR R1 R0 R256 - 0x78060017, // 0001 JMPF R1 #001A - 0x58040001, // 0002 LDCONST R1 K1 - 0x88080100, // 0003 GETMBR R2 R0 R256 - 0x8C080502, // 0004 GETMET R2 R2 R258 - 0x7C080200, // 0005 CALL R2 1 - 0x14080202, // 0006 LT R2 R1 R2 - 0x780A0011, // 0007 JMPF R2 #001A - 0x8C080103, // 0008 GETMET R2 R0 R259 - 0x88100100, // 0009 GETMBR R4 R0 R256 - 0x94100801, // 000A GETIDX R4 R4 R1 - 0x88100904, // 000B GETMBR R4 R4 R260 - 0x7C080400, // 000C CALL R2 2 - 0x780A0009, // 000D JMPF R2 #0018 - 0x88080100, // 000E GETMBR R2 R0 R256 - 0x94080401, // 000F GETIDX R2 R2 R1 - 0x88080505, // 0010 GETMBR R2 R2 R261 - 0x880C0100, // 0011 GETMBR R3 R0 R256 - 0x8C0C0706, // 0012 GETMET R3 R3 R262 - 0x5C140200, // 0013 MOVE R5 R1 - 0x7C0C0400, // 0014 CALL R3 2 - 0x5C0C0400, // 0015 MOVE R3 R2 - 0x7C0C0000, // 0016 CALL R3 0 - 0x70020000, // 0017 JMP #0019 - 0x00040307, // 0018 ADD R1 R1 R263 - 0x7001FFE8, // 0019 JMP #0003 - 0x80000000, // 001A RET 0 R0 + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x78060017, // 0001 JMPF R1 #001A + 0x58040001, // 0002 LDCONST R1 K1 + 0x88080100, // 0003 GETMBR R2 R0 K0 + 0x8C080502, // 0004 GETMET R2 R2 K2 + 0x7C080200, // 0005 CALL R2 1 + 0x14080202, // 0006 LT R2 R1 R2 + 0x780A0011, // 0007 JMPF R2 #001A + 0x8C080103, // 0008 GETMET R2 R0 K3 + 0x88100100, // 0009 GETMBR R4 R0 K0 + 0x94100801, // 000A GETIDX R4 R4 R1 + 0x88100904, // 000B GETMBR R4 R4 K4 + 0x7C080400, // 000C CALL R2 2 + 0x780A0009, // 000D JMPF R2 #0018 + 0x88080100, // 000E GETMBR R2 R0 K0 + 0x94080401, // 000F GETIDX R2 R2 R1 + 0x88080505, // 0010 GETMBR R2 R2 K5 + 0x880C0100, // 0011 GETMBR R3 R0 K0 + 0x8C0C0706, // 0012 GETMET R3 R3 K6 + 0x5C140200, // 0013 MOVE R5 R1 + 0x7C0C0400, // 0014 CALL R3 2 + 0x5C0C0400, // 0015 MOVE R3 R2 + 0x7C0C0000, // 0016 CALL R3 0 + 0x70020000, // 0017 JMP #0019 + 0x00040307, // 0018 ADD R1 R1 K7 + 0x7001FFE8, // 0019 JMP #0003 + 0x80000000, // 001A RET 0 }) ) ); /*******************************************************************/ + +/******************************************************************** +** Solidified function: cmd +********************************************************************/ +be_local_closure(cmd, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_string("json", 916562499, 4), + /* K1 */ be_nested_string("_cmd", -875145154, 4), + /* K2 */ be_nested_string("load", -435725847, 4), + /* K3 */ be_nested_string("instance", 193386898, 8), + /* K4 */ be_nested_string("response", 1499316702, 8), + }), + (be_nested_const_str("cmd", -158181397, 3)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[19]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 K0 + 0x8C0C0101, // 0001 GETMET R3 R0 K1 + 0x5C140200, // 0002 MOVE R5 R1 + 0x7C0C0400, // 0003 CALL R3 2 + 0x8C100502, // 0004 GETMET R4 R2 K2 + 0x5C180600, // 0005 MOVE R6 R3 + 0x7C100400, // 0006 CALL R4 2 + 0x60140004, // 0007 GETGBL R5 G4 + 0x5C180800, // 0008 MOVE R6 R4 + 0x7C140200, // 0009 CALL R5 1 + 0x1C140B03, // 000A EQ R5 R5 K3 + 0x78160001, // 000B JMPF R5 #000E + 0x80040800, // 000C RET 1 R4 + 0x70020003, // 000D JMP #0012 + 0x60140013, // 000E GETGBL R5 G19 + 0x7C140000, // 000F CALL R5 0 + 0x98160804, // 0010 SETIDX R5 K4 R4 + 0x80040A00, // 0011 RET 1 R5 + 0x80000000, // 0012 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: time_str +********************************************************************/ +be_local_closure(time_str, /* name */ + be_nested_proto( + 13, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[10]) { /* constants */ + /* K0 */ be_nested_string("string", 398550328, 6), + /* K1 */ be_nested_string("time_dump", -964556549, 9), + /* K2 */ be_nested_string("format", -1180859054, 6), + /* K3 */ be_nested_string("%04d-%02d-%02dT%02d:%02d:%02d", -869438695, 29), + /* K4 */ be_nested_string("year", -1367388900, 4), + /* K5 */ be_nested_string("month", -696646139, 5), + /* K6 */ be_nested_string("day", -464576003, 3), + /* K7 */ be_nested_string("hour", -1241306097, 4), + /* K8 */ be_nested_string("min", -913357481, 3), + /* K9 */ be_nested_string("sec", -1155074638, 3), + }), + (be_nested_const_str("time_str", -1681139684, 8)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[14]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 K0 + 0x8C0C0101, // 0001 GETMET R3 R0 K1 + 0x5C140200, // 0002 MOVE R5 R1 + 0x7C0C0400, // 0003 CALL R3 2 + 0x8C100502, // 0004 GETMET R4 R2 K2 + 0x58180003, // 0005 LDCONST R6 K3 + 0x941C0704, // 0006 GETIDX R7 R3 K4 + 0x94200705, // 0007 GETIDX R8 R3 K5 + 0x94240706, // 0008 GETIDX R9 R3 K6 + 0x94280707, // 0009 GETIDX R10 R3 K7 + 0x942C0708, // 000A GETIDX R11 R3 K8 + 0x94300709, // 000B GETIDX R12 R3 K9 + 0x7C101000, // 000C CALL R4 8 + 0x80040800, // 000D RET 1 R4 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: load +********************************************************************/ +be_local_closure(load, /* name */ + be_nested_proto( + 14, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[16]) { /* constants */ + /* K0 */ be_nested_string("string", 398550328, 6), + /* K1 */ be_nested_string("split", -2017972765, 5), + /* K2 */ be_nested_string(".", 722245873, 1), + /* K3 */ be_const_int(1), + /* K4 */ be_nested_string("be", 942383232, 2), + /* K5 */ be_nested_string("bec", 1336821081, 3), + /* K6 */ be_nested_string("io_error", 1970281036, 8), + /* K7 */ be_nested_string("file extension is not '.be' or '.bec'", -1199247657, 37), + /* K8 */ be_nested_string("c", -435409838, 1), + /* K9 */ be_nested_string("r", -150190315, 1), + /* K10 */ be_nested_string("close", 667630371, 5), + /* K11 */ be_nested_string("file", -1427482813, 4), + /* K12 */ be_nested_string("save", -855671224, 4), + /* K13 */ be_nested_string("log", 1062293841, 3), + /* K14 */ be_nested_string("format", -1180859054, 6), + /* K15 */ be_nested_string("BRY: could not save compiled file %s (%s)", 736659787, 41), + }), + (be_nested_const_str("load", -435725847, 4)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[68]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 K0 + 0x8C0C0501, // 0001 GETMET R3 R2 K1 + 0x5C140200, // 0002 MOVE R5 R1 + 0x58180002, // 0003 LDCONST R6 K2 + 0x7C0C0600, // 0004 CALL R3 3 + 0x6010000C, // 0005 GETGBL R4 G12 + 0x5C140600, // 0006 MOVE R5 R3 + 0x7C100200, // 0007 CALL R4 1 + 0x18100903, // 0008 LE R4 R4 K3 + 0x74120007, // 0009 JMPT R4 #0012 + 0x5411FFFE, // 000A LDINT R4 -1 + 0x94100604, // 000B GETIDX R4 R3 R4 + 0x20100904, // 000C NE R4 R4 K4 + 0x78120004, // 000D JMPF R4 #0013 + 0x5411FFFE, // 000E LDINT R4 -1 + 0x94100604, // 000F GETIDX R4 R3 R4 + 0x20100905, // 0010 NE R4 R4 K5 + 0x78120000, // 0011 JMPF R4 #0013 + 0xB0060D07, // 0012 RAISE 1 K6 K7 + 0x6010000C, // 0013 GETGBL R4 G12 + 0x5C140200, // 0014 MOVE R5 R1 + 0x7C100200, // 0015 CALL R4 1 + 0x04100903, // 0016 SUB R4 R4 K3 + 0x94100204, // 0017 GETIDX R4 R1 R4 + 0x1C100908, // 0018 EQ R4 R4 K8 + 0xA8020007, // 0019 EXBLK 0 #0022 + 0x60140011, // 001A GETGBL R5 G17 + 0x5C180200, // 001B MOVE R6 R1 + 0x581C0009, // 001C LDCONST R7 K9 + 0x7C140400, // 001D CALL R5 2 + 0x8C180B0A, // 001E GETMET R6 R5 K10 + 0x7C180200, // 001F CALL R6 1 + 0xA8040001, // 0020 EXBLK 1 1 + 0x70020006, // 0021 JMP #0029 + 0x58140006, // 0022 LDCONST R5 K6 + 0xAC140200, // 0023 CATCH R5 1 0 + 0x70020002, // 0024 JMP #0028 + 0x50140000, // 0025 LDBOOL R5 0 0 + 0x80040A00, // 0026 RET 1 R5 + 0x70020000, // 0027 JMP #0029 + 0xB0080000, // 0028 RAISE 2 R0 R0 + 0x6014000D, // 0029 GETGBL R5 G13 + 0x5C180200, // 002A MOVE R6 R1 + 0x581C000B, // 002B LDCONST R7 K11 + 0x7C140400, // 002C CALL R5 2 + 0x74120011, // 002D JMPT R4 #0040 + 0xA8020005, // 002E EXBLK 0 #0035 + 0x8C18010C, // 002F GETMET R6 R0 K12 + 0x00200308, // 0030 ADD R8 R1 K8 + 0x5C240A00, // 0031 MOVE R9 R5 + 0x7C180600, // 0032 CALL R6 3 + 0xA8040001, // 0033 EXBLK 1 1 + 0x7002000A, // 0034 JMP #0040 + 0xAC180001, // 0035 CATCH R6 0 1 + 0x70020007, // 0036 JMP #003F + 0x8C1C010D, // 0037 GETMET R7 R0 K13 + 0x8C24050E, // 0038 GETMET R9 R2 K14 + 0x582C000F, // 0039 LDCONST R11 K15 + 0x00300308, // 003A ADD R12 R1 K8 + 0x5C340C00, // 003B MOVE R13 R6 + 0x7C240800, // 003C CALL R9 4 + 0x7C1C0400, // 003D CALL R7 2 + 0x70020000, // 003E JMP #0040 + 0xB0080000, // 003F RAISE 2 R0 R0 + 0x5C180A00, // 0040 MOVE R6 R5 + 0x7C180000, // 0041 CALL R6 0 + 0x50180200, // 0042 LDBOOL R6 1 0 + 0x80040C00, // 0043 RET 1 R6 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: find_op +********************************************************************/ +be_local_closure(find_op, /* name */ + be_nested_proto( + 13, /* nstack */ + 2, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + /* K0 */ be_nested_string("string", 398550328, 6), + /* K1 */ be_nested_string("=<>!", -1630497019, 4), + /* K2 */ be_nested_string("chars_in_string", -1146182164, 15), + /* K3 */ be_const_int(0), + /* K4 */ be_nested_string("split", -2017972765, 5), + /* K5 */ be_const_int(1), + }), + (be_nested_const_str("find_op", -528253920, 7)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[42]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 K0 + 0x580C0001, // 0001 LDCONST R3 K1 + 0x8C100102, // 0002 GETMET R4 R0 K2 + 0x5C180200, // 0003 MOVE R6 R1 + 0x5C1C0600, // 0004 MOVE R7 R3 + 0x7C100600, // 0005 CALL R4 3 + 0x28140903, // 0006 GE R5 R4 K3 + 0x78160019, // 0007 JMPF R5 #0022 + 0x8C140504, // 0008 GETMET R5 R2 K4 + 0x5C1C0200, // 0009 MOVE R7 R1 + 0x5C200800, // 000A MOVE R8 R4 + 0x7C140600, // 000B CALL R5 3 + 0x94180B03, // 000C GETIDX R6 R5 K3 + 0x941C0B05, // 000D GETIDX R7 R5 K5 + 0x8C200102, // 000E GETMET R8 R0 K2 + 0x5C280E00, // 000F MOVE R10 R7 + 0x5C2C0600, // 0010 MOVE R11 R3 + 0x50300200, // 0011 LDBOOL R12 1 0 + 0x7C200800, // 0012 CALL R8 4 + 0x5C101000, // 0013 MOVE R4 R8 + 0x28200903, // 0014 GE R8 R4 K3 + 0x7822000B, // 0015 JMPF R8 #0022 + 0x8C200504, // 0016 GETMET R8 R2 K4 + 0x5C280E00, // 0017 MOVE R10 R7 + 0x5C2C0800, // 0018 MOVE R11 R4 + 0x7C200600, // 0019 CALL R8 3 + 0x94241103, // 001A GETIDX R9 R8 K3 + 0x94281105, // 001B GETIDX R10 R8 K5 + 0x602C0012, // 001C GETGBL R11 G18 + 0x7C2C0000, // 001D CALL R11 0 + 0x40301606, // 001E CONNECT R12 R11 R6 + 0x40301609, // 001F CONNECT R12 R11 R9 + 0x4030160A, // 0020 CONNECT R12 R11 R10 + 0x80041600, // 0021 RET 1 R11 + 0x60140012, // 0022 GETGBL R5 G18 + 0x7C140000, // 0023 CALL R5 0 + 0x40180A01, // 0024 CONNECT R6 R5 R1 + 0x4C180000, // 0025 LDNIL R6 + 0x40180A06, // 0026 CONNECT R6 R5 R6 + 0x4C180000, // 0027 LDNIL R6 + 0x40180A06, // 0028 CONNECT R6 R5 R6 + 0x80040A00, // 0029 RET 1 R5 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: remove_timer ********************************************************************/ @@ -1042,150 +888,52 @@ be_local_closure(remove_timer, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 7]) { /* constants */ - be_nested_string("tasmota", 424643812, 7), /* R256 - K0 */ - be_nested_string("_timers", -1694866380, 7), /* R257 - K1 */ - be_const_int(0), /* R258 - K2 */ - be_nested_string("size", 597743964, 4), /* R259 - K3 */ - be_nested_string("id", 926444256, 2), /* R260 - K4 */ - be_nested_string("remove", -611183107, 6), /* R261 - K5 */ - be_const_int(1), /* R262 - K6 */ + /* K0 */ be_nested_string("tasmota", 424643812, 7), + /* K1 */ be_nested_string("_timers", -1694866380, 7), + /* K2 */ be_const_int(0), + /* K3 */ be_nested_string("size", 597743964, 4), + /* K4 */ be_nested_string("id", 926444256, 2), + /* K5 */ be_nested_string("remove", -611183107, 6), + /* K6 */ be_const_int(1), }), (be_nested_const_str("remove_timer", -153495081, 12)), - (be_nested_const_str("input", -103256197, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[23]) { /* code */ - 0xB80A0000, // 0000 GETNGBL R2 R256 - 0x88080501, // 0001 GETMBR R2 R2 R257 - 0x780A0012, // 0002 JMPF R2 #0016 - 0x58080002, // 0003 LDCONST R2 K2 - 0xB80E0000, // 0004 GETNGBL R3 R256 - 0x880C0701, // 0005 GETMBR R3 R3 R257 - 0x8C0C0703, // 0006 GETMET R3 R3 R259 - 0x7C0C0200, // 0007 CALL R3 1 - 0x140C0403, // 0008 LT R3 R2 R3 - 0x780E000B, // 0009 JMPF R3 #0016 - 0x880C0101, // 000A GETMBR R3 R0 R257 - 0x940C0602, // 000B GETIDX R3 R3 R2 - 0x880C0704, // 000C GETMBR R3 R3 R260 - 0x1C0C0601, // 000D EQ R3 R3 R1 - 0x780E0004, // 000E JMPF R3 #0014 - 0x880C0101, // 000F GETMBR R3 R0 R257 - 0x8C0C0705, // 0010 GETMET R3 R3 R261 - 0x5C140400, // 0011 MOVE R5 R2 - 0x7C0C0400, // 0012 CALL R3 2 - 0x70020000, // 0013 JMP #0015 - 0x00080506, // 0014 ADD R2 R2 R262 - 0x7001FFED, // 0015 JMP #0004 - 0x80000000, // 0016 RET 0 R0 + 0xB80A0000, // 0000 GETNGBL R2 K0 + 0x88080501, // 0001 GETMBR R2 R2 K1 + 0x780A0012, // 0002 JMPF R2 #0016 + 0x58080002, // 0003 LDCONST R2 K2 + 0xB80E0000, // 0004 GETNGBL R3 K0 + 0x880C0701, // 0005 GETMBR R3 R3 K1 + 0x8C0C0703, // 0006 GETMET R3 R3 K3 + 0x7C0C0200, // 0007 CALL R3 1 + 0x140C0403, // 0008 LT R3 R2 R3 + 0x780E000B, // 0009 JMPF R3 #0016 + 0x880C0101, // 000A GETMBR R3 R0 K1 + 0x940C0602, // 000B GETIDX R3 R3 R2 + 0x880C0704, // 000C GETMBR R3 R3 K4 + 0x1C0C0601, // 000D EQ R3 R3 R1 + 0x780E0004, // 000E JMPF R3 #0014 + 0x880C0101, // 000F GETMBR R3 R0 K1 + 0x8C0C0705, // 0010 GETMET R3 R3 K5 + 0x5C140400, // 0011 MOVE R5 R2 + 0x7C0C0400, // 0012 CALL R3 2 + 0x70020000, // 0013 JMP #0015 + 0x00080506, // 0014 ADD R2 R2 K6 + 0x7001FFED, // 0015 JMP #0004 + 0x80000000, // 0016 RET 0 }) ) ); /*******************************************************************/ -/******************************************************************** - // Add command to list - "def add_cmd(c,f) " - "if !self._ccmd " - "self._ccmd={} " - "end " - "if type(f) == 'function' " - "self._ccmd[c]=f " - "else " - "raise 'value_error', 'the second argument is not a function' " - "end " - "end " -********************************************************************/ -/******************************************************************** -** Solidified function: add_cmd -********************************************************************/ - -be_define_local_const_str(add_cmd_str_name, "add_cmd", -933336417, 7); -be_define_local_const_str(add_cmd_str_source, "string", 398550328, 6); -be_define_local_const_str(add_cmd_str_0, "_ccmd", -2131545883, 5); -be_define_local_const_str(add_cmd_str_1, "function", -1630125495, 8); -be_define_local_const_str(add_cmd_str_2, "value_error", 773297791, 11); -be_define_local_const_str(add_cmd_str_3, "the second argument is not a function", -340392827, 37); - -static const bvalue add_cmd_ktab[4] = { - { { .s=be_local_const_str(add_cmd_str_0) }, BE_STRING}, - { { .s=be_local_const_str(add_cmd_str_1) }, BE_STRING}, - { { .s=be_local_const_str(add_cmd_str_2) }, BE_STRING}, - { { .s=be_local_const_str(add_cmd_str_3) }, BE_STRING}, -}; - -static const uint32_t add_cmd_code[15] = { - 0x880C0100, // 0000 GETMBR R3 R0 R256 - 0x740E0002, // 0001 JMPT R3 #0005 - 0x600C000B, // 0002 GETGBL R3 G11 - 0x7C0C0000, // 0003 CALL R3 0 - 0x90020003, // 0004 SETMBR R0 R256 R3 - 0x600C0015, // 0005 GETGBL R3 G21 - 0x5C100400, // 0006 MOVE R4 R2 - 0x7C0C0200, // 0007 CALL R3 1 - 0x1C0C0701, // 0008 EQ R3 R3 R257 - 0x780E0002, // 0009 JMPF R3 #000D - 0x880C0100, // 000A GETMBR R3 R0 R256 - 0x980C0202, // 000B SETIDX R3 R1 R2 - 0x70020000, // 000C JMP #000E - 0xB0060503, // 000D RAISE 1 R258 R259 - 0x80000000, // 000E RET 0 R0 -}; - -static const bproto add_cmd_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 5, // nstack - 0, // nupvals - 3, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &add_cmd_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &add_cmd_code, // code - be_local_const_str(add_cmd_str_name), // name - 15, // codesize - 4, // nconst - 0, // nproto - be_local_const_str(add_cmd_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure add_cmd_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &add_cmd_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ - /******************************************************************** - // Remove command from list - "def remove_cmd(c) " - "if self._ccmd " - "self._ccmd.remove(c) " - "end " - "end " +** Solidified function: get_light ********************************************************************/ - -/******************************************************************** -** Solidified function: remove_cmd -********************************************************************/ -be_local_closure(remove_cmd, /* name */ +be_local_closure(get_light, /* name */ be_nested_proto( - 5, /* nstack */ + 6, /* nstack */ 2, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -1193,244 +941,42 @@ be_local_closure(remove_cmd, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 2]) { /* upvals */ - { { .s=be_nested_const_str("_ccmd", -2131545883, 5) }, BE_STRING}, - { { .s=be_nested_const_str("remove", -611183107, 6) }, BE_STRING}, + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_string("tasmota.get_light() is deprecated, use light.get()", -769213649, 50), + /* K1 */ be_nested_string("light", -493019601, 5), + /* K2 */ be_nested_string("get", 1410115415, 3), }), - (be_nested_const_str("remove_cmd", -462651594, 10)), - (be_nested_const_str("string", 398550328, 6)), - ( &(const binstruction[ 7]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x780A0003, // 0001 JMPF R2 #0006 - 0x88080100, // 0002 GETMBR R2 R0 R256 - 0x8C080501, // 0003 GETMET R2 R2 R257 - 0x5C100200, // 0004 MOVE R4 R1 - 0x7C080400, // 0005 CALL R2 2 - 0x80000000, // 0006 RET 0 R0 + (be_nested_const_str("get_light", 381930476, 9)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[16]) { /* code */ + 0x60080001, // 0000 GETGBL R2 G1 + 0x580C0000, // 0001 LDCONST R3 K0 + 0x7C080200, // 0002 CALL R2 1 + 0xA40A0200, // 0003 IMPORT R2 K1 + 0x4C0C0000, // 0004 LDNIL R3 + 0x200C0203, // 0005 NE R3 R1 R3 + 0x780E0004, // 0006 JMPF R3 #000C + 0x8C0C0502, // 0007 GETMET R3 R2 K2 + 0x5C140200, // 0008 MOVE R5 R1 + 0x7C0C0400, // 0009 CALL R3 2 + 0x80040600, // 000A RET 1 R3 + 0x70020002, // 000B JMP #000F + 0x8C0C0502, // 000C GETMET R3 R2 K2 + 0x7C0C0200, // 000D CALL R3 1 + 0x80040600, // 000E RET 1 R3 + 0x80000000, // 000F RET 0 }) ) ); /*******************************************************************/ + /******************************************************************** -** Solidified function: exec_cmd +** Solidified function: exec_rules ********************************************************************/ -be_local_closure(exec_cmd, /* name */ +be_local_closure(exec_rules, /* name */ be_nested_proto( 12, /* nstack */ - 4, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 5]) { /* constants */ - be_nested_string("_ccmd", -2131545883, 5), /* R256 - K0 */ - be_nested_string("json", 916562499, 4), /* R257 - K1 */ - be_nested_string("load", -435725847, 4), /* R258 - K2 */ - be_nested_string("find_key_i", 850136726, 10), /* R259 - K3 */ - be_nested_string("resolvecmnd", 993361485, 11), /* R260 - K4 */ - }), - (be_nested_const_str("exec_cmd", 493567399, 8)), - (be_nested_const_str("string", 398550328, 6)), - ( &(const binstruction[27]) { /* code */ - 0x88100100, // 0000 GETMBR R4 R0 R256 - 0x78120016, // 0001 JMPF R4 #0019 - 0xA4120200, // 0002 IMPORT R4 R257 - 0x8C140902, // 0003 GETMET R5 R4 R258 - 0x5C1C0600, // 0004 MOVE R7 R3 - 0x7C140400, // 0005 CALL R5 2 - 0x8C180103, // 0006 GETMET R6 R0 R259 - 0x88200100, // 0007 GETMBR R8 R0 R256 - 0x5C240200, // 0008 MOVE R9 R1 - 0x7C180600, // 0009 CALL R6 3 - 0x4C1C0000, // 000A LDNIL 7 - 0x201C0C07, // 000B NE R7 R6 R7 - 0x781E000B, // 000C JMPF R7 #0019 - 0x8C1C0104, // 000D GETMET R7 R0 R260 - 0x5C240C00, // 000E MOVE R9 R6 - 0x7C1C0400, // 000F CALL R7 2 - 0x881C0100, // 0010 GETMBR R7 R0 R256 - 0x941C0E06, // 0011 GETIDX R7 R7 R6 - 0x5C200C00, // 0012 MOVE R8 R6 - 0x5C240400, // 0013 MOVE R9 R2 - 0x5C280600, // 0014 MOVE R10 R3 - 0x5C2C0A00, // 0015 MOVE R11 R5 - 0x7C1C0800, // 0016 CALL R7 4 - 0x501C0200, // 0017 LDBOOL R7 1 0 - 0x80040E00, // 0018 RET 1 R7 - 0x50100000, // 0019 LDBOOL R4 0 0 - 0x80040800, // 001A RET 1 R4 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** - // Force gc and return allocated memory - "def gc() " - "import gc " - "gc.collect() " - "return gc.allocated() " - "end " -********************************************************************/ - -/******************************************************************** -** Solidified function: gc -********************************************************************/ -be_local_closure(gc, /* name */ - be_nested_proto( - 4, /* nstack */ - 1, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 3]) { /* upvals */ - { { .s=be_nested_const_str("gc", 1042313471, 2) }, BE_STRING}, - { { .s=be_nested_const_str("collect", -1895928271, 7) }, BE_STRING}, - { { .s=be_nested_const_str("allocated", 429986098, 9) }, BE_STRING}, - }), - (be_nested_const_str("gc", 1042313471, 2)), - (be_nested_const_str("string", 398550328, 6)), - ( &(const binstruction[ 6]) { /* code */ - 0xA4060000, // 0000 IMPORT R1 R256 - 0x8C080301, // 0001 GETMET R2 R1 R257 - 0x7C080200, // 0002 CALL R2 1 - 0x8C080302, // 0003 GETMET R2 R1 R258 - 0x7C080200, // 0004 CALL R2 1 - 0x80040400, // 0005 RET 1 R2 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: event -********************************************************************/ -be_local_closure(event, /* name */ - be_nested_proto( - 19, /* nstack */ - 6, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[15]) { /* constants */ - be_nested_string("introspect", 164638290, 10), /* R256 - K0 */ - be_nested_string("every_50ms", -1911083288, 10), /* R257 - K1 */ - be_nested_string("run_deferred", 371594696, 12), /* R258 - K2 */ - be_nested_string("cmd", -158181397, 3), /* R259 - K3 */ - be_nested_string("exec_cmd", 493567399, 8), /* R260 - K4 */ - be_nested_string("rule", -64077613, 4), /* R261 - K5 */ - be_nested_string("exec_rules", 1445221092, 10), /* R262 - K6 */ - be_nested_string("gc", 1042313471, 2), /* R263 - K7 */ - be_nested_string("_drivers", -1034638311, 8), /* R264 - K8 */ - be_nested_string("get", 1410115415, 3), /* R265 - K9 */ - be_nested_string("function", -1630125495, 8), /* R266 - K10 */ - be_nested_string("string", 398550328, 6), /* R267 - K11 */ - be_nested_string("format", -1180859054, 6), /* R268 - K12 */ - be_nested_string("BRY: Exception> '%s' - %s", -2047976332, 25), /* R269 - K13 */ - be_nested_string("stop_iteration", -121173395, 14), /* R270 - K14 */ - }), - (be_nested_const_str("event", -30355297, 5)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[79]) { /* code */ - 0xA41A0000, // 0000 IMPORT R6 R256 - 0x1C1C0301, // 0001 EQ R7 R1 R257 - 0x781E0001, // 0002 JMPF R7 #0005 - 0x8C1C0102, // 0003 GETMET R7 R0 R258 - 0x7C1C0200, // 0004 CALL R7 1 - 0x1C1C0303, // 0005 EQ R7 R1 R259 - 0x781E0006, // 0006 JMPF R7 #000E - 0x8C1C0104, // 0007 GETMET R7 R0 R260 - 0x5C240400, // 0008 MOVE R9 R2 - 0x5C280600, // 0009 MOVE R10 R3 - 0x5C2C0800, // 000A MOVE R11 R4 - 0x7C1C0800, // 000B CALL R7 4 - 0x80040E00, // 000C RET 1 R7 - 0x7002003F, // 000D JMP #004E - 0x1C1C0305, // 000E EQ R7 R1 R261 - 0x781E0004, // 000F JMPF R7 #0015 - 0x8C1C0106, // 0010 GETMET R7 R0 R262 - 0x5C240800, // 0011 MOVE R9 R4 - 0x7C1C0400, // 0012 CALL R7 2 - 0x80040E00, // 0013 RET 1 R7 - 0x70020038, // 0014 JMP #004E - 0x1C1C0307, // 0015 EQ R7 R1 R263 - 0x781E0003, // 0016 JMPF R7 #001B - 0x8C1C0107, // 0017 GETMET R7 R0 R263 - 0x7C1C0200, // 0018 CALL R7 1 - 0x80040E00, // 0019 RET 1 R7 - 0x70020032, // 001A JMP #004E - 0x881C0108, // 001B GETMBR R7 R0 R264 - 0x781E0030, // 001C JMPF R7 #004E - 0x601C0000, // 001D GETGBL R7 G0 - 0x88200108, // 001E GETMBR R8 R0 R264 - 0x7C1C0200, // 001F CALL R7 1 - 0xA8020027, // 0020 EXBLK 0 #0049 - 0x5C200E00, // 0021 MOVE R8 R7 - 0x7C200000, // 0022 CALL R8 0 - 0x8C240D09, // 0023 GETMET R9 R6 R265 - 0x5C2C1000, // 0024 MOVE R11 R8 - 0x5C300200, // 0025 MOVE R12 R1 - 0x7C240600, // 0026 CALL R9 3 - 0x60280015, // 0027 GETGBL R10 G21 - 0x5C2C1200, // 0028 MOVE R11 R9 - 0x7C280200, // 0029 CALL R10 1 - 0x1C28150A, // 002A EQ R10 R10 R266 - 0x782A001B, // 002B JMPF R10 #0048 - 0xA802000E, // 002C EXBLK 0 #003C - 0x5C281200, // 002D MOVE R10 R9 - 0x5C2C1000, // 002E MOVE R11 R8 - 0x5C300400, // 002F MOVE R12 R2 - 0x5C340600, // 0030 MOVE R13 R3 - 0x5C380800, // 0031 MOVE R14 R4 - 0x5C3C0A00, // 0032 MOVE R15 R5 - 0x7C280A00, // 0033 CALL R10 5 - 0x502C0200, // 0034 LDBOOL R11 1 0 - 0x1C2C140B, // 0035 EQ R11 R10 R11 - 0x782E0002, // 0036 JMPF R11 #003A - 0x502C0200, // 0037 LDBOOL R11 1 0 - 0xA8040002, // 0038 EXBLK 1 2 - 0x80041600, // 0039 RET 1 R11 - 0xA8040001, // 003A EXBLK 1 1 - 0x7002000B, // 003B JMP #0048 - 0xAC280002, // 003C CATCH R10 0 2 - 0x70020008, // 003D JMP #0047 - 0xA4321600, // 003E IMPORT R12 R267 - 0x6034000F, // 003F GETGBL R13 G15 - 0x8C38190C, // 0040 GETMET R14 R12 R268 - 0x5840000D, // 0041 LDCONST R16 K13 - 0x5C441400, // 0042 MOVE R17 R10 - 0x5C481600, // 0043 MOVE R18 R11 - 0x7C380800, // 0044 CALL R14 4 - 0x7C340200, // 0045 CALL R13 1 - 0x70020000, // 0046 JMP #0048 - 0xB0080000, // 0047 RAISE 2 R0 R0 - 0x7001FFD7, // 0048 JMP #0021 - 0x581C000E, // 0049 LDCONST R7 K14 - 0xAC1C0200, // 004A CATCH R7 1 0 - 0xB0080000, // 004B RAISE 2 R0 R0 - 0x501C0000, // 004C LDBOOL R7 0 0 - 0x80040E00, // 004D RET 1 R7 - 0x80000000, // 004E RET 0 R0 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** -** Solidified function: add_driver -********************************************************************/ -be_local_closure(add_driver, /* name */ - be_nested_proto( - 5, /* nstack */ 2, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -1438,30 +984,65 @@ be_local_closure(add_driver, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 2]) { /* constants */ - be_nested_string("_drivers", -1034638311, 8), /* R256 - K0 */ - be_nested_string("push", -2022703139, 4), /* R257 - K1 */ + ( &(const bvalue[ 8]) { /* constants */ + /* K0 */ be_nested_string("_rules", -28750191, 6), + /* K1 */ be_nested_string("json", 916562499, 4), + /* K2 */ be_nested_string("load", -435725847, 4), + /* K3 */ be_nested_string("BRY: ERROR, bad json: ", -1579831487, 22), + /* K4 */ be_const_int(3), + /* K5 */ be_nested_string("keys", -112588595, 4), + /* K6 */ be_nested_string("try_rule", 1986449405, 8), + /* K7 */ be_nested_string("stop_iteration", -121173395, 14), }), - (be_nested_const_str("add_driver", 1654458371, 10)), - (be_nested_const_str("string", 398550328, 6)), - ( &(const binstruction[12]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x780A0004, // 0001 JMPF R2 #0007 - 0x88080100, // 0002 GETMBR R2 R0 R256 - 0x8C080501, // 0003 GETMET R2 R2 R257 - 0x5C100200, // 0004 MOVE R4 R1 - 0x7C080400, // 0005 CALL R2 2 - 0x70020003, // 0006 JMP #000B - 0x6008000A, // 0007 GETGBL R2 G10 - 0x7C080000, // 0008 CALL R2 0 - 0x400C0401, // 0009 CONNECT R3 R2 R1 - 0x90020002, // 000A SETMBR R0 R256 R2 - 0x80000000, // 000B RET 0 R0 + (be_nested_const_str("exec_rules", 1445221092, 10)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[40]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x780A0023, // 0001 JMPF R2 #0026 + 0xA40A0200, // 0002 IMPORT R2 K1 + 0x8C0C0502, // 0003 GETMET R3 R2 K2 + 0x5C140200, // 0004 MOVE R5 R1 + 0x7C0C0400, // 0005 CALL R3 2 + 0x50100000, // 0006 LDBOOL R4 0 0 + 0x4C140000, // 0007 LDNIL R5 + 0x1C140605, // 0008 EQ R5 R3 R5 + 0x78160004, // 0009 JMPF R5 #000F + 0x60140001, // 000A GETGBL R5 G1 + 0x001A0601, // 000B ADD R6 K3 R1 + 0x581C0004, // 000C LDCONST R7 K4 + 0x7C140400, // 000D CALL R5 2 + 0x70020015, // 000E JMP #0025 + 0x60140010, // 000F GETGBL R5 G16 + 0x88180100, // 0010 GETMBR R6 R0 K0 + 0x8C180D05, // 0011 GETMET R6 R6 K5 + 0x7C180200, // 0012 CALL R6 1 + 0x7C140200, // 0013 CALL R5 1 + 0xA802000C, // 0014 EXBLK 0 #0022 + 0x5C180A00, // 0015 MOVE R6 R5 + 0x7C180000, // 0016 CALL R6 0 + 0x8C1C0106, // 0017 GETMET R7 R0 K6 + 0x5C240600, // 0018 MOVE R9 R3 + 0x5C280C00, // 0019 MOVE R10 R6 + 0x882C0100, // 001A GETMBR R11 R0 K0 + 0x942C1606, // 001B GETIDX R11 R11 R6 + 0x7C1C0800, // 001C CALL R7 4 + 0x741E0001, // 001D JMPT R7 #0020 + 0x74120000, // 001E JMPT R4 #0020 + 0x50100001, // 001F LDBOOL R4 0 1 + 0x50100200, // 0020 LDBOOL R4 1 0 + 0x7001FFF2, // 0021 JMP #0015 + 0x58140007, // 0022 LDCONST R5 K7 + 0xAC140200, // 0023 CATCH R5 1 0 + 0xB0080000, // 0024 RAISE 2 R0 R0 + 0x80040800, // 0025 RET 1 R4 + 0x50080000, // 0026 LDBOOL R2 0 0 + 0x80040400, // 0027 RET 1 R2 }) ) ); /*******************************************************************/ + /******************************************************************** ** Solidified function: remove_driver ********************************************************************/ @@ -1481,558 +1062,211 @@ be_local_closure(remove_driver, /* name */ /* K2 */ be_nested_string("pop", 1362321360, 3), }), (be_nested_const_str("remove_driver", 1030243768, 13)), - (be_nested_const_str("input", -103256197, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[14]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 K0 - 0x780A000A, // 0001 JMPF R2 #000D - 0x88080100, // 0002 GETMBR R2 R0 K0 - 0x8C080501, // 0003 GETMET R2 R2 K1 - 0x5C100200, // 0004 MOVE R4 R1 - 0x7C080400, // 0005 CALL R2 2 - 0x4C0C0000, // 0006 LDNIL R3 - 0x200C0403, // 0007 NE R3 R2 R3 - 0x780E0003, // 0008 JMPF R3 #000D - 0x880C0100, // 0009 GETMBR R3 R0 K0 - 0x8C0C0702, // 000A GETMET R3 R3 K2 - 0x5C140400, // 000B MOVE R5 R2 - 0x7C0C0400, // 000C CALL R3 2 - 0x80000000, // 000D RET 0 + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x780A000A, // 0001 JMPF R2 #000D + 0x88080100, // 0002 GETMBR R2 R0 K0 + 0x8C080501, // 0003 GETMET R2 R2 K1 + 0x5C100200, // 0004 MOVE R4 R1 + 0x7C080400, // 0005 CALL R2 2 + 0x4C0C0000, // 0006 LDNIL R3 + 0x200C0403, // 0007 NE R3 R2 R3 + 0x780E0003, // 0008 JMPF R3 #000D + 0x880C0100, // 0009 GETMBR R3 R0 K0 + 0x8C0C0702, // 000A GETMET R3 R3 K2 + 0x5C140400, // 000B MOVE R5 R2 + 0x7C0C0400, // 000C CALL R3 2 + 0x80000000, // 000D RET 0 }) ) ); /*******************************************************************/ + /******************************************************************** -** Solidified function: load +** Solidified function: try_rule ********************************************************************/ -be_local_closure(load, /* name */ +be_local_closure(try_rule, /* name */ be_nested_proto( 14, /* nstack */ - 2, /* argc */ + 4, /* argc */ 0, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[16]) { /* upvals */ - { { .s=be_nested_const_str("string", 398550328, 6) }, BE_STRING}, - { { .s=be_nested_const_str("split", -2017972765, 5) }, BE_STRING}, - { { .s=be_nested_const_str(".", 722245873, 1) }, BE_STRING}, - { { .i=1 }, BE_INT}, - { { .s=be_nested_const_str("be", 942383232, 2) }, BE_STRING}, - { { .s=be_nested_const_str("bec", 1336821081, 3) }, BE_STRING}, - { { .s=be_nested_const_str("io_error", 1970281036, 8) }, BE_STRING}, - { { .s=be_nested_const_str("file extension is not '.be' or '.bec'", -1199247657, 37) }, BE_STRING}, - { { .s=be_nested_const_str("c", -435409838, 1) }, BE_STRING}, - { { .s=be_nested_const_str("r", -150190315, 1) }, BE_STRING}, - { { .s=be_nested_const_str("close", 667630371, 5) }, BE_STRING}, - { { .s=be_nested_const_str("file", -1427482813, 4) }, BE_STRING}, - { { .s=be_nested_const_str("save", -855671224, 4) }, BE_STRING}, - { { .s=be_nested_const_str("log", 1062293841, 3) }, BE_STRING}, - { { .s=be_nested_const_str("format", -1180859054, 6) }, BE_STRING}, - { { .s=be_nested_const_str("BRY: could not save compiled file %s (%s)", 736659787, 41) }, BE_STRING}, + ( &(const bvalue[17]) { /* constants */ + /* K0 */ be_nested_string("string", 398550328, 6), + /* K1 */ be_nested_string("find_op", -528253920, 7), + /* K2 */ be_nested_string("split", -2017972765, 5), + /* K3 */ be_const_int(0), + /* K4 */ be_nested_string("#", 638357778, 1), + /* K5 */ be_nested_string("find_key_i", 850136726, 10), + /* K6 */ be_nested_string("stop_iteration", -121173395, 14), + /* K7 */ be_const_int(1), + /* K8 */ be_const_int(2), + /* K9 */ be_nested_string("==", -1863000881, 2), + /* K10 */ be_nested_string("!==", 559817114, 3), + /* K11 */ be_nested_string("=", 940354920, 1), + /* K12 */ be_nested_string("!=", -1866252285, 2), + /* K13 */ be_nested_string(">", 990687777, 1), + /* K14 */ be_nested_string(">=", 284975636, 2), + /* K15 */ be_nested_string("<", 957132539, 1), + /* K16 */ be_nested_string("<=", -1795743310, 2), }), - (be_nested_const_str("load", -435725847, 4)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[68]) { /* code */ - 0xA40A0000, // 0000 IMPORT R2 R256 - 0x8C0C0501, // 0001 GETMET R3 R2 R257 - 0x5C140200, // 0002 MOVE R5 R1 - 0x58180002, // 0003 LDCONST R6 K2 - 0x7C0C0600, // 0004 CALL R3 3 - 0x60100012, // 0005 GETGBL R4 G18 - 0x5C140600, // 0006 MOVE R5 R3 - 0x7C100200, // 0007 CALL R4 1 - 0x18100903, // 0008 LE R4 R4 R259 - 0x74120007, // 0009 JMPT R4 #0012 - 0x5411FFFE, // 000A LDINT R4 -1 - 0x94100604, // 000B GETIDX R4 R3 R4 - 0x20100904, // 000C NE R4 R4 R260 - 0x78120004, // 000D JMPF R4 #0013 - 0x5411FFFE, // 000E LDINT R4 -1 - 0x94100604, // 000F GETIDX R4 R3 R4 - 0x20100905, // 0010 NE R4 R4 R261 - 0x78120000, // 0011 JMPF R4 #0013 - 0xB0060D07, // 0012 RAISE 1 R262 R263 - 0x60100012, // 0013 GETGBL R4 G18 - 0x5C140200, // 0014 MOVE R5 R1 - 0x7C100200, // 0015 CALL R4 1 - 0x04100903, // 0016 SUB R4 R4 R259 - 0x94100204, // 0017 GETIDX R4 R1 R4 - 0x1C100908, // 0018 EQ R4 R4 R264 - 0xA8020007, // 0019 EXBLK 0 #0022 - 0x6014000E, // 001A GETGBL R5 G14 - 0x5C180200, // 001B MOVE R6 R1 - 0x581C0009, // 001C LDCONST R7 K9 - 0x7C140400, // 001D CALL R5 2 - 0x8C180B0A, // 001E GETMET R6 R5 R266 - 0x7C180200, // 001F CALL R6 1 - 0xA8040001, // 0020 EXBLK 1 1 - 0x70020006, // 0021 JMP #0029 - 0x58140006, // 0022 LDCONST R5 K6 - 0xAC140200, // 0023 CATCH R5 1 0 - 0x70020002, // 0024 JMP #0028 - 0x50140000, // 0025 LDBOOL R5 0 0 - 0x80040A00, // 0026 RET 1 R5 - 0x70020000, // 0027 JMP #0029 - 0xB0080000, // 0028 RAISE 2 R0 R0 - 0x60140005, // 0029 GETGBL R5 G5 - 0x5C180200, // 002A MOVE R6 R1 - 0x581C000B, // 002B LDCONST R7 K11 - 0x7C140400, // 002C CALL R5 2 - 0x74120011, // 002D JMPT R4 #0040 - 0xA8020005, // 002E EXBLK 0 #0035 - 0x8C18010C, // 002F GETMET R6 R0 R268 - 0x00200308, // 0030 ADD R8 R1 R264 - 0x5C240A00, // 0031 MOVE R9 R5 - 0x7C180600, // 0032 CALL R6 3 - 0xA8040001, // 0033 EXBLK 1 1 - 0x7002000A, // 0034 JMP #0040 - 0xAC180001, // 0035 CATCH R6 0 1 - 0x70020007, // 0036 JMP #003F - 0x8C1C010D, // 0037 GETMET R7 R0 R269 - 0x8C24050E, // 0038 GETMET R9 R2 R270 - 0x582C000F, // 0039 LDCONST R11 K15 - 0x00300308, // 003A ADD R12 R1 R264 - 0x5C340C00, // 003B MOVE R13 R6 - 0x7C240800, // 003C CALL R9 4 - 0x7C1C0400, // 003D CALL R7 2 - 0x70020000, // 003E JMP #0040 - 0xB0080000, // 003F RAISE 2 R0 R0 - 0x5C180A00, // 0040 MOVE R6 R5 - 0x7C180000, // 0041 CALL R6 0 - 0x50180200, // 0042 LDBOOL R6 1 0 - 0x80040C00, // 0043 RET 1 R6 + (be_nested_const_str("try_rule", 1986449405, 8)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[143]) { /* code */ + 0xA4120000, // 0000 IMPORT R4 K0 + 0x8C140101, // 0001 GETMET R5 R0 K1 + 0x5C1C0400, // 0002 MOVE R7 R2 + 0x7C140400, // 0003 CALL R5 2 + 0x5C180200, // 0004 MOVE R6 R1 + 0x8C1C0902, // 0005 GETMET R7 R4 K2 + 0x94240B03, // 0006 GETIDX R9 R5 K3 + 0x58280004, // 0007 LDCONST R10 K4 + 0x7C1C0600, // 0008 CALL R7 3 + 0x60200010, // 0009 GETGBL R8 G16 + 0x5C240E00, // 000A MOVE R9 R7 + 0x7C200200, // 000B CALL R8 1 + 0xA802000D, // 000C EXBLK 0 #001B + 0x5C241000, // 000D MOVE R9 R8 + 0x7C240000, // 000E CALL R9 0 + 0x8C280105, // 000F GETMET R10 R0 K5 + 0x5C300C00, // 0010 MOVE R12 R6 + 0x5C341200, // 0011 MOVE R13 R9 + 0x7C280600, // 0012 CALL R10 3 + 0x4C2C0000, // 0013 LDNIL R11 + 0x1C2C140B, // 0014 EQ R11 R10 R11 + 0x782E0002, // 0015 JMPF R11 #0019 + 0x502C0000, // 0016 LDBOOL R11 0 0 + 0xA8040001, // 0017 EXBLK 1 1 + 0x80041600, // 0018 RET 1 R11 + 0x94180C0A, // 0019 GETIDX R6 R6 R10 + 0x7001FFF1, // 001A JMP #000D + 0x58200006, // 001B LDCONST R8 K6 + 0xAC200200, // 001C CATCH R8 1 0 + 0xB0080000, // 001D RAISE 2 R0 R0 + 0x94200B07, // 001E GETIDX R8 R5 K7 + 0x94240B08, // 001F GETIDX R9 R5 K8 + 0x78220066, // 0020 JMPF R8 #0088 + 0x1C281109, // 0021 EQ R10 R8 K9 + 0x782A000A, // 0022 JMPF R10 #002E + 0x60280008, // 0023 GETGBL R10 G8 + 0x5C2C0C00, // 0024 MOVE R11 R6 + 0x7C280200, // 0025 CALL R10 1 + 0x602C0008, // 0026 GETGBL R11 G8 + 0x5C301200, // 0027 MOVE R12 R9 + 0x7C2C0200, // 0028 CALL R11 1 + 0x2028140B, // 0029 NE R10 R10 R11 + 0x782A0001, // 002A JMPF R10 #002D + 0x50280000, // 002B LDBOOL R10 0 0 + 0x80041400, // 002C RET 1 R10 + 0x70020059, // 002D JMP #0088 + 0x1C28110A, // 002E EQ R10 R8 K10 + 0x782A000A, // 002F JMPF R10 #003B + 0x60280008, // 0030 GETGBL R10 G8 + 0x5C2C0C00, // 0031 MOVE R11 R6 + 0x7C280200, // 0032 CALL R10 1 + 0x602C0008, // 0033 GETGBL R11 G8 + 0x5C301200, // 0034 MOVE R12 R9 + 0x7C2C0200, // 0035 CALL R11 1 + 0x1C28140B, // 0036 EQ R10 R10 R11 + 0x782A0001, // 0037 JMPF R10 #003A + 0x50280000, // 0038 LDBOOL R10 0 0 + 0x80041400, // 0039 RET 1 R10 + 0x7002004C, // 003A JMP #0088 + 0x1C28110B, // 003B EQ R10 R8 K11 + 0x782A000A, // 003C JMPF R10 #0048 + 0x6028000A, // 003D GETGBL R10 G10 + 0x5C2C0C00, // 003E MOVE R11 R6 + 0x7C280200, // 003F CALL R10 1 + 0x602C000A, // 0040 GETGBL R11 G10 + 0x5C301200, // 0041 MOVE R12 R9 + 0x7C2C0200, // 0042 CALL R11 1 + 0x2028140B, // 0043 NE R10 R10 R11 + 0x782A0001, // 0044 JMPF R10 #0047 + 0x50280000, // 0045 LDBOOL R10 0 0 + 0x80041400, // 0046 RET 1 R10 + 0x7002003F, // 0047 JMP #0088 + 0x1C28110C, // 0048 EQ R10 R8 K12 + 0x782A000A, // 0049 JMPF R10 #0055 + 0x6028000A, // 004A GETGBL R10 G10 + 0x5C2C0C00, // 004B MOVE R11 R6 + 0x7C280200, // 004C CALL R10 1 + 0x602C000A, // 004D GETGBL R11 G10 + 0x5C301200, // 004E MOVE R12 R9 + 0x7C2C0200, // 004F CALL R11 1 + 0x1C28140B, // 0050 EQ R10 R10 R11 + 0x782A0001, // 0051 JMPF R10 #0054 + 0x50280000, // 0052 LDBOOL R10 0 0 + 0x80041400, // 0053 RET 1 R10 + 0x70020032, // 0054 JMP #0088 + 0x1C28110D, // 0055 EQ R10 R8 K13 + 0x782A000A, // 0056 JMPF R10 #0062 + 0x6028000A, // 0057 GETGBL R10 G10 + 0x5C2C0C00, // 0058 MOVE R11 R6 + 0x7C280200, // 0059 CALL R10 1 + 0x602C000A, // 005A GETGBL R11 G10 + 0x5C301200, // 005B MOVE R12 R9 + 0x7C2C0200, // 005C CALL R11 1 + 0x1828140B, // 005D LE R10 R10 R11 + 0x782A0001, // 005E JMPF R10 #0061 + 0x50280000, // 005F LDBOOL R10 0 0 + 0x80041400, // 0060 RET 1 R10 + 0x70020025, // 0061 JMP #0088 + 0x1C28110E, // 0062 EQ R10 R8 K14 + 0x782A000A, // 0063 JMPF R10 #006F + 0x6028000A, // 0064 GETGBL R10 G10 + 0x5C2C0C00, // 0065 MOVE R11 R6 + 0x7C280200, // 0066 CALL R10 1 + 0x602C000A, // 0067 GETGBL R11 G10 + 0x5C301200, // 0068 MOVE R12 R9 + 0x7C2C0200, // 0069 CALL R11 1 + 0x1428140B, // 006A LT R10 R10 R11 + 0x782A0001, // 006B JMPF R10 #006E + 0x50280000, // 006C LDBOOL R10 0 0 + 0x80041400, // 006D RET 1 R10 + 0x70020018, // 006E JMP #0088 + 0x1C28110F, // 006F EQ R10 R8 K15 + 0x782A000A, // 0070 JMPF R10 #007C + 0x6028000A, // 0071 GETGBL R10 G10 + 0x5C2C0C00, // 0072 MOVE R11 R6 + 0x7C280200, // 0073 CALL R10 1 + 0x602C000A, // 0074 GETGBL R11 G10 + 0x5C301200, // 0075 MOVE R12 R9 + 0x7C2C0200, // 0076 CALL R11 1 + 0x2828140B, // 0077 GE R10 R10 R11 + 0x782A0001, // 0078 JMPF R10 #007B + 0x50280000, // 0079 LDBOOL R10 0 0 + 0x80041400, // 007A RET 1 R10 + 0x7002000B, // 007B JMP #0088 + 0x1C281110, // 007C EQ R10 R8 K16 + 0x782A0009, // 007D JMPF R10 #0088 + 0x6028000A, // 007E GETGBL R10 G10 + 0x5C2C0C00, // 007F MOVE R11 R6 + 0x7C280200, // 0080 CALL R10 1 + 0x602C000A, // 0081 GETGBL R11 G10 + 0x5C301200, // 0082 MOVE R12 R9 + 0x7C2C0200, // 0083 CALL R11 1 + 0x2428140B, // 0084 GT R10 R10 R11 + 0x782A0001, // 0085 JMPF R10 #0088 + 0x50280000, // 0086 LDBOOL R10 0 0 + 0x80041400, // 0087 RET 1 R10 + 0x5C280600, // 0088 MOVE R10 R3 + 0x5C2C0C00, // 0089 MOVE R11 R6 + 0x94300B03, // 008A GETIDX R12 R5 K3 + 0x5C340200, // 008B MOVE R13 R1 + 0x7C280600, // 008C CALL R10 3 + 0x50280200, // 008D LDBOOL R10 1 0 + 0x80041400, // 008E RET 1 R10 }) ) ); /*******************************************************************/ -/******************************************************************** - // tasmota.wire_scan(addr:int [, index:int]) -> wire1 or wire2 or nil - // scan for the first occurrence of the addr, starting with bus1 then bus2 - // optional: skip if index is disabled via I2CEnable - "def wire_scan(addr,idx) " - // skip if the I2C index is disabled - "if idx != nil && !self.i2c_enabled(idx) return nil end " - "if self.wire1.detect(addr) return self.wire1 end " - "if self.wire2.detect(addr) return self.wire2 end " - "return nil " - "end " -********************************************************************/ -/******************************************************************** -** Solidified function: wire_scan -********************************************************************/ - -be_define_local_const_str(wire_scan_str_name, "wire_scan", -1623691416, 9); -be_define_local_const_str(wire_scan_str_source, "string", 398550328, 6); -be_define_local_const_str(wire_scan_str_0, "i2c_enabled", 218388101, 11); -be_define_local_const_str(wire_scan_str_1, "wire1", -1082245877, 5); -be_define_local_const_str(wire_scan_str_2, "detect", 8884370, 6); -be_define_local_const_str(wire_scan_str_3, "wire2", -1065468258, 5); - -static const bvalue wire_scan_ktab[4] = { - { { .s=be_local_const_str(wire_scan_str_0) }, BE_STRING}, - { { .s=be_local_const_str(wire_scan_str_1) }, BE_STRING}, - { { .s=be_local_const_str(wire_scan_str_2) }, BE_STRING}, - { { .s=be_local_const_str(wire_scan_str_3) }, BE_STRING}, -}; - -static const uint32_t wire_scan_code[25] = { - 0x4C0C0000, // 0000 LDNIL 3 - 0x200C0403, // 0001 NE R3 R2 R3 - 0x780E0005, // 0002 JMPF R3 #0009 - 0x8C0C0100, // 0003 GETMET R3 R0 R256 - 0x5C140400, // 0004 MOVE R5 R2 - 0x7C0C0400, // 0005 CALL R3 2 - 0x740E0001, // 0006 JMPT R3 #0009 - 0x4C0C0000, // 0007 LDNIL 3 - 0x80040600, // 0008 RET 1 R3 - 0x880C0101, // 0009 GETMBR R3 R0 R257 - 0x8C0C0702, // 000A GETMET R3 R3 R258 - 0x5C140200, // 000B MOVE R5 R1 - 0x7C0C0400, // 000C CALL R3 2 - 0x780E0001, // 000D JMPF R3 #0010 - 0x880C0101, // 000E GETMBR R3 R0 R257 - 0x80040600, // 000F RET 1 R3 - 0x880C0103, // 0010 GETMBR R3 R0 R259 - 0x8C0C0702, // 0011 GETMET R3 R3 R258 - 0x5C140200, // 0012 MOVE R5 R1 - 0x7C0C0400, // 0013 CALL R3 2 - 0x780E0001, // 0014 JMPF R3 #0017 - 0x880C0103, // 0015 GETMBR R3 R0 R259 - 0x80040600, // 0016 RET 1 R3 - 0x4C0C0000, // 0017 LDNIL 3 - 0x80040600, // 0018 RET 1 R3 -}; - -static const bproto wire_scan_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 6, // nstack - 0, // nupvals - 3, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &wire_scan_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &wire_scan_code, // code - be_local_const_str(wire_scan_str_name), // name - 25, // codesize - 4, // nconst - 0, // nproto - be_local_const_str(wire_scan_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure wire_scan_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &wire_scan_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ - -/******************************************************************** - def time_str(time) - import string - var tm = self.time_dump(time) - return string.format("%04d-%02d-%02dT%02d:%02d:%02d", tm['year'], tm['month'], tm['day'], tm['hour'], tm['min'], tm['sec']) - end -********************************************************************/ -/******************************************************************** -** Solidified function: time_str -********************************************************************/ -be_local_closure(time_str, /* name */ - be_nested_proto( - 13, /* nstack */ - 2, /* argc */ - 0, /* varg */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[10]) { /* constants */ - be_nested_string("string", 398550328, 6), - be_nested_string("time_dump", -964556549, 9), - be_nested_string("format", -1180859054, 6), - be_nested_string("%04d-%02d-%02dT%02d:%02d:%02d", -869438695, 29), - be_nested_string("year", -1367388900, 4), - be_nested_string("month", -696646139, 5), - be_nested_string("day", -464576003, 3), - be_nested_string("hour", -1241306097, 4), - be_nested_string("min", -913357481, 3), - be_nested_string("sec", -1155074638, 3), - }), - (be_nested_const_str("time_str", -1681139684, 8)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[14]) { /* code */ - 0xA40A0000, // 0000 IMPORT R2 R256 - 0x8C0C0101, // 0001 GETMET R3 R0 R257 - 0x5C140200, // 0002 MOVE R5 R1 - 0x7C0C0400, // 0003 CALL R3 2 - 0x8C100502, // 0004 GETMET R4 R2 R258 - 0x58180003, // 0005 LDCONST R6 K3 - 0x941C0704, // 0006 GETIDX R7 R3 R260 - 0x94200705, // 0007 GETIDX R8 R3 R261 - 0x94240706, // 0008 GETIDX R9 R3 R262 - 0x94280707, // 0009 GETIDX R10 R3 R263 - 0x942C0708, // 000A GETIDX R11 R3 R264 - 0x94300709, // 000B GETIDX R12 R3 R265 - 0x7C101000, // 000C CALL R4 8 - 0x80040800, // 000D RET 1 R4 - }) - ) -); -/*******************************************************************/ - -/******************************************************************** - // cmd high-level function - "def cmd(command) " - "import json " - "var ret = self._cmd(command) " - "var j = json.load(ret) " - "if type(j) == 'instance' " - "return j " - "else " - "return {'response':j} " - "end " - "end " -********************************************************************/ -/******************************************************************** -** Solidified function: cmd -********************************************************************/ - -be_define_local_const_str(cmd_str_name, "cmd", -158181397, 3); -be_define_local_const_str(cmd_str_source, "string", 398550328, 6); -be_define_local_const_str(cmd_str_0, "json", 916562499, 4); -be_define_local_const_str(cmd_str_1, "_cmd", -875145154, 4); -be_define_local_const_str(cmd_str_2, "load", -435725847, 4); -be_define_local_const_str(cmd_str_3, "instance", 193386898, 8); -be_define_local_const_str(cmd_str_4, "response", 1499316702, 8); - -static const bvalue cmd_ktab[5] = { - { { .s=be_local_const_str(cmd_str_0) }, BE_STRING}, - { { .s=be_local_const_str(cmd_str_1) }, BE_STRING}, - { { .s=be_local_const_str(cmd_str_2) }, BE_STRING}, - { { .s=be_local_const_str(cmd_str_3) }, BE_STRING}, - { { .s=be_local_const_str(cmd_str_4) }, BE_STRING}, -}; - -static const uint32_t cmd_code[19] = { - 0xA40A0000, // 0000 IMPORT R2 R256 - 0x8C0C0101, // 0001 GETMET R3 R0 R257 - 0x5C140200, // 0002 MOVE R5 R1 - 0x7C0C0400, // 0003 CALL R3 2 - 0x8C100502, // 0004 GETMET R4 R2 R258 - 0x5C180600, // 0005 MOVE R6 R3 - 0x7C100400, // 0006 CALL R4 2 - 0x60140015, // 0007 GETGBL R5 G21 - 0x5C180800, // 0008 MOVE R6 R4 - 0x7C140200, // 0009 CALL R5 1 - 0x1C140B03, // 000A EQ R5 R5 R259 - 0x78160001, // 000B JMPF R5 #000E - 0x80040800, // 000C RET 1 R4 - 0x70020003, // 000D JMP #0012 - 0x6014000B, // 000E GETGBL R5 G11 - 0x7C140000, // 000F CALL R5 0 - 0x98160804, // 0010 SETIDX R5 R260 R4 - 0x80040A00, // 0011 RET 1 R5 - 0x80000000, // 0012 RET 0 R0 -}; - -static const bproto cmd_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 7, // nstack - 0, // nupvals - 2, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &cmd_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &cmd_code, // code - be_local_const_str(cmd_str_name), // name - 19, // codesize - 5, // nconst - 0, // nproto - be_local_const_str(cmd_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure cmd_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &cmd_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ - - -/******************************************************************** - "def get_light(l) " - "print('tasmota.get_light() is deprecated, use light.get()') " - "import light " - "if l != nil " - "return light.get(l) " - "else " - "return light.get() " - "end " - "end " -********************************************************************/ -/******************************************************************** -** Solidified function: get_light -********************************************************************/ - -be_define_local_const_str(get_light_str_name, "get_light", 381930476, 9); -be_define_local_const_str(get_light_str_source, "string", 398550328, 6); -be_define_local_const_str(get_light_str_0, "tasmota.get_light() is deprecated, use light.get()", -769213649, 50); -be_define_local_const_str(get_light_str_1, "light", -493019601, 5); -be_define_local_const_str(get_light_str_2, "get", 1410115415, 3); - -static const bvalue get_light_ktab[3] = { - { { .s=be_local_const_str(get_light_str_0) }, BE_STRING}, - { { .s=be_local_const_str(get_light_str_1) }, BE_STRING}, - { { .s=be_local_const_str(get_light_str_2) }, BE_STRING}, -}; - -static const uint32_t get_light_code[16] = { - 0x6008000F, // 0000 GETGBL R2 G15 - 0x580C0000, // 0001 LDCONST R3 K0 - 0x7C080200, // 0002 CALL R2 1 - 0xA40A0200, // 0003 IMPORT R2 R257 - 0x4C0C0000, // 0004 LDNIL 3 - 0x200C0203, // 0005 NE R3 R1 R3 - 0x780E0004, // 0006 JMPF R3 #000C - 0x8C0C0502, // 0007 GETMET R3 R2 R258 - 0x5C140200, // 0008 MOVE R5 R1 - 0x7C0C0400, // 0009 CALL R3 2 - 0x80040600, // 000A RET 1 R3 - 0x70020002, // 000B JMP #000F - 0x8C0C0502, // 000C GETMET R3 R2 R258 - 0x7C0C0200, // 000D CALL R3 1 - 0x80040600, // 000E RET 1 R3 - 0x80000000, // 000F RET 0 R0 -}; - -static const bproto get_light_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 6, // nstack - 0, // nupvals - 2, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &get_light_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &get_light_code, // code - be_local_const_str(get_light_str_name), // name - 16, // codesize - 3, // nconst - 0, // nproto - be_local_const_str(get_light_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure get_light_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &get_light_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ - -/******************************************************************** - - // set_light and get_light deprecetaion - "def set_light(v,l) " - "print('tasmota.set_light() is deprecated, use light.set()') " - "import light " - "if l != nil " - "return light.set(v,l) " - "else " - "return light.set(v) " - "end " - "end " - -********************************************************************/ -/******************************************************************** -** Solidified function: set_light -********************************************************************/ - -be_define_local_const_str(set_light_str_name, "set_light", -1118891144, 9); -be_define_local_const_str(set_light_str_source, "string", 398550328, 6); -be_define_local_const_str(set_light_str_0, "tasmota.set_light() is deprecated, use light.set()", 2124937871, 50); -be_define_local_const_str(set_light_str_1, "light", -493019601, 5); -be_define_local_const_str(set_light_str_2, "set", -970520829, 3); - -static const bvalue set_light_ktab[3] = { - { { .s=be_local_const_str(set_light_str_0) }, BE_STRING}, - { { .s=be_local_const_str(set_light_str_1) }, BE_STRING}, - { { .s=be_local_const_str(set_light_str_2) }, BE_STRING}, -}; - -static const uint32_t set_light_code[18] = { - 0x600C000F, // 0000 GETGBL R3 G15 - 0x58100000, // 0001 LDCONST R4 K0 - 0x7C0C0200, // 0002 CALL R3 1 - 0xA40E0200, // 0003 IMPORT R3 R257 - 0x4C100000, // 0004 LDNIL 4 - 0x20100404, // 0005 NE R4 R2 R4 - 0x78120005, // 0006 JMPF R4 #000D - 0x8C100702, // 0007 GETMET R4 R3 R258 - 0x5C180200, // 0008 MOVE R6 R1 - 0x5C1C0400, // 0009 MOVE R7 R2 - 0x7C100600, // 000A CALL R4 3 - 0x80040800, // 000B RET 1 R4 - 0x70020003, // 000C JMP #0011 - 0x8C100702, // 000D GETMET R4 R3 R258 - 0x5C180200, // 000E MOVE R6 R1 - 0x7C100400, // 000F CALL R4 2 - 0x80040800, // 0010 RET 1 R4 - 0x80000000, // 0011 RET 0 R0 -}; - -static const bproto set_light_proto = { - NULL, // bgcobject *next - 8, // type - 0x08, // marked - 8, // nstack - 0, // nupvals - 3, // argc - 0, // varg - NULL, // bgcobject *gray - NULL, // bupvaldesc *upvals - (bvalue*) &set_light_ktab, // ktab - NULL, // bproto **ptab - (binstruction*) &set_light_code, // code - be_local_const_str(set_light_str_name), // name - 18, // codesize - 3, // nconst - 0, // nproto - be_local_const_str(set_light_str_source), // source -#if BE_DEBUG_RUNTIME_INFO /* debug information */ - NULL, // lineinfo - 0, // nlineinfo -#endif -#if BE_DEBUG_VAR_INFO - NULL, // varinfo - 0, // nvarinfo -#endif -}; - -static const bclosure set_light_closure = { - NULL, // bgcobject *next - 36, // type - 0x08, // marked - 0, // nupvals - NULL, // bgcobject *gray - (bproto*) &set_light_proto, // proto - { NULL } // upvals -}; - -/*******************************************************************/ /******************************************************************** ** Solidified function: cb_dispatch @@ -2048,44 +1282,196 @@ be_local_closure(cb_dispatch, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 3]) { /* constants */ - be_nested_string("_cb", -251666929, 3), - be_const_int(0), - be_nested_string("find", -1108310694, 4), + /* K0 */ be_nested_string("_cb", -251666929, 3), + /* K1 */ be_const_int(0), + /* K2 */ be_nested_string("find", -1108310694, 4), }), (be_nested_const_str("cb_dispatch", 1741510499, 11)), - (be_nested_const_str("input", -103256197, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), ( &(const binstruction[20]) { /* code */ - 0x88180100, // 0000 GETMBR R6 R0 R256 - 0x4C1C0000, // 0001 LDNIL 7 - 0x1C180C07, // 0002 EQ R6 R6 R7 - 0x781A0000, // 0003 JMPF R6 #0005 - 0x80060200, // 0004 RET 1 R257 - 0x88180100, // 0005 GETMBR R6 R0 R256 - 0x8C180D02, // 0006 GETMET R6 R6 R258 - 0x5C200200, // 0007 MOVE R8 R1 - 0x7C180400, // 0008 CALL R6 2 - 0x4C1C0000, // 0009 LDNIL 7 - 0x201C0C07, // 000A NE R7 R6 R7 - 0x781E0006, // 000B JMPF R7 #0013 - 0x5C1C0C00, // 000C MOVE R7 R6 - 0x5C200400, // 000D MOVE R8 R2 - 0x5C240600, // 000E MOVE R9 R3 - 0x5C280800, // 000F MOVE R10 R4 - 0x5C2C0A00, // 0010 MOVE R11 R5 - 0x7C1C0800, // 0011 CALL R7 4 - 0x80040E00, // 0012 RET 1 R7 - 0x80060200, // 0013 RET 1 R257 + 0x88180100, // 0000 GETMBR R6 R0 K0 + 0x4C1C0000, // 0001 LDNIL R7 + 0x1C180C07, // 0002 EQ R6 R6 R7 + 0x781A0000, // 0003 JMPF R6 #0005 + 0x80060200, // 0004 RET 1 K1 + 0x88180100, // 0005 GETMBR R6 R0 K0 + 0x8C180D02, // 0006 GETMET R6 R6 K2 + 0x5C200200, // 0007 MOVE R8 R1 + 0x7C180400, // 0008 CALL R6 2 + 0x4C1C0000, // 0009 LDNIL R7 + 0x201C0C07, // 000A NE R7 R6 R7 + 0x781E0006, // 000B JMPF R7 #0013 + 0x5C1C0C00, // 000C MOVE R7 R6 + 0x5C200400, // 000D MOVE R8 R2 + 0x5C240600, // 000E MOVE R9 R3 + 0x5C280800, // 000F MOVE R10 R4 + 0x5C2C0A00, // 0010 MOVE R11 R5 + 0x7C1C0800, // 0011 CALL R7 4 + 0x80040E00, // 0012 RET 1 R7 + 0x80060200, // 0013 RET 1 K1 }) ) ); /*******************************************************************/ + /******************************************************************** -** Solidified function: gen_cb +** Solidified function: gc ********************************************************************/ -be_local_closure(gen_cb, /* name */ +be_local_closure(gc, /* name */ be_nested_proto( - 7, /* nstack */ + 4, /* nstack */ + 1, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_string("gc", 1042313471, 2), + /* K1 */ be_nested_string("collect", -1895928271, 7), + /* K2 */ be_nested_string("allocated", 429986098, 9), + }), + (be_nested_const_str("gc", 1042313471, 2)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[ 6]) { /* code */ + 0xA4060000, // 0000 IMPORT R1 K0 + 0x8C080301, // 0001 GETMET R2 R1 K1 + 0x7C080200, // 0002 CALL R2 1 + 0x8C080302, // 0003 GETMET R2 R1 K2 + 0x7C080200, // 0004 CALL R2 1 + 0x80040400, // 0005 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: event +********************************************************************/ +be_local_closure(event, /* name */ + be_nested_proto( + 19, /* nstack */ + 6, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[15]) { /* constants */ + /* K0 */ be_nested_string("introspect", 164638290, 10), + /* K1 */ be_nested_string("every_50ms", -1911083288, 10), + /* K2 */ be_nested_string("run_deferred", 371594696, 12), + /* K3 */ be_nested_string("cmd", -158181397, 3), + /* K4 */ be_nested_string("exec_cmd", 493567399, 8), + /* K5 */ be_nested_string("rule", -64077613, 4), + /* K6 */ be_nested_string("exec_rules", 1445221092, 10), + /* K7 */ be_nested_string("gc", 1042313471, 2), + /* K8 */ be_nested_string("_drivers", -1034638311, 8), + /* K9 */ be_nested_string("get", 1410115415, 3), + /* K10 */ be_nested_string("function", -1630125495, 8), + /* K11 */ be_nested_string("string", 398550328, 6), + /* K12 */ be_nested_string("format", -1180859054, 6), + /* K13 */ be_nested_string("BRY: Exception> '%s' - %s", -2047976332, 25), + /* K14 */ be_nested_string("stop_iteration", -121173395, 14), + }), + (be_nested_const_str("event", -30355297, 5)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[79]) { /* code */ + 0xA41A0000, // 0000 IMPORT R6 K0 + 0x1C1C0301, // 0001 EQ R7 R1 K1 + 0x781E0001, // 0002 JMPF R7 #0005 + 0x8C1C0102, // 0003 GETMET R7 R0 K2 + 0x7C1C0200, // 0004 CALL R7 1 + 0x1C1C0303, // 0005 EQ R7 R1 K3 + 0x781E0006, // 0006 JMPF R7 #000E + 0x8C1C0104, // 0007 GETMET R7 R0 K4 + 0x5C240400, // 0008 MOVE R9 R2 + 0x5C280600, // 0009 MOVE R10 R3 + 0x5C2C0800, // 000A MOVE R11 R4 + 0x7C1C0800, // 000B CALL R7 4 + 0x80040E00, // 000C RET 1 R7 + 0x7002003F, // 000D JMP #004E + 0x1C1C0305, // 000E EQ R7 R1 K5 + 0x781E0004, // 000F JMPF R7 #0015 + 0x8C1C0106, // 0010 GETMET R7 R0 K6 + 0x5C240800, // 0011 MOVE R9 R4 + 0x7C1C0400, // 0012 CALL R7 2 + 0x80040E00, // 0013 RET 1 R7 + 0x70020038, // 0014 JMP #004E + 0x1C1C0307, // 0015 EQ R7 R1 K7 + 0x781E0003, // 0016 JMPF R7 #001B + 0x8C1C0107, // 0017 GETMET R7 R0 K7 + 0x7C1C0200, // 0018 CALL R7 1 + 0x80040E00, // 0019 RET 1 R7 + 0x70020032, // 001A JMP #004E + 0x881C0108, // 001B GETMBR R7 R0 K8 + 0x781E0030, // 001C JMPF R7 #004E + 0x601C0010, // 001D GETGBL R7 G16 + 0x88200108, // 001E GETMBR R8 R0 K8 + 0x7C1C0200, // 001F CALL R7 1 + 0xA8020027, // 0020 EXBLK 0 #0049 + 0x5C200E00, // 0021 MOVE R8 R7 + 0x7C200000, // 0022 CALL R8 0 + 0x8C240D09, // 0023 GETMET R9 R6 K9 + 0x5C2C1000, // 0024 MOVE R11 R8 + 0x5C300200, // 0025 MOVE R12 R1 + 0x7C240600, // 0026 CALL R9 3 + 0x60280004, // 0027 GETGBL R10 G4 + 0x5C2C1200, // 0028 MOVE R11 R9 + 0x7C280200, // 0029 CALL R10 1 + 0x1C28150A, // 002A EQ R10 R10 K10 + 0x782A001B, // 002B JMPF R10 #0048 + 0xA802000E, // 002C EXBLK 0 #003C + 0x5C281200, // 002D MOVE R10 R9 + 0x5C2C1000, // 002E MOVE R11 R8 + 0x5C300400, // 002F MOVE R12 R2 + 0x5C340600, // 0030 MOVE R13 R3 + 0x5C380800, // 0031 MOVE R14 R4 + 0x5C3C0A00, // 0032 MOVE R15 R5 + 0x7C280A00, // 0033 CALL R10 5 + 0x502C0200, // 0034 LDBOOL R11 1 0 + 0x1C2C140B, // 0035 EQ R11 R10 R11 + 0x782E0002, // 0036 JMPF R11 #003A + 0x502C0200, // 0037 LDBOOL R11 1 0 + 0xA8040002, // 0038 EXBLK 1 2 + 0x80041600, // 0039 RET 1 R11 + 0xA8040001, // 003A EXBLK 1 1 + 0x7002000B, // 003B JMP #0048 + 0xAC280002, // 003C CATCH R10 0 2 + 0x70020008, // 003D JMP #0047 + 0xA4321600, // 003E IMPORT R12 K11 + 0x60340001, // 003F GETGBL R13 G1 + 0x8C38190C, // 0040 GETMET R14 R12 K12 + 0x5840000D, // 0041 LDCONST R16 K13 + 0x5C441400, // 0042 MOVE R17 R10 + 0x5C481600, // 0043 MOVE R18 R11 + 0x7C380800, // 0044 CALL R14 4 + 0x7C340200, // 0045 CALL R13 1 + 0x70020000, // 0046 JMP #0048 + 0xB0080000, // 0047 RAISE 2 R0 R0 + 0x7001FFD7, // 0048 JMP #0021 + 0x581C000E, // 0049 LDCONST R7 K14 + 0xAC1C0200, // 004A CATCH R7 1 0 + 0xB0080000, // 004B RAISE 2 R0 R0 + 0x501C0000, // 004C LDBOOL R7 0 0 + 0x80040E00, // 004D RET 1 R7 + 0x80000000, // 004E RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: remove_cmd +********************************************************************/ +be_local_closure(remove_cmd, /* name */ + be_nested_proto( + 5, /* nstack */ 2, /* argc */ 0, /* varg */ 0, /* has upvals */ @@ -2093,52 +1479,76 @@ be_local_closure(gen_cb, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 7]) { /* constants */ - be_nested_string("_cb", -251666929, 3), - be_const_int(0), - be_nested_string("find", -1108310694, 4), - be_nested_string("_get_cb", 1448849122, 7), - be_nested_string("stop_iteration", -121173395, 14), - be_nested_string("internal_error", -1775809127, 14), - be_nested_string("No callback available", 633786138, 21), + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_string("_ccmd", -2131545883, 5), + /* K1 */ be_nested_string("remove", -611183107, 6), }), - (be_nested_const_str("gen_cb", -1049739745, 6)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[34]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x4C0C0000, // 0001 LDNIL 3 - 0x1C080403, // 0002 EQ R2 R2 R3 - 0x780A0002, // 0003 JMPF R2 #0007 - 0x6008000B, // 0004 GETGBL R2 G11 - 0x7C080000, // 0005 CALL R2 0 - 0x90020002, // 0006 SETMBR R0 R256 R2 - 0x60080000, // 0007 GETGBL R2 G0 - 0x540E0012, // 0008 LDINT R3 19 - 0x400E0203, // 0009 CONNECT R3 R257 R3 - 0x7C080200, // 000A CALL R2 1 - 0xA8020010, // 000B EXBLK 0 #001D - 0x5C0C0400, // 000C MOVE R3 R2 - 0x7C0C0000, // 000D CALL R3 0 - 0x88100100, // 000E GETMBR R4 R0 R256 - 0x8C100902, // 000F GETMET R4 R4 R258 - 0x5C180600, // 0010 MOVE R6 R3 - 0x7C100400, // 0011 CALL R4 2 - 0x4C140000, // 0012 LDNIL 5 - 0x1C100805, // 0013 EQ R4 R4 R5 - 0x78120006, // 0014 JMPF R4 #001C - 0x88100100, // 0015 GETMBR R4 R0 R256 - 0x98100601, // 0016 SETIDX R4 R3 R1 - 0x8C100103, // 0017 GETMET R4 R0 R259 - 0x5C180600, // 0018 MOVE R6 R3 - 0x7C100400, // 0019 CALL R4 2 - 0xA8040001, // 001A EXBLK 1 1 - 0x80040800, // 001B RET 1 R4 - 0x7001FFEE, // 001C JMP #000C - 0x58080004, // 001D LDCONST R2 K4 - 0xAC080200, // 001E CATCH R2 1 0 - 0xB0080000, // 001F RAISE 2 R0 R0 - 0xB0060B06, // 0020 RAISE 1 R261 R262 - 0x80000000, // 0021 RET 0 R0 + (be_nested_const_str("remove_cmd", -462651594, 10)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[ 7]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x780A0003, // 0001 JMPF R2 #0006 + 0x88080100, // 0002 GETMBR R2 R0 K0 + 0x8C080501, // 0003 GETMET R2 R2 K1 + 0x5C100200, // 0004 MOVE R4 R1 + 0x7C080400, // 0005 CALL R2 2 + 0x80000000, // 0006 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: exec_cmd +********************************************************************/ +be_local_closure(exec_cmd, /* name */ + be_nested_proto( + 12, /* nstack */ + 4, /* argc */ + 0, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 5]) { /* constants */ + /* K0 */ be_nested_string("_ccmd", -2131545883, 5), + /* K1 */ be_nested_string("json", 916562499, 4), + /* K2 */ be_nested_string("load", -435725847, 4), + /* K3 */ be_nested_string("find_key_i", 850136726, 10), + /* K4 */ be_nested_string("resolvecmnd", 993361485, 11), + }), + (be_nested_const_str("exec_cmd", 493567399, 8)), + (be_nested_const_str("Tasmota.be", 825809411, 10)), + ( &(const binstruction[27]) { /* code */ + 0x88100100, // 0000 GETMBR R4 R0 K0 + 0x78120016, // 0001 JMPF R4 #0019 + 0xA4120200, // 0002 IMPORT R4 K1 + 0x8C140902, // 0003 GETMET R5 R4 K2 + 0x5C1C0600, // 0004 MOVE R7 R3 + 0x7C140400, // 0005 CALL R5 2 + 0x8C180103, // 0006 GETMET R6 R0 K3 + 0x88200100, // 0007 GETMBR R8 R0 K0 + 0x5C240200, // 0008 MOVE R9 R1 + 0x7C180600, // 0009 CALL R6 3 + 0x4C1C0000, // 000A LDNIL R7 + 0x201C0C07, // 000B NE R7 R6 R7 + 0x781E000B, // 000C JMPF R7 #0019 + 0x8C1C0104, // 000D GETMET R7 R0 K4 + 0x5C240C00, // 000E MOVE R9 R6 + 0x7C1C0400, // 000F CALL R7 2 + 0x881C0100, // 0010 GETMBR R7 R0 K0 + 0x941C0E06, // 0011 GETIDX R7 R7 R6 + 0x5C200C00, // 0012 MOVE R8 R6 + 0x5C240400, // 0013 MOVE R9 R2 + 0x5C280600, // 0014 MOVE R10 R3 + 0x5C2C0A00, // 0015 MOVE R11 R5 + 0x7C1C0800, // 0016 CALL R7 4 + 0x501C0200, // 0017 LDBOOL R7 1 0 + 0x80040E00, // 0018 RET 1 R7 + 0x50100000, // 0019 LDBOOL R4 0 0 + 0x80040800, // 001A RET 1 R4 }) ) ); diff --git a/lib/libesp32/Berry/default/be_timer_class.c b/lib/libesp32/Berry/default/be_timer_class.c index 4ee9d0ade..e6c495851 100644 --- a/lib/libesp32/Berry/default/be_timer_class.c +++ b/lib/libesp32/Berry/default/be_timer_class.c @@ -19,35 +19,35 @@ be_local_closure(tostring, /* name */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 6]) { /* constants */ - be_nested_string("string", 398550328, 6), /* R256 - K0 */ - be_nested_string("format", -1180859054, 6), /* R257 - K1 */ - be_nested_string("= 1 && be_isfunction(vm, 1)) { + size_t arg_count = top - 1; /* we have at least 'top - 1' arguments */ + /* test if last argument is a list */ + + if (top > 1 && be_isinstance(vm, top) && be_getmember(vm, top, ".p") && be_islist(vm, top + 1)) { + int32_t list_size = be_data_size(vm, top + 1); + + if (list_size > 0) { + be_stack_require(vm, list_size + 3); /* make sure we don't overflow the stack */ + for (int i = 0; i < list_size; i++) { + be_pushnil(vm); + } + be_moveto(vm, top + 1, top + 1 + list_size); + be_moveto(vm, top, top + list_size); + + be_refpush(vm, -2); + be_pushiter(vm, -1); + while (be_iter_hasnext(vm, -2)) { + be_iter_next(vm, -2); + be_moveto(vm, -1, top); + top++; + be_pop(vm, 1); + } + be_pop(vm, 1); /* remove iterator */ + be_refpop(vm); + } + be_pop(vm, 2); + arg_count = arg_count - 1 + list_size; + } + /* actual call */ + be_call(vm, arg_count); + /* remove args */ + be_pop(vm, arg_count); + /* return value */ + + be_return(vm); + } + be_raise(vm, "value_error", "first argument must be a function"); + be_return_nil(vm); +} + static int l_str(bvm *vm) { if (be_top(vm)) { @@ -407,6 +456,12 @@ void be_load_baselib(bvm *vm) be_regfunc(vm, "isinstance", l_isinstance); be_regfunc(vm, "__iterator__", l_iterator); } + +/* call must be added later to respect order of builtins */ +void be_load_baselib_call(bvm *vm) +{ + be_regfunc(vm, "call", l_call); +} #else extern const bclass be_class_list; extern const bclass be_class_map; @@ -437,6 +492,7 @@ vartab m_builtin (scope: local) { map, class(be_class_map) range, class(be_class_range) bytes, class(be_class_bytes) + call, func(l_call) } @const_object_info_end */ #include "../generate/be_fixed_m_builtin.h" diff --git a/lib/libesp32/Berry/src/be_introspectlib.c b/lib/libesp32/Berry/src/be_introspectlib.c index 5254b9791..fc9dac898 100644 --- a/lib/libesp32/Berry/src/be_introspectlib.c +++ b/lib/libesp32/Berry/src/be_introspectlib.c @@ -76,62 +76,12 @@ static int m_setmember(bvm *vm) be_return_nil(vm); } -/* call a function with variable number of arguments */ -/* first argument is a callable object (function, closure, native function, native closure) */ -/* then all subsequent arguments are pushed except the last one */ -/* If the last argument is a 'list', then all elements are pushed as arguments */ -/* otherwise the last argument is pushed as well */ -static int m_vcall(bvm *vm) -{ - int top = be_top(vm); - if (top >= 1 && be_isfunction(vm, 1)) { - size_t arg_count = top - 1; /* we have at least 'top - 1' arguments */ - /* test if last argument is a list */ - - if (top > 1 && be_isinstance(vm, top) && be_getmember(vm, top, ".p") && be_islist(vm, top + 1)) { - int32_t list_size = be_data_size(vm, top + 1); - - if (list_size > 0) { - be_stack_require(vm, list_size + 3); /* make sure we don't overflow the stack */ - for (int i = 0; i < list_size; i++) { - be_pushnil(vm); - } - be_moveto(vm, top + 1, top + 1 + list_size); - be_moveto(vm, top, top + list_size); - - be_refpush(vm, -2); - be_pushiter(vm, -1); - while (be_iter_hasnext(vm, -2)) { - be_iter_next(vm, -2); - be_moveto(vm, -1, top); - top++; - be_pop(vm, 1); - } - be_pop(vm, 1); /* remove iterator */ - be_refpop(vm); - } - be_pop(vm, 2); - arg_count = arg_count - 1 + list_size; - } - /* actual call */ - be_call(vm, arg_count); - /* remove args */ - be_pop(vm, arg_count); - /* return value */ - - be_return(vm); - } - be_raise(vm, "value_error", "first argument must be a function"); - be_return_nil(vm); -} - #if !BE_USE_PRECOMPILED_OBJECT be_native_module_attr_table(introspect) { be_native_module_function("members", m_attrlist), be_native_module_function("get", m_findmember), be_native_module_function("set", m_setmember), - be_native_module_function("vcall", m_vcall), }; be_define_native_module(introspect, NULL); @@ -142,7 +92,6 @@ module introspect (scope: global, depend: BE_USE_INTROSPECT_MODULE) { get, func(m_findmember) set, func(m_setmember) - vcall, func(m_vcall) } @const_object_info_end */ #include "../generate/be_fixed_introspect.h" diff --git a/lib/libesp32/Berry/src/be_libs.c b/lib/libesp32/Berry/src/be_libs.c index a4c774df4..0c55717f3 100644 --- a/lib/libesp32/Berry/src/be_libs.c +++ b/lib/libesp32/Berry/src/be_libs.c @@ -8,6 +8,7 @@ #include "be_libs.h" extern void be_load_baselib(bvm *vm); +extern void be_load_baselib_call(bvm *vm); extern void be_load_listlib(bvm *vm); extern void be_load_maplib(bvm *vm); extern void be_load_rangelib(bvm *vm); @@ -23,5 +24,6 @@ void be_loadlibs(bvm *vm) be_load_rangelib(vm); be_load_filelib(vm); be_load_byteslib(vm); + be_load_baselib_call(vm); #endif } diff --git a/lib/libesp32/Berry/tools/coc/block_builder.cpp b/lib/libesp32/Berry/tools/coc/block_builder.cpp index 9cf05be95..acea6777c 100755 --- a/lib/libesp32/Berry/tools/coc/block_builder.cpp +++ b/lib/libesp32/Berry/tools/coc/block_builder.cpp @@ -33,10 +33,12 @@ block_builder::block_builder(const object_block *object, const macro_table *macr m_strtab.push_back(it->second); } - for (auto i : object->data) { - if (i.second.depend.empty() || macro->query(i.second.depend)) { - m_block.data[i.first] = i.second.value; - m_strtab.push_back(i.first); + for (auto key : object->data_ordered) { + auto second = object->data.at(key); + if (second.depend.empty() || macro->query(second.depend)) { + m_block.data[key] = second.value; + m_strtab.push_back(key); + m_block.data_ordered.push_back(key); /* record insertion order */ } } } @@ -106,10 +108,9 @@ std::string block_builder::vartab_tostring(const block &block) idxblk = block; idxblk.data.clear(); - for (auto it : block.data) { - varvec.push_back(it.second); - it.second = "int(" + std::to_string(index++) + ")"; - idxblk.data.insert(it); + for (auto key : block.data_ordered) { + varvec.push_back(block.data.at(key)); + idxblk.data[key] = "int(" + std::to_string(index++) + ")"; } ostr << map_tostring(idxblk, block.name + "_map", true) << std::endl; diff --git a/lib/libesp32/Berry/tools/coc/block_builder.h b/lib/libesp32/Berry/tools/coc/block_builder.h index 7eb82bd3e..1a45ada3e 100755 --- a/lib/libesp32/Berry/tools/coc/block_builder.h +++ b/lib/libesp32/Berry/tools/coc/block_builder.h @@ -28,6 +28,7 @@ private: std::string name; std::map attr; std::map data; + std::vector data_ordered; /* used to retrieve in insertion order */ }; std::string block_tostring(const block &block); diff --git a/lib/libesp32/Berry/tools/coc/coc_parser.cpp b/lib/libesp32/Berry/tools/coc/coc_parser.cpp index f1e86ecb5..2bbd69965 100644 --- a/lib/libesp32/Berry/tools/coc/coc_parser.cpp +++ b/lib/libesp32/Berry/tools/coc/coc_parser.cpp @@ -186,4 +186,5 @@ void coc_parser::parse_body_item(object_block *object) if (parse_char_continue(',')) value.depend = parse_tonewline(); object->data[key] = value; + object->data_ordered.push_back(key); } diff --git a/lib/libesp32/Berry/tools/coc/object_block.h b/lib/libesp32/Berry/tools/coc/object_block.h index 474545457..c437f2b62 100644 --- a/lib/libesp32/Berry/tools/coc/object_block.h +++ b/lib/libesp32/Berry/tools/coc/object_block.h @@ -20,6 +20,7 @@ struct object_block { std::string name; std::map attr; std::map data; + std::vector data_ordered; /* preserve order of keys */ }; #endif diff --git a/lib/libesp32/Berry/tools/grammar/berry.bytecode b/lib/libesp32/Berry/tools/grammar/berry.bytecode index 2c265fb5c..2d71dde22 100755 --- a/lib/libesp32/Berry/tools/grammar/berry.bytecode +++ b/lib/libesp32/Berry/tools/grammar/berry.bytecode @@ -80,7 +80,7 @@ class: method_count: 4 -- number of method method_table: [ string -- method name - function -- method function body + function | nil -- method function body or nil (static member) if the first byte is null (which would be an empty func name) ](method_count) member_index_table -> [ string -- member name diff --git a/lib/libesp32/Berry/tools/grammar/berry.ebnf b/lib/libesp32/Berry/tools/grammar/berry.ebnf index dedf72a90..1ca79a763 100644 --- a/lib/libesp32/Berry/tools/grammar/berry.ebnf +++ b/lib/libesp32/Berry/tools/grammar/berry.ebnf @@ -17,7 +17,7 @@ func_body = '(' [arg_field {',' arg_field}] ')' block 'end'; arg_field = ['*'] ID; (* class define statement *) class_stmt = 'class' ID [':' ID] class_block 'end'; -class_block = {'var' ID {',' ID} | func_stmt}; +class_block = {'var' ID {',' ID} | 'static' ID ['=' expr] {',' ID ['=' expr] } | func_stmt}; import_stmt = 'import' (ID (['as' ID] | {',' ID}) | STRING 'as' ID); (* exceptional handling statement *) try_stmt = 'try' block except_block {except_block} 'end'; diff --git a/tasmota/berry/modules/partition.bec b/tasmota/berry/modules/partition.bec index 712196d537203ebf1a12c8c9b9340ee9b65e5f35..48ce1d2abfe586533deb754b170042627960b504 100644 GIT binary patch delta 5739 zcmaJ_Z){sv6+iF2`~LX(*?xI>b{xk|+{8`1H0{zh+e+81)hJBsS{TFHqRCt0wr+`N zlj3+=HZ0jg6Zk`h%3cLu01atKAO>{mK0JwNF!5&+XiV?{!MJLkUe^gB=4ufB0jCj5=?5B|J&a`1NPt=wg_3Fy`mDO`gPuJ>ewRP2@)AiE__Ai~T*QyN+ zS5KX*jtx;WCuYE~P(gW3cW2LdOwz{;kdUj2_i9ntvCZXtK z&<>GtLY9rZAhVGqV>#{JCB8LE*`yyQr<|iqSvBmVLbflHY&8?!zr=wZlu!C8-P*Lt zT_lmMkY+WNN$m<2YdhXAVx!(~HQU>=3~yB}On>ZA4XUoMH|jXNs*(4+dRix%!5V4r zL-n+j_8!xI3A1@S^`}LGsO)`5pV)PndoXE9~>C20JL zWVk}aU6M#(BhltILGneJ#7ibxiL7O^9X}ScH%;#iV`c{~0YObG>r1e+s?vG`Mn-$~ ze0BW`UM#j-3svduiyddJeL42kR*L8XrV(i`N@Ofz(M4IZJ4(#XkCC$>KvSc>guaGx z7n?IJ6&k(-C)nWrMA&zA^bN9?RmlZUuB@4^fDM`=>EK)zY!S|9{uVqZPr(Fhae+^V zg>a($KG4j8&Ewd7cQl!KSRf0u>4=tyXi3m^MzmB!vq8&8G$j<2=eIV7Fp!A`#Pxv< z2Xs54xBBSAptJh<#O*%13wrNl&qQ=SSQ>OmwF@%7n+oSL&5USdfFJ8YvUc1{B_A6Z3_d-FJfHl;9YirO!uxzl5t}k} zr9iI&o})_Hj>c-RM3ZFE#>Hpnjy(7e$?x)k)>1#>CTG9R%?I{}fP+1K3wGa5miYpc zhDFHqC0zgRza7vrpczd?!R5!DQ{bjSgc9;4MIE4-pn-1;b9#JaIlc@b1Gm-O65h_~j*R!ATQ+l({RHa*Gx zeBuUY@lLu6y#6!p15h^5j~wq$?pN@QdrP+WX!@IoFd_JgMceyt`rX|`Qy8;IEMr@o zRx}?YvnClYSRvW}R{;GxKfIKf!>&6baO zt0SLN6*_tBHt*GuhboW-dy*uu0{e#P%WT$`Q|_ihvoeh%KhuI;U}^#RIQp|{FuSec zN7bpZcIv4HFtw-mv)OxaNSqm9togF{a&}}K2?1gMdiBX3n<{|K)icaR-uu~M{7>B< z>gHNkWfOEHAudaB8$K1m`ijcBFqQ>;JdnXm`WmoCSKvkwKvIw9Jvurf8Q$Zg_o-p< z{@LhVY?}X!zS+WsIf!j-==D+7HJQL8(cH^;Bpc9<(VU=USrL{Yt2RYZ*^pzl0C*jh zaK9A8x~%B%Jjx?x6@Yv2K+~@L@BxN$H?LD>gUpOi8t@I?slk)=M0S(RLS+TQHaRf< z^SzMS0&}p5aE&P3Q-Q<2$Qp72fN8qeG}}=v_p%D_lQ9>{4gUWK%wt?*S}aK4M1Xxb zA3XHOV-xmZV&eU7>?91dgEfx{wzo6?+Kn;qLUpxzu2%Q{nm-;ThrRH^YLZC9A#ZEWHDNE7Pl~P9{ z6G%U|$mWc3YjQ4h^IQ{i<2+Xh=fbZ7J_~S1Eu;pCm|Jq$=_un%0g#OQ0tr=;ii^P{ zqhxVHMS?@+jXWvv#377uOQNgnEyvyKyn5hgA-@f0@1H*u^;>al(LY{abeF^>*x*juotjokJ)wZ~x2ei!ks zPM(TVzpKvFYYL*Zmf~J{=GGw# z=@`6l`+_FC%QFwg5JIc#7m#Rpf1CLl@ccpcB_;G%z-<9V!$vO?7ttNK7Y9?pBSn49 z`(A0Pr2|A6P`gS{P*_L8EXp#FF-6}7IZ>toY2%Rg=Q@Bp%Dyeuy{o#RrZ$sC6?v|0;dtwAG!Q0~gW$>e#bgtG| zs-AAFJW)d(I$*2c-|}3aP9K>))U(_-X5W$?imwCIeNR5SpD= zkWMA_&~@~f?W#z$$#HxW!7CL6vpg(|@&ogskma5Wh4COtR^fI-9E^A`1TaUjJHs6O zK*#wV-$f@KMaG{5*D{2QOyt3L4V*I5cgkzsM0o@YGV0QN#vhGtTMqs^hFjKE#>=>6 z7S~A;fLc*&0F_&nAaT^(yiA!!o?$yk7&DC>qo}6`7Sz=&o*HruA+kk{a?nK1Hxa(a z8RkW?LI#49k!@hn{dN~+FOBIK(|co1IF>9KW3hlH%)1?^xdh2d zEvPy8z%`!rT?mq9K|~3C`QjdI%GuHszGX6ADxmH6=)D03ut&3m$Ec2$gzvupJW)rNY^ zyEvZqN>fu;GY3cHX^oE60XB7%d)ukvQj{li4HNd*=vk7mG$@^BdqO1wjNPDr-*$eq7IJ<4wr*Saw-1{Z7q zfaUEweB=bDlR+h5*b9KG%KNAQ_>rlXScEf-1!SxNOa;gz@vqeFcIk#^PVeRXi1+Km w6DPxJm64AtEUtjK&<8-^bt9|@IR*zwFw%bD8nFt4H`M5XRH5pbu$-g+0kZuePXGV_ delta 5763 zcmaJ_Z){uFbwBUD`~L9piF~A~p?z!jReLsHd-Ou$t{JTdQ;je(-bNJa*sdY9syETiRZ#VAN z+XgK>|CFHD8tuAEFP;DNatwB;d3Skrv$@%}dG`8dt84M3v9YdDo$g!Bx|*%GH{aY+ zvqo#JepgX#uKbZ2YrXcWnyl2?@z`y7%x0zA+NgEgjqQ|@Q)}I=bz+fsYVB@X0q@jT z-&on)R`ORN-&N49#_AjOwxU>TZ*Hw^-fP8b)ZSdLD{fE`>=m%ttF6?VN^-NlrZ_bl zt-4ZyCmZ!{Jw9Nw(dnw)8=Z9sRkCo3jaugowQZ}GaBpumoAtIL?KB%}^|m7IY&BZL zZ9H!!B)!hPMtAj&Ql?v5X~M=hJ!W?s^?T|N-THR7)~?s$MWb0~j7{D6mJDict_%FD zt?Ah5&~o$cdUJVo#rySa8EWPpuhtr!tr|p{bPrd0`CL4n7qq_B*fgoxSiggVZo$fp zZez1$((BDy=Z-}k+(v6XMfd6}oq8LNAx|6OD|uRNuUDybMg1Ez~lpr)oBt{DDf9OXU4AqcNKF-qutlYsgh8z zY6|N_+3IcV(E|NG6vrO1lYZxybMhVSsj26|fykNHb*CuE#oahnUH(Y>(!N*7tEMSm znV~|(bo^^V_aBh%MV|aK{lbBHU?*&EH$%Z9iExQ5FES2VdtkQX%OB~l3WsVPSus}4 z6M*URLt|Cby*diXvJ zxTiUxFeXCMNI;O-;c{T5`-8*PXazX z*&ioxf`S3yWO%bW=Gw^&6>JYy5KCmnFdeXKG0<6JXP<_%g>WoQ3;U!OmxMOkCsA73 zr`6g{KqJQAq$1*Yb_tTAA>DP**=g*xic5oRyq9540wV|X;0M7w%C`g|37%E; z*Ayi8dGqq~-qUl8o97&2h+U1mMI8=dXhC1#WTsZ^!+Rsr#SW4W$^Y`cB6lagA)m>7 zEN8O6>YW1cda`-&ai+rFg5x5lka!TWgP-LAD*)z1x`B9A@i~JvJWbc{>*g5D0St8e zvB#j8?j{VSK_O&=2%cQjO&|Cf;150vMt*b?r)F(QR~BQB=@JF=CIo1dkLO@)YOoe) z*dppQKlBgFbndczG550ka_(Ag2AILeR)sXqJx)aO=ebYstKhmx_%MF3L;`yI`h8}R zlJogn@?rjz{7L?X=>p`+XD0u|%wtCKqscF(rg_FSLaqk?Y#zltFRxGSPaz3Z0SEuh zsS8hqY%6ji6Sf%2&>_=8wo?(Q3$hiCZH5|w%W&lPr(Tt(3%76j;7Xdn&e-Z2TfLXB z46?D+hq;ttiaTz?(40Q!Q*}n11T}_CRQb)7x4QL?{J8MkNgE)(SPfn==w-kzzF3Xo z!=rSOX;8a%Pu`w>uEr;QG%(q6eNBi5nla?=b`8_o({V-t=VFPRyG?|TW#CSeS}_V6 zWM?Xt8^Azu9RcedTmEYLC3!u(EdMn8`=0wWV8GAAY}G%Y3|t|DwC+TwIIRm0Y2AzB z#N|7>9nc}T3s^dOI>5R8YwS+K^&c1$7fE--<~-nTQl=1P9Cuz{q4-R!>Jz-;dx@G48fv#Kdkwoc_Ow z6|D!_1qAX$%EzV0ievyAx?mOul)ZBY9{#NOFItfua(Fz>NhA;~FbR8|{O^O`>9rLB z5-7^2#${Ld5EHNGadG-Yh%?VF3Zv8?WKq}iCC@a?)N{M6Kscg+KSrDzTj$5tLxm@y44N5~iccyVB=q?a zg{Bf%`WA$X5#fadVT=$@j|m(y9G)&r@O-cP_+J0=@XAB)$cKh`1}l>PaO|~XS7AAe z>lv~(YTbi@5y!D(hy9dY>~pBOa^d)y9CsL_!GpH+_)YoI`F&D9u^~TuA~-xA3NJ!e zfi$Hh9&F05o;cdGP+Yjs3=Gv0c~|4s$U~n-$=qSBRF#ERDQNXgd#19G+`r4_6h+*5 z><{x)s-`DP@C!Jba~5VU!6$wbKf!qKZ0|P+GGh$0V{3nGJrtN53iK|5=hI8%eo}Bg z*~jLe#6J|U^?Fx+r#vBlT;7#;pLpisUqA7E?RU7od?FOdf19rmskBcHXPC#W15BxK zMuNlEck$an%_8})Pku(8ntKVqWAe*$C*-&1uJ%H7BSQxNUmE)lS{qq-q0DC$(`hW4-vDs=ZvT6^rxQ!2)KK~#V{n`RhjG}9F#ELo^+oKJ1!(-|(3 zXmQCwws6A8f+hAN5C?{;d7dT0B7wdLrb-zRI@YDkecuRSfiOCdj0@nG1HZiD7e;Rk zEpZ$5;9wGsby(t1(nO%n%%Zv4o&{qUFn$Jd4RLY1hZ74u8suP|xT=R-)m5KY=pKDR ze*VnNzS0ZU9{LRhKAaA~uCRR!u>ErH%+X%jj5QpdOC$ zQ{xz0VQyTS?u}y{UFmzNy3$hkM+yb$V<))Y)Tc&{_9qX<)>9ThLq2 zm*l@)I{c|2zlpK^@uwE#1|(SSo=klF!gtAftBa3at+j`@KK1+hX_sniYs+iu+p3x6 z&uPmHxKnGb;k%(Z^7TvQXnbUonalox5d89-*vUcvi{8r+r5st?_&Bqhm(N~4s^w+v za%18I=(cRT}0_v z`URR_W2A1!JDiK?_EgDGPgRZoYlFdnIy%zUWI0G)G9bf{K&*B8n5U0xx-mf Rb&F_(c_-c|I4~yo`yZYeLPY=o