|How far will C/C++ get me as an intermediate form for my language? firstname.lastname@example.org (Tony) (2008-10-31)|
|Re: How far will C/C++ get me as an intermediate form for my language? email@example.com (firstname.lastname@example.org) (2008-11-15)|
|Date:||Sat, 15 Nov 2008 09:42:01 -0800 (PST)|
|Posted-Date:||15 Nov 2008 18:30:50 EST|
I think starting with C or even C++ as an intermediate form is a great
idea. Most c/c++ compilers today can optimize the heck out of any
code you write, as long as you at least try to give it something
decent to start with. If you want garbage collection in your language
(many languages are becoming that way) you'll want to make sure to
take care of that in you're output code. Another nice feature of
using c/c++ as IR is that it's probably about the closest you can get
to machine code without losing portability, that is, if you want to be
able to generate/optimize programs for other architectures, too.
About the destructor in your example above: if you implemented your
compiler to output in c++ and then compiled that, you wouldn't have to
take care of calling the destructor (c++ compiler will do it for you)
unless you really wanted to. In that case, just call the code before
the last brace. Another suggestion: if you're not already, use gcc (g
++) as your back-end compiler. It's free and compatible across many
systems even on the same architecture. Good luck. I'd be interested
in knowing how it works out for you.
Return to the
Search the comp.compilers archives again.