suy...@cse.iitm.ac.in wrote on 03/26/2014 12:46:45 PM:
>
> I am currently working on X10 compiler as I wish to implement an
> optimization in it. For this purpose I have to modify the existing
> AST and add new nodes in the AST. For this purpose I believe methods
> of the classes AltSynthesizer, Synthesizer and AsyncSynth come into
> use. I have been able to construct most of the nodes for my
> optimization except for "Async". I wish to add a new AST node for
> "Async" and that I can do with the help of "getStmt()" method in
> "AsyncSynth".
>
> But for async creation it requires a "Context". Now if I have a code
> something like this:
>
> for(var j:Int=0; j<m; j++) {
>   val ni=j;
>   async {
>     for(var i:Int=0; i<n; i++) {
>       .....
>     }
>   }
> }
>
> Then what all would be part of the context of "async", outer and
> inner "for" loop. Will only be type information be pushed and will
> context for all of these be separate "Kind". For the two loops I
> created an "emptyContext()" and that was working. So I was able to
> add nested loops to the AST. But as soon as I added an "Async" and
> passed an "emptyContext()" to it, the program started error. I am
> actually stuck with how and with what to set the context for these
constructs.
>

Hi,

        The usual pattern is to use a ContextVisitor (or subclass of
ContextVisitor).  Then the context is maintained by the visitor as scopes
are entered/exited and local decls encountered and is simply available as
an instance field of the visitor (context) when visiting a node.

--dave
------------------------------------------------------------------------------
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to