Skip to content

Commit

Permalink
Require region for initialising an object
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp41 committed Oct 25, 2024
1 parent a0c31a6 commit fa7570d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
6 changes: 3 additions & 3 deletions src/rt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace rt::core

class FrameObject : public objects::DynObject
{
FrameObject() : objects::DynObject(framePrototypeObject(), true) {}
FrameObject() : objects::DynObject(framePrototypeObject()) {}

public:
FrameObject(objects::DynObject* parent_frame)
Expand Down Expand Up @@ -58,8 +58,8 @@ namespace rt::core
class FuncObject : public objects::DynObject
{
public:
FuncObject(objects::DynObject* prototype_, bool global = false)
: objects::DynObject(prototype_, global)
FuncObject(objects::DynObject* prototype_)
: objects::DynObject(prototype_)
{}
};

Expand Down
22 changes: 7 additions & 15 deletions src/rt/objects/dyn_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ namespace rt::objects
}

// prototype is borrowed, the caller does not need to provide an RC.
DynObject(DynObject* prototype_ = nullptr, bool first_frame = false)
DynObject(DynObject* prototype_ = nullptr, Region* containing_region = get_local_region())
: prototype(prototype_)
{
if (!first_frame)
{
count++;
all_objects.insert(this);
auto local_region = get_local_region();
region = local_region;
local_region->objects.insert(this);
}
assert(containing_region != nullptr);
count++;
all_objects.insert(this);
region = containing_region;
containing_region->objects.insert(this);

if (prototype != nullptr)
{
Expand Down Expand Up @@ -163,12 +160,7 @@ namespace rt::objects
return false;

auto r = get_region(obj);
// If we are freezing something primitive it doesn't have a region
// So need to check for nullptr region here.
if (r != nullptr)
{
get_region(obj)->objects.erase(obj);
}
get_region(obj)->objects.erase(obj);
obj->region.set_ptr(immutable_region);

return !obj->is_cown();
Expand Down

0 comments on commit fa7570d

Please sign in to comment.