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

AVM: Add TEAL macro expansion support #4502

Closed
michaeldiamant opened this issue Aug 31, 2022 · 0 comments · Fixed by #4737
Closed

AVM: Add TEAL macro expansion support #4502

michaeldiamant opened this issue Aug 31, 2022 · 0 comments · Fixed by #4737
Assignees

Comments

@michaeldiamant
Copy link
Contributor

Problem

When reading/writing TEAL, the lack of human readable labels and/or ability to concisely group operations can increase the chance of maintainer error.

To address these concerns, the story requests adding macro expansion support for 1+ direct substitution terms separated by semicolon (examples below).

How a human readable label helps - Consider scratch slot ID identification in the following snippet.

// Allocate scratch slots

loop:
 <get next value>
 load 0
 +
 store 0
 load 1
 int 1
 +
 store 1
 <branch is not done>

 load 0
 load 1
 /

Now imagine replacing IDs with a human readable identifier:

// Allocate scratch slots
#define TOTAL 0
#define COUNT 1

loop:
 <get next value>
 load TOTAL
 +
 store TOTAL
 load COUNT
 int 1
 +
 store COUNT
 <branch is not done>

 load TOTAL
 load COUNT
 /

How grouping operations helps - Consider repetitive operations like incrementing by 1. Imagine defining something like:

#define inc int 1; +

int 5
inc

The example leverages #4363 to delimit lines by semi-colon (;) as a way to concisely, visually group statements.

Solution

Dependencies

Urgency

@michaeldiamant michaeldiamant linked a pull request Aug 31, 2022 that will close this issue
@michaeldiamant michaeldiamant linked a pull request Sep 9, 2022 that will close this issue
@michaeldiamant michaeldiamant linked a pull request Dec 2, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants