001: package xtc.lang.jeannie;
002:
003: import xtc.tree.GNode;
004: import xtc.tree.Printer;
005:
006: public final class DebuggerAstPrinter extends JeanniePrinter {
007: public DebuggerAstPrinter(final Printer printer) {
008: super (printer, null);
009: }
010:
011: /** Visit a BreakClassCommand = QualifiedIdentifier LineNumber. */
012: public final void visitBreakClassCommand(final GNode n) {
013: enterJava(TransitionKind.SILENT);
014: _printer.p("stop at ").p(n.getNode(0)).p(':').p(n.getString(1))
015: .pln();
016: exitJava();
017: }
018:
019: /** Visit a BreakFileCommand = FileName LineNumber. */
020: public final void visitBreakFileCommand(final GNode n) {
021: _printer.p("break ").p(n.getString(0)).p(':').p(n.getString(1))
022: .pln();
023: }
024:
025: /** Visit a C2jCommand = (no children). */
026: public final void visitC2jCommand(final GNode n) {
027: assert 0 == n.size();
028: _printer.p("c2j").pln();
029: }
030:
031: /** Visit a ContinueCommand = (no children). */
032: public final void visitContinueCommand(final GNode n) {
033: assert 0 == n.size();
034: _printer.p("continue").pln();
035: }
036:
037: /** Visit a DeleteCommand = IntegerLiteral. */
038: public final void visitDeleteCommand(final GNode n) {
039: enterJava(TransitionKind.SILENT);
040: _printer.p("delete ").p(n.getNode(0)).pln();
041: exitJava();
042: }
043:
044: /** Visit a DownCommand = IntegerLiteral. */
045: public final void visitDownCommand(final GNode n) {
046: enterJava(TransitionKind.SILENT);
047: _printer.p("down ").p(n.getNode(0)).pln();
048: exitJava();
049: }
050:
051: /** Visit a ExitCommand = (no children). */
052: public final void visitExitCommand(final GNode n) {
053: assert 0 == n.size();
054: _printer.p("exit").pln();
055: }
056:
057: /** Visit a GdbCommand = RestOfLine. */
058: public final void visitGdbCommand(final GNode n) {
059: _printer.p("gdb ").p(n.getString(0)).pln();
060: }
061:
062: /** Visit a HelpCommand = (no children). */
063: public final void visitHelpCommand(final GNode n) {
064: assert 0 == n.size();
065: _printer.p("help").pln();
066: }
067:
068: /** Visit a InfoBreakCommand = (no children). */
069: public final void visitInfoBreakCommand(final GNode n) {
070: assert 0 == n.size();
071: _printer.p("info break").pln();
072: }
073:
074: /** Visit a InfoWatchCommand = (no children). */
075: public final void visitInfoWatchCommand(final GNode n) {
076: assert 0 == n.size();
077: _printer.p("info watch").pln();
078: }
079:
080: /** Visit an InitJCommand = (no children). */
081: public final void visitInitJCommand(final GNode n) {
082: assert 0 == n.size();
083: _printer.p("initj").pln();
084: }
085:
086: /** Visit a J2cCommand = (no children). */
087: public final void visitJ2cCommand(final GNode n) {
088: assert 0 == n.size();
089: _printer.p("j2c").pln();
090: }
091:
092: /** Visit a JdbCommand = RestOfLine. */
093: public final void visitJdbCommand(final GNode n) {
094: _printer.p("jdb ").p(n.getString(0)).pln();
095: }
096:
097: /** Visit a JRetCommand = (no children). */
098: public final void visitJRetCommand(final GNode n) {
099: assert 0 == n.size();
100: _printer.p("jret").pln();
101: }
102:
103: /** Visit a ListCommand = (no children). */
104: public final void visitListCommand(final GNode n) {
105: assert 0 == n.size();
106: _printer.p("list").pln();
107: }
108:
109: /** Visit a LocalsCommand = (no children). */
110: public final void visitLocalsCommand(final GNode n) {
111: assert 0 == n.size();
112: _printer.p("locals").pln();
113: }
114:
115: /** Visit a NextCommand = (no children). */
116: public final void visitNextCommand(final GNode n) {
117: assert 0 == n.size();
118: _printer.p("next").pln();
119: }
120:
121: /** Visit a RunCommand = (no children). */
122: public final void visitRunCommand(final GNode n) {
123: assert 0 == n.size();
124: _printer.p("run").pln();
125: }
126:
127: /** Visit a PrintCExpressionCommand = C.Expression. */
128: public final void visitPrintCExpressionCommand(final GNode n) {
129: enterC(TransitionKind.SILENT);
130: _printer.p("print ").p(n.getNode(0)).pln();
131: exitC();
132: }
133:
134: /** Visit a PrintJavaExpressionCommand = Java.Expression. */
135: public final void visitPrintJavaExpressionCommand(final GNode n) {
136: enterJava(TransitionKind.SILENT);
137: _printer.p("print ").p(n.getNode(0)).pln();
138: exitJava();
139: }
140:
141: /** Visit a StatCommand = (no children). */
142: public final void visitStatCommand(final GNode n) {
143: assert 0 == n.size();
144: _printer.p("stat").pln();
145: }
146:
147: /** Visit a StepCommand = (no children). */
148: public final void visitStepCommand(final GNode n) {
149: assert 0 == n.size();
150: _printer.p("step").pln();
151: }
152:
153: /** Visit a UpCommand = IntegerLiteral. */
154: public final void visitUpCommand(final GNode n) {
155: enterJava(TransitionKind.SILENT);
156: _printer.p("up ").p(n.getNode(0)).pln();
157: exitJava();
158: }
159:
160: /** Visit a WatchCExpressionCommand = C.Expression. */
161: public final void visitWatchCExpressionCommand(final GNode n) {
162: enterC(TransitionKind.SILENT);
163: _printer.p("watch ").p(n.getNode(0)).pln();
164: exitC();
165: }
166:
167: /** Visit a WatchJavaFieldCommand = WatchKind? QualifiedIdentifier. */
168: public final void visitWatchJavaFieldCommand(final GNode n) {
169: enterJava(TransitionKind.SILENT);
170: _printer.p("watch ");
171: if (null != n.get(0))
172: _printer.p(n.getString(0)).p(' ');
173: _printer.p(n.getNode(1)).pln();
174: exitJava();
175: }
176:
177: /** Visit a WhereCommand = (no children). */
178: public final void visitWhereCommand(final GNode n) {
179: assert 0 == n.size();
180: _printer.p("where").pln();
181: }
182:
183: /** Visit a MetaVariable = Identifier. */
184: public final void visitMetaVariable(final GNode n) {
185: _printer.p('$').p(n.getString(0)).pln();
186: }
187: }
|