001: package xtc.lang.jeannie;
002:
003: import xtc.lang.jeannie.DebuggerExpression.TargetSourceLanguage;
004:
005: public interface DebuggerSymbolMapper {
006: SourceFileAndLine getCurrentSourceFileAndLine();
007:
008: VariableRemapEntry lookUpVariableRemap(String variable,
009: String sourceFile, int sourceLineNumber);
010:
011: /**
012: * A source-level view of the current position. This is a
013: * <source file, source line> pair.
014: */
015: static class SourceFileAndLine {
016:
017: /**
018: * The source File.
019: */
020: private final String sourceFile;
021:
022: /**
023: * The source line.
024: */
025: private final int sourceLine;
026:
027: /**
028: * @param sourceFile The source file.
029: * @param sourceLine The source line.
030: */
031: SourceFileAndLine(String sourceFile, int sourceLine) {
032: this .sourceFile = sourceFile;
033: this .sourceLine = sourceLine;
034: }
035:
036: /**
037: * @return The source file.
038: */
039: public String getSourceFile() {
040: return sourceFile;
041: }
042:
043: /**
044: * @return The source line.
045: */
046: public int getSourceLine() {
047: return sourceLine;
048: }
049: }
050:
051: /**
052: * A source level variable entry.
053: */
054: static class VariableRemapEntry {
055:
056: /**
057: * Variable Remap for the Jeannie source-to-source transformation.
058: */
059: final int startLine;
060: final int startColumn;
061: final int endLine;
062: final int endColumn;
063: final TargetSourceLanguage targetLanguage;
064: final String sourceVariableName;
065: final String targetVariableName;
066:
067: /**
068: * @param startLine The start line in the target source file.
069: * @param startColumn The start column in the target source file.
070: * @param endLine The end line in the target source file.
071: * @param endColumn The end column in the target source file.
072: * @param targetLanguage The target language (C or Java).
073: * @param sourceVariableName The variable name in the source language.
074: * @param targetVariableName The variable name in the target language.
075: */
076: VariableRemapEntry(int startLine, int startColumn, int endLine,
077: int endColumn, TargetSourceLanguage targetLanguage,
078: String sourceVariableName, String targetVariableName) {
079: this .startLine = startLine;
080: this .startColumn = startColumn;
081: this .endLine = endLine;
082: this .endColumn = endColumn;
083: this .targetLanguage = targetLanguage;
084: this .sourceVariableName = sourceVariableName;
085: this .targetVariableName = targetVariableName;
086: }
087:
088: /**
089: * Generate the variable expression in the target language environment such
090: * that jdb or gdb can recognize the expression.
091: *
092: * @return jdb or gdb expression for the variable.
093: */
094: String targetLanguageExpression() {
095: StringBuffer sb = new StringBuffer();
096: switch (targetLanguage) {
097: case JAVA:
098: sb.append("jEnv.").append(targetVariableName);
099: break;
100: case C:
101: sb.append("cEnv.").append(targetVariableName);
102: break;
103: default:
104: assert false;
105: break;
106: }
107: return sb.toString();
108: }
109: }
110: }
|