Mercurial > hg > truffle
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 16511:aee02665e505
Truffle: NodeUtil fix for displaying null SourceSections.
author | Michael Van De Vanter <michael.van.de.vanter@oracle.com> |
---|---|
date | Mon, 14 Jul 2014 16:04:09 -0700 |
parents | 915ebb306fcc |
children | d86f948268da |
comparison
equal
deleted
inserted
replaced
16463:f1d839174e71 | 16511:aee02665e505 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this | 7 * published by the Free Software Foundation. Oracle designates this |
862 return node.getClass().getSimpleName(); | 862 return node.getClass().getSimpleName(); |
863 } | 863 } |
864 | 864 |
865 private static String displaySourceAttribution(Node node) { | 865 private static String displaySourceAttribution(Node node) { |
866 final SourceSection section = node.getSourceSection(); | 866 final SourceSection section = node.getSourceSection(); |
867 if (section instanceof NullSourceSection) { | |
868 return "source: " + section.getShortDescription(); | |
869 } | |
867 if (section != null) { | 870 if (section != null) { |
868 final String srcText = section.getCode(); | 871 final String srcText = section.getCode(); |
869 final StringBuilder sb = new StringBuilder(); | 872 final StringBuilder sb = new StringBuilder(); |
870 sb.append("source: len=" + srcText.length()); | 873 sb.append("source: len=" + srcText.length()); |
871 sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); | 874 sb.append(" (" + section.getCharIndex() + "," + (section.getCharEndIndex() - 1) + ")"); |