[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Getting source location information
From: |
Bruce Korb |
Subject: |
Re: Getting source location information |
Date: |
Wed, 30 Nov 2005 12:53:50 -0800 |
User-agent: |
KMail/1.7.1 |
On Wednesday 30 November 2005 11:00 am, Rob Browning wrote:
> If so, then I wondered if it might be possible to just implement the
> function mentioned originally
> i.e. ag_scm_c_eval_string_from_file_line, and here's what I came up
> with. Note that I have no idea if this will actually work; I haven't
> tested it, and I don't know the semantics of the port related
> filename, line, and column bits offhand.
>
> (define (eval-port port)
> ;; See strports.c inner_eval_string for similar code.
> (let loop ((next-form (read port))
> (any-read? #f)
> (result #f))
> (if (eof-object? next-form)
> (if any-read? result)
> (loop (read port)
> #t
> (primitive-eval next-form)))))
>
> (define (eval-string-from-file str filename line column)
> (call-with-input-string str
> (lambda (port)
> (set-port-filename! port filename)
> (set-port-line! port line)
> (set-port-column! port column)
> (eval-port port))))
With the final piece being the C code:
SCM proc = scm_c_eval_string ("eval-string-from-file");
SCM str = scm_from_locale_string (scheme_text);
SCM file = scm_from_locale_string (file_name);
SCM line = scm_from_int (line_no);
SCM res = scm_call_3 (proc, str, file, line);
// Let's forget columns -- we don't have scm_call_4.
Actually, I might as well create the port in C and invoke "eval-port" directly.
I could easily set the column number, too. (If I were tracking it.)
I'll give this a spin and let you know if it works shortly
(a day or two). Thank you. (I still think adding it to libguile
would not hurt.)
Regards, Bruce
- Re: I don't want to maintain this, (continued)
- Re: I don't want to maintain this, Ludovic Courtès, 2005/11/30
- Re: I don't want to maintain this, Bruce Korb, 2005/11/30
- Re: I don't want to maintain this, Ludovic Courtès, 2005/11/30
- Re: I don't want to maintain this, Bruce Korb, 2005/11/30
- Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Ludovic Courtès, 2005/11/30
- Re: Getting source location information, Rob Browning, 2005/11/30
- Re: Getting source location information,
Bruce Korb <=
- Re: Getting source location information, Rob Browning, 2005/11/30
- Re: Getting source location information, Bruce Korb, 2005/11/30
- Re: Getting source location information, Han-Wen Nienhuys, 2005/11/30
Re: I don't want to maintain this, Kevin Ryde, 2005/11/30
Re: I don't want to maintain this, Kevin Ryde, 2005/11/30