Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ModuleTypeInfo


    /**
     * Generates the short description for a module.
     * @param moduleName the module to be described.
     */
    private void generateShortDescriptionForModule(final ModuleName moduleName) {
        ModuleTypeInfo moduleTypeInfo = programModelManager.getModuleTypeInfo(moduleName);
        CALFeatureMetadata metadata = getMetadata(CALFeatureName.getModuleFeatureName(moduleName), getLocale());
        CALDocComment docComment = moduleTypeInfo.getCALDocComment();

        generateShortDescription(metadata, docComment, new ReferenceGenerator(MODULES_SUBDIRECTORY));
    }
View Full Code Here


                }
            } else if (!typeExpr.isFunctionType()) {
                if (tca != null) {
                    TypeConstructor tc = tca.getRoot();
                    // Ignore functions
                    ModuleTypeInfo m = findModuleWithClassInstance(CAL_Prelude.TypeClasses.Inputable, tc.getName());
                    if (m != null) {
                        inputableImports.add(m.getModuleName());
                    } else if (!tc.getName().getModuleName().equals(module.getModuleName())){
                        // Create a module name based on our naming.
                        ModuleName mn =
                            ModuleName.make(
                                    tc.getName().getModuleName().toString() + "_JavaIO");
View Full Code Here

                    }
                }
            }

            for (int i = 0, n = module.getNImportedModules(); i < n; ++i) {
                ModuleTypeInfo mti = module.getNthImportedModule(i);
                ModuleTypeInfo ci = findModuleWithClassInstance(className, typeConstructorName, mti, visitedModules);
                if (ci != null) {
                    return ci;
                }
            }
           
View Full Code Here

                    return module.getModuleName();
                }
            }
           
            for (int i = 0, n = module.getNImportedModules(); i < n; ++i) {
                ModuleTypeInfo importedModule = module.getNthImportedModule(i);
                ModuleName mn = findModuleContainingType(visitedModules, typeName, importedModule);
                if (mn != null) {
                    return mn;
                }
            }
View Full Code Here

                    }
                }
            }
           
            for (int i = 0, n = module.getNImportedModules(); i < n; ++i) {
                ModuleTypeInfo importedModule = module.getNthImportedModule(i);
                findTypeConstructorForJavaClass(javaTypes, typeConstructors, importedModule, visitedModules);
            }
        }
View Full Code Here

        TypeExpr valueNodeArgTypes[] = new TypeExpr[nArgs];
        for (int i = 0; i < nArgs; i++) {
            valueNodeArgTypes[i] = argValues[i].getTypeExpr();
        }
       
        ModuleTypeInfo currentModuleTypeInfo = getWorkspaceManager().getWorkspace().getMetaModule(targetModule).getTypeInfo();
        TypeExpr[] specializedTargetTypePieces;
        try {       
            specializedTargetTypePieces = TypeExpr.patternMatchPieces(valueNodeArgTypes, targetTypePieces, currentModuleTypeInfo);
        } catch (TypeException te){
            // What to do?
View Full Code Here

     * AUTOBURN_MULTIPLE means we didn't do anything because there was more than one burn possibility.
     * AUTOBURN_IMPOSSIBLE means we didn't do anything because the gems can't connect even if burned.
     */
    AutoburnLogic.AutoburnAction handleAutoburnGemGesture(Gem thisGem, TypeExpr typeToUnify, boolean burn) {

        ModuleTypeInfo currentModuleTypeInfo = tableTop.getCurrentModuleTypeInfo();

        // If the gem can't have inputs check if it is connectable.
        int numArgs = thisGem.getNInputs();
        if (numArgs == 0 || thisGem instanceof CollectorGem) {
           
View Full Code Here

        /// Perform basic existence checks on the documented entities
        //
       
        AbstractDocumentationGenerator.DocLabelMaker labelMaker = new AbstractDocumentationGenerator.DocLabelMaker();
       
        ModuleTypeInfo moduleInfo = leccCALServices.getWorkspaceManager().getModuleTypeInfo(moduleName);
       
        HashSet<String> labels = new HashSet<String>();
       
        // Gather all the labels, which will be used as a checklist later to see whether all the labels have
        // corresponding entries generated.
        for (int i = 0, n = moduleInfo.getNFunctions(); i < n; i++) {
            Function function = moduleInfo.getNthFunction(i);
           
            if (parent.isDocForFunctionOrClassMethodGenerated(function.getName().getModuleName(), function.getName().getUnqualifiedName())) {
                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));
                    }
                }
            }
        }
       
        for (int i = 0, n = moduleInfo.getNTypeClasses(); i < n; i++) {
            TypeClass typeClass = moduleInfo.getNthTypeClass(i);
           
            if (parent.isDocForTypeClassGenerated(typeClass.getName().getModuleName(), typeClass.getName().getUnqualifiedName())) {
                labels.add(labelMaker.getLabel(typeClass));
               
                for (int j = 0, m = typeClass.getNClassMethods(); j < m; j++) {
                    ClassMethod method = typeClass.getNthClassMethod(j);
                    if (parent.isDocForFunctionOrClassMethodGenerated(method.getName().getModuleName(), method.getName().getUnqualifiedName())) {
                        labels.add(labelMaker.getLabel(method));
                    }
                }
            }
        }
       
        for (int i = 0, n = moduleInfo.getNClassInstances(); i < n; i++) {
            ClassInstance instance = moduleInfo.getNthClassInstance(i);
            TypeClass typeClass = instance.getTypeClass();
           
            if (parent.isDocForClassInstanceGenerated(instance)) {
                labels.add(labelMaker.getLabel(instance));
               
View Full Code Here

     * Tests the method WorkspaceManager.getModuleTypeInfo(). The workspace
     * manager should be able to return the module type info for the Prelude
     * module.
     */
    public void testGetModuleTypeInfo() {
        ModuleTypeInfo mti = workspaceManager.getModuleTypeInfo(CAL_Prelude.MODULE_NAME);
        assertNotNull(mti);
        assertEquals(CAL_Prelude.MODULE_NAME, mti.getModuleName());
    }
View Full Code Here

            // Iterate over the modules.
            for (int i = 0, nMetaModules = workspace.getNMetaModules(); i < nMetaModules; i++) {
                MetaModule metaModule = workspace.getNthMetaModule(i);
               
                // We're only interested in modules which are compiled.
                ModuleTypeInfo moduleTypeInfo = metaModule.getTypeInfo();
                if (moduleTypeInfo == null) {
                    // Not compiled.
                    continue;
                }
               
                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,
                        //   we choose the type in the module which is "closest" to the Prelude.
                        // For now, this distance is approximated by the number of imports in the module.
                        // TODOEL: Later, we can figure out the size of the import graph.
                        QualifiedName existingMappedName = classToTypeConsNameMap.get(foreignType);
                        if (existingMappedName == null) {
                            // Add a new mapping.
                            classToTypeConsNameMap.put(foreignType, calName);
                            continue;
                        }
                        // a mapping already exists.
                        ModuleTypeInfo existingMappingModuleTypeInfo = workspace.getMetaModule(existingMappedName.getModuleName()).getTypeInfo();
                        if (existingMappingModuleTypeInfo == null) {
                            // Existing mapping's type info not compiled.
                            continue;
                        }
                        int existingMappingNImports = existingMappingModuleTypeInfo.getNImportedModules();
                       
                        if (nImports < existingMappingNImports) {
                            // override the existing mapping.
                            classToTypeConsNameMap.put(foreignType, calName);
                            continue;
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.