Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/jdwpgen/AbstractNamedNode.java
32287 views
/*1* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package build.tools.jdwpgen;2627import java.util.*;28import java.io.*;2930abstract class AbstractNamedNode extends Node {3132NameNode nameNode = null;33String name;3435public String name() {36return name;37}3839void prune() {40Iterator<Node> it = components.iterator();4142if (it.hasNext()) {43Node nameNode = it.next();4445if (nameNode instanceof NameNode) {46this.nameNode = (NameNode)nameNode;47this.name = this.nameNode.text();48it.remove();49} else {50error("Bad name: " + name);51}52} else {53error("empty");54}55super.prune();56}5758void constrain(Context ctx) {59nameNode.constrain(ctx);60super.constrain(ctx.subcontext(name));61}6263void document(PrintWriter writer) {64writer.println("<h4><a name=" + name + ">" + name +65" Command Set</a></h4>");66for (Node node : components) {67node.document(writer);68}69}7071String javaClassName() {72return name();73}7475void genJavaClassSpecifics(PrintWriter writer, int depth) {76}7778String javaClassImplements() {79return ""; // does not implement anything, by default80}8182void genJavaClass(PrintWriter writer, int depth) {83writer.println();84genJavaComment(writer, depth);85indent(writer, depth);86if (depth != 0) {87writer.print("static ");88}89writer.print("class " + javaClassName());90writer.println(javaClassImplements() + " {");91genJavaClassSpecifics(writer, depth+1);92for (Node node : components) {93node.genJava(writer, depth+1);94}95indent(writer, depth);96writer.println("}");97}9899void genCInclude(PrintWriter writer) {100if (nameNode instanceof NameValueNode) {101writer.println("#define " + context.whereC +102" " + nameNode.value());103}104super.genCInclude(writer);105}106}107108109