[IronPython] Building via AST

Justin Chase justin.m.chase at gmail.com
Tue Apr 13 02:51:56 CEST 2010


Awesome.  I will thanks.

On Apr 12, 2010 7:49 PM, "Dino Viehland" <dinov at microsoft.com> wrote:

 This might be possible.  If you wrap this all up in a PythonAst object
(calling the constructor which takes a CompilerContext), call Bind on it
then you should get a LambdaExpression back out.  You can Compile() on
that.



But it’s not like this is well traveled territory and this only applies to
2.6.1 (before that the trees weren’t DLR ASTs so they weren’t reducable).
When we do this ourselves we also call the produced delegate and flow in
some data.  The delegate is going to want at least a FunctionCode object as
an argument but I think you could get away with passing null (at least as
long as no exceptions are thrown).  The delegate might also want a
CodeContext object as well depending on the compilation mode we end up using
(which is based on the CompilerContext you give us).  This you wouldn’t be
able to get away w/ passing null.  But you can get one by doing new
ModuleContext(new PythonDictionary(), pythonContext).GlobalContext.  The
HostingHelpers class can give you a LanguageContext from the ScriptEngine
for Python which you can cast to a PythonContext.



Let me know if it works! J



*From:* users-bounces at lists.ironpython.com [mailto:
users-bounces at lists.ironpython.com] *On Behalf Of *Justin Chase
*Sent:* Monday, April 12, 2010 4:09 PM

To: Discussion of IronPython Subject: Re: [IronPython] Building via AST

  Ok, so at risk of being a nuissance I have one last question because I
feel like I'm half way t...

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100412/0aa156bd/attachment.html>


More information about the Ironpython-users mailing list