jasmin icon indicating copy to clipboard operation
jasmin copied to clipboard

Parameters are not substituted in annotations

Open vbgl opened this issue 1 year ago • 2 comments

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).

vbgl avatar Oct 02 '24 11:10 vbgl

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 ?

bgregoir avatar Oct 02 '24 15:10 bgregoir

I’d rather say term rewriting instead of string replacement, but yes, that’s the idea.

vbgl avatar Oct 02 '24 15:10 vbgl