jasmin
jasmin copied to clipboard
Parameters are not substituted in annotations
The following program is rejected by the compiler:
param int N = 4;
#[stacksize = N]
export fn xor(reg u32 x y) -> reg u32 {
stack u8[N] s;
s[u32 0] = x;
x = y;
y = s[u32 0];
x ^= y;
return x;
}
I think it would be nice to be able to use parameters in annotations. It might be necessary to provide means to disambiguate identifiers (e.g., here N could be the name of a function).
This will be clearly nice to have. How will you do the change in the annotations ? By doing a global string replacement ? #[s1 = ... @param(N) ... ] --> #[s1 = ... 4 ...] I don't say that we should use this syntax. I just want to understand how we can do it ?
I’d rather say term rewriting instead of string replacement, but yes, that’s the idea.