[gambit-list] A register is not initialized in gvm code?

Marc Feeley feeley at iro.umontreal.ca
Tue Nov 23 09:35:29 EST 2010


On 2010-11-23, at 7:11 AM, Oleg Parashchenko wrote:

> Hello Marc,
> 
> On Fri, 19 Nov 2010 09:09:13 -0500
> Marc Feeley <feeley at iro.umontreal.ca> wrote:
> 
> ...
>> 
>> In the source code of the compiler you will find comments:
>> 
>> - gsc/_back.scm: top of file comment is the API with the back-end
>> - gsc/_t-c-1.scm: check comments for each API function
> 
> Thanks for the pointer, the documentation there is useful.
> 
> ...
>>> Instead implementing a backend for Gambit, I'd like to start with an
>>> independent tool, which parses the GVM code.
>> 
>> Yikes!  Please don't do this!  It's plain wrong!  Hook into the
>> compiler by creating a new "target".  A minimalist target is no more
>> that 100 lines of simple code.
> 
> I'm a bit sceptical that the task can be so easy, but going to follow
> the advice.

See the code attached below (_t-univ.scm) which you should put in the gsc/ subdirectory.

> At the first time, I'll need to experiment, but the cycle (change code,
> re-compile gsc, install it, run the new gsc) is a bit long. Is there a
> possibility to avoid re-compilation and immediately run the new code?

Absolutely!  You can interpret the code you are developing and hook it into the compiler (so that the compiler is calling your interpreted code).  It is all transparent (the compiler, which is compiled Scheme code, can call interpreted Scheme code, and vice-versa).  Here's a sample interaction from within the gsc/ subdirectory:

% gsc
Gambit v4.6.0

> (load "_t-univ.scm")
"/Users/feeley/gambit/gsc/_t-univ.scm"
> (c#cf "fib.scm" 'php '() #f #f)
...

The (load "_t-univ.scm") installs a target for php.  Note that I am calling c#cf (the compiler's internal "compile-file" function) directly so that the target (i.e. php) can be chosen explicitly.  See the top of the file gsc/_front.scm for documentation on c#cf's parameters.

If you modify _t-univ.scm you can either reload the file, or send to the REPL the function definition that you modified (this can be done with a cut-and-paste, or even better, from within emacs with C-x C-e if your cursor is just after the code to send to the REPL, and you are running gsi as a subprocess, with C-u M-x run-scheme).

Marc

-------------- next part --------------
A non-text attachment was scrubbed...
Name: _t-univ.scm
Type: application/octet-stream
Size: 5664 bytes
Desc: not available
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20101123/22406149/attachment.obj>


More information about the Gambit-list mailing list