Skip to content

Add platform independent reversible code #263

@tolauwae

Description

@tolauwae

def_prim_reverse(chip_digital_write) {
for (IOStateElement state : external_state) {
if (!state.output) {
continue;
}
if (state.key[0] == 'p') {
invoke_primitive(m, "chip_digital_write", stoi(state.key.substr(1)),
(uint32_t)state.value);
}
}
}

This code will likely be the same for all chip_digital_write primitives, regardless of platform. Since you are just invoking the primitive.

(in fact this will the strategy for most primitives)

I think we can generalize this and move to a reversibility file to avoid code duplication. In will make implementing the reversibility for other primitives easier as well.

Originally posted by @tolauwae in #250 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    Scheduled

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions