本文整理了Java中com.oracle.truffle.api.nodes.Node.getEncapsulatingSourceSection()
方法的一些代码示例,展示了Node.getEncapsulatingSourceSection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getEncapsulatingSourceSection()
方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
方法名:getEncapsulatingSourceSection
[英]Retrieves the segment of guest language source code that is represented by this Node, if present; otherwise retrieves the segment represented by the nearest AST ancestor that has this information. Can be called on any thread and without a language context.
[中]检索此节点表示的来宾语言源代码段(如果存在);否则,检索由具有此信息的最近AST祖先表示的段。可以在任何线程上调用,无需语言上下文。
代码示例来源:origin: com.oracle.truffle/truffle-api
@Override
public SourceSection getInstrumentedSourceSection() {
if (node == null) {
return null;
} else {
return node.getEncapsulatingSourceSection();
}
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
@Override
public SourceSection getInstrumentedSourceSection() {
if (node == null) {
return null;
} else {
return node.getEncapsulatingSourceSection();
}
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
/**
* Returns a location where this exception occurred in the AST. This method may return
* <code>null</code> to indicate that the location is not available.
*
* @return the {@link SourceSection} or null
* @since 0.33
*/
default SourceSection getSourceLocation() {
final Node node = getLocation();
return node == null ? null : node.getEncapsulatingSourceSection();
}
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/**
* Returns a location where this exception occurred in the AST. This method may return
* <code>null</code> to indicate that the location is not available.
*
* @return the {@link SourceSection} or null
* @since 0.33
*/
default SourceSection getSourceLocation() {
final Node node = getLocation();
return node == null ? null : node.getEncapsulatingSourceSection();
}
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/**
* Get a source section representing this scope. Please note that while this scope does not
* provide variables that are valid only after the suspension point, the source section can
* actually span after the suspension point.
*
* @return the source section, or <code>null</code> when not available.
* @since 0.29
*/
public SourceSection getSourceSection() {
Node node = scope.getNode();
if (node != null) {
return node.getEncapsulatingSourceSection();
} else {
return null;
}
}
代码示例来源:origin: com.oracle/truffle
public String displaySourceLocation(Node node) {
if (node == null) {
return "<unknown>";
}
SourceSection section = node.getSourceSection();
boolean estimated = false;
if (section == null) {
section = node.getEncapsulatingSourceSection();
estimated = true;
}
return section.getShortDescription() + (estimated ? "~" : "");
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
public SourceSection getInstrumentedSourceSection() {
SourceSection ss = eventContext.getInstrumentedSourceSection();
if (ss == null) {
Node node = eventContext.getInstrumentedNode();
// Nodes tagged with standard tags should have a source section attached.
PrintStream err = new PrintStream(env.err());
err.print("WARNING: Instrumented node " + node + " of class " + node.getClass() + " has null SourceSection.");
ss = node.getEncapsulatingSourceSection();
if (ss == null) {
RootNode root = node.getRootNode();
err.print("WARNING: and null encapsulating SourceSection under " + root + " of class = " + root.getClass());
}
err.flush();
}
return ss;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
/**
* Returns the source section location of this trace element. The source section is
* <code>null</code> if the source location is not available.
*
* @since 1.0
*/
public SourceSection getSourceSection() {
Node node = traceElement.getLocation();
if (node != null) {
return session.resolveSection(node.getEncapsulatingSourceSection());
}
return null;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
@Override
public Caller visitFrame(FrameInstance frameInstance) {
// we stop at eval root stack frames
if (!SuspendedEvent.isEvalRootStackFrame(DebuggerSession.this, frameInstance) && (depth++ == 0)) {
return null;
}
Node callNode = frameInstance.getCallNode();
// Prefer call node with a source section
if (callNode != null && callNode.getEncapsulatingSourceSection() != null) {
return new Caller(frameInstance);
} else {
if (nearestCaller[0] == null) {
nearestCaller[0] = new Caller(frameInstance);
}
return null;
}
}
});
代码示例来源:origin: org.graalvm.compiler/compiler
SourceSection sourceSection = null;
if (callNode != null) {
sourceSection = callNode.getEncapsulatingSourceSection();
代码示例来源:origin: org.graalvm.truffle/truffle-api
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) {
if (TruffleOptions.TraceRewritesFilterFromCost != null) {
if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) {
return;
}
}
if (TruffleOptions.TraceRewritesFilterToCost != null) {
if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) {
return;
}
}
String filter = TruffleOptions.TraceRewritesFilterClass;
Class<? extends Node> from = oldNode.getClass();
Class<? extends Node> to = newNode.getClass();
if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) {
return;
}
final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection();
PrintStream out = System.out;
out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s %s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode),
reason != null && reason.length() > 0 ? reason : "unknown", formatLocation(reportedSourceSection));
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
/**
* Get a source section representing this scope. Please note that while this scope does not
* provide variables that are valid only after the suspension point, the source section can
* actually span after the suspension point.
*
* @return the source section, or <code>null</code> when not available.
* @throws DebugException when guest language code throws an exception
* @since 0.29
*/
public SourceSection getSourceSection() throws DebugException {
try {
Node node = scope.getNode();
if (node != null) {
return session.resolveSection(node.getEncapsulatingSourceSection());
} else {
return null;
}
} catch (ThreadDeath td) {
throw td;
} catch (Throwable ex) {
throw new DebugException(session, ex, language, null, true, null);
}
}
代码示例来源:origin: com.oracle.truffle/truffle-api
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) {
if (TruffleOptions.TraceRewritesFilterFromCost != null) {
if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) {
return;
}
}
if (TruffleOptions.TraceRewritesFilterToCost != null) {
if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) {
return;
}
}
String filter = TruffleOptions.TraceRewritesFilterClass;
Class<? extends Node> from = oldNode.getClass();
Class<? extends Node> to = newNode.getClass();
if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) {
return;
}
final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection();
PrintStream out = System.out;
out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s %s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode),
reason != null && reason.length() > 0 ? reason : "unknown", formatLocation(reportedSourceSection));
}
代码示例来源:origin: com.oracle/truffle
static void traceRewrite(Node oldNode, Node newNode, CharSequence reason) {
if (TruffleOptions.TraceRewritesFilterFromCost != null) {
if (filterByKind(oldNode, TruffleOptions.TraceRewritesFilterFromCost)) {
return;
}
}
if (TruffleOptions.TraceRewritesFilterToCost != null) {
if (filterByKind(newNode, TruffleOptions.TraceRewritesFilterToCost)) {
return;
}
}
String filter = TruffleOptions.TraceRewritesFilterClass;
Class<? extends Node> from = oldNode.getClass();
Class<? extends Node> to = newNode.getClass();
if (filter != null && (filterByContainsClassName(from, filter) || filterByContainsClassName(to, filter))) {
return;
}
final SourceSection reportedSourceSection = oldNode.getEncapsulatingSourceSection();
PrintStream out = System.out;
out.printf("[truffle] rewrite %-50s |From %-40s |To %-40s |Reason %s%s%n", oldNode.toString(), formatNodeInfo(oldNode), formatNodeInfo(newNode),
reason != null && reason.length() > 0 ? reason : "unknown", reportedSourceSection != null ? " at " + reportedSourceSection.getShortDescription() : "");
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/**
* Returns the source section of the location where the debugging session was suspended. The
* source section is <code>null</code> if the source location is not available.
*
* <p>
* This method is thread-safe.
*
* @since 0.17
*/
public SourceSection getSourceSection() {
verifyValidState(true);
if (currentFrame == null) {
SuspendedContext context = getContext();
return context.getInstrumentedSourceSection();
} else {
Node callNode = currentFrame.getCallNode();
if (callNode != null) {
return callNode.getEncapsulatingSourceSection();
}
return null;
}
}
代码示例来源:origin: cesquivias/mumbler
SourceSection sourceSection = callNode.getEncapsulatingSourceSection();
Source source = sourceSection != null ? sourceSection.getSource() : null;
String sourceName = source != null ? source.getName() : null;
代码示例来源:origin: org.graalvm.truffle/truffle-api
/**
* Returns the source section of the location where the debugging session was suspended. The
* source section is <code>null</code> if the source location is not available.
*
* <p>
* This method is thread-safe.
*
* @since 0.17
*/
public SourceSection getSourceSection() {
verifyValidState(true);
if (currentFrame == null) {
SuspendedContext context = getContext();
return event.getSession().resolveSection(context.getInstrumentedSourceSection());
} else {
Node callNode = currentFrame.getCallNode();
if (callNode != null) {
return event.getSession().resolveSection(callNode.getEncapsulatingSourceSection());
}
return null;
}
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
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.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);
}
代码示例来源:origin: com.oracle.truffle/truffle-api
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);
}
内容来源于网络,如有侵权,请联系作者删除!