aboutsummaryrefslogtreecommitdiff
path: root/src/repl.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-04-06 22:45:02 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-04-06 22:45:02 -0400
commit44cd26f2cebd760a53aa4ff1b7779e718a101650 (patch)
tree4bdc9144c6825a0c394155712d5e464ee2a61061 /src/repl.c
parent3406515a44b13d0c290c28ac42bd364ce27560c7 (diff)
Rename Array -> List in all code and docs
Diffstat (limited to 'src/repl.c')
-rw-r--r--src/repl.c38
1 files changed, 19 insertions, 19 deletions
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: {