Interface GraphLocations<M,P,L>

Type Parameters:
M - type representing methods
P - type representing source code location
L - represeting stack element location

public interface GraphLocations<M,P,L>
Provides source location information about compiled code. This interface is an extension of GraphElements - by default the elements work with classical StackTraceElement. Should the default behavior not be sufficient, feel free to implement the additional operations available in this interface and register your implementation when building the GraphOutput instance.
Since:
0.33 part of GraalVM 0.33
  • Method Summary

    Modifier and Type
    Method
    Description
    locationLanguage(L location)
    Identification of the language.
    int
    Line number of a location.
    int
    locationOffsetEnd(L location)
    Offset of the location.
    int
    Offset of the location.
    locationURI(L location)
    The universal resource identification that contains the location.If the location can be found in an assummably accessible resource, then use such resource identification.
    methodLocation(M method, int bci, P pos)
    Stack trace element for a method, index and position.
  • Method Details

    • methodLocation

      Iterable<L> methodLocation(M method, int bci, P pos)
      Stack trace element for a method, index and position. Returns all applicable source locations for given code position. Each provided location is expected to represent location in a different language.
      Parameters:
      method - the method
      bci - the index
      pos - the position
      Returns:
      elements representing location for all language strata
    • locationLanguage

      String locationLanguage(L location)
      Identification of the language. Each location can point to a source in a different language - e.g. each location can have multiple strata.
      Parameters:
      location - the location
      Returns:
      id of the language/strata
    • locationURI

      URI locationURI(L location) throws URISyntaxException
      The universal resource identification that contains the location.If the location can be found in an assummably accessible resource, then use such resource identification. It is up to the side processing the URI to load the content from the location. Protocols scheme file, http, or https are assumed to be accessible.

      If the location is inside of a virtual source, or source which is unlikely to be accessible outside of running program, then it may be better to encode the whole source into the resource identifier. This can be done by using data URIs like:

       data:text/javascript,alert('Vivat graphs!')
       
      Parameters:
      location - the location
      Returns:
      the file name for the given location or null if it is not known
      Throws:
      URISyntaxException - yielding this exception aborts the graph dumping
    • locationLineNumber

      int locationLineNumber(L location)
      Line number of a location. The first line in the source file is one. Negative value means the line location isn't available. In such situation one can provide an offset driven location co-ordinates via locationOffsetStart(java.lang.Object) and locationOffsetEnd(java.lang.Object) methods.
      Parameters:
      location - the location
      Returns:
      the line number for given location, negative value means no line
    • locationOffsetStart

      int locationOffsetStart(L location)
      Offset of the location. In certain situations it is preferrable to specify offset rather than line number of a location in source. In such case return the start offset from this method and end offset via locationOffsetEnd(java.lang.Object) method. Offsets are counted from 0.
      Parameters:
      location - the location
      Returns:
      the starting offset of the location, negative value means no offset
    • locationOffsetEnd

      int locationOffsetEnd(L location)
      Offset of the location. In certain situations it is preferrable to specify offset rather than line number of a location in source. In such case return the start offset via locationOffsetStart(java.lang.Object) method and end from this method. Offsets are counted from 0.
      Parameters:
      location - the location
      Returns:
      the end offset (exclusive) of the location, negative value means no offset