public interface ScopeProvider<C>
Register the scope provider service for a guest language by directly implementing the
TruffleLanguage with this interface.
|Modifier and Type||Interface and Description|
Abstraction of a scope in a guest language program.
ScopeProvider.AbstractScope findScope(C langContext, Node node, Frame frame)
node. There must be at least one scope provided, that corresponds to the enclosing function. The language might provide additional block scopes, closure scopes, etc. The scope hierarchy should correspond with the scope nesting, from the inner-most to the outer-most. The scopes are expected to contain variables valid at the associated node.
In general, there can be a different list of scopes with different variables and arguments
returned for different
Frame instances, as scopes may depend on runtime information.
Known lexical scopes are returned when
frame argument is
Scope.findScopes(com.oracle.truffle.api.instrumentation.TruffleInstrument.Env, com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.Frame)
provides result of this method called on the implementation of the enclosing
. When the guest language does not implement this service, the enclosing
scope with variables read from its
FrameSlots is provided
langContext- the language execution context
node- a node to find the enclosing scopes for. The node is inside a
RootNodeassociated with this language.
frame- The current frame the node is in, or
nullfor lexical access when the program is not running, or is not suspended at the node's location.