Berry simplified solidification

This commit is contained in:
Stephan Hadinger 2021-04-28 08:49:22 +02:00
parent 22356d511b
commit deee1bb69c
6 changed files with 449 additions and 509 deletions

View File

@ -30,8 +30,8 @@ static const bupvaldesc add_cmd_0_upvals[2] = {
be_local_const_upval(1, 0),
};
be_define_local_const_str(add_cmd_0_str_name, "add_cmd_0", 607256038, 0, 8, 0);
be_define_local_const_str(add_cmd_0_str_source, "input", -103256197, 0, 5, 0);
be_define_local_const_str(add_cmd_0_str_name, "add_cmd_0", 607256038, 8);
be_define_local_const_str(add_cmd_0_str_source, "input", -103256197, 5);
static const uint32_t add_cmd_0_code[8] = {
0x68100000, // 0000 GETUPV R4 U0
@ -51,10 +51,10 @@ static const bproto *add_cmd_subproto[1] = {
&add_cmd_0_proto,
};
be_define_local_const_str(add_cmd_str_name, "add_cmd", -933336417, 0, 7, 0);
be_define_local_const_str(add_cmd_str_source, "input", -103256197, 0, 5, 0);
be_define_local_const_str(add_cmd_str_0, "get_tasmota", 334356779, 0, 11, 0);
be_define_local_const_str(add_cmd_str_1, "add_cmd", -933336417, 0, 7, 0);
be_define_local_const_str(add_cmd_str_name, "add_cmd", -933336417, 7);
be_define_local_const_str(add_cmd_str_source, "input", -103256197, 5);
be_define_local_const_str(add_cmd_str_0, "get_tasmota", 334356779, 11);
be_define_local_const_str(add_cmd_str_1, "add_cmd", -933336417, 7);
static const bvalue add_cmd_ktab[2] = {
{ { .s=be_local_const_str(add_cmd_str_0) }, BE_STRING},

View File

@ -10,6 +10,9 @@
#ifdef USE_LVGL
// temporary work-around
#define be_define_local_const_str2(a,b,c,d,e,f) be_define_local_const_str(a,b,c,e)
#include "lvgl.h"
extern int lv0_start(bvm *vm);
@ -632,67 +635,67 @@ be_define_native_module(lvgl, NULL);
#else
be_define_local_const_str(SYMBOL_AUDIO, "\xef\x80\x81", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_VIDEO, "\xef\x80\x88", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_LIST, "\xef\x80\x8b", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_OK, "\xef\x80\x8c", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_CLOSE, "\xef\x80\x8d", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_POWER, "\xef\x80\x91", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_SETTINGS, "\xef\x80\x93", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_HOME, "\xef\x80\x95", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_DOWNLOAD, "\xef\x80\x99", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_DRIVE, "\xef\x80\x9c", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_REFRESH, "\xef\x80\xa1", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_MUTE, "\xef\x80\xa6", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_VOLUME_MID, "\xef\x80\xa7", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_VOLUME_MAX, "\xef\x80\xa8", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_IMAGE, "\xef\x80\xbe", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_EDIT, "\xef\x8C\x84", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_PREV, "\xef\x81\x88", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_PLAY, "\xef\x81\x8b", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_PAUSE, "\xef\x81\x8c", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_STOP, "\xef\x81\x8d", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_NEXT, "\xef\x81\x91", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_EJECT, "\xef\x81\x92", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_LEFT, "\xef\x81\x93", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_RIGHT, "\xef\x81\x94", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_PLUS, "\xef\x81\xa7", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_MINUS, "\xef\x81\xa8", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_EYE_OPEN, "\xef\x81\xae", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_EYE_CLOSE, "\xef\x81\xb0", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_WARNING, "\xef\x81\xb1", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_SHUFFLE, "\xef\x81\xb4", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_UP, "\xef\x81\xb7", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_DOWN, "\xef\x81\xb8", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_LOOP, "\xef\x81\xb9", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_DIRECTORY, "\xef\x81\xbb", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_UPLOAD, "\xef\x82\x93", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_CALL, "\xef\x82\x95", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_CUT, "\xef\x83\x84", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_COPY, "\xef\x83\x85", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_SAVE, "\xef\x83\x87", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_CHARGE, "\xef\x83\xa7", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_PASTE, "\xef\x83\xAA", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BELL, "\xef\x83\xb3", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_KEYBOARD, "\xef\x84\x9c", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_GPS, "\xef\x84\xa4", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_FILE, "\xef\x85\x9b", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_WIFI, "\xef\x87\xab", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BATTERY_FULL, "\xef\x89\x80", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BATTERY_3, "\xef\x89\x81", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BATTERY_2, "\xef\x89\x82", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BATTERY_1, "\xef\x89\x83", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BATTERY_EMPTY, "\xef\x89\x84", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_USB, "\xef\x8a\x87", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BLUETOOTH, "\xef\x8a\x93", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_TRASH, "\xef\x8B\xAD", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BACKSPACE, "\xef\x95\x9A", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_SD_CARD, "\xef\x9F\x82", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_NEW_LINE, "\xef\xA2\xA2", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_AUDIO, "\xef\x80\x81", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_VIDEO, "\xef\x80\x88", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_LIST, "\xef\x80\x8b", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_OK, "\xef\x80\x8c", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_CLOSE, "\xef\x80\x8d", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_POWER, "\xef\x80\x91", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_SETTINGS, "\xef\x80\x93", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_HOME, "\xef\x80\x95", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_DOWNLOAD, "\xef\x80\x99", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_DRIVE, "\xef\x80\x9c", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_REFRESH, "\xef\x80\xa1", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_MUTE, "\xef\x80\xa6", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_VOLUME_MID, "\xef\x80\xa7", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_VOLUME_MAX, "\xef\x80\xa8", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_IMAGE, "\xef\x80\xbe", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_EDIT, "\xef\x8C\x84", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_PREV, "\xef\x81\x88", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_PLAY, "\xef\x81\x8b", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_PAUSE, "\xef\x81\x8c", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_STOP, "\xef\x81\x8d", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_NEXT, "\xef\x81\x91", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_EJECT, "\xef\x81\x92", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_LEFT, "\xef\x81\x93", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_RIGHT, "\xef\x81\x94", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_PLUS, "\xef\x81\xa7", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_MINUS, "\xef\x81\xa8", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_EYE_OPEN, "\xef\x81\xae", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_EYE_CLOSE, "\xef\x81\xb0", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_WARNING, "\xef\x81\xb1", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_SHUFFLE, "\xef\x81\xb4", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_UP, "\xef\x81\xb7", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_DOWN, "\xef\x81\xb8", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_LOOP, "\xef\x81\xb9", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_DIRECTORY, "\xef\x81\xbb", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_UPLOAD, "\xef\x82\x93", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_CALL, "\xef\x82\x95", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_CUT, "\xef\x83\x84", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_COPY, "\xef\x83\x85", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_SAVE, "\xef\x83\x87", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_CHARGE, "\xef\x83\xa7", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_PASTE, "\xef\x83\xAA", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BELL, "\xef\x83\xb3", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_KEYBOARD, "\xef\x84\x9c", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_GPS, "\xef\x84\xa4", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_FILE, "\xef\x85\x9b", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_WIFI, "\xef\x87\xab", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BATTERY_FULL, "\xef\x89\x80", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BATTERY_3, "\xef\x89\x81", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BATTERY_2, "\xef\x89\x82", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BATTERY_1, "\xef\x89\x83", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BATTERY_EMPTY, "\xef\x89\x84", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_USB, "\xef\x8a\x87", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BLUETOOTH, "\xef\x8a\x93", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_TRASH, "\xef\x8B\xAD", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BACKSPACE, "\xef\x95\x9A", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_SD_CARD, "\xef\x9F\x82", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_NEW_LINE, "\xef\xA2\xA2", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_DUMMY, "\xEF\xA3\xBF", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_DUMMY, "\xEF\xA3\xBF", 0, 0, 3, 0);
be_define_local_const_str(SYMBOL_BULLET, "\xE2\x80\xA2", 0, 0, 3, 0);
be_define_local_const_str2(SYMBOL_BULLET, "\xE2\x80\xA2", 0, 0, 3, 0);
/* @const_object_info_begin

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,8 @@
#include "be_string.h"
#include "be_gc.h"
// temporary work-around
#define be_define_local_const_str2(a,b,c,d,e,f) be_define_local_const_str(a,b,c,e)
#ifdef USE_I2C
extern int b_wire_init(bvm *vm);
@ -43,14 +45,14 @@ extern int b_wire_detect(bvm *vm);
** Solidified function: read_bytes
********************************************************************/
be_define_local_const_str(read_bytes_str_name, "read_bytes", -718234123, 0, 10, 0);
be_define_local_const_str(read_bytes_str_source, "string", 398550328, 0, 6, 0);
be_define_local_const_str(read_bytes_str_0, "_begin_transmission", -1515506120, 0, 19, 0);
be_define_local_const_str(read_bytes_str_1, "_write", -2079504471, 0, 6, 0);
be_define_local_const_str(read_bytes_str_2, "_end_transmission", -1057486896, 0, 17, 0);
be_define_local_const_str(read_bytes_str_3, "_request_from", -329818692, 0, 13, 0);
be_define_local_const_str(read_bytes_str_4, "_available", 1306196581, 0, 10, 0);
be_define_local_const_str(read_bytes_str_5, "_read", 346717030, 0, 5, 0);
be_define_local_const_str2(read_bytes_str_name, "read_bytes", -718234123, 0, 10, 0);
be_define_local_const_str2(read_bytes_str_source, "string", 398550328, 0, 6, 0);
be_define_local_const_str2(read_bytes_str_0, "_begin_transmission", -1515506120, 0, 19, 0);
be_define_local_const_str2(read_bytes_str_1, "_write", -2079504471, 0, 6, 0);
be_define_local_const_str2(read_bytes_str_2, "_end_transmission", -1057486896, 0, 17, 0);
be_define_local_const_str2(read_bytes_str_3, "_request_from", -329818692, 0, 13, 0);
be_define_local_const_str2(read_bytes_str_4, "_available", 1306196581, 0, 10, 0);
be_define_local_const_str2(read_bytes_str_5, "_read", 346717030, 0, 5, 0);
static const bvalue read_bytes_ktab[6] = {
{ { .s=be_local_const_str(read_bytes_str_0) }, BE_STRING},
@ -141,11 +143,11 @@ const bclosure read_bytes_closure = {
** Solidified function: write_bytes
********************************************************************/
be_define_local_const_str(write_bytes_str_name, "write_bytes", 1227543792, 0, 11, 0);
be_define_local_const_str(write_bytes_str_source, "string", 398550328, 0, 6, 0);
be_define_local_const_str(write_bytes_str_0, "_begin_transmission", -1515506120, 0, 19, 0);
be_define_local_const_str(write_bytes_str_1, "_write", -2079504471, 0, 6, 0);
be_define_local_const_str(write_bytes_str_2, "_end_transmission", -1057486896, 0, 17, 0);
be_define_local_const_str2(write_bytes_str_name, "write_bytes", 1227543792, 0, 11, 0);
be_define_local_const_str2(write_bytes_str_source, "string", 398550328, 0, 6, 0);
be_define_local_const_str2(write_bytes_str_0, "_begin_transmission", -1515506120, 0, 19, 0);
be_define_local_const_str2(write_bytes_str_1, "_write", -2079504471, 0, 6, 0);
be_define_local_const_str2(write_bytes_str_2, "_end_transmission", -1057486896, 0, 17, 0);
static const bvalue write_bytes_ktab[3] = {
{ { .s=be_local_const_str(write_bytes_str_0) }, BE_STRING},

View File

@ -80,9 +80,9 @@ static void m_solidify_proto(bvm *vm, bproto *pr, const char * func_name, int bu
}
/* create static strings for name and source */
logfmt("be_define_local_const_str(%s_str_name, \"%s\", %i, 0, %u, 0);\n",
logfmt("be_define_local_const_str(%s_str_name, \"%s\", %i, %u);\n",
func_name, str(pr->name), be_strhash(pr->name), str_len(pr->name));
logfmt("be_define_local_const_str(%s_str_source, \"%s\", %i, 0, %u, 0);\n",
logfmt("be_define_local_const_str(%s_str_source, \"%s\", %i, %u);\n",
func_name, func_source, be_strhash(pr->source), str_len(pr->source));
/* create static strings first */
@ -95,7 +95,7 @@ static void m_solidify_proto(bvm *vm, bproto *pr, const char * func_name, int bu
if (len >= 255) {
be_raise(vm, "internal_error", "Strings greater than 255 chars not supported yet");
}
logfmt("\", %i, 0, %zu, 0);\n", be_strhash(pr->ktab[i].v.s), len >= 255 ? 255 : len);
logfmt("\", %i, %zu);\n", be_strhash(pr->ktab[i].v.s), len >= 255 ? 255 : len);
}
}
logfmt("\n");

View File

@ -252,15 +252,15 @@ typedef struct bntvmodule {
/* support for solidified berry functions */
/* native const strings outside of global string hash */
#define be_define_local_const_str(_name, _s, _hash, _extra, _len, _next) \
static const bcstring be_local_const_str_##_name = { \
.next = (bgcobject *)NULL, \
.type = BE_STRING, \
.marked = GC_CONST, \
.extra = 0, \
.slen = _len, \
.hash = 0, \
.s = _s \
#define be_define_local_const_str(_name, _s, _hash, _len) \
static const bcstring be_local_const_str_##_name = { \
.next = (bgcobject *)NULL, \
.type = BE_STRING, \
.marked = 0x08, /* GC_CONST */ \
.extra = 0, \
.slen = _len, \
.hash = 0, \
.s = _s \
}
#define be_local_const_str(_name) (bstring*) &be_local_const_str_##_name
@ -297,15 +297,15 @@ typedef struct bntvmodule {
static const bproto _name##_proto = { \
NULL, /* bgcobject *next */ \
8, /* type BE_PROTO */ \
GC_CONST, /* marked outside of GC */ \
0x08, /* marked outside of GC */ \
(_nstack), /* nstack */ \
BE_IIF(_is_upval)(sizeof(_name##_upvals)/sizeof(bupvaldesc),0),/* nupvals */ \
BE_IIF(_is_upval)(sizeof(_name##_upvals)/sizeof(bupvaldesc),0),/* nupvals */ \
(_argc), /* argc */ \
0, /* varg */ \
NULL, /* bgcobject *gray */ \
BE_IIF(_is_upval)((bupvaldesc*)&_name##_upvals,NULL), /* bupvaldesc *upvals */ \
BE_IIF(_is_upval)((bupvaldesc*)&_name##_upvals,NULL), /* bupvaldesc *upvals */\
BE_IIF(_is_const)((bvalue*)&_name##_ktab,NULL), /* ktab */ \
BE_IIF(_is_subproto)((struct bproto**)&_name##_subproto,NULL),/* bproto **ptab */ \
BE_IIF(_is_subproto)((struct bproto**)&_name##_subproto,NULL),/* bproto **ptab */\
(binstruction*) &_name##_code, /* code */ \
be_local_const_str(_name##_str_name), /* name */ \
sizeof(_name##_code)/sizeof(uint32_t), /* codesize */ \
@ -320,7 +320,7 @@ typedef struct bntvmodule {
const bclosure _name##_closure = { \
NULL, /* bgcobject *next */ \
36, /* type BE_CLOSURE */ \
GC_CONST, /* marked */ \
0x08, /* marked GC_CONST */ \
0, /* nupvals */ \
NULL, /* bgcobject *gray */ \
(bproto*) &_name##_proto, /* proto */ \