Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ModuleTypeInfo


     *
     * @param enumName enumeration name
     * @return true if specified enumeration exists; false if not
     */
    private boolean retrieveEnumerationValues(String enumName) {
        ModuleTypeInfo workingModuleTypeInfo = perspective.getWorkingModuleTypeInfo();
       
        TypeConstructor typeCons = workingModuleTypeInfo.getTypeConstructor(enumName);
       
        if (typeCons != null) {
            ((DefaultListModel)enumListControl.getModel()).clear();
           
            if(typeCons.getScope() == Scope.PUBLIC) {
                publicButton.doClick();
            } else {
                privateButton.doClick();
            }
           
            int constructors = typeCons.getNDataConstructors();
            for (int i = 0; i < constructors; i++) {
                QualifiedName constructorName = typeCons.getNthDataConstructor(i).getName();
                ((DefaultListModel)enumListControl.getModel()).addElement(constructorName.getUnqualifiedName());
            }
           
            // We need to determine whether the existing enumeration has only a derived Eq instance,
            // or the full complement of derived instances (i.e. Eq, Ord, Bounded, Enum), so that
            // the correct selection can be shown in the derived instances combo box.
           
            TypeClass ordTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Ord);
            ClassInstance ordInstance = workingModuleTypeInfo.getVisibleClassInstance(ordTypeClass, typeCons);
           
            TypeClass boundedTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Bounded);
            ClassInstance boundedInstance = workingModuleTypeInfo.getVisibleClassInstance(boundedTypeClass, typeCons);
           
            TypeClass enumTypeClass = workingModuleTypeInfo.getVisibleTypeClass(CAL_Prelude.TypeClasses.Enum);
            ClassInstance enumInstance = workingModuleTypeInfo.getVisibleClassInstance(enumTypeClass, typeCons);
           
            if (ordInstance == null && boundedInstance == null && enumInstance == null) {
                getDerivedInstancesField().setSelectedItem(DerivedInstancesOption.EQ_ONLY_DERIVED_INSTANCES_OPTION);
            } else {
                getDerivedInstancesField().setSelectedItem(DerivedInstancesOption.EQ_ORD_BOUNDED_ENUM_DERIVED_INSTANCES_OPTION);               
View Full Code Here


                        cachedTypes[i] = cachedVN.getTypeExpr();
                    }                                                   
                }
               
                try {
                    ModuleTypeInfo contextModuleTypeInfo = gemCutter.getPerspective().getWorkingModuleTypeInfo();                                            
                    specializedInputTypes = TypeExpr.patternMatchPieces(cachedTypes, inputTypes, contextModuleTypeInfo);
                } catch (TypeException te) {
                    throw new IllegalStateException("Error reusing cached args.");
                }                           
            } else {
View Full Code Here

                if (cachedVN != null) {
                    typesFromCachedArgs[i] = cachedVN.getTypeExpr();
                }                                  
            }
           
            ModuleTypeInfo contextModuleTypeInfo = gemCutter.getPerspective().getWorkingModuleTypeInfo();
           
            return TypeExpr.canPatternMatchPieces(typesFromCachedArgs, targetPieces, contextModuleTypeInfo);           
        }
View Full Code Here

     * @param mti
     * @param moduleNames (Set of String) the set module names which will be populated.
     */
    private static void buildDependeeModuleNameSet (ModuleTypeInfo mti, Set<ModuleName> moduleNames) {
        for (int i = 0; i < mti.getNImportedModules(); ++i) {
            ModuleTypeInfo importedModule = mti.getNthImportedModule(i);

            // Check whether this module has already been traversed..
            if (moduleNames.add(importedModule.getModuleName())) {
                buildDependeeModuleNameSet (importedModule, moduleNames);
            }
        }
    }
View Full Code Here

                    changedModules.put (moduleName, new Long(timeStamp));
                    generateAll = true;

                } else {
                    // Check imported modules.
                    ModuleTypeInfo mti = module.getModuleTypeInfo();
                    for (int i = 0; i < mti.getNImportedModules(); ++i) {
                        ModuleTypeInfo imti = mti.getNthImportedModule(i);
                        Long l = changedModules.get(imti.getModuleName());
                        if (l != null && l.longValue() > timeStamp) {
                            generateAll = true;
                            break;
                        }
                    }
View Full Code Here

        }
        moduleSet.add((LECCModule)currentModuleTypeInfo.getModule());
       
        // Call recursively on imported modules.
        for (int i = 0; i < currentModuleTypeInfo.getNImportedModules(); ++i) {
            ModuleTypeInfo importedModuleTypeInfo = currentModuleTypeInfo.getNthImportedModule(i);
            buildDependeeModuleSet (importedModuleTypeInfo, moduleNames, moduleSet);
        }
    }
View Full Code Here

             * Returns a list of the names of the gems which have the specified return type and no inputs.
             */
            private List <String> fetchGemsOfType(final TypeExpr returnTypeExpr) {
                GemViewer gemViewer = new GemViewer();
               
                final ModuleTypeInfo moduleTypeInfo = perspective.getWorkingModuleTypeInfo();

                // Create a filter which will find all gems which return the specified type
                // and take no inputs.
                // TODO: add support for gems which do take inputs...
                GemFilter filter = new GemFilter() {
View Full Code Here

       
        if (metaModule == null) {
            return null;
        }
       
        ModuleTypeInfo moduleInfo = metaModule.getTypeInfo();
        CALFeatureName.FeatureType type = featureName.getType();
       
        if (type == CALFeatureName.FUNCTION) {
            return moduleInfo.getFunctionalAgent(name.getUnqualifiedName());
           
        } else if (type == CALFeatureName.TYPE_CONSTRUCTOR) {
            return moduleInfo.getTypeConstructor(name.getUnqualifiedName());
           
        } else if (type == CALFeatureName.TYPE_CLASS) {
            return moduleInfo.getTypeClass(name.getUnqualifiedName());
           
        } else if (type == CALFeatureName.DATA_CONSTRUCTOR) {
            return moduleInfo.getDataConstructor(name.getUnqualifiedName());
           
        } else if (type == CALFeatureName.CLASS_METHOD) {
            return moduleInfo.getClassMethod(name.getUnqualifiedName());
        }
       
        throw new IllegalArgumentException("feature type is not a for a scoped entity: " + type);
    }
View Full Code Here

         * Add all the dependencies for module moduleName to importedModuleSet.
         * @param moduleName name of module
         */
        private void findModuleDependencies(ModuleName moduleName) {
            MetaModule metaModule = workspace.getMetaModule(moduleName);
            ModuleTypeInfo moduleTypeInfo = metaModule.getTypeInfo();
           
            for(int i = 0, nImports = moduleTypeInfo.getNImportedModules(); i < nImports; i++) {
                ModuleTypeInfo importedModule = moduleTypeInfo.getNthImportedModule(i);
                ModuleName importedModuleName = importedModule.getModuleName();
                if(rootModuleSet.contains(importedModuleName) || importedModuleSet.contains(importedModuleName)) {
                    continue;
                }
                importedModuleSet.add(importedModuleName);
                findModuleDependencies(importedModuleName);
View Full Code Here

                }
               

                public String getTypeString(final TypeExpr typeExpr) {
                    final ScopedEntityNamingPolicy namingPolicy;
                    final ModuleTypeInfo currentModuleTypeInfo = tableTop.getCurrentModuleTypeInfo();
                    if (currentModuleTypeInfo == null) {
                        namingPolicy = ScopedEntityNamingPolicy.FULLY_QUALIFIED;
                    } else {
                        namingPolicy = new ScopedEntityNamingPolicy.UnqualifiedUnlessAmbiguous(currentModuleTypeInfo);
                    }
View Full Code Here

TOP

Related Classes of org.openquark.cal.compiler.ModuleTypeInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.