private String handleLocation(ILexLocation location) { if (location != null) { return location.getModule(); } else { return null; } } }
@Override public int compareTo(Renaming other) { if (loc.getModule() != null && other.loc.getModule() != null) { if (!loc.getModule().equals(other.loc.getModule())) { return other.loc.getModule().compareTo(loc.getModule()); } } ILexLocation otherLoc = other.getLoc(); return otherLoc.getStartOffset() - loc.getStartOffset(); } }
public String getName(PType type) { return type.getLocation().getModule(); } }
public LexNameToken getThreadName(ILexLocation loc) { LexNameToken thread = new LexNameToken(loc.getModule(), "thread", loc); thread.setTypeQualifier(new Vector<PType>()); return thread; }
public static boolean isValidModule(ILexLocation location) { return isNotNull(location) && isNotNull(location.getModule()); }
@Override public boolean equals(Object other) { if (other instanceof ILexLocation) { ILexLocation lother = (ILexLocation) other; return startPos == lother.getStartPos() && startLine == lother.getStartLine() && module.equals(lother.getModule()) && file.equals(lother.getFile()); } return false; }
@Override public String toString() { return "[Violation in module " + location.getModule() + ": '" + description + "'. Location: line " + location.getStartLine() + " at position: " + location.getStartPos() + " in " + location.getFile().getName() + "]"; }
public int compareLocations(ILexLocation firstLoc, ILexLocation secondLoc) { String firstModule = firstLoc.getModule(); String secondModule = secondLoc.getModule(); if (!firstModule.equals(secondModule)) { return firstModule.compareTo(secondModule); } int firstLine = firstLoc.getStartLine(); int secondLine = secondLoc.getStartLine(); if (firstLine == secondLine) { int firstPos = firstLoc.getStartPos(); int secondPos = secondLoc.getStartPos(); return firstPos - secondPos; } else { return firstLine - secondLine; } }
public static ASelfObjectDesignator newASelfObjectDesignator( ILexLocation location) { ASelfObjectDesignator result = new ASelfObjectDesignator(); result.setLocation(location); result.setSelf(new LexNameToken(location.getModule(), "self", location)); return result; }
public static ASelfExp newASelfExp(ILexLocation location) { ASelfExp result = new ASelfExp(); initExpression(result, location); result.setName(new LexNameToken(location.getModule(), "self", location)); return result; }
@Override public PDefinition caseAImportedDefinition(AImportedDefinition node, Newquestion question) throws AnalysisException { // We can only find an import if it is being sought from the module that // imports it. if (question.fromModule != null && !node.getLocation().getModule().equals(question.fromModule)) { return null; // Someone else's import } PDefinition def = af.createPDefinitionAssistant().findType(node.getDef(), question.sought, question.fromModule); if (def != null) { af.createPDefinitionAssistant().markUsed(node); } return def; }
public static void addSpan(LexNameToken name, LexToken upto) { LexLocation span = new LexLocation(name.location.getFile(), name.location.getModule(), name.location.getStartLine(), name.location.getStartPos(), upto.location.getEndLine(), upto.location.getEndPos(), upto.location.getStartOffset(), upto.location.getEndOffset()); nameSpans.put(name, span); }
public static void addSpan(LexNameToken name, LexToken upto) { LexLocation span = new LexLocation(name.location.getFile(), name.location.getModule(), name.location.getStartLine(), name.location.getStartPos(), upto.location.getEndLine(), upto.location.getEndPos(), upto.location.getStartOffset(), upto.location.getEndOffset()); nameSpans.put(name, span); }
/** * This first prints out the current breakpoint source location before calling the superclass' run method. The * synchronization prevents more than one debugging session on the console. * * @return the exit status */ public ExitStatus run() { synchronized (DebuggerReader.class) // Only one console! { println("Stopped " + breakpoint); println(interpreter.getSourceLine(breakpoint.location)); try { interpreter.setDefaultName(breakpoint.location.getModule()); } catch (Exception e) { throw new InternalException(52, "Cannot set default name at breakpoint"); } ExitStatus status = super.run(new Vector<File>()); return status; } }
@Override public LexNameSet caseARecordInvariantType(ARecordInvariantType node, FreeVarInfo info) throws AnalysisException { if (info.env.findType(node.getName(), node.getLocation().getModule()) == null) { // Invariant values covered in TCTypeDefinition return new LexNameSet(node.getName().getExplicit(true)); } else { return new LexNameSet(); } }
@Override public LexNameSet caseANamedInvariantType(ANamedInvariantType node, FreeVarInfo info) throws AnalysisException { if (info.env.findType(node.getName(), node.getLocation().getModule()) == null) { // Invariant values covered in TCTypeDefinition return new LexNameSet(node.getName().getExplicit(true)); } else { return new LexNameSet(); } }
@Override public PDefinition caseARenamedDefinition(ARenamedDefinition node, Newquestion question) throws AnalysisException { // We can only find an import if it is being sought from the module that // imports it. if (question.fromModule != null && !node.getLocation().getModule().equals(question.fromModule)) { return null; // Someone else's import } PDefinition renamed = af.createPDefinitionAssistant().findName(node, question.sought, NameScope.TYPENAME); if (renamed != null && node.getDef() instanceof ATypeDefinition) { af.createPDefinitionAssistant().markUsed(node.getDef()); return renamed; } else { return af.createPDefinitionAssistant().findType(node.getDef(), question.sought, question.fromModule); } }
public static AThreadDefinition newAThreadDefinition(PStm statement) { AThreadDefinition result = new AThreadDefinition(); // Definition initialization initDefinition(result, Pass.DEFS, statement.getLocation(), null, NameScope.GLOBAL); result.setStatement(statement); // used to be a static method on LexNameToken - removed when we went to // interface result.setOperationName(new LexNameToken(statement.getLocation().getModule(), "thread", statement.getLocation())); result.getOperationName().setTypeQualifier(new Vector<PType>()); result.setAccess(af.createPAccessSpecifierAssistant().getProtected()); return result; }