Luke Palmer wrote: >Klass-Jan Stol writes: > >>>The thing is, I don't have a lot of experience when it comes to >>>compilers, but I do know a whole lot about python. :) If this >>>approach makes sense, is there someone with IMCC experience who'd >>>be willing to do some virtual pair programming with me and spike >>>out a prototype? >>> >>If I understood correctly, the codegenerator is isolated to one >>module, right? I don't know Python, and I've a little experience >>with IMC, but it seems to me only a new code generator module should >>be written. So, if for example the Python code generator (generating >>python byte code) has a method "gen_assignment(...)" for generating >>python byte code doing an assignment, then the new module method >>(generating IMC) should do the same, but with IMC instructions. As >>noted earlier, I've got no experience in Python whatsoever, but it >>seems to me it's just a matter of generating the right IMC >>instructions for each construct, so when walking the parse tree, >>calling "gen_imc_*" methods. > >Well... sortof. It's definitely going to take writing a whole new >code generator module; it's not just a matter of getting the right >instructions. Python's interpreter is stack-based, while Parrot's is >register-based, which are two very different kinds of data.
Not necessarily. I've had a good deal of success translating jvm->imcc (which is also a stack->register conversion) simply by simulating the stack during the translation. Since the JVM spec is pretty specific on what is on the stack both before and after an op, this was pretty easy to do. I'm not familiar with the Python bytecode spec (to be a little more accurate, I'm completely clueless about it), but perhaps something similar can be done? Also, another thing to consider is that it might be easier to translate python bytecode directly to imcc rather than to generate imcc straight from the parse tree itself... It's just a thought, anyways. - Joe -- This message was sent using 3wmail. Your fast free POP3 mail client at www.3wmail.com