@Override public int compare(IrNodeInfo first, IrNodeInfo second) { INode vdmNode = getVdmNode(first); ILexLocation firstLoc = vdmNode == null ? null : findLocation(vdmNode); if (firstLoc == null) { return -1; } vdmNode = getVdmNode(second); ILexLocation secondLoc = vdmNode == null ? null : findLocation(vdmNode); if (secondLoc == null) { return 1; } return compareLocations(firstLoc, secondLoc); } });
public ILexLocation findLocation(IrNodeInfo info) { INode vdmNode = getVdmNode(info); if (vdmNode == null) { return null; } return findLocation(vdmNode); }
@Override public int compare(VdmNodeInfo first, VdmNodeInfo second) { ILexLocation firstLoc = findLocation(first.getNode()); if (firstLoc == null) { return -1; } ILexLocation secondLoc = findLocation(second.getNode()); if (secondLoc == null) { return 1; } return compareLocations(firstLoc, secondLoc); } });
LocationAssistantIR locationAssistant = assistantManager.getLocationAssistant(); List<IrNodeInfo> nodesSorted = locationAssistant.getIrNodeInfoLocationSorted(unsupportedNodes); INode vdmNode = locationAssistant.getVdmNode(nodeInfo); MsgPrinter.getPrinter().print(vdmNode != null ? vdmNode.toString() : nodeInfo.getNode().getClass().getSimpleName()); ILexLocation location = locationAssistant.findLocation(nodeInfo);
public static void printUnsupportedIrNodes( Set<VdmNodeInfo> unsupportedNodes) { AssistantManager assistantManager = new AssistantManager(); LocationAssistantIR locationAssistant = assistantManager.getLocationAssistant(); List<VdmNodeInfo> nodesSorted = locationAssistant.getVdmNodeInfoLocationSorted(unsupportedNodes); for (VdmNodeInfo vdmNodeInfo : nodesSorted) { MsgPrinter.getPrinter().print(vdmNodeInfo.getNode().toString() + " (" + vdmNodeInfo.getNode().getClass().getSimpleName() + ")"); ILexLocation location = locationAssistant.findLocation(vdmNodeInfo.getNode()); MsgPrinter.getPrinter().print(location != null ? " at [line, pos] = [" + location.getStartLine() + ", " + location.getStartPos() + "] in " + location.getFile().getName() : ""); String reason = vdmNodeInfo.getReason(); if (reason != null) { MsgPrinter.getPrinter().print(". Reason: " + reason); } MsgPrinter.getPrinter().println(""); } }
public STypeIR getElementType(STypeIR t) { STypeIR elementType; if (t instanceof ASetSetTypeIR) { elementType = ((ASetSetTypeIR) t).getSetOf().clone(); } else if (t instanceof ASeqSeqTypeIR) { elementType = ((ASeqSeqTypeIR) t).getSeqOf().clone(); } else { String vdmNodeInfo = info.getLocationAssistant().consVdmNodeInfoStr(t); log.error("Expected set or sequence type. Got: " + t.getClass().getName() + "." + vdmNodeInfo); elementType = new AUnknownTypeIR(); elementType.setSourceNode(t.getSourceNode()); } return elementType; }
public String consVdmNodeInfoStr(STypeIR t) { StringBuilder sb = new StringBuilder(); INode vdmNode = AssistantBase.getVdmNode(t); if(vdmNode != null) { sb.append("VDM node: " + vdmNode + "."); ILexLocation loc = findLocation(vdmNode); if(loc != null) { sb.append(" VDM node location: " + loc + "."); } } return sb.toString(); } }
@Override public int compareTo(Violation other) { return locationAssistant.compareLocations(this.location, other.location); } }
public AssistantManager() { this.nodeAssistant = new NodeAssistantIR(this); this.expAssistant = new ExpAssistantIR(this); this.declAssistant = new DeclAssistantIR(this); this.stmAssistant = new StmAssistantIR(this); this.typeAssistant = new TypeAssistantIR(this); this.locationAssistant = new LocationAssistantIR(this); this.bindAssistant = new BindAssistantIR(this); this.patternAssistant = new PatternAssistantIR(this); }
public String formatVdmSource(PIR irNode) { if (getJavaSettings().printVdmLocations() && irNode != null) { org.overture.ast.node.INode vdmNode = LocationAssistantIR.getVdmNode(irNode); if (vdmNode != null) { ILexLocation loc = info.getLocationAssistant().findLocation(vdmNode); if (loc != null) { return String.format("/* %s %d:%d */\n", loc.getFile().getName(), loc.getStartLine(), loc.getStartPos()); } } } return ""; }
public String formatElementType(STypeIR type) throws AnalysisException { if (type instanceof SSetTypeIR) { SSetTypeIR setType = (SSetTypeIR) type; return format(setType.getSetOf()); } else if (type instanceof SSeqTypeIR) { SSeqTypeIR seqType = (SSeqTypeIR) type; return format(seqType.getSeqOf()); } else if (type instanceof AStringTypeIR) { return format(new ACharBasicTypeIR()); } else { String vdmNodeInfo = info.getLocationAssistant().consVdmNodeInfoStr(type); log.error("Expected set, seq or string type when trying to format element type. Got: " + type + ". " + vdmNodeInfo); return format(new AUnknownTypeIR()); } }