Post by UlrichI understood it that way but I still think there might be 3 better ways
1.Replace the back-end of OO2C by a Pascal generating one. Or, to
re-phrase it: implement a Pascal generating back-end for OOC, i.e.
create an OO2P.
This might be possible, but it would certainly be more difficult than
implementing a C back-end. For example, oo2c represents type descriptors
using initialised C arrays and structures. This would have to be done
differently in Pascal since it lacks initialisers. Also, the emitted
code is at a very low level: oo2c maps all Oberon-2 data operations to
integer and floating-point register operations. This involves a lot of
pointer/address arithmetic, goto statements, etc. I'm not saying it
can't be done, but the result would not be pretty...
Post by Ulrich2.Get rid of the C-Lib calls which are introduced by the back-end of
OO2C. I'm not sure whether that's feasible because the C compiler be it
the gcc or any other ANSI-C compliant one might automatically generate
C-Lib calls for certain language constructs which unfortunately can't be
avoided.
I think gcc can be configured to work independent of libc. It might be
necessary to provide alternative implementations for certain functions
(eg. startup code, exception handling). Some of OOC's standard modules
do depend on libc. For example: file I/O, timer functions, exception
handling, etc. Some of the generated code may depend on things like
memcpy, but most of these should be localised to the run-time module
RT0. I don't know what dependencies exist between the GC (OOC uses Hans
Boehm's conservative GC) and libc.
Post by Ulrich3.Write a back-end for OOC which directly generates processor
instructions. You might probably use the fpc back-end as an example.
Using this back-end to write a back-end for OOC shouldn't be too hard
although you will probably need some time to learn how the GSA
Actually, OOC dropped GSA in favour of a flatter SSA representation in
the version 2 compiler:
http://sourceforge.net/mailarchive/message.php?msg_id=2686075
Post by Ulrichrepresentation of OOC can be mapped to the fpc back-end calls.
One alternative would be to use OOC's existing x86 back-end which emits
x86 assembley instructions - it might need some work to get back in sync
with the current language implementation. Alternatively, one could build
an interface between the SSA IR and some other code generator. I don't
know what the fpc back-end looks like, but it might be usable. Another
alternative would be the lcc back-end, which has a well defined
interface to the compiler.
Yet another option might be to use libtcc
(http://fabrice.bellard.free.fr/tcc/). You give it a C string containing
the program, it compiles directly to binary code, and gives access to
all defined symbols and functions. TCC is about 10 times faster than
gcc, and it includes an ELF/PE linker. I recall that someone once got
OOC working with TCC.
Cheers,
Stewart