1. Eu to C translator questions.
- Posted by Mark Brown <mabrown at SENET.COM.AU> Jun 19, 2000
- 479 views
------=_NextPart_000_002B_01BFD983.5AAB9280 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all. With the Eu --> C translator progressing, I'm curious as to just how this is all going to work (others have tried to explain=20 it to me but I still don't get it) How can the Euphoria specific parts of the language (and I'm=20 thinking here of the "dynamic" parts of Euphoria, atoms,=20 sequences etc) be translated to C code without giving the=20 whole game away? Or am right in thinking that an interpreted=20 / run time core will still exist somewhere along the line.=20 I can't see how the specific Euphoria types can be handled in C without the code that handles it either being visible to us or hidden in some sort of run time form. Can someone explain? All the best Mark =20 ------=_NextPart_000_002B_01BFD983.5AAB9280 charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META content=3D"text/html; charset=3Diso-8859-1" = http-equiv=3DContent-Type> <META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT size=3D2>Hi all.</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>With the Eu --> C translator progressing, I'm = curious as=20 to</FONT></DIV> <DIV><FONT size=3D2>just how this is all going to work (others have = tried to=20 </FONT><FONT size=3D2>explain </FONT></DIV> <DIV><FONT size=3D2>it to me but I still don't get it)</FONT></DIV> <DIV> </DIV> <DIV><FONT size=3D2>How can the Euphoria specific parts of the language=20 </FONT><FONT size=3D2>(and I'm </FONT></DIV> <DIV><FONT size=3D2>thinking here of the "dynamic" parts of=20 Euphoria, </FONT><FONT size=3D2>atoms, </FONT></DIV> <DIV><FONT size=3D2>sequences etc) be translated to C code </FONT><FONT=20 size=3D2>without giving the </FONT></DIV> <DIV><FONT size=3D2>whole game away?</FONT> <FONT size=3D2>Or=20 am<EM> </EM>right in </FONT><FONT size=3D2>thinking that an = interpreted=20 </FONT></DIV> <DIV><FONT size=3D2>/ run time core will still </FONT><FONT = size=3D2>exist somewhere=20 along the line. </FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>I can't see how the specific Euphoria types can be = handled=20 in</FONT></DIV> <DIV><FONT size=3D2>C without the code that handles it either being = visible to=20 us</FONT></DIV> <DIV><FONT size=3D2>or hidden in some sort of run time = form.</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>Can someone explain?</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> <DIV><FONT size=3D2>All the best</FONT></DIV> <DIV><FONT size=3D2></FONT> </DIV> ------=_NextPart_000_002B_01BFD983.5AAB9280--
2. Re: Eu to C translator questions.
- Posted by Robert Craig <rds at ATTCANADA.NET> Jun 19, 2000
- 480 views
Mark Brown writes: > How can the Euphoria specific parts of the language (and I'm > thinking here of the "dynamic" parts of Euphoria, atoms, > sequences etc) be translated to C code without giving the > whole game away? Or am right in thinking that an interpreted > / run time core will still exist somewhere along the line. > I can't see how the specific Euphoria types can be handled in > C without the code that handles it either being visible to us > or hidden in some sort of run time form. The compiler generates a .c file for each Euphoria file in your program, i.e. a .c for the main file, and a .c file for each included file. Creating one huge .c would risk blowing the size limits on some C compilers. Your .c's are compiled into .obj's (machine code) and linked with other .obj's supplied by RDS. The RDS .obj's contain run-time routines for things like repeat(), append(), dir() etc. Things which take too much code to be done in-line. The scanner, parser, and these runtime routines are shared between the interpreter and the compiler (although some run-time routines for the compiler have checking eliminated for greater speed.) It's true that by examining the generated C code, people will learn a lot. They won't be able to examine the run-time routines because I don't plan to give away the source to the run-time routines. Just because people get a few tips on how to implement Euphoria in C, I don't think that means that a lot of Euphoria clones are going to suddenly appear, putting RDS out of business. I don't think there are many people out there with the motivation, the time, and the stamina to do a really good job of it. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Eu to C translator questions.
- Posted by Jason Leit <jasonleit at HOTMAIL.COM> Jun 20, 2000
- 446 views
You know I gave this Euphoria compiler project some thought, and imagined how *I* would do it if I had to. And I came up with a simple sheme. A single .obj file called Euphoria.obj would contain all the Ephoria run-time routines. Then, for each .e or .ew file, a .h header with exported globals is generated, and a coresponding .c file. Some of the routines in Euphoria.obj would be something like these; Sequence * create_sequence(); void init_sequence(); void append_seqeunce(); void prepend_sequence(); void insert_item(); void free_sequence(); Then when a Euphoria program converted to C should use a sequence, it just does it by calling above routines. Anyone that looks at the source generated by the Euphoria compiler can't tell how sequence work, because these functions are defined in a precompiled .obj file. When thinking about using precompiled routines to implement Euphoria's library, I came to realise that the mayority or work that needs to be done by any Euphoria program, is call some C routines. I then thought of how easy it would be to go for the gold and implement a Euphoria to ASM compiler. Just some control-flow and math operations, and calling some functions, is what the ASM source should look like. Look at NASM, it supports dozens of platforms, consists out off a single executable, is open-source and free, and works with 32-Bit windows and can call routines from DLLs plus generate DLLs. I found writing ASM programs in NASM often easier then writing equivalent programs in C. 32-Bit ASM on Windows is a heck of a lot easier and more elegant then old-school ASM, infact I find ASM on Win32 to be easier to use then most "high-level" programming languages out there. (like JAVA for example : ) Since my guesses are that what Rob is doing is stepping through an array in memory containing the virtual machine instructions Euphoria programs get turned into before running them, and then are now translated to equivalent C code, then mapping the Interpetter's Eu compiled code to C would be harder then when mapping it to ASM. You should be carefull to nottice if what you are doing is translate some pointers to "add(),div(),call()" virtual machine codes to C, because if so the C compiler won't be able to do math optimisations, and converting output to an assembler instead of a C compiler would be easier to do that way. But I guess you allready knew this :) Jason Leit, Cheers :) >Robert Craig writes: >The compiler generates a .c file for each Euphoria file in >your program, i.e. a .c for the main file, and a .c file for each >included file. Creating one huge .c would risk blowing the >size limits on some C compilers. > >Your .c's are compiled into .obj's (machine code) >and linked with other .obj's supplied by RDS. >The RDS .obj's contain run-time routines >for things like repeat(), append(), dir() etc. Things which take >too much code to be done in-line. > >The scanner, parser, and these runtime routines are shared >between the interpreter and the compiler (although some run-time >routines for the compiler have checking eliminated for >greater speed.) > >It's true that by examining the generated C code, people >will learn a lot. They won't be able to examine the run-time >routines because I don't plan to give away the source >to the run-time routines. > >Just because people get a few tips on how to implement >Euphoria in C, I don't think that means that a lot of Euphoria >clones are going to suddenly appear, putting RDS out of business. >I don't think there are many people out there with the motivation, >the time, and the stamina to do a really good job of it. > >Regards, > Rob Craig > Rapid Deployment Software > http://www.RapidEuphoria.com ________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com