Skip to content

Commit fa7570d

Browse files
committed
Require region for initialising an object
1 parent a0c31a6 commit fa7570d

2 files changed

Lines changed: 10 additions & 18 deletions

File tree

src/rt/core.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace rt::core
1515

1616
class FrameObject : public objects::DynObject
1717
{
18-
FrameObject() : objects::DynObject(framePrototypeObject(), true) {}
18+
FrameObject() : objects::DynObject(framePrototypeObject()) {}
1919

2020
public:
2121
FrameObject(objects::DynObject* parent_frame)
@@ -58,8 +58,8 @@ namespace rt::core
5858
class FuncObject : public objects::DynObject
5959
{
6060
public:
61-
FuncObject(objects::DynObject* prototype_, bool global = false)
62-
: objects::DynObject(prototype_, global)
61+
FuncObject(objects::DynObject* prototype_)
62+
: objects::DynObject(prototype_)
6363
{}
6464
};
6565

src/rt/objects/dyn_object.h

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,14 @@ namespace rt::objects
7979
}
8080

8181
// prototype is borrowed, the caller does not need to provide an RC.
82-
DynObject(DynObject* prototype_ = nullptr, bool first_frame = false)
82+
DynObject(DynObject* prototype_ = nullptr, Region* containing_region = get_local_region())
8383
: prototype(prototype_)
8484
{
85-
if (!first_frame)
86-
{
87-
count++;
88-
all_objects.insert(this);
89-
auto local_region = get_local_region();
90-
region = local_region;
91-
local_region->objects.insert(this);
92-
}
85+
assert(containing_region != nullptr);
86+
count++;
87+
all_objects.insert(this);
88+
region = containing_region;
89+
containing_region->objects.insert(this);
9390

9491
if (prototype != nullptr)
9592
{
@@ -163,12 +160,7 @@ namespace rt::objects
163160
return false;
164161

165162
auto r = get_region(obj);
166-
// If we are freezing something primitive it doesn't have a region
167-
// So need to check for nullptr region here.
168-
if (r != nullptr)
169-
{
170-
get_region(obj)->objects.erase(obj);
171-
}
163+
get_region(obj)->objects.erase(obj);
172164
obj->region.set_ptr(immutable_region);
173165

174166
return !obj->is_cown();

0 commit comments

Comments
 (0)