suy...@cse.iitm.ac.in wrote on 03/31/2014 08:56:33 AM:


> Thank you for the reply and I have another query.
>
> I could visualize that ContextVisitor is used to setting and
> retrieving the context for each node. Thus using the current context
> returned by the ContextVisitor I was able to set the context for the
> "async" node (generated by me). Each async requires a "closure" as a
> parameter and this closure should not be accepting any parameters.
> But when the java code is generated I see that a Closure class is
> generated. To the "runAsync()" method an instance of this Closure
> class is passed which accepts some parameters. These parameters are
> the variables which may be used inside the "async" but are not
> declared within the "async". Also the Closure class has its own set
> of these variables which get initialized by its constructor during
> call to "runAsync()".
>
> Interestingly in the code generated by me all the free variables
> that may be used by the "async body" are not captured by the Closure
> class. For generation of an "async" node, is "AsyncSynth" the right
> class? If it is so then how come the Closure generated in the
> "getStmt()" method (present in AsyncSynth class) not capturing the
> free variables. Even though I tried to modify the "getStmt()" method
> such that Closure generated gets a list of parameters, that didn't
> seem to work.

It looks like AsyncSynth is not currently being used.  So, not sure if it
is still valid or not.  Probably still useful as a starting point.

I suspect you need to run the ClosureCaptureVisitor on the new closure body
that was constructed (for asyncs in the original program, this computation
is done by the typechecker).  For things that are constructed later in
compilation, the variables that are captured need to be explicitly
computed.   You'll find some examples of code that uses the
ClosureCaptureVisitor in CastInjector and ConstantPropagator.

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

Reply via email to