/** * Find a hierarchy of local scopes enclosing the given {@link Node node}. Unless the node is in * a global scope, it is expected that there is at least one scope provided, that corresponds to * the enclosing function. The language might provide additional block scopes, closure scopes, * etc. Global top scopes are provided by {@link #findTopScopes(java.lang.Object)}. 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 given node. * <p> * Scopes may depend on the information provided by the frame. <br/> * Lexical scopes are returned when <code>frame</code> argument is <code>null</code>. * <p> * When not overridden, the enclosing {@link RootNode}'s scope with variables read from its * {@link FrameDescriptor}'s {@link FrameSlot}s is provided by default. * <p> * The * {@link com.oracle.truffle.api.instrumentation.TruffleInstrument.Env#findLocalScopes(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.Frame)} * provides result of this method to instruments. * * @param context the current context of the language * @param node a node to find the enclosing scopes for. The node, is inside a {@link RootNode} * associated with this language. * @param frame The current frame the node is in, or <code>null</code> for lexical access when * the program is not running, or is not suspended at the node's location. * @return an iterable with scopes in their nesting order from the inner-most to the outer-most. * @since 0.30 */ protected Iterable<Scope> findLocalScopes(C context, Node node, Frame frame) { assert node != null; return AccessAPI.engineAccess().createDefaultLexicalScope(node, frame); }
/** * Find a hierarchy of local scopes enclosing the given {@link Node node}. Unless the node is in * a global scope, it is expected that there is at least one scope provided, that corresponds to * the enclosing function. The language might provide additional block scopes, closure scopes, * etc. Global top scopes are provided by {@link #findTopScopes(java.lang.Object)}. 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 given node. * <p> * Scopes may depend on the information provided by the frame. <br/> * Lexical scopes are returned when <code>frame</code> argument is <code>null</code>. * <p> * When not overridden, the enclosing {@link RootNode}'s scope with variables read from its * {@link FrameDescriptor}'s {@link FrameSlot}s is provided by default. * <p> * The * {@link com.oracle.truffle.api.instrumentation.TruffleInstrument.Env#findLocalScopes(com.oracle.truffle.api.nodes.Node, com.oracle.truffle.api.frame.Frame)} * provides result of this method to instruments. * * @param context the current context of the language * @param node a node to find the enclosing scopes for. The node, is inside a {@link RootNode} * associated with this language. * @param frame The current frame the node is in, or <code>null</code> for lexical access when * the program is not running, or is not suspended at the node's location. * @return an iterable with scopes in their nesting order from the inner-most to the outer-most. * @since 0.30 */ protected Iterable<Scope> findLocalScopes(C context, Node node, Frame frame) { assert node != null; return AccessAPI.engineAccess().createDefaultLexicalScope(node, frame); }