Berry automated solidification of code

This commit is contained in:
Stephan Hadinger 2022-09-12 22:02:25 +02:00
parent 1139314e38
commit e0f9154986
28 changed files with 7861 additions and 4161 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ tasmota/tasmota.ino.cpp
platformio_override.ini platformio_override.ini
platformio_tasmota_cenv.ini platformio_tasmota_cenv.ini
lib/libesp32/berry/generate/* lib/libesp32/berry/generate/*
lib/libesp32/berry/berry
## Visual Studio Code specific ###### ## Visual Studio Code specific ######
.vscode .vscode

View File

@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
## [12.1.1.2] ## [12.1.1.2]
### Added ### Added
- Berry has persistent MQTT subscriptions: auto-subscribe at (re)connection - Berry has persistent MQTT subscriptions: auto-subscribe at (re)connection
- Berry automated solidification of code
### Changed ### Changed

View File

@ -1,4 +1,4 @@
CFLAGS = -Wall -Wextra -std=c99 -pedantic-errors -O2 CFLAGS = -Wall -Wextra -std=c99 -O2 -Wno-zero-length-array -Wno-empty-translation-unit
DEBUG_FLAGS = -O0 -g -DBE_DEBUG DEBUG_FLAGS = -O0 -g -DBE_DEBUG
TEST_FLAGS = $(DEBUG_FLAGS) --coverage -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined TEST_FLAGS = $(DEBUG_FLAGS) --coverage -fno-omit-frame-pointer -fsanitize=address -fsanitize=undefined
LIBS = -lm LIBS = -lm
@ -7,8 +7,8 @@ CC = gcc
MKDIR = mkdir MKDIR = mkdir
LFLAGS = LFLAGS =
INCPATH = src default INCPATH = src default ../re1.5
SRCPATH = src default SRCPATH = src default ../re1.5
GENERATE = generate GENERATE = generate
CONFIG = default/berry_conf.h CONFIG = default/berry_conf.h
COC = tools/coc/coc COC = tools/coc/coc

View File

@ -25,7 +25,6 @@ be_extern_native_module(strict);
be_extern_native_module(undefined); be_extern_native_module(undefined);
/* Berry extensions */ /* Berry extensions */
#include "be_mapping.h"
be_extern_native_module(cb); be_extern_native_module(cb);
/* Tasmota specific */ /* Tasmota specific */
@ -111,13 +110,14 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
#endif #endif
&be_native_module(undefined), &be_native_module(undefined),
&be_native_module(re),
#ifdef TASMOTA
/* Berry extensions */ /* Berry extensions */
&be_native_module(cb), &be_native_module(cb),
/* user-defined modules register start */ /* user-defined modules register start */
&be_native_module(python_compat), &be_native_module(python_compat),
&be_native_module(re),
&be_native_module(path), &be_native_module(path),
&be_native_module(mqtt), &be_native_module(mqtt),
&be_native_module(persist), &be_native_module(persist),
@ -173,6 +173,7 @@ BERRY_LOCAL const bntvmodule* const be_module_table[] = {
&be_native_module(MI32), &be_native_module(MI32),
&be_native_module(BLE), &be_native_module(BLE),
#endif //USE_MI_ESP32 #endif //USE_MI_ESP32
#endif // TASMOTA
/* user-defined modules register end */ /* user-defined modules register end */
NULL /* do not remove */ NULL /* do not remove */
}; };
@ -224,6 +225,7 @@ be_extern_native_class(lv_clock_icon);
be_extern_native_class(int64); be_extern_native_class(int64);
BERRY_LOCAL bclass_array be_class_table = { BERRY_LOCAL bclass_array be_class_table = {
#ifdef TASMOTA
/* first list are direct classes */ /* first list are direct classes */
&be_native_class(tasmota), &be_native_class(tasmota),
&be_native_class(Trigger), &be_native_class(Trigger),
@ -290,6 +292,7 @@ BERRY_LOCAL bclass_array be_class_table = {
#ifdef USE_BERRY_INT64 #ifdef USE_BERRY_INT64
&be_native_class(int64), &be_native_class(int64),
#endif #endif
#endif // TASMOTA
NULL, /* do not remove */ NULL, /* do not remove */
}; };

View File

@ -0,0 +1,410 @@
/********************************************************************
** Copyright (c) 2018-2020 Guan Wenliang
** This file is part of the Berry default interpreter.
** skiars@qq.com, https://github.com/Skiars/berry
** See Copyright Notice in the LICENSE file or at
** https://github.com/Skiars/berry/blob/master/LICENSE
********************************************************************/
#ifndef TASMOTA // only when compiling stand-along
#include "berry.h"
#include "be_mem.h"
#include "be_sys.h"
#include <stdio.h>
#include <string.h>
/* this file contains configuration for the file system. */
/* standard input and output */
BERRY_API void be_writebuffer(const char *buffer, size_t length)
{
be_fwrite(stdout, buffer, length);
}
BERRY_API char* be_readstring(char *buffer, size_t size)
{
return be_fgets(stdin, buffer, (int)size);
}
/* use the standard library implementation file API. */
#if !defined(USE_FATFS)
void* be_fopen(const char *filename, const char *modes)
{
return fopen(filename, modes);
}
int be_fclose(void *hfile)
{
return fclose(hfile);
}
size_t be_fwrite(void *hfile, const void *buffer, size_t length)
{
return fwrite(buffer, 1, length, hfile);
}
size_t be_fread(void *hfile, void *buffer, size_t length)
{
return fread(buffer, 1, length, hfile);
}
char* be_fgets(void *hfile, void *buffer, int size)
{
return fgets(buffer, size, hfile);
}
int be_fseek(void *hfile, long offset)
{
return fseek(hfile, offset, SEEK_SET);
}
long int be_ftell(void *hfile)
{
return ftell(hfile);
}
long int be_fflush(void *hfile)
{
return fflush(hfile);
}
size_t be_fsize(void *hfile)
{
long int size, offset = be_ftell(hfile);
fseek(hfile, 0L, SEEK_END);
size = ftell(hfile);
fseek(hfile, offset, SEEK_SET);
return size;
}
#else /* use the FatFs library implementation file API. */
#include "ff.h"
#if FF_FS_RPATH != 2
#error FatFs check (FF_FS_RPATH == 2) failed.
#endif
#if FF_USE_STRFUNC < 1
#error FatFs check (FF_USE_STRFUNC >= 1) failed.
#endif
void* be_fopen(const char *filename, const char *modes)
{
BYTE mode = 0;
FIL *fp = be_os_malloc(sizeof(FIL));
switch (modes[0]) {
case 'r': mode |= FA_READ; break;
case 'w': mode |= FA_CREATE_ALWAYS | FA_WRITE; break;
case 'a': mode |= FA_OPEN_APPEND | FA_WRITE; break;
default: return NULL;
}
switch (modes[1]) {
case '+': mode |= FA_READ | FA_WRITE; break;
case 't':
case 'b':
case '\0': break;
default: return NULL;
}
if (modes[1] && modes[2] == '+') {
mode |= FA_READ | FA_WRITE;
}
if (fp && f_open(fp, filename, mode) == FR_OK) {
return fp;
}
be_os_free(fp);
return NULL;
}
int be_fclose(void *hfile)
{
int res = f_close(hfile) != FR_OK;
be_os_free(hfile);
return res;
}
size_t be_fwrite(void *hfile, const void *buffer, size_t length)
{
UINT bw;
if (hfile == stdout || hfile == stderr || hfile == stdin) {
return fwrite(buffer, 1, length, hfile);
}
f_write(hfile, buffer, (UINT)length, &bw);
return bw;
}
size_t be_fread(void *hfile, void *buffer, size_t length)
{
UINT br;
if (hfile == stdout || hfile == stderr || hfile == stdin) {
return fread(buffer, 1, length, hfile);
}
f_read(hfile, buffer, (UINT)length, &br);
return br;
}
char* be_fgets(void *hfile, void *buffer, int size)
{
if (hfile == stdout || hfile == stderr || hfile == stdin) {
return fgets(buffer, size, hfile);
}
return f_gets(buffer, size, hfile);
}
int be_fseek(void *hfile, long offset)
{
return f_lseek(hfile, (FSIZE_t)offset);
}
long int be_ftell(void *hfile)
{
return f_tell(hfile);
}
long int be_fflush(void *hfile)
{
return f_sync(hfile);
}
size_t be_fsize(void *hfile)
{
return f_size(hfile);
}
#endif /* !defined(USE_FATFS) */
#if BE_USE_FILE_SYSTEM
#if defined(USE_FATFS) /* FatFs */
int be_isdir(const char *path)
{
FILINFO fno;
FRESULT fr = f_stat(path, &fno);
return fr == FR_OK && fno.fattrib & AM_DIR;
}
int be_isfile(const char *path)
{
FILINFO fno;
FRESULT fr = f_stat(path, &fno);
return fr == FR_OK && !(fno.fattrib & AM_DIR);
}
int be_isexist(const char *path)
{
FILINFO fno;
return f_stat(path, &fno) == FR_OK;
}
char* be_getcwd(char *buf, size_t size)
{
FRESULT fr = f_getcwd(buf, (UINT)size);
return fr == FR_OK ? buf : NULL;
}
int be_chdir(const char *path)
{
return f_chdir(path);
}
int be_mkdir(const char *path)
{
return f_mkdir(path);
}
int be_unlink(const char *filename)
{
return f_unlink(filename);
}
int be_dirfirst(bdirinfo *info, const char *path)
{
info->dir = be_os_malloc(sizeof(DIR));
info->file = be_os_malloc(sizeof(FILINFO));
if (info->dir && info->file) {
FRESULT fr = f_opendir(info->dir, path);
return fr == FR_OK ? be_dirnext(info) : 1;
}
be_os_free(info->dir);
be_os_free(info->file);
info->dir = NULL;
info->file = NULL;
return 1;
}
int be_dirnext(bdirinfo *info)
{
FRESULT fr = f_readdir(info->dir, info->file);
info->name = ((FILINFO *)info->file)->fname;
return fr != FR_OK || *info->name == '\0';
}
int be_dirclose(bdirinfo *info)
{
if (info->dir) {
int res = f_closedir(info->dir) != FR_OK;
be_os_free(info->dir);
be_os_free(info->file);
return res;
}
return 1;
}
#elif defined(_MSC_VER) /* MSVC*/
#include <windows.h>
#include <direct.h>
#include <io.h>
int be_isdir(const char *path)
{
DWORD type = GetFileAttributes(path);
return type != INVALID_FILE_ATTRIBUTES
&& (type & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
int be_isfile(const char *path)
{
DWORD type = GetFileAttributes(path);
return type != INVALID_FILE_ATTRIBUTES
&& (type & FILE_ATTRIBUTE_DIRECTORY) == 0;
}
int be_isexist(const char *path)
{
return GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES;
}
char* be_getcwd(char *buf, size_t size)
{
return _getcwd(buf, (int)size);
}
int be_chdir(const char *path)
{
return _chdir(path);
}
int be_mkdir(const char *path)
{
return _mkdir(path);
}
int be_unlink(const char *filename)
{
return remove(filename);
}
int be_dirfirst(bdirinfo *info, const char *path)
{
char *buf = be_os_malloc(strlen(path) + 3);
info->file = be_os_malloc(sizeof(struct _finddata_t));
info->dir = NULL;
if (buf && info->file) {
struct _finddata_t *cfile = info->file;
strcat(strcpy(buf, path), "/*");
info->dir = (void *)_findfirst(buf, cfile);
info->name = cfile->name;
be_os_free(buf);
return (intptr_t)info->dir == -1;
}
be_os_free(buf);
return 1;
}
int be_dirnext(bdirinfo *info)
{
struct _finddata_t *cfile = info->file;
int res = _findnext((intptr_t)info->dir, cfile) != 0;
info->name = cfile->name;
return res;
}
int be_dirclose(bdirinfo *info)
{
be_os_free(info->file);
return _findclose((intptr_t)info->dir) != 0;
}
#else /* must be POSIX */
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
int be_isdir(const char *path)
{
struct stat path_stat;
int res = stat(path, &path_stat);
return res == 0 && S_ISDIR(path_stat.st_mode);
}
int be_isfile(const char *path)
{
struct stat path_stat;
int res = stat(path, &path_stat);
return res == 0 && !S_ISDIR(path_stat.st_mode);
}
int be_isexist(const char *path)
{
struct stat path_stat;
return stat(path, &path_stat) == 0;
}
char* be_getcwd(char *buf, size_t size)
{
return getcwd(buf, size);
}
int be_chdir(const char *path)
{
return chdir(path);
}
int be_mkdir(const char *path)
{
#ifdef _WIN32
return mkdir(path);
#else
return mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
#endif
}
int be_unlink(const char *filename)
{
return remove(filename);
}
int be_dirfirst(bdirinfo *info, const char *path)
{
info->dir = opendir(path);
if (info->dir) {
return be_dirnext(info);
}
return 1;
}
int be_dirnext(bdirinfo *info)
{
struct dirent *file;
info->file = file = readdir(info->dir);
if (file) {
info->name = file->d_name;
return 0;
}
return 1;
}
int be_dirclose(bdirinfo *info)
{
return closedir(info->dir) != 0;
}
#endif /* POSIX */
#endif /* BE_USE_OS_MODULE || BE_USE_FILE_SYSTEM */
#endif // COMPILE_BERRY_LIB

View File

@ -8,7 +8,7 @@
#include "be_constobj.h" #include "be_constobj.h"
#include "be_mem.h" #include "be_mem.h"
#include "be_object.h" #include "be_object.h"
#include "re1.5.h" #include "../../re1.5/re1.5.h"
/******************************************************************** /********************************************************************
# Berry skeleton for `re` module # Berry skeleton for `re` module
@ -60,15 +60,17 @@ int be_re_compile(bvm *vm) {
be_raise(vm, "type_error", NULL); be_raise(vm, "type_error", NULL);
} }
// pushes either a list if matched, else `nil`
int be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbool is_anchored) { // return index of next offset, or -1 if not found
const char *be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbool is_anchored) {
Subject subj = {hay, hay + strlen(hay)}; Subject subj = {hay, hay + strlen(hay)};
int sub_els = (code->sub + 1) * 2; int sub_els = (code->sub + 1) * 2;
const char *sub[sub_els]; const char *sub[sub_els];
if (!re1_5_recursiveloopprog(code, &subj, sub, sub_els, is_anchored)) { if (!re1_5_recursiveloopprog(code, &subj, sub, sub_els, is_anchored)) {
be_return_nil(vm); // no match be_pushnil(vm);
return NULL; // no match
} }
be_newobject(vm, "list"); be_newobject(vm, "list");
@ -81,8 +83,8 @@ int be_re_match_search_run(bvm *vm, ByteProg *code, const char *hay, bbool is_an
be_data_push(vm, -2); be_data_push(vm, -2);
be_pop(vm, 1); be_pop(vm, 1);
} }
be_pop(vm, 1); // remove list be_pop(vm, 1); // remove list
be_return(vm); // return list object return sub[1];
} }
int be_re_match_search(bvm *vm, bbool is_anchored) { int be_re_match_search(bvm *vm, bbool is_anchored) {
@ -100,7 +102,42 @@ int be_re_match_search(bvm *vm, bbool is_anchored) {
if (ret != 0) { if (ret != 0) {
be_raise(vm, "internal_error", "error in regex"); be_raise(vm, "internal_error", "error in regex");
} }
return be_re_match_search_run(vm, code, hay, is_anchored); be_re_match_search_run(vm, code, hay, is_anchored);
be_return(vm);
}
be_raise(vm, "type_error", NULL);
}
int be_re_match_search_all(bvm *vm, bbool is_anchored) {
int32_t argc = be_top(vm); // Get the number of arguments
if (argc >= 2 && be_isstring(vm, 1) && be_isstring(vm, 2)) {
const char * regex_str = be_tostring(vm, 1);
const char * hay = be_tostring(vm, 2);
int limit = -1;
if (argc >= 3) {
limit = be_toint(vm, 3);
}
int sz = re1_5_sizecode(regex_str);
if (sz < 0) {
be_raise(vm, "internal_error", "error in regex");
}
ByteProg *code = be_os_malloc(sizeof(ByteProg) + sz);
int ret = re1_5_compilecode(code, regex_str);
if (ret != 0) {
be_raise(vm, "internal_error", "error in regex");
}
be_newobject(vm, "list");
for (int i = limit; i != 0 && hay != NULL; i--) {
hay = be_re_match_search_run(vm, code, hay, is_anchored);
if (hay != NULL) {
be_data_push(vm, -2); // add sub list to list
}
be_pop(vm, 1);
}
be_pop(vm, 1);
be_return(vm);
} }
be_raise(vm, "type_error", NULL); be_raise(vm, "type_error", NULL);
} }
@ -114,6 +151,15 @@ int be_re_search(bvm *vm) {
return be_re_match_search(vm, bfalse); return be_re_match_search(vm, bfalse);
} }
// Berry: `re.search_all`
int be_re_match_all(bvm *vm) {
return be_re_match_search_all(vm, btrue);
}
// Berry: `re.search_all`
int be_re_search_all(bvm *vm) {
return be_re_match_search_all(vm, bfalse);
}
// Berry: `re_pattern.search(s:string) -> list(string)` // Berry: `re_pattern.search(s:string) -> list(string)`
int re_pattern_search(bvm *vm) { int re_pattern_search(bvm *vm) {
int32_t argc = be_top(vm); // Get the number of arguments int32_t argc = be_top(vm); // Get the number of arguments
@ -121,7 +167,8 @@ int re_pattern_search(bvm *vm) {
const char * hay = be_tostring(vm, 2); const char * hay = be_tostring(vm, 2);
be_getmember(vm, 1, "_p"); be_getmember(vm, 1, "_p");
ByteProg * code = (ByteProg*) be_tocomptr(vm, -1); ByteProg * code = (ByteProg*) be_tocomptr(vm, -1);
return be_re_match_search_run(vm, code, hay, bfalse); be_re_match_search_run(vm, code, hay, bfalse);
be_return(vm);
} }
be_raise(vm, "type_error", NULL); be_raise(vm, "type_error", NULL);
} }
@ -133,7 +180,8 @@ int re_pattern_match(bvm *vm) {
const char * hay = be_tostring(vm, 2); const char * hay = be_tostring(vm, 2);
be_getmember(vm, 1, "_p"); be_getmember(vm, 1, "_p");
ByteProg * code = (ByteProg*) be_tocomptr(vm, -1); ByteProg * code = (ByteProg*) be_tocomptr(vm, -1);
return be_re_match_search_run(vm, code, hay, btrue); be_re_match_search_run(vm, code, hay, btrue);
be_return(vm);
} }
be_raise(vm, "type_error", NULL); be_raise(vm, "type_error", NULL);
} }
@ -209,38 +257,25 @@ int be_re_split(bvm *vm) {
be_raise(vm, "type_error", NULL); be_raise(vm, "type_error", NULL);
} }
/******************************************************************** #include "../generate/be_fixed_re.h"
** Solidified module: re #include "../generate/be_fixed_be_class_re_pattern.h"
********************************************************************/ /*
be_local_module(re, @const_object_info_begin
"re", module re (scope: global) {
be_nested_map(4, compile, func(be_re_compile)
( (struct bmapnode*) &(const bmapnode[]) { search, func(be_re_search)
{ be_nested_key("compile", 1000265118, 7, -1), be_const_func(be_re_compile) }, searchall, func(be_re_search_all)
{ be_nested_key("search", -2144130903, 6, -1), be_const_func(be_re_search) }, match, func(be_re_match)
{ be_nested_key("match", 2116038550, 5, 0), be_const_func(be_re_match) }, matchall, func(be_re_match_all)
{ be_nested_key("split", -2017972765, 5, -1), be_const_func(be_re_split) }, split, func(be_re_split)
})) }
); @const_object_info_end
BE_EXPORT_VARIABLE be_define_const_native_module(re);
/********************************************************************/
// ===================================================================
/********************************************************************
** Solidified class: re_pattern
********************************************************************/
be_local_class(re_pattern,
1,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("search", -2144130903, 6, -1), be_const_func(re_pattern_search) },
{ be_nested_key("match", 2116038550, 5, 0), be_const_func(re_pattern_match) },
{ be_nested_key("split", -2017972765, 5, -1), be_const_func(re_pattern_split) },
})),
(be_nested_const_str("re_pattern", 2041968961, 10))
);
/*******************************************************************/
@const_object_info_begin
class be_class_re_pattern (scope: global, name: re_pattern) {
_p, var
search, func(re_pattern_search)
match, func(re_pattern_match)
split, func(re_pattern_split)
}
@const_object_info_end */

View File

@ -0,0 +1,372 @@
/********************************************************************
** Copyright (c) 2018-2020 Guan Wenliang
** This file is part of the Berry default interpreter.
** skiars@qq.com, https://github.com/Skiars/berry
** See Copyright Notice in the LICENSE file or at
** https://github.com/Skiars/berry/blob/master/LICENSE
********************************************************************/
#ifndef TASMOTA // only when compiling stand-along
#include "berry.h"
#include "be_repl.h"
#include "be_vm.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* using GNU/readline library */
#if defined(USE_READLINE_LIB)
#include <readline/readline.h>
#include <readline/history.h>
#endif
/* detect operating system name */
#if defined(__linux)
#define OS_NAME "Linux"
#elif defined(__unix)
#define OS_NAME "Unix"
#elif defined(__APPLE__)
#define OS_NAME "Darwin"
#elif defined(_WIN32)
#define OS_NAME "Windows"
#else
#define OS_NAME "Unknown OS"
#endif
/* detect compiler name and version */
#if defined(__clang__)
#define COMPILER "clang " __clang_version__
#elif defined(__GNUC__)
#define COMPILER "GCC " __VERSION__
#elif defined(_MSC_VER)
#define COMPILER "MSVC"
#elif defined(__CC_ARM)
#define COMPILER "ARMCC"
#elif defined(__ICCARM__)
#define COMPILER "IAR"
#else
#define COMPILER "Unknown Compiler"
#endif
#if BE_DEBUG
#define FULL_VERSION "Berry " BERRY_VERSION " (debug)"
#else
#define FULL_VERSION "Berry " BERRY_VERSION
#endif
/* prompt message when REPL is loaded */
#define repl_prelude \
FULL_VERSION " (build in " __DATE__ ", " __TIME__ ")\n" \
"[" COMPILER "] on " OS_NAME " (default)\n" \
/* command help information */
#define help_information \
"Usage: berry [options] [script [args]]\n" \
"Avilable options are:\n" \
" -i enter interactive mode after executing 'file'\n" \
" -l all variables in 'file' are parsed as local\n" \
" -e load 'script' source string and execute\n" \
" -c <file> compile script 'file' to bytecode file\n" \
" -o <file> save bytecode to 'file'\n" \
" -g force named globals in VM\n" \
" -s force Berry compiler in strict mode\n" \
" -v show version information\n" \
" -h show help information\n\n" \
"For more information, please see:\n" \
" <https://github.com/skiars/berry>.\n"
#define array_count(a) (sizeof(a) / sizeof((a)[0]))
#define arg_i (1 << 0)
#define arg_c (1 << 1)
#define arg_o (1 << 2)
#define arg_l (1 << 3)
#define arg_h (1 << 4)
#define arg_v (1 << 5)
#define arg_e (1 << 6)
#define arg_g (1 << 7)
#define arg_s (1 << 8)
#define arg_err (1 << 9)
struct arg_opts {
int idx;
const char *pattern;
const char *optarg;
const char *errarg;
const char *src;
const char *dst;
};
/* check if the character is a letter */
static int is_letter(int ch)
{
return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z');
}
/* matching options
* pattern: pattern string, the set of vaild options
* ch: option character to be matched
* */
static const char* match_opt(const char *pattern, int ch)
{
int c = '\0';
if (pattern) {
while ((c = *pattern) != '\0' && c != ch) {
c = *(++pattern);
while (c != '\0' && !is_letter(c)) {
c = *(++pattern); /* skip characters that are not letters */
}
}
}
return c == ch ? pattern : NULL;
}
/* read an option from the arguments
* opt: option match state
* argc: the number of arguments
* argv: the arguments list
* */
static int arg_getopt(struct arg_opts *opt, int argc, char *argv[])
{
if (opt->idx < argc) {
char *arg = argv[opt->idx];
if (arg[0] == '-' && strlen(arg) == 2) {
const char *res = match_opt(opt->pattern, arg[1]);
/* the '?' indicates an optional argument after the option */
if (++opt->idx < argc && res != NULL
&& res[1] == '?' && *argv[opt->idx] != '-') {
opt->optarg = argv[opt->idx++]; /* save the argument */
return *res;
}
opt->optarg = NULL;
opt->errarg = arg;
return res != NULL ? *res : '?';
}
}
return 0;
}
/* portable readline function package */
static char* get_line(const char *prompt)
{
#if defined(USE_READLINE_LIB)
char *line = readline(prompt);
if (line && strlen(line)) {
add_history(line);
}
return line;
#else
static char buffer[1000];
fputs(prompt, stdout);
fflush(stdout);
if (be_readstring(buffer, sizeof(buffer))) {
buffer[strlen(buffer) - 1] = '\0';
return buffer;
}
return NULL;
#endif
}
static void free_line(char *ptr)
{
#if defined(USE_READLINE_LIB)
free(ptr);
#else
(void)ptr;
#endif
}
static int handle_result(bvm *vm, int res)
{
switch (res) {
case BE_OK: /* everything is OK */
return 0;
case BE_EXCEPTION: /* uncatched exception */
be_dumpexcept(vm);
return 1;
case BE_EXIT: /* return exit code */
return be_toindex(vm, -1);
case BE_IO_ERROR:
be_writestring("error: ");
be_writestring(be_tostring(vm, -1));
be_writenewline();
return -2;
case BE_MALLOC_FAIL:
be_writestring("error: memory allocation failed.\n");
return -1;
default: /* unkonw result */
return 2;
}
}
/* execute a script source or file and output a result or error */
static int doscript(bvm *vm, const char *name, int args)
{
/* load string, bytecode file or compile script file */
int res = args & arg_e ? /* check script source string */
be_loadstring(vm, name) : be_loadmode(vm, name, args & arg_l);
if (res == BE_OK) { /* parsing succeeded */
res = be_pcall(vm, 0); /* execute */
}
return handle_result(vm, res);
}
/* load a Berry script string or file and execute
* args: the enabled options mask
* */
static int load_script(bvm *vm, int argc, char *argv[], int args)
{
int res = 0;
int repl_mode = args & arg_i || (args == 0 && argc == 0);
if (repl_mode) { /* enter the REPL mode after executing the script file */
be_writestring(repl_prelude);
}
if (argc > 0) { /* check file path or source string argument */
res = doscript(vm, argv[0], args);
}
if (repl_mode) { /* enter the REPL mode */
res = be_repl(vm, get_line, free_line);
if (res == -BE_MALLOC_FAIL) {
be_writestring("error: memory allocation failed.\n");
}
}
return res;
}
/* compile the source code to a bytecode file */
static int build_file(bvm *vm, const char *dst, const char *src, int args)
{
int res = be_loadmode(vm, src, args & arg_l); /* compile script file */
if (res == BE_OK) {
if (!dst) dst = "a.out"; /* the default output file name */
res = be_savecode(vm, dst); /* save bytecode file */
}
return handle_result(vm, res);
}
static int parse_arg(struct arg_opts *opt, int argc, char *argv[])
{
int ch, args = 0;
opt->idx = 1;
while ((ch = arg_getopt(opt, argc, argv)) != '\0') {
switch (ch) {
case 'h': args |= arg_h; break;
case 'v': args |= arg_v; break;
case 'i': args |= arg_i; break;
case 'l': args |= arg_l; break;
case 'e': args |= arg_e; break;
case 'g': args |= arg_g; break;
case 's': args |= arg_s; break;
case '?': return args | arg_err;
case 'c':
args |= arg_c;
opt->src = opt->optarg;
break;
case 'o':
args |= arg_o;
opt->dst = opt->optarg;
break;
default:
break;
}
}
return args;
}
static void push_args(bvm *vm, int argc, char *argv[])
{
be_newobject(vm, "list");
while (argc--) {
be_pushstring(vm, *argv++);
be_data_push(vm, -2);
be_pop(vm, 1);
}
be_pop(vm, 1);
be_setglobal(vm, "_argv");
be_pop(vm, 1);
}
/*
* command format: berry [options] [script [args]]
* command options:
* -i: enter interactive mode after executing 'script'
* -b: load code from bytecode file
* -e: load 'script' source and execute
* command format: berry options
* command options:
* -v: show version information
* -h: show help information
* command format: berry option file [option file]
* command options:
* -c: compile script file to bytecode file
* -o: set the output file name
* */
static int analysis_args(bvm *vm, int argc, char *argv[])
{
int args = 0;
struct arg_opts opt = { 0 };
opt.pattern = "vhilegsc?o?";
args = parse_arg(&opt, argc, argv);
argc -= opt.idx;
argv += opt.idx;
if (args & arg_err) {
be_writestring(be_pushfstring(vm,
"error: missing argument to '%s'\n", opt.errarg));
be_pop(vm, 1);
return -1;
}
if (args & arg_g) {
comp_set_named_gbl(vm); /* forced named global in VM code */
args &= ~arg_g; /* clear the flag for this option not to interfere with other options */
}
if (args & arg_s) {
comp_set_strict(vm); /* compiler in strict mode */
args &= ~arg_s;
}
if (args & arg_v) {
be_writestring(FULL_VERSION "\n");
}
if (args & arg_h) {
be_writestring(help_information);
}
push_args(vm, argc, argv);
if (args & (arg_c | arg_o)) {
if (!opt.src && argc > 0) {
opt.src = *argv;
}
return build_file(vm, opt.dst, opt.src, args);
}
return load_script(vm, argc, argv, args);
}
#if defined(_WIN32)
#define BERRY_ROOT "\\Windows\\system32"
static const char *module_paths[] = {
BERRY_ROOT "\\berry\\packages",
};
#else
#define BERRY_ROOT "/usr/local"
static const char *module_paths[] = {
BERRY_ROOT "/lib/berry/packages",
};
#endif
static void berry_paths(bvm * vm)
{
size_t i;
for (i = 0; i < array_count(module_paths); ++i) {
be_module_path_set(vm, module_paths[i]);
}
}
int main(int argc, char *argv[])
{
int res;
bvm *vm = be_vm_new(); /* create a virtual machine instance */
berry_paths(vm);
res = analysis_args(vm, argc, argv);
be_vm_delete(vm); /* free all objects and vm */
return res;
}
#endif // COMPILE_BERRY_LIB

View File

@ -131,7 +131,11 @@
* will not be used. * will not be used.
* Default: 0 * Default: 0
**/ **/
#ifdef TASMOTA
#define BE_USE_FILE_SYSTEM 0 #define BE_USE_FILE_SYSTEM 0
#else
#define BE_USE_FILE_SYSTEM 1
#endif
/* Macro: BE_USE_SCRIPT_COMPILER /* Macro: BE_USE_SCRIPT_COMPILER
* Enable compiler when BE_USE_SCRIPT_COMPILER is not 0, otherwise * Enable compiler when BE_USE_SCRIPT_COMPILER is not 0, otherwise
@ -197,7 +201,11 @@
* This options tries to move such memory areas to this region. * This options tries to move such memory areas to this region.
* Default: 0 * Default: 0
**/ **/
#ifdef TASMOTA
#define BE_USE_MEM_ALIGNED 1 #define BE_USE_MEM_ALIGNED 1
#else
#define BE_USE_MEM_ALIGNED 0
#endif
/* Macro: BE_USE_XXX_MODULE /* Macro: BE_USE_XXX_MODULE
* These macros control whether the related module is compiled. * These macros control whether the related module is compiled.
@ -205,20 +213,36 @@
* point you can use the import statement to import the module. * point you can use the import statement to import the module.
* They will not compile related modules when they are false. * They will not compile related modules when they are false.
**/ **/
#define BE_USE_STRING_MODULE 1
#define BE_USE_JSON_MODULE 1
#define BE_USE_MATH_MODULE 1
#define BE_USE_TIME_MODULE 0
#define BE_USE_OS_MODULE 0
#define BE_USE_GLOBAL_MODULE 1
#define BE_USE_SYS_MODULE 1
#define BE_USE_DEBUG_MODULE 0
#define BE_USE_GC_MODULE 1
#define BE_USE_SOLIDIFY_MODULE 0
#define BE_USE_INTROSPECT_MODULE 1
#define BE_USE_STRICT_MODULE 1
#ifdef USE_BERRY_DEBUG #ifdef TASMOTA
#define BE_USE_STRING_MODULE 1
#define BE_USE_JSON_MODULE 1
#define BE_USE_MATH_MODULE 1
#define BE_USE_TIME_MODULE 0
#define BE_USE_OS_MODULE 0
#define BE_USE_GLOBAL_MODULE 1
#define BE_USE_SYS_MODULE 1
#define BE_USE_DEBUG_MODULE 0
#define BE_USE_GC_MODULE 1
#define BE_USE_SOLIDIFY_MODULE 0
#define BE_USE_INTROSPECT_MODULE 1
#define BE_USE_STRICT_MODULE 1
#else
#define BE_USE_STRING_MODULE 1
#define BE_USE_JSON_MODULE 1
#define BE_USE_MATH_MODULE 1
#define BE_USE_TIME_MODULE 1
#define BE_USE_OS_MODULE 1
#define BE_USE_GLOBAL_MODULE 1
#define BE_USE_SYS_MODULE 1
#define BE_USE_DEBUG_MODULE 1
#define BE_USE_GC_MODULE 1
#define BE_USE_SOLIDIFY_MODULE 1
#define BE_USE_INTROSPECT_MODULE 1
#define BE_USE_STRICT_MODULE 1
#endif
#if defined(USE_BERRY_DEBUG) || !defined(TASMOTA)
#undef BE_USE_DEBUG_MODULE #undef BE_USE_DEBUG_MODULE
#undef BE_USE_SOLIDIFY_MODULE #undef BE_USE_SOLIDIFY_MODULE
#define BE_USE_DEBUG_MODULE 1 #define BE_USE_DEBUG_MODULE 1

2
lib/libesp32/berry/tools/coc/coc Normal file → Executable file
View File

@ -31,7 +31,7 @@ class builder:
sb.build(self.output) sb.build(self.output)
def parse_file(self, filename): def parse_file(self, filename):
if re.search(r"\.(c|cc|cpp)$", filename): if re.search(r"\.(h|c|cc|cpp)$", filename):
# print(f"> parse {filename}") # print(f"> parse {filename}")
text = "" text = ""
with open(filename) as f: with open(filename) as f:

View File

@ -0,0 +1,2 @@
# empty module
# allows stand-alone `import path`

View File

@ -0,0 +1,81 @@
#! ../berry/berry -s -g
#
# Berry solidify files
#
# `../berry/berry -s -g`
import os
import global
import solidify
import string
import re
# import sys
# sys.path().push('src/embedded') # allow to import from src/embedded
# globals that need to exist to make compilation succeed
var globs = "path,ctypes_bytes_dyn,tasmota,ccronexpr,gpio,light,webclient,load"
var files = ['tasmota_class.be', 'leds.be', 'animate_module.be', 'autoconf_module.be','driver_class.be']
for g:string.split(globs, ",")
global.(g) = nil
end
var prefix_dir = "src/embedded/"
var prefix_out = "src/solidify/"
def clean_directory(dir)
var file_list = os.listdir(dir)
for f : file_list
if f[0] == '.' continue end # ignore files starting with `.`
os.remove(dir + f)
end
end
var pattern = "#@\\s*solidify:([A-Za-z0-9_,]+)"
def parse_file(fname)
print("Parsing: ", fname)
var f = open(prefix_dir + fname)
var src = f.read()
f.close()
# try to compile
var compiled = compile(src)
compiled() # run the compile code to instanciate the classes and modules
# output solidified
var fname_h = string.split(fname, '.be')[0] + '.h' # take whatever is before the first '.be'
var fout = open(prefix_out + "solidified_" + fname_h, "w")
fout.write(string.format("/* Solidification of %s */\n", fname_h))
fout.write("/********************************************************************\\\n")
fout.write("* Generated code, don't edit *\n")
fout.write("\\********************************************************************/\n")
fout.write('#include "be_constobj.h"\n')
var directives = re.searchall(pattern, src)
# print(directives)
for directive : directives
var object_list = string.split(directive[1], ',')
var object_name = object_list[0]
var weak = (object_list.find('weak') != nil) # do we solidify with weak strings?
var o = global.(object_name)
solidify.dump(o, weak, fout)
end
fout.write("/********************************************************************/\n")
fout.write("/* End of solidification */\n")
fout.close()
end
clean_directory(prefix_out)
var src_file_list = os.listdir(prefix_dir)
for src_file : src_file_list
if src_file[0] == '.' continue end
end
# manual
for f : files
parse_file(f)
end

View File

@ -4,709 +4,4 @@
* To use: `import animate` * To use: `import animate`
* *
*******************************************************************/ *******************************************************************/
#include "be_constobj.h" #include "solidify/solidified_animate_module.h"
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_rotate_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 8]) { /* constants */
/* K0 */ be_nested_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
/* K6 */ be_nested_str(ins_goto),
/* K7 */ be_const_int(0),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[25]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x5C2C0800, // 000C MOVE R11 R4
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x88140102, // 000F GETMBR R5 R0 K2
0x8C140B03, // 0010 GETMET R5 R5 K3
0xB81E0800, // 0011 GETNGBL R7 K4
0x8C1C0F06, // 0012 GETMET R7 R7 K6
0x58240007, // 0013 LDCONST R9 K7
0x58280007, // 0014 LDCONST R10 K7
0x582C0007, // 0015 LDCONST R11 K7
0x7C1C0800, // 0016 CALL R7 4
0x7C140400, // 0017 CALL R5 2
0x80000000, // 0018 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_rotate
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_rotate,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_rotate_init_closure) },
})),
be_str_weak(Animate_rotate)
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_from_to_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* 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_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[16]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x5C2C0800, // 000C MOVE R11 R4
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x80000000, // 000F RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_from_to
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_from_to,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_from_to_init_closure) },
})),
be_str_weak(Animate_from_to)
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_back_forth_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 9]) { /* constants */
/* K0 */ be_nested_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
/* K6 */ be_const_int(2),
/* K7 */ be_nested_str(ins_goto),
/* K8 */ be_const_int(0),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[34]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x0C2C0906, // 000C DIV R11 R4 K6
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x88140102, // 000F GETMBR R5 R0 K2
0x8C140B03, // 0010 GETMET R5 R5 K3
0xB81E0800, // 0011 GETNGBL R7 K4
0x8C1C0F05, // 0012 GETMET R7 R7 K5
0x5C240600, // 0013 MOVE R9 R3
0x5C280400, // 0014 MOVE R10 R2
0x0C2C0906, // 0015 DIV R11 R4 K6
0x7C1C0800, // 0016 CALL R7 4
0x7C140400, // 0017 CALL R5 2
0x88140102, // 0018 GETMBR R5 R0 K2
0x8C140B03, // 0019 GETMET R5 R5 K3
0xB81E0800, // 001A GETNGBL R7 K4
0x8C1C0F07, // 001B GETMET R7 R7 K7
0x58240008, // 001C LDCONST R9 K8
0x58280008, // 001D LDCONST R10 K8
0x582C0008, // 001E LDCONST R11 K8
0x7C1C0800, // 001F CALL R7 4
0x7C140400, // 0020 CALL R5 2
0x80000000, // 0021 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_back_forth
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_back_forth,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_back_forth_init_closure) },
})),
be_str_weak(Animate_back_forth)
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_ins_goto_init, /* name */
be_nested_proto(
4, /* nstack */
4, /* argc */
2, /* 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_str(pc_rel),
/* K1 */ be_nested_str(pc_abs),
/* K2 */ be_nested_str(duration),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x90020202, // 0001 SETMBR R0 K1 R2
0x90020403, // 0002 SETMBR R0 K2 R3
0x80000000, // 0003 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_ins_goto
********************************************************************/
be_local_class(Animate_ins_goto,
3,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(pc_rel, -1), be_const_var(0) },
{ be_const_key(duration, -1), be_const_var(2) },
{ be_const_key(pc_abs, -1), be_const_var(1) },
{ be_const_key(init, 2), be_const_closure(Animate_ins_goto_init_closure) },
})),
be_str_weak(Animate_ins_goto)
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_ins_ramp_init, /* name */
be_nested_proto(
4, /* nstack */
4, /* argc */
2, /* 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_str(a),
/* K1 */ be_nested_str(b),
/* K2 */ be_nested_str(duration),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x90020202, // 0001 SETMBR R0 K1 R2
0x90020403, // 0002 SETMBR R0 K2 R3
0x80000000, // 0003 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_ins_ramp
********************************************************************/
be_local_class(Animate_ins_ramp,
3,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(a, -1), be_const_var(0) },
{ be_const_key(b, 2), be_const_var(1) },
{ be_const_key(duration, -1), be_const_var(2) },
{ be_const_key(init, -1), be_const_closure(Animate_ins_ramp_init_closure) },
})),
be_str_weak(Animate_ins_ramp)
);
/********************************************************************
** Solidified function: run
********************************************************************/
be_local_closure(Animate_engine_run, /* name */
be_nested_proto(
6, /* nstack */
3, /* argc */
2, /* 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_str(tasmota),
/* K1 */ be_nested_str(millis),
/* K2 */ be_nested_str(value),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(running),
/* K5 */ be_nested_str(add_driver),
}),
&be_const_str_run,
&be_const_str_solidified,
( &(const binstruction[19]) { /* code */
0x4C0C0000, // 0000 LDNIL R3
0x1C0C0203, // 0001 EQ R3 R1 R3
0x780E0003, // 0002 JMPF R3 #0007
0xB80E0000, // 0003 GETNGBL R3 K0
0x8C0C0701, // 0004 GETMET R3 R3 K1
0x7C0C0200, // 0005 CALL R3 1
0x5C040600, // 0006 MOVE R1 R3
0x4C0C0000, // 0007 LDNIL R3
0x200C0403, // 0008 NE R3 R2 R3
0x780E0000, // 0009 JMPF R3 #000B
0x90020402, // 000A SETMBR R0 K2 R2
0x90020601, // 000B SETMBR R0 K3 R1
0x500C0200, // 000C LDBOOL R3 1 0
0x90020803, // 000D SETMBR R0 K4 R3
0xB80E0000, // 000E GETNGBL R3 K0
0x8C0C0705, // 000F GETMET R3 R3 K5
0x5C140000, // 0010 MOVE R5 R0
0x7C0C0400, // 0011 CALL R3 2
0x80000000, // 0012 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_engine_init, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
2, /* 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_str(code),
/* K1 */ be_nested_str(pc),
/* K2 */ be_const_int(0),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(running),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 8]) { /* code */
0x60040012, // 0000 GETGBL R1 G18
0x7C040000, // 0001 CALL R1 0
0x90020001, // 0002 SETMBR R0 K0 R1
0x90020302, // 0003 SETMBR R0 K1 K2
0x90020702, // 0004 SETMBR R0 K3 K2
0x50040000, // 0005 LDBOOL R1 0 0
0x90020801, // 0006 SETMBR R0 K4 R1
0x80000000, // 0007 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: autorun
********************************************************************/
be_local_closure(Animate_engine_autorun, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
2, /* 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_str(run),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(add_driver),
}),
&be_const_str_autorun,
&be_const_str_solidified,
( &(const binstruction[ 9]) { /* code */
0x8C0C0100, // 0000 GETMET R3 R0 K0
0x5C140200, // 0001 MOVE R5 R1
0x5C180400, // 0002 MOVE R6 R2
0x7C0C0600, // 0003 CALL R3 3
0xB80E0200, // 0004 GETNGBL R3 K1
0x8C0C0702, // 0005 GETMET R3 R3 K2
0x5C140000, // 0006 MOVE R5 R0
0x7C0C0400, // 0007 CALL R3 2
0x80000000, // 0008 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: stop
********************************************************************/
be_local_closure(Animate_engine_stop, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
2, /* 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_str(running),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(remove_driver),
}),
&be_const_str_stop,
&be_const_str_solidified,
( &(const binstruction[ 7]) { /* code */
0x50040000, // 0000 LDBOOL R1 0 0
0x90020001, // 0001 SETMBR R0 K0 R1
0xB8060200, // 0002 GETNGBL R1 K1
0x8C040302, // 0003 GETMET R1 R1 K2
0x5C0C0000, // 0004 MOVE R3 R0
0x7C040400, // 0005 CALL R1 2
0x80000000, // 0006 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: is_running
********************************************************************/
be_local_closure(Animate_engine_is_running, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(running),
}),
&be_const_str_is_running,
&be_const_str_solidified,
( &(const binstruction[ 2]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x80040200, // 0001 RET 1 R1
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: every_50ms
********************************************************************/
be_local_closure(Animate_engine_every_50ms, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(animate),
}),
&be_const_str_every_50ms,
&be_const_str_solidified,
( &(const binstruction[ 3]) { /* code */
0x8C040100, // 0000 GETMET R1 R0 K0
0x7C040200, // 0001 CALL R1 1
0x80000000, // 0002 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: animate
********************************************************************/
be_local_closure(Animate_engine_animate, /* name */
be_nested_proto(
12, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[22]) { /* constants */
/* K0 */ be_nested_str(running),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(millis),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(pc),
/* K5 */ be_nested_str(code),
/* K6 */ be_const_int(0),
/* K7 */ be_nested_str(internal_error),
/* K8 */ be_nested_str(Animate_X20pc_X20is_X20out_X20of_X20range),
/* K9 */ be_nested_str(animate),
/* K10 */ be_nested_str(ins_ramp),
/* K11 */ be_nested_str(closure),
/* K12 */ be_nested_str(duration),
/* K13 */ be_nested_str(value),
/* K14 */ be_nested_str(scale_uint),
/* K15 */ be_nested_str(a),
/* K16 */ be_nested_str(b),
/* K17 */ be_const_int(1),
/* K18 */ be_nested_str(ins_goto),
/* K19 */ be_nested_str(pc_rel),
/* K20 */ be_nested_str(pc_abs),
/* K21 */ be_nested_str(unknown_X20instruction),
}),
&be_const_str_animate,
&be_const_str_solidified,
( &(const binstruction[99]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x740A0000, // 0001 JMPT R2 #0003
0x80000400, // 0002 RET 0
0x4C080000, // 0003 LDNIL R2
0x1C080202, // 0004 EQ R2 R1 R2
0x780A0003, // 0005 JMPF R2 #000A
0xB80A0200, // 0006 GETNGBL R2 K1
0x8C080502, // 0007 GETMET R2 R2 K2
0x7C080200, // 0008 CALL R2 1
0x5C040400, // 0009 MOVE R1 R2
0x50080200, // 000A LDBOOL R2 1 0
0x780A0054, // 000B JMPF R2 #0061
0x88080103, // 000C GETMBR R2 R0 K3
0x04080202, // 000D SUB R2 R1 R2
0x880C0104, // 000E GETMBR R3 R0 K4
0x6010000C, // 000F GETGBL R4 G12
0x88140105, // 0010 GETMBR R5 R0 K5
0x7C100200, // 0011 CALL R4 1
0x280C0604, // 0012 GE R3 R3 R4
0x780E0002, // 0013 JMPF R3 #0017
0x500C0000, // 0014 LDBOOL R3 0 0
0x90020003, // 0015 SETMBR R0 K0 R3
0x70020049, // 0016 JMP #0061
0x880C0104, // 0017 GETMBR R3 R0 K4
0x140C0706, // 0018 LT R3 R3 K6
0x780E0000, // 0019 JMPF R3 #001B
0xB0060F08, // 001A RAISE 1 K7 K8
0x880C0104, // 001B GETMBR R3 R0 K4
0x88100105, // 001C GETMBR R4 R0 K5
0x940C0803, // 001D GETIDX R3 R4 R3
0x6014000F, // 001E GETGBL R5 G15
0x5C180600, // 001F MOVE R6 R3
0xB81E1200, // 0020 GETNGBL R7 K9
0x881C0F0A, // 0021 GETMBR R7 R7 K10
0x7C140400, // 0022 CALL R5 2
0x78160020, // 0023 JMPF R5 #0045
0x8810010B, // 0024 GETMBR R4 R0 K11
0x8814070C, // 0025 GETMBR R5 R3 K12
0x14140405, // 0026 LT R5 R2 R5
0x7816000E, // 0027 JMPF R5 #0037
0xB8160200, // 0028 GETNGBL R5 K1
0x8C140B0E, // 0029 GETMET R5 R5 K14
0x5C1C0400, // 002A MOVE R7 R2
0x58200006, // 002B LDCONST R8 K6
0x8824070C, // 002C GETMBR R9 R3 K12
0x8828070F, // 002D GETMBR R10 R3 K15
0x882C0710, // 002E GETMBR R11 R3 K16
0x7C140C00, // 002F CALL R5 6
0x90021A05, // 0030 SETMBR R0 K13 R5
0x78120002, // 0031 JMPF R4 #0035
0x5C140800, // 0032 MOVE R5 R4
0x8818010D, // 0033 GETMBR R6 R0 K13
0x7C140200, // 0034 CALL R5 1
0x7002002A, // 0035 JMP #0061
0x7002000C, // 0036 JMP #0044
0x88140710, // 0037 GETMBR R5 R3 K16
0x90021A05, // 0038 SETMBR R0 K13 R5
0x78120002, // 0039 JMPF R4 #003D
0x5C140800, // 003A MOVE R5 R4
0x8818010D, // 003B GETMBR R6 R0 K13
0x7C140200, // 003C CALL R5 1
0x88140104, // 003D GETMBR R5 R0 K4
0x00140B11, // 003E ADD R5 R5 K17
0x90020805, // 003F SETMBR R0 K4 R5
0x8814070C, // 0040 GETMBR R5 R3 K12
0x04140405, // 0041 SUB R5 R2 R5
0x04140205, // 0042 SUB R5 R1 R5
0x90020605, // 0043 SETMBR R0 K3 R5
0x7002001A, // 0044 JMP #0060
0x6010000F, // 0045 GETGBL R4 G15
0x5C140600, // 0046 MOVE R5 R3
0xB81A1200, // 0047 GETNGBL R6 K9
0x88180D12, // 0048 GETMBR R6 R6 K18
0x7C100400, // 0049 CALL R4 2
0x78120013, // 004A JMPF R4 #005F
0x8810070C, // 004B GETMBR R4 R3 K12
0x14100404, // 004C LT R4 R2 R4
0x78120001, // 004D JMPF R4 #0050
0x70020011, // 004E JMP #0061
0x7002000D, // 004F JMP #005E
0x88100713, // 0050 GETMBR R4 R3 K19
0x20100906, // 0051 NE R4 R4 K6
0x78120004, // 0052 JMPF R4 #0058
0x88100104, // 0053 GETMBR R4 R0 K4
0x88140713, // 0054 GETMBR R5 R3 K19
0x00100805, // 0055 ADD R4 R4 R5
0x90020804, // 0056 SETMBR R0 K4 R4
0x70020001, // 0057 JMP #005A
0x88100714, // 0058 GETMBR R4 R3 K20
0x90020804, // 0059 SETMBR R0 K4 R4
0x8810070C, // 005A GETMBR R4 R3 K12
0x04100404, // 005B SUB R4 R2 R4
0x04100204, // 005C SUB R4 R1 R4
0x90020604, // 005D SETMBR R0 K3 R4
0x70020000, // 005E JMP #0060
0xB0060F15, // 005F RAISE 1 K7 K21
0x7001FFA8, // 0060 JMP #000A
0x8808010D, // 0061 GETMBR R2 R0 K13
0x80040400, // 0062 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_engine
********************************************************************/
be_local_class(Animate_engine,
6,
NULL,
be_nested_map(13,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(code, -1), be_const_var(0) },
{ be_const_key(run, 4), be_const_closure(Animate_engine_run_closure) },
{ be_const_key(running, 8), be_const_var(4) },
{ be_const_key(init, -1), be_const_closure(Animate_engine_init_closure) },
{ be_const_key(autorun, -1), be_const_closure(Animate_engine_autorun_closure) },
{ be_const_key(value, -1), be_const_var(5) },
{ be_const_key(stop, 3), be_const_closure(Animate_engine_stop_closure) },
{ be_const_key(pc, -1), be_const_var(2) },
{ be_const_key(is_running, 11), be_const_closure(Animate_engine_is_running_closure) },
{ be_const_key(every_50ms, 10), be_const_closure(Animate_engine_every_50ms_closure) },
{ be_const_key(animate, -1), be_const_closure(Animate_engine_animate_closure) },
{ be_const_key(closure, -1), be_const_var(1) },
{ be_const_key(ins_time, 9), be_const_var(3) },
})),
be_str_weak(Animate_engine)
);
/********************************************************************
** Solidified module: animate
********************************************************************/
be_local_module(animate,
"animate",
be_nested_map(6,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(rotate, 2), be_const_class(be_class_Animate_rotate) },
{ be_const_key(from_to, 3), be_const_class(be_class_Animate_from_to) },
{ be_const_key(back_forth, -1), be_const_class(be_class_Animate_back_forth) },
{ be_const_key(ins_goto, -1), be_const_class(be_class_Animate_ins_goto) },
{ be_const_key(ins_ramp, -1), be_const_class(be_class_Animate_ins_ramp) },
{ be_const_key(engine, -1), be_const_class(be_class_Animate_engine) },
}))
);
BE_EXPORT_VARIABLE be_define_const_native_module(animate);
/********************************************************************/

File diff suppressed because it is too large Load Diff

View File

@ -4,97 +4,4 @@
* To use: `d = Driver()` * To use: `d = Driver()`
* *
*******************************************************************/ *******************************************************************/
#include "be_constobj.h" #include "solidify/solidified_driver_class.h"
/********************************************************************
** Solidified function: add_cmd
********************************************************************/
be_local_closure(Driver_add_cmd, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
( &(const struct bproto*[ 1]) {
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 2]) { /* upvals */
be_local_const_upval(1, 2),
be_local_const_upval(1, 0),
}),
0, /* has sup protos */
NULL, /* no sub protos */
0, /* has constants */
NULL, /* no const */
&be_const_str__X3Clambda_X3E,
&be_const_str_solidified,
( &(const binstruction[ 8]) { /* code */
0x68100000, // 0000 GETUPV R4 U0
0x68140001, // 0001 GETUPV R5 U1
0x5C180000, // 0002 MOVE R6 R0
0x5C1C0200, // 0003 MOVE R7 R1
0x5C200400, // 0004 MOVE R8 R2
0x5C240600, // 0005 MOVE R9 R3
0x7C100A00, // 0006 CALL R4 5
0x80040800, // 0007 RET 1 R4
})
),
}),
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(tasmota),
/* K1 */ be_nested_str(add_cmd),
}),
&be_const_str_add_cmd,
&be_const_str_solidified,
( &(const binstruction[ 7]) { /* code */
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 R0
0x80000000, // 0006 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Driver
********************************************************************/
be_local_class(Driver,
13,
NULL,
be_nested_map(14,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(web_add_console_button, 6), be_const_var(7) },
{ be_const_key(web_add_config_button, -1), be_const_var(6) },
{ be_const_key(button_pressed, 9), be_const_var(11) },
{ be_const_key(every_second, 1), be_const_var(0) },
{ be_const_key(web_add_handler, 11), be_const_var(2) },
{ be_const_key(add_cmd, -1), be_const_closure(Driver_add_cmd_closure) },
{ be_const_key(web_sensor, -1), be_const_var(9) },
{ be_const_key(display, -1), be_const_var(12) },
{ be_const_key(web_add_main_button, 2), be_const_var(4) },
{ be_const_key(save_before_restart, -1), be_const_var(8) },
{ be_const_key(web_add_management_button, 0), be_const_var(5) },
{ be_const_key(every_100ms, 13), be_const_var(1) },
{ be_const_key(json_append, -1), be_const_var(10) },
{ be_const_key(web_add_button, -1), be_const_var(3) },
})),
be_str_weak(Driver)
);
/*******************************************************************/
void be_load_Driver_class(bvm *vm) {
be_pushntvclass(vm, &be_class_Driver);
be_setglobal(vm, "Driver");
be_pop(vm, 1);
}

File diff suppressed because it is too large Load Diff

View File

@ -182,6 +182,7 @@ class Animate_back_forth : Animate_engine
end end
animate.back_forth = Animate_back_forth animate.back_forth = Animate_back_forth
#@ solidify:animate
#- #-
a=Animate_back_forth(nil, 0, 100, 5000) a=Animate_back_forth(nil, 0, 100, 5000)

View File

@ -382,8 +382,11 @@ autoconf_module.init = def (m)
return Autoconf() # return an instance of this class return Autoconf() # return an instance of this class
end end
#@ solidify:autoconf_module
#-
aa = autoconf_module.init(autoconf_module) aa = autoconf_module.init(autoconf_module)
import webserver import webserver
webserver.on('/ac2', / -> aa.page_autoconf_mgr(), webserver.HTTP_GET) webserver.on('/ac2', / -> aa.page_autoconf_mgr(), webserver.HTTP_GET)
return autoconf_module return autoconf_module
-#

View File

@ -1,6 +1,7 @@
#- Native code used for testing and code solidification -# #- Native code used for testing and code solidification -#
#- Do not use it -# #- Do not use it -#
#@ solidify:Driver
class Driver class Driver
var every_second var every_second
var every_100ms var every_100ms

View File

@ -23,6 +23,7 @@
class Leds_ntv end class Leds_ntv end
#@ solidify:Leds
class Leds : Leds_ntv class Leds : Leds_ntv
var gamma # if true, apply gamma (true is default) var gamma # if true, apply gamma (true is default)
var leds # number of leds var leds # number of leds

View File

@ -1,6 +1,7 @@
#- Native code used for testing and code solidification -# #- Native code used for testing and code solidification -#
#- Do not use it -# #- Do not use it -#
#@ solidify:Trigger
class Trigger class Trigger
var trig, f, id var trig, f, id
var o # optional object var o # optional object
@ -31,6 +32,7 @@ class Trigger
end end
tasmota = nil tasmota = nil
#@ solidify:Tasmota
class Tasmota class Tasmota
var _fl # list of fast_loop registered closures var _fl # list of fast_loop registered closures
var _rules var _rules

View File

@ -0,0 +1,712 @@
/* Solidification of animate_module.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_rotate_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 8]) { /* constants */
/* K0 */ be_nested_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
/* K6 */ be_nested_str(ins_goto),
/* K7 */ be_const_int(0),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[25]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x5C2C0800, // 000C MOVE R11 R4
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x88140102, // 000F GETMBR R5 R0 K2
0x8C140B03, // 0010 GETMET R5 R5 K3
0xB81E0800, // 0011 GETNGBL R7 K4
0x8C1C0F06, // 0012 GETMET R7 R7 K6
0x58240007, // 0013 LDCONST R9 K7
0x58280007, // 0014 LDCONST R10 K7
0x582C0007, // 0015 LDCONST R11 K7
0x7C1C0800, // 0016 CALL R7 4
0x7C140400, // 0017 CALL R5 2
0x80000000, // 0018 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_rotate
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_rotate,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_rotate_init_closure) },
})),
(bstring*) &be_const_str_Animate_rotate
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_from_to_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* 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_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[16]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x5C2C0800, // 000C MOVE R11 R4
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x80000000, // 000F RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_from_to
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_from_to,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_from_to_init_closure) },
})),
(bstring*) &be_const_str_Animate_from_to
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_back_forth_init, /* name */
be_nested_proto(
12, /* nstack */
5, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 9]) { /* constants */
/* K0 */ be_nested_str(init),
/* K1 */ be_nested_str(closure),
/* K2 */ be_nested_str(code),
/* K3 */ be_nested_str(push),
/* K4 */ be_nested_str(animate),
/* K5 */ be_nested_str(ins_ramp),
/* K6 */ be_const_int(2),
/* K7 */ be_nested_str(ins_goto),
/* K8 */ be_const_int(0),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[34]) { /* code */
0x60140003, // 0000 GETGBL R5 G3
0x5C180000, // 0001 MOVE R6 R0
0x7C140200, // 0002 CALL R5 1
0x8C140B00, // 0003 GETMET R5 R5 K0
0x7C140200, // 0004 CALL R5 1
0x90020201, // 0005 SETMBR R0 K1 R1
0x88140102, // 0006 GETMBR R5 R0 K2
0x8C140B03, // 0007 GETMET R5 R5 K3
0xB81E0800, // 0008 GETNGBL R7 K4
0x8C1C0F05, // 0009 GETMET R7 R7 K5
0x5C240400, // 000A MOVE R9 R2
0x5C280600, // 000B MOVE R10 R3
0x0C2C0906, // 000C DIV R11 R4 K6
0x7C1C0800, // 000D CALL R7 4
0x7C140400, // 000E CALL R5 2
0x88140102, // 000F GETMBR R5 R0 K2
0x8C140B03, // 0010 GETMET R5 R5 K3
0xB81E0800, // 0011 GETNGBL R7 K4
0x8C1C0F05, // 0012 GETMET R7 R7 K5
0x5C240600, // 0013 MOVE R9 R3
0x5C280400, // 0014 MOVE R10 R2
0x0C2C0906, // 0015 DIV R11 R4 K6
0x7C1C0800, // 0016 CALL R7 4
0x7C140400, // 0017 CALL R5 2
0x88140102, // 0018 GETMBR R5 R0 K2
0x8C140B03, // 0019 GETMET R5 R5 K3
0xB81E0800, // 001A GETNGBL R7 K4
0x8C1C0F07, // 001B GETMET R7 R7 K7
0x58240008, // 001C LDCONST R9 K8
0x58280008, // 001D LDCONST R10 K8
0x582C0008, // 001E LDCONST R11 K8
0x7C1C0800, // 001F CALL R7 4
0x7C140400, // 0020 CALL R5 2
0x80000000, // 0021 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_back_forth
********************************************************************/
extern const bclass be_class_Animate_engine;
be_local_class(Animate_back_forth,
0,
&be_class_Animate_engine,
be_nested_map(1,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(Animate_back_forth_init_closure) },
})),
(bstring*) &be_const_str_Animate_back_forth
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_ins_goto_init, /* name */
be_nested_proto(
4, /* nstack */
4, /* argc */
2, /* 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_str(pc_rel),
/* K1 */ be_nested_str(pc_abs),
/* K2 */ be_nested_str(duration),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x90020202, // 0001 SETMBR R0 K1 R2
0x90020403, // 0002 SETMBR R0 K2 R3
0x80000000, // 0003 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_ins_goto
********************************************************************/
be_local_class(Animate_ins_goto,
3,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(pc_rel, -1), be_const_var(0) },
{ be_const_key(duration, -1), be_const_var(2) },
{ be_const_key(init, -1), be_const_closure(Animate_ins_goto_init_closure) },
{ be_const_key(pc_abs, 2), be_const_var(1) },
})),
(bstring*) &be_const_str_Animate_ins_goto
);
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_ins_ramp_init, /* name */
be_nested_proto(
4, /* nstack */
4, /* argc */
2, /* 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_str(a),
/* K1 */ be_nested_str(b),
/* K2 */ be_nested_str(duration),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 4]) { /* code */
0x90020001, // 0000 SETMBR R0 K0 R1
0x90020202, // 0001 SETMBR R0 K1 R2
0x90020403, // 0002 SETMBR R0 K2 R3
0x80000000, // 0003 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_ins_ramp
********************************************************************/
be_local_class(Animate_ins_ramp,
3,
NULL,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(a, -1), be_const_var(0) },
{ be_const_key(b, 2), be_const_var(1) },
{ be_const_key(duration, -1), be_const_var(2) },
{ be_const_key(init, -1), be_const_closure(Animate_ins_ramp_init_closure) },
})),
(bstring*) &be_const_str_Animate_ins_ramp
);
/********************************************************************
** Solidified function: run
********************************************************************/
be_local_closure(Animate_engine_run, /* name */
be_nested_proto(
6, /* nstack */
3, /* argc */
2, /* 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_str(tasmota),
/* K1 */ be_nested_str(millis),
/* K2 */ be_nested_str(value),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(running),
/* K5 */ be_nested_str(add_driver),
}),
&be_const_str_run,
&be_const_str_solidified,
( &(const binstruction[19]) { /* code */
0x4C0C0000, // 0000 LDNIL R3
0x1C0C0203, // 0001 EQ R3 R1 R3
0x780E0003, // 0002 JMPF R3 #0007
0xB80E0000, // 0003 GETNGBL R3 K0
0x8C0C0701, // 0004 GETMET R3 R3 K1
0x7C0C0200, // 0005 CALL R3 1
0x5C040600, // 0006 MOVE R1 R3
0x4C0C0000, // 0007 LDNIL R3
0x200C0403, // 0008 NE R3 R2 R3
0x780E0000, // 0009 JMPF R3 #000B
0x90020402, // 000A SETMBR R0 K2 R2
0x90020601, // 000B SETMBR R0 K3 R1
0x500C0200, // 000C LDBOOL R3 1 0
0x90020803, // 000D SETMBR R0 K4 R3
0xB80E0000, // 000E GETNGBL R3 K0
0x8C0C0705, // 000F GETMET R3 R3 K5
0x5C140000, // 0010 MOVE R5 R0
0x7C0C0400, // 0011 CALL R3 2
0x80000000, // 0012 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(Animate_engine_init, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
2, /* 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_str(code),
/* K1 */ be_nested_str(pc),
/* K2 */ be_const_int(0),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(running),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 8]) { /* code */
0x60040012, // 0000 GETGBL R1 G18
0x7C040000, // 0001 CALL R1 0
0x90020001, // 0002 SETMBR R0 K0 R1
0x90020302, // 0003 SETMBR R0 K1 K2
0x90020702, // 0004 SETMBR R0 K3 K2
0x50040000, // 0005 LDBOOL R1 0 0
0x90020801, // 0006 SETMBR R0 K4 R1
0x80000000, // 0007 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: autorun
********************************************************************/
be_local_closure(Animate_engine_autorun, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
2, /* 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_str(run),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(add_driver),
}),
&be_const_str_autorun,
&be_const_str_solidified,
( &(const binstruction[ 9]) { /* code */
0x8C0C0100, // 0000 GETMET R3 R0 K0
0x5C140200, // 0001 MOVE R5 R1
0x5C180400, // 0002 MOVE R6 R2
0x7C0C0600, // 0003 CALL R3 3
0xB80E0200, // 0004 GETNGBL R3 K1
0x8C0C0702, // 0005 GETMET R3 R3 K2
0x5C140000, // 0006 MOVE R5 R0
0x7C0C0400, // 0007 CALL R3 2
0x80000000, // 0008 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: stop
********************************************************************/
be_local_closure(Animate_engine_stop, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
2, /* 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_str(running),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(remove_driver),
}),
&be_const_str_stop,
&be_const_str_solidified,
( &(const binstruction[ 7]) { /* code */
0x50040000, // 0000 LDBOOL R1 0 0
0x90020001, // 0001 SETMBR R0 K0 R1
0xB8060200, // 0002 GETNGBL R1 K1
0x8C040302, // 0003 GETMET R1 R1 K2
0x5C0C0000, // 0004 MOVE R3 R0
0x7C040400, // 0005 CALL R1 2
0x80000000, // 0006 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: is_running
********************************************************************/
be_local_closure(Animate_engine_is_running, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(running),
}),
&be_const_str_is_running,
&be_const_str_solidified,
( &(const binstruction[ 2]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x80040200, // 0001 RET 1 R1
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: every_50ms
********************************************************************/
be_local_closure(Animate_engine_every_50ms, /* name */
be_nested_proto(
3, /* nstack */
1, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(animate),
}),
&be_const_str_every_50ms,
&be_const_str_solidified,
( &(const binstruction[ 3]) { /* code */
0x8C040100, // 0000 GETMET R1 R0 K0
0x7C040200, // 0001 CALL R1 1
0x80000000, // 0002 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: animate
********************************************************************/
be_local_closure(Animate_engine_animate, /* name */
be_nested_proto(
12, /* nstack */
2, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[22]) { /* constants */
/* K0 */ be_nested_str(running),
/* K1 */ be_nested_str(tasmota),
/* K2 */ be_nested_str(millis),
/* K3 */ be_nested_str(ins_time),
/* K4 */ be_nested_str(pc),
/* K5 */ be_nested_str(code),
/* K6 */ be_const_int(0),
/* K7 */ be_nested_str(internal_error),
/* K8 */ be_nested_str(Animate_X20pc_X20is_X20out_X20of_X20range),
/* K9 */ be_nested_str(animate),
/* K10 */ be_nested_str(ins_ramp),
/* K11 */ be_nested_str(closure),
/* K12 */ be_nested_str(duration),
/* K13 */ be_nested_str(value),
/* K14 */ be_nested_str(scale_uint),
/* K15 */ be_nested_str(a),
/* K16 */ be_nested_str(b),
/* K17 */ be_const_int(1),
/* K18 */ be_nested_str(ins_goto),
/* K19 */ be_nested_str(pc_rel),
/* K20 */ be_nested_str(pc_abs),
/* K21 */ be_nested_str(unknown_X20instruction),
}),
&be_const_str_animate,
&be_const_str_solidified,
( &(const binstruction[99]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x740A0000, // 0001 JMPT R2 #0003
0x80000400, // 0002 RET 0
0x4C080000, // 0003 LDNIL R2
0x1C080202, // 0004 EQ R2 R1 R2
0x780A0003, // 0005 JMPF R2 #000A
0xB80A0200, // 0006 GETNGBL R2 K1
0x8C080502, // 0007 GETMET R2 R2 K2
0x7C080200, // 0008 CALL R2 1
0x5C040400, // 0009 MOVE R1 R2
0x50080200, // 000A LDBOOL R2 1 0
0x780A0054, // 000B JMPF R2 #0061
0x88080103, // 000C GETMBR R2 R0 K3
0x04080202, // 000D SUB R2 R1 R2
0x880C0104, // 000E GETMBR R3 R0 K4
0x6010000C, // 000F GETGBL R4 G12
0x88140105, // 0010 GETMBR R5 R0 K5
0x7C100200, // 0011 CALL R4 1
0x280C0604, // 0012 GE R3 R3 R4
0x780E0002, // 0013 JMPF R3 #0017
0x500C0000, // 0014 LDBOOL R3 0 0
0x90020003, // 0015 SETMBR R0 K0 R3
0x70020049, // 0016 JMP #0061
0x880C0104, // 0017 GETMBR R3 R0 K4
0x140C0706, // 0018 LT R3 R3 K6
0x780E0000, // 0019 JMPF R3 #001B
0xB0060F08, // 001A RAISE 1 K7 K8
0x880C0104, // 001B GETMBR R3 R0 K4
0x88100105, // 001C GETMBR R4 R0 K5
0x940C0803, // 001D GETIDX R3 R4 R3
0x6014000F, // 001E GETGBL R5 G15
0x5C180600, // 001F MOVE R6 R3
0xB81E1200, // 0020 GETNGBL R7 K9
0x881C0F0A, // 0021 GETMBR R7 R7 K10
0x7C140400, // 0022 CALL R5 2
0x78160020, // 0023 JMPF R5 #0045
0x8810010B, // 0024 GETMBR R4 R0 K11
0x8814070C, // 0025 GETMBR R5 R3 K12
0x14140405, // 0026 LT R5 R2 R5
0x7816000E, // 0027 JMPF R5 #0037
0xB8160200, // 0028 GETNGBL R5 K1
0x8C140B0E, // 0029 GETMET R5 R5 K14
0x5C1C0400, // 002A MOVE R7 R2
0x58200006, // 002B LDCONST R8 K6
0x8824070C, // 002C GETMBR R9 R3 K12
0x8828070F, // 002D GETMBR R10 R3 K15
0x882C0710, // 002E GETMBR R11 R3 K16
0x7C140C00, // 002F CALL R5 6
0x90021A05, // 0030 SETMBR R0 K13 R5
0x78120002, // 0031 JMPF R4 #0035
0x5C140800, // 0032 MOVE R5 R4
0x8818010D, // 0033 GETMBR R6 R0 K13
0x7C140200, // 0034 CALL R5 1
0x7002002A, // 0035 JMP #0061
0x7002000C, // 0036 JMP #0044
0x88140710, // 0037 GETMBR R5 R3 K16
0x90021A05, // 0038 SETMBR R0 K13 R5
0x78120002, // 0039 JMPF R4 #003D
0x5C140800, // 003A MOVE R5 R4
0x8818010D, // 003B GETMBR R6 R0 K13
0x7C140200, // 003C CALL R5 1
0x88140104, // 003D GETMBR R5 R0 K4
0x00140B11, // 003E ADD R5 R5 K17
0x90020805, // 003F SETMBR R0 K4 R5
0x8814070C, // 0040 GETMBR R5 R3 K12
0x04140405, // 0041 SUB R5 R2 R5
0x04140205, // 0042 SUB R5 R1 R5
0x90020605, // 0043 SETMBR R0 K3 R5
0x7002001A, // 0044 JMP #0060
0x6010000F, // 0045 GETGBL R4 G15
0x5C140600, // 0046 MOVE R5 R3
0xB81A1200, // 0047 GETNGBL R6 K9
0x88180D12, // 0048 GETMBR R6 R6 K18
0x7C100400, // 0049 CALL R4 2
0x78120013, // 004A JMPF R4 #005F
0x8810070C, // 004B GETMBR R4 R3 K12
0x14100404, // 004C LT R4 R2 R4
0x78120001, // 004D JMPF R4 #0050
0x70020011, // 004E JMP #0061
0x7002000D, // 004F JMP #005E
0x88100713, // 0050 GETMBR R4 R3 K19
0x20100906, // 0051 NE R4 R4 K6
0x78120004, // 0052 JMPF R4 #0058
0x88100104, // 0053 GETMBR R4 R0 K4
0x88140713, // 0054 GETMBR R5 R3 K19
0x00100805, // 0055 ADD R4 R4 R5
0x90020804, // 0056 SETMBR R0 K4 R4
0x70020001, // 0057 JMP #005A
0x88100714, // 0058 GETMBR R4 R3 K20
0x90020804, // 0059 SETMBR R0 K4 R4
0x8810070C, // 005A GETMBR R4 R3 K12
0x04100404, // 005B SUB R4 R2 R4
0x04100204, // 005C SUB R4 R1 R4
0x90020604, // 005D SETMBR R0 K3 R4
0x70020000, // 005E JMP #0060
0xB0060F15, // 005F RAISE 1 K7 K21
0x7001FFA8, // 0060 JMP #000A
0x8808010D, // 0061 GETMBR R2 R0 K13
0x80040400, // 0062 RET 1 R2
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Animate_engine
********************************************************************/
be_local_class(Animate_engine,
6,
NULL,
be_nested_map(13,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(code, -1), be_const_var(0) },
{ be_const_key(run, 9), be_const_closure(Animate_engine_run_closure) },
{ be_const_key(running, 4), be_const_var(4) },
{ be_const_key(ins_time, 8), be_const_var(3) },
{ be_const_key(closure, 10), be_const_var(1) },
{ be_const_key(value, -1), be_const_var(5) },
{ be_const_key(init, 11), be_const_closure(Animate_engine_init_closure) },
{ be_const_key(pc, -1), be_const_var(2) },
{ be_const_key(animate, -1), be_const_closure(Animate_engine_animate_closure) },
{ be_const_key(autorun, -1), be_const_closure(Animate_engine_autorun_closure) },
{ be_const_key(is_running, -1), be_const_closure(Animate_engine_is_running_closure) },
{ be_const_key(stop, -1), be_const_closure(Animate_engine_stop_closure) },
{ be_const_key(every_50ms, 3), be_const_closure(Animate_engine_every_50ms_closure) },
})),
(bstring*) &be_const_str_Animate_engine
);
/********************************************************************
** Solidified module: animate
********************************************************************/
be_local_module(animate,
"animate",
be_nested_map(6,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(rotate, 2), be_const_class(be_class_Animate_rotate) },
{ be_const_key(from_to, 3), be_const_class(be_class_Animate_from_to) },
{ be_const_key(back_forth, -1), be_const_class(be_class_Animate_back_forth) },
{ be_const_key(ins_goto, -1), be_const_class(be_class_Animate_ins_goto) },
{ be_const_key(ins_ramp, -1), be_const_class(be_class_Animate_ins_ramp) },
{ be_const_key(engine, -1), be_const_class(be_class_Animate_engine) },
}))
);
BE_EXPORT_VARIABLE be_define_const_native_module(animate);
/********************************************************************/
/********************************************************************/
/* End of solidification */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,100 @@
/* Solidification of driver_class.h */
/********************************************************************\
* Generated code, don't edit *
\********************************************************************/
#include "be_constobj.h"
/********************************************************************
** Solidified function: add_cmd
********************************************************************/
be_local_closure(Driver_add_cmd, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
2, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
( &(const struct bproto*[ 1]) {
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 2]) { /* upvals */
be_local_const_upval(1, 2),
be_local_const_upval(1, 0),
}),
0, /* has sup protos */
NULL, /* no sub protos */
0, /* has constants */
NULL, /* no const */
&be_const_str__X3Clambda_X3E,
&be_const_str_solidified,
( &(const binstruction[ 8]) { /* code */
0x68100000, // 0000 GETUPV R4 U0
0x68140001, // 0001 GETUPV R5 U1
0x5C180000, // 0002 MOVE R6 R0
0x5C1C0200, // 0003 MOVE R7 R1
0x5C200400, // 0004 MOVE R8 R2
0x5C240600, // 0005 MOVE R9 R3
0x7C100A00, // 0006 CALL R4 5
0x80040800, // 0007 RET 1 R4
})
),
}),
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(tasmota),
/* K1 */ be_nested_str(add_cmd),
}),
&be_const_str_add_cmd,
&be_const_str_solidified,
( &(const binstruction[ 7]) { /* code */
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 R0
0x80000000, // 0006 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified class: Driver
********************************************************************/
be_local_class(Driver,
13,
NULL,
be_nested_map(14,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(web_add_console_button, 6), be_const_var(7) },
{ be_const_key(web_add_config_button, -1), be_const_var(6) },
{ be_const_key(button_pressed, 9), be_const_var(11) },
{ be_const_key(every_second, 1), be_const_var(0) },
{ be_const_key(web_add_handler, 11), be_const_var(2) },
{ be_const_key(add_cmd, -1), be_const_closure(Driver_add_cmd_closure) },
{ be_const_key(web_sensor, -1), be_const_var(9) },
{ be_const_key(display, -1), be_const_var(12) },
{ be_const_key(web_add_main_button, 2), be_const_var(4) },
{ be_const_key(save_before_restart, -1), be_const_var(8) },
{ be_const_key(web_add_management_button, 0), be_const_var(5) },
{ be_const_key(every_100ms, 13), be_const_var(1) },
{ be_const_key(json_append, -1), be_const_var(10) },
{ be_const_key(web_add_button, -1), be_const_var(3) },
})),
(bstring*) &be_const_str_Driver
);
/*******************************************************************/
void be_load_Driver_class(bvm *vm) {
be_pushntvclass(vm, &be_class_Driver);
be_setglobal(vm, "Driver");
be_pop(vm, 1);
}
/********************************************************************/
/* End of solidification */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -9,8 +9,11 @@ extern void berry_log_C(const char * berry_buf, ...);
void void
re1_5_fatal(const char *msg) re1_5_fatal(const char *msg)
{ {
#ifdef TASMOTA
berry_log_C("BRY: regex fatal error: %s", msg); berry_log_C("BRY: regex fatal error: %s", msg);
// fprintf(stderr, "fatal error: %s\n", msg); #else
fprintf(stderr, "fatal error: %s\n", msg);
#endif
exit(2); exit(2);
} }

View File

@ -17,6 +17,6 @@ for filePath in fileList:
# print("Deleting file : ", filePath) # print("Deleting file : ", filePath)
except: except:
print("Error while deleting file : ", filePath) print("Error while deleting file : ", filePath)
cmd = (env["PYTHONEXE"],join("tools","coc","coc"),"-o","generate","src","default",join("..","berry_tasmota","src"),join("..","berry_mapping","src"),join("..","berry_int64","src"),join("..","..","libesp32_lvgl","lv_binding_berry","src"),join("..","..","libesp32_lvgl","lv_binding_berry","generate"),"-c",join("default","berry_conf.h")) cmd = (env["PYTHONEXE"],join("tools","coc","coc"),"-o","generate","src","default",join("..","berry_tasmota","src"),join("..","berry_tasmota","src","solidify"),join("..","berry_mapping","src"),join("..","berry_int64","src"),join("..","..","libesp32_lvgl","lv_binding_berry","src"),join("..","..","libesp32_lvgl","lv_binding_berry","generate"),"-c",join("default","berry_conf.h"))
returncode = subprocess.call(cmd, shell=False) returncode = subprocess.call(cmd, shell=False)
os.chdir(CURRENT_DIR) os.chdir(CURRENT_DIR)