diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | builtins/array.c | 3 | ||||
| -rw-r--r-- | builtins/functions.c | 19 | ||||
| -rw-r--r-- | builtins/table.c | 3 | ||||
| -rw-r--r-- | compile.c | 3 |
5 files changed, 12 insertions, 22 deletions
@@ -13,3 +13,9 @@ func greeting(name:Text)->Text ``` Check out the [test/](test/) folder to see some examples. + +## Dependencies + +Tomo uses the [Boehm garbage collector](https://www.hboehm.info/gc/) for +runtime garbage collection (which is available from your package manager of +choice, for example: `pacman -S gc`). diff --git a/builtins/array.c b/builtins/array.c index 8ee771ea..07814f66 100644 --- a/builtins/array.c +++ b/builtins/array.c @@ -321,7 +321,8 @@ public uint32_t Array__hash(const array_t *arr, const TypeInfo *type) const TypeInfo *item = type->ArrayInfo.item; if (item->tag == PointerInfo || (item->tag == CustomInfo && item->CustomInfo.hash == NULL)) { // Raw data hash int64_t item_size = item->size; - uint8_t hash_batch[4 + 8*item_size] = {}; + uint8_t hash_batch[4 + 8*item_size]; + memset(hash_batch, 0, sizeof(hash_batch)); uint8_t *p = hash_batch, *end = hash_batch + sizeof(hash_batch); int64_t length = arr->length; *p = (uint32_t)length; diff --git a/builtins/functions.c b/builtins/functions.c index bcaf5d11..448b7758 100644 --- a/builtins/functions.c +++ b/builtins/functions.c @@ -130,25 +130,6 @@ public CORD builtin_last_err() return CORD_from_char_star(strerror(errno)); } -static inline char *without_colors(const char *str) -{ - // Strip out color escape sequences: "\x1b[" ... "m" - size_t fmt_len = strlen(str); - char *buf = GC_malloc_atomic(fmt_len+1); - char *dest = buf; - for (const char *src = str; *src; ++src) { - if (src[0] == '\x1b' && src[1] == '[') { - src += 2; - while (*src && *src != 'm') - ++src; - } else { - *(dest++) = *src; - } - } - *dest = '\0'; - return buf; -} - public void __doctest(void *expr, const TypeInfo *type, CORD expected, const char *filename, int64_t start, int64_t end) { static file_t *file = NULL; diff --git a/builtins/table.c b/builtins/table.c index eb329c9c..5631a7fb 100644 --- a/builtins/table.c +++ b/builtins/table.c @@ -271,7 +271,8 @@ public void *Table_reserve(table_t *t, const void *key, const void *value, const maybe_copy_on_write(t, type); - char buf[entry_size(type)] = {}; + char buf[entry_size(type)]; + memset(buf, 0, sizeof(buf)); memcpy(buf, key, key_size); if (value && value_size > 0) memcpy(buf + value_offset(type), value, value_size); @@ -1454,10 +1454,11 @@ void compile_namespace(env_t *env, const char *ns_name, ast_t *block) for (ast_list_t *stmt = block ? Match(block, Block)->statements : NULL; stmt; stmt = stmt->next) { ast_t *ast = stmt->ast; switch (ast->tag) { - case FunctionDef: + case FunctionDef: { CORD code = compile_statement(ns_env, ast); env->code->funcs = CORD_cat(env->code->funcs, code); break; + } case Declare: { auto decl = Match(ast, Declare); type_t *t = get_type(ns_env, decl->value); |
