< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/NashornTextifier.java

Print this page
rev 1296 : 8081603: erroneous dot file generated from Nashorn --print-code
   1 /*
   2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1092             final StringBuilder sb = new StringBuilder();
1093             sb.append("digraph " + dottyFriendly(name) + " {");
1094             sb.append("\n");
1095             sb.append("\tgraph [fontname=courier]\n");
1096             sb.append("\tnode [style=filled,color="+COLOR_DEFAULT+",fontname=courier]\n");
1097             sb.append("\tedge [fontname=courier]\n\n");
1098 
1099             for (final String node : nodes) {
1100                 sb.append("\t");
1101                 sb.append(node);
1102                 sb.append(" [");
1103                 sb.append("id=");
1104                 sb.append(node);
1105                 sb.append(", label=\"");
1106                 String c = contents.get(node).toString();
1107                 if (c.startsWith(LEFT_ALIGN)) {
1108                     c = c.substring(LEFT_ALIGN.length());
1109                 }
1110                 final String ex = catches.get(node);
1111                 if (ex != null) {
1112                     sb.append("*** CATCH: ").append(ex).append(" ***\n");
1113                 }
1114                 sb.append(c);
1115                 sb.append("\"]\n");
1116             }
1117 
1118             for (final String from : edges.keySet()) {
1119                 for (final String to : edges.get(from)) {
1120                     sb.append("\t");
1121                     sb.append(from);
1122                     sb.append(" -> ");
1123                     sb.append(to);
1124                     sb.append("[label=\"");
1125                     sb.append(to);
1126                     sb.append("\"");
1127                     if (catches.get(to) != null) {
1128                         sb.append(", color=red, style=dashed");
1129                     }
1130                     sb.append(']');
1131                     sb.append(";\n");
1132                 }


   1 /*
   2  * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   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
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


1092             final StringBuilder sb = new StringBuilder();
1093             sb.append("digraph " + dottyFriendly(name) + " {");
1094             sb.append("\n");
1095             sb.append("\tgraph [fontname=courier]\n");
1096             sb.append("\tnode [style=filled,color="+COLOR_DEFAULT+",fontname=courier]\n");
1097             sb.append("\tedge [fontname=courier]\n\n");
1098 
1099             for (final String node : nodes) {
1100                 sb.append("\t");
1101                 sb.append(node);
1102                 sb.append(" [");
1103                 sb.append("id=");
1104                 sb.append(node);
1105                 sb.append(", label=\"");
1106                 String c = contents.get(node).toString();
1107                 if (c.startsWith(LEFT_ALIGN)) {
1108                     c = c.substring(LEFT_ALIGN.length());
1109                 }
1110                 final String ex = catches.get(node);
1111                 if (ex != null) {
1112                     sb.append("*** CATCH: ").append(ex).append(" ***\\l");
1113                 }
1114                 sb.append(c);
1115                 sb.append("\"]\n");
1116             }
1117 
1118             for (final String from : edges.keySet()) {
1119                 for (final String to : edges.get(from)) {
1120                     sb.append("\t");
1121                     sb.append(from);
1122                     sb.append(" -> ");
1123                     sb.append(to);
1124                     sb.append("[label=\"");
1125                     sb.append(to);
1126                     sb.append("\"");
1127                     if (catches.get(to) != null) {
1128                         sb.append(", color=red, style=dashed");
1129                     }
1130                     sb.append(']');
1131                     sb.append(";\n");
1132                 }


< prev index next >