DRAFT PROPOSAL: Meta-compiler for non-java code to run on the java virtual machine
Anders Björklund
anders.bjorklund at sajtopia.se
Fri Feb 22 12:24:19 PST 2008
Hi all,
I propose to implement
A meta-compiler for non-java code to run on the java virtual machine.
--------------------------------------------------------------------------------------------------------
1.0 Specifics
A system consisting of:
A representation of class files with utility methods to translate
to and
from the internal binary representation. This representation could
also
be used outside of the compiler for other binary formats.
An instrumentation to manipulate the internal bytearrays of the
representation, shielding users of the system from implementation
details.
Bytecode needed in the compilation stage would be created with most
code calling a language-type library written in java. That way most
parts of a language implementation can be made using java, with just
some minor parts as bytecode from the language developer.
I belive such a system would decrease the time it would take to
implement a new language on the jvm. Performance would be lower, but
once the new language is up and running, focus can turn to changing
those non performing sections into bytecode, all the time having a
working language.
Operations could be mapped to a specific command class defined in
the language-type library. Eventually the library may be discarded
once
the entire new language has been properly implemented as bytecode.
--------------------------------------------------------------------------------------------------------
2.0 Goals
To simplify the creation and manipulation of binary files - in
particular the
java class format.
To simplify the migration of one or more computer languages to the
java
platform.
--------------------------------------------------------------------------------------------------------
3.0 Status
I already have the binary parsing and the resulting representation
working as a graph of objects.
When it comes to parsing source code, I have previously created the
lexer/parser "HiLexed" (available from SourceForge under GPL 2).
Using HiLexed I am able to map most computer languages using a
format similar to Backus Naur, into callbacks to the would-be
compiler.
The binary representation is functional and I can look at classfiles
accessing bytecode in separate methods, read the constant pool and
look at access modifiers of fields etc.
The representation graph can be saved into a classfile again after
manipulation.
--------------------------------------------------------------------------------------------------------
4.0 Complete implementation
As evaluation of my proposal, I suggest to build an
implementation of a
small new language running on the jvm.
This language would be extendable, supporting reading from the
keyboard, loops, some operation on collected input as well as writing
the results back to the console.
(Submitter: Anders Bjorklund__AT__sajtopia.se)
More information about the challenge-discuss
mailing list