Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/make/src/classes/build/tools/jdwpgen/OutNode.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.*;2930class OutNode extends AbstractTypeListNode {3132String cmdName;3334void set(String kind, List<Node> components, int lineno) {35super.set(kind, components, lineno);36components.add(0, new NameNode("Out"));37}3839void constrain(Context ctx) {40super.constrain(ctx.commandWritingSubcontext());41CommandNode cmd = (CommandNode)parent;42cmdName = cmd.name;43}4445void genProcessMethod(PrintWriter writer, int depth) {46writer.println();47indent(writer, depth);48writer.print(49"static " + cmdName + " process(VirtualMachineImpl vm");50for (Node node : components) {51TypeNode tn = (TypeNode)node;52writer.println(", ");53indent(writer, depth+5);54writer.print(tn.javaParam());55}56writer.println(")");57indent(writer, depth+6);58writer.println("throws JDWPException {");59indent(writer, depth+1);60writer.print("PacketStream ps = enqueueCommand(vm");61for (Node node : components) {62TypeNode tn = (TypeNode)node;63writer.print(", ");64writer.print(tn.name());65}66writer.println(");");67indent(writer, depth+1);68writer.println("return waitForReply(vm, ps);");69indent(writer, depth);70writer.println("}");71}7273void genEnqueueMethod(PrintWriter writer, int depth) {74writer.println();75indent(writer, depth);76writer.print(77"static PacketStream enqueueCommand(VirtualMachineImpl vm");78for (Node node : components) {79TypeNode tn = (TypeNode)node;80writer.println(", ");81indent(writer, depth+5);82writer.print(tn.javaParam());83}84writer.println(") {");85indent(writer, depth+1);86writer.println(87"PacketStream ps = new PacketStream(vm, COMMAND_SET, COMMAND);");88if (Main.genDebug) {89indent(writer, depth+1);90writer.println(91"if ((vm.traceFlags & VirtualMachineImpl.TRACE_SENDS) != 0) {");92indent(writer, depth+2);93writer.print(94"vm.printTrace(\"Sending Command(id=\" + ps.pkt.id + \") ");95writer.print(parent.context.whereJava);96writer.println(97"\"+(ps.pkt.flags!=0?\", FLAGS=\" + ps.pkt.flags:\"\"));");98indent(writer, depth+1);99writer.println("}");100}101genJavaWrites(writer, depth+1);102indent(writer, depth+1);103writer.println("ps.send();");104indent(writer, depth+1);105writer.println("return ps;");106indent(writer, depth);107writer.println("}");108}109110void genWaitMethod(PrintWriter writer, int depth) {111writer.println();112indent(writer, depth);113writer.println(114"static " + cmdName + " waitForReply(VirtualMachineImpl vm, " +115"PacketStream ps)");116indent(writer, depth+6);117writer.println("throws JDWPException {");118indent(writer, depth+1);119writer.println("ps.waitForReply();");120indent(writer, depth+1);121writer.println("return new " + cmdName + "(vm, ps);");122indent(writer, depth);123writer.println("}");124}125126void genJava(PrintWriter writer, int depth) {127genJavaPreDef(writer, depth);128super.genJava(writer, depth);129genProcessMethod(writer, depth);130genEnqueueMethod(writer, depth);131genWaitMethod(writer, depth);132}133}134135136