Commit 361f63df authored by Johannes Roith's avatar Johannes Roith
Browse files

Should hopefully find the required mappings, given a list of line numbers.

parent 7468ae5a
package de.in.tum.www2.cup.analysis;
import java.util.ArrayList;
import java.util.List;
import de.in.tum.www2.cup.Position;
......@@ -8,8 +9,32 @@ import de.in.tum.www2.cup.ast.*;
public class GetDebuggerMappingVisitor extends Visitor<Object>
{
class Mapping {
public int caseIndex;
public static class Mapping {
private int debugId;
private int lineOffsetFromId;
/**
*
* @return
*/
public int getDebugId() {
return debugId;
}
/**
*
* @return
*/
public int getLineOffsetFromId() {
return lineOffsetFromId;
}
Mapping(int debugId, int lineOffsetFromId) {
this.debugId = debugId;
this.lineOffsetFromId = lineOffsetFromId;
}
}
private int[] lines;
......@@ -21,10 +46,33 @@ public class GetDebuggerMappingVisitor extends Visitor<Object>
public GetDebuggerMappingVisitor(int[] lines) {
this.lines = lines;
this.mappings = new ArrayList<Mapping>();
}
// TODO: - find matching action block.
// - get parent (ProductionRight) node
// - return case label hint.
private void doCheck(ActionCodeBlock node) {
if (node == null)
return;
Range range = node.getRange();
if (range != null) {
for (int line : lines) {
if (line >= node.getBegin().getLine() &&
line >= node.getEnd().getLine())
{
int lineOffset = line - node.getBegin().getLine();
mappings.add(new Mapping(node.getDebugId(), lineOffset));
}
}
}
}
@Override
public void postVisit (ActionCodeBlock node, Object data) {
doCheck(node);
}
@Override
public void postVisit (SpecialCodeBlock node, Object data) {
// doCheck(node);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment