Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased]

### Enhancements
* Add `clr` and `fil` support in incremental evaluator before main loop

## v26.6.7

### Bugfixes
Expand Down
39 changes: 39 additions & 0 deletions src/eval/evaluator_inc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,45 @@ bool IncrementalEvaluator::checkPreLoop(bool skip_input_transform,
is_transform = true;
break;

// clearing or filling memory cells
case Operation::Type::CLR:
case Operation::Type::FIL: {
if (op.source.type != Operand::Type::CONSTANT) {
if (error_code) {
*error_code = ErrorCode::MEMORY_OP_SOURCE_INVALID;
}
return false;
}
auto bounds = ProgramUtil::getTargetMemoryRange(op);
if (bounds.first == Number::INF || bounds.second == Number::INF) {
if (error_code) {
*error_code = ErrorCode::MEMORY_OP_SOURCE_INVALID;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three validation failures (non-constant source, infinite bounds, range too large) use MEMORY_OP_SOURCE_INVALID. The last case is semantically different — consider a distinct error code or at least a comment to distinguish it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also see L253-L276

return false;
}
int64_t left = bounds.first.asInt();
int64_t right = bounds.second.asInt();
if (right - left >= interpreter.settings.max_memory) {
if (error_code) {
*error_code = ErrorCode::MEMORY_OP_SOURCE_INVALID;
}
return false;
}
// CLR: cells become constant zero → not input-dependent.
// FIL: cells take the value of op.target → inherit its input-dependency.
bool input_dependent = false;
if (op.type == Operation::Type::FIL) {
input_dependent = isInputDependent(op.target);
}
for (int64_t i = left; i < right; i++) {
if (input_dependent) {
input_dependent_cells.insert(i);
} else {
input_dependent_cells.erase(i);
}
Comment thread
loader3229 marked this conversation as resolved.
}
} break;

default:
// everything else is currently not allowed
if (error_code) {
Expand Down
17 changes: 17 additions & 0 deletions tests/inceval/I032.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mov $1,2
fil $1,4
add $4,1
fil $4,3
clr $2,3
lpb $0
sub $0,1
add $1,$3
add $3,$5
add $4,$6
add $1,$4
add $1,$5
add $5,$4
add $4,$3
add $3,$6
lpe
mov $0,$1
Loading