guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Description of `program-sources' and accessors


From: Andy Wingo
Subject: Re: Description of `program-sources' and accessors
Date: Tue, 22 Apr 2014 21:31:51 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

On Tue 22 Apr 2014 18:43, "Diogo F. S. Ramos" <address@hidden> writes:

>>> I'm using this interface to know where an object has been defined.
>>
>> What does this mean?  (Have you seen the (system xref) facility?  It
>> doesn't do a good job with non-procedures, but perhaps we could change
>> that.)
>
> Thank you for the reference.  `procedure-callees' and
> `procedure-callers' are very useful.
>
> For what I mean, I want to know the source file and line where an object
> has been defined.  For example:
>
>   (object-location (module-ref (current-module) 'procedure-callees)) =>
>   ((file . "/path/to/module/system/xref.scm") (line . 89))
>
> I couldn't figure out how to achieve it with (system xref) but after
> your explanation, I'm using the VMs interface, hence my previous
> question.

I see.  Indeed, you need to use (program-source proc 0) currently, for
procedures.  For non-procedure objects there's currently no way to know
where they're defined, and indeed it's tricky.  E.g.:

  (define foo '(1 2 3))
  (define bar '(1 2 3))

Since these are literals they share storage, so you can't tell whether
the value that `foo' evaluates to proceeded from the "foo" definition or
the "bar" definition.  Then there are immediates like fixnums, etc,
which obviously can't be traced to their definitions.

On the other hand it is probably possible to know where a name "foo" in
a module (bar) is defined, through VM internals.  Not currently
implemented.  But that's a mapping from fully-qualified _names_ to
locations, not values to locations.

Regards,

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]