EvolveBlockRegion

Structs ยท AiDotNet.Evolution.Programs

One matched evolve block, split into the text before it, the block body, and the text after it.

Inheritance: ValueType โ†’ EvolveBlockRegion

Implements: IEquatable<EvolveBlockRegion>

For Beginners

Imagine a page with a paragraph highlighted for editing. This type hands you three pieces: everything above the highlight, the highlighted paragraph itself, and everything below it. To produce an edited page you only replace the middle piece and glue the three back together, which is what Rewrite does for you. Splitting the file this way is what guarantees that changing the evolvable region never disturbs the rest of the file.

How It Works

Prefix ends with the start-marker line and its terminator, Suffix begins at the end-marker line, and Body is everything between them including its own trailing terminator when it is non-empty. Concatenating the three parts therefore reproduces the original source byte for byte, and Rewrite substitutes a new body while preserving every character outside the block: imports, harness code, and the evaluator entry point cannot be lost by an over-eager rewrite.

Properties

Property Summary
bool IsEmpty { get; } Gets whether this region carries no source text, which is the state of a default instance.
int BodyLineCount { get; } Gets the number of body lines between the markers.
int EndLineIndex { get; } Gets the zero-based index of the line holding the end marker.
int StartLineIndex { get; } Gets the zero-based index of the line holding the start marker.
string Body { get; } Gets the block body, terminated by a line break unless it is empty.
string NewLine { get; } Gets the line terminator used by the source this region came from.
string Prefix { get; } Gets the source text up to and including the start-marker line and its terminator.
string Suffix { get; } Gets the source text from the end-marker line to the end of the file.

Methods

Method Summary
bool Equals(EvolveBlockRegion other)
bool Equals(object obj)
bool op_Equality(EvolveBlockRegion left, EvolveBlockRegion right) Determines whether two regions describe the same split of the same source.
bool op_Inequality(EvolveBlockRegion left, EvolveBlockRegion right) Determines whether two regions differ.
int GetHashCode()
string Rewrite(string replacement) Rebuilds the whole source with replacement in place of Body.
string ToSource() Reconstructs the original source this region was extracted from.
string ToString() Returns the line span of this region without echoing any source text.