use of com.oracle.truffle.sl.nodes.local.SLLexicalScope in project graal by oracle.
the class SLLanguage method findLocalScopes.
@Override
public Iterable<Scope> findLocalScopes(SLContext context, Node node, Frame frame) {
final SLLexicalScope scope = SLLexicalScope.createScope(node);
return new Iterable<Scope>() {
@Override
public Iterator<Scope> iterator() {
return new Iterator<Scope>() {
private SLLexicalScope previousScope;
private SLLexicalScope nextScope = scope;
@Override
public boolean hasNext() {
if (nextScope == null) {
nextScope = previousScope.findParent();
}
return nextScope != null;
}
@Override
public Scope next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
Scope vscope = Scope.newBuilder(nextScope.getName(), nextScope.getVariables(frame)).node(nextScope.getNode()).arguments(nextScope.getArguments(frame)).build();
previousScope = nextScope;
nextScope = null;
return vscope;
}
};
}
};
}
Aggregations