@Override public Collection<? extends PDefinition> caseAFunctionExport( AFunctionExport exp, LinkedList<PDefinition> actualDefs) throws AnalysisException { List<PDefinition> list = new Vector<PDefinition>(); for (ILexNameToken name : exp.getNameList()) { PDefinition def = af.createPDefinitionListAssistant().findName(actualDefs, name, NameScope.NAMES); if (def != null) { list.add(def); } } return list; }
@Override public Collection<? extends PDefinition> caseAOperationExport( AOperationExport exp, LinkedList<PDefinition> actualDefs) throws AnalysisException { List<PDefinition> list = new Vector<PDefinition>(); for (ILexNameToken name : ((AOperationExport) exp).getNameList()) { PDefinition def = af.createPDefinitionListAssistant().findName(actualDefs, name, NameScope.NAMES); if (def != null) { list.add(def); } } return list; }
@Override public PDefinition caseAValueDefinition(AValueDefinition node, Newquestion question) throws AnalysisException { return af.createPDefinitionListAssistant().findName(node.getDefs(), question.sought, question.scope); }
@Override public PDefinition caseAEqualsDefinition(AEqualsDefinition node, Newquestion question) throws AnalysisException { List<PDefinition> defs = node.getDefs(); if (defs != null) { PDefinition def = af.createPDefinitionListAssistant().findName(defs, question.sought, question.scope); if (def != null) { return def; } } return null; }
@Override public PDefinition findName(ILexNameToken name, NameScope scope) { PDefinition def = af.createPDefinitionListAssistant().findName(module.getDefs(), name, scope); if (def != null && !ExcludedDefinitions.isExcluded(def)) { return def; } def = af.createPDefinitionListAssistant().findName(module.getImportdefs(), name, scope); if (def != null) { return def; } return null; // Modules are always bottom of the env chain }
@Override public PDefinition caseAMultiBindListDefinition( AMultiBindListDefinition node, Newquestion question) throws AnalysisException { if (node.getDefs() != null) { PDefinition def = af.createPDefinitionListAssistant().findName(node.getDefs(), question.sought, question.scope); if (def != null) { return def; } } return null; }
@Override public PDefinition findName(ILexNameToken name, NameScope scope) { PDefinition def = af.createPDefinitionListAssistant().findName(definitions, name, scope); if (def != null && !ExcludedDefinitions.isExcluded(def)) { return def; } if (outer == null) { return null; } else { if (limitStateScope) { scope = NameScope.NAMES; // Limit NAMESAND(ANY)STATE } return outer.findName(name, scope); } }
@Override public Collection<? extends PDefinition> caseAValueExport(AValueExport exp, LinkedList<PDefinition> actualDefs) throws AnalysisException { List<PDefinition> list = new Vector<PDefinition>(); for (ILexNameToken name : exp.getNameList()) { PDefinition def = af.createPDefinitionListAssistant().findName(actualDefs, name, NameScope.NAMES); PType type = exp.getExportType().clone(); if (def != null) { if (def instanceof AUntypedDefinition) { AUntypedDefinition untyped = (AUntypedDefinition) def; list.add(AstFactory.newALocalDefinition(untyped.getLocation(), untyped.getName(), NameScope.GLOBAL, type)); // new ALocalDefinition(untyped.getLocation(), NameScope.GLOBAL, // false,null,PAccessSpecifierAssistant.getDefault(),type, false,untyped.getName())); } else { list.add(def); } } } return list; }
private void setInheritedDefinitions(SClassDefinition definition) { List<PDefinition> indefs = new Vector<PDefinition>(); for (SClassDefinition sclass : definition.getSuperDefs()) { indefs.addAll(getInheritable(sclass)); } // The inherited definitions are ordered such that the // definitions, taken in order, will consider the overriding // members before others. List<PDefinition> superInheritedDefinitions = new Vector<PDefinition>(); for (PDefinition d : indefs) { superInheritedDefinitions.add(d); ILexNameToken localname = d.getName().getModifiedName(definition.getName().getName()); if (af.createPDefinitionListAssistant().findName(definition.getDefinitions(), localname, NameScope.NAMESANDSTATE) == null || af.createPDefinitionAssistant().isSubclassResponsibility(d)) { AInheritedDefinition local = AstFactory.newAInheritedDefinition(localname, d); definition.getLocalInheritedDefinitions().add(local); } } definition.setSuperInheritedDefinitions(superInheritedDefinitions); definition.setAllInheritedDefinitions(new Vector<PDefinition>()); definition.getAllInheritedDefinitions().addAll(superInheritedDefinitions); definition.getAllInheritedDefinitions().addAll(definition.getLocalInheritedDefinitions()); }
@Override public List<PDefinition> defaultSValueImport(SValueImport imp, AModuleModules module) throws AnalysisException { List<PDefinition> list = new Vector<PDefinition>(); imp.setFrom(module); ILexNameToken name = imp.getName(); PDefinition expdef = af.createPDefinitionListAssistant().findName(module.getExportdefs(), name, NameScope.NAMES); if (expdef == null) { TypeCheckerErrors.report(3193, "No export declared for import of value " + name + " from " + module.getName(), imp.getLocation(), imp); } else { if (imp.getRenamed() != null) { expdef = AstFactory.newARenamedDefinition(imp.getRenamed(), expdef); } else { expdef = AstFactory.newAImportedDefinition(imp.getLocation(), expdef); } list.add(expdef); } return list; }
if (af.createPDefinitionListAssistant().findName(defs, localname, NameScope.NAMESANDSTATE) == null)
public PType caseAOperationExport(AOperationExport exp, TypeCheckInfo question) throws AnalysisException { ITypeCheckerAssistantFactory af = question.assistantFactory; ModuleEnvironment menv = (ModuleEnvironment)question.env; for (ILexNameToken name : exp.getNameList()) { PDefinition def = af.createPDefinitionListAssistant().findName(menv.getDefinitions(), name, NameScope.NAMES); if (def == null) { TypeCheckerErrors.report(3185, "Exported operation " + name + " not defined in module", name.getLocation(), exp); } else { PType act = def.getType(); PType type = question.assistantFactory.createPTypeAssistant().typeResolve(exp.getExportType(), null, THIS, question); exp.setExportType(type); if (act != null && !af.createPTypeAssistant().equals(act, type)) { TypeCheckerErrors.report(3186, "Exported operation type does not match actual type", name.getLocation(), exp); TypeCheckerErrors.detail2("Exported", type, "Actual", act); } } } return null; }
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()); } } } } } }
PDefinition def = af.createPDefinitionListAssistant().findName(menv.getDefinitions(), name, NameScope.NAMES);
expdef = question.assistantFactory.createPDefinitionListAssistant().findName(node.getFrom().getExportdefs(), node.getName(), NameScope.NAMES);
expdef = question.assistantFactory.createPDefinitionListAssistant().findName(node.getFrom().getExportdefs(), node.getName(), NameScope.NAMES);
PDefinition override = af.createPDefinitionListAssistant().findName(c.getDefinitions(), localName, NameScope.NAMESANDSTATE);
PDefinition def = af.createPDefinitionListAssistant().findName(menv.getDefinitions(), name, NameScope.NAMES);