This commit is contained in:
Francesco Cozzuto
2021-11-04 17:27:06 +01:00
parent 0157d28f67
commit b224f57361
5 changed files with 8 additions and 25 deletions
+1 -1
View File
@@ -5,6 +5,6 @@ fun x(a, b, c)
x(1, 2, 3, 4, 5);
x(1, 2, 3, 4);
x(1, 2, 3);
x(1, 2); # Fails here!
x(1, 2);
x(1);
x();
+3 -4
View File
@@ -1,7 +1,6 @@
l = [1, 2, 3];
l = [1, 2, 3, 4];
print(count);
print(count(l));
print(l, '\n');
print('The list contains ', count(l), ' items.\n');
print('The list is: ', l, '.\n');
+3 -16
View File
@@ -13,7 +13,7 @@ typedef struct {
static Object *select(Object *self, Object *key, Heap *heap, Error *err);
static _Bool insert(Object *self, Object *key, Object *val, Heap *heap, Error *err);
static int count(Object *self);
static void print(Object *self, FILE *fp);
static void print(Object *self, FILE *fp);
static const Type t_map = {
.base = (Object) { .type = &t_type, .flags = Object_STATIC },
@@ -76,10 +76,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
assert(heap != NULL);
assert(error != NULL);
fprintf(stderr, "Selecting from:\n\t");
Object_Print(self, stderr);
fprintf(stderr, "\n");
MapObject *map = (MapObject*) self;
int mask = map->mapper_size - 1;
@@ -92,15 +88,10 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
int i = hash & mask;
#warning "TEMP"
fprintf(stderr, "-----------------\n");
while(1)
{
int k = map->mapper[i];
fprintf(stderr, "map->mapper[%d] = %d\n", i, k);
if(k == -1)
{
// Empty slot.
@@ -113,10 +104,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
// Is it the right one?
assert(k >= 0);
#warning "TEMP"
fprintf(stderr, "map->keys[%d] = ", k);
Object_Print(map->keys[k], stderr);
fprintf(stderr, " (of type %s)\n", Object_GetName(map->keys[k]));
if(Object_Compare(key, map->keys[k], error))
// Found it!
@@ -133,8 +120,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
pert >>= 5;
i = (i * 5 + pert + 1) & mask;
fprintf(stderr, "%d -> %d\n", old_i, i);
}
UNREACHABLE;
@@ -264,6 +249,8 @@ static _Bool insert(Object *self, Object *key, Object *val, Heap *heap, Error *e
// Collision.
}
int old_i = i;
pert >>= 5;
i = (i * 5 + pert + 1) & mask;
}
-3
View File
@@ -96,9 +96,6 @@ static _Bool op_eql(Object *self, Object *other)
_Bool match = s1->size == s2->size && !strncmp(s1->body, s2->body, s1->size);
#warning "TEMP"
fprintf(stderr, "%s == %s ? %s\n", s1->body, s2->body, match ? "yes" : "no");
return match;
}
+1 -1
View File
@@ -3,7 +3,7 @@
int hashbytes(unsigned char *str, int len)
{
int x = (intptr_t) str; // just to not use 0.
int x = 0; // Temp?
x ^= *str << 7;