Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delta calculation for matching of delta in CTPX should be done with context operators #275

Open
Leo-Nogismus opened this issue Sep 25, 2023 · 0 comments
Assignees

Comments

@Leo-Nogismus
Copy link
Collaborator

In CTPX::reduce(), we calculate the delta between the consequent and target value at the beginning of the function. This lets us create a binding_map of this delta value and match patterns against this. For this, we are currently still relying on simple minus calculation of Atom::Float() values. This should be updated to the same operator usage as in the find_guard_builder() function.

See

bool have_delta = false;
BindingMap bm_with_delta;
if (target_->get_reference(0)->code(0).asOpcode() == Opcodes::MkVal) {
// This is the same as the searched_for delta in find_guard_builder.
float32 delta = consequent->get_reference(0)->code(MK_VAL_VALUE).asFloat() -
target_->get_reference(0)->code(MK_VAL_VALUE).asFloat();
if (delta != 0) {
have_delta = true;
P<Code> delta_code(new LObject());
delta_code->code(0) = Atom::Float(delta);
bm_with_delta.init(delta_code, 0);
}
}

@Leo-Nogismus Leo-Nogismus self-assigned this Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant