Skip to content

Commit

Permalink
Cleanup: PR preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
xFrednet committed Nov 7, 2024
1 parent 84557bf commit 952ec3c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
24 changes: 23 additions & 1 deletion docs/builtin.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Causes the interpreter to enter *interactive mode*.

Aborts the interpreter process. It's intended to indicate that an execution branch is not reachable.

#### `pass()`

Does nothing it can be used to fill empty blocks

## Constructors

#### `Region()`
Expand All @@ -22,7 +26,7 @@ Creates a new `cown` object.

The region must have a local reference count of one. The `move` keyword is used to replace the local value with `None`.

### `create(proto)`
#### `create(proto)`

Creates a new object from the given prototype.

Expand All @@ -34,6 +38,24 @@ Performs a deep freeze of the object and all referenced objects.

This will move the objects out of their current region into the immutable region. Cowns will stop the freeze propagation, as they can be safely shared across threads and behaviors.

#### `close(reg)`

Forces the given region to close by invalidating all local references into to region and its subregions.

This function will also correct all dirty LRCs.

#### `try_close(reg)`

Checks if the given region can be closed. If the LRC is dirty or subreagions are open, it will correct all dirty LRCs.

Returns `True`, if the region is closed in the end, `False` otherwise.

## Pragmas

#### `pragma_disable_implicit_freezing()`

Disables implicit freezing for the rest of the program.

## Mermaid

#### `mermaid_hide(obj, ..)`
Expand Down
1 change: 1 addition & 0 deletions src/lang/interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ namespace verona::interpreter
// RC stays the same
frame()->stack_push(old_var, "swapped value", false);

rt::move_reference(obj, frame()->object(), old_var);
rt::move_reference(frame()->object(), obj, new_var);
rt::remove_reference(frame()->object(), obj);
rt::remove_reference(frame()->object(), key);
Expand Down
1 change: 0 additions & 1 deletion src/rt/core/builtin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ namespace rt::core
return std::nullopt;
});

// TODO: Document
add_builtin("close", [](auto frame, auto args) {
close_function_impl(frame, args, true);
return std::nullopt;
Expand Down
5 changes: 2 additions & 3 deletions src/rt/objects/region.cc
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace rt::objects

auto invalidate = dst_reg == to_close_reg;
invalidate |=
(to_close_reg->sub_region_reference_count != 0 &&
(to_close_reg && to_close_reg->sub_region_reference_count != 0 &&
Region::is_ancestor(dst_reg, to_close_reg));
if (invalidate)
{
Expand Down Expand Up @@ -334,13 +334,12 @@ namespace rt::objects

bool Region::try_close()
{
// TODO: Is this correct, or should it be the combined LRC?
if (is_closed())
{
return true;
}

if (this->is_lrc_dirty)
if (this->is_lrc_dirty || this->sub_region_reference_count != 0)
{
clean_lrcs();
}
Expand Down
4 changes: 2 additions & 2 deletions src/rt/ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ namespace rt::ui
};

private:
/// Uses the local set to construct a reasonable set of roots, used for UI
/// methods that don't start from the local frame.
/// Uses the local region to construct a reasonable set of roots, used for
/// UI methods that don't start from the local frame.
std::vector<objects::DynObject*> local_root_objects();
};

Expand Down

0 comments on commit 952ec3c

Please sign in to comment.