diff --git a/samples/func.noja b/samples/func.noja index dc58017..b1ff276 100644 --- a/samples/func.noja +++ b/samples/func.noja @@ -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(); \ No newline at end of file diff --git a/samples/list.noja b/samples/list.noja index 7277e92..f23b286 100644 --- a/samples/list.noja +++ b/samples/list.noja @@ -1,7 +1,6 @@ -l = [1, 2, 3]; +l = [1, 2, 3, 4]; -print(count); -print(count(l)); -print(l, '\n'); \ No newline at end of file +print('The list contains ', count(l), ' items.\n'); +print('The list is: ', l, '.\n'); \ No newline at end of file diff --git a/src/objects/o_map.c b/src/objects/o_map.c index 95a1124..0377ddb 100644 --- a/src/objects/o_map.c +++ b/src/objects/o_map.c @@ -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; } diff --git a/src/objects/o_string.c b/src/objects/o_string.c index dfe4b3f..cce9084 100644 --- a/src/objects/o_string.c +++ b/src/objects/o_string.c @@ -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; } diff --git a/src/utils/hash.c b/src/utils/hash.c index cd20650..f62fd17 100644 --- a/src/utils/hash.c +++ b/src/utils/hash.c @@ -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;