codegen: use the and instruction when doing zero-extend
[ajla.git] / array.h
blob4639ec43a813a30cc837c877b4dfd235ad36d1f1
1 /*
2 * Copyright (C) 2024 Mikulas Patocka
4 * This file is part of Ajla.
6 * Ajla is free software: you can redistribute it and/or modify it under the
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, either version 3 of the License, or (at your option) any later
9 * version.
11 * Ajla is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along with
16 * Ajla. If not, see <https://www.gnu.org/licenses/>.
19 #ifndef AJLA_ARRAY_H
20 #define AJLA_ARRAY_H
22 #include "data.h"
23 #include "arindex.h"
25 #define array_read name(array_read)
26 #define array_clone name(array_clone)
27 #define array_modify name(array_modify)
28 #define array_len name(array_len)
29 #define array_is_empty name(array_is_empty)
30 #define array_join name(array_join)
31 #define array_sub name(array_sub)
32 #define array_create name(array_create)
33 #define array_create_sparse name(array_create_sparse)
34 #define array_string name(array_string)
35 #define array_incomplete_decompose name(array_incomplete_decompose)
36 #define array_incomplete_collapse name(array_incomplete_collapse)
37 #define array_from_flat_mem name(array_from_flat_mem)
40 #define BTREE_MAX_NODE_EXPAND 2
41 #define BTREE_MAX_NODE_COLLAPSE 2
42 #define BTREE_MIN_SIZE ((BTREE_MAX_SIZE - BTREE_MAX_NODE_EXPAND) / 2 - BTREE_MAX_NODE_COLLAPSE)
43 #define SCALAR_SPLIT_SIZE minimum(BTREE_MAX_SIZE, signed_maximum(int_default_t))
46 bool attr_fastcall array_read(struct data *array, array_index_t idx, pointer_t **result_ptr, unsigned char **result_flat, const struct type **flat_type, int_default_t *run);
48 struct data *array_clone(pointer_t *ptr, ajla_error_t *err);
50 #define ARRAY_MODIFY_NEED_FLAT 1
51 #define ARRAY_MODIFY_NEED_PTR 2
52 bool attr_fastcall array_modify(pointer_t *root, array_index_t idx, unsigned flags, pointer_t **result_ptr, unsigned char **result_flat, const struct type **flat_type, frame_s *fp, const code_t *ip);
54 array_index_t attr_fastcall array_len(struct data *array);
55 bool attr_fastcall array_is_empty(struct data *array);
57 struct data * attr_fastcall array_join(struct data *array1, struct data *array2, ajla_error_t *err);
58 struct data * attr_fastcall array_sub(struct data *array, array_index_t start, array_index_t len, bool deref, ajla_error_t *err);
60 pointer_t array_create(array_index_t length, const struct type *flat_type, const unsigned char *flat, pointer_t ptr);
61 pointer_t array_create_sparse(array_index_t length, pointer_t ptr);
62 pointer_t attr_fastcall array_string(int_default_t length, const struct type *flat_type, const unsigned char *flat);
64 void attr_fastcall array_incomplete_decompose(struct data *array, struct data **first, pointer_t *last);
65 bool attr_fastcall array_incomplete_collapse(pointer_t *ptr);
67 struct data * attr_fastcall array_from_flat_mem(const struct type *type, const char *mem, size_t n_elements, ajla_error_t *mayfail);
69 #endif