minilua::Origin class

The origin of a value.

Defaults to NoOrigin.

Using BinaryOrigin and UnaryOrigin you can build a tree to track the changes made to a Value while running a lua program.

You can manually walk the tree using the variant returned by Origin::raw.

Supports equality operators.

Constructors, destructors, conversion operators

Origin()
Creates an Origin using NoOrigin.
Origin(Type) explicit
Creates an Origin from the underlying variant type.
Origin(NoOrigin)
Creates an Origin from NoOrigin.
Origin(ExternalOrigin)
Creates an Origin from an ExternalOrigin.
Origin(LiteralOrigin)
Creates an Origin from a LiteralOrigin.
Origin(BinaryOrigin)
Creates an Origin from a BinaryOrigin.
Origin(UnaryOrigin)
Creates an Origin from an UnaryOrigin.

Public functions

auto raw() const -> const Type & -> auto
Returns the underlying variant type.
auto raw() -> Type & -> auto
Returns the underlying variant type.
auto is_none() const -> bool -> auto
Check if the origin is NoOrigin.
auto is_external() const -> bool -> auto
Check if the origin is an ExternalOrigin.
auto is_literal() const -> bool -> auto
Check if the origin is a LiteralOrigin.
auto is_binary() const -> bool -> auto
Check if the origin is a BinaryOrigin.
auto is_unary() const -> bool -> auto
Check if the origin is a UnaryOrigin.
auto force(const Value&) const -> std::optional< SourceChangeTree > -> auto
Uses the reverse function to try to force the result value to change.
void set_file(std::optional<std::shared_ptr<std::string>> file)
auto simplify() const -> Origin -> auto
auto with_updated_ranges(const RangeMap&) const -> Origin -> auto
Returns a new origin with updated ranges.

Function documentation

void minilua::Origin::set_file(std::optional<std::shared_ptr<std::string>> file)

Sets the file of the underlying origin type (if possible).

auto minilua::Origin::simplify() const -> Origin

Simplify the origin.

Removes unusable origins from the tree.

auto minilua::Origin::with_updated_ranges(const RangeMap&) const -> Origin

Returns a new origin with updated ranges.

This will replace the matching LiteralOrigin ranges of the keys with those of the values. Other origin ranges will not be updated.

The files in the range map will be ignored for finding the correct range to replace. But the returned origin will always contain ranges with the same file as the original origin.