Package org.openquark.cal.compiler

Examples of org.openquark.cal.compiler.ForeignTypeInfo


            }
            visitedModules.add(module);
           
            for (int i = 0, n = module.getNTypeConstructors(); i < n; ++i) {
                TypeConstructor tc = module.getNthTypeConstructor(i);
                ForeignTypeInfo fti = tc.getForeignTypeInfo();
                if (fti == null) {
                    continue;
                }
               
                JavaTypeName foreignType = JavaTypeName.make(fti.getForeignType());
                for (int j = 0, k = javaTypes.length; j < k; ++j) {
                    if (typeConstructors[j] != null) {
                        continue;
                    }
                    if (foreignType.equals(javaTypes[j])) {
View Full Code Here


    /**
     * Generate implementation info for foreign type (if the implementation type is visible).
     * @param typeConstructor the type constructor, which may or may not correspond to a foreign type.
     */
    private void generateForeignTypeInfo(TypeConstructor typeConstructor) {
        ForeignTypeInfo foreignTypeInfo = typeConstructor.getForeignTypeInfo();
        if (foreignTypeInfo != null) {
           
            Scope implScope = foreignTypeInfo.getImplementationVisibility();
            if (filter.shouldAcceptBasedOnScopeOnly(implScope)) {
               
                try {
                    String className = JavaTypeName.getFullJavaSourceName(foreignTypeInfo.getForeignType());
                   
                    currentPage
                        .openTag(HTML.Tag.DL, classAttribute(getScopeStyleClass(implScope)))
                        .addTaggedText(HTML.Tag.DT, classAttribute(StyleClassConstants.ATTRIBUTE_HEADER), LocalizableUserVisibleString.IMPLEMENTATION_VISIBILITY_COLON.toResourceString())
                        .addTaggedText(HTML.Tag.DD, implScope.toString())
View Full Code Here

                        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.
View Full Code Here

        final QualifiedName typeName = QualifiedName.makeFromCompoundName(qualifiedTypeConsName);

        //fetch the Class object from the type's ForeignTypeInfo

        final ForeignTypeInfo foreignTypeInfo =
            program
            .getModule(typeName.getModuleName())
            .getModuleTypeInfo()
            .getTypeConstructor(typeName.getUnqualifiedName())
            .getForeignTypeInfo();

        if (foreignTypeInfo != null) {
            return foreignTypeInfo.getForeignType();
        }

        return null;      
    }
View Full Code Here

            if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {               
                return true;
            }
   
            if(typeConsApp.getForeignTypeInfo() != null) {
                ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                Class<?> foreignClass = fti.getForeignType();
                if(foreignClass.isPrimitive() && foreignClass != void.class) {
                    return true;
                }
               
                if (foreignClass == java.lang.String.class) {
View Full Code Here

               
                return makeBoolean;
            }

            if(typeConsApp.getForeignTypeInfo() != null) {
                ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                Class<?> foreignClass = fti.getForeignType();
               
                // We handle the primitive Java types, excluding void.
                if(foreignClass.isPrimitive() && foreignClass != void.class) {
                    MethodVariable mv = new MethodVariable(argName);
                    String funcName;
View Full Code Here

            if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {
                return JavaTypeName.BOOLEAN;
            }

            if(typeConsApp.getForeignTypeInfo() != null) {
                ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                Class<?> foreignClass = fti.getForeignType();
                if(foreignClass.isPrimitive() && foreignClass != void.class) {
                    if (foreignClass == boolean.class) {
                        return JavaTypeName.BOOLEAN;
                    } else if (foreignClass == byte.class) {
                        return JavaTypeName.BYTE;
View Full Code Here

                if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {
                    return JavaTypeName.BOOLEAN;
                }

                if(typeConsApp.getForeignTypeInfo() != null) {
                    ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                    return JavaTypeName.make (SCJavaDefn.getForeignType(fti));
                }

                if (LECCMachineConfiguration.TREAT_ENUMS_AS_INTS) {
                    if (isEnumDataType (typeConsApp)) {
View Full Code Here

        visitedModules.add(module);
       
        for (int i = 0, n = module.getNTypeConstructors(); i < n; ++i) {
            TypeConstructor tc = module.getNthTypeConstructor(i);
           
            ForeignTypeInfo fti = tc.getForeignTypeInfo();
            if (fti == null) {
                continue;
            }
           
            JavaTypeName foreignType = JavaTypeName.make(fti.getForeignType());
            if (javaType.equals(foreignType)) {
                return tc;
            }
        }
       
View Full Code Here

                if (typeConsApp.isNonParametricType(CAL_Prelude.TypeConstructors.Boolean)) {
                    return JavaTypeName.BOOLEAN;
                }
                   
                if(typeConsApp.getForeignTypeInfo() != null) {
                    ForeignTypeInfo fti = typeConsApp.getForeignTypeInfo();
                    return JavaTypeName.make (fti.getForeignType());
                }

                TypeConstructor typeConstructor = typeConsApp.getRoot();

                JavaTypeName typeName = (JavaTypeName)typeToClassMappings.get(typeConstructor.getName());
View Full Code Here

TOP

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

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.