Patrick Scherer wrote
> Hello everyone,
> 
> This is my first time here so I hope this is the right place to ask
> questions.
> 
> In an attempt to move lots of code from VA Smalltalk to Pharo, I need to
> compile a lot of methods whose code may or may not work due to missing
> classes in Pharo etc.
> I want to be able to compile these methods programatically without
> interruptions (using method source strings only) and gather all compiler
> errors that occur. What would be the best way to go about this?
> 
> Also: How do I control in which package a compiled method ends up if the
> target class is in a different package (Method extension)?
> 
> Any help would be greatly appreciated!
> 
> Kind regards,
> Patrick Scherer

IIRC, Stephanne recently listed preservation of unloaded supers / extensions
of unloaded classes as an area the INRIA group was working on, with a paper
scheduled for ESUG, he might be able to help.

I also recently went through roughly the same to import VSE code (for
inspection in Moose, not execution).
Can't say it was the best way, but I ended up creating a custom CodeImporter
with several error/notification handlers around the "normal" loading code,
and modifying the base system to raise said exceptions at appropriate places
(rather than as currently, invoking dialogs directly)
For instance, a MissingClass notification in MethodChunk >>
handleMissingBehavior, and a MissingPool from TClass >> #sharing:, (both
with defaultAction implemented as per current dialog-raising behavior, so
they work the same unless explicitly handled).

For my case, it was sufficient to have the handlers put classes/pools
auto-generated by handlers in predetermined packages.

The biggest pain / time drain was dealing with creating instvars in
autogenerated classes when referenced from imported code (ie in methods on
classes with missing superclasses) so the analysis wouldn't treat them as
unknown globals, so if you don't initially need that, I'd skip it.

I also did a compiler plugin to be able to rewrite certain selectors on
import (mostly base class extensions from VSE clashing with existing
implementations in Pharo), if you go that route, beware that the compiler
doesn't really like you actually redefining source from outside an editor,
and there will be some pains to have it store the correct(ed) source
strings.

To create a method as an extension in Package MyX, you need to give it a
categoriy of *MyX (with an optional -originalCategory suffix if you want
that)

Good luck!

Cheers,
Henry




--
View this message in context: 
http://forum.world.st/Compiling-lots-of-method-source-without-debugger-tp4958669p4958690.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Reply via email to