Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.TypeConstructor


             */
            int nModuleTypeConstructors = moduleTypeInfo.getNTypeConstructors();
            totalTypeConstructors += nModuleTypeConstructors;
           
            for (int i = 0; i < nModuleTypeConstructors; i++) {
                TypeConstructor nthTypeConstructor = moduleTypeInfo.getNthTypeConstructor(i);
                int nDataConstructorsInType = nthTypeConstructor.getNDataConstructors();
                totalDataConstructors += nDataConstructorsInType;
               
                if (nthTypeConstructor.getForeignTypeInfo() != null) {
                    totalForeignTypes++;
                }
               
                typeConstructorNameSet.add(nthTypeConstructor.getName());
            }
           
            /*
             * Type classes and class methods
             */
 
View Full Code Here


                labels.add(labelMaker.getLabel(function));
            }
        }
       
        for (int i = 0, n = moduleInfo.getNTypeConstructors(); i < n; i++) {
            TypeConstructor typeCons = moduleInfo.getNthTypeConstructor(i);
           
            if (parent.isDocForTypeConsGenerated(typeCons.getName().getModuleName(), typeCons.getName().getUnqualifiedName())) {
                labels.add(labelMaker.getLabel(typeCons));
               
                for (int j = 0, m = typeCons.getNDataConstructors(); j < m; j++) {
                    DataConstructor dataCons = typeCons.getNthDataConstructor(j);
                    if (parent.isDocForDataConsGenerated(dataCons.getName().getModuleName(), dataCons.getName().getUnqualifiedName())) {
                        labels.add(labelMaker.getLabel(dataCons));
                    }
                }
            }
View Full Code Here

                    ModuleTypeInfo typeInfo = workspaceManager.getModuleTypeInfo(moduleName);
                    if (typeInfo == null) {
                        iceLogger.log(Level.INFO, "The module " + moduleName + " does not exist.");
                    } else {
                        String typeName = qualifiedTypeName.getUnqualifiedName();
                        TypeConstructor typeCons = typeInfo.getTypeConstructor(typeName);
                        if (typeCons == null) {
                            iceLogger.log(Level.INFO, "The type constructor " + qualifiedTypeName + " does not exist.");
                        } else {
                            CALDocComment comment = typeCons.getCALDocComment();
                            if (comment != null) {
                                iceLogger.log(Level.INFO, "CALDoc for the " + qualifiedTypeName + " type constructor:\n" + CALDocToTextUtilities.getTextFromCALDocComment(comment));
                            } else {
                                iceLogger.log(Level.INFO, "There is no CALDoc for the " + qualifiedTypeName + " type constructor.");
                            }
View Full Code Here

                    ModuleTypeInfo typeInfo = workspaceManager.getModuleTypeInfo(moduleName);
                    if (typeInfo == null) {
                        iceLogger.log(Level.INFO, "The module " + moduleName + " does not exist.");
                    } else {
                        String typeName = qualifiedTypeName.getUnqualifiedName();
                        TypeConstructor typeCons = typeInfo.getTypeConstructor(typeName);
                        if (typeCons == null) {
                            iceLogger.log(Level.INFO, "The type constructor " + qualifiedTypeName + " does not exist.");
                        } else if (typeCons.getNDataConstructors() == 0) {
                            iceLogger.log(Level.INFO, "The type " + typeCons.getName() + " is not an algebraic type.");
                        } else {
                           
                            SourceModel.TopLevelSourceElement[] decls =
                                DerivedInstanceFunctionGenerator.makeAlgebraicTypeInstanceFunctions(
                                    typeInfo, typeCons, compact, workspaceManager.getModuleTypeInfo(CAL_Debug.MODULE_NAME));
                           
                            for (final SourceModel.TopLevelSourceElement element : decls) {
                                // remove any unnecessary qualifications based on the visibility rules of the module
                                // where the type is defined
                                SourceModel.SourceElement decl =
                                    SourceModelUtilities.UnnecessaryQualificationRemover.removeUnnecessaryQualifications(typeInfo, element);
                               
                                // separate the instances with comments
                                if (decl instanceof SourceModel.InstanceDefn) {
                                    SourceModel.InstanceDefn instanceDefn = (SourceModel.InstanceDefn)decl;
                                    System.out.println("/**");
                                    System.out.println(" * {@code " + instanceDefn.getTypeClassName().getUnqualifiedName() + "@} instance for {@code " + typeCons.getName().getUnqualifiedName() + "@}.");
                                    System.out.println(" */");
                                }
                               
                                System.out.println(decl.toSourceText());
                               
View Full Code Here

                int nImports = moduleTypeInfo.getNImportedModules();
               
                // Iterate over the type constructors in the module.
                int nTypeConstructors = moduleTypeInfo.getNTypeConstructors();
                for (int j = 0; j < nTypeConstructors; j++) {
                    TypeConstructor typeCons = moduleTypeInfo.getNthTypeConstructor(j);
                   
                    QualifiedName calName = typeCons.getName();
                    
                    //Prelude.Unit and Prelude.Boolean are special cases in that they are algebraic types that however correspond
                    //to foreign types for the purposes of declaring foreign functions.
                   
                    if (calName.equals(CAL_Prelude.TypeConstructors.Unit)) {
                        classToTypeConsNameMap.put(void.class, calName);
                        continue;
                    }
                    if (calName.equals(CAL_Prelude.TypeConstructors.Boolean)) {
                        classToTypeConsNameMap.put(boolean.class, calName);
                        continue;
                    }
                   
                    // Check if the type is foreign.
                    ForeignTypeInfo fti = typeCons.getForeignTypeInfo();
                   
                    if (fti != null && fti.getImplementationVisibility() == Scope.PUBLIC) {
                        Class<?> foreignType = fti.getForeignType();
                       
                        // In cases where a single class maps to multiple type constructors,
View Full Code Here

     * no visible data constructors.
     */
    public DataConstructor[] getDataConstructorsForType(QualifiedName typeConstructorName) {

        ModuleTypeInfo currentModuleTypeInfo = module.getModuleTypeInfo();
        TypeConstructor typeCons = currentModuleTypeInfo.getVisibleTypeConstructor(typeConstructorName);

        if (typeCons == null) {
            return null;
        }
       
        List<DataConstructor> dataConsList = new ArrayList<DataConstructor>();
                      
        for (int n = 0, numDataCons = typeCons.getNDataConstructors(); n < numDataCons; n++) {
           
            DataConstructor dataCons = typeCons.getNthDataConstructor(n);
           
            if (currentModuleTypeInfo.isEntityVisible(dataCons)) {
                dataConsList.add(dataCons);
            }
        }
View Full Code Here

           
            ModuleTypeInfo importedInfo = moduleTypeInfo.getNthImportedModule(n);

            for (int c = 0, numTypes = importedInfo.getNTypeConstructors(); c < numTypes; c++) {
               
                TypeConstructor typeCons = importedInfo.getNthTypeConstructor(c);
               
                if (moduleTypeInfo.isEntityVisible(typeCons)) {
                    types.add(typeCons);
                }
            }
View Full Code Here

     * False otherwise.
     */
    public boolean isEnumDataType(QualifiedName typeConstructorName) {
              
        ModuleTypeInfo currentModuleTypeInfo = module.getModuleTypeInfo();
        TypeConstructor typeCons = currentModuleTypeInfo.getVisibleTypeConstructor(typeConstructorName);
        if (typeCons == null) {
            return false;
        }
           
        int nDataCons = typeCons.getNDataConstructors();
        if (nDataCons == 0) {
            return false;
        }

        boolean hasVisibleConstructor = false;

        for (int i = 0; i < nDataCons; ++i) {
           
            DataConstructor dataCons = typeCons.getNthDataConstructor(i);

            if (currentModuleTypeInfo.isEntityVisible(dataCons)) {
 
                int arity = dataCons.getArity();
                if (arity > 0) {
View Full Code Here

       
        // Type constructors.
        int constructorCount = moduleInfo.getNTypeConstructors();
        for (int i = 0; i < constructorCount; i++) {
           
            TypeConstructor typeConstructor = moduleInfo.getNthTypeConstructor(i);
            programFeatureNameSet.add(CALFeatureName.getScopedEntityFeatureName(typeConstructor));
           
            // Data constructors.
            int dataConstructorCount = typeConstructor.getNDataConstructors();
            for (int n = 0; n < dataConstructorCount; n++) {
                DataConstructor dataConstructor = typeConstructor.getNthDataConstructor(n);
                programFeatureNameSet.add(CALFeatureName.getScopedEntityFeatureName(dataConstructor));
            }
        }
       
       
View Full Code Here

                TypeExpr fieldTypeExpr = dcFieldTypeExprs[i];
                updateInputableImports(fieldTypeExpr);
                String dcFieldTypeConsName = "";
                TypeConsApp typeConsApp = fieldTypeExpr.rootTypeConsApp();
                if (typeConsApp != null) {
                    TypeConstructor tc = typeConsApp.getRoot();
                    dcFieldTypeConsName = tc.getName().toString();
                }

                String constructorArgTypeConsName = ((TypeExprDefn.TypeCons)argTypes[i]).getTypeConsName().toString();

               
View Full Code Here

TOP

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

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.