Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion default/be_modtab.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ be_extern_native_module(undefined);
/* user-defined modules declare end */

/* module list declaration */
BERRY_LOCAL const bntvmodule_t* const be_module_table[] = {
BERRY_LOCAL const bntvmodule_t* be_module_table[] = {
/* default modules register */
#if BE_USE_STRING_MODULE
&be_native_module(string),
Expand Down
7 changes: 0 additions & 7 deletions default/berry_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@
**/
#define BE_BYTES_MAX_SIZE (32*1024) /* 32 kb default value */

/* Macro: BE_USE_PRECOMPILED_OBJECT
* Use precompiled objects to avoid creating these objects at
* runtime. Enable this macro can greatly optimize RAM usage.
* Default: 1
**/
#define BE_USE_PRECOMPILED_OBJECT 1

/* Macro: BE_DEBUG_SOURCE_FILE
* Indicate if each function remembers its source file name
* 0: do not keep the file name (saves 4 bytes per function)
Expand Down
14 changes: 0 additions & 14 deletions src/be_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,10 @@ BERRY_API void be_regfunc(bvm *vm, const char *name, bntvfunc f)
{
bvalue *var;
bstring *s = be_newstr(vm, name);
#if !BE_USE_PRECOMPILED_OBJECT
int idx = be_builtin_find(vm, s);
be_assert(idx < 0);
if (idx < 0) { /* new function */
idx = be_builtin_new(vm, s);
#else
int idx = be_global_find(vm, s);
be_assert(idx < be_builtin_count(vm));
if (idx < be_builtin_count(vm)) { /* new function */
idx = be_global_new(vm, s);
#endif
var = be_global_var(vm, idx);
var_setntvfunc(var, f);
} /* error case, do nothing */
Expand All @@ -100,17 +93,10 @@ BERRY_API void be_regclass(bvm *vm, const char *name, const bnfuncinfo *lib)
{
bvalue *var;
bstring *s = be_newstr(vm, name);
#if !BE_USE_PRECOMPILED_OBJECT
int idx = be_builtin_find(vm, s);
be_assert(idx < 0);
if (idx < 0) { /* new function */
idx = be_builtin_new(vm, s);
#else
int idx = be_global_find(vm, s);
be_assert(idx < be_builtin_count(vm));
if (idx < be_builtin_count(vm)) { /* new function */
idx = be_global_new(vm, s);
#endif
var = be_global_var(vm, idx);
var_setclass(var, class_auto_make(vm, s, lib));
} /* error case, do nothing */
Expand Down
30 changes: 0 additions & 30 deletions src/be_baselib.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,36 +478,7 @@ int be_baselib_isinstance(bvm *vm)
return _issubv(vm, be_isinstance);
}

#if !BE_USE_PRECOMPILED_OBJECT
void be_load_baselib(bvm *vm)
{
be_regfunc(vm, "assert", be_baselib_assert);
be_regfunc(vm, "print", be_baselib_print);
be_regfunc(vm, "input", be_baselib_input);
be_regfunc(vm, "super", be_baselib_super);
be_regfunc(vm, "type", be_baselib_type);
be_regfunc(vm, "classname", be_baselib_classname);
be_regfunc(vm, "classof", be_baselib_classof);
be_regfunc(vm, "number", be_baselib_number);
be_regfunc(vm, "str", be_baselib_str);
be_regfunc(vm, "int", be_baselib_int);
be_regfunc(vm, "real", be_baselib_real);
be_regfunc(vm, "module", be_baselib_module);
be_regfunc(vm, "size", be_baselib_size);
be_regfunc(vm, "compile", be_baselib_compile);
be_regfunc(vm, "issubclass", be_baselib_issubclass);
be_regfunc(vm, "isinstance", be_baselib_isinstance);
be_regfunc(vm, "__iterator__", be_baselib_iterator);
}

/* call must be added later to respect order of builtins */
void be_load_baselib_next(bvm *vm)
{
be_regfunc(vm, "call", l_call);
be_regfunc(vm, "bool", l_bool);
be_regfunc(vm, "format", be_str_format);
}
#else
extern const bclass be_class_list;
extern const bclass be_class_map;
extern const bclass be_class_range;
Expand Down Expand Up @@ -549,4 +520,3 @@ void be_load_baselib(bvm *vm)
{
be_const_builtin_set(vm, &m_builtin_map, &m_builtin_vector);
}
#endif
56 changes: 0 additions & 56 deletions src/be_byteslib.c
Original file line number Diff line number Diff line change
Expand Up @@ -1905,61 +1905,6 @@ be_local_closure(setbits, /* name */
);
/*******************************************************************/

#if !BE_USE_PRECOMPILED_OBJECT
void be_load_byteslib(bvm *vm)
{
static const bnfuncinfo members[] = {
{ ".p", NULL },
{ ".len", NULL },
{ ".size", NULL },
{ "_buffer", m_buffer },
{ "_change_buffer", m_change_buffer },
{ "ismapped", m_is_mapped },
{ "isreadonly", m_is_readonly },
{ "init", m_init },
{ "deinit", m_deinit },
{ "tostring", m_tostring },
{ "asstring", m_asstring },
{ "tobool", m_tobool },
{ "fromstring", m_fromstring },
{ "tob64", m_tob64 },
{ "fromb64", m_fromb64 },
{ "fromhex", m_fromhex },
{ "tohex", m_tohex },
{ "add", m_add },
{ "get", m_getu },
{ "geti", m_geti },
{ "set", m_set },
{ "seti", m_set }, // setters for signed and unsigned are identical
{ "setbytes", m_setbytes },
{ "getfloat", m_getfloat },
{ "setfloat", m_setfloat },
{ "addfloat", m_addfloat },
{ "item", m_item },
{ "setitem", m_setitem },
{ "size", m_size },
{ "resize", m_resize },
{ "clear", m_clear },
{ "reverse", m_reverse },
{ "copy", m_copy },
{ "append", m_connect },
{ "appendhex", m_appendhex },
{ "appendb64", m_appendb64 },
{ "+", m_merge },
{ "..", m_connect },
{ "==", m_equal },
{ "!=", m_nequal },

{ NULL, (bntvfunc) BE_CLOSURE }, /* mark section for berry closures */
{ "getbits", (bntvfunc) &getbits_closure },
{ "setbits", (bntvfunc) &setbits_closure },

{ NULL, NULL }
};
be_regclass(vm, "bytes", members);
}
#else

#include "../generate/be_const_bytes_def.h"

/* @const_object_info_begin
Expand Down Expand Up @@ -2010,4 +1955,3 @@ class be_class_bytes (scope: global, name: bytes) {
}
@const_object_info_end */
#include "../generate/be_fixed_be_class_bytes.h"
#endif
2 changes: 0 additions & 2 deletions src/be_byteslib.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ typedef struct buf_impl {

size_t be_bytes_tohex(char * out, size_t outsz, const uint8_t * in, size_t insz);

#if BE_USE_PRECOMPILED_OBJECT
#include "../generate/be_const_bytes.h"
#endif

#endif
24 changes: 0 additions & 24 deletions src/be_debuglib.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,29 +240,6 @@ static int m_reallocs(bvm *vm) {
#endif
}

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(debug) {
be_native_module_function("attrdump", m_attrdump),
be_native_module_function("codedump", m_codedump),
be_native_module_function("traceback", m_traceback),
#if BE_USE_DEBUG_HOOK
be_native_module_function("sethook", m_sethook),
#endif
#if BE_USE_PERF_COUNTERS
be_native_module_function("counters", m_counters),
#endif
be_native_module_function("calldepth", m_calldepth),
be_native_module_function("top", m_top),
#if BE_DEBUG_VAR_INFO
be_native_module_function("varname", m_varname),
be_native_module_function("upvname", m_upvname),
#endif
be_native_module_function("caller", m_caller),
be_native_module_function("gcdebug", m_gcdebug)
};

be_define_native_module(debug, NULL);
#else
/* @const_object_info_begin
module debug (scope: global, depend: BE_USE_DEBUG_MODULE) {
attrdump, func(m_attrdump)
Expand All @@ -284,6 +261,5 @@ module debug (scope: global, depend: BE_USE_DEBUG_MODULE) {
}
@const_object_info_end */
#include "../generate/be_fixed_debug.h"
#endif

#endif /* BE_USE_DEBUG_MODULE */
11 changes: 0 additions & 11 deletions src/be_filelib.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,7 @@ static int i_savecode(bvm *vm)
be_return_nil(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
static int m_open(bvm *vm)
#else
int be_nfunc_open(bvm *vm)
#endif
{
int argc = be_top(vm);
const char *fname, *mode;
Expand Down Expand Up @@ -256,10 +252,3 @@ int be_nfunc_open(bvm *vm)
}
be_return_nil(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
void be_load_filelib(bvm *vm)
{
be_regfunc(vm, "open", m_open);
}
#endif
9 changes: 0 additions & 9 deletions src/be_gclib.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,12 @@ static int m_collect(bvm *vm)
be_return_nil(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(gc){
be_native_module_function("allocated", m_allocated),
be_native_module_function("collect", m_collect)
};

be_define_native_module(gc, NULL);
#else
/* @const_object_info_begin
module gc (scope: global, depend: BE_USE_GC_MODULE) {
allocated, func(m_allocated)
collect, func(m_collect)
}
@const_object_info_end */
#include "../generate/be_fixed_gc.h"
#endif

#endif /* BE_USE_SYS_MODULE */
12 changes: 0 additions & 12 deletions src/be_globallib.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,6 @@ static int m_undef(bvm *vm)
be_return_nil(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(global) {
be_native_module_function("()", m_globals),
be_native_module_function("contains", m_contains),
be_native_module_function("member", m_findglobal),
be_native_module_function("setmember", m_setglobal),
be_native_module_function("undef", m_undef),
};

be_define_native_module(global, NULL);
#else
/* @const_object_info_begin
module global (scope: global, depend: BE_USE_GLOBAL_MODULE) {
(), func(m_globals)
Expand All @@ -113,6 +102,5 @@ module global (scope: global, depend: BE_USE_GLOBAL_MODULE) {
}
@const_object_info_end */
#include "../generate/be_fixed_global.h"
#endif

#endif /* BE_USE_GLOBAL_MODULE */
23 changes: 0 additions & 23 deletions src/be_introspectlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,28 +246,6 @@ static int m_name(bvm *vm)
be_return_nil(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(introspect) {
be_native_module_function("members", m_attrlist),

be_native_module_function("get", m_findmember),
be_native_module_function("set", m_setmember),
be_native_module_function("contains", m_contains),

be_native_module_function("module", m_getmodule),
be_native_module_function("setmodule", m_setmodule),

be_native_module_function("toptr", m_toptr),
be_native_module_function("fromptr", m_fromptr),
be_native_module_function("solidified", m_solidified),

be_native_module_function("name", m_name),

be_native_module_function("ismethod", m_ismethod),
};

be_define_native_module(introspect, NULL);
#else
/* @const_object_info_begin
module introspect (scope: global, depend: BE_USE_INTROSPECT_MODULE) {
members, func(m_attrlist)
Expand All @@ -289,6 +267,5 @@ module introspect (scope: global, depend: BE_USE_INTROSPECT_MODULE) {
}
@const_object_info_end */
#include "../generate/be_fixed_introspect.h"
#endif

#endif /* BE_USE_INTROSPECT_MODULE */
9 changes: 0 additions & 9 deletions src/be_jsonlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,21 +514,12 @@ static int m_json_dump(bvm *vm)
be_return(vm);
}

#if !BE_USE_PRECOMPILED_OBJECT
be_native_module_attr_table(json) {
be_native_module_function("load", m_json_load),
be_native_module_function("dump", m_json_dump)
};

be_define_native_module(json, NULL);
#else
/* @const_object_info_begin
module json (scope: global, depend: BE_USE_JSON_MODULE) {
load, func(m_json_load)
dump, func(m_json_dump)
}
@const_object_info_end */
#include "../generate/be_fixed_json.h"
#endif

#endif /* BE_USE_JSON_MODULE */
8 changes: 0 additions & 8 deletions src/be_libs.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,4 @@ extern void be_load_byteslib(bvm *vm);
void be_loadlibs(bvm *vm)
{
be_load_baselib(vm);
#if !BE_USE_PRECOMPILED_OBJECT
be_load_listlib(vm);
be_load_maplib(vm);
be_load_rangelib(vm);
be_load_filelib(vm);
be_load_byteslib(vm);
be_load_baselib_next(vm);
#endif
}
33 changes: 0 additions & 33 deletions src/be_listlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,38 +493,6 @@ static int m_nequal(bvm *vm)
return list_equal(vm, bfalse);
}

#if !BE_USE_PRECOMPILED_OBJECT
void be_load_listlib(bvm *vm)
{
static const bnfuncinfo members[] = {
{ ".p", NULL },
{ "init", m_init },
{ "tostring", m_tostring },
{ "push", m_push },
{ "pop", m_pop },
{ "insert", m_insert },
{ "remove", m_remove },
{ "item", m_item },
{ "find", m_find },
{ "setitem", m_setitem },
{ "size", m_size },
{ "resize", m_resize },
{ "clear", m_clear },
{ "iter", m_iter },
{ "concat", m_concat },
{ "reverse", m_reverse },
{ "copy", m_copy },
{ "keys", m_keys },
{ "tobool", m_tobool },
{ "..", m_connect },
{ "+", m_merge },
{ "==", m_equal },
{ "!=", m_nequal },
{ NULL, NULL }
};
be_regclass(vm, "list", members);
}
#else
/* @const_object_info_begin
class be_class_list (scope: global, name: list) {
.p, var
Expand Down Expand Up @@ -553,4 +521,3 @@ class be_class_list (scope: global, name: list) {
}
@const_object_info_end */
#include "../generate/be_fixed_be_class_list.h"
#endif
Loading