Don't allow fibers as map keys.
I hacked in support for it for a misguided reason (trying to fake "thread-local storage") and ended up not using it for that anyway.
This commit is contained in:
@@ -54,13 +54,13 @@ bool validateInt(WrenVM* vm, Value arg, const char* argName)
|
||||
|
||||
bool validateKey(WrenVM* vm, Value arg)
|
||||
{
|
||||
if (IS_BOOL(arg) || IS_CLASS(arg) || IS_FIBER(arg) || IS_NULL(arg) ||
|
||||
if (IS_BOOL(arg) || IS_CLASS(arg) || IS_NULL(arg) ||
|
||||
IS_NUM(arg) || IS_RANGE(arg) || IS_STRING(arg))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
vm->fiber->error = CONST_STRING(vm, "Key must be a value type or fiber.");
|
||||
vm->fiber->error = CONST_STRING(vm, "Key must be a value type.");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,6 @@ ObjFiber* wrenNewFiber(WrenVM* vm, Obj* fn)
|
||||
|
||||
ObjFiber* fiber = ALLOCATE(vm, ObjFiber);
|
||||
initObj(vm, &fiber->obj, OBJ_FIBER, vm->fiberClass);
|
||||
fiber->id = vm->nextFiberId++;
|
||||
fiber->frames = frames;
|
||||
fiber->frameCapacity = INITIAL_CALL_FRAMES;
|
||||
fiber->stack = stack;
|
||||
@@ -344,9 +343,6 @@ static uint32_t hashObject(Obj* object)
|
||||
// Classes just use their name.
|
||||
return hashObject((Obj*)((ObjClass*)object)->name);
|
||||
|
||||
case OBJ_FIBER:
|
||||
return ((ObjFiber*)object)->id;
|
||||
|
||||
case OBJ_RANGE:
|
||||
{
|
||||
ObjRange* range = (ObjRange*)object;
|
||||
|
||||
@@ -242,10 +242,6 @@ typedef struct sObjFiber
|
||||
// error object. Otherwise, it will be null.
|
||||
Value error;
|
||||
|
||||
// A unique-ish numeric ID for the fiber. Lets fibers be used as map keys.
|
||||
// Unique-ish since IDs may overflow and wrap around.
|
||||
uint16_t id;
|
||||
|
||||
// This will be true if the caller that called this fiber did so using "try".
|
||||
// In that case, if this fiber fails with an error, the error will be given
|
||||
// to the caller.
|
||||
|
||||
@@ -50,11 +50,6 @@ struct WrenVM
|
||||
// for the module.
|
||||
ObjMap* modules;
|
||||
|
||||
// The ID that will be assigned to the next fiber that is allocated. Fibers
|
||||
// are given unique-ish (not completely unique since this can overflow) IDs
|
||||
// so that they can be used as map keys.
|
||||
uint16_t nextFiberId;
|
||||
|
||||
// Memory management data:
|
||||
|
||||
// The number of bytes that are known to be currently allocated. Includes all
|
||||
|
||||
Reference in New Issue
Block a user