com.oracle.truffle.api.Scope Java Examples
The following examples show how to use
com.oracle.truffle.api.Scope.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HashemLanguage.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
@Override public Iterable<Scope> findLocalScopes(HashemContext context, Node node, Frame frame) { final HashemLexicalScope scope = HashemLexicalScope.createScope(node); return new Iterable<Scope>() { @Override public Iterator<Scope> iterator() { return new Iterator<Scope>() { private HashemLexicalScope previousScope; private HashemLexicalScope nextScope = scope; @Override public boolean hasNext() { if (nextScope == null) { nextScope = previousScope.findParent(); } return nextScope != null; } @Override public Scope next() { if (!hasNext()) { throw new NoSuchElementException(); } Object functionObject = findFunctionObject(); Scope vscope = Scope.newBuilder(nextScope.getName(), nextScope.getVariables(frame)).node(nextScope.getNode()).arguments(nextScope.getArguments(frame)).rootInstance( functionObject).build(); previousScope = nextScope; nextScope = null; return vscope; } private Object findFunctionObject() { String name = node.getRootNode().getName(); return context.getFunctionRegistry().getFunction(name); } }; } }; }
Example #2
Source File: HashemInstrumentTest.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
private static void checkRootNode(Scope ls, String name, MaterializedFrame frame) { assertEquals(name, ls.getName()); Node node = ls.getNode(); assertTrue(node.getClass().getName(), node instanceof RootNode); assertEquals(name, ((RootNode) node).getName()); assertEquals(frame.getFrameDescriptor(), ((RootNode) node).getFrameDescriptor()); }
Example #3
Source File: HashemInstrumentTest.java From mr-hashemi with Universal Permissive License v1.0 | 5 votes |
private static void checkBlock(Scope ls) { assertEquals("block", ls.getName()); // Test that ls.getNode() does not return the current root node, it ought to be a block node Node node = ls.getNode(); assertNotNull(node); assertFalse(node.getClass().getName(), node instanceof RootNode); }
Example #4
Source File: SqueakLanguage.java From trufflesqueak with MIT License | 5 votes |
@Override protected Iterable<Scope> findLocalScopes(final SqueakImageContext context, final Node node, final Frame frame) { // TODO: support access at parse time (frame == null). if (!FrameAccess.isTruffleSqueakFrame(frame)) { return super.findLocalScopes(context, node, frame); } final CompiledCodeObject blockOrMethod = FrameAccess.getBlockOrMethod(frame); final String name = blockOrMethod.toString(); final Object receiver = FrameAccess.getReceiver(frame); final ContextObjectInfo variables = new ContextObjectInfo(frame); final InteropArray arguments = new InteropArray(frame.getArguments()); return Collections.singletonList(Scope.newBuilder(name, variables).node(node).receiver(receiver.toString(), receiver).arguments(arguments).build()); }
Example #5
Source File: HashemLanguage.java From mr-hashemi with Universal Permissive License v1.0 | 4 votes |
@Override protected Iterable<Scope> findTopScopes(HashemContext context) { return context.getTopScopes(); }
Example #6
Source File: SqueakLanguage.java From trufflesqueak with MIT License | 4 votes |
@Override protected Iterable<Scope> findTopScopes(final SqueakImageContext context) { context.ensureLoaded(); return Arrays.asList(Scope.newBuilder("Smalltalk", context.getGlobals()).build()); }