@Override public ILexLocation defaultPDefinition(PDefinition node) throws AnalysisException { return node.getLocation(); }
@Override public void caseAIdentifierStateDesignator(AIdentifierStateDesignator node) throws AnalysisException { PDefinition def = idDefs.get(node); if (def == null) { log.error("Could not find definition for " + node); } else { if (def.getLocation().equals(defLoc)) { this.idOccurences.add(node); } } } }
@Override public void caseAVariableExp(AVariableExp node) throws AnalysisException { if (node.getVardef() == null) { return; } if (node.getVardef().getLocation().equals(defLoc)) { varOccurences.add(node); } } }
@SuppressWarnings("deprecation") public CombinedDefaultModule(Set<AModuleModules> modules) { super(null, null, null, new Vector<PDefinition>(), new Vector<ClonableFile>(), true, false); this.modules.addAll(modules); if (getDefs().isEmpty()) { setName(new LexIdentifierToken("DEFAULT", false, new LexLocation())); } else { setName(new LexIdentifierToken("DEFAULT", false, getDefs().get(0).getLocation())); } }
public UniqueNameGenerator(INode node) { if (node instanceof PExp) { location = ((PExp) node).getLocation(); module = handleLocation(location); } else if (node instanceof PDefinition) { location = ((PDefinition) node).getLocation(); module = handleLocation(location); } else { location = null; module = null; } }
public void typeCheck(List<PDefinition> defs, IQuestionAnswer<TypeCheckInfo, PType> rootVisitor, TypeCheckInfo question) throws AnalysisException { for (PDefinition d : defs) { if (d.getName() != null && d.getName().getName().equals("RESULT")) { TypeCheckerErrors.report(3336, "Illegal use of RESULT reserved identifier", d.getLocation(), d); } d.apply(rootVisitor, question); } }
private AExplicitOperationDefinition getInvDefinition(SClassDefinition d) { List<PDefinition> invdefs = getInvDefs(d); if (invdefs.isEmpty()) { return null; } // Location of last local invariant ILexLocation invloc = invdefs.get(invdefs.size() - 1).getLocation(); AOperationType type = AstFactory.newAOperationType(invloc, new Vector<PType>(), AstFactory.newABooleanBasicType(invloc)); type.setPure(true); LexNameToken invname = new LexNameToken(d.getName().getName(), "inv_" + d.getName().getName(), invloc); PStm body = AstFactory.newAClassInvariantStm(invname, invdefs); return AstFactory.newAExplicitOperationDefinition(invname, type, new Vector<PPattern>(), null, null, body); }
public void unusedCheckBaseCase(PDefinition d) { if (!af.createPDefinitionAssistant().isUsed(d)) { TypeCheckerErrors.warning(5000, "Definition '" + d.getName() + "' not used", d.getLocation(), d); markUsed(d); // To avoid multiple warnings } }
if (!def.getLocation().equals(found.getLocation()) && af.createPDefinitionAssistant().isFunctionOrOperation(def)) TypeCheckerErrors.detail2("1", def.getLocation(), "2", found.getLocation()); break; !def.getLocation().equals(indef.getLocation()) && !af.createPDefinitionAssistant().hasSupertype(def.getClassDefinition(), indef.getClassDefinition().getType()) && af.createPDefinitionAssistant().isFunctionOrOperation(def)) + question.sought + " is multiply defined in class", question.sought.getLocation(), question.sought); TypeCheckerErrors.detail2("1", def.getLocation(), "2", indef.getLocation()); break;
private void checkAmbiguities(SClassDefinition c, List<PDefinition> defs, List<PDefinition> defs2) { for (PDefinition indef : defs) { ILexNameToken localName = indef.getName().getModifiedName(c.getName().getName()); for (PDefinition indef2 : defs2) { if (!indef.getLocation().equals(indef2.getLocation()) && af.createPDefinitionAssistant().kind(indef).equals(af.createPDefinitionAssistant().kind(indef2))) { ILexNameToken localName2 = indef2.getName().getModifiedName(c.getName().getName()); if (af.getLexNameTokenAssistant().isEqual(localName, localName2)) { PDefinition override = af.createPDefinitionListAssistant().findName(c.getDefinitions(), localName, NameScope.NAMESANDSTATE); if (override == null) // OK if we override the ambiguity { TypeCheckerErrors.report(3276, "Ambiguous definitions inherited by " + c.getName().getName(), c.getLocation(), c); TypeCheckerErrors.detail("1", indef.getName() + " " + indef.getLocation()); TypeCheckerErrors.detail("2", indef2.getName() + " " + indef2.getLocation()); } } } } } }
if (def != null && !def.getLocation().equals(n1.getLocation()) && def.getNameScope().matches(scope)) if (def.getLocation().getFile().equals(n1.getLocation().getFile())) + def.getLocation().toShortString() + " hidden by " + n1.getFullName(); } else message = def.getName() + " " + def.getLocation() + " hidden by " + n1.getFullName();
/** * Check a DefinitionList for incompatible duplicate pattern definitions. * * @param d * @param defs * @return */ public List<PDefinition> checkDuplicatePatterns(PDefinition d, List<PDefinition> defs) { Set<PDefinition> noDuplicates = new HashSet<PDefinition>(); for (PDefinition d1 : defs) { for (PDefinition d2 : defs) { if (d1 != d2 && d1.getName() != null && d2.getName() != null && d1.getName().equals(d2.getName())) { if (!af.getTypeComparator().compatible(d1.getType(), d2.getType())) { TypeCheckerErrors.report(3322, "Duplicate patterns bind to different types", d.getLocation(), d); TypeCheckerErrors.detail2(d1.getName().getName(), d1.getType(), d2.getName().getName(), d2.getType()); } } } noDuplicates.add(d1); } return new Vector<PDefinition>(noDuplicates); }
} else result.setName(defaultName(definitions.get(0).getLocation()));
public static AExternalDefinition newAExternalDefinition(PDefinition state, ILexToken mode) { AExternalDefinition result = new AExternalDefinition(); initDefinition(result, Pass.DEFS, state.getLocation(), state.getName(), NameScope.STATE); result.setState(state); result.setReadOnly(mode.is(VDMToken.READ)); result.setOldname(result.getReadOnly() ? null : state.getName().getOldName()); return result; }
private void findRenamings(PDefinition localDefToRename, INode parentNode, INode defScope) throws AnalysisException { ILexNameToken localDefName = getName(localDefToRename); if (localDefName == null) { return; } String newName = computeNewName(localDefName.getName()); if (!contains(localDefName.getLocation())) { registerRenaming(localDefName, newName); } Set<AVariableExp> vars = collectVarOccurences(localDefToRename.getLocation(), defScope); for (AVariableExp varExp : vars) { registerRenaming(varExp.getName(), newName); } Set<AIdentifierStateDesignator> idStateDesignators = collectIdDesignatorOccurrences(localDefToRename.getLocation(), defScope); for (AIdentifierStateDesignator id : idStateDesignators) { registerRenaming(id.getName(), newName); } Set<AIdentifierPattern> idPatterns = collectIdOccurences(localDefName, parentNode); for (AIdentifierPattern id : idPatterns) { registerRenaming(id.getName(), newName); } }
+ def1.getName().getName(), def1.getLocation(), def1); TypeCheckerErrors.detail2(def1.getName().getName(), def1.getType(), def2.getName().getName(), def2.getType()); done.add(def1.getName().getName()); TypeCheckerErrors.detail2(def1.getName().getName(), def1.getLocation().getFile().getName() + " " + def1.getLocation().toShortString(), def2.getName().getName(), def2.getLocation().getFile().getName() + " " + def2.getLocation().toShortString()); done.add(def1.getName().getName());
public static AInheritedDefinition newAInheritedDefinition( ILexNameToken localname, PDefinition d) { AInheritedDefinition result = new AInheritedDefinition(); initDefinition(result, d.getPass(), d.getLocation(), localname, d.getNameScope()); result.setSuperdef(d); result.setOldname(localname.getOldName()); result.setType(d.getType()); af.createPDefinitionAssistant().setClassDefinition(result, d.getClassDefinition()); result.setAccess(d.getAccess().clone()); return result; }
+ def.getName().getName() + " at " + def.getLocation());
+ override.getName().getName(), override.getLocation(), override); TypeCheckerErrors.detail2("This", override.getType(), "Super", indef.getType());
TypeChecker.detail2(composeType.getName().getName(), composeType.getLocation(), existing.getName().getName(), existing.getLocation());