Skip to content

[#41] add code cleaning to IndigoM/GenCode and remove DestroyPrefix

Pinto Pasquale requested to merge pasqu4le/#41-remove-destroyprefix into master

Description

The execution of an IndigoM only increments the stack or at most keeps it the same, except for intermediate passages and for cleaning it in the cases where DestroyPrefix is used (e.g. branches of an if). Given this, to avoid the problem described in the issue we can add a new field to Gencode that keeps track of the Lorentz code necessary to return from the output stack to the input one of an IndigoM. As a result there is no longer need for DestroyPrefix anymore and when necessary the newly added cleanGenCode function can be used instead of gcCode.

Note: in only 2 cases DestroyPrefix was used to remove more of the stack than the input stack:

  • compileIndigoContract where it also removed the param (an additional drop covers this case)
  • toLorentzFun2Args where it could have removed more (still required to know and specify the output stack, so IMO not really a loss)

Note on tests: the changes modified the tree structure of the output, and until a solution is merged for the issue described in !149 (merged) the optimized golden test for the contracts no longer passes. However given that the output no longer contains unused nops we can check their un-optimized version.

Last note: README has not been updated because it is already outdated and will probably need to be modified again when an MR for #44 (closed) is created (coming soon, based on this one)

Related issue(s)

Resolves #41 (closed)

Checklist for your Merge Request

Related changes (conditional)

  • Tests (see short guidelines)

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
    • I updated the changelog if my changes are externally visible.

Stylistic guide (mandatory)

Edited by Pinto Pasquale

Merge request reports