use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SLInstrumentTest method checkRootNode.
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());
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class PolyglotExceptionFrame method createGuest.
static PolyglotExceptionFrame createGuest(PolyglotExceptionImpl exception, TruffleStackTraceElement frame, boolean first) {
if (frame == null) {
return null;
}
RootNode targetRoot = frame.getTarget().getRootNode();
if (targetRoot.isInternal()) {
return null;
}
LanguageInfo info = targetRoot.getLanguageInfo();
if (info == null) {
return null;
}
PolyglotEngineImpl engine = exception.context.getEngine();
PolyglotLanguage language = engine.idToLanguage.get(info.getId());
String rootName = targetRoot.getName();
SourceSection location;
Node callNode = frame.getLocation();
if (callNode != null) {
com.oracle.truffle.api.source.SourceSection section = callNode.getEncapsulatingSourceSection();
if (section != null) {
Source source = engine.getAPIAccess().newSource(language.getId(), section.getSource());
location = engine.getAPIAccess().newSourceSection(source, section);
} else {
location = null;
}
} else {
location = first ? exception.getSourceLocation() : null;
}
return new PolyglotExceptionFrame(exception, language, location, rootName, false, null);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class InstrumentationTest method testQueryTags2.
/*
* Test behavior of queryTags when used with languages
*/
@Test
public void testQueryTags2() throws IOException {
Instrument instrument = engine.getInstruments().get("testIsNodeTaggedWith1");
assureEnabled(instrument);
TestIsNodeTaggedWith1.expressionNode = null;
TestIsNodeTaggedWith1.statementNode = null;
TestIsNodeTaggedWith1Language.instrumenter = null;
Source otherLanguageSource = Source.create("testIsNodeTaggedWith1-lang", "STATEMENT(EXPRESSION)");
run(otherLanguageSource);
Instrumenter instrumenter = TestIsNodeTaggedWith1Language.instrumenter;
Node languageExpression = TestIsNodeTaggedWith1.expressionNode;
Node languageStatement = TestIsNodeTaggedWith1.statementNode;
assertTags(instrumenter.queryTags(languageExpression), InstrumentationTestLanguage.EXPRESSION);
assertTags(instrumenter.queryTags(languageStatement), InstrumentationTestLanguage.STATEMENT);
TestIsNodeTaggedWith1.expressionNode = null;
TestIsNodeTaggedWith1.statementNode = null;
run("EXPRESSION");
// fail if called with nodes from a different language
Node otherLanguageExpression = TestIsNodeTaggedWith1.expressionNode;
try {
instrumenter.queryTags(otherLanguageExpression);
Assert.fail();
} catch (IllegalArgumentException e) {
}
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class Context method parse.
@Override
protected ExecutableNode parse(InlineParsingRequest request) throws Exception {
Source code = request.getSource();
Node location = request.getLocation();
if (location == null) {
throw new IllegalArgumentException("Location must not be null.");
}
BaseNode node;
try {
node = parse(code);
} catch (LanguageError e) {
throw new IOException(e);
}
return new InlineExecutableNode(this, node);
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class InstrumentationUpdateTest method assertLoaded.
private void assertLoaded(Node... children) {
Iterator<LoadSourceSectionEvent> loadIterator = loadEvents.iterator();
for (Node loadedChild : children) {
Assert.assertTrue(loadIterator.hasNext());
Assert.assertSame(loadedChild, loadIterator.next().getNode());
}
Assert.assertFalse(loadIterator.hasNext());
}
Aggregations