Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ModuleTypeInfo


        nameToEntityMap = new HashMap<String, GemEntity>();
        gemEntityList = new ArrayList<GemEntity>();

        // Populate entity map and list from the module.
        ModuleTypeInfo typeInfo = module.getModuleTypeInfo();

        if (typeInfo != null) {
   
            FunctionalAgent[] entities = typeInfo.getFunctionalAgents();
   
            for (int i = 0; i < entities.length; ++i) {
                FunctionalAgent envEntity = entities [i];
                addGemEntity(new GemEntity(envEntity, virtualResourceManager));
            }
View Full Code Here


     * @param workspace
     * @param importedModuleName
     * @return ModuleTypeInfo the imported module or null if the module does not import a module with the given name.
     */
    public MetaModule getImportedModule(CALWorkspace workspace, ModuleName importedModuleName) {
        ModuleTypeInfo importedTypeInfo = module.getModuleTypeInfo().getImportedModule(importedModuleName);
        return importedTypeInfo == null ? null : workspace.getMetaModule(importedModuleName);
    }
View Full Code Here

     * This will be null if the type constructor is not visible or zero length if it has
     * 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);
            }
        }
       
        return dataConsList.toArray(new DataConstructor[0]);
View Full Code Here

     */
    public TypeConstructor[] getTypeConstructors() {

        List<TypeConstructor> types = new ArrayList<TypeConstructor>();
       
        ModuleTypeInfo moduleTypeInfo = getTypeInfo();
       
        for (int n = 0, numTypes = moduleTypeInfo.getNTypeConstructors(); n < numTypes; n++) {
            types.add(moduleTypeInfo.getNthTypeConstructor(n));
        }

        // check for types in the imported modules
       
        for (int n = 0, numImports = moduleTypeInfo.getNImportedModules(); n < numImports; n++) {
           
            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

     * @return boolean True if the type constructor exists and is an "enum" (ie. all data constructors take 0 arguments).
     * 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) {
                    return false;
                }
View Full Code Here

    public Set<CALFeatureName> getFeatureNames() {
        // CALFeatureNames for all features in the current program.
        Set<CALFeatureName> programFeatureNameSet = new HashSet<CALFeatureName>();
       
        // Grab the module names and feature names.
        ModuleTypeInfo moduleInfo = module.getModuleTypeInfo();
       
        // Module name.
        programFeatureNameSet.add(CALFeatureName.getModuleFeatureName(this));
       
        // Functional agents.
        FunctionalAgent[] entities = moduleInfo.getFunctionalAgents();
        for (final FunctionalAgent entity : entities) {
            programFeatureNameSet.add(CALFeatureName.getScopedEntityFeatureName(entity));
        }
       
        // 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));
            }
        }
       
       
        // Type classes.
        int classCount = moduleInfo.getNTypeClasses();
        for (int i = 0; i < classCount; i++) {
           
            TypeClass typeClass = moduleInfo.getNthTypeClass(i);
            programFeatureNameSet.add(CALFeatureName.getScopedEntityFeatureName(typeClass));
           
            // Class methods.
            int methodCount = typeClass.getNClassMethods();
            for (int n = 0; n < methodCount; n++) {
                programFeatureNameSet.add(CALFeatureName.getScopedEntityFeatureName(typeClass.getNthClassMethod(n)));
            }
        }
       
        // Class instances.
        int instanceCount = moduleInfo.getNClassInstances();
        for (int n = 0; n < instanceCount; n++) {
           
            ClassInstance instance = moduleInfo.getNthClassInstance(n);
            programFeatureNameSet.add(CALFeatureName.getClassInstanceFeatureName(instance));
           
            // Instance methods.
            TypeClass typeClass = instance.getTypeClass();
            int methodCount = typeClass.getNClassMethods();
View Full Code Here

        undoableEditSupport.beginUpdate();
       
        //this is a record field selection gem for which the field has been updated by the connection
        RecordFieldSelectionGem modifiedRecordFieldSelectionGem=null;
       
        ModuleTypeInfo currentModuleTypeInfo = getCurrentModuleTypeInfo();

        //is connection possible as a normal connection or value gem connection
        canConnect = GemGraph.isCompositionConnectionValid(srcPart, destPart, currentModuleTypeInfo) ||
                     GemGraph.isDefaultableValueGemSource(srcPart, destPart, gemCutter.getConnectionContext());
          
View Full Code Here

     * @return A string that will be rendered as part of a gem node in the explorer tree
     */       
    protected String getGemDisplayString(Gem gem) {
        // different icons and text for each type of gem
        if (gem instanceof FunctionalAgentGem) {
            ModuleTypeInfo currentModuleTypeInfo = tableTopExplorerOwner.getCurrentModuleTypeInfo();
            if (currentModuleTypeInfo == null) {
                return null;
            }
            ScopedEntityNamingPolicy namingPolicy = new UnqualifiedUnlessAmbiguous(currentModuleTypeInfo);
            FunctionalAgentGem functionalAgentGem = (FunctionalAgentGem) gem;
View Full Code Here

        if (inputPolicies == null) {
            inputPolicies = new InputPolicy[0];
        }
        // Get supercombinator defined at the current target and its name
        ModuleTypeInfo currentModuleTypeInfo = getWorkspaceManager().getWorkspace().getMetaModule(getTargetModule()).getTypeInfo();
        AdjunctSource scDef = target.getTargetDef(null, currentModuleTypeInfo);

        CompilerMessageLogger logger = new MessageLogger ();
        TypeExpr targetTypeExpr = getTypeChecker().checkFunction(scDef, targetModule, logger);
       
View Full Code Here

        }
       
        this.foreignClassLoader = foreignClassLoader;
        functionNameToFunctionMap = new HashMap<String, MachineFunction>();
        adjunctFunctionNameToFunctionMap = new HashMap<String, MachineFunction>();
        moduleTypeInfo = new ModuleTypeInfo(name, this);
    }
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.