Leo --

Here's a Jako snippet:

  var int x = 5;
  {
    var int x = 3;
    print x;
  }
  print x

A naiive translation to imcc might be:

  .sub _foo
  .local int x
  x = 5
  .local int x
  x = 3
  print x
  print x
  .end

but (of course) that leads to an "x already defined" error.

I was hoping to use .local for all my variables, but I don't see a way to 
handle
scopes with the IMCC machinery. It looks like the perl6 compiler uses 
virtual
registers so it can do its own scoping stuff.

Is IMCC intended to (eventually) have scoping support for .local? Wouldn't
that require .scope ...  .endscope directives, which would correspond to 
the
open and close braces above? The .namespace ... .endnamespace directives
look suspiciously like they might be the ones I need. Based on a quick 
look
at the source (didn't see any examples), this seemed reasonable, but it 
doesn't help:

  .sub _foo
    .local int x
    x = 5
    .namespace ANON
    .local int x
    x = 3
    print x
    .endnamespace ANON
    print x
  .end

Is this supposed to be working in IMCC? Could you give me some pointers?

I'll need to bracket my subs and inner blocks with whatever scoping 
mechanism
is appropriate.

I'd like to preserve my use of named .locals rather than move entirely to 
temporaries,
since having the names around makes the .imc file easier to follow.


Regards,

-- Gregor

Reply via email to