Skip to content

Commit

Permalink
Fix bad value boxings
Browse files Browse the repository at this point in the history
  • Loading branch information
klange committed Jan 8, 2024
1 parent bc30248 commit 4008133
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ KRK_Method(object,__hash__) {
}
KrkObj * obj = AS_OBJECT(self);
if (!(obj->flags & KRK_OBJ_FLAGS_VALID_HASH)) {
obj->hash = INTEGER_VAL((int)((intptr_t)self >> 3));
obj->hash = (uint32_t)((intptr_t)(obj) >> 3);
obj->flags |= KRK_OBJ_FLAGS_VALID_HASH;
}
return INTEGER_VAL(obj->hash);
}

KRK_Method(object,__eq__) {
METHOD_TAKES_EXACTLY(1);
if (argv[0] == argv[1]) return BOOLEAN_VAL(1);
if (krk_valuesSame(argv[0],argv[1])) return BOOLEAN_VAL(1);
return NOTIMPL_VAL();
}

Expand Down
2 changes: 1 addition & 1 deletion src/obj_function.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ KRK_Method(method,__func__) {

KRK_Method(method,__self__) {
ATTRIBUTE_NOT_ASSIGNABLE();
return OBJECT_VAL(self->receiver);
return self->receiver;
}

KRK_Function(staticmethod) {
Expand Down
2 changes: 1 addition & 1 deletion src/obj_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ KRK_Method(list,__delitem__) {
METHOD_TAKES_EXACTLY(1);

if (IS_INTEGER(argv[1])) {
FUNC_NAME(list,pop)(2,(KrkValue[]){argv[0],INTEGER_VAL(argv[1])},0);
FUNC_NAME(list,pop)(2,(KrkValue[]){argv[0],argv[1]},0);
} else if (IS_slice(argv[1])) {
KRK_SLICER(argv[1],self->values.count) {
return NONE_VAL();
Expand Down
2 changes: 1 addition & 1 deletion src/table.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ inline int krk_hashValue(KrkValue value, uint32_t *hashOut) {
return 0;
}
if (IS_CLASS(value)) {
*hashOut = INTEGER_VAL((int)(intptr_t)AS_OBJECT(value));
*hashOut = (uint32_t)((int)(intptr_t)AS_OBJECT(value));
return 0;
}
_unhashable:
Expand Down
4 changes: 2 additions & 2 deletions src/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void krk_finalizeClass(KrkClass * _class) {
_class->_hash = NULL;
KrkValue v;
if (!krk_tableGet_fast(&_class->methods, AS_STRING(vm.specialMethodNames[METHOD_HASH]), &v)) {
krk_tableSet(&_class->methods, OBJECT_VAL(vm.specialMethodNames[METHOD_HASH]), NONE_VAL());
krk_tableSet(&_class->methods, vm.specialMethodNames[METHOD_HASH], NONE_VAL());
}
}
}
Expand Down Expand Up @@ -1516,7 +1516,7 @@ int krk_importModule(KrkString * name, KrkString * runAs) {
pushStringBuilderStr(&sb, &name->chars[dots], name->length - dots);
}

krk_push(OBJECT_VAL(finishStringBuilder(&sb)));
krk_push(finishStringBuilder(&sb));

/* Now to try to import the fully qualified module path */
if (krk_importModule(AS_STRING(krk_peek(0)), AS_STRING(krk_peek(0)))) {
Expand Down

0 comments on commit 4008133

Please sign in to comment.