inAModuleModules(node, question); if(node.getName() != null ) node.getName().apply(this, question); if(node.getImports() != null && !_visitedNodes.contains(node.getImports())) node.getImports().apply(this, question); if(node.getExports() != null && !_visitedNodes.contains(node.getExports())) node.getExports().apply(this, question); List<PDefinition> copy = new ArrayList<PDefinition>(node.getDefs()); for( PDefinition e : copy) List<PDefinition> copy = new ArrayList<PDefinition>(node.getImportdefs()); for( PDefinition e : copy) List<PDefinition> copy = new ArrayList<PDefinition>(node.getExportdefs()); for( PDefinition e : copy)
private Set<AModuleModules> getFlatModules() { Set<AModuleModules> flats = new HashSet<AModuleModules>(); for (AModuleModules m : this) { if (m.getIsFlat() && !(m instanceof CombinedDefaultModule)) { flats.add(m); } } return flats; }
/** * Generate the exportdefs list of definitions. The exports list of export declarations is processed by searching * the defs list of locally defined objects. The exportdefs field is populated with the result. * * @param m */ public void processExports(AModuleModules m) { if (m.getExports() != null) { m.getExportdefs().clear(); if (!m.getIsDLModule()) { m.getExportdefs().addAll(getDefinitions(m.getExports(), m.getDefs())); } else { m.getExportdefs().addAll(getDefinitions(m.getExports())); } } }
public void typeCheckExports(AModuleModules m) throws AnalysisException { if (m.getExports() != null && !m.getIsDLModule()) { af.createAModuleExportsAssistant().typeCheck(m.getExports(), new ModuleEnvironment(af, m)); } }
public AModuleModules findModule(List<AModuleModules> allModules, ILexIdentifierToken sought) { for (AModuleModules m : allModules) { if (m.getName().equals(sought)) { return m; } } return null; }
IRInfo question) throws AnalysisException String name = node.getName().getName(); AModuleImports imports = node.getImports(); AModuleExports exports = node.getExports(); Boolean isDlModule = node.getIsDLModule(); Boolean isFlat = node.getIsFlat(); moduleCg.setIsFlat(isFlat); for (PDefinition def : node.getDefs())
public List<PDefinition> getDefinitions() { return module.getDefs(); }
if (m1 != m2 && m1.getName().equals(m2.getName())) TypeChecker.report(3429, "Module " + m1.getName() + " duplicates " + m2.getName(), m1.getName().getLocation()); if (m1.getIsFlat()) TypeChecker.report(3308, "Cannot mix modules and flat specifications", m1.getName().getLocation()); if (!m1.getTypeChecked()) for (PDefinition definition : module.getDefs()) if (!m.getTypeChecked()) assistantFactory.createPDefinitionListAssistant().implicitDefinitions(m.getDefs(), env); if (!m.getTypeChecked()) if (!m.getTypeChecked()) for (PDefinition d : m.getImportdefs()) if (!m.getTypeChecked()) for (PDefinition d : m.getDefs()) if (!m.getTypeChecked())
@Override public PDefinition findType(ILexNameToken name, String fromModule) { PDefinition def = af.createPDefinitionAssistant().findType(module.getDefs(), name, module.getName().getName()); if (def != null) { return def; } def = af.createPDefinitionAssistant().findType(module.getImportdefs(), name, module.getName().getName()); if (def != null) { return def; } return null; // Modules are always bottom of the env chain }
@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; }
@Override public Set<PDefinition> findMatches(ILexNameToken name) { Set<PDefinition> defs = af.createPDefinitionListAssistant().findMatches(module.getDefs(), name); defs.addAll(af.createPDefinitionListAssistant().findMatches(module.getImportdefs(), name)); return defs; }
private void computeNamedTypeInvInfo(List<AModuleModules> ast) throws AnalysisException { NamedTypeInvDepCalculator depCalc = new NamedTypeInvDepCalculator(this.getJavaGen().getInfo()); for (AModuleModules m : ast) { if (!javaGen.getInfo().getDeclAssistant().isLibrary(m)) { m.apply(depCalc); } } this.typeInfoList = depCalc.getTypeDataList(); }
public void processImports(AModuleModules m, List<AModuleModules> allModules) { if (m.getImports() != null) { List<PDefinition> updated = af.createAModuleImportsAssistant().getDefinitions(m.getImports(), allModules); D: for (PDefinition u : updated) { for (PDefinition tc : m.getImportdefs()) { if (tc.getName() != null && u.getName() != null && tc.getName().matches(u.getName())) { u.setUsed(tc.getUsed()); // Copy usage from TC phase continue D; } } } m.getImportdefs().clear(); m.getImportdefs().addAll(updated); } }
public void typeCheckImports(AModuleModules m) throws AnalysisException { if (m.getImports() != null) { af.createAModuleImportsAssistant().typeCheck(m.getImports(), new ModuleEnvironment(af, m)); } }
@Override public List<PDefinition> caseAAllImport(AAllImport imp, AModuleModules module) throws AnalysisException { // return AAllImportAssistantTC.getDefinitions(imp,from); imp.setFrom(module); if (imp.getFrom().getExportdefs().isEmpty()) { TypeCheckerErrors.report(3190, "Import all from module with no exports?", imp.getLocation(), imp); } List<PDefinition> imported = new Vector<PDefinition>(); for (PDefinition d : imp.getFrom().getExportdefs()) { PDefinition id = AstFactory.newAImportedDefinition(imp.getLocation(), d); af.createPDefinitionAssistant().markUsed(id); // So imports all is quiet imported.add(id); } return imported; // The lot! }
public AModuleModules findModule(LexIdentifierToken sought) { for (AModuleModules m : this) { if (m.getName().equals(sought)) { return m; } } return null; }
@Override public LinkedList<PDefinition> getDefs() { LinkedList<PDefinition> definitions = new LinkedList<PDefinition>(); for (AModuleModules m : modules) { definitions.addAll(m.getDefs()); } return definitions; }