From 44cd26f2cebd760a53aa4ff1b7779e718a101650 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 6 Apr 2025 22:45:02 -0400 Subject: Rename Array -> List in all code and docs --- src/repl.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'src/repl.c') diff --git a/src/repl.c b/src/repl.c index 463e7ff8..bd08a3e4 100644 --- a/src/repl.c +++ b/src/repl.c @@ -128,10 +128,10 @@ const TypeInfo_t *type_to_type_info(type_t *t) default: print_err("Invalid bits"); } case TextType: return &Text$info; - case ArrayType: { - const TypeInfo_t *item_info = type_to_type_info(Match(t, ArrayType)->item_type); - TypeInfo_t array_info = *Array$info(item_info); - return memcpy(GC_MALLOC(sizeof(TypeInfo_t)), &array_info, sizeof(TypeInfo_t)); + case ListType: { + const TypeInfo_t *item_info = type_to_type_info(Match(t, ListType)->item_type); + TypeInfo_t list_info = *List$info(item_info); + return memcpy(GC_MALLOC(sizeof(TypeInfo_t)), &list_info, sizeof(TypeInfo_t)); } case TableType: { const TypeInfo_t *key_info = type_to_type_info(Match(t, TableType)->key_type); @@ -391,17 +391,17 @@ void eval(env_t *env, ast_t *ast, void *dest) type_t *indexed_t = get_type(env, index->indexed); // type_t *index_t = get_type(env, index->index); switch (indexed_t->tag) { - case ArrayType: { - Array_t arr; - eval(env, index->indexed, &arr); + case ListType: { + List_t list; + eval(env, index->indexed, &list); int64_t raw_index = Int64$from_int(ast_to_int(env, index->index), false); int64_t index_int = raw_index; - if (index_int < 1) index_int = arr.length + index_int + 1; - if (index_int < 1 || index_int > arr.length) + if (index_int < 1) index_int = list.length + index_int + 1; + if (index_int < 1 || index_int > list.length) print_err(raw_index, - " is an invalid index for an array with length ", (int64_t)arr.length); - size_t item_size = type_size(Match(indexed_t, ArrayType)->item_type); - memcpy(dest, arr.data + arr.stride*(index_int-1), item_size); + " is an invalid index for a list with length ", (int64_t)list.length); + size_t item_size = type_size(Match(indexed_t, ListType)->item_type); + memcpy(dest, list.data + list.stride*(index_int-1), item_size); break; } case TableType: { @@ -427,16 +427,16 @@ void eval(env_t *env, ast_t *ast, void *dest) } break; } - case Array: { - assert(t->tag == ArrayType); - Array_t arr = {}; - size_t item_size = type_size(Match(t, ArrayType)->item_type); + case List: { + assert(t->tag == ListType); + List_t list = {}; + size_t item_size = type_size(Match(t, ListType)->item_type); char item_buf[item_size]; - for (ast_list_t *item = Match(ast, Array)->items; item; item = item->next) { + for (ast_list_t *item = Match(ast, List)->items; item; item = item->next) { eval(env, item->ast, item_buf); - Array$insert(&arr, item_buf, I(0), (int64_t)type_size(Match(t, ArrayType)->item_type)); + List$insert(&list, item_buf, I(0), (int64_t)type_size(Match(t, ListType)->item_type)); } - memcpy(dest, &arr, sizeof(Array_t)); + memcpy(dest, &list, sizeof(List_t)); break; } case Table: { -- cgit v1.2.3