001: package xtc.lang.jeannie;
002:
003: import java.io.IOException;
004:
005: import xtc.lang.jeannie.Debugger.DebugerControlStatus;
006: import xtc.lang.jeannie.DebuggerAstAnalyzer.Language;
007: import xtc.lang.jeannie.JeanniePrinter.TransitionKind;
008: import xtc.tree.GNode;
009: import xtc.tree.Visitor;
010:
011: public final class DebuggerInterpreter extends Visitor {
012: private final Debugger _dbg;
013:
014: DebuggerInterpreter(final Debugger dbg) {
015: _dbg = dbg;
016: }
017:
018: /** Visit an AdditiveExpression = Expression ("+" / "-") Expression. */
019: public final void visitAdditiveExpression(final GNode n) {
020: assert false : "not yet implemented";
021: }
022:
023: /** Visit an AddressExpression = Expression. */
024: public final void visitAddressExpression(final GNode n) {
025: assert false : "not yet implemented";
026: }
027:
028: /** Visit Arguments = Expression*. */
029: public final void visitArguments(final GNode n) {
030: assert false : "not yet implemented";
031: }
032:
033: /** Visit an AssignmentExpression = Expression ("=" / "+=" / "-=" / "*=" / "/=" / "%=" / "<<=" / ">>=" / "&=" / "^=" / "|=") Expression. */
034: public final void visitAssignmentExpression(final GNode n) {
035: assert false : "not yet implemented";
036: }
037:
038: /** Visit a BreakClassCommand = QualifiedIdentifier LineNumber. */
039: public final void visitBreakClassCommand(final GNode n) {
040: String className = n.getNode(0).getString(0);
041: int lineNumber = Integer.parseInt(n.getString(1));
042: _dbg.debuggerCommand.executeStopAt(className, lineNumber);
043: }
044:
045: /** Visit a BreakFileCommand = FileName LineNumber. */
046: public final void visitBreakFileCommand(final GNode n) {
047: String fileName = n.getString(0);
048: int lineNumber = Integer.parseInt(n.getString(1));
049: _dbg.debuggerCommand.executeBreak(fileName, lineNumber);
050: }
051:
052: /** Visit a C2jCommand = (no children). */
053: public final void visitC2jCommand(final GNode n) {
054: _dbg.n2j();
055: }
056:
057: /** Visit a CallExpression = [Expression] null MethodName Arguments. */
058: public final void visitCallExpression(final GNode n) {
059: assert false : "not yet implemented";
060: }
061:
062: /** Visit a CInJavaExpression = C.UnaryExpression. */
063: public final void visitCInJavaExpression(final GNode n) {
064: assert false : "not yet implemented";
065: }
066:
067: /** Visit a ContinueCommand = (no children). */
068: public final void visitContinueCommand(final GNode n) {
069: _dbg.cont();
070: }
071:
072: /** Visit a DeleteCommand = IntegerLiteral. */
073: public final void visitDeleteCommand(final GNode n) {
074: int id = Integer.parseInt(n.getNode(0).getString(0));
075: _dbg.debuggerCommand.executeDelete(id);
076: }
077:
078: /** Visit a DirectComponentSelection = Expression String. */
079: public final void visitDirectComponentSelection(final GNode n) {
080: assert false : "not yet implemented";
081: }
082:
083: /** Visit a DownCommand = IntegerLiteral. */
084: public final void visitDownCommand(final GNode n) {
085: assert false : "not yet implemented";
086: }
087:
088: /** Visit a EqualityExpression = Expression ("==" / "!=") Expression. */
089: public final String visitEqualityExpression(final GNode n) {
090: assert false : "not yet implemented";
091: //maybe, use meta-variables or some other temporary storage of pointers in Java
092: final DebuggerAstAnalyzer.Language language = DebuggerAstAnalyzer
093: .getNodeLanguage(n);
094: final String left = (String) dispatch(n.getNode(0));
095: final String operator = n.getString(1);
096: final String right = (String) dispatch(n.getNode(2));
097: if (language == DebuggerAstAnalyzer.Language.C) {
098: //TD gdb evaluate expression
099: } else {
100: //TD jdb evaluate expression
101: }
102: return null;
103: }
104:
105: /** Visit a Expression = Expression ("=" / "+=" / "-=" / "*=" / "/=" / "&=" / "|=" / "^=" / "%=" / "<<=" / ">>=" / ">>>=") Expression. */
106: public final void visitExpression(final GNode n) {
107: assert false : "not yet implemented";
108: }
109:
110: /** Visit ExpressionList = Expression+. */
111: public final void visitExpressionList(final GNode n) {
112: assert false : "not yet implemented";
113: }
114:
115: /** Visit a FunctionCall = Expression [ExpressionList]. */
116: public final void visitFunctionCall(final GNode n) {
117: assert false : "not yet implemented";
118: }
119:
120: /** Visit a GdbCommand = RestOfLine. */
121: public final void visitGdbCommand(final GNode n) {
122: String cmd = n.getString(0);
123: _dbg.debuggerCommand.executeGDBCommand(cmd);
124: }
125:
126: /** Visit a HelpCommand = (no children). */
127: public final void visitHelpCommand(final GNode n) {
128: _dbg.printCommandHelp();
129: }
130:
131: /** Visit an IndirectionExpression = Expression. */
132: public final void visitIndirectionExpression(final GNode n) {
133: assert false : "not yet implemented";
134: }
135:
136: /** Visit a InfoBreakCommand = (no children). */
137: public final void visitInfoBreakCommand(final GNode n) {
138: _dbg.debuggerCommand.executeInfoBreak();
139: }
140:
141: /** Visit a InfoWatchCommand = (no children). */
142: public final void visitInfoWatchCommand(final GNode n) {
143: _dbg.debuggerCommand.executeInfoWatch();
144: }
145:
146: /** Visit an InitJCommand = (no children). */
147: public final void visitInitJCommand(final GNode n) {
148: _dbg.preparingDebuggerSwitching();
149: }
150:
151: /** Visit an IntegerConstant = String. */
152: public final void visitIntegerConstant(final GNode n) {
153: assert false : "not yet implemented";
154: }
155:
156: /** Visit an IntegerLiteral = String. */
157: public final void visitIntegerLiteral(final GNode n) {
158: assert false : "not yet implemented";
159: }
160:
161: /** Visit a J2cCommand = (no children). */
162: public final void visitJ2cCommand(final GNode n) {
163: _dbg.j2n();
164: }
165:
166: /** Visit a JavaInCExpression = Java.UnaryExpression. */
167: public final void visitJavaInCExpression(final GNode n) {
168: assert false : "not yet implemented";
169: }
170:
171: /** Visit a JdbCommand = RestOfLine. */
172: public final void visitJdbCommand(final GNode n) {
173: String cmd = n.getString(0);
174: _dbg.debuggerCommand.executeJDBCommand(cmd);
175: }
176:
177: /** Visit a JRetCommand = (no children). */
178: public final void visitJRetCommand(final GNode n) {
179: _dbg.jret();
180: }
181:
182: /** Visit a ListCommand = (no children). */
183: public final void visitListCommand(final GNode n) {
184: _dbg.debuggerCommand.executeList();
185: }
186:
187: /** Visit a LocalsCommand = (no children). */
188: public final void visitLocalsCommand(final GNode n) {
189: _dbg.debuggerCommand.executeLocals();
190: }
191:
192: /** Visit a MetaVariable = Identifier. */
193: public final void visitMetaVariable(final GNode n) {
194: assert false : "not yet implemented";
195: }
196:
197: /** Visit a NextCommand = (no children). */
198: public final void visitNextCommand(final GNode n) {
199: _dbg.debuggerCommand.executeNext();
200: }
201:
202: /** Visit a NextCommand = (no children). */
203: public final void visitRunCommand(final GNode n) {
204: _dbg.run();
205: }
206:
207: /** Visit an StringLiteral = (no children). */
208: public final void visitNullLiteral(final GNode n) {
209: assert false : "not yet implemented";
210: }
211:
212: /** Visit a PrimaryIdentifier = String. */
213: public void visitPrimaryIdentifier(final GNode n) {
214: assert false : "not yet implemented";
215: }
216:
217: /** Visit a PrintCExpressionCommand = C.Expression. */
218: public final void visitPrintCExpressionCommand(final GNode n) {
219: _dbg.debuggerCommand.executePrint(n);
220: }
221:
222: /** Visit a PrintJavaExpressionCommand = Java.Expression. */
223: public final void visitPrintJavaExpressionCommand(final GNode n) {
224: _dbg.debuggerCommand.executePrint(n);
225: }
226:
227: /** Visit a QualifiedIdentifier = Identifier+. */
228: public final String visitQualifiedIdentifier(final GNode n) {
229: return Utilities.qualifiedIdentifierToString(n);
230: }
231:
232: /** Visit a SelectionExpression = Expression Identifier. */
233: public final void visitSelectionExpression(final GNode n) {
234: assert false : "not yet implemented";
235: }
236:
237: /** Visit a StatCommand = (no children). */
238: public final void visitStatCommand(final GNode n) {
239: _dbg.printStatus();
240: }
241:
242: /** Visit a StepCommand = (no children). */
243: public final void visitStepCommand(final GNode n) {
244: _dbg.debuggerCommand.executeStep();
245: }
246:
247: /** Visit an StringConstant = String. */
248: public final void visitStringConstant(final GNode n) {
249: assert false : "not yet implemented";
250: }
251:
252: /** Visit an StringLiteral = String. */
253: public final void visitStringLiteral(final GNode n) {
254: assert false : "not yet implemented";
255: }
256:
257: /** Visit a SubscriptExpression = Expression Expression. */
258: public final void visitSubscriptExpression(final GNode n) {
259: assert false : "not yet implemented";
260: }
261:
262: /** Visit a ThisExpression = [Expression]. */
263: public final void visitThisExpression(final GNode n) {
264: assert false : "not yet implemented";
265: }
266:
267: /** Visit an UpCommand = IntegerLiteral. */
268: public final void visitUpCommand(final GNode n) {
269: int steps = Integer.parseInt(n.getNode(0).getString(0));
270: _dbg.debuggerCommand.executeUp(steps);
271: }
272:
273: /** Visit a WatchCExpressionCommand = C.Expression. */
274: public final void visitWatchCExpressionCommand(final GNode n) {
275: assert false : "not yet implemented";
276: }
277:
278: /** Visit a WatchJavaFieldCommand = [WatchKind] QualifiedIdentifier. */
279: public final void visitWatchJavaFieldCommand(final GNode n) {
280: String accessType = n.getString(0);
281: String className = n.getNode(1).getString(0);
282: String fieldName = n.getNode(1).getString(1);
283: _dbg.debuggerCommand.executeWatch(accessType, className,
284: fieldName);
285: }
286:
287: /** Visit a WhereCommand = (no children). */
288: public final void visitWhereCommand(final GNode n) {
289: _dbg.debuggerCommand.executeWhere();
290: }
291: }
|