bug fix
This commit is contained in:
+1
-1
@@ -5,6 +5,6 @@ fun x(a, b, c)
|
|||||||
x(1, 2, 3, 4, 5);
|
x(1, 2, 3, 4, 5);
|
||||||
x(1, 2, 3, 4);
|
x(1, 2, 3, 4);
|
||||||
x(1, 2, 3);
|
x(1, 2, 3);
|
||||||
x(1, 2); # Fails here!
|
x(1, 2);
|
||||||
x(1);
|
x(1);
|
||||||
x();
|
x();
|
||||||
+3
-4
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
l = [1, 2, 3];
|
l = [1, 2, 3, 4];
|
||||||
|
|
||||||
print(count);
|
print('The list contains ', count(l), ' items.\n');
|
||||||
print(count(l));
|
print('The list is: ', l, '.\n');
|
||||||
print(l, '\n');
|
|
||||||
+3
-16
@@ -13,7 +13,7 @@ typedef struct {
|
|||||||
static Object *select(Object *self, Object *key, Heap *heap, Error *err);
|
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 _Bool insert(Object *self, Object *key, Object *val, Heap *heap, Error *err);
|
||||||
static int count(Object *self);
|
static int count(Object *self);
|
||||||
static void print(Object *self, FILE *fp);
|
static void print(Object *self, FILE *fp);
|
||||||
|
|
||||||
static const Type t_map = {
|
static const Type t_map = {
|
||||||
.base = (Object) { .type = &t_type, .flags = Object_STATIC },
|
.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(heap != NULL);
|
||||||
assert(error != NULL);
|
assert(error != NULL);
|
||||||
|
|
||||||
fprintf(stderr, "Selecting from:\n\t");
|
|
||||||
Object_Print(self, stderr);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
|
|
||||||
MapObject *map = (MapObject*) self;
|
MapObject *map = (MapObject*) self;
|
||||||
|
|
||||||
int mask = map->mapper_size - 1;
|
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;
|
int i = hash & mask;
|
||||||
|
|
||||||
#warning "TEMP"
|
|
||||||
fprintf(stderr, "-----------------\n");
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
int k = map->mapper[i];
|
int k = map->mapper[i];
|
||||||
|
|
||||||
fprintf(stderr, "map->mapper[%d] = %d\n", i, k);
|
|
||||||
|
|
||||||
if(k == -1)
|
if(k == -1)
|
||||||
{
|
{
|
||||||
// Empty slot.
|
// Empty slot.
|
||||||
@@ -113,10 +104,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
|
|||||||
// Is it the right one?
|
// Is it the right one?
|
||||||
|
|
||||||
assert(k >= 0);
|
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))
|
if(Object_Compare(key, map->keys[k], error))
|
||||||
// Found it!
|
// Found it!
|
||||||
@@ -133,8 +120,6 @@ static Object *select(Object *self, Object *key, Heap *heap, Error *error)
|
|||||||
|
|
||||||
pert >>= 5;
|
pert >>= 5;
|
||||||
i = (i * 5 + pert + 1) & mask;
|
i = (i * 5 + pert + 1) & mask;
|
||||||
|
|
||||||
fprintf(stderr, "%d -> %d\n", old_i, i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UNREACHABLE;
|
UNREACHABLE;
|
||||||
@@ -264,6 +249,8 @@ static _Bool insert(Object *self, Object *key, Object *val, Heap *heap, Error *e
|
|||||||
// Collision.
|
// Collision.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int old_i = i;
|
||||||
|
|
||||||
pert >>= 5;
|
pert >>= 5;
|
||||||
i = (i * 5 + pert + 1) & mask;
|
i = (i * 5 + pert + 1) & mask;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
_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;
|
return match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
int hashbytes(unsigned char *str, int len)
|
int hashbytes(unsigned char *str, int len)
|
||||||
{
|
{
|
||||||
int x = (intptr_t) str; // just to not use 0.
|
int x = 0; // Temp?
|
||||||
|
|
||||||
x ^= *str << 7;
|
x ^= *str << 7;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user