|Joint compilation of Java and Ceylon||Stéphane Épardaud||5/11/12 12:43 AM|
I committed a fix yesterday for the compiler that allows us to compile
Java and Ceylon in one run, provided the Java code doesn't depend on
the Ceylon code we're compiling, which is lame, but still better than
nothing. To make it clearer: if your Java code depends on Ceylon code
it won't work.
That got me thinking about how we can do better, and make it work for
every case, and also for the IDE and ceylond (which right now doesn't
loads java source files), and I think I found a way.
We write (or reuse) a Java parser and feed their AST to the Ceylon
type-checker to extract their signatures, so that the typechecking
works and we extract the model from Java code.
This is essentially what the compiler is doing via its mappings from
"javac source symbol" -> ClassMirror -> "lazy model" (aka the model
loader, or at least part of it), but the part of the model loader that
allows us to feed java source to the loader is only available for the
compiler. Ceylond uses reflection (though we could invoke javadoc to
do that) and the IDE uses its own reflection thing (AFAIK only from
binary right now). In both cases with some work we might be able to
make it joint compile Java, but only if it doesn't invoke Ceylon code,
which is still limiting.
By having the Ceylon model for Java source built by the Ceylon
typechecker we ensures that every other project can then use it
without issue. Then the compiler can produce the Java+Ceylon binaries,
ceylondoc can produce Java+Ceylon docs (we'd then map Java doc
comments to our doc format) and the IDE can use a single compilation
pass as well.
All we need is a Java parser (should be relatively easy to do with
antlr, even by reusing an open source grammar, by reusing an open
source parser) and that the typechecker builds the model for that AST
at the same time as the Ceylon AST. Keep in mind we only have to do
the "signature" part of the model, and never the
What do you think of this solution?
|Re: [ceylon-dev] Joint compilation of Java and Ceylon||David Festal||5/11/12 12:49 AM|
Le 11/05/2012 09:43, Stephane Epardaud a �crit :
> I committed a fix yesterday for the compiler that allows us to compileIn the case of the IDE, it also uses source files indeed, that have been
parsed (or will be on-the-fly) by the Java parser included in Eclipse.
This is the case for a while.
> In both cases with some work we might be able toThe Eclipse Java parser is designed to be reused, and can even be used
in standalone more (batch), outside Eclipse, which seems very
interesting to me.
And this would avoid having 2 different things in the IDE.
Just an idea.
|Re: [ceylon-dev] Joint compilation of Java and Ceylon||Stéphane Épardaud||5/11/12 12:51 AM|
On 11 May 2012 09:49, Festal David <david....@serli.com> wrote:That would break if the Java code depends on Ceylon code though, right?
Yeah, I was also thinking that for the compiler we should reuse the
javac AST, otherwise we're going to parse it twice, but we can start
with a separate parser and work towards making it pluggable later.
|Re: [ceylon-dev] Joint compilation of Java and Ceylon||David Festal||5/11/12 1:02 AM|
Le 11/05/2012 09:51, Stephane Epardaud a �crit :
> On 11 May 2012 09:49, Festal David<david....@serli.com> wrote:Not necessarily : it depends on the order we use for building, but this
is fully related to Eclipse build lifecycle, and I've not concluded on
how to do it.
What will surely break is when 2 files both depend on each other :
A.ceylon depends on B.java, and B.java depends on A.ceylon.
>I was meaning : the Eclipse Java Parser could be an interesting too in
order to do what you want, instead of creating one from scratch.
|Re: [ceylon-dev] Joint compilation of Java and Ceylon||Stéphane Épardaud||5/11/12 1:05 AM|
On 11 May 2012 10:02, Festal David <david....@serli.com> wrote:
> What will surely break is when 2 files both depend on each other : A.ceylonRight, that's what I meant.