Vl-location
Representation of a point in a source file.
- Signature
(vl-location filename line col) → loc
- Arguments
- filename — Guard (stringp filename).
- line — Guard (posp line).
- col — Guard (natp col).
- Returns
- loc — Type (vl-location-p loc).
A vl-location structure represents some location in a source
code file. These locations are attached to characters and module items to
provide context during error reporting.
Historically, vl-location was an ordinary, tagged defprod with
three fields: a filename, line number, and column number. Because there are
many locations, this representation used a lot of memory.
We now instead represent locations using a custom structure, essentially of
the form:
(linecol . (:vl-location . filename))
Where the line and column number typically are only a single fixnum; see
vl-linecol. It looks like this takes 2 conses, but we hons the
(:vl-location . filename) pair so that we only need one such cons per
file. So for all practical purposes, each vl-location really only costs
us a single cons.
Despite this fancy representation, the interface to locations still acts as
though it is a defprod with just a filename, line, and column number.
You can use the ordinary b* binders and make/change macros to access and
create locations, as you would expect.
A downside of this representation is that vl-location structures are no
longer very readable when you encounter them in traces, etc. However, the
:vl-location tag is still there, which allows vl-fmt to understand
when it has encountered a location, and to print these locations in a readable
way.
Subtopics
- Vl-location-p
- Recognizer for vl-location structures.
- Vl-string-between-locs
- Given a string, extract all text that occurs between two vl-location-ps.
- Vl-location-between-p
- (vl-location-between-p x min max) is true exactly when x is in the
same file as min and max, and inclusively falls between these
bounds.
- Vl-string-findloc
- Traverse a string to determine the position of a vl-location-p.
- Vl-linecol
- Packed representation of a line number and column number.
- Vl-location-string
- Convert an vl-location-p into a string.
- Vl-location-fix
- Fixing function for vl-location structures.
- Vl-location->line
- Get the line number from a vl-location.
- Vl-location->filename
- Get the filename from a vl-location.
- Vl-location->col
- Get the column number from a vl-location.
- Vl-locationlist
- A list of vl-location-p objects.
- *vl-fakeloc*
- A "fake" vl-location-p which we use when generating our
own extended-characters and module items.