EspruinoCompiler icon indicating copy to clipboard operation
EspruinoCompiler copied to clipboard

Infer argument types

Open gfwilliams opened this issue 10 years ago • 0 comments

Currently if I write:

function a(x) {
  "compiled";
  print(x|0);
}

You get something a bit like like:

void a(JsVar *x) {
  print(jsvGetInteger(x)|0);
}

We know that x|0 is an integer already, so ideally:

  • x itself would get converted to an integer, which would change the argument type
  • x|0 then detected as a no-op and removed (although the compiler would do this so do we care?)
void a(int x) {
  print(x);
}

gfwilliams avatar Jul 22 '15 08:07 gfwilliams