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 |
|---|---|
static class |
ScopeProvider.AbstractScope
Abstraction of a scope in a guest language program.
|
| Modifier and Type | Method and Description |
|---|---|
ScopeProvider.AbstractScope |
findScope(C langContext,
Node node,
Frame frame)
Find a hierarchy of scopes enclosing the given
node. |
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 null.
The
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 RootNode
. When the guest language does not implement this service, the enclosing RootNode's
scope with variables read from its FrameDescriptor's FrameSlots is provided
by default.
langContext - the language execution contextnode - a node to find the enclosing scopes for. The node is inside a RootNode
associated with this language.frame - The current frame the node is in, or null for lexical access when
the program is not running, or is not suspended at the node's location.ScopeProvider.AbstractScope.